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; }
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); }