Beispiel #1
0
        public static RaceCar AddRaceCar(Scene scene, TransformNode Marke, Vector3 CarPos, GeometryNode CModel, int IdPlayer)
        {
            TransformNode transNode = new TransformNode();
            transNode.Name = "Tcar:" + IdPlayer;
            transNode.Translation = CarPos;

            CModel.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;

            NewtonPhysics physicsEngine = (NewtonPhysics)scene.PhysicsEngine;

            RaceCar car = new RaceCar(CModel, physicsEngine);
            for (int i = 0; i < 4; i++)
                car.Tires[i] = CreateTire((TireID)Enum.ToObject(typeof(TireID), i),
                    car.TireTransformNode[i], CModel, scene.PhysicsEngine.Gravity);

            car.Collidable = true;
            car.Interactable = true;
            car.StartPos = CarPos;
            //Physic material Name
            car.MaterialName = "Car" + IdPlayer;

            CModel.Physics = car;
            CModel.Physics.NeverDeactivate = true;
            CModel.AddToPhysicsEngine = true;

            //Add To node
            transNode.AddChild(CModel);
            Marke.AddChild(transNode);

            Newton.NewtonSetBodyLeaveWorldEvent(physicsEngine.NewtonWorld,
                car.LeaveWorldCallback);

            return car;
        }
Beispiel #2
0
        public static RaceCar AddRaceCar(Scene scene, TransformNode Marke, Vector3 CarPos, GeometryNode CModel, int IdPlayer)
        {
            TransformNode transNode = new TransformNode();

            transNode.Name        = "Tcar:" + IdPlayer;
            transNode.Translation = CarPos;

            CModel.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;

            NewtonPhysics physicsEngine = (NewtonPhysics)scene.PhysicsEngine;

            RaceCar car = new RaceCar(CModel, physicsEngine);

            for (int i = 0; i < 4; i++)
            {
                car.Tires[i] = CreateTire((TireID)Enum.ToObject(typeof(TireID), i),
                                          car.TireTransformNode[i], CModel, scene.PhysicsEngine.Gravity);
            }

            car.Collidable   = true;
            car.Interactable = true;
            car.StartPos     = CarPos;
            //Physic material Name
            car.MaterialName = "Car" + IdPlayer;

            CModel.Physics = car;
            CModel.Physics.NeverDeactivate = true;
            CModel.AddToPhysicsEngine      = true;

            //Add To node
            transNode.AddChild(CModel);
            Marke.AddChild(transNode);

            Newton.NewtonSetBodyLeaveWorldEvent(physicsEngine.NewtonWorld,
                                                car.LeaveWorldCallback);

            return(car);
        }
Beispiel #3
0
        public static RaceCar AddRaceCarOld(Scene scene, TransformNode parentTrans, Vector3 CarPos, Vector4 CarColor, CarType_Enum CType)
        {
            TransformNode transNode = new TransformNode();
            //transNode.Scale = new Vector3(2.8f, 2.8f, 2.8f);
            transNode.Translation = CarPos;

            Material carMat = new Material();
            carMat.Diffuse = CarColor;
            carMat.Specular = Color.White.ToVector4();
            carMat.SpecularPower = 10;

            GeometryNode carNode = new GeometryNode("Race Car");
            //Intento cargar un modelo
            ModelLoader loader = new ModelLoader();

            //Cargo el modelo Dependiendo del tipo
            switch (CType)
            {
                case CarType_Enum.Basic:
                    carNode.Model = new Box(3, 1.0f, 2);
                    carNode.Material = carMat;
                    break;
                case CarType_Enum.Ferrary:
                    carNode.Model = (Model)loader.Load("Models", "ferrari");
                    ((Model)carNode.Model).UseInternalMaterials = true;
                    break;
                case CarType_Enum.Tank:
                    carNode.Model = (Model)loader.Load("Models", "Osirian_Battle_Tank");
                    ((Model)carNode.Model).UseInternalMaterials = true;
                    break;
                default:
                    carNode.Model = new Box(3, 1.0f, 2);
                    carNode.Material = carMat;
                    break;
            }

            carNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;

            NewtonPhysics physicsEngine = (NewtonPhysics)scene.PhysicsEngine;

            RaceCar car = new RaceCar(carNode, physicsEngine);
            for (int i = 0; i < 4; i++)
                car.Tires[i] = CreateTire((TireID)Enum.ToObject(typeof(TireID), i),
                    car.TireTransformNode[i], carNode, scene.PhysicsEngine.Gravity);

            car.Collidable = true;
            car.Interactable = true;

            car.StartPos = CarPos;

            carNode.Physics = car;
            carNode.Physics.NeverDeactivate = true;
            carNode.AddToPhysicsEngine = true;

            parentTrans.AddChild(transNode);
            transNode.AddChild(carNode);

            Newton.NewtonSetBodyLeaveWorldEvent(physicsEngine.NewtonWorld,
                car.LeaveWorldCallback);

            return car;
        }
Beispiel #4
0
        public static RaceCar AddRaceCarOld(Scene scene, TransformNode parentTrans, Vector3 CarPos, Vector4 CarColor, CarType_Enum CType)
        {
            TransformNode transNode = new TransformNode();

            //transNode.Scale = new Vector3(2.8f, 2.8f, 2.8f);
            transNode.Translation = CarPos;

            Material carMat = new Material();

            carMat.Diffuse       = CarColor;
            carMat.Specular      = Color.White.ToVector4();
            carMat.SpecularPower = 10;

            GeometryNode carNode = new GeometryNode("Race Car");
            //Intento cargar un modelo
            ModelLoader loader = new ModelLoader();

            //Cargo el modelo Dependiendo del tipo
            switch (CType)
            {
            case CarType_Enum.Basic:
                carNode.Model    = new Box(3, 1.0f, 2);
                carNode.Material = carMat;
                break;

            case CarType_Enum.Ferrary:
                carNode.Model = (Model)loader.Load("Models", "ferrari");
                ((Model)carNode.Model).UseInternalMaterials = true;
                break;

            case CarType_Enum.Tank:
                carNode.Model = (Model)loader.Load("Models", "Osirian_Battle_Tank");
                ((Model)carNode.Model).UseInternalMaterials = true;
                break;

            default:
                carNode.Model    = new Box(3, 1.0f, 2);
                carNode.Material = carMat;
                break;
            }

            carNode.Model.ShadowAttribute = ShadowAttribute.ReceiveCast;

            NewtonPhysics physicsEngine = (NewtonPhysics)scene.PhysicsEngine;

            RaceCar car = new RaceCar(carNode, physicsEngine);

            for (int i = 0; i < 4; i++)
            {
                car.Tires[i] = CreateTire((TireID)Enum.ToObject(typeof(TireID), i),
                                          car.TireTransformNode[i], carNode, scene.PhysicsEngine.Gravity);
            }

            car.Collidable   = true;
            car.Interactable = true;

            car.StartPos = CarPos;

            carNode.Physics = car;
            carNode.Physics.NeverDeactivate = true;
            carNode.AddToPhysicsEngine      = true;

            parentTrans.AddChild(transNode);
            transNode.AddChild(carNode);

            Newton.NewtonSetBodyLeaveWorldEvent(physicsEngine.NewtonWorld,
                                                car.LeaveWorldCallback);

            return(car);
        }