Пример #1
0
        private SceneNodeBase GetTree(Scene scene)
        {
            var children = new List <SceneNodeBase>();

            {
                const float alpha  = 0.2f;
                var         colors = new vec4[] { new vec4(1, 0, 0, alpha), new vec4(0, 1, 0, alpha), new vec4(0, 0, 1, alpha) };

                for (int k = -1; k < 2; k++)
                {
                    for (int j = -1; j < 2; j++)
                    {
                        int index = 0;
                        for (int i = -1; i < 2; i++)
                        {
                            vec3 worldPosition = new vec3(i * 2, j * 2, k * 2);
                            var  cubeNode      = CubeNode.Create();
                            cubeNode.WorldPosition = worldPosition;
                            cubeNode.Color         = colors[index++];
                            cubeNode.Name          = string.Format("{0},{1},{2}:{3}", k, j, i, cubeNode.Color);

                            children.Add(cubeNode);
                        }
                    }
                }
            }
            this.peelingNode = new PeelingNode(children.ToArray());

            return(this.peelingNode);
        }
Пример #2
0
        public static CubeNode Create()
        {
            RenderMethodBuilder initBuilder, peelBuilder;
            {
                var vs       = new VertexShader(Shaders.initVert);
                var fs       = new FragmentShader(Shaders.initFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", CubeModel.positions);
                initBuilder = new RenderMethodBuilder(provider, map);
            }
            {
                var vs       = new VertexShader(Shaders.peelVert);// reuse blend vertex shader.
                var fs       = new FragmentShader(Shaders.peelFrag);
                var provider = new ShaderArray(vs, fs);
                var map      = new AttributeMap();
                map.Add("vVertex", CubeModel.positions);
                peelBuilder = new RenderMethodBuilder(provider, map);
            }

            var model = new CubeModel();
            var node  = new CubeNode(model, initBuilder, peelBuilder);

            node.Initialize();

            return(node);
        }
Пример #3
0
        private void trvScene_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (lastSelected != null)
            {
                vec4  color = lastSelected.Color;
                float alpha = color.w;
                lastSelected.Color = new vec4(color.x, color.y, color.z, alpha / 3.0f);
                lastSelected       = null;
            }

            var cube = e.Node.Tag as CubeNode;

            if (cube != null)
            {
                vec4  color = cube.Color;
                float alpha = color.w;
                cube.Color        = new vec4(color.x, color.y, color.z, alpha * 3.0f);
                this.lastSelected = cube;
            }

            this.propGrid.SelectedObject = e.Node.Tag;

            this.lblState.Text = string.Format("{0} objects selected.", 1);
        }