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.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height); this.scene = new Scene(camera, this.winGLCanvas1); { var node = NormalMappingNode.Create(); float max = node.ModelSize.max(); node.Scale *= 16.0f / max; this.rootNode = node; 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); }
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 sphere = new Sphere(1, 40, 80); var filename = Path.Combine(System.Windows.Forms.Application.StartupPath, "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); var node = NormalMappingNode.Create(model, model.GetSize(), ObjVNF.strPosition, ObjVNF.strTexCoord, ObjVNF.strNormal, ObjVNF.strTangent); float max = node.ModelSize.max(); node.Scale *= 16.0f / max; this.rootNode = node; 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; var manipulater = new FirstPerspectiveManipulater(); manipulater.Bind(camera, this.winGLCanvas1); }