Exemplo n.º 1
0
        private void createPhysics()
        {
            rigidBody = new RigidBody();
            RigidBodyDescription description = new RigidBodyDescription();

            description.Density = 4;
            rigidBody.CreateStatic(
                node.Position,
                description,
                physicsScene,
                physicsScene.Physics.CreateTriangleMesh(new
                                                        StaticMeshData(ent.GetMesh())));
            ((SinbadState)state).AddActorNode(new ActorNode(node, Actor));
        }
Exemplo n.º 2
0
        private void setupPhysics()
        {
            //if (mControlled)
            //{
            //    SimpleShape shape = new SimpleShape(new Mogre.Vector3(50, CHAR_HEIGHT, 0));
            //    CharacterControllerDescription description = new CharacterControllerDescription();
            //    physicsController = new CharacterController();
            //    physicsController.createCharacterController(mBodyNode.Position, shape, description, mPhysicsScene);
            //}
            //else
            //{
            rigidBody = new RigidBody();
            RigidBodyDescription description = new RigidBodyDescription();

            description.Density        = 4;
            description.LinearVelocity = new Mogre.Vector3(0, 2, 5);
            ShapeDesc shape = mPhysics.CreateConvexHull(new
                                                        StaticMeshData(mBodyEnt.GetMesh()));

            rigidBody.CreateDynamic(
                mBodyNode.Position,
                mBodyNode.Orientation.ToRotationMatrix(),
                description,
                mPhysicsScene,
                shape);
            //BodyDesc bodyDesc = new BodyDesc();
            //bodyDesc.LinearVelocity = new Mogre.Vector3(0, 2, 5);
            //
            //// the actor properties control the mass, position and orientation
            //// if you leave the body set to null it will become a static actor and wont move
            //ActorDesc actorDesc = new ActorDesc();
            //actorDesc.Density = 4;
            //actorDesc.Body = bodyDesc;
            //actorDesc.GlobalPosition = mBodyNode.Position;
            //actorDesc.GlobalOrientation = mBodyNode.Orientation.ToRotationMatrix();

            // a quick trick the get the size of the physics shape right is to use the bounding box of the entity
            //actorDesc.Shapes.Add(
            //    mPhysics.CreateConvexHull(new
            //    StaticMeshData(mBodyEnt.GetMesh())));
            //
            //// finally, create the actor in the physics scene
            //mActor = mPhysicsScene.CreateActor(actorDesc);
            if (!mControlled)
            {
                ((SinbadState)mWorld).AddActorNode(new ActorNode(mBodyNode, rigidBody.Actor));
            }
            //}
        }