示例#1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 0.2f;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene            = new Scene(camera);
            this.scene.ClearColor = Color.Black.ToVec4();
            {
                var node   = DemoNode.Create();
                var ground = GroundNode.Create();
                ground.RenderUnit.Methods[0].SwitchList.Add(new PolygonModeSwitch(PolygonMode.Line));
                ground.EnableRendering = ThreeFlags.None;
                var group = new GroupNode(node, ground);
                this.scene.RootNode = group;
            }

            var list            = new ActionList();
            var transformAction = new TransformAction(scene.RootNode);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
示例#2
0
        public static DemoNode Create()
        {
            RenderMethodBuilder updateBuilder, updateBuilder2;
            {
                var vs = new VertexShader(updateVert);
                var feedbackVaryings = new string[] { outPosition, };
                IShaderProgramProvider updateProvider = new ShaderArray(feedbackVaryings, ShaderProgram.BufferMode.Separate, vs);
                var map = new AttributeMap();
                map.Add(inPosition, DemoModel.inPosition);
                var map2 = new AttributeMap();
                map2.Add(inPosition, DemoModel.inPosition2);
                updateBuilder  = new RenderMethodBuilder(updateProvider, map);
                updateBuilder2 = new RenderMethodBuilder(updateProvider, map2);
            }

            RenderMethodBuilder renderBuilder, renderBuilder2;
            {
                IShaderProgramProvider renderProvider;
                var vs = new VertexShader(renderVert);
                var fs = new FragmentShader(renderFrag);
                renderProvider = new ShaderArray(vs, fs);
                var map = new AttributeMap();
                map.Add(inPosition, DemoModel.inPosition);
                var map2 = new AttributeMap();
                map2.Add(inPosition, DemoModel.inPosition2);
                renderBuilder  = new RenderMethodBuilder(renderProvider, map);
                renderBuilder2 = new RenderMethodBuilder(renderProvider, map2);
            }

            var model = new DemoModel();
            var node  = new DemoNode(model, updateBuilder, updateBuilder2, renderBuilder, renderBuilder2);

            node.Initialize();

            return(node);
        }