Ejemplo n.º 1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var thread = System.Threading.Thread.CurrentThread;
            {
                this.winGLCanvas1.MakeCurrent();
                var position = new vec3(5, 3, 4) * 0.5f;
                var center   = new vec3(0, 0, 0);
                var up       = new vec3(0, 1, 0);
                var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
                this.cubeNode1 = CubeNode.Create();
                var scene = new Scene(camera);
                scene.RootNode = cubeNode1;
                this.scene1    = scene;

                var list            = new ActionList();
                var transformAction = new TransformAction(scene);
                list.Add(transformAction);
                var renderAction = new RenderAction(scene);
                list.Add(renderAction);
                this.actionList1 = list;

                //// uncomment these lines to enable manipualter of camera!
                //var manipulater = new FirstPerspectiveManipulater();
                //manipulater.BindingMouseButtons = System.Windows.Forms.MouseButtons.Right;
                //manipulater.Bind(camera, this.winGLCanvas1);
            }
            {
                this.winGLCanvas2.MakeCurrent();
                var position = new vec3(5, 3, 4) * 0.5f;
                var center   = new vec3(0, 0, 0);
                var up       = new vec3(0, 1, 0);
                var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas2.Width, this.winGLCanvas2.Height);
                this.cubeNode2 = CubeNode.Create();
                var scene = new Scene(camera);
                scene.RootNode = cubeNode2;
                this.scene2    = scene;

                var list            = new ActionList();
                var transformAction = new TransformAction(scene);
                list.Add(transformAction);
                var renderAction = new RenderAction(scene);
                list.Add(renderAction);
                this.actionList2 = list;

                //// uncomment these lines to enable manipualter of camera!
                //var manipulater = new FirstPerspectiveManipulater();
                //manipulater.BindingMouseButtons = System.Windows.Forms.MouseButtons.Right;
                //manipulater.Bind(camera, this.winGLCanvas1);
            }
        }
Ejemplo n.º 2
0
        public static CubeNode Create()
        {
            // model provides vertex buffer and index buffer(within an IDrawCommand).
            var model = new CubeModel();
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", CubeModel.strPosition);
            // help to build a render method.
            var builder = new RenderMethodBuilder(array, map);
            // create node.
            var node = new CubeNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }