Esempio n. 1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            //CSharpGL.HowTransformFeedbackWorks.Run();
            var position = new vec3(5, 3, 4);
            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 = ParticleDemoNode.Create(10000);
                var node   = DemoNode.Create();
                var ground = GroundNode.Create();
                ground.RenderUnit.Methods[0].StateList.Add(new PolygonModeState(PolygonMode.Line));
                var group = new GroupNode(node, ground);
                this.scene.RootElement = group;
            }

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Esempio n. 2
0
        public static DemoNode Create()
        {
            IShaderProgramProvider updateProvider, renderProvider;
            {
                var vs = new VertexShader(updateVert, inPosition, inVelocity);
                var feedbackVaryings = new string[] { outPosition, outVelocity };
                updateProvider = new ShaderArray(feedbackVaryings, ShaderProgram.BufferMode.Separate, vs);
            }
            {
                var vs = new VertexShader(renderVert, inPosition);
                var fs = new FragmentShader(renderFrag);
                renderProvider = new ShaderArray(vs, fs);
            }
            RenderMethodBuilder updateBuilder, updateBuilder2, renderBuilder, renderBuilder2;
            {
                var map = new AttributeMap();
                map.Add(inPosition, DemoModel.inPosition);
                map.Add(inVelocity, DemoModel.inVelocity);
                updateBuilder = new RenderMethodBuilder(updateProvider, map);
            }
            {
                var map = new AttributeMap();
                map.Add(inPosition, DemoModel.inPosition2);
                map.Add(inVelocity, DemoModel.inVelocity2);
                updateBuilder2 = new RenderMethodBuilder(updateProvider, map);
            }
            {
                var map = new AttributeMap();
                map.Add(inPosition, DemoModel.inPosition);
                map.Add(inVelocity, DemoModel.inVelocity);
                renderBuilder = new RenderMethodBuilder(renderProvider, map);
            }
            {
                var map = new AttributeMap();
                map.Add(inPosition, DemoModel.inPosition2);
                map.Add(inVelocity, DemoModel.inVelocity2);
                renderBuilder2 = new RenderMethodBuilder(renderProvider, map);
            }

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

            node.Initialize();

            return(node);
        }