Exemplo n.º 1
0
        public MeshesScene(Demo demo, string name, int instanceIndex, string info)
        {
            this.demo = demo;
            this.name = name;
            this.instanceIndexName = " " + instanceIndex.ToString();
            this.info = info;

            // Create a new objects in the scene
            skyInstance1     = new Sky(demo, 1);
            cursorInstance   = new Cursor(demo);
            shotInstance     = new Shot(demo);
            columnInstance1  = new Column(demo, 1);
            triangleMesh1    = new TriangleMesh1(demo, 1);
            triangleMesh2    = new TriangleMesh2(demo, 1);
            torusMesh        = new TorusMesh(demo, 1);
            camera2Instance1 = new Camera2(demo, 1);
            lightInstance    = new Lights(demo);

            // Create a new controllers in the scene
            skyDraw1Instance1          = new SkyDraw1(demo, 1);
            cursorDraw1Instance        = new CursorDraw1(demo);
            camera2Animation1Instance1 = new Camera2Animation1(demo, 1);
            camera2Draw1Instance1      = new Camera2Draw1(demo, 1);
        }
Exemplo n.º 2
0
        public void Create()
        {
            string sceneInstanceIndexName = name + instanceIndexName;

            if (demo.Engine.Factory.PhysicsSceneManager.Find(sceneInstanceIndexName) != null)
            {
                return;
            }

            scene = demo.Engine.Factory.PhysicsSceneManager.Create(sceneInstanceIndexName);

            // Initialize maximum number of solver iterations for the scene
            scene.MaxIterationCount = 10;

            // Initialize time of simulation for the scene
            scene.TimeOfSimulation = 1.0f / 15.0f;

            Initialize();

            // Initialize objects in the scene
            skyInstance1.Initialize(scene);
            cursorInstance.Initialize(scene);
            shotInstance.Initialize(scene);
            columnInstance1.Initialize(scene);
            triangleMesh1.Initialize(scene);
            triangleMesh2.Initialize(scene);
            torusMesh.Initialize(scene);
            camera2Instance1.Initialize(scene);
            lightInstance.Initialize(scene);

            // Initialize controllers in the scene
            skyDraw1Instance1.Initialize(scene);
            cursorDraw1Instance.Initialize(scene);
            camera2Animation1Instance1.Initialize(scene);
            camera2Draw1Instance1.Initialize(scene);

            // Create shapes shared for all physics objects in the scene
            // These shapes are used by all objects in the scene
            Demo.CreateSharedShapes(demo, scene);

            // Create shapes for objects in the scene
            Sky.CreateShapes(demo, scene);
            Cursor.CreateShapes(demo, scene);
            Shot.CreateShapes(demo, scene);
            Column.CreateShapes(demo, scene);
            TriangleMesh1.CreateShapes(demo, scene);
            TriangleMesh2.CreateShapes(demo, scene);
            TorusMesh.CreateShapes(demo, scene);
            Camera2.CreateShapes(demo, scene);
            Lights.CreateShapes(demo, scene);

            // Create physics objects for objects in the scene
            skyInstance1.Create(new Vector3(0.0f, 0.0f, 0.0f));
            cursorInstance.Create();
            shotInstance.Create();
            columnInstance1.Create(new Vector3(-500.0f, -20.0f, 1000.0f), Vector3.One, Quaternion.Identity, "Box", 4, new Vector3(8.0f, 8.0f, 8.0f), 1.0f, true, 0.1f, 0.05f);
            triangleMesh1.Create(new Vector3(0.0f, 60.0f, 0.0f), Vector3.One, Quaternion.Identity, 0.0f);
            triangleMesh2.Create(new Vector3(0.0f, 60.0f, 0.0f), Vector3.One, Quaternion.Identity, 0.0f);
            torusMesh.Create(new Vector3(-550.0f, -20.0f, 1000.0f), Vector3.One, Quaternion.Identity, 100000.0f);
            camera2Instance1.Create(new Vector3(-550.0f, -90.0f, 1020.0f), Quaternion.Identity, Quaternion.FromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(-95.0f)), Quaternion.Identity, true);

            lightInstance.CreateLightPoint(0, "Glass", new Vector3(-530.0f, -106.0f, 1020.0f), new Vector3(1.0f, 0.7f, 0.0f), 20.0f, 1.0f);
            lightInstance.CreateLightPoint(1, "Glass", new Vector3(-500.0f, -116.0f, 1040.0f), new Vector3(0.5f, 0.7f, 0.1f), 20.0f, 1.0f);
            lightInstance.CreateLightPoint(2, "Glass", new Vector3(-470.0f, -124.0f, 1040.0f), new Vector3(1.0f, 0.7f, 0.0f), 20.0f, 1.0f);
            lightInstance.CreateLightPoint(3, "Glass", new Vector3(45.0f, -275.0f, 380.0f), new Vector3(1.0f, 0.7f, 0.5f), 20.0f, 1.0f);
            lightInstance.CreateLightPoint(4, "Glass", new Vector3(0.0f, -100.0f, 0.0f), new Vector3(1.0f, 1.0f, 0.5f), 20.0f, 1.0f);
            lightInstance.CreateLightPoint(5, "Glass", new Vector3(-470.0f, -124.0f, 1020.0f), new Vector3(0.3f, 0.7f, 0.5f), 20.0f, 1.0f);
            lightInstance.CreateLightSpot(0, "Glass", new Vector3(-530.0f, -104.0f, 1000.0f), new Vector3(0.1f, 0.7f, 1.0f), 20.0f, 1.0f);
            lightInstance.CreateLightSpot(1, "Glass", new Vector3(-500.0f, -114.0f, 1020.0f), new Vector3(1.0f, 0.5f, 0.2f), 20.0f, 1.0f);
            lightInstance.CreateLightSpot(2, "Glass", new Vector3(-470.0f, -124.0f, 1000.0f), new Vector3(0.5f, 1.0f, 0.2f), 20.0f, 1.0f);

            // Set controllers for objects in the scene
            SetControllers();
        }