public override void CreateScene()
{
scene.AmbientLight = ColorEx.Black;
// create a scene node
mainNode = scene.RootSceneNode.CreateChildSceneNode();
// Load the meshes with non-default HBU options
for ( int mn = 0; mn < entityMeshes.Length; mn++ )
{
Mesh mesh = MeshManager.Instance.Load( entityMeshes[ mn ], ResourceGroupManager.DefaultResourceGroupName,
BufferUsage.DynamicWriteOnly,
BufferUsage.StaticWriteOnly,
true, true, 1 ); //so we can still read it
short srcIdx, destIdx;
if ( !mesh.SuggestTangentVectorBuildParams( out srcIdx, out destIdx ) )
{
mesh.BuildTangentVectors( srcIdx, destIdx );
}
// Create entity
entities[ mn ] = scene.CreateEntity( "Ent" + mn.ToString(), entityMeshes[ mn ] );
// Attach to child of root node
mainNode.AttachObject( entities[ mn ] );
// Make invisible, except for index 0
if ( mn == 0 )
{
entities[ mn ].MaterialName = materialNames[ currentMaterial ];
}
else
{
entities[ mn ].IsVisible = false;
}
}
for ( int i = 0; i < NUM_LIGHTS; i++ )
{
lightPivots[ i ] = scene.RootSceneNode.CreateChildSceneNode();
lightPivots[ i ].Rotate( lightRotationAxes[ i ], lightRotationAngles[ i ] );
// Create a light, use default parameters
lights[ i ] = scene.CreateLight( "Light" + i.ToString() );
lights[ i ].Position = lightPositions[ i ];
lights[ i ].Diffuse = diffuseLightColors[ i ];
lights[ i ].Specular = specularLightColors[ i ];
lights[ i ].IsVisible = lightState[ i ];
// Attach light
lightPivots[ i ].AttachObject( lights[ i ] );
// Create billboard for light
lightFlareSets[ i ] = scene.CreateBillboardSet( "Flare" + i.ToString() );
lightFlareSets[ i ].MaterialName = "Particles/Flare";
lightPivots[ i ].AttachObject( lightFlareSets[ i ] );
lightFlares[ i ] = lightFlareSets[ i ].CreateBillboard( lightPositions[ i ] );
lightFlares[ i ].Color = diffuseLightColors[ i ];
lightFlareSets[ i ].IsVisible = lightState[ i ];
}
// move the camera a bit right and make it look at the knot
camera.MoveRelative( new Vector3( 50, 0, 20 ) );
camera.LookAt( new Vector3( 0, 0, 0 ) );
}