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, this.winGLCanvas1) { 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); }
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); string folder = System.Windows.Forms.Application.StartupPath; var totalBmp = new Bitmap(System.IO.Path.Combine(folder, @"cubemaps_skybox.png")); Bitmap[] bitmaps = GetBitmaps(totalBmp); this.skybox = SkyboxNode.Create(bitmaps); this.skybox.Scale *= 60; string objFilename = System.IO.Path.Combine(folder, "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(); } }
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(), }; 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); foreach (var item in Enum.GetNames(typeof(LogicOperationCode))) { this.cmbLogicOperation.Items.Add(item); } }
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.winGLCanvas1); { var manipulater = new ArcBallManipulater(System.Windows.Forms.MouseButtons.Right); manipulater.Bind(camera, this.winGLCanvas1); var node = RaycastNode.Create(); node.BindManipulater(manipulater); 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; this.pickingAction = new PickingAction(scene); this.triangleTip = new LegacyTriangleNode(); this.quadTip = new LegacyQuadNode(); }
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); 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(); var manipulater = new FirstPerspectiveManipulater(); manipulater.Bind(camera, this.winGLCanvas1); //string filename = "nanosuit.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.RootElement = node; }
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); 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(); 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.RootElement; this.scene.RootElement = node; if (rootElement != null) { rootElement.Dispose(); } } }
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.teapot = TeapotNode.Create(); teapot.Children.Add(new LegacyBoundingBoxNode(teapot.ModelSize)); var ground = GroundNode.Create(); ground.Color = Color.Gray.ToVec4(); ground.Scale *= 10; ground.WorldPosition = new vec3(0, -3, 0); this.textNode = new DirectTextNode() { Text = "Color Coded Picking" }; var group = new GroupNode(this.teapot, ground, this.textNode); 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; this.pickingAction = new PickingAction(scene); this.triangleTip = new LegacyTriangleNode(); this.quadTip = new LegacyQuadNode(); this.chkRenderWireframe_CheckedChanged(this.chkRenderWireframe, EventArgs.Empty); this.chkRenderBody_CheckedChanged(this.chkRenderBody, EventArgs.Empty); // uncomment these lines to enable manipualter of camera! //var manipulater = new FirstPerspectiveManipulater(); //manipulater.BindingMouseButtons = System.Windows.Forms.MouseButtons.Right; //manipulater.Bind(camera, this.winGLCanvas1); }
private void FormMain_Load(object sender, EventArgs e) { var position = new vec3(8, 6, 4) * 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.teapot = TeapotNode.Create(); this.teapot.Scale *= 3; teapot.Children.Add(new LegacyBoundingBoxNode(teapot.ModelSize)); string folder = System.Windows.Forms.Application.StartupPath; var totalBmp = new Bitmap(System.IO.Path.Combine(folder, @"cubemaps_skybox.png")); this.skybox = SkyboxNode.Create(totalBmp); this.skybox.Scale *= 60; var group = new GroupNode(this.teapot, this.skybox); this.scene = new Scene(camera) { 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(); this.chkRenderWireframe_CheckedChanged(this.chkRenderWireframe, EventArgs.Empty); this.chkRenderBody_CheckedChanged(this.chkRenderBody, EventArgs.Empty); }