public void setCastShadow ( boolean enableFlag ) { GVRSceneObject owner = getOwnerObject ( ) ; if ( owner != null ) { GVRShadowMap shadowMap = ( GVRShadowMap ) getComponent ( GVRRenderTarget . getComponentType ( ) ) ; if ( enableFlag ) { if ( shadowMap != null ) { shadowMap . setEnable ( true ) ; } else { float angle = ( float ) Math . acos ( getFloat ( "outer_cone_angle" ) ) * 2.0f ; GVRCamera shadowCam = GVRShadowMap . makePerspShadowCamera ( getGVRContext ( ) . getMainScene ( ) . getMainCameraRig ( ) . getCenterCamera ( ) , angle ) ; shadowMap = new GVRShadowMap ( getGVRContext ( ) , shadowCam ) ; owner . attachComponent ( shadowMap ) ; } mChanged . set ( true ) ; } else if ( shadowMap != null ) { shadowMap . setEnable ( false ) ; } } mCastShadow = enableFlag ; }
Enables or disabled shadow casting for a spot light . Enabling shadows attaches a GVRShadowMap component to the GVRSceneObject which owns the light and provides the component with an perspective camera for shadow casting .