Beispiel #1
0
		void DestroyPlane()
		{
			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;
			}
		}
Beispiel #2
0
		void CreatePlane()
		{
			DestroyPlane();

			string meshName;

			if( !string.IsNullOrEmpty( customMesh ) )
			{
				meshName = customMesh;
			}
			else
			{
				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();

			meshObject = SceneManager.Instance.CreateMeshObject( meshName );
			if( meshObject != null )
			{
				meshObject.SetMaterialNameForAllSubObjects( material.Name );
				meshObject.RenderQueueGroup = renderQueueGroup;

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

			needUpdatePlane = false;
		}