/// <summary> /// /// </summary> /// <param name="zCoordinate">Lokalna wspo³rzêdna Z po³o¿enia liny</param> private void InitArrestingWire(float zCoordinate) { float z = zCoordinate; Vector3 position = new Vector3(1.4f, 0.55f, zCoordinate); SceneNode wireNode = mainNode.CreateChildSceneNode(name + "_ArrestingWire" + z + "Node", position); SceneNode lWireNode = wireNode.CreateChildSceneNode(name + "_LArrestingWire" + z + "Node", new Vector3(arrestingWiresSpan / 2.0f, 0.0f, 0.0f)); initLArrestingWire(lWireNode); SceneNode rWireNode = wireNode.CreateChildSceneNode(name + "_RArrestingWire" + z + "Node", new Vector3(-arrestingWiresSpan / 2.0f, 0.0f, 0.0f)); initRArrestingWire(rWireNode); Entity lWire = sceneMgr.CreateEntity(name + "_LArrestingWire" + z, "ArrestingWire.mesh"); Entity rWire = sceneMgr.CreateEntity(name + "_RArrestingWire" + z, "ArrestingWire.mesh"); lWire.CastShadows = false; rWire.CastShadows = false; lWireNode.AttachObject(lWire); rWireNode.AttachObject(rWire); arrestingWires.Add(wireNode); }
// Just override the mandatory create scene method public override void CreateScene() { // Set ambient light sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f); Entity ent = sceneMgr.CreateEntity("head", "ogrehead.mesh"); // Add entity to the root scene node sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent); // Green nimbus around Ogre //mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject( // mSceneMgr->createParticleSystem("Nimbus", "Examples/GreenyNimbus")); // Create some nice fireworks sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject( sceneMgr.CreateParticleSystem("Fireworks", "Examples/Fireworks")); // Create shared node for 2 fountains mFountainNode = sceneMgr.RootSceneNode.CreateChildSceneNode(); // fountain 1 ParticleSystem pSys2 = sceneMgr.CreateParticleSystem("fountain1", "Examples/PurpleFountain"); // Point the fountain at an angle SceneNode fNode = mFountainNode.CreateChildSceneNode(); fNode.Translate(200,-100,0); fNode.Rotate(Vector3.UNIT_Z, new Degree(20)); fNode.AttachObject(pSys2); // fountain 2 ParticleSystem pSys3 = sceneMgr.CreateParticleSystem("fountain2", "Examples/PurpleFountain"); // Point the fountain at an angle fNode = mFountainNode.CreateChildSceneNode(); fNode.Translate(-200,-100,0); fNode.Rotate(Vector3.UNIT_Z, new Degree(-20)); fNode.AttachObject(pSys3); // Create a rainstorm ParticleSystem pSys4 = sceneMgr.CreateParticleSystem("rain", "Examples/Rain"); SceneNode rNode = sceneMgr.RootSceneNode.CreateChildSceneNode(); rNode.Translate(0,1000,0); rNode.AttachObject(pSys4); // Fast-forward the rain so it looks more natural pSys4.FastForward(5); // Aureola around Ogre perpendicular to the ground ParticleSystem pSys5 = sceneMgr.CreateParticleSystem("Aureola", "Examples/Aureola"); sceneMgr.RootSceneNode.CreateChildSceneNode().AttachObject(pSys5); // Set nonvisible timeout ParticleSystem.DefaultNonVisibleUpdateTimeout = 5; }
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; }
// Just override the mandatory create scene method protected override void CreateScene() { this.mViewport.BackgroundColor = Color.Black; // Set ambient light mSceneManager.AmbientLight = Color.FromArgb(255, 125, 125, 125); Entity ent = mSceneManager.CreateEntity("head", "ogrehead.mesh"); // Add entity to the root scene node mSceneManager.GetRootSceneNode().CreateChildSceneNode().AttachObject(ent); // Green nimbus around Ogre ParticleSystem pSys1 = mSceneManager.CreateParticleSystem("Nimbus", "Examples/GreenyNimbus"); mSceneManager.GetRootSceneNode().CreateChildSceneNode().AttachObject(pSys1); // Create shared node for 2 fountains mFountainNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode(); // fountain 1 ParticleSystem pSys2 = mSceneManager.CreateParticleSystem("fountain1", "Examples/PurpleFountain"); // Point the fountain at an angle SceneNode fNode = mFountainNode.CreateChildSceneNode(); fNode.Translate(200, -100, 0); fNode.Rotate(Vector3.UnitZ, new Radian(new Degree(20))); fNode.AttachObject(pSys2); // fountain 2 ParticleSystem pSys3 = mSceneManager.CreateParticleSystem("fountain2", "Examples/PurpleFountain"); // Point the fountain at an angle fNode = mFountainNode.CreateChildSceneNode(); fNode.Translate(-200, -100, 0); fNode.Rotate(Vector3.UnitZ, new Radian(new Degree(-20))); fNode.AttachObject(pSys3); // Create a rainstorm ParticleSystem pSys4 = mSceneManager.CreateParticleSystem("rain", "Examples/Rain"); SceneNode rNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode(); rNode.Translate(0, 1000, 0); rNode.AttachObject(pSys4); // Fast-forward the rain so it looks more natural pSys4.FastForward(5); mCamera.SetPosition(0, 0, 200); mCamera.LookAt = new Vector3(0, 0, 0); }
protected virtual void initRegularBunker(SceneNode islandNode, float positionOnIsland) { String nameSuffix = tileID.ToString(); gunPlaceNode = islandNode.CreateChildSceneNode("GunEmplacement" + nameSuffix, new Vector3(0.0f, 0.1f, -7.0f)); gunPlaceNode.Translate(new Vector3(0.0f, levelTile.HitBound.LowestY, positionOnIsland)); if (!(LevelTile is FortressBunkerTile)) { Entity sandbags = sceneMgr.CreateEntity("Sandbags" + nameSuffix, "Sandbags.mesh"); gunPlaceNode.AttachObject(sandbags); } installationNode = gunPlaceNode.CreateChildSceneNode("BunkerNode" + nameSuffix, new Vector3(0.0f, 0.0f, 4.5f)); if (LevelTile is FortressBunkerTile) { installationEntity = sceneMgr.CreateEntity("Fortress" + nameSuffix, "Fortress.mesh"); } else { installationEntity = sceneMgr.CreateEntity("Bunker" + nameSuffix, "Bunker.mesh"); } isConcrete = false; if (LevelTile is ConcreteBunkerTile || LevelTile is FortressBunkerTile) { isConcrete = true; } if (LevelTile is ConcreteBunkerTile && !(LevelTile is FortressBunkerTile)) { installationEntity.SetMaterialName("Concrete"); // aby by³ betonowy } installationNode.AttachObject(installationEntity); string flakBaseMesh = "FlakBase.mesh"; string flakbarrelMesh = "FlakBarrel.mesh"; Entity flakBase = sceneMgr.CreateEntity("FlakBase" + nameSuffix, flakBaseMesh); gunPlaceNode.AttachObject(flakBase); flakBarrel = sceneMgr.CreateEntity("FlakBarrel" + nameSuffix, flakbarrelMesh); gunNode = gunPlaceNode.CreateChildSceneNode("FlakBarrelNode" + nameSuffix, new Vector3(0.0f, 0.5f, 0.0f)); gunNode.AttachObject(flakBarrel); }
public Boundary(String name) { points = new List <Vector2>(); semantics = new List <IBoundarySemantic>(); touchedPages = new List <PageCoord>(); this.name = name; sceneNode = parentSceneNode.CreateChildSceneNode(name); pageSize = TerrainManager.Instance.PageSize; }
protected virtual void initFlakBunker(SceneNode islandNode, float positionOnIsland) { String nameSuffix = tileID.ToString(); gunPlaceNode = islandNode.CreateChildSceneNode("GunEmplacement" + nameSuffix, new Vector3(0.0f, 0.1f, -3.5f)); gunPlaceNode.Translate(new Vector3(0.0f, levelTile.HitBound.LowestY, positionOnIsland)); gunPlaceNode.Scale(1.2f, 1.2f, 1.2f); yawGunPlaceNode = gunPlaceNode.CreateChildSceneNode("YawGunPlaceNode" + nameSuffix); SceneNode sandbagsNode = islandNode.CreateChildSceneNode("Sandbags1" + nameSuffix, gunPlaceNode.Position + new Vector3(0.0f, 0.1f, 3.0f)); sandbagsNode.Scale(2, 2, 2); sandbagsNode.Yaw(new Radian(new Degree(180))); sandbagsNode.AttachObject(sceneMgr.CreateEntity("Sandbags1" + nameSuffix, "Sandbags.mesh")); SceneNode sandbagsNode2 = islandNode.CreateChildSceneNode("Sandbags2" + nameSuffix, gunPlaceNode.Position + new Vector3(0.0f, 0.1f, -5.0f)); sandbagsNode2.Scale(2, 2, 2); sandbagsNode2.AttachObject(sceneMgr.CreateEntity("Sandbags2" + nameSuffix, "Sandbags.mesh")); isConcrete = true; string flakBaseMesh = "MegaFlakBase.mesh"; string flakbarrelMesh = "MegaFlakBarrel.mesh"; Entity flakBase = sceneMgr.CreateEntity("FlakBase" + nameSuffix, flakBaseMesh); yawGunPlaceNode.AttachObject(flakBase); flakBarrel = sceneMgr.CreateEntity("FlakBarrel" + nameSuffix, flakbarrelMesh); gunNode = yawGunPlaceNode.CreateChildSceneNode("FlakBarrelNode" + nameSuffix, new Vector3(0.0f, 1.0f, 0.0f)); gunNode.AttachObject(flakBarrel); installationNode = gunPlaceNode.CreateChildSceneNode("BunkerNode" + nameSuffix, new Vector3(0.0f, 0.0f, 4.5f)); installationNode.Scale(0.5f, 0.5f, 0.5f); installationEntity = sceneMgr.CreateEntity("Sandbags" + nameSuffix, "Sandbags.mesh"); installationNode.AttachObject(installationEntity); }
protected virtual void initReflector() { reflectorNode = gunPlaceNode.CreateChildSceneNode("ReflectorNode" + tileID, Vector3.ZERO); reflectorSubNodes = EffectsManager.Singleton.Reflector(sceneMgr, reflectorNode, new Vector3(0.0f, 1.5f, 0.0f), new Vector2(24, 10), true, tileID.ToString()); flickeringReflectorWhenDestroyed = UnitConverter.RandomGen.Next(0, 2) == 0; // 50% }
void CreateExtraLights() { _lightRootNode = _sceneManager.RootSceneNode.CreateChildSceneNode(); //Create 7 more lights for (var i = 0; i < 7; ++i) { SceneNode lightNode = _lightRootNode.CreateChildSceneNode(); Light light = _sceneManager.CreateLight(); light.Name = "Extra Point Light"; lightNode.AttachObject(light); light.Type = Light.LightTypes.LT_POINT; light.SetAttenuation(1000.0f, 1.0f, 0.0f, 1.0f); light.SetDiffuseColour( _randomizer.Next(255) / 255.0f * 0.25f, _randomizer.Next(255) / 255.0f * 0.25f, _randomizer.Next(255) / 255.0f * 0.25f); lightNode.Position = new Vector3( ((float)_randomizer.NextDouble() * 2.0f - 1.0f) * 60.0f, ((float)_randomizer.NextDouble() * 2.0f - 1.0f) * 10.0f, ((float)_randomizer.NextDouble() * 2.0f - 1.0f) * 60.0f); } }
public override void initOnScene(SceneNode parentNode, int tileCMVIndex, int compositeModelTilesNumber) { base.initOnScene(parentNode, tileCMVIndex, compositeModelTilesNumber); String nameSuffix = tileID.ToString(); float positionOnIsland = -getRelativePosition(parentNode, LevelTile); if (levelTile is BarrelTile) { installationNode = parentNode.CreateChildSceneNode("Barrels" + nameSuffix, new Vector3(0, 0.1f, positionOnIsland - 5.0f)); switch (LevelTile.Variant) { //Bez drzew case 0: initBarrel(installationNode, 4); break; case 1: initPalm(new Vector3(-0.8f, 0, -2)); initPalm(new Vector3(-0.6f, 0, 2)); initBarrel(installationNode, 3); break; } } }
private void InitializeNode() { _entity = _parentSceneManager.CreateEntity(_name, _meshName); _node = _parentNode.CreateChildSceneNode(_nodeName); _node.AttachObject(_entity); }
public SceneNode point3d(string name, int id, float x, float y, float z, SceneNode node, SceneManager sceneMgr) { Entity ent; if (node == null)//point of reference 0,0,0 { ManualObject aux = sceneMgr.CreateManualObject(); //ent = sceneMgr.CreateEntity(name + id, this.getNameEntities()); node = sceneMgr.RootSceneNode.CreateChildSceneNode(name + id + "Node", new Vector3(y, z, x)); node.AttachObject(aux); return(node); } else//create new point { float xAux = x; float yAux = y; SceneNode nodeAux; ent = sceneMgr.CreateEntity(name + id, getNameEntities()); nodeAux = node.CreateChildSceneNode(name + "Node_" + id, new Vector3(yAux, z, xAux)); nodeAux.AttachObject(ent); return(nodeAux); } }
protected void initBarrack(SceneNode islandNode, float positionOnIsland) { String nameSuffix = tileID.ToString(); installationEntity = sceneMgr.CreateEntity("Barracks" + nameSuffix, "Barracks.mesh"); installationNode = islandNode.CreateChildSceneNode("Barracks" + nameSuffix, new Vector3(0, 0, positionOnIsland - 5.0f)); installationNode.AttachObject(installationEntity); installationNode.Scale(new Vector3(1.0f, 1.2f, 1.0f)); installationNode.Translate(new Vector3(0.0f, levelTile.HitBound.LowestY, 0.0f)); if (LevelView.IsNightScene && EngineConfig.ShadowsQuality == 0) // cienie nie lubia innych zrodel swiatla :/ { InitLightFlare(new ColourValue(1f, 1f, 0.9f), new Vector3(0, 1.9f, -2.6f), new Vector2(1.5f, 1.5f)); } if (EngineConfig.DisplayingMinimap) { minimapItem = new MinimapItem(installationNode, framework.MinimapMgr, "Cube.mesh", new ColourValue(0, 0.8f, 0), installationEntity); minimapItem.ScaleOverride = new Vector2(0, 13); // stala wysokosc bunkra, niezale¿na od bounding box minimapItem.Refresh(); } }
/// <summary> /// /// </summary> /// <param name="sceneMgr"></param> /// <param name="parent"></param> /// <param name="localPosition"></param> public ParticleSystem Start(SceneManager sceneMgr, SceneNode parent, Vector3 localPosition, Vector3 direction, Vector2 defaultParticleSize, bool enabled) { ParticleSystem smokeSystem = null; SceneNode smokeNode = null; // if (!IsEmitting(sceneMgr, parent)) { if (sceneMgr.HasParticleSystem(parent.Name + systemName)) { smokeSystem = sceneMgr.GetParticleSystem(parent.Name + systemName); smokeNode = parent.GetChild(parent.Name + "_" + systemName + "Node") as SceneNode; } else { smokeSystem = sceneMgr.CreateParticleSystem(parent.Name + systemName, materialName); smokeNode = parent.CreateChildSceneNode(parent.Name + "_" + systemName + "Node", localPosition); smokeNode.AttachObject(smokeSystem); } } ParticleEmitter e = smokeSystem.GetEmitter(0); smokeNode.Position = localPosition; e.Direction = direction; e.Enabled = enabled; if (defaultParticleSize != Vector2.ZERO) { smokeSystem.SetDefaultDimensions(defaultParticleSize.x, defaultParticleSize.y); } return(smokeSystem); }
public FirstPersonModel(Character character, SceneNode eyeNode) : base(character) { this.EyeNode = eyeNode; WeaponSceneNode = EyeNode.CreateChildSceneNode(); WeaponCenterNode = WeaponSceneNode.CreateChildSceneNode(); }
protected override void CreateScene() { // create a 3d line Line3d line = new Line3d(new Vector3(0, 0, 30), Vector3.UnitY, 50, ColorEx.Blue); Triangle 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 SceneNode node = scene.RootSceneNode.CreateChildSceneNode(); SceneNode lineNode = node.CreateChildSceneNode(); SceneNode triNode = node.CreateChildSceneNode(); triNode.Position = new Vector3(50, 0, 0); // add the line and triangle to the scene lineNode.AttachObject(line); triNode.AttachObject(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) NodeRotationControllerValue rotate = new NodeRotationControllerValue(triNode, Vector3.UnitY); NodeRotationControllerValue rotate2 = new NodeRotationControllerValue(lineNode, Vector3.UnitZ); // the multiply controller function will multiply the source controller value by the specified value each frame. MultipyControllerFunction 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 camera.Position = new Vector3(30, 30, 220); window.DebugText = "Spinning triangle - Using custom built geometry"; }
public override void initOnScene(SceneNode parentNode, int tileCMVIndex, int compositeModelTilesNumber) { base.initOnScene(parentNode, tileCMVIndex, compositeModelTilesNumber); if (LevelTile is MiddleIslandTile) { installationNode = parentNode.CreateChildSceneNode("Middle" + tileID.ToString(), new Vector3(0, 0, -getRelativePosition(parentNode, LevelTile))); int variant = ((IslandTile)LevelTile).Variant; switch (variant) { case 0: break; // 3 palmy case 1: initPalm2(new Vector3(-1, 0, -6.5f)); initPalm(new Vector3(0.5f, 0, -5.6f)); initPalm(new Vector3(-1, 0, -4.4f)); break; // 4 palmy case 2: initPalm(new Vector3(-1, 0, -6)); initPalm2(new Vector3(1, 0, -5)); initPalm(new Vector3(1, 0, -7)); initPalm2(new Vector3(-1, 0, -4)); break; // flaga case 3: initFlag(new Vector3(0, 0, -4.5f)); break; // uniesione 3 palmy case 12: initPalm2(new Vector3(-1, 7.5f, -7.0f)); initPalm(new Vector3(0.5f, 7.5f, -5f)); initPalm(new Vector3(-1, 7.5f, -4.0f)); break; // uniesione 4 palmy case 13: initPalm(new Vector3(-1, 7.5f, -6)); initPalm2(new Vector3(1, 7.5f, -5)); initPalm(new Vector3(1, 7.5f, -6.5f)); initPalm2(new Vector3(-1, 7.5f, -4)); break; // uniesiona flaga case 14: initFlag(new Vector3(0, 6.5f, -4.5f)); break; } } }
public virtual void postInitOnScene() { if (EngineConfig.ExplosionLights && LevelView.IsNightScene) { string lightName = "Ammunition" + GetHashCode() + "_light"; if (sceneMgr.HasLight(lightName)) { explosionFlash = sceneMgr.GetLight(lightName); } else { explosionFlash = sceneMgr.CreateLight(lightName); } explosionFlash.Type = Light.LightTypes.LT_POINT; explosionFlash.SetAttenuation(15f, 0f, 1f, 0f); explosionFlash.DiffuseColour = new ColourValue(0.7f, 0.7f, 0.7f); explosionFlash.SpecularColour = new ColourValue(0.3f, 0.3f, 0.3f); explosionFlash.Visible = false; explosionFlash.CastShadows = false; } else { explosionFlash = null; } SceneNode flashNode = ammunitionNode.CreateChildSceneNode(new Vector3(0f, 2.5f, 0f)); if (EngineConfig.ExplosionLights && LevelView.IsNightScene) { if (!explosionFlash.IsAttached) { flashNode.AttachObject(explosionFlash); } explosionFlash.SetAttenuation(15f, 0f, 1f, 0f); explosionFlash.DiffuseColour = new ColourValue(0.7f, 0.7f, 0.7f); explosionFlash.SpecularColour = new ColourValue(0.3f, 0.3f, 0.3f); } if (EngineConfig.DisplayingMinimap && minimapItem != null) { minimapItem.Show(); } refreshPosition(); ammunitionNode.SetVisible(true, false); if (EngineConfig.ExplosionLights && LevelView.IsNightScene) { explosionFlash.Visible = false; } ammunitionNode._update(true, false); // inaczej bounding box zajmuje cala przestrzen zawarta miedzy starym polozeniem pocisku (-100000, -1000 costam) a nowym. Niszczy to cienie }
private void drawCircle(SceneNode p_Node, string name) { SceneNode l_ShoeTargetNode = p_Node.CreateChildSceneNode(p_Node.Name + name, new Vector3(0f, 0f, 0f)); Entity l_Entity = mSceneManager.CreateEntity(name, SceneManager.PrefabType.PT_SPHERE); l_Entity.SetMaterialName("Examples/Fish"); l_ShoeTargetNode.AttachObject(l_Entity); l_ShoeTargetNode.Scale(0.1f, 0.1f, 0.1f); }
private static void CreateTree(SceneManager sm, Vector3 offset) { Entity tree = sm.CreateEntity("tree01.mesh"); SceneNode treeNode = sm.RootSceneNode.CreateChildSceneNode(); SceneNode child1 = treeNode.CreateChildSceneNode(); child1.AttachObject(tree); child1.Rotate(Vector3.UNIT_X, Mogre.Math.HALF_PI); child1.Rotate(Vector3.UNIT_Z, Mogre.Math.HALF_PI / 2); Entity tree2 = sm.CreateEntity("tree01.mesh"); SceneNode child2 = treeNode.CreateChildSceneNode(); child2.AttachObject(tree2); child2.Rotate(Vector3.UNIT_X, Mogre.Math.HALF_PI); child2.Rotate(Vector3.UNIT_Z, Mogre.Math.HALF_PI / -2); treeNode.Scale(20, 20, 20); treeNode.Translate(offset.x, offset.y + 30, offset.z); }
protected override void CreateScene() { if (!Root.Instance.RenderSystem.Caps.CheckCap(Capabilities.VertexPrograms) || !Root.Instance.RenderSystem.Caps.CheckCap(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; }
/// <summary> /// Create the SceneNode and Entities associated with this renderable object. /// When overriding, create Entities first, then call base.Create(); /// After that, you can manipulate the node as necessary. /// </summary> /// <param name="sm">Scenemanager to add the scenenode to</param> /// /// <param name="cityNode">City Node to add a child to</param> public virtual void Create(SceneManager sm, SceneNode cityNode) { node = cityNode.CreateChildSceneNode(); foreach (Entity e in this.entities) { node.AttachObject(e); } node.SetScale(this.scale); node.Orientation = this.rotation; isVisible = true; }
public CompositeModelView(List <TileView> tileViews, IFrameWork framework, SceneNode parentNode, String name) { firstTileIndex = tileViews[0].LevelTile.TileIndex; this.tileViews = tileViews; this.framework = framework; this.parentNode = parentNode; sceneMgr = framework.SceneMgr; this.name = name; mainNode = parentNode.CreateChildSceneNode(name); }
public override void CreateScene() { SceneNode node1 = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Tutorial10Node"); // Create a point light Light l = base.sceneMgr.CreateLight("MainLight"); // Accept default settings: point light, white diffuse, just set position // Add light to the scene node SceneNode lightNode = base.sceneMgr.RootSceneNode.CreateChildSceneNode(); lightNode.CreateChildSceneNode(new Vector3(10, 10, 10)).AttachObject(l); MeshPtr pMesh = MeshManager.Singleton.Load("knot.mesh", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, HardwareBuffer.Usage.HBU_DYNAMIC_WRITE_ONLY, HardwareBuffer.Usage.HBU_STATIC_WRITE_ONLY, true, true);//can still read it //ushort src, dest; //if (!pMesh.SuggestTangentVectorBuildParams(VertexElementSemantic.VES_TANGENT, out src, out dest)) // pMesh.BuildTangentVectors(VertexElementSemantic.VES_TANGENT, src, dest); //create entity Entity entity = sceneMgr.CreateEntity("Tutorial10Entity", "knot.mesh"); entity.SetMaterialName("CgTutorials/C5E2_Material"); //attach to main node node1.AttachObject(entity); // set up spline animation of node Animation anim = sceneMgr.CreateAnimation("LightTrack", 10F); // Spline it for nice curves anim.SetInterpolationMode(Animation.InterpolationMode.IM_SPLINE); // Create a track to animate the camera's node NodeAnimationTrack track = anim.CreateNodeTrack(0, lightNode); // Setup keyframes TransformKeyFrame key = track.CreateNodeKeyFrame(0F); // startposition key = track.CreateNodeKeyFrame(2.5F); key.Translate = new Vector3(500F, 500F, -1000F); key = track.CreateNodeKeyFrame(5F); key.Translate = new Vector3(-1500F, 1000F, -600F); key = track.CreateNodeKeyFrame(7.5F); key.Translate = new Vector3(0F, 100F, 0F); key = track.CreateNodeKeyFrame(10F); key.Translate = new Vector3(0F, 0F, 0F); // Create a new animation state to track this animState = sceneMgr.CreateAnimationState("LightTrack"); animState.Enabled = true; }
/// <summary> /// /// </summary> private void CreateGeometry() { for (int k = 0; k < _numberOfBlocks; k++) { _geometryBlocks.Add(new GeometryBlock(_vclouds, _height.y, _alpha, _beta, _radius, _phie, _na, _nb, _nc, k)); _geometryBlocks[k].Create(); // Each geometry block must be in a different scene node, See: GeometryBlock::isInFrustum(Ogre::Camera *c) SceneNode sn = _sceneNode.CreateChildSceneNode(); sn.AttachObject(_geometryBlocks[k].Entity); } }
public UniqueParticleSystem(SceneManager sceneManager, SceneNode worldNode, string templateName) { ParticleSystem = sceneManager.CreateParticleSystem("UniqueParticleSystem" + Guid.NewGuid().ToString(), templateName); ReferenceEmitters = ParticleSystem.GetParticleEmitterEnumerable().ToArray(); foreach (ParticleEmitter emitter in ReferenceEmitters) emitter.Enabled = false; ParticleQuotaPerEmitter = ParticleSystem.ParticleQuota; SceneNode = worldNode.CreateChildSceneNode(); SceneNode.AttachObject(ParticleSystem); }
protected override void CreateScene() { _previousVisibilityFlags = MovableObject.DefaultVisibilityFlags; MovableObject.DefaultVisibilityFlags = RegularSurfaces; _workspace.SetListener(new CubeMapCompositorWorkspaceListener(this)); _sceneManager.SetSkyDome(true, "Examples/CloudySky"); // setup some basic lighting for our scene _sceneManager.AmbientLight = new ColourValue(0.3f, 0.3f, 0.3f); SceneNode lightNode = _sceneManager.RootSceneNode.CreateChildSceneNode(); lightNode.SetPosition(20, 80, 50); lightNode.AttachObject(_sceneManager.CreateLight()); CreateCubeMap(); // create an ogre head, give it the dynamic cube map material, and place it at the origin _head = _sceneManager.CreateEntity("ogrehead.mesh", ResourceGroupManager.AUTODETECT_RESOURCE_GROUP_NAME, SceneMemoryMgrTypes.SCENE_STATIC); _head.Name = "CubeMappedHead"; _head.SetMaterialName("Examples/DynamicCubeMap"); _head.VisibilityFlags = NonRefractiveSurfaces; _sceneManager.GetRootSceneNode(SceneMemoryMgrTypes.SCENE_STATIC).AttachObject(_head); _pivot = _sceneManager.RootSceneNode.CreateChildSceneNode(); // create a pivot node Entity fish = _sceneManager.CreateEntity("fish.mesh"); fish.Name = "Fish"; _fishSwim = fish.GetAnimationState("swim"); _fishSwim.Enabled = true; // create a child node at an offset and attach a regular ogre head and a nimbus to it SceneNode node = _pivot.CreateChildSceneNode(); node.SetPosition(-60, 10, 0); node.SetScale(7, 7, 7); node.Yaw(new Degree(90)); node.AttachObject(fish); // create a floor mesh resource using (var mesh = MeshManager.Singleton.CreatePlane("floor", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, new Plane(Vector3.UNIT_Y, -30), 1000, 1000, 10, 10, true, 1, 8, 8, Vector3.UNIT_Z)) { // create a floor entity, give it a material, and place it at the origin Entity floor = _sceneManager.CreateEntity("Floor", mesh, SceneMemoryMgrTypes.SCENE_STATIC); floor.SetMaterialName("Examples/BumpyMetal"); _sceneManager.GetRootSceneNode(SceneMemoryMgrTypes.SCENE_STATIC).AttachObject(floor); } }
public void TestChildSceneNodeRemoval() { SceneManager sceneManager = new BspSceneManager("Manager under test"); SceneNode node = sceneManager.CreateSceneNode("testNode"); SceneNode childNode = node.CreateChildSceneNode("childNode"); Assert.IsTrue(ManagerContainsNode(sceneManager, childNode), "A child node was created but not added to the scene graph."); node.RemoveChild(childNode.Name); Assert.IsTrue(ManagerContainsNode(sceneManager, childNode), "A child node was removed from its parent but also incorrectly removed from the scene graph."); }
public void TestChildSceneNodeDestruction() { SceneManager sceneManager = new PCZSceneManager("Manager under test"); SceneNode node = sceneManager.CreateSceneNode("testNode"); SceneNode childNode = node.CreateChildSceneNode("childNode"); Assert.IsTrue(ManagerContainsNode(sceneManager, childNode), "A child node was created but not added to the scene graph."); node.RemoveAndDestroyChild(childNode); Assert.IsFalse(ManagerContainsNode(sceneManager, childNode), "A child node was destroryed but not removed from the scene graph."); }
public Island(SceneNode node, API.Geo.World currentWorld) { this.mChunkList = new Dictionary <Vector3, Chunk>(); this.mNode = node; this.mWorld = currentWorld; this.blocksAdded = new List <PositionFaceAndStatus>(); this.blocksDeleted = new List <PositionFaceAndStatus>(); this.mFaceNode = node.CreateChildSceneNode(); }
public static SceneNode initPalm(SceneManager sceneMgr, SceneNode parent, Vector3 position, bool forceLowDetails, bool rayBasedY) { Entity palm; SceneNode palmNode; /* if(rayBasedY) * { * position = ViewHelper.GetVerticalRayIntersection(sceneMgr, parent, position); * }*/ int id = LevelView.PropCounter; if (EngineConfig.LowDetails || forceLowDetails) { palm = sceneMgr.CreateEntity("Palm" + id, "TwoSidedPlane.mesh"); palm.SetMaterialName("FakePalmTree"); } else { palm = sceneMgr.CreateEntity("Palm" + id, "PalmTree.mesh"); } palm.CastShadows = EngineConfig.ShadowsQuality > 0; palmNode = parent.CreateChildSceneNode("PalmNode" + LevelView.PropCounter, position); if (EngineConfig.LowDetails || forceLowDetails) { float angle = Math.RangeRandom(-Math.PI / 5, Math.PI / 5); palmNode.Yaw(Math.HALF_PI + angle); palmNode.Scale(0.5f, 1, 1); palmNode.Translate(new Vector3(0, 2.5f, 0)); palmNode.Pitch(-Math.HALF_PI); //palmNode.Pitch(Math.PI); Quaternion q = new Quaternion(new Radian(new Degree(20)), Vector3.UNIT_X); Quaternion q2 = new Quaternion(new Radian(new Degree(-20)), Vector3.UNIT_X); EffectsManager.Singleton.RectangularEffect(sceneMgr, parent, "0", EffectsManager.EffectType.PALMTOP1, position + new Vector3(0f, 4.0f, -0.0f), new Vector2(1.4f, 1.4f), q, true).FirstNode.Yaw(angle); EffectsManager.Singleton.RectangularEffect(sceneMgr, parent, "1", EffectsManager.EffectType.PALMTOP1, position + new Vector3(0f, 4.0f, -0.0f), new Vector2(1.4f, 1.4f), q2, true).FirstNode.Yaw(angle); } else { palmNode.Rotate(Vector3.UNIT_Y, Math.RangeRandom(0.0f, Math.PI)); palmNode.Scale(1, Math.RangeRandom(0.9f, 1.1f), 1); } palmNode.AttachObject(palm); return(palmNode); }
public static void AttachAxes(SceneManager sceneMgr, SceneNode node, float scale) { if (EngineConfig.DisplayAxes) { Entity a = sceneMgr.CreateEntity(node.Name + "_Axes", "axes.mesh"); a.SetMaterialName("Misc/Axes"); SceneNode axesNode = node.CreateChildSceneNode(node.Name + "_AxesNode"); float len = node.GetAttachedObject(0).BoundingRadius; float rescale = len / a.BoundingRadius; axesNode.AttachObject(a); axesNode.Scale(new Vector3(rescale * scale, rescale * scale, rescale * scale)); } }
public ThirdPersonModel(Character character, SceneNode characterNode, string[] bodyEntityNames) : base(character) { BodyEntities = bodyEntityNames.Select(name => Character.World.Scene.CreateEntity(name)).ToArray(); BodyNode = characterNode.CreateChildSceneNode(); BodyNode.Yaw(MathHelper.Pi); WeaponSceneNode = BodyNode.CreateChildSceneNode(); WeaponCenterNode = WeaponSceneNode.CreateChildSceneNode(); foreach (Entity bodyEntity in BodyEntities) { BodyNode.AttachObject(bodyEntity); // To play multiple animations that does not affect each other, // blending mode cannot be average. if (bodyEntity.HasSkeleton) bodyEntity.Skeleton.BlendMode = SkeletonAnimationBlendMode.ANIMBLEND_CUMULATIVE; } WeaponCenterNode.Yaw(MathHelper.Pi); }
public Player(Vector3 oPos, Quaternion oOrent) { unique++; //create a scene node, off the root scene node sn = Program.Instance.sceneManager.RootSceneNode.CreateChildSceneNode(); //Load the mesh into the entity ent = Program.Instance.sceneManager.CreateEntity("playa" + unique, "PC_01.mesh"); //Attach the Entity to the scene node sn.AttachObject(ent); l = Program.Instance.sceneManager.CreateLight("Sun"); l.DiffuseColour = new ColourValue(0.9f, 0.6f, 0.2f); light_node = sn.CreateChildSceneNode(); light_node.AttachObject(l); light_node.Position = new Vector3(0, 0, -55); sn.Orientation = new Quaternion(new Degree(90), Vector3.UNIT_X); position = new Vector2(0, 0); isPlayer = true; }
protected void processNode(XmlElement XMLNode, SceneNode pParent) { // Construct the node's name String name = m_sPrependNode + getAttrib(XMLNode, "name"); // Create the scene node SceneNode pNode; if (name.Length == 0) { // Let Ogre choose the name if (pParent != null) pNode = pParent.CreateChildSceneNode(); else pNode = mAttachNode.CreateChildSceneNode(); } else { // Provide the name if (pParent != null) pNode = pParent.CreateChildSceneNode(name); else pNode = mAttachNode.CreateChildSceneNode(name); } // Process other attributes XmlElement pElement; // Process position (?) pElement = (XmlElement)XMLNode.SelectSingleNode("position"); if (pElement != null) { pNode.Position = parseVector3(pElement); pNode.SetInitialState(); } // Process quaternion (?) pElement = (XmlElement)XMLNode.SelectSingleNode("quaternion"); if (pElement != null) { pNode.Orientation = parseQuaternion(pElement); pNode.SetInitialState(); } // Process rotation (?) pElement = (XmlElement)XMLNode.SelectSingleNode("rotation"); if (pElement != null) { pNode.Orientation = parseRotation(pElement); pNode.SetInitialState(); } // Process scale (?) pElement = (XmlElement)XMLNode.SelectSingleNode("scale"); if (pElement != null) { pNode.SetScale(parseVector3(pElement)); pNode.SetInitialState(); } // Process entity (*) pElement = (XmlElement)XMLNode.SelectSingleNode("entity"); if (pElement != null) { processEntity(pElement, pNode); } // Process light (*) pElement = (XmlElement)XMLNode.SelectSingleNode("light"); if (pElement != null) { processLight(pElement, pNode); } // Process plane (*) pElement = (XmlElement)XMLNode.SelectSingleNode("plane"); while (pElement != null) { processPlane(pElement, pNode); pElement = (XmlElement)pElement.NextSibling; } // Process camera (*) pElement = (XmlElement)XMLNode.SelectSingleNode("camera"); if (pElement != null) { processCamera(pElement, pNode); } // Process userDataReference (?) pElement = (XmlElement)XMLNode.SelectSingleNode("userData"); if (pElement != null) processUserDataReference(pElement, pNode); // Process childnodes pElement = (XmlElement)XMLNode.SelectSingleNode("node"); while (pElement != null) { processNode(pElement, pNode); pElement = (XmlElement)pElement.NextSibling; } }
public SimNode(SceneNode root, SceneNode node) { SceneNode = root.CreateChildSceneNode(); SceneNode.AddChild(node); }
protected void setupTapMotion() { float l_Wiimote1XPosition = -1 * mWidth / 32; float l_Wiimote2XPosition = 1 * mWidth / 32; float l_StartingYPosition = mHeight / 1.5f; float l_EndingYPosition = -1 * mHeight / 1.5f; float l_StartingZPosition = -1 * mWidth / 2; float l_EndingZPosition = mWidth / 2; mNode = mSceneManager.RootSceneNode.CreateChildSceneNode("WiimoteNode", new Vector3(0f, 0f, 0f)); SceneNode l_WimmoteTapMotionNode = mNode.CreateChildSceneNode("WiimoteTapMotionNode", new Vector3(0f, 0f, 0f)); SceneNode l_Wiimote1LineNode = l_WimmoteTapMotionNode.CreateChildSceneNode("Wiimote1LineNode", new Vector3(0f, 0f, 0f)); drawLine(l_Wiimote1LineNode, "Wiimote1LineNode", new Vector3(0f, l_StartingYPosition, l_StartingZPosition), new Vector3(0f, l_EndingYPosition, l_EndingZPosition)); SceneNode l_Wiimote1LineShoeNode = l_Wiimote1LineNode.CreateChildSceneNode("Wiimote1LineShoeNode", new Vector3(0f, l_EndingYPosition / 8, l_EndingZPosition / 8)); drawCircle(l_Wiimote1LineShoeNode, "WiimoteLine1Shoe"); l_Wiimote1LineNode.Translate(l_Wiimote1XPosition, 0f, 0f); l_Wiimote1LineNode.Translate(0, 0f, 0f); SceneNode l_Wiimote2LineNode = l_WimmoteTapMotionNode.CreateChildSceneNode("Wiimote2LineNode", new Vector3(0f, 0f, 0f)); drawLine(l_Wiimote2LineNode, "Wiimote2LineNode", new Vector3(0, l_StartingYPosition, l_StartingZPosition), new Vector3(0, l_EndingYPosition, l_EndingZPosition)); SceneNode l_Wiimote2LineShoeNode = l_Wiimote2LineNode.CreateChildSceneNode("Wiimote2LineShoeNode", new Vector3(0f, l_EndingYPosition / 8, l_EndingZPosition / 8)); drawCircle(l_Wiimote2LineShoeNode, "WiimoteLine2Shoe"); l_Wiimote2LineNode.Translate(l_Wiimote2XPosition, 0f, 0f); mWiimote1SceneNode = l_Wiimote1LineShoeNode.CreateChildSceneNode("Wiimote1SceneNode", new Vector3(0f, 0f, 0f)); mWiimote2SceneNode = l_Wiimote2LineShoeNode.CreateChildSceneNode("Wiimote2SceneNode", new Vector3(0f, 0f, 0f)); WiimoteOrgeControlCSVParser l_Parser = new WiimoteOrgeControlCSVParser(); l_Parser.loadShapeData(mDynamicShapes); int l_ShapeIndex = 0; SceneNode l_SceneNode = null; Mogre.Degree l_ShoeYawAngle = new Mogre.Degree(90); Mogre.Degree l_ShoePitchAngle = new Mogre.Degree(-20); Mogre.Degree l_DegreeRollAngle = new Mogre.Degree(30); foreach (WiimoteOrgeControlShape l_Shape in mDynamicShapes) { l_ShapeIndex++; if (l_Shape.Foot.CompareTo(ProjectCommon.ProjectConstants.SHAPE_LEFT_FOOT) == 0) l_SceneNode = mWiimote1SceneNode.CreateChildSceneNode("Wiimote1Node" + l_ShapeIndex, new Vector3(0,//l_Wiimote1XPosition, l_StartingYPosition * l_Shape.Time, l_StartingZPosition * l_Shape.Time)); else l_SceneNode = mWiimote2SceneNode.CreateChildSceneNode("Wiimote2Node" + l_ShapeIndex, new Vector3(0,//l_Wiimote2XPosition, l_StartingYPosition * l_Shape.Time, l_StartingZPosition * l_Shape.Time)); l_SceneNode.Scale(2f, 2f, 2f); l_SceneNode.Yaw(l_ShoeYawAngle); // l_SceneNode.Pitch(l_ShoePitchAngle); // l_SceneNode.Roll(30); InitialShoeRollAngle = l_SceneNode.Orientation.Roll.ValueDegrees; InitialShoePitchAngle = l_SceneNode.Orientation.Pitch.ValueDegrees; mInitialShoeAxis = l_SceneNode.Orientation; mInitialShoeAxis.w = InitialShoeRollAngle; drawShoe(l_SceneNode, "Shoe" + l_ShapeIndex); //TODO : Need to get back movable text // create entity // MovableText msg = new MovableText("txt001", l_Shape.Message, "BlueHighway", 6, new ColourValue(200, 50, 200)); // msg.SetTextAlignment(MovableText.HorizontalAlignment.H_CENTER, MovableText.VerticalAlignment.V_ABOVE); // msg.AdditionalHeight = 8.0f; // attach to a SceneNode // l_SceneNode.AttachObject(msg); } /* // SceneNode l_TestShoeNode = mNode.CreateChildSceneNode("TestShoeNode",new Vector3(0f, 0f, 0f)); SceneNode l_TestShoeNode = SceneManager.RootSceneNode.CreateChildSceneNode("TestShoeNode",new Vector3(0f, 0f, 0f)); drawShoe(l_TestShoeNode,"TestShoe"); l_TestShoeNode.Scale(5f, 5f, 5f); Mogre.Degree l_ShoeYawAngle = new Mogre.Degree(90); l_TestShoeNode.Yaw(l_ShoeYawAngle.ValueRadians); Mogre.Degree l_ShoePitchAngle = new Mogre.Degree(-20); l_TestShoeNode.Pitch(l_ShoePitchAngle.ValueRadians); */ mNode.Translate(new Vector3(mWidth / 8, 0f, 0f)); Mogre.Degree l_DegreeAngle = new Mogre.Degree(-15); // l_WimmoteTapMotionNode.Yaw(l_DegreeAngle.ValueRadians); mQuatDirection = new Quaternion(l_DegreeAngle.ValueRadians, Vector3.UNIT_Z); mNode.Rotate(mQuatDirection); mDirection = new Vector3(0f, l_EndingYPosition / 8, l_EndingZPosition / 8).NormalisedCopy; mTapNodePosition = mDirection; }
public void Init(String handle) { try { // Create root object mRoot = new Root(); // Define Resources ConfigFile cf = new ConfigFile(); cf.Load("./resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); String secName, typeName, archName; while (seci.MoveNext()) { secName = seci.CurrentKey; ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair<string, string> pair in settings) { typeName = pair.Key; archName = pair.Value; ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName); } } //Load the resources from resources.cfg and selected tab (_ConfigurationPaths) //LoadResourceLocations(_ConfigurationPaths); //example of manual add: _FileSystemPaths.Add("../../Media/models"); foreach (string foo in _ConfigurationPaths) { AddResourceLocation(foo); } // Setup RenderSystem mRSys = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); //mRSys = mRoot.GetRenderSystemByName("OpenGL Rendering Subsystem"); // or use "OpenGL Rendering Subsystem" mRoot.RenderSystem = mRSys; mRSys.SetConfigOption("Full Screen", "No"); mRSys.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour"); // Create Render Window mRoot.Initialise(false, "Main Ogre Window"); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = handle; misc["FSAA"] = "4"; // misc["VSync"] = "True"; //not sure how to enable vsync to remove those warnings in Ogre.log mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); // Init resources MaterialManager.Singleton.SetDefaultTextureFiltering(TextureFilterOptions.TFO_ANISOTROPIC); TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); // Create a Simple Scene //SceneNode node = null; // mMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "SceneManager"); mMgr = mRoot.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE, "SceneManager"); mMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f); mCamera = mMgr.CreateCamera("Camera"); mWindow.AddViewport(mCamera); mCamera.AutoAspectRatio = true; mCamera.Viewport.SetClearEveryFrame(false); //Entity ent = mMgr.CreateEntity(displayMesh, displayMesh); //ent.SetMaterialName(displayMaterial); //node = mMgr.RootSceneNode.CreateChildSceneNode(displayMesh + "node"); //node.AttachObject(ent); mCamera.Position = new Vector3(0, 0, 0); //mCamera.Position = new Vector3(0, 0, -400); mCamera.LookAt(0, 0, 1); //Create a single point light source Light light2 = mMgr.CreateLight("MainLight"); light2.Position = new Vector3(0, 10, -25); light2.Type = Light.LightTypes.LT_POINT; light2.SetDiffuseColour(1.0f, 1.0f, 1.0f); light2.SetSpecularColour(0.1f, 0.1f, 0.1f); mWindow.WindowMovedOrResized(); IsInitialized = true; // Create the camera's top node (which will only handle position). cameraNode = mMgr.RootSceneNode.CreateChildSceneNode(); cameraNode.Position = new Vector3(0, 0, 0); //cameraNode = mMgr->getRootSceneNode()->createChildSceneNode(); //cameraNode->setPosition(0, 0, 500); // Create the camera's yaw node as a child of camera's top node. cameraYawNode = cameraNode.CreateChildSceneNode(); // Create the camera's pitch node as a child of camera's yaw node. cameraPitchNode = cameraYawNode.CreateChildSceneNode(); // Create the camera's roll node as a child of camera's pitch node // and attach the camera to it. cameraRollNode = cameraPitchNode.CreateChildSceneNode(); cameraRollNode.AttachObject(mCamera); mRaySceneQuery = mMgr.CreateRayQuery(new Ray()); } catch (Exception ex) { Console.WriteLine("[Error,OgreForm.cs]: " + ex.Message + "," + ex.StackTrace); } }
public SceneNode point3d(string name, int id, float x, float y, float z, SceneNode node, SceneManager sceneMgr) { Entity ent; if (node == null)//point of reference 0,0,0 { ManualObject aux = sceneMgr.CreateManualObject(); //ent = sceneMgr.CreateEntity(name + id, this.getNameEntities()); node = sceneMgr.RootSceneNode.CreateChildSceneNode(name + id + "Node", new Vector3(y, z, x)); node.AttachObject(aux); return node; } else//create new point { float xAux = x; float yAux = y; SceneNode nodeAux; ent = sceneMgr.CreateEntity(name + id, getNameEntities()); nodeAux = node.CreateChildSceneNode(name + "Node_" + id, new Vector3(yAux, z, xAux)); nodeAux.AttachObject(ent); return nodeAux; } }
/// <summary> /// /// </summary> /// <param name="mgr"></param> /// <param name="rootSceneNode"></param> /// <param name="method"></param> public StaticBillboardSet(SceneManager mgr, SceneNode rootSceneNode, BillboardMethod method) { mSceneMgr = mgr; mRenderMethod = method; mVisible = true; mFadeEnabled = false; mBBOrigin = BillboardOrigin.Center; //Fall back to Compatible if vertex shaders are not available if (mRenderMethod == BillboardMethod.Accelerated) { RenderSystemCapabilities caps = Root.Singleton.RenderSystem.Capabilities; if (!caps.HasCapability(Capabilities.VertexPrograms)) mRenderMethod = BillboardMethod.Compatible; } mNode = rootSceneNode.CreateChildSceneNode(); mEntityName = GetUniqueID("SBSEntity"); if (mRenderMethod == BillboardMethod.Accelerated) { //Accelerated billboard method mEntity = null; mUFactor = 1.0f; mVFactor = 1.0f; //Load vertex shader to align billboards to face the camera (if not loaded already) if (++mSelfInstances == 1) { //First shader, simple camera-alignment HighLevelGpuProgram vertexShader = (HighLevelGpuProgram)HighLevelGpuProgramManager.Instance.GetByName("Sprite_vp"); if (vertexShader == null) { string vertexProg = string.Empty; vertexProg = "void Sprite_vp( \n" + " float4 position : POSITION, \n" + " float3 normal : NORMAL, \n" + " float4 color : COLOR, \n" + " float2 uv : TEXCOORD0, \n" + " out float4 oPosition : POSITION, \n" + " out float2 oUv : TEXCOORD0, \n" + " out float4 oColor : COLOR, \n" + " out float4 oFog : FOG, \n" + " uniform float4x4 worldViewProj, \n" + " uniform float uScroll, \n" + " uniform float vScroll, \n" + " uniform float4 preRotatedQuad[4] ) \n" + "{ \n" + //Face the camera " float4 vCenter = float4( position.x, position.y, position.z, 1.0f ); \n" + " float4 vScale = float4( normal.x, normal.y, normal.x, 1.0f ); \n" + " oPosition = mul( worldViewProj, vCenter + (preRotatedQuad[normal.z] * vScale) ); \n" + //Color " oColor = color; \n" + //UV Scroll " oUv = uv; \n" + " oUv.x += uScroll; \n" + " oUv.y += vScroll; \n" + //Fog " oFog.x = oPosition.z; \n" + "}"; vertexShader = HighLevelGpuProgramManager.Instance.CreateProgram( "Sprite_vp", ResourceGroupManager.DefaultResourceGroupName, "cg", GpuProgramType.Vertex); vertexShader.Source = vertexProg; vertexShader.SetParam("profiles", "vs_1_1 arbvp1"); vertexShader.SetParam("entry_point", "Sprite_vp"); vertexShader.Load(); } //Second shader, camera alignment and distance based fading HighLevelGpuProgram vertexShader2 = (HighLevelGpuProgram)HighLevelGpuProgramManager.Instance.GetByName("SpriteFade_vp"); if (vertexShader2 == null) { string vertexProg2 = string.Empty; vertexProg2 = "void SpriteFade_vp( \n" + " float4 position : POSITION, \n" + " float3 normal : NORMAL, \n" + " float4 color : COLOR, \n" + " float2 uv : TEXCOORD0, \n" + " out float4 oPosition : POSITION, \n" + " out float2 oUv : TEXCOORD0, \n" + " out float4 oColor : COLOR, \n" + " out float4 oFog : FOG, \n" + " uniform float4x4 worldViewProj, \n" + " uniform float3 camPos, \n" + " uniform float fadeGap, \n" + " uniform float invisibleDist, \n" + " uniform float uScroll, \n" + " uniform float vScroll, \n" + " uniform float4 preRotatedQuad[4] ) \n" + "{ \n" + //Face the camera " float4 vCenter = float4( position.x, position.y, position.z, 1.0f ); \n" + " float4 vScale = float4( normal.x, normal.y, normal.x, 1.0f ); \n" + " oPosition = mul( worldViewProj, vCenter + (preRotatedQuad[normal.z] * vScale) ); \n" + " oColor.rgb = color.rgb; \n" + //Fade out in the distance " float dist = distance(camPos.xz, position.xz); \n" + " oColor.a = (invisibleDist - dist) / fadeGap; \n" + //UV scroll " oUv = uv; \n" + " oUv.x += uScroll; \n" + " oUv.y += vScroll; \n" + //Fog " oFog.x = oPosition.z; \n" + "}"; vertexShader2 = HighLevelGpuProgramManager.Instance.CreateProgram( "SpriteFade_vp", ResourceGroupManager.DefaultResourceGroupName, "cg", GpuProgramType.Vertex); vertexShader2.Source = vertexProg2; vertexShader2.SetParam("profiles", "vs_1_1 arbvp1"); vertexShader2.SetParam("entry_point", "SpriteFade_vp"); vertexShader2.Load(); } } } else { //Compatible billboard method mFallbackSet = mSceneMgr.CreateBillboardSet(GetUniqueID("SBS"), 100); mNode.AttachObject(mFallbackSet); } }
protected void processNode(XmlElement XMLNode, SceneNode pParent) { // Construct the node's name String name = m_sPrependNode + getAttrib(XMLNode, "name"); // Create the scene node SceneNode pNode; if (name.Length == 0) { // Let Ogre choose the name if (pParent != null) pNode = pParent.CreateChildSceneNode(); else pNode = mAttachNode.CreateChildSceneNode(); } else { // Provide the name if (pParent != null) pNode = pParent.CreateChildSceneNode(name); else pNode = mAttachNode.CreateChildSceneNode(name); } // Process other attributes XmlElement pElement; // Process position (?) pElement = (XmlElement)XMLNode.SelectSingleNode("position"); if (pElement != null) { pNode.Position = parseVector3(pElement); pNode.SetInitialState(); } // Process quaternion (?) pElement = (XmlElement)XMLNode.SelectSingleNode("quaternion"); if (pElement != null) { pNode.Orientation = parseQuaternion(pElement); pNode.SetInitialState(); } // Process rotation (?) pElement = (XmlElement)XMLNode.SelectSingleNode("rotation"); if (pElement != null) { pNode.Orientation = parseRotation(pElement); pNode.SetInitialState(); } // Process scale (?) pElement = (XmlElement)XMLNode.SelectSingleNode("scale"); if (pElement != null) { pNode.SetScale(parseVector3(pElement)); pNode.SetInitialState(); } // Process entity (*) pElement = (XmlElement)XMLNode.SelectSingleNode("entity"); if (pElement != null) { processEntity(pElement, pNode); } // Process light (*) pElement = (XmlElement)XMLNode.SelectSingleNode("light"); if (pElement != null) { processLight(pElement, pNode); } // Process plane (*) pElement = (XmlElement)XMLNode.SelectSingleNode("plane"); while (pElement != null) { processPlane(pElement, pNode); pElement = (XmlElement)pElement.NextSibling; } //process particle (*) pElement = (XmlElement)XMLNode.SelectSingleNode("particleSystem"); if (pElement != null) processParticleSystem(pElement, pNode); // Process camera (*) pElement = (XmlElement)XMLNode.SelectSingleNode("camera"); if (pElement != null) { processCamera(pElement, pNode); } // Process childnodes pElement = (XmlElement)XMLNode.SelectSingleNode("node"); while (pElement != null) { processNode(pElement, pNode); pElement = (XmlElement)pElement.NextSibling; } /** Póki co kolizję ładujemy bezpośrednio z plików z obiektami, zwłaszcza, że ze względu na wygenerowane .scene przez grafików * w aktualnej planszy mamy niecałe 300 meshy, więc jak się znajdzie ktoś, komu chce się przerabiać je na Col to zapraszam.;) MSZ */ if (!name.Contains("triggerBox#")) { //pNode.SetVisible(false); MogreNewt.CollisionPrimitives.TreeCollisionSceneParser collision = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(Tachycardia.Core.Singleton.NewtonWorld); collision.ParseScene(pNode, true, 1); Tachycardia.Map map = Tachycardia.Core.Singleton.CurrentMap = new Tachycardia.Map(); map.m_Body = new MogreNewt.Body(Tachycardia.Core.Singleton.NewtonWorld, collision); map.m_Body.SetPositionOrientation(pNode.Position, pNode.Orientation); collision.Dispose(); //to do wymiany powinno byc w propertisie map.m_Body.MaterialGroupID = Tachycardia.Core.Singleton.PhysicsManager.getMaterialID("Ground"); map.m_Body.AttachNode(pNode); } else { } }
public SimNode(SceneNode root, MovableObject movableObject) { SceneNode = root.CreateChildSceneNode(); SceneNode.AttachObject(movableObject); }