示例#1
0
        private SceneNodeBase GetRootNode()
        {
            var rootNode = new GroupNode();

            {
                var axisNode = AxisNode.Create();
                axisNode.Scale = new vec3(1, 1, 1) * 2;
                rootNode.Children.Add(axisNode);
            }
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    var cubeNode = CubeNode.Create();
                    cubeNode.WorldPosition = new vec3(i - 1, 0, j - 1) * 2;
                    rootNode.Children.Add(cubeNode);
                }
            }
            {
                var groundNode = GroundNode.Create();
                rootNode.Children.Add(groundNode);
            }

            return(rootNode);
        }
示例#2
0
        public static AxisNode Create()
        {
            // vertex buffer and index buffer.
            var model = new AxisModel();
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmnetCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", AxisModel.strPosition);
            map.Add("inColor", AxisModel.strColor);
            // build a render method.
            var builder = new RenderMethodBuilder(array, map, new LineWidthSwitch(3));
            // create node.
            var node = new AxisNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }