Esempio n. 1
0
        private SceneNodeBase GetRootNode()
        {
            var rootNode = new GroupNode();

            {
                var axisNode = AxisNode.Create();
                axisNode.Scale = new vec3(1, 1, 1) * 2f;
                rootNode.Children.Add(axisNode);
            }
            {
                var cameraNode = CameraNode.Create();
                cameraNode.Scale = new vec3(1, 1, 1) * 1f;
                rootNode.Children.Add(cameraNode);
            }
            {
                var perspectiveNode = PerspectiveNode.Create();
                rootNode.Children.Add(perspectiveNode);
            }
            //{
            //    var cameraOutlineNode = CameraOutlineNode.Create();
            //    rootNode.Children.Add(cameraOutlineNode);
            //}
            //{
            //    var groundNode = GroundNode.Create();
            //    rootNode.Children.Add(groundNode);
            //}
            {
                var sliceNode = SliceNode.Create();
                sliceNode.WorldPosition = new vec3(0, 0, -7);
                sliceNode.Scale         = new vec3(1, 1, 1) * 7;
                rootNode.Children.Add(sliceNode);
            }
            {
                var cubeNode = CubeNode.Create();
                cubeNode.WorldPosition = new vec3(0, 0, -7);
                cubeNode.RotationAngle = 35;
                cubeNode.RotationAxis  = new vec3(1, 1, 1);
                rootNode.Children.Add(cubeNode);
            }
            {
                var groundNode = GroundNode.Create();
                groundNode.Scale         = new vec3(1, 1, 1) * 0.5f;
                groundNode.WorldPosition = new vec3(0, 0, -7);
                groundNode.RotationAngle = 90;
                groundNode.RotationAxis  = new vec3(1, 0, 0);
                rootNode.Children.Add(groundNode);
            }

            return(rootNode);
        }
Esempio n. 2
0
        public static GroundNode Create()
        {
            // vertex buffer and index buffer.
            var model = new GroundModel(14);
            // 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", GroundModel.strPosition);
            // build a render method.
            var builder = new RenderMethodBuilder(array, map, new LineWidthSwitch(1));
            // create node.
            var node = new GroundNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }