Esempio n. 1
0
		protected override void SetupContent()
		{
			// create a 3d line
			this._line = new Line3d( new Vector3( 0, 0, 30 ), Vector3.UnitY, 50, ColorEx.Blue );

			this._tri = new Triangle( new Vector3( -25, 0, 0 ), new Vector3( 0, 50, 0 ), new Vector3( 25, 0, 0 ), ColorEx.Red,
			                          ColorEx.Blue, ColorEx.Green );

			// create a node for the line
			var node = SceneManager.RootSceneNode.CreateChildSceneNode();
			var lineNode = node.CreateChildSceneNode();
			var triNode = node.CreateChildSceneNode();
			triNode.Position = new Vector3( 50, 0, 0 );

			// add the line and triangle to the scene
			lineNode.AttachObject( this._line );
			triNode.AttachObject( this._tri );

			// create a node rotation controller value, which will mark the specified scene node as a target of the rotation
			// we want to rotate along the Y axis for the triangle and Z for the line (just for the hell of it)
			var rotate = new NodeRotationControllerValue( triNode, Vector3.UnitY );
			var rotate2 = new NodeRotationControllerValue( lineNode, Vector3.UnitZ );

			// the multiply controller function will multiply the source controller value by the specified value each frame.
			var func = new MultipyControllerFunction( 50 );

			// create a new controller, using the rotate and func objects created above.  there are 2 overloads to this method.  the one being
			// used uses an internal FrameTimeControllerValue as the source value by default.  The destination value will be the node, which
			// is implemented to simply call Rotate on the specified node along the specified axis.  The function will mutiply the given value
			// against the source value, which in this case is the current frame time.  The end result in this demo is that if 50 is specified in the
			// MultiplyControllerValue, then the node will rotate 50 degrees per second.  since the value is scaled by the frame time, the speed
			// of the rotation will be consistent on all machines regardless of CPU speed.
			ControllerManager.Instance.CreateController( rotate, func );
			ControllerManager.Instance.CreateController( rotate2, func );

			// place the camera in an optimal position
			base.Camera.Position = new Vector3( 30, 30, 220 );
		}