상속: HighLevelMaterial
예제 #1
0
        void DestroyPlane()
        {
            DestroyReflectionTexture();

            if( sceneNode != null )
            {
                sceneNode.Dispose();
                sceneNode = null;
            }
            if( meshObject != null )
            {
                meshObject.Dispose();
                meshObject = null;
            }
            if( meshPlane != null )
            {
                meshPlane.Dispose();
                meshPlane = null;
            }

            if( material != null )
            {
                material.Dispose();
                material = null;
            }
        }
예제 #2
0
        void CreatePlane()
        {
            if( RenderSystem.Instance.IsDeviceLost() )
                return;

            DestroyPlane();

            Viewport defaultViewport = RendererWorld.Instance.DefaultViewport;

            if( RenderSystem.Instance.HasShaderModel2() &&
                RenderSystem.Instance.Capabilities.UserClipPlanes &&
                ReflectionLevel != ReflectionLevels.None )
            {
                CreateReflectionTexture();
            }

            string meshName = MeshManager.Instance.GetUniqueName( "WaterPlane" );

            Vec2 tile;
            if( fixedPipelineMapTiling != 0 )
                tile = size / fixedPipelineMapTiling;
            else
                tile = new Vec2( 0, 0 );

            meshPlane = MeshManager.Instance.CreatePlane( meshName, new Plane( new Vec3( 0, 0, 1 ), 0 ),
                size, segments, true, 1, tile, new Vec3( 0, 1, 0 ) );

            //create material
            string materialName = MaterialManager.Instance.GetUniqueName( "_GeneratedWaterPlane" );
            material = (WaterPlaneHighLevelMaterial)HighLevelMaterialManager.Instance.
                CreateMaterial( materialName, "WaterPlaneHighLevelMaterial" );
            material.Init( this );
            material.UpdateBaseMaterial();

            //change material of mesh
            foreach( SubMesh subMesh in meshPlane.SubMeshes )
                subMesh.MaterialName = material.Name;

            meshObject = SceneManager.Instance.CreateMeshObject( meshName );
            meshObject.RenderQueueGroup = renderQueueGroup;

            sceneNode = new SceneNode();
            sceneNode.Attach( meshObject );
            sceneNode.Position = position;
            sceneNode.Visible = Visible;

            needUpdatePlane = false;
        }