/// <summary> // After defining the ModelElements they are initialized in the LoadModelElements method. The model is positioned and PhysObj attached here /// </summary> protected override void LoadModelElements() { Model = new ModelElement(mSceneMgr); HullGroupNode = new ModelElement(mSceneMgr); WheelGroupNode = new ModelElement(mSceneMgr); GunGroupNode = new ModelElement(mSceneMgr); PowerCells = new ModelElement(mSceneMgr, "PowerCells.mesh"); Hull = new ModelElement(mSceneMgr, "Main.mesh"); Sphere = new ModelElement(mSceneMgr, "Sphere.mesh"); float radius = 9; //physics for player controlNode = mSceneMgr.CreateSceneNode(); controlNode.Position += radius * Vector3.UNIT_Y; Model.GameNode.Position -= (radius * Vector3.UNIT_Y); Model.GameNode.Position -= new Vector3(0f, -8f, 0f); //set model to be above the ground //controlNode.SetPosition(0, 140, 0); physObj = new PhysObj(radius, "Player", 1f, 0.3f, 0.7f); physObj.SceneNode = controlNode; physObj.Position = controlNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); }
/// <summary> // The colour material is attached to the bomb mesh. The model is repositioned again next to the player in the scene later on. The PhysObj attached here /// </summary> protected override void Load() //In the class override the Load method { base.Load(); //in its body initialize the gameEntity, and the gameNode for the projectile Model = new ModelElement(mSceneMgr, "Sphere.mesh"); gameNode = Model.GameNode; mSceneMgr.RootSceneNode.AddChild(gameNode); Model.GameEntity.SetMaterialName("red"); gameNode.Scale(new Vector3(0.5f, 0.5f, 0.5f)); //scale down the size of the projectile models gameNode.SetPosition(200, 200, 20); physObj = new PhysObj(5f, "Cannonball", 0.1f, 0.7f, 1.5f); physObj.SceneNode = gameNode; //set its sceneNode property to gameNode physObj.Position = gameNode.Position; //physObj.AddForceToList(new WeightForce(physObj.InvMass)); //add a weight force //physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); }
protected override void AssembleModel() { // Attach and assemble model wheelsGroupNode.AddChild(playerSphereNode.GameNode); hullGroupNode.AddChild(playerCellsNode.GameNode); hullGroupNode.AddChild(playerMainNode.GameNode); hullGroupNode.AddChild(wheelsGroupNode); hullGroupNode.AddChild(gunGroupNode); modelNode.AddChild(hullGroupNode); controlNode = mSceneMgr.CreateSceneNode(); controlNode.AddChild(modelNode); mSceneMgr.RootSceneNode.AddChild(controlNode); float radius = 12; controlNode.Position += radius * Vector3.UNIT_Y; modelNode.Position -= radius * Vector3.UNIT_Y; physObj = new PhysObj(radius, "Player", 0.1f, 0.7f, 0.3f); physObj.SceneNode = controlNode; physObj.Position = controlNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); //physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); this.gameNode = controlNode; //base.AssembleModel(); }
/// <summary> /// This method is detaches from the scene graph and derstroies the game node and the game entity /// </summary> public virtual void Dispose() { //Console.WriteLine("Delete Object"); if (physObj != null) { Physics.RemovePhysObj(physObj); physObj = null; //Console.WriteLine("Delete Physics"); } if (gameNode != null) { if (gameNode.Parent != null) { gameNode.DetachAllObjects(); gameNode.RemoveAndDestroyAllChildren(); gameNode.Parent.RemoveChild(gameNode.Name); } gameNode.Dispose(); } if (gameEntity != null) { gameEntity.Dispose(); } }
/// <summary> /// This code Disposes the sphere, body and gameNode of the playerModel object. /// </summary> public override void Dispose() { if (sphere != null) { sphere.Dispose(); } if (body != null) { body.Dispose(); } if (gameNode != null) { gameNode.Dispose(); } if (powerCells != null) { powerCells.Dispose(); } Physics.RemovePhysObj(physObj); physObj = null; }
protected override void AssembleModel() { controlNode.AddChild(modelNode.GameNode); modelNode.AddChild(hullGroupNode.GameNode); hullGroupNode.AddChild(power.GameNode); hullGroupNode.AddChild(hull.GameNode); hullGroupNode.AddChild(gunsGroupNode.GameNode); hullGroupNode.AddChild(weelsGroupNode.GameNode); weelsGroupNode.AddChild(sphere.GameNode); mSceneMgr.RootSceneNode.AddChild(controlNode.GameNode); float radius = 10; // controlNode.GameNode.Position += radius * Vector3.UNIT_Y; // modelNode.GameNode.Position += radius * Vector3.UNIT_Y; gameNode = controlNode.GameNode; physObj = new PhysObj(radius, "Player", 0.01f, 0.7f, 0.3f); physObj.SceneNode = controlNode.GameNode; physObj.Position = controlNode.GameNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
/// <summary> // The material is attached to the powerup mesh. The model is positioned randomly in the scene and PhysObj attached here /// </summary> protected override void LoadModel() //The class should override the LoadModel method from PowerUp { //load the geometry for the power up and the scene graph nodes base.LoadModel(); timePickUpEntity = mSceneMgr.CreateEntity("Watch.mesh"); timePickUpEntity.SetMaterialName("clockPickup"); timePickUpNode = mSceneMgr.CreateSceneNode(); timePickUpNode.Scale(new Vector3(0.3f, 0.3f, 0.3f)); timePickUpNode.SetPosition(Mogre.Math.RangeRandom(-450, 450), 150, Mogre.Math.RangeRandom(-450, 450)); timePickUpNode.AttachObject(timePickUpEntity); mSceneMgr.RootSceneNode.AddChild(timePickUpNode); timePickUpEntity.GetMesh().BuildEdgeList(); physObj = new PhysObj(6f, "TimePickUp", 0.1f, 0.3f, 20f); physObj.SceneNode = timePickUpNode; physObj.Position = timePickUpNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); }
/// <summary> /// This method detaches and dispode of all the elements of the compound model /// </summary> public void Dispose() { //if (sphere != null) // Start removing from the leaves of the sub-graph //{ // if (sphere.Parent != null) // sphere.Parent.RemoveChild(sphere); // sphere.DetachAllObjects(); // sphere.Dispose(); // sphereEntity.Dispose(); //} //if (mainHull != null) //{ // if (mainHull.Parent != null) // mainHull.Parent.RemoveChild(mainHull); // mainHull.DetachAllObjects(); // mainHull.Dispose(); // hullEntity.Dispose(); // } if (model != null) // Stop removing with the sub-graph root { if (model.Parent != null) { model.Parent.RemoveChild(model); } model.Dispose(); Physics.RemovePhysObj(physObj); physObj = null; } }
/// <summary> /// This method loads the nodes and entities needed by the compound model /// </summary> protected override void LoadModelElements() { hullGroup = mSceneMgr.CreateSceneNode(); wheelGroup = mSceneMgr.CreateSceneNode(); gunGroup = mSceneMgr.CreateSceneNode(); mainHull = mSceneMgr.CreateSceneNode(); hullEntity = mSceneMgr.CreateEntity("Main.mesh"); hullEntity.GetMesh().BuildEdgeList(); sphere = mSceneMgr.CreateSceneNode(); sphereEntity = mSceneMgr.CreateEntity("Sphere.mesh"); sphereEntity.GetMesh().BuildEdgeList(); powerCells = mSceneMgr.CreateSceneNode(); powerCellsEntity = mSceneMgr.CreateEntity("PowerCells.mesh"); powerCellsEntity.GetMesh().BuildEdgeList(); model = mSceneMgr.CreateSceneNode(); float radius = 50; model.Position += radius * Vector3.UNIT_Y; hullGroup.Position -= radius * Vector3.UNIT_Y; physObj = new PhysObj(radius, "PlayerModel", 0.1f, 0.21f, 0.1f); physObj.SceneNode = model; physObj.Position = model.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); }
public CollectableGun(SceneManager mSceneMgr, Gun gun, Armoury playerArmoury, Vector3 position) { // Initialize here the mSceneMgr, the gun and the playerArmoury fields to the values passed as parameters this.mSceneMgr = mSceneMgr; this.gun = gun; this.playerArmoury = playerArmoury; // Initialize the gameNode here, scale it by 1.5f using the Scale funtion, and add as its child the gameNode contained in the Gun object. // Finally attach the gameNode to the sceneGraph. //gunNode = new ModelElement(mSceneMgr); //gunNode.GameNode.Scale(new Vector3(1.5f, 1.5f, 1.5f)); //gunNode.GameNode.AddChild(gun.GameNode); gameNode = mSceneMgr.CreateSceneNode(); gameNode.AddChild(gun.modelNode); gameNode.Position = position; mSceneMgr.RootSceneNode.AddChild(gameNode); // Here goes the link to the physics engine // (ignore until week 8) ... physObj = new PhysObj(10, "CollectableGun", 0.01f, 0.7f, 0.3f); physObj.SceneNode = gameNode; physObj.Position = gameNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
protected override void LoadModel() { base.LoadModel(); pUEntity = mSceneMgr.CreateEntity("Sphere.mesh"); pUNode = mSceneMgr.CreateSceneNode(); pUNode.Scale(0.5f, 0.5f, 0.5f); pUNode.AttachObject(pUEntity); controlNode = mSceneMgr.CreateSceneNode(); controlNode.AddChild(pUNode); mSceneMgr.RootSceneNode.AddChild(controlNode); float radius = 0.5f; controlNode.Position += radius * Vector3.UNIT_Y; pUNode.Position -= radius * Vector3.UNIT_Y; physObj = new PhysObj(radius, "Ball", 0.1f, 0.7f, 0.3f); physObj.SceneNode = controlNode; physObj.Position = controlNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); physObj.SceneNode = pUNode; pUEntity.GetMesh().BuildEdgeList(); }
/// <summary> // The material is attached to the powerup mesh. The model is positioned randomly in the scene and PhysObj attached here /// </summary> protected override void LoadModel() //The class should override the LoadModel method from PowerUp { //load the geometry for the power up and the scene graph nodes base.LoadModel(); lifePickUpEntity = mSceneMgr.CreateEntity("Heart.mesh"); lifePickUpEntity.SetMaterialName("HeartHMD"); lifePickUpNode = mSceneMgr.CreateSceneNode(); lifePickUpNode.Scale(new Vector3(5f, 5f, 5f)); lifePickUpNode.SetPosition(Mogre.Math.RangeRandom(-450, 450), 150, Mogre.Math.RangeRandom(-450, 450)); lifePickUpNode.Position += 3 * Vector3.UNIT_Y; lifePickUpNode.Position -= new Vector3(0f, -8f, 0f); //Model.GameNode.Position -= (3 * Vector3.UNIT_Y); //Model.GameNode.Position -= new Vector3(0f, -80f, 0f); lifePickUpNode.AttachObject(lifePickUpEntity); mSceneMgr.RootSceneNode.AddChild(lifePickUpNode); lifePickUpEntity.GetMesh().BuildEdgeList(); physObj = new PhysObj(9f, "LifePickUp", 0.1f, 0.3f, 20f); physObj.SceneNode = lifePickUpNode; physObj.Position = lifePickUpNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); }
/// <summary> // The robot mesh is loaded. The model is positioned randomly in the scene and PhysObj attached here /// </summary> protected override void LoadModelElements() { base.LoadModelElements(); Model = new ModelElement(mSceneMgr, "robot.mesh"); controlNode = mSceneMgr.CreateSceneNode(); float radius = 30; controlNode.Position += radius * Vector3.UNIT_Y; Model.GameNode.Position -= (radius * Vector3.UNIT_Y); if (isBoss) { Model.GameNode.Position -= new Vector3(0f, -9f, 0f); //set model to be above the ground } controlNode.SetPosition(Mogre.Math.RangeRandom(-450, 450), 0, Mogre.Math.RangeRandom(-450, 450)); GameNode = controlNode; if (isBoss) { controlNode.Scale(new Vector3(1.7f, 1.7f, 1.7f)); } physObj = new PhysObj(30f, "Robot", 10f, 0.3f, 5f); physObj.SceneNode = controlNode; physObj.Position = controlNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); }
protected virtual void LoadModel() { remove = false; physObj = new PhysObj(7, "Gem", 0.3f, 0.5f); physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.SceneNode = gameNode; Physics.AddPhysObj(physObj); }
/// <summary> /// Disposes of the physics and the model. /// </summary> public override void Dispose() { Physics.RemovePhysObj(physObj); physObj = null; gameNode.Parent.RemoveChild(lifePuModel.GameNode); lifePuModel.GameNode.DetachAllObjects(); lifePuModel.GameNode.Dispose(); lifePuModel.Dispose(); }
/// <summary> /// This method dispose of the bomb, destroying the physics object, and removing the bomb and its mesh from the scenegraph /// </summary> public void Dispose() { Physics.RemovePhysObj(physObj); physObj = null; bombNode.Parent.RemoveChild(bombNode); bombNode.DetachAllObjects(); bombNode.Dispose(); bombEntity.Dispose(); }
/// <summary> /// This method detaches the robot node from the scene graph and destroies it and the robot enetity /// </summary> public void Dispose() { robotNode.RemoveAllChildren(); robotNode.Parent.RemoveChild(robotNode); robotNode.DetachAllObjects(); robotNode.Dispose(); robotEntity.Dispose(); Physics.RemovePhysObj(physObj); physObj = null; }
protected virtual void LoadModel() { float radius = 5; p2 = physObj = new PhysObj(radius, "Gem", 0.1f, 0.5f, 0.0001f); physObj.SceneNode = gameNode; physObj.Position = gameNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); //physObj.AddForceToList(new ElasticForce(p2, physObj)); Physics.AddPhysObj(physObj); }
protected override void Load() { RemoveMe = false; bombElement = new ModelElement(mSceneMgr, "Bomb.mesh"); bombElement.GameNode.Scale(2, 2, 2); mSceneMgr.RootSceneNode.AddChild(bombElement.GameNode); physObj = new PhysObj(10, "Bomb", 0.1f, 0.5f); physObj.SceneNode = bombElement.GameNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
protected override void LoadModel() { RemoveMe = false; shieldElement = new ModelElement(mSceneMgr, "Shield.mesh"); mSceneMgr.RootSceneNode.AddChild(shieldElement.GameNode); physObj = new PhysObj(10, "Shield", 0.1f, 0.5f); physObj.SceneNode = shieldElement.GameNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
/// <summary> /// This method loads the mesh and attaches it to a node and to the schenegraph /// </summary> private void Load() { robotEntity = mSceneMgr.CreateEntity("robot.mesh"); //make sure the mesh is in the Media/models folder robotNode = mSceneMgr.CreateSceneNode(); robotNode.AttachObject(robotEntity); robotNode.Position = position; mSceneMgr.RootSceneNode.AddChild(robotNode); physObj = new PhysObj(10, "Robot", 0.01f, 0.5f); physObj.SceneNode = robotNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
protected override void LoadModel() { RemoveMe = false; blueGemElement = new ModelElement(mSceneMgr, "Gem.mesh"); blueGemElement.GameNode.Scale(2, 2, 2); mSceneMgr.RootSceneNode.AddChild(blueGemElement.GameNode); physObj = new PhysObj(10, "Gem", 0.1f, 0.5f, 5f); physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); physObj.SceneNode = blueGemElement.GameNode; Physics.AddPhysObj(physObj); }
protected override void Load() { projectileEntity = mSceneMgr.CreateEntity("Bomb.mesh"); projectileNode = mSceneMgr.CreateSceneNode(); projectileNode.AttachObject(projectileEntity); gameNode = projectileNode; mSceneMgr.RootSceneNode.AddChild(projectileNode); physObj = new PhysObj(10, "CannonBall", 1.5f, 0.5f); physObj.SceneNode = projectileNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
/// <summary> /// Contains the parts of the model and gives it physics. /// </summary> virtual protected void LoadModelElement() { removeMe = false; blueGemModel = new ModelElement(mSceneMgr, "Gem.mesh"); gameNode.Scale(2, 2, 2); physObj = new PhysObj(15, "Gem", 0.1f, 0.01f, 0.3f); physObj.SceneNode = gameNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
virtual protected void Load() { // Physics float radius = 10; //sProjNode.Position -= radius * Vector3.UNIT_Y; physObj = new PhysObj(radius, "Projectile", 0.1f, 0.7f, 0.3f); physObj.SceneNode = gameNode; physObj.Position = gameNode.Position; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj));//Friction Physics.AddPhysObj(physObj); }
/// <summary> /// Contains the parts of the model and gives the model physics. /// </summary> protected void LoadModelElement() { removeMe = false; shieldPuModel = new ModelElement(mSceneMgr, "Sphere.Mesh"); gameNode.Scale(1, 1, 1); physObj = new PhysObj(10, "Shield", 0.1f, 0.01f, 0.5f); physObj.SceneNode = gameNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
protected override void LoadModel() { RemoveMe = false; gameEntity = mSceneMgr.CreateEntity("ogrehead.mesh"); GameNode = mSceneMgr.CreateSceneNode(); GameNode.AttachObject(gameEntity); mSceneMgr.RootSceneNode.AddChild(GameNode); physObj = new PhysObj(10, "PowerUp", 0.1f, 0.5f); physObj.SceneNode = GameNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
protected override void LoadModel() { RemoveMe = false; redGemElement = new ModelElement(mSceneMgr, "Gem.mesh"); redGemElement.GameEntity.SetMaterialName("Red"); redGemElement.GameNode.Scale(2, 2, 2); mSceneMgr.RootSceneNode.AddChild(redGemElement.GameNode); physObj = new PhysObj(10, "Gem", 0.1f, 0.5f); physObj.SceneNode = redGemElement.GameNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); physObj.AddForceToList(new FrictionForce(physObj)); Physics.AddPhysObj(physObj); }
/// <summary> /// Contains the parts of the model and gives the model physics. /// </summary> protected void LoadModelElement() { removeMe = false; healthPuModel = new ModelElement(mSceneMgr, "PowerCells.Mesh"); gameNode.Scale(2, 2, 2); physObj = new PhysObj(10, "Health", 0.1f, 0.01f, 0.5f); physObj.SceneNode = gameNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }
/// <summary> /// Contains the parts of the model and gives the model physics. /// </summary> protected void LoadModelElement() { removeMe = false; lifePuModel = new ModelElement(mSceneMgr, "Heart.mesh"); lifePuModel.GameEntity.SetMaterialName("Red"); gameNode.Scale(7, 7, 7); physObj = new PhysObj(15, "Life", 0.1f, 0.01f, 0.5f); physObj.SceneNode = gameNode; physObj.AddForceToList(new WeightForce(physObj.InvMass)); Physics.AddPhysObj(physObj); }