private void FormMain_Load(object sender, EventArgs e) { var position = new vec3(1, 0.6f, 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) ; string folder = System.Windows.Forms.Application.StartupPath; string objFilename = System.IO.Path.Combine(folder + @"\..\..\..\..\Infrastructure\CSharpGL.Models", "vnfHanoiTower.obj_"); var parser = new ObjVNFParser(false); ObjVNFResult result = parser.Parse(objFilename); if (result.Error != null) { MessageBox.Show(result.Error.ToString()); } else { double radian = 120.0 / 180.0 * Math.PI / 2.0; var light = new CSharpGL.SpotLight(new vec3(1, 1, 1), new vec3(), (float)Math.Cos(radian)); var model = new ObjVNF(result.Mesh); this.node = SpotLightNode.Create(light, model, ObjVNF.strPosition, ObjVNF.strNormal, model.GetSize()); float max = node.ModelSize.max(); this.node.Scale *= 16.0f / max; this.lightNode = LightPostionNode.Create(); lightNode.SetLight(light); lightNode.WorldPosition = new vec3(1, 1, 1) * 4; var groupNode = new GroupNode(node, lightNode); this.scene.RootNode = groupNode; (new FormProperyGrid(groupNode)).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); }
private void FormMain_Load(object sender, EventArgs e) { var position = new vec3(1, 0.6f, 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); 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 light = new CSharpGL.SpotLight(new vec3(1, 1, 1), new vec3(), 60); var model = new ObjVNF(result.Mesh); this.node = SpotLightNode.Create(light, model, ObjVNF.strPosition, ObjVNF.strNormal, model.GetSize()); float max = node.ModelSize.max(); this.node.Scale *= 16.0f / max; this.lightNode = LightPostionNode.Create(); lightNode.SetLight(light); lightNode.WorldPosition = new vec3(1, 1, 1) * 4; var groupNode = new GroupNode(node, lightNode); this.scene.RootElement = groupNode; (new FormProperyGrid(groupNode)).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); }