Axiom.Demos.Dot3Bump.CreateScene C# (CSharp) Method

CreateScene() public method

public CreateScene ( ) : void
return void
		public override void CreateScene()
		{
			// Check prerequisites first
			RenderSystemCapabilities caps = Root.Instance.RenderSystem.Capabilities;
			if ( !caps.HasCapability( Capabilities.VertexPrograms ) || !caps.HasCapability( Capabilities.FragmentPrograms ) )
			{
				throw new AxiomException( "Your card does not support vertex and fragment programs, so cannot run this demo. Sorry!" );
			}
			else
			{
				if ( !GpuProgramManager.Instance.IsSyntaxSupported( "arbfp1" ) &&
					!GpuProgramManager.Instance.IsSyntaxSupported( "ps_2_0" ) )
				{
					throw new AxiomException( "Your card does not support shader model 2, so cannot run this demo. Sorry!" );
				}
			}

			scene.AmbientLight = ColorEx.Black;

			// create scene node
			mainNode = scene.RootSceneNode.CreateChildSceneNode();

			// Load the meshes with non-default HBU options
			for ( int mn = 0; mn < NUM_ENTITIES; mn++ )
			{
				Mesh mesh = MeshManager.Instance.Load( entityMeshes[ mn ], ResourceGroupManager.DefaultResourceGroupName,
					BufferUsage.DynamicWriteOnly,
					BufferUsage.StaticWriteOnly,
					true, true, 1 ); //so we can still read it

				// Build tangent vectors, all our meshes use only 1 texture coordset
				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[ currentEntity, 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 ) );

			// show overlay
			Overlay pOver = OverlayManager.Instance.GetByName( "Example/DP3Overlay" );
			objectInfo = OverlayManager.Instance.Elements.GetElement( "Example/DP3/ObjectInfo" );
			materialInfo = OverlayManager.Instance.Elements.GetElement( "Example/DP3/MaterialInfo" );
			info = OverlayManager.Instance.Elements.GetElement( "Example/DP3/Info" );

			objectInfo.Text = "Current: " + entityMeshes[ currentEntity ];
			materialInfo.Text = "Current: " + materialNames[ currentEntity, currentMaterial ];
			if ( !caps.HasCapability( Capabilities.FragmentPrograms ) )
			{
				info.Text = "NOTE: Light colours and specular highlights are not supported by your card.";
			}
			pOver.Show();
		}