Пример #1
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(0, 0, 0.9f);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);
            {
                this.computeShaderNode = ComputeShaderNode.Create();
                this.scene.RootNode    = this.computeShaderNode;
            }
            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
            manipulater.StepLength = 0.1f;

            MessageBox.Show("Press 'n' to switch config!");
        }
Пример #2
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 1f;
            var center = new vec3(0, 0, 0);
            var up = new vec3(0, 1, 0);
            var camera = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
            int width = this.winGLCanvas1.Width, height = this.winGLCanvas1.Height;
            var scene = new Scene(camera);

            scene.RootNode = GetRootNode();
            this.scene     = scene;

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #3
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var rootElement = GetRootElement();
            //var teapot = ShadowMappingRenderer.Create();
            //var rootElement = teapot;

            var position = new vec3(0, 0, 1);
            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, this.winGLCanvas1)
            {
                RootElement = rootElement,
                ClearColor  = Color.SkyBlue.ToVec4(),
            };

            Match(this.trvScene, scene.RootElement);
            this.trvScene.ExpandAll();

            var tansformAction      = new TransformAction(scene);
            var shadowMappingAction = new ShadowMappingAction(scene);
            var renderAction        = new RenderAction(scene);
            var actionList          = new ActionList();

            actionList.Add(tansformAction); actionList.Add(shadowMappingAction); actionList.Add(renderAction);
            this.actionList = actionList;
        }
Пример #4
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 0.2f;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);
            {
                var manipulater = new ArcBallManipulater(GLMouseButtons.Left | GLMouseButtons.Right);
                manipulater.Bind(camera, this.winGLCanvas1);
                manipulater.Rotated += manipulater_Rotated;
                var node = RaycastNode.Create();
                this.scene.RootNode = node;
                (new FormPropertyGrid(node)).Show();
            }

            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();
        }
Пример #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.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);

            this.scene.RootNode = new GroupNode();
            (new FormPropertyGrid(scene)).Show();

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);

            var rootElement = this.scene.RootNode;

            rootElement.Children.Clear();
            string filename = @"D:\GitHub\CSharpGL\Demos\EZMFileViewer\media\dwarf_anim.ezm";

            CreateTextureNode(filename);
            CreateBoneLineNode(filename);
            CreateBonePointNode(filename);
        }
Пример #6
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 0.5f;
            var center = new vec3(0, 0, 0);
            var up = new vec3(0, 1, 0);
            var camera = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
            int width = this.winGLCanvas1.Width, height = this.winGLCanvas1.Height;

            this.rectNode = RectNode.Create(0, 0, width, height);
            var scene = new Scene(camera);

            scene.RootNode = rectNode;
            this.scene     = scene;

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

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

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


            Match(this.trvScene, scene.RootNode);
            this.trvScene.ExpandAll();
        }
Пример #7
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Ortho, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
            var scene    = new Scene(camera);
            var rootNode = GetRootNode();

            scene.RootNode = rootNode;
            this.scene     = scene;
            this.rootNode  = rootNode;

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

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

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

            // Enable manipualter of camera!
            var manipulater = new FirstPerspectiveManipulater();

            manipulater.BindingMouseButtons = GLMouseButtons.Right;
            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #8
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var rootElement = GetTree();

            var position = new vec3(5, 3, 4) * 0.2f;
            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)

            {
                RootNode   = rootElement,
                ClearColor = Color.SkyBlue.ToVec4(),
            };

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.StepLength = 0.1f;
            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #9
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var rootElement = GetRootElement();

            var position = new vec3(4, 3, 5) * 0.5f;
            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)

            {
                RootNode   = rootElement,
                ClearColor = Color.SkyBlue.ToVec4(),
            };

            var tansformAction = new TransformAction(scene.RootNode);
            var renderAction   = new RenderAction(scene);
            var actionList     = new ActionList();

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

            this.pickingAction = new Picking(scene);

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);

            foreach (var item in Enum.GetNames(typeof(LogicOperationCode)))
            {
                this.cmbLogicOperation.Items.Add(item);
            }
        }
