예제 #1
0
        public WayPoint()
        {
            _Orientation       = Quaternion.IDENTITY;
            _DisplayNameOffset = new Vector3(0, 0.2f, 0);

            Entity = Engine.Singleton.SceneManager.CreateEntity("Spawn.mesh");
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                     Node,
                                                                                     Quaternion.IDENTITY,
                                                                                     0.1f,
                                                                                     Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            Inertia = inertia;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(1, inertia * 1);

            Body.ForceCallback += BodyForceCallback;

            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            collision.Dispose();
        }
예제 #2
0
        public WayPoint()
        {
            _Orientation = Quaternion.IDENTITY;
            _DisplayNameOffset = new Vector3(0, 0.2f, 0);

            Entity = Engine.Singleton.SceneManager.CreateEntity("Spawn.mesh");
            Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                Node,
                Quaternion.IDENTITY,
                0.1f,
                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);

            Inertia = inertia;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(0, inertia * 0);

            Body.ForceCallback += BodyForceCallback;

            Body.UserData = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.WaypointMaterialID;
            //Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            collision.Dispose();
        }
예제 #3
0
        public Described(DescribedProfile profile)
        {
            Profile   = profile.Clone();
            Activator = "";
            Entity    = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node      = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();

            Entity.CastShadows = true;
            Node.AttachObject(Entity);



            ConvexCollision coll = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                Node,
                                                                                Quaternion.IDENTITY,
                                                                                0.1f,
                                                                                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia = new Vector3(1, 1, 1), offset;

            coll.CalculateInertialMatrix(out inertia, out offset);

            Inertia = inertia;
            Body    = new Body(Engine.Singleton.NewtonWorld, coll, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.Mass, Profile.Mass * inertia);

            Body.MaterialGroupID = Engine.Singleton.MaterialManager.DescribedMaterialID;
            Body.UserData        = this;

            coll.Dispose();

            Body.ForceCallback += BodyForceCallback;
        }
예제 #4
0
파일: Described.cs 프로젝트: CloneDeath/RPG
        public Described(DescribedProfile profile)
        {
            Profile = profile.Clone();

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            Vector3 scaledSize = Entity.BoundingBox.Size * Profile.BodyScaleFactor;

            IsContainer = profile.IsContainer;

            if (IsContainer)
            {
                Container = new Container();

                if (profile.PrizeID != null)
                {
                    Prize p1 = PrizeManager.P[profile.PrizeID].prize_Clone();
                    Container.Contains = new List <DescribedProfile>(p1.ItemsList); //PrizeManager.P[profile.PrizeID].ItemsList;
                    Container.Gold     = p1.AmountGold;                             //PrizeManager.P[profile.PrizeID].AmountGold;
                    Container.MaxItems = p1.AmountExp;                              //PrizeManager.P[profile.PrizeID].AmountExp;
                }
            }

            if (Profile.Mass != 0)
            {
                ConvexCollision coll = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                    Node,
                                                                                    Quaternion.IDENTITY,
                                                                                    0.01f,
                                                                                    Engine.Singleton.GetUniqueBodyId());

                Vector3 inertia = new Vector3(1, 1, 1), offset;
                coll.CalculateInertialMatrix(out inertia, out offset);


                Body = new Body(Engine.Singleton.NewtonWorld, coll, true);
                coll.Dispose();
                Body.AttachNode(Node);
                Body.SetMassMatrix(Profile.Mass, Profile.Mass * inertia);
            }
            else
            {
                //Collision coll = new MogreNewt.CollisionPrimitives.TreeCollision(Engine.Singleton.NewtonWorld, Node, true, Engine.Singleton.GetUniqueBodyId());

                Collision coll = new MogreNewt.CollisionPrimitives.TreeCollision(Engine.Singleton.NewtonWorld, Entity, true, Engine.Singleton.GetUniqueBodyId());

                //Body = new Body(Engine.Singleton.NewtonWorld, coll, true);
                Body = new Body(Engine.Singleton.NewtonWorld, coll, false);
                coll.Dispose();
                Body.AttachNode(Node);
            }
            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.DescribedMaterialID;
        }
예제 #5
0
        public void RecalculateCollision()
        {
            Vector3    pos    = Position;
            Quaternion orient = Orientation;

            Node.DetachAllObjects();
            Engine.Singleton.SceneManager.DestroySceneNode(Node);
            Engine.Singleton.SceneManager.DestroyEntity(Entity);
            Body.Dispose();
            Body = null;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                     Node,
                                                                                     Quaternion.IDENTITY,
                                                                                     0.1f,
                                                                                     Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed    += BodyTransformCallback;
            Body.ForceCallback  += BodyForceCallback;
            Orientation          = orient;
            Position             = pos;
            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
                Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();
        }
예제 #6
0
        public ForceBall(SceneManager sceneManager, MogreNewt.World physicsWorld, float tempSize, int own)
        {
            MogreNewt.ConvexCollision col;
            Mogre.Vector3 offset;
            Mogre.Vector3 inertia;

            unique++;

            // Create the visible mesh (no physics)
            ent = sceneManager.CreateEntity("forceball" + unique, "Sph.mesh");
            sn = sceneManager.RootSceneNode.CreateChildSceneNode();
            sn.AttachObject(ent);
            Console.WriteLine("end ball create");
            size = tempSize;

            sn.SetScale(size, size, size);

            // Create the collision hull
            col = new MogreNewt.CollisionPrimitives.ConvexHull(physicsWorld, sn);
            col.calculateInertialMatrix(out inertia, out offset);

            // Create the physics body. This body is what you manipulate. The graphical Ogre scenenode is automatically synced with the physics body
            body = new MogreNewt.Body(physicsWorld, col);
            col.Dispose();

            //body.setPositionOrientation(new Vector3(0, 10, 0), Quaternion.IDENTITY);

            body.attachToNode(sn);
            body.setContinuousCollisionMode(1);
            body.setMassMatrix(mass, mass * inertia);
            body.IsGravityEnabled = true;
            body.setUserData(this);

            trail = sceneManager.CreateParticleSystem("awesome" + StringConverter.ToString(unique), "Char/Smoke");
            trail.CastShadows = true;
            trail.GetEmitter(0).EmissionRate = 100;
            sn.AttachObject(trail);

            Console.WriteLine("player stuff");

            owner = own;
            Player tempP = (Player)Program.p1;
            colour = tempP.cv;
        }
예제 #7
0
        public PhysicsNode(SimNode simNode, State State)
            : base(simNode.SceneNode)
        {
            SceneNode = simNode.SceneNode;
            SceneNode child = SceneNode;
            while (child.NumChildren() > 0) child = child.GetChild(0) as SceneNode;

            var hull = new MogreNewt.CollisionPrimitives.ConvexHull(State.PhysicsWorld.World, child, child.Orientation, 0.002f, SceneNode.Name.GetHashCode());
            Body = new Body(State.PhysicsWorld.World, hull);
            Body.AttachNode(SceneNode);
            Body.IsGravityEnabled = true;

            Body.SetPositionOrientation(SceneNode._getDerivedPosition(), SceneNode.Orientation); // REALPosition Orient
            Body.ForceCallback += State.PhysicsWorld.ForceCallback;
            //            Body.AngularDamping = new Vector3(1,1,1);
            //            Body.LinearDamping = 1;
            Body.UserData = new PhysicsControlData();
            hull.Dispose();
        }
예제 #8
0
        //public List<GameObject> Contacts;

        //public Described PickingTarget;

        //public List<DescribedProfile> Inventory;
        //ItemSword _Sword;
        //Entity SwordEntity;
        //public CharacterAnimBlender AnimBlender;


        //public bool TalkPerm;
        //public bool InventoryPerm;

        //public bool PickItemOrder;
        //public bool MoveOrder;
        //public bool MoveOrderBack;

        //public bool GetSwordOrder;
        //public bool HideSwordOrder;
        //bool _RunOrder;

        /*public bool RunOrder
         * {
         *  get
         *  {
         *      return _RunOrder;
         *  }
         *  set
         *  {
         *      if (_RunOrder == true && value == false)
         *      {
         *          _RunOrder = false;
         *          Profile.WalkSpeed -= 2.0f;
         *      }
         *      if (_RunOrder == false && value == true)
         *      {
         *          _RunOrder = true;
         *          Profile.WalkSpeed += 2.0f;
         *      }
         *  }
         * }
         *
         * public float TurnDelta;
         *
         * public bool FollowPathOrder;
         * public List<Vector3> WalkPath;
         * public static DecTree.Enemies.e_Node Tree = new EnemyDecTree();
         *
         *
         * //////////////////////////////////////////////
         * //              Moje zmienne:
         * //////////////////////////////////////////////
         *
         * Container Container;
         * public bool isContainer;
         * bool isSeen;
         * bool isReachable;
         * float ZasiegWzroku;
         * float ZasiegOgolny;
         * Prize DropPrize;
         * public Statistics Statistics;*/

        public Enemy(CharacterProfile profile)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            // Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                     Node,
                                                                                     Quaternion.IDENTITY,
                                                                                     0.1f,
                                                                                     Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            Inertia = inertia;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia * Profile.BodyMass);
            //Body.AutoSleep = false;

            //Body.Transformed += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            //Joint upVector = new MogreNewt.BasicJoints.UpVector(
            // Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();
        }
예제 #9
0
        public PhysicsNode(SimNode simNode, State State) : base(simNode.SceneNode)
        {
            SceneNode = simNode.SceneNode;
            SceneNode child = SceneNode;

            while (child.NumChildren() > 0)
            {
                child = child.GetChild(0) as SceneNode;
            }

            var hull = new MogreNewt.CollisionPrimitives.ConvexHull(State.PhysicsWorld.World, child, child.Orientation, 0.002f, SceneNode.Name.GetHashCode());

            Body = new Body(State.PhysicsWorld.World, hull);
            Body.AttachNode(SceneNode);
            Body.IsGravityEnabled = true;

            Body.SetPositionOrientation(SceneNode._getDerivedPosition(), SceneNode.Orientation); // REALPosition Orient
            Body.ForceCallback += State.PhysicsWorld.ForceCallback;
//            Body.AngularDamping = new Vector3(1,1,1);
//            Body.LinearDamping = 1;
            Body.UserData = new PhysicsControlData();
            hull.Dispose();
        }
예제 #10
0
        public Enemy(CharacterProfile profile, bool czyPojemnik, float zasiegWzr, float zasiegOgl)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                Node,
                Quaternion.IDENTITY,
                0.1f,
                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
            Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();

            isContainer = czyPojemnik;
            isSeen = false;
            isReachable = false;
            _ZasiegWzroku = zasiegWzr;
            _ZasiegOgolny = zasiegOgl;
            _Statistics = Profile.Statistics.statistics_Clone();
            State = StateTypes.IDLE;

            //DROPPRIZE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            if (Profile.DropPrizeID == "")
                Profile.DropPrizeID = "pPusty";

            DropPrize = PrizeManager.P[Profile.DropPrizeID].prize_Clone();
            List<DescribedProfile> lista_tym = new List<DescribedProfile>();
            List<DescribedProfile> lista_tym2 = new List<DescribedProfile>(DropPrize.ItemsList);

            if (DropPrize.ItemsList.Count > 2)
            {
                for (int i = 0; i < 2; i++)
                {
                    int Los = Engine.Singleton.Random.Next(lista_tym2.Count);
                    lista_tym.Add(lista_tym2[Los]);
                    lista_tym2.RemoveAt(Los);
                    DropPrize.ItemsList = new List<DescribedProfile>(lista_tym);
                }
            }

            else
                DropPrize.ItemsList = new List<DescribedProfile>(DropPrize.ItemsList);

            DropPrize.AmountGold = Engine.Singleton.Random.Next(DropPrize.AmountGold / 2, DropPrize.AmountGold + 1);
            DropExp = DropPrize.AmountExp;

            //PO DROPPRIZIE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            walkAnim = Entity.GetAnimationState("WALK");
            idleAnim = Entity.GetAnimationState("IDLE");
            attackAnim = Entity.GetAnimationState("ATTACK");
            deadAnim = Entity.GetAnimationState("DEAD");

            //Animation("IdleLegs").Enabled = true;
            //Animation("IdleLegs").Loop = true;
            FriendlyType = Profile.FriendlyType;
            ProfName = Profile.ProfileName;
        }
예제 #11
0
        public void RecalculateCollision()
        {
            Vector3 pos = Position;
            Quaternion orient = Orientation;
            Node.DetachAllObjects();
            Engine.Singleton.SceneManager.DestroySceneNode(Node);
            Engine.Singleton.SceneManager.DestroyEntity(Entity);
            Body.Dispose();
            Body = null;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                Node,
                Quaternion.IDENTITY,
                0.1f,
                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;
            Orientation = orient;
            Position = pos;
            Body.UserData = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
            Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();
        }
