예제 #1
0
        private void AddObjects()
        {
            // create SceneGraph
            sceneGraph = new SceneGraph();
            // create sceneGraphObjects
            floor  = new SceneGraphObject();
            teapot = new SceneGraphObject();
            // load meshes and add them to actors
            floor.setMesh("assets/floor.obj");
            teapot.setMesh("assets/teapot.obj");
            // load a texture
            teapot.Mesh.Texture = "assets/wood.jpg";
            floor.Mesh.Texture  = "assets/wood.jpg";
            // create camera
            var camera = new Camera();

            camera.transform.RotateModel(new Vector3(1, 0, 0), 0.2f * PI);
            camera.transform.TranslateModel(new Vector3(0, 0, -20));
            // setup lights
            var light  = new Light();
            var light2 = new Light();

            light2.transform.TranslateModel(new Vector3(0, 5, 9));
            light.transform.TranslateModel(new Vector3(-12, 10, 0));
            light.color      = new Vector3(.9f, .2f, .1f);
            light2.color     = new Vector3(1f);
            light.intensity  = 200f;
            light2.intensity = 50f;
            // add scenegraphobjects to scenegraph
            sceneGraph.Add(floor);
            sceneGraph.Add(teapot);
            sceneGraph.Add(camera);
            sceneGraph.Add(light);
            sceneGraph.Add(light2);
        }
예제 #2
0
 public void Add(SceneGraphObject o)
 {
     // check for types and add o to the correct list
     if (o is Camera)
     {
         _cameras.Add(o as Camera);
         /// if o is Camera add it to _cameras and check it should be used as the main camera
         if (_camera == null)
         {
             _camera = o as Camera;
         }
     }
     else if (o is Light)
     {
         _ligthts.Add(o as Light);
     }
     /// always add o to _children to display o in the scenegraph
     _children.Add(o);
 }