protected override void CreateScene() { RenderManager.BackgroundColor = Color.CornflowerBlue; // Main Camera definition and Pick Entity Behavior FreeCamera camera = new FreeCamera("MainCamera", new Vector3(0, 40, 50), Vector3.Zero); camera.Entity.AddComponent(new PickingBehavior()); this.EntityManager.Add(camera.Entity); // Sample needs Collision groups to ignore collisions between wheels and body // Collision group 1: Body // Collision group 2: Wheels (ignores collision with body) // collision group 3: terrain (collides with body and wheels) Physic3DCollisionGroup bodyCollisiongroup = new Physic3DCollisionGroup(); Physic3DCollisionGroup wheelCollistionGroup = new Physic3DCollisionGroup(); wheelCollistionGroup.IgnoreCollisionWith(bodyCollisiongroup); Physic3DCollisionGroup terrainCollisiongroup = new Physic3DCollisionGroup(); terrainCollisiongroup.DefineCollisionWith(bodyCollisiongroup); terrainCollisiongroup.DefineCollisionWith(wheelCollistionGroup); // Creates Entities this.CreateGround(new Vector3(0, -5, 0), terrainCollisiongroup); this.CreateVehicle(bodyCollisiongroup, wheelCollistionGroup); }
protected override void CreateScene() { this.Load(WaveContent.Scenes.MyScene); // This sample needs Collision Groups to ignore such between chasis and wheels var chasisCollisionGroup = new Physic3DCollisionGroup(); var wheelCollisionGroup = new Physic3DCollisionGroup(); wheelCollisionGroup.IgnoreCollisionWith(chasisCollisionGroup); var groundCollisionGroup = new Physic3DCollisionGroup(); groundCollisionGroup.DefineCollisionWith(chasisCollisionGroup); groundCollisionGroup.DefineCollisionWith(wheelCollisionGroup); this.SetUpPhysicsOnGround(chasisCollisionGroup); this.SetUpPhysicsOnWheels(wheelCollisionGroup); this.SetUpPhysicsOnChasis(groundCollisionGroup); }
protected override void CreateScene() { Physic3DCollisionGroup DiceCollisionGroup = new Physic3DCollisionGroup(); Physic3DCollisionGroup TableCollisionGroup = new Physic3DCollisionGroup(); TableCollisionGroup.DefineCollisionWith(DiceCollisionGroup); DiceCollisionGroup.DefineCollisionWith(TableCollisionGroup); RenderManager.DebugLines = false; physicsArgs = new Physic3DCollisionEventArgs(); RenderManager.BackgroundColor = Color.CornflowerBlue; CameraPoint point1 = new CameraPoint(); CameraPoint point2 = new CameraPoint(); CameraPoint point3 = new CameraPoint(); CameraPoint point4 = new CameraPoint(); Entity ground = this.CreateGround(); this.Createwalls(); ground.FindComponent<RigidBody3D>().CollisionGroup = TableCollisionGroup; //var AnimationCamera = new PathCamera("AnimationCamera", new Vector3(0, 50, 80), Vector3.Zero, ); //var beh = new PathCameraBehavior(new List<point1,point2,point3,point4>()); //EntityManager.Add(AnimationCamera); PhysicsManager.Gravity3D = new Vector3(0, -9.8f, 0); Entity Die1 = new Entity("Die1") .AddComponent(new Transform3D()) .AddComponent(new RigidBody3D() { Restitution = GenRand(0.4, 0.7), AngularVelocity = new Vector3(2.5f, 0, 0) }) .AddComponent(new MeshCollider()) .AddComponent(new Model("Content/Dice_LowPoly_OBJ.wpk")) .AddComponent( new MaterialsMap(new BasicMaterial("Content/Red_Diffuse.wpk") { ReferenceAlpha = 0.5f })) //.AddComponent(new MaterialsMap(new BasicMaterial(Color.Black))) .AddComponent(new ModelRenderer()); float scale = .005f; Die1.FindComponent<Transform3D>().Scale.X = scale; Die1.FindComponent<Transform3D>().Scale.Y = scale; Die1.FindComponent<Transform3D>().Scale.Z = scale; Die1.FindComponent<Transform3D>().Position.Y = 2f; Die1.FindComponent<Transform3D>().Position.X = 0f; Die1.FindComponent<RigidBody3D>().CollisionGroup = DiceCollisionGroup; //Die1.FindComponent<RigidBody3D>().EnableContinuousContact = true; Die1.FindComponent<RigidBody3D>().LinearVelocity = new Vector3(Getrandom(), 0f, -3f); Die1.FindComponent<MeshCollider>().IsActive = true; Console.WriteLine(Die1.FindComponent<RigidBody3D>().Restitution); EntityManager.Add(Die1); Thread.Sleep(new TimeSpan(1000)); Entity Die2 = new Entity("Die2") .AddComponent(new Transform3D()) .AddComponent(new RigidBody3D() {Restitution = GenRand(0.4, 0.7)}) .AddComponent(new MeshCollider()) .AddComponent(new Model("Content/Dice_LowPoly_OBJ.wpk")) .AddComponent( new MaterialsMap(new BasicMaterial("Content/White_Diffuse.wpk") { ReferenceAlpha = 0.5f })) //.AddComponent(new MaterialsMap(new BasicMaterial(Color.Black))) .AddComponent(new ModelRenderer()); Die2.FindComponent<Transform3D>().Scale.X = scale; Die2.FindComponent<Transform3D>().Scale.Y = scale; Die2.FindComponent<Transform3D>().Scale.Z = scale; Die2.FindComponent<Transform3D>().Position.Y = 2f; Die2.FindComponent<Transform3D>().Position.X = 1f; Die2.FindComponent<RigidBody3D>().LinearVelocity = new Vector3(Getrandom(), 0f, -3f); Die2.FindComponent<RigidBody3D>().CollisionGroup = DiceCollisionGroup; //Die1.FindComponent<RigidBody3D>().EnableContinuousContact = true; Die2.FindComponent<MeshCollider>().IsActive = true; Console.WriteLine(Die2.FindComponent<RigidBody3D>().Restitution); EntityManager.Add(Die2); //var mainCamera = new ViewCamera("MainCamera", new Vector3(0, 3, 0), // new Vector3(Die1.FindComponent<Transform3D>().Position.X, // Die1.FindComponent<Transform3D>().Position.Y, Die1.FindComponent<Transform3D>().Position.Z)); //xyz //EntityManager.Add(mainCamera); //RenderManager.SetActiveCamera(mainCamera.Entity); var mainCamera = new FreeCamera("MainCamera", new Vector3(-10, 3, 0), Vector3.Zero); // new Vector3(Die1.FindComponent<Transform3D>().Position.X, //Die1.FindComponent<Transform3D>().Position.Y, Die1.FindComponent<Transform3D>().Position.Z)); EntityManager.Add(mainCamera); RenderManager.SetActiveCamera(mainCamera.Entity); //mainCamera.Entity.AddComponent(new Cam(Die1)); this.AddSceneBehavior(new sb(), sb.Order.PostUpdate); }