예제 #12
0
        public Enemy(CharacterProfile profile, bool czyPojemnik, float zasiegWzr, float zasiegOgl)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node   = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                                                                                     Node,
                                                                                     Quaternion.IDENTITY,
                                                                                     0.1f,
                                                                                     Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;

            collision.CalculateInertialMatrix(out inertia, out offset);

            inertia *= Profile.BodyMass;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia);
            Body.AutoSleep = false;

            Body.Transformed   += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData        = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;

            Joint upVector = new MogreNewt.BasicJoints.UpVector(
                Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();

            isContainer   = czyPojemnik;
            isSeen        = false;
            isReachable   = false;
            _ZasiegWzroku = zasiegWzr;
            _ZasiegOgolny = zasiegOgl;
            _Statistics   = Profile.Statistics.statistics_Clone();
            State         = StateTypes.IDLE;

            //DROPPRIZE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            if (Profile.DropPrizeID == "")
            {
                Profile.DropPrizeID = "pPusty";
            }

            DropPrize = PrizeManager.P[Profile.DropPrizeID].prize_Clone();
            List <DescribedProfile> lista_tym  = new List <DescribedProfile>();
            List <DescribedProfile> lista_tym2 = new List <DescribedProfile>(DropPrize.ItemsList);

            if (DropPrize.ItemsList.Count > 2)
            {
                for (int i = 0; i < 2; i++)
                {
                    int Los = Engine.Singleton.Random.Next(lista_tym2.Count);
                    lista_tym.Add(lista_tym2[Los]);
                    lista_tym2.RemoveAt(Los);
                    DropPrize.ItemsList = new List <DescribedProfile>(lista_tym);
                }
            }

            else
            {
                DropPrize.ItemsList = new List <DescribedProfile>(DropPrize.ItemsList);
            }

            DropPrize.AmountGold = Engine.Singleton.Random.Next(DropPrize.AmountGold / 2, DropPrize.AmountGold + 1);
            DropExp = DropPrize.AmountExp;

            //PO DROPPRIZIE KUFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

            walkAnim   = Entity.GetAnimationState("WALK");
            idleAnim   = Entity.GetAnimationState("IDLE");
            attackAnim = Entity.GetAnimationState("ATTACK");
            deadAnim   = Entity.GetAnimationState("DEAD");

            //Animation("IdleLegs").Enabled = true;
            //Animation("IdleLegs").Loop = true;
            FriendlyType = Profile.FriendlyType;
            ProfName     = Profile.ProfileName;
        }
예제 #13
0
        //public List<GameObject> Contacts;
        //public Described PickingTarget;
        //public List<DescribedProfile> Inventory;
        //ItemSword _Sword;
        //Entity SwordEntity;
        //public CharacterAnimBlender AnimBlender;
        //public bool TalkPerm;
        //public bool InventoryPerm;
        //public bool PickItemOrder;
        //public bool MoveOrder;
        //public bool MoveOrderBack;
        //public bool GetSwordOrder;
        //public bool HideSwordOrder;
        //bool _RunOrder;
        /*public bool RunOrder
        {
            get
            {
                return _RunOrder;
            }
            set
            {
                if (_RunOrder == true && value == false)
                {
                    _RunOrder = false;
                    Profile.WalkSpeed -= 2.0f;
                }
                if (_RunOrder == false && value == true)
                {
                    _RunOrder = true;
                    Profile.WalkSpeed += 2.0f;
                }
            }
        }

        public float TurnDelta;

        public bool FollowPathOrder;
        public List<Vector3> WalkPath;
        public static DecTree.Enemies.e_Node Tree = new EnemyDecTree();

        //////////////////////////////////////////////
        //              Moje zmienne:
        //////////////////////////////////////////////

        Container Container;
        public bool isContainer;
        bool isSeen;
        bool isReachable;
        float ZasiegWzroku;
        float ZasiegOgolny;
        Prize DropPrize;
        public Statistics Statistics;*/
        public Enemy(CharacterProfile profile)
        {
            Profile = profile.Clone();

            _Orientation = Quaternion.IDENTITY;

            Entity = Engine.Singleton.SceneManager.CreateEntity(Profile.MeshName);
            Node = Engine.Singleton.SceneManager.RootSceneNode.CreateChildSceneNode();
            Node.AttachObject(Entity);

            // Vector3 scaledSize = Entity.BoundingBox.HalfSize * Profile.BodyScaleFactor;

            ConvexCollision collision = new MogreNewt.CollisionPrimitives.ConvexHull(Engine.Singleton.NewtonWorld,
                Node,
                Quaternion.IDENTITY,
                0.1f,
                Engine.Singleton.GetUniqueBodyId());

            Vector3 inertia, offset;
            collision.CalculateInertialMatrix(out inertia, out offset);

            Inertia = inertia;

            Body = new Body(Engine.Singleton.NewtonWorld, collision, true);
            Body.AttachNode(Node);
            Body.SetMassMatrix(Profile.BodyMass, inertia * Profile.BodyMass);
            //Body.AutoSleep = false;

            //Body.Transformed += BodyTransformCallback;
            Body.ForceCallback += BodyForceCallback;

            Body.UserData = this;
            Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;

            //Joint upVector = new MogreNewt.BasicJoints.UpVector(
            // Engine.Singleton.NewtonWorld, Body, Vector3.UNIT_Y);

            collision.Dispose();
        }