Пример #10
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position    = new vec3(5, 3, 4) * 1f;
            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);
            var scene       = new Scene(camera);
            var rootElement = GetTree(scene);

            scene.RootNode   = rootElement;
            scene.ClearColor = Color.SkyBlue.ToVec4();
            this.scene       = scene;

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

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

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

            Match(this.trvScene, scene.RootNode);
            this.trvScene.ExpandAll();

            // Note: uncomment this to enable camera movement.
            //var manipulater = new FirstPerspectiveManipulater();
            //manipulater.StepLength = 0.1f;
            //manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #11
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 1.6f;
            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);
            this.scene.ClearColor = Color.Black.ToVec4();
            {
                var particlesNode = ParticlesNode.Create(10000);
                this.particleNode = particlesNode;
                var attractorsNode = AttractorsNode.Create(particlesNode);
                this.attractorsNode = attractorsNode;
                var cubeNode = CubeNode.Create();
                cubeNode.RenderUnit.Methods[0].SwitchList.Add(new PolygonModeSwitch(PolygonMode.Line));
                var groupNode = new GroupNode(particlesNode, attractorsNode);//, cubeNode);
                this.scene.RootNode = groupNode;
            }

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #12
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var rootElement = GetRootElement();

            var position = new vec3(-3, 3, 4) * 0.5f;
            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)
            {
                RootElement = rootElement,
                ClearColor = Color.SkyBlue.ToVec4(),
            };

            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 PickingAction(scene);
            this.triangleTip = new LegacyTriangleNode();
            this.quadTip = new LegacyQuadNode();
            this.tipList.Add(this.triangleTip);
            this.tipList.Add(this.quadTip);

            Match(this.trvScene, scene.RootElement);
            this.trvScene.ExpandAll();

            var manipulater = new FirstPerspectiveManipulater();
            manipulater.BindingMouseButtons = GLMouseButtons.Right;
            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #13
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            //var rootElement = GetLegacyPropellerLegacyFlabellum();
            //var rootElement = GetLegacyPropellerFlabellum();
            //var rootElement = GetPropellerLegacyFlabellum();
            //var rootElement = GetPropellerFlabellum();
            var rootElement = GetPropellerRTT();

            var position = new vec3(5, 3, 4);
            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, this.winGLCanvas1)
            {
                RootElement = rootElement,
                ClearColor  = Color.SkyBlue.ToVec4(),
            };

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

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

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

            this.legacyPickingAction = new LegacyPickingAction(scene);

            Match(this.trvScene, scene.RootElement);
            this.trvScene.ExpandAll();
        }
Пример #14
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(0, 0, 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, this.winGLCanvas1);
            {
                var node = GrayFilterNode.Create();
                this.scene.RootElement = node;
            }
            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #15
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var rootElement = GetRootElement();

            var position = new vec3(4, 3, 5) * 0.5f;
            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)

            {
                RootElement = rootElement,
                ClearColor  = Color.SkyBlue.ToVec4(),
            };

            Match(this.trvScene, scene.RootElement);
            this.trvScene.ExpandAll();

            var tansformAction = new TransformAction(scene);
            var renderAction   = new RenderAction(scene);
            var actionList     = new ActionList();

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

            this.pickingAction = new PickingAction(scene);

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #16
0
 private void Render()
 {
     if (ActiveByHierarchy)
     {
         RenderAction?.Invoke();
     }
 }
Пример #17
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            SceneNodeBase rootElement = GetRootElement();

            var position = new vec3(1, 0, 4);
            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)
            {
                RootNode   = rootElement,
                ClearColor = Color.SkyBlue.ToVec4(),
            };

            var list = new ActionList();

            var transformAction = new TransformAction(scene);

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

            list.Add(renderAction);

            this.actionList = list;

            MessageBox.Show("Press 'n' to switch texture indexes!");
        }
Пример #18
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            //CSharpGL.HowTransformFeedbackWorks.Run();
            var position = new vec3(5, 3, 4);
            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)
            ;
            //this.scene.ClearColor = Color.Black.ToVec4();
            {
                //var node = ParticleDemoNode.Create(10000);
                var node   = DemoNode.Create();
                var ground = GroundNode.Create();
                ground.RenderUnit.Methods[0].StateList.Add(new PolygonModeState(PolygonMode.Line));
                var group = new GroupNode(node, ground);
                this.scene.RootNode = group;
            }

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #19
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var     position = new vec3(5, 3, 4) * 0.3f;
            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);
            Texture texture0, texture1, texture2;

            GetTextures(out texture0, out texture1, out texture2);
            texture0.TextureUnitIndex = 0; // glActiveTexture(GL_TEXTURE0 + 0); glBindTexture(GL_TEXTURE_2D, texture0.TextureId);
            texture1.TextureUnitIndex = 0; // glActiveTexture(GL_TEXTURE0 + 0); glBindTexture(GL_TEXTURE_1D, texture1.TextureId);
            texture2.TextureUnitIndex = 1; // glActiveTexture(GL_TEXTURE0 + 1); glBindTexture(GL_TEXTURE_2D, texture2.TextureId);
            this.cubeNode             = CubeNode.Create(texture0, texture1, texture2);
            var scene = new Scene(camera);

            scene.RootNode = cubeNode;
            this.scene     = scene;

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

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

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

            //// uncomment these lines to enable manipualter of camera!
            //var manipulater = new FirstPerspectiveManipulater();
            //manipulater.BindingMouseButtons = System.Windows.Forms.MouseButtons.Right;
            //manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #20
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var     position = new vec3(5, 3, 4) * 0.5f;
            var     center   = new vec3(0, 0, 0);
            var     up       = new vec3(0, 1, 0);
            var     camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
            Texture texture  = GetCubemapTexture();

            this.node = CubemapViewerNode.Create(texture);
            var scene = new Scene(camera);

            scene.RootNode = node;
            this.scene     = scene;

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

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

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

            //// uncomment these lines to enable manipualter of camera!
            //var manipulater = new FirstPerspectiveManipulater();
            //manipulater.BindingMouseButtons = System.Windows.Forms.MouseButtons.Right;
            //manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #21
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var rootElement = GetTree();

            var position = new vec3(5, 3, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera)

            {
                RootNode   = rootElement,
                ClearColor = Color.SkyBlue.ToVec4(),
            };

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

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

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

            Match(this.trvScene, scene.RootNode);
            this.trvScene.ExpandAll();
        }
Пример #22
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 0.2f;
            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);
            this.scene.ClearColor = Color.Black.ToVec4();
            {
                var node   = DemoNode.Create();
                var ground = GroundNode.Create();
                ground.RenderUnit.Methods[0].SwitchList.Add(new PolygonModeSwitch(PolygonMode.Line));
                ground.EnableRendering = ThreeFlags.None;
                var group = new GroupNode(node, ground);
                this.scene.RootNode = group;
            }

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #23
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(-0.2f, 0, 1) * 14;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);
            {
                var   node = NormalMappingNode.Create();
                float max  = node.ModelSize.max();
                node.Scale         *= 16.0f / max;
                this.rootNode       = node;
                this.scene.RootNode = node;

                (new FormProperyGrid(node)).Show();
            }

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #24
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            foreach (var item in Enum.GetNames(typeof(EnvironmentMappingNode.Ratio)))
            {
                this.cmbRatios.Items.Add(item);
            }

            var position = new vec3(8, 0, 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);

            var totalBmp = new Bitmap(@"cubemaps_skybox.png");

            Bitmap[] bitmaps = GetBitmaps(totalBmp);
            this.skybox = SkyboxNode.Create(bitmaps); this.skybox.Scale *= 60;
            string       objFilename = "nanosuit.obj_";
            var          parser      = new ObjVNFParser(false);
            ObjVNFResult result      = parser.Parse(objFilename);

            if (result.Error != null)
            {
                MessageBox.Show(result.Error.ToString());
            }
            else
            {
                var model = new ObjVNF(result.Mesh);
                var node  = EnvironmentMappingNode.Create(
                    this.skybox.SkyboxTexture,
                    model, ObjVNF.strPosition, ObjVNF.strNormal);
                node.ModelSize = model.GetSize();
                float max = node.ModelSize.max();
                node.Scale *= 20.0f / max;
                node.Children.Add(new LegacyBoundingBoxNode(node.ModelSize));
                this.environmentMappingNode = node;

                var group = new GroupNode(this.environmentMappingNode, this.skybox);

                this.scene = new Scene(camera, this.winGLCanvas1)
                {
                    RootElement = group,
                };

                var list            = new ActionList();
                var transformAction = new TransformAction(scene);
                list.Add(transformAction);
                var renderAction = new RenderAction(scene);
                list.Add(renderAction);
                this.actionList = list;

                var manipulater = new FirstPerspectiveManipulater();
                manipulater.Bind(camera, this.winGLCanvas1);

                this.pickingAction = new PickingAction(scene);

                this.triangleTip = new LegacyTriangleNode();
                this.quadTip     = new LegacyQuadNode();
            }
        }
Пример #25
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(-0.2f, 0, 1) * 14;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);
            var rootNode = new GroupNode();

            this.scene.RootNode = rootNode;
            {
                var sphere   = new Sphere2();//(1, 40, 80);
                var filename = Path.Combine(System.Windows.Forms.Application.StartupPath, "sphere2.obj_");
                sphere.DumpObjFile(filename, "sphere2");
                var          parser = new ObjVNFParser(false, true);
                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);
                    // render rows*column number of spheres with varying metallic/roughness values scaled by rows and columns respectively
                    for (int row = 0; row < nrRows; ++row)
                    {
                        for (int col = 0; col < nrColumns; ++col)
                        {
                            var node = PBRNode.Create(model, model.GetSize(),
                                                      ObjVNF.strPosition, ObjVNF.strTexCoord, ObjVNF.strNormal, ObjVNF.strTangent);
                            node.Metallic = (float)row / (float)nrRows;
                            // we clamp the roughness to 0.025 - 1.0 as perfectly smooth surfaces (roughness of 0.0) tend to look a bit off
                            // on direct lighting.
                            node.Roughness     = glm.clamp((float)col / (float)nrColumns, 0.05f, 1.0f);
                            node.WorldPosition = new vec3(
                                (col - (nrColumns / 2)) * spacing,
                                (row - (nrRows / 2)) * spacing,
                                0.0f);
                            rootNode.Children.Add(node);
                        }
                    }
                }
            }

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

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

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

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #26
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4) * 2f;
            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);
            this.scene.ClearColor = Color.Black.ToVec4();
            {
                var light = new PointLight(new vec3(1, 1, 1) * 30);
                this.scene.Lights.Add(light);
            }
            {
                var group = new GroupNode();
                {
                    var node = ParticleNode.Create(6000);
                    group.Children.Add(node);
                }

                {
                    string       folder   = System.Windows.Forms.Application.StartupPath;
                    string       filename = System.IO.Path.Combine(folder + @"\..\..\..\..\Infrastructure\CSharpGL.Models", "floor.obj_");
                    var          parser   = new ObjVNFParser(true);
                    ObjVNFResult result   = parser.Parse(filename);
                    if (result.Error != null)
                    {
                        MessageBox.Show(result.Error.ToString());
                    }
                    else
                    {
                        ObjVNFMesh mesh  = result.Mesh;
                        var        model = new ObjVNF(mesh);
                        var        node  = NoShadowNode.Create(model, ObjVNF.strPosition, ObjVNF.strNormal, model.GetSize());
                        node.WorldPosition = new vec3(0, -3, 0);
                        node.Color         = new vec3(0, 1, 0);
                        node.Name          = filename;
                        group.Children.Add(node);
                    }
                }

                this.scene.RootNode = group;
            }

            {
                var list            = new ActionList();
                var transformAction = new TransformAction(scene.RootNode);
                list.Add(transformAction);
                var renderAction = new RenderAction(scene);
                list.Add(renderAction);
                var blinnPhongAction = new BlinnPhongAction(scene);
                list.Add(blinnPhongAction);
                this.actionList = list;
            }

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Пример #27
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4);
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera)
            ;

            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();

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);

            //string folder = System.Windows.Forms.Application.StartupPath;
            //string filename = System.IO.Path.Combine(folder + @"\..\..\..\..\Infrastructure\CSharpGL.Models", "vnfHanoiTower.obj_");
            //var parser = new ObjVNFParser(false);
            //ObjVNFResult result = parser.Parse(filename);
            //if (result.Error != null)
            //{
            //    MessageBox.Show(result.Error.ToString());
            //}
            //else
            //{
            //    var model = new ObjVNF(result.Mesh);
            //    var node = OITNode.Create(model, ObjVNF.strPosition, ObjVNF.strNormal, model.GetSize());
            //    float max = node.ModelSize.max();
            //    node.Scale *= 7.0f / max;
            //    node.WorldPosition = new vec3(0, 0, 0);
            //    var rootElement = this.scene.RootElement;
            //    this.scene.RootElement = node;
            //    if (rootElement != null) { rootElement.Dispose(); }
            //}
            // use teapot instead.
            var   model = new Teapot();
            var   node  = OITNode.Create(model, Teapot.strPosition, Teapot.strNormal, model.GetModelSize());
            float max   = node.ModelSize.max();

            node.Scale         *= 7.0F / max;
            node.WorldPosition  = new vec3(0, 0, 0);
            this.scene.RootNode = node;
        }
Пример #28
0
    private void OnMouseDown()
    {
        menu.SetActive(true);
        menuScript   = GameObject.Find("ActionMenu").GetComponent <RenderAction>();
        isMenuActive = menuScript.IsActive;

        if (!isMenuActive)
        {
            menuScript.SetUpList(name);
        }
    }
Пример #29
0
        public void Render(GenericChartSection section, IRenderingContext context)
        {
            if (section.Chart.IsEmpty)
            {
                return;
            }

            var renderAction = new RenderAction(context, section);

            renderAction.Render();
        }
Пример #30
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 3, 4);
            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)
            ;

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

            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();

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);

            string       folder   = System.Windows.Forms.Application.StartupPath;
            string       filename = System.IO.Path.Combine(folder, "nanosuit.obj_");
            var          parser   = new ObjVNFParser(false);
            ObjVNFResult result   = parser.Parse(filename);

            if (result.Error != null)
            {
                MessageBox.Show(result.Error.ToString());
            }
            else
            {
                var node = ObjVNFNode.Create(result.Mesh);
                node.Children.Add(new LegacyBoundingBoxNode(node.ModelSize));
                float max = node.ModelSize.max();
                node.Scale        *= 7.0f / max;
                node.WorldPosition = new vec3(0, 0, 0);
                var rootElement = this.scene.RootNode;
                this.scene.RootNode = node;
                if (rootElement != null)
                {
                    rootElement.Dispose();
                }
            }
        }