Ejemplo n.º 1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 1.6f;
            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 particlesNode = ParticlesNode.Create(10000);
                this.particleNode = particlesNode;
                var attractorsNode = AttractorsNode.Create(particlesNode);
                this.attractorsNode = attractorsNode;
                var cubeNode = CubeNode.Create();
                cubeNode.RenderUnit.Methods[0].SwitchList.Add(new PolygonModeSwitch(PolygonMode.Line));
                var groupNode = new GroupNode(particlesNode, attractorsNode);//, cubeNode);
                this.scene.RootNode = groupNode;
            }

            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);
        }
Ejemplo n.º 2
0
        public static AttractorsNode Create(ParticlesNode attractorsSource)
        {
            var model = new Sphere(0.1f, 10, 40);
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmentCode);
            var array = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add("inPosition", Sphere.strPosition);
            map.Add("inColor", Sphere.strColor);
            var builder = new RenderMethodBuilder(array, map);
            var node    = new AttractorsNode(model, builder);

            node.attractorsSource = attractorsSource;
            node.Initialize();

            return(node);
        }