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

            {
                var node = CubeNode.Create();
                node.WorldPosition = new vec3(1, 1, 1) * 0.5f;
                node.Scale         = new vec3(1, 1, 1) * 0.5f;
                rootNode.Children.Add(node);
            }
            {
                var node = SliceNode.Create();
                //node.Scale = new vec3(1, 1, 1) * 5;
                //rootNode.Children.Add(node);
                this.sliceNode = node;
            }
            {
                var node = IntersectionNode.Create();
                //node.Scale = new vec3(1, 1, 1) * 5;
                rootNode.Children.Add(node);
                this.intersectionNode = node;
            }
            //{
            //    var node = GroundNode.Create();
            //    node.Scale = new vec3(1, 1, 1) * 5;
            //    node.Color = Color.Yellow.ToVec4();
            //    rootNode.Children.Add(node);
            //}

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

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

            // initialize node.
            node.Initialize();

            return(node);
        }