Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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! this time we'll scale it slightly to make it more vehicle-friendly :P
            Vector3   size = new Vector3(2.0f, 0.5f, 2.0f);
            Entity    floor;
            SceneNode floornode;

            floor     = sceneMgr.CreateEntity("Floor", "simple_terrain.mesh");
            floornode = sceneMgr.RootSceneNode.CreateChildSceneNode("FloorNode");
            floornode.AttachObject(floor);
            floor.SetMaterialName("Simple/BeachStones");
            floornode.SetScale(size);

            collisionNode = floornode;

            floor.CastShadows = false;

            //Vector3 siz(100.0, 10.0, 100.0);
            MogreNewt.Collision col = new MogreNewt.CollisionPrimitives.TreeCollision(m_World, floornode, false);
            MogreNewt.Body      bod = new MogreNewt.Body(m_World, col);
            col.Dispose();

            bod.AttachToNode(floornode);
            bod.SetPositionOrientation(new Vector3(0, -2.0f, 0.0f), Quaternion.IDENTITY);

            // here's where we make the simple vehicle.  everything is taken care of in the constuctor.
            mCar = new SimpleVehicle(sceneMgr, m_World, new Vector3(0, -0.5f, 0), Quaternion.IDENTITY);



            // position camera
            camera.SetPosition(0.0f, 1.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);
        }