private void Form_Load(object sender, EventArgs e) { { var camera = new Camera( new vec3(0, 0, 5), new vec3(0, 0, 0), new vec3(0, 1, 0), CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height); var rotator = new SatelliteManipulater(); rotator.Bind(camera, this.glCanvas1); this.scene = new Scene(camera, this.glCanvas1); this.scene.ClearColor = Color.SkyBlue; this.glCanvas1.Resize += this.scene.Resize; } { const int gridsPer2Unit = 20; const int scale = 2; var ground = GroundRenderer.Create(new GroundModel(gridsPer2Unit * scale)); ground.Scale = new vec3(scale, scale, scale); var obj = new SceneObject(); obj.Renderer = ground; this.scene.RootObject.Children.Add(obj); } { SimpleRenderer movableRenderer = SimpleRenderer.Create(new Teapot()); movableRenderer.RotationAxis = new vec3(0, 1, 0); movableRenderer.Scale = new vec3(0.1f, 0.1f, 0.1f); this.movableRenderer = movableRenderer; SceneObject obj = movableRenderer.WrapToSceneObject(); this.scene.RootObject.Children.Add(obj); } { BillboardRenderer billboardRenderer = BillboardRenderer.Create(new BillboardModel()); SceneObject obj = billboardRenderer.WrapToSceneObject(new UpdateBillboardPosition(movableRenderer)); this.scene.RootObject.Children.Add(obj); } { LabelRenderer labelRenderer = LabelRenderer.Create(); labelRenderer.Text = "Teapot - CSharpGL"; SceneObject obj = labelRenderer.WrapToSceneObject(new UpdateLabelPosition(movableRenderer)); this.scene.RootObject.Children.Add(obj); } { var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom, new Padding(3, 3, 3, 3), new Size(128, 128)); this.scene.RootUI.Children.Add(uiAxis); } { var frmPropertyGrid = new FormProperyGrid(this.scene); frmPropertyGrid.Show(); } { var frmPropertyGrid = new FormProperyGrid(this.glCanvas1); frmPropertyGrid.Show(); } { this.scene.Start(); } }
private void Form_Load(object sender, EventArgs e) { { var camera = new Camera( new vec3(5, 3, 4), new vec3(0, 0, 0), new vec3(0, 1, 0), CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height); var scene = new Scene(camera, this.glCanvas1); scene.ClearColor = Color.SkyBlue; this.glCanvas1.Resize += scene.Resize; this.scene = scene; var cameraManipulater = new SatelliteManipulater(); cameraManipulater.Bind(camera, this.glCanvas1); this.cameraManipulater = cameraManipulater; } { const int gridsPer2Unit = 20; const int scale = 2; GroundRenderer renderer = GroundRenderer.Create(new GroundModel(gridsPer2Unit * scale)); renderer.Scale = new vec3(scale, scale, scale); SceneObject obj = renderer.WrapToSceneObject(generateBoundingBox: true); this.scene.RootObject.Children.Add(obj); } { var arcballManipulater = new ArcBallManipulater(); arcballManipulater.Bind(this.scene.Camera, this.glCanvas1); SimpleRenderer renderer = SimpleRenderer.Create(new Teapot()); SceneObject obj = renderer.WrapToSceneObject(); obj.Scripts.Add(new ArcballScript(arcballManipulater)); { BoundingBoxRenderer box = renderer.GetBoundingBoxRenderer(); var boxObj = box.WrapToSceneObject(); boxObj.Scripts.Add(new ArcballScript(arcballManipulater)); obj.Children.Add(boxObj); } this.scene.RootObject.Children.Add(obj); } { var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom, new Padding(3, 3, 3, 3), new Size(128, 128)); uiAxis.Initialize(); this.scene.UIRoot.Children.Add(uiAxis); } { var builder = new StringBuilder(); builder.AppendLine("1: Scene's property grid."); builder.AppendLine("2: Canvas' property grid."); builder.AppendLine("3: Form's property grid."); MessageBox.Show(builder.ToString()); } { this.scene.Start(); } }
private void glSceneCanvas1_Load(object sender, EventArgs e) { { this.glSceneCanvas1.Scene.Camera.Position = new vec3(5, 4, 3); } { const int size = 128; var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom, new Padding(10, 10, 10, 10), new Size(size, size)); this.glSceneCanvas1.Scene.UIRoot.Children.Add(uiAxis); } { var ground = GroundRenderer.Create(new GroundModel(20)); ground.Scale = new vec3(10, 10, 10); SceneObject obj = ground.WrapToSceneObject(name: "ground", generateBoundingBox: true); this.glSceneCanvas1.Scene.RootObject.Children.Add(obj); } { SimpleRenderer axis = SimpleRenderer.Create(new Axis()); SceneObject obj = axis.WrapToSceneObject(name: "Axis", generateBoundingBox: true); this.glSceneCanvas1.Scene.RootObject.Children.Add(obj); } }