CreateChildSceneNode() public method

Creates a new child scene node.
public CreateChildSceneNode ( ) : SceneNode
return SceneNode
Esempio n. 1
0
        public MultiLights(SceneManager pSceneManager, SceneNode pCamNode, MovingObject pPlayerShip, Int32 pNumberOfLights)
        {
            oldCamLightColor = CamLightColor = new ColorEx(0.13f, 0.1f, 0.05f);
            PlayerLightColor = ColorEx.White;
            camLights = new List<Light>(pNumberOfLights);

            innerLights = (Int32)Math.Round(pNumberOfLights / 3.0f, MidpointRounding.AwayFromZero);
            outerLights = pNumberOfLights - innerLights;

            // create the playership's light.
            playerLight = pSceneManager.CreateLight("playerSpotLight");
            playerLight.Type = LightType.Spotlight;
            playerLight.Diffuse = PlayerLightColor;
            playerLight.Specular = ColorEx.White;
            playerLight.SetSpotlightRange(0.0f, 120.0f);
            playerLight.Direction = Vector3.NegativeUnitZ;

            playerLightNode = pPlayerShip.Node.CreateChildSceneNode();
            playerLightNode.AttachObject(playerLight);
            playerLightNode.Position = new Vector3(0, 0, 0);
            playerLightNode.SetDirection(new Vector3(1, 0, 0), TransformSpace.Local);

            // create the camera spotlights around the camera's direction.
            camInnerLightNode = pCamNode.CreateChildSceneNode();
            camInnerLightNode.Position = new Vector3(0, 0, 0);
            camOuterLightNode = pCamNode.CreateChildSceneNode();
            camOuterLightNode.Position = new Vector3(0, 0, 0);

            for (var i = 0; i < innerLights; i++)
            {
                var light = pSceneManager.CreateLight("camInnerLight " + (i + 1));
                light.Type = LightType.Spotlight;
                light.Diffuse = CamLightColor;
                light.Specular = ColorEx.White;
                light.SetSpotlightRange(0.0f, 25.0f);
                light.Direction = Quaternion.FromAngleAxis(360.0 * i / innerLights * Constants.DegreesToRadians, Vector3.UnitZ) *
                    Quaternion.FromAngleAxis(10.0 * Constants.DegreesToRadians, Vector3.UnitX) *
                    Vector3.NegativeUnitZ;

                camLights.Add(light);
                camInnerLightNode.AttachObject(light);
            }
            for (var i = 0; i < outerLights; i++)
            {
                var light = pSceneManager.CreateLight("camOuterLight " + (i + 1));
                light.Type = LightType.Spotlight;
                light.Diffuse = CamLightColor;
                light.Specular = ColorEx.White;
                light.SetSpotlightRange(0.0f, 25.0f);
                light.Direction = Quaternion.FromAngleAxis(360.0 * i / outerLights * Constants.DegreesToRadians, Vector3.UnitZ) *
                    Quaternion.FromAngleAxis(20.0 * Constants.DegreesToRadians, Vector3.UnitX) *
                    Vector3.NegativeUnitZ;

                camLights.Add(light);
                camOuterLightNode.AttachObject(light);
            }
        }
        protected override void CreateScene()
        {
            // set some ambient light
            scene.AmbientLight = ColorEx.Gray;

            // create an entity to have follow the path
            Entity ogreHead = scene.CreateEntity("OgreHead", "ogrehead.mesh");

            // create a scene node for the entity and attach the entity
            SceneNode headNode = scene.RootSceneNode.CreateChildSceneNode();
            headNode.AttachObject(ogreHead);

            //             // create a cool glowing green particle system
            //             ParticleSystem greenyNimbus = ParticleSystemManager.Instance.CreateSystem("GreenyNimbus", "ParticleSystems/GreenyNimbus");
            //             scene.RootSceneNode.CreateChildSceneNode().AttachObject(greenyNimbus);
            ParticleSystem fireworks = ParticleSystemManager.Instance.CreateSystem("Fireworks", "Examples/Fireworks");
            scene.RootSceneNode.CreateChildSceneNode().AttachObject(fireworks);

            // shared node for the 2 fountains
            fountainNode = scene.RootSceneNode.CreateChildSceneNode();

            // create the first fountain
            ParticleSystem fountain1 = ParticleSystemManager.Instance.CreateSystem("Fountain1", "Examples/PurpleFountain");
            SceneNode node = fountainNode.CreateChildSceneNode();
            node.Translate(new Vector3(200, -100, 0));
            node.Rotate(Vector3.UnitZ, 20);
            node.AttachObject(fountain1);

            // create the second fountain
            ParticleSystem fountain2 = ParticleSystemManager.Instance.CreateSystem("Fountain2", "Examples/PurpleFountain");
            node = fountainNode.CreateChildSceneNode();
            node.Translate(new Vector3(-200, -100, 0));
            node.Rotate(Vector3.UnitZ, -20);
            node.AttachObject(fountain2);

            // create a rainstorm
            ParticleSystem rain = ParticleSystemManager.Instance.CreateSystem("Rain", "Examples/Rain");
            scene.RootSceneNode.CreateChildSceneNode(new Vector3(0, 1000, 0), Quaternion.Identity).AttachObject(rain);
            rain.FastForward(5.0f);

            // Aureola around Ogre perpendicular to the ground
            ParticleSystem pSys5 = ParticleSystemManager.Instance.CreateSystem("Aureola",
                "Examples/Aureola");
            scene.RootSceneNode.CreateChildSceneNode().AttachObject(pSys5);

            // Set nonvisible timeout
            ParticleSystem.DefaultNonVisibleUpdateTimeout = 5;
        }
Esempio n. 3
0
		/// <summary>
		/// 
		/// </summary>
		protected override void SetupContent()
		{

			SceneManager.SetSkyBox( true, "Examples/EveningSkyBox", 5000 );

			// dim orange ambient and two bright orange lights to match the skybox
			SceneManager.AmbientLight = new ColorEx( 0.3f, 0.2f, 0.0f );
			Light light = SceneManager.CreateLight( "Light1" );
			light.Position = new Vector3( 2000, 1000, -1000 );
			light.Diffuse = new ColorEx( 1.0f, 0.5f, 0.0f );
			light = SceneManager.CreateLight( "Light2" );
			light.Position = new Vector3( 2000, 1000, 1000 );
			light.Diffuse = new ColorEx( 1.0f, 0.5f, 0.0f );

			_pivot = SceneManager.RootSceneNode.CreateChildSceneNode(); // create a pivot node

			// create a child node and attach ogre head and some smoke to it
			SceneNode headNode = _pivot.CreateChildSceneNode( new Vector3( 100, 0, 0 ) );
			headNode.AttachObject(  SceneManager.CreateEntity( "Head", "ogrehead.mesh" ) );
			headNode.AttachObject( ParticleSystemManager.Instance.CreateSystem( "Smoke", "Examples/Smoke" ) );

			Camera.Position = new Vector3( 0.0f, 30.0f, 350.0f );

			base.SetupContent();
		}
Esempio n. 4
0
		public override void CreateScene()
		{
			if ( !Root.Instance.RenderSystem.Capabilities.HasCapability( Capabilities.VertexPrograms ) ||
				!Root.Instance.RenderSystem.Capabilities.HasCapability( Capabilities.FragmentPrograms ) )
			{

				throw new Exception( "Your hardware does not support vertex and fragment programs, so you cannot run this demo." );
			}

			// create a simple default point light
			Light light = scene.CreateLight( "MainLight" );
			light.Position = new Vector3( 20, 80, 50 );

			rotNode = scene.RootSceneNode.CreateChildSceneNode();
			rotNode.CreateChildSceneNode( new Vector3( 20, 40, 50 ), Quaternion.Identity ).AttachObject( light );

			Entity entity = scene.CreateEntity( "Head", "ogrehead.mesh" );

			camera.Position = new Vector3( 20, 0, 100 );
			camera.LookAt( Vector3.Zero );

			// eyes
			SubEntity subEnt = entity.GetSubEntity( 0 );
			subEnt.MaterialName = "Examples/CelShading";
			subEnt.SetCustomParameter( CustomShininess, new Vector4( 35.0f, 0.0f, 0.0f, 0.0f ) );
			subEnt.SetCustomParameter( CustomDiffuse, new Vector4( 1.0f, 0.3f, 0.3f, 1.0f ) );
			subEnt.SetCustomParameter( CustomSpecular, new Vector4( 1.0f, 0.6f, 0.6f, 1.0f ) );

			// skin
			subEnt = entity.GetSubEntity( 1 );
			subEnt.MaterialName = "Examples/CelShading";
			subEnt.SetCustomParameter( CustomShininess, new Vector4( 10.0f, 0.0f, 0.0f, 0.0f ) );
			subEnt.SetCustomParameter( CustomDiffuse, new Vector4( 0.0f, 0.5f, 0.0f, 1.0f ) );
			subEnt.SetCustomParameter( CustomSpecular, new Vector4( 0.3f, 0.5f, 0.3f, 1.0f ) );

			// earring
			subEnt = entity.GetSubEntity( 2 );
			subEnt.MaterialName = "Examples/CelShading";
			subEnt.SetCustomParameter( CustomShininess, new Vector4( 25.0f, 0.0f, 0.0f, 0.0f ) );
			subEnt.SetCustomParameter( CustomDiffuse, new Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
			subEnt.SetCustomParameter( CustomSpecular, new Vector4( 1.0f, 1.0f, 0.7f, 1.0f ) );

			// teeth
			subEnt = entity.GetSubEntity( 3 );
			subEnt.MaterialName = "Examples/CelShading";
			subEnt.SetCustomParameter( CustomShininess, new Vector4( 20.0f, 0.0f, 0.0f, 0.0f ) );
			subEnt.SetCustomParameter( CustomDiffuse, new Vector4( 1.0f, 1.0f, 0.7f, 1.0f ) );
			subEnt.SetCustomParameter( CustomSpecular, new Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );

			// add entity to the root scene node
			scene.RootSceneNode.CreateChildSceneNode().AttachObject( entity );

			window.GetViewport( 0 ).BackgroundColor = ColorEx.White;
		}
        public WaterPlane(float height, String name, SceneNode parentSceneNode)
        {
            this.height = height;
            this.name = name;

            // create a scene node
            if (parentSceneNode == null)
            {
                parentSceneNode = TerrainManager.Instance.RootSceneNode;
            }
            waterSceneNode = parentSceneNode.CreateChildSceneNode(name);

            // set up material
            material = TerrainManager.Instance.WaterMaterial;

            CastShadows = false;
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="camera"></param>
		private void SetupCamera( Camera cam )
		{
			// create a pivot at roughly the character's shoulder
			cameraPivot = cam.SceneManager.RootSceneNode.CreateChildSceneNode();
			// this is where the camera should be soon, and it spins around the pivot
			cameraGoal = cameraPivot.CreateChildSceneNode( new Vector3( 0, 0, 15 ) );
			// this is where the camera actually is
			cameraNode = cam.SceneManager.RootSceneNode.CreateChildSceneNode();
			cameraNode.Position = cameraPivot.Position + cameraGoal.Position;

			cameraPivot.SetFixedYawAxis( true );
			cameraGoal.SetFixedYawAxis( true );
			cameraNode.SetFixedYawAxis( true );

			// our model is quite small, so reduce the clipping planes
			cam.Near = 0.1f;
			cam.Far = 100;
			cameraNode.AttachObject( cam );
			pivotPitch = 0;
		}
        public WaterPlane(SceneNode parentSceneNode, XmlTextReader r)
        {
            FromXML(r);

            // create a scene node
            if (parentSceneNode == null)
            {
                parentSceneNode = TerrainManager.Instance.RootSceneNode;
            }
            waterSceneNode = parentSceneNode.CreateChildSceneNode(name);

            // set up material
            material = TerrainManager.Instance.WaterMaterial;
        }
Esempio n. 8
0
        /** Loads the landscape using parameters in the given in the constructor. */
        public void Load( ref SceneNode RootNode )
        {
            if ( isPreLoaded == false )
            {
                return;
            }

            if ( isLoaded == true )
            {
                return;
            }

            Texture.TextureManager.Instance.Load(tableX, tableZ);
            //create a root landscape node.
            pageNode = RootNode.CreateChildSceneNode( "Page." +  tableX.ToString() + "." + tableZ.ToString()  );
            // Set node position
            pageNode.Position = new Vector3( (float)iniX , 0.0f, (float)iniZ );

            tiles = new Tiles();
            for (long  i = 0; i < numTiles; i++ )
            {
                tiles.Add( new TileRow() );

                for (long  j = 0; j < numTiles; j++ )
                {
                    //Debug.WriteLine(String.Format("Page[{0},{1}][{2},{3}]",tableX,tableZ,i,j));

                    Tile.Tile tile = TileManager.Instance.GetTile();
                    if ( tile != null )
                    {
                        tiles[ i ].Add( tile );
                        tile.Init(ref pageNode,(int) tableX, (int)tableZ,(int) i, (int)j );
                    }
                    else
                    {
                        string err = "Error: Invalid Tile: Make sure the default TileManager size is set to WorldWidth * WorldHeight * 4. Try increasing MaxNumTiles in the configuration file.";
                        throw new ApplicationException(err);
                    }
                }
            }

            for (long  j = 0; j < numTiles; j++ )
            {
                for (long  i = 0; i < numTiles; i++ )
                {
                    if ( j != numTiles - 1 )
                    {
                        tiles[ i ][ j ].SetNeighbor( Neighbor.South, tiles[ i ][ j + 1 ] );
                        tiles[ i ][ j + 1 ].SetNeighbor( Neighbor.North, tiles[ i ][ j ] );
                    }
                    if ( i != numTiles - 1 )
                    {
                        tiles[ i ][ j ].SetNeighbor( Neighbor.East, tiles[ i + 1 ][ j ] );
                        tiles[ i + 1 ][ j ].SetNeighbor( Neighbor.West, tiles[ i ][ j ] );
                    }
                }
            }

            LinkTileNeighbors();
            pageNode.NeedUpdate();
            isLoaded = true;
        }
        /// <summary>
        /// Initialize the world manager
        /// </summary>
        public void Initialize(SceneManager sceneManager, ITerrainGenerator gen, ILODSpec clientLodSpec, SceneNode root)
        {
            Debug.Assert(!initialized, "Attempt to initialize already initialized TerrainManager");
            scene = sceneManager;
            terrainGenerator = gen;
            terrainGenerator.TerrainChanged += TerrainGenerator_OnTerrainChanged;
            lodSpec = clientLodSpec ?? defaultLODSpec;

            pageSize = lodSpec.PageSize;
            visPageRadius = lodSpec.VisiblePageRadius;
            pageArraySize = (visPageRadius * 2) + 1;

            // Compute the size of a "subPage", which is the same as the smalles tile size.
            // We assume that the page containing the camera will have the smallest sized tiles.
            subPageSize = pageSize / TilesPerPage(0);

            minMetersPerSample = lodSpec.MetersPerSample(Vector3.Zero, 0, 0);
            maxMetersPerSample = lodSpec.MetersPerSample(Vector3.Zero, visPageRadius, visPageRadius * pageSize / subPageSize);

            rootSceneNode = root;
            worldRootSceneNode = rootSceneNode.CreateChildSceneNode("TerrainRoot");
            oceanSceneNode = rootSceneNode.CreateChildSceneNode("OceanNode");

            terrainMaterialConfig = new AutoSplatConfig();

            terrainDecalManager = new TerrainDecalManager(pageArraySize);

            shadowConfig = new ShadowConfig(scene);

            oceanConfig = new OceanConfig();
            oceanConfig.ConfigChange += OceanConfigChanged;
            ocean = new OceanPage(oceanConfig);

            oceanSceneNode.AttachObject(ocean);
            //ocean.ShowBoundingBox = true;
            showOcean = true;

            detailVeg = new DetailVeg(65, rootSceneNode);

            // allocate the page array
            pages = new Page[pageArraySize, pageArraySize];

            InitPages();

            heightFieldsCreated = false;

            boundaries = new List<Boundary>();
            roads = new Roads();

            SpeedTreeWrapper.SetDropToBillboard(true);

            // make sure variables based on camera location are up to date
            CameraLocation = cameraLocation;

            // set up material used by water boundaries
            waterMaterial = MaterialManager.Instance.GetByName("MVSMWater");
            if (waterMaterial != null)
                waterMaterial.Load();

            initialized = true;
        }