public void SetCollisionMesh(String meshFile) { m_CollisionNode = Core.Singleton.m_SceneManager.RootSceneNode.CreateChildSceneNode(); m_CollisionEntity = Core.Singleton.m_SceneManager.CreateEntity(meshFile); m_CollisionNode.AttachObject(m_CollisionEntity); m_CollisionNode.SetVisible(false); MogreNewt.CollisionPrimitives.TreeCollisionSceneParser collision = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser( Core.Singleton.m_NewtonWorld); collision.ParseScene(m_CollisionNode, true, 1); m_Body = new Body(Core.Singleton.m_NewtonWorld, collision); collision.Dispose(); m_Body.AttachNode(m_CollisionNode); }
void SetCollisionMesh(String meshFile) { CollisionNode = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode(); CollisionEntity = Engine.Singleton.SceneManager.CreateEntity(meshFile); CollisionNode.AttachObject(CollisionEntity); CollisionNode.SetVisible(false); MogreNewt.CollisionPrimitives.TreeCollisionSceneParser collision = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser( Engine.Singleton.NewtonWorld); collision.ParseScene(CollisionNode, true, 1); Body = new Body(Engine.Singleton.NewtonWorld, collision); collision.Dispose(); Body.AttachNode(CollisionNode); Body.UserData = this; Body.MaterialGroupID = Engine.Singleton.MaterialManager.LevelMaterialID; }
public void Init(State State) { this.State = State; State.PhysicsWorld = this; World = new MogreNewt.World(); World.SetPlatformArchitecture(MogreNewt.World.PlatformArchitecture.PA_BEST_HARDWARE); World.SetWorldSize(new Vector3(-500, -500, -500), new Vector3(500, 500, 500)); World.SetSolverModel(MogreNewt.World.SolverModelMode.SM_2_PASS); World.DebuggerInstance.Init(State.SceneManager); // using the new "SceneParser" TreeCollision primitive. this will automatically parse an entire tree of // SceneNodes (parsing all children), and add collision for all meshes in the tree. var statCol = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(World); statCol.ParseScene(State.SceneManager.RootSceneNode, true, 0); // was floornode var sceneBody = new Body(World, statCol); statCol.Dispose(); sceneBody.AttachNode(State.SceneManager.RootSceneNode); // was floornode sceneBody.SetPositionOrientation(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.IDENTITY); var ent = State.SceneManager.CreateEntity("cylinder_body", "mocksub.mesh"); var simNode = new SimNode(State.SceneManager.RootSceneNode, ent); // rigid body. var phyNode = new PhysicsNode(simNode, State); phyNode.Body.SetPositionOrientation(new Vector3(0, 10, 0), Quaternion.IDENTITY); phyNode.Body.SetMassMatrix(125, Vector3.ZERO); var physicsNode = new PhysicsNode(State.SubNode, State); physicsNode.Body.SetMassMatrix(125, Vector3.ZERO); // TODO: FIX THIS State.SubNode = physicsNode; // initial position State.Root.FrameStarted += NewtonUpdate; }
public void Init(State State) { this.State = State; State.PhysicsWorld = this; World = new MogreNewt.World(); World.SetPlatformArchitecture(MogreNewt.World.PlatformArchitecture.PA_BEST_HARDWARE); World.SetWorldSize(new Vector3(-500, -500, -500), new Vector3(500, 500, 500)); World.SetSolverModel(MogreNewt.World.SolverModelMode.SM_2_PASS); World.DebuggerInstance.Init(State.SceneManager); // using the new "SceneParser" TreeCollision primitive. this will automatically parse an entire tree of // SceneNodes (parsing all children), and add collision for all meshes in the tree. var statCol = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(World); statCol.ParseScene(State.SceneManager.RootSceneNode, true, 0); // was floornode var sceneBody = new Body(World, statCol); statCol.Dispose(); sceneBody.AttachNode(State.SceneManager.RootSceneNode); // was floornode sceneBody.SetPositionOrientation(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.IDENTITY); var ent = State.SceneManager.CreateEntity("cylinder_body", "mocksub.mesh"); var simNode = new SimNode(State.SceneManager.RootSceneNode, ent); // rigid body. var phyNode = new PhysicsNode(simNode, State); phyNode.Body.SetPositionOrientation(new Vector3(0, 10, 0), Quaternion.IDENTITY); phyNode.Body.SetMassMatrix(125, Vector3.ZERO); var physicsNode = new PhysicsNode(State.SubNode, State); physicsNode.Body.SetMassMatrix(125, Vector3.ZERO); // TODO: FIX THIS State.SubNode = physicsNode; // initial position State.Root.FrameStarted += NewtonUpdate; }
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 override void CreateScene() { // Newton initialization m_World = new World(); MogreNewt.Debugger.Instance.Init(sceneMgr); // sky box. sceneMgr.SetSkyBox(true, "Examples/CloudyNoonSkyBox"); // shadows on! sceneMgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_ADDITIVE; // floor object! Entity floor; SceneNode floornode; floor = sceneMgr.CreateEntity("Floor", "simple_terrain.mesh"); floornode = sceneMgr.RootSceneNode.CreateChildSceneNode("FloorNode"); floornode.AttachObject(floor); floor.SetMaterialName("Simple/BeachStones"); floor.CastShadows = false; //------------------------------------------------------------- // add some other objects. Entity floor2; SceneNode floornode2; floor2 = sceneMgr.CreateEntity("Floor2", "simple_terrain.mesh"); floornode2 = floornode.CreateChildSceneNode("FloorNode2"); floornode2.AttachObject(floor2); floor2.SetMaterialName("Simple/BeachStones"); floor2.CastShadows = false; floornode2.SetPosition(80.0f, 0.0f, 0.0f); Entity floor3; SceneNode floornode3; floor3 = sceneMgr.CreateEntity("Floor3", "simple_terrain.mesh"); floornode3 = floornode.CreateChildSceneNode("FloorNode3"); floornode3.AttachObject(floor3); floor3.SetMaterialName("Simple/BeachStones"); floor3.CastShadows = false; floornode3.SetPosition(-80.0f, -5.0f, 0.0f); floornode3.Orientation = new Quaternion(new Degree(15.0f), Vector3.UNIT_Z); //------------------------------------------------------------- // using the new "SceneParser" TreeCollision primitive. this will automatically parse an entire tree of // SceneNodes (parsing all children), and add collision for all meshes in the tree. MogreNewt.CollisionPrimitives.TreeCollisionSceneParser stat_col = new MogreNewt.CollisionPrimitives.TreeCollisionSceneParser(m_World); stat_col.ParseScene(floornode, true); MogreNewt.Body bod = new MogreNewt.Body(m_World, stat_col); stat_col.Dispose(); bod.AttachNode(floornode); bod.SetPositionOrientation(new Vector3(0.0f, -20.0f, 0.0f), Quaternion.IDENTITY); // position camera camera.SetPosition(0.0f, -3.0f, 20.0f); //make a light Light light; light = sceneMgr.CreateLight("Light1"); light.Type = Light.LightTypes.LT_POINT; light.SetPosition(0.0f, 100.0f, 100.0f); }