示例#1
0
        private SceneNodeBase GetRootElement()
        {
            var rectangle = RectangleNode.Create();

            rectangle.Scale *= 3;
            string folder = System.Windows.Forms.Application.StartupPath;

            rectangle.TextureSource = new TextureSource(System.IO.Path.Combine(folder, @"texture2D.png"));

            //var blend = RectangleNode.Create();
            //blend.Scale *= 1.5f;
            //blend.WorldPosition = new vec3(-0.5f, 0, 0.1f);
            //blend.RenderUnit.Methods[0].StateList.Add(new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha));
            //blend.TextureSource = new TextureSource(@"particle.png");

            //var blend2 = RectangleNode.Create();
            //blend2.Scale *= 1.5f;
            //blend2.WorldPosition = new vec3(0.5f, 0, 0.2f);
            //blend2.RenderUnit.Methods[0].StateList.Add(new BlendState(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha));
            //blend2.TextureSource = new TextureSource(@"particle.png");

            // note: this tells us that the right way is to render the nearest transparenct object at last.
            var group = new GroupNode(rectangle);//, blend, blend2);

            var axis = AxisNode.Create();

            group.Children.Add(axis);
            return(group);
        }
示例#2
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);
        }
示例#3
0
        //private SceneNodeBase GetRootElement()
        //{
        //    var rectangle = DistanceFieldNode.Create();
        //    rectangle.Scale *= 3;
        //    string folder = System.Windows.Forms.Application.StartupPath;
        //    rectangle.TextureSource = new TextureSource(System.IO.Path.Combine(folder, @"texture2D.png"));

        //    var group = new GroupNode(rectangle);//, blend, blend2);

        //    var axis = AxisNode.Create();
        //    group.Children.Add(axis);
        //    return group;
        //}

        private SceneNodeBase GetRootElement()
        {
            var group = new GroupNode();

            {
                string      dictFilename   = "VeraMoBI.ttf_sdf.txt";
                string      glyphsFilename = "VeraMoBI.ttf_sdf.png";
                GlyphServer server         = GlyphServer.Load(dictFilename, glyphsFilename);
                var         node           = SingleLineNode.Create(100, server);
                node.TextColor = Color.Red;
                node.Text      = "The quick brown fox jumps over a lazy dog!";
                group.Children.Add(node);
                this.singleLineNode = node;
            }
            {
                var axis = AxisNode.Create();
                group.Children.Add(axis);
            }

            return(group);
        }
示例#4
0
        private SceneNodeBase GetRootNode()
        {
            var group = new GroupNode();

            var sphere   = new Sphere(1, 40, 80);
            var filename = "sphere.obj_";

            sphere.DumpObjFile(filename, "sphere");
            var          parser = new ObjVNFParser(false);
            ObjVNFResult result = parser.Parse(filename);

            if (result.Error != null)
            {
                Console.WriteLine("Error: {0}", result.Error);
            }
            else
            {
                ObjVNFMesh mesh  = result.Mesh;
                var        model = new ObjVNF(mesh);
                model.DumpObjFile("vnf" + filename, "sphere");
                var sphereNode = ObjVNFNode.Create(mesh);
                (new FormPropertyGrid(sphereNode)).Show();
                group.Children.Add(sphereNode);
                {
                    var planeNode = PlaneNode.Create();
                    planeNode.Color         = new vec4(1, 1, 1, 1);
                    planeNode.WorldPosition = new vec3(0, 1, 0);
                    planeNode.Scale         = new vec3(1, 1, 1) * 0.5f;
                    sphereNode.Children.Add(planeNode);
                }
                {
                    var axisNode = AxisNode.Create();
                    axisNode.WorldPosition = new vec3(0, 1, 0);
                    axisNode.Scale         = new vec3(1, 1, 1) * 0.5f;
                    sphereNode.Children.Add(axisNode);
                }
            }

            return(group);
        }
示例#5
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 6, 4) * 3;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);

            //(new FormTree(scene)).Show();

            this.scene.RootNode = new GroupNode();
            {
                var axisNode = AxisNode.Create();
                axisNode.Scale = new vec3(1, 1, 1) * 30;
                this.scene.RootNode.Children.Add(axisNode);
            }

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            this.pickingAction = new Picking(scene);

            //this.triangleTip = new LegacyTriangleNode();
            //this.quadTip = new LegacyQuadNode();
            this.tipNode = HighlightGeometryNode.Create();

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
            {
                ObjItem[] items = HanoiTower.GetDataSource();
                for (int i = 0; i < items.Length; i++)
                {
                    var item     = items[i];
                    var filename = "item" + (i) + ".obj";
                    item.model.DumpObjFile(filename, "item" + (i));
                    var          parser = new ObjVNFParser(false);
                    ObjVNFResult result = parser.Parse(filename);
                    if (result.Error != null)
                    {
                        //Console.WriteLine("Error: {0}", result.Error);
                    }
                    else
                    {
                        ObjVNFMesh mesh = result.Mesh;
                        var        node = ObjVNFNode.Create(mesh);
                        node.Children.Add(new LegacyBoundingBoxNode(node.ModelSize));
                        //float max = node.ModelSize.max();
                        //node.Scale *= 7.0f / max;
                        node.WorldPosition = item.position;
                        node.Diffuse       = item.color;
                        var rootElement = this.scene.RootNode;
                        this.scene.RootNode.Children.Add(node);
                        //if (rootElement != null) { rootElement.Dispose(); }
                    }
                }
            }
        }