void UpdateReflectionCubemap( TextureUnitState textureUnitState, Vec3 objectWorldPosition )
        {
            string textureName = "";

            //get cubemap from CubemapZone's
            if( Map.Instance != null )
            {
                Map.Instance.GetObjects( new Bounds( objectWorldPosition ), delegate( MapObject obj )
                {
                    CubemapZone zone = obj as CubemapZone;
                    if( zone != null && !zone.GlobalZone )
                        textureName = zone.GetTextureName();
                } );

                if( string.IsNullOrEmpty( textureName ) )
                {
                    CubemapZone zone = CubemapZone.GetGlobalZone();
                    if( zone != null )
                        textureName = zone.GetTextureName();
                }
            }

            //get cubemap from SkyBox
            if( string.IsNullOrEmpty( textureName ) )
                textureName = SceneManager.Instance.GetSkyBoxTextureName();

            //update state
            textureUnitState.SetCubicTextureName( textureName, true );
        }
Exemple #2
0
        void UpdateReflectionCubemap( TextureUnitState textureUnitState, Vec3 objectWorldPosition )
        {
            string textureName = "";

            Vec4 reflectionParallax_cubemapPosition = Vec4.Zero;
            Vec3 reflectionParallax_rotationScale0 = Vec3.Zero;
            Vec3 reflectionParallax_rotationScale1 = Vec3.Zero;
            Vec3 reflectionParallax_rotationScale2 = Vec3.Zero;
            Vec3 reflectionParallax_position = Vec3.Zero;

            //get cubemap from CubemapZone's
            if( Map.Instance != null )
            {
                CubemapZone zone = CubemapZone.GetZoneForPoint( objectWorldPosition, true );
                if( zone != null )
                {
                    textureName = zone.GetTextureName();
                    reflectionParallax_cubemapPosition = new Vec4( zone.Position, 0 );
                }

                CubemapZone_BoxParallaxCorrectedZone zone2 = CubemapZone_BoxParallaxCorrectedZone.GetZoneForPoint( objectWorldPosition, 1 );
                if( zone2 != null )
                {
                    Mat3 mat = zone2.GetCachedRotationScaleInverseMatrix();
                    //Mat3 mat = zone2.Rotation.ToMat3() * Mat3.FromScale( zone2.Scale * .5f );
                    //mat = mat.GetInverse();

                    mat.Transpose();
                    reflectionParallax_rotationScale0 = mat[ 0 ];
                    reflectionParallax_rotationScale1 = mat[ 1 ];
                    reflectionParallax_rotationScale2 = mat[ 2 ];
                    reflectionParallax_position = zone2.Position;

                    //enable parallax correction
                    reflectionParallax_cubemapPosition.W = 1;
                }
            }

            UpdateReflectionBoxParallaxCorrectedCubemapsGpuParameters( reflectionParallax_cubemapPosition,
                reflectionParallax_rotationScale0, reflectionParallax_rotationScale1, reflectionParallax_rotationScale2,
                reflectionParallax_position );

            //get cubemap from SkyBox
            if( string.IsNullOrEmpty( textureName ) )
                textureName = SceneManager.Instance.GetSkyBoxTextureName();

            //update state
            textureUnitState.SetCubicTextureName( textureName, true );
        }
		void UpdateReflectionCubemap( TextureUnitState textureUnitState, Vec3 objectWorldPosition )
		{
			string textureName = "";

			//get cubemap from CubemapZone's
			if( Map.Instance != null )
			{
				CubemapZone zone = CubemapZone.GetZoneForPoint( objectWorldPosition, true );
				if( zone != null )
					textureName = zone.GetTextureName();
			}

			//get cubemap from SkyBox
			if( string.IsNullOrEmpty( textureName ) )
				textureName = SceneManager.Instance.GetSkyBoxTextureName();

			//update state
			textureUnitState.SetCubicTextureName( textureName, true );
		}