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

            {
                var axisNode = AxisNode.Create();
                axisNode.Scale = new vec3(1, 1, 1) * 0.2f;
                rootNode.Children.Add(axisNode);
            }
            {
                var cameraNode = CameraNode.Create();
                cameraNode.Scale = new vec3(1, 1, 1) * 0.2f;
                rootNode.Children.Add(cameraNode);
            }
            {
                //var cameraOutlineNode = CameraOutlineNode.Create();
                //rootNode.Children.Add(cameraOutlineNode);
            }
            {
                var cubeNode = CubeNode.Create();
                cubeNode.WorldPosition = new vec3(0, 0, -5);
                cubeNode.RotationAxis  = new vec3(1, 1, 1);
                cubeNode.RotationAngle = 17;

                rootNode.Children.Add(cubeNode);
            }
            {
                //var miniGroup = new SwitchListGroupNode();
                {
                    var rectNode = RectNode.Create();
                    rectNode.WorldPosition = new vec3(0, 0, -5);
                    rectNode.Scale         = new vec3(1, 1, 1) * 3;

                    rootNode.Children.Add(rectNode);
                }
                {
                    var perspectiveNode = PerspectiveNode.Create();
                    rootNode.Children.Add(perspectiveNode);
                }
                //miniGroup.SwitchList.Add(new BlendSwitch(BlendEquationMode.Add, BlendSrcFactor.SrcAlpha, BlendDestFactor.OneMinusSrcAlpha));
                //rootNode.Children.Add(miniGroup);
            }
            {
                var groundNode = GroundNode.Create();
                //rootNode.Children.Add(groundNode);
            }

            return(rootNode);
        }
Ejemplo n.º 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(fragmentCode);
            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(5));
            // create node.
            var node = new AxisNode(model, builder);

            // initialize node.
            node.Initialize();

            return(node);
        }