public Trigger(string _shapename, Mogre.Vector3 _shapesize) { switch (_shapename) { case "box": m_collision = new MogreNewt.CollisionPrimitives.Box( Core.Singleton.NewtonWorld, _shapesize, new Mogre.Quaternion(new Mogre.Radian(1.57f), new Mogre.Vector3(0, 0, 1)), Core.Singleton.GetUniqueBodyId() ); break; case "ellipsoid": m_collision = new MogreNewt.CollisionPrimitives.Ellipsoid( Core.Singleton.NewtonWorld, _shapesize, new Mogre.Quaternion(new Mogre.Radian(1.57f), new Mogre.Vector3(0, 0, 1)), Core.Singleton.GetUniqueBodyId() ); break; } m_collision.IsTriggerVolume = true; m_Body = new MogreNewt.Body(Core.Singleton.NewtonWorld, m_collision, true); m_Body.UserData = this; m_Body.Type = (int)PhysicsManager.BodyTypes.TRIGGER; m_Body.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("Trigger"); }
public PlayerController(Mogre.Node node, Mogre.Entity entity, float mass) { //init logic states for controler initLogicStates(); //force direction m_GoTo = Mogre.Quaternion.IDENTITY; //node to update m_PlayerNode = node; //Ball MogreNewt.ConvexCollision collision = new MogreNewt.CollisionPrimitives.Ellipsoid( Core.Singleton.NewtonWorld, new Mogre.Vector3(0.25f, 0.25f, 0.25f), new Mogre.Quaternion(new Mogre.Radian(1.57f), new Mogre.Vector3(0, 1, 0)), Core.Singleton.GetUniqueBodyId()); Mogre.Vector3 inertia, offset; collision.CalculateInertialMatrix(out inertia, out offset); inertia *= mass;//mass m_MainBody = new MogreNewt.Body(Core.Singleton.NewtonWorld, collision, true); m_MainBody.SetMassMatrix(mass, inertia); m_MainBody.AutoSleep = false; m_MainBody.LinearDamping = 1.0f; m_MainBody.Transformed += BodyTransformCallback; m_MainBody.ForceCallback += BodyForceCallback; m_MainBody.UserData = this; m_MainBody.Type = (int)PhysicsManager.BodyTypes.PLAYER; collision.Dispose(); m_MainBody.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("Player"); //Ball end m_Pose = m_myPoses["normal"]; ///Second helper body Mogre.Vector3 inertia2, offset2; m_Pose.m_collision.CalculateInertialMatrix(out inertia2, out offset2); inertia2 *= 1; m_SecondBody = new MogreNewt.Body(Core.Singleton.NewtonWorld, m_Pose.m_collision, true); m_SecondBody.SetMassMatrix(1, inertia2); m_SecondBody.AutoSleep = false; m_SecondBody.IsGravityEnabled = false; m_SecondBody.SetPositionOrientation(new Mogre.Vector3(0, 1f, 0), Mogre.Quaternion.IDENTITY); m_SecondBody.MaterialGroupID = Core.Singleton.PhysicsManager.getMaterialID("Player"); m_SecondBody.UserData = null; //set Y joint for second body MogreNewt.Joint upVector = new MogreNewt.BasicJoints.UpVector( Core.Singleton.NewtonWorld, m_SecondBody, Mogre.Vector3.UNIT_Y); //connections between player bodies! player_join = new MogreNewt.BasicJoints.BallAndSocket(Core.Singleton.NewtonWorld, m_MainBody, m_SecondBody, new Mogre.Vector3(0, 0, 0)); }