public static Create ( |
||
model | ||
리턴 |
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 UniformStructRenderer(IBufferable model, IShaderProgramProvider shaderProgramProvider, AttributeMap attributeMap, params GLState[] switches) : base(model, shaderProgramProvider, attributeMap, switches) { var groundRenderer = GroundRenderer.Create(new GroundModel(20)); groundRenderer.Scale = new vec3(10, 10, 10); this.groundRenderer = groundRenderer; }
private UniformArrayRenderer(IBufferable model, ShaderCode[] shaderCodes, AttributeMap attributeMap, params GLState[] switches) : base(model, shaderCodes, attributeMap, switches) { var groundRenderer = GroundRenderer.Create(new GroundModel(20)); groundRenderer.Scale = new vec3(10, 10, 10); this.groundRenderer = groundRenderer; }
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); this.camera = camera; var cameraManipulater = new SatelliteManipulater(); cameraManipulater.Bind(camera, this.glCanvas1); this.cameraManipulater = cameraManipulater; var arcballManipulater = new ArcBallManipulater(); arcballManipulater.Bind(camera, this.glCanvas1); this.arcballManipulater = arcballManipulater; } { const int gridsPer2Unit = 20; const int scale = 2; GroundRenderer ground = GroundRenderer.Create(new GroundModel(gridsPer2Unit * scale)); ground.Initialize(); ground.Scale = scale; this.ground = ground; } { var shaderCodes = new ShaderCode[2]; shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\Teapot.vert"), ShaderType.VertexShader); shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\Teapot.frag"), ShaderType.FragmentShader); var map = new PropertyNameMap(); map.Add("in_Position", "position"); map.Add("in_Color", "color"); var teapotRenderer = new Renderer(new Teapot(), shaderCodes, map); teapotRenderer.Initialize(); this.teapotRenderer = teapotRenderer; } { var UIRoot = new UIRoot(); UIRoot.Initialize(); this.uiRoot = UIRoot; var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom, new Padding(3, 3, 3, 3), new Size(128, 128), -100, 100); uiAxis.Initialize(); this.uiAxis = uiAxis; UIRoot.Children.Add(uiAxis); } { var frmPropertyGrid = new FormProperyGrid(this.teapotRenderer); frmPropertyGrid.Show(); } { var frmPropertyGrid = new FormProperyGrid(this.glCanvas1); frmPropertyGrid.Show(); } }
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 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); this.camera = camera; var cameraManipulater = new SatelliteManipulater(); cameraManipulater.Bind(camera, this.glCanvas1); this.cameraManipulater = cameraManipulater; var arcballManipulater = new ArcBallManipulater(); arcballManipulater.Bind(camera, this.glCanvas1); this.arcballManipulater = arcballManipulater; } { const int gridsPer2Unit = 20; const int scale = 2; GroundRenderer ground = GroundRenderer.Create(new GroundModel(gridsPer2Unit * scale)); ground.Initialize(); ground.Scale = scale; this.ground = ground; } { var renderer = UpdatingTextureRenderer.Create(new TexturedRectangleModel()); renderer.Initialize(); this.renderer = renderer; } { var UIRoot = new UIRoot(); UIRoot.Initialize(); this.uiRoot = UIRoot; var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom, new Padding(3, 3, 3, 3), new Size(128, 128), -100, 100); uiAxis.Initialize(); this.uiAxis = uiAxis; UIRoot.Children.Add(uiAxis); } { var frmPropertyGrid = new FormProperyGrid(this.renderer); frmPropertyGrid.Show(); } { var frmPropertyGrid = new FormProperyGrid(this.glCanvas1); frmPropertyGrid.Show(); } }
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); } }
private void Form_Load(object sender, EventArgs e) { foreach (var item in Enum.GetValues(typeof(GeometryType))) { this.cmbPickingGeometryType.Items.Add(item); } foreach (var item in Enum.GetValues(typeof(RenderModes))) { this.cmbRenderMode.Items.Add(item); } { var frmBulletinBoard = new FormBulletinBoard(); //frmBulletinBoard.Dump = true; frmBulletinBoard.Show(); this.bulletinBoard = frmBulletinBoard; } { //this.glCanvas1.ShowSystemCursor = false; } { var camera = new Camera( new vec3(15, 5, 0), new vec3(0, 0, 0), new vec3(0, 1, 0), CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height); var rotator = new FirstPerspectiveManipulater(); rotator.StepLength = 0.5f; rotator.Bind(camera, this.glCanvas1); var scene = new Scene(camera, this.glCanvas1); //scene.Cursor.Enabled = false; this.scene = scene; this.glCanvas1.Resize += scene.Resize; } { 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 font = new Font("Courier New", 32); var uiText = new UIText(AnchorStyles.Left | AnchorStyles.Bottom, new Padding(0, 0, 0, 0), new Size(250, 20), -100, 100, font.GetFontBitmap("[index: 0123456789]").GetFontTexture()); uiText.Text = ""; this.uiText = uiText; this.scene.UIRoot.Children.Add(uiText); } { GroundRenderer ground = GroundRenderer.Create(new GroundModel(20)); ground.Initialize(); ground.Scale = new vec3(20, 20, 20); ground.WorldPosition = new vec3(0, 0, 0); SceneObject obj = ground.WrapToSceneObject(name: "Ground", generateBoundingBox: true); this.scene.RootObject.Children.Add(obj); } { bool useHighlightedPickingEffect = false; if (MessageBox.Show("Use highlighted picking effect?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { useHighlightedPickingEffect = true; } List <PickableRenderer> list = GetPickableRenderers(); const float distance = 10; float sideCount = (float)Math.Sqrt(list.Count); int sideCounti = (int)sideCount; float x = -sideCount * distance / 2; float z = -sideCount * distance / 2; //float x = 0, z = 0; for (int i = 0; i < list.Count; i++) { PickableRenderer item = list[i]; SceneObject obj; if (useHighlightedPickingEffect) { var model = item.Model; var highlightRenderer = new HighlightRenderer(model, item.PositionNameInIBufferable); var renderer = new HighlightedPickableRenderer( highlightRenderer, item); renderer.WorldPosition = new vec3(x, 2, z); renderer.Initialize(); obj = renderer.WrapToSceneObject(generateBoundingBox: true); } else { item.WorldPosition = new vec3(x, 2, z); obj = item.WrapToSceneObject(generateBoundingBox: true); } this.scene.RootObject.Children.Add(obj); x += distance; if (i % sideCounti == sideCounti - 1) { z += distance; x = -sideCount * distance / 2; } } } { this.glCanvas1.MouseDown += glCanvas1_MouseDown; this.glCanvas1.MouseMove += glCanvas1_MouseMove; this.glCanvas1.MouseUp += glCanvas1_MouseUp; } { var builder = new StringBuilder(); builder.AppendLine("1: Scene's property grid."); builder.AppendLine("2: Canvas' property grid."); builder.AppendLine("3: Form's property grid."); builder.AppendLine("4: Save to bitmap file."); MessageBox.Show(builder.ToString()); } }
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.glCanvas1.Resize += this.scene.Resize; } { const int gridsPer2Unit = 20; const int scale = 2; var ground = GroundRenderer.Create(new GroundModel(gridsPer2Unit * scale)); ground.Scale = scale; //ground.Initialize(); //this.ground = ground; var obj = new SceneObject(); obj.Renderer = ground; this.scene.RootObject.Children.Add(obj); } //MovableRenderer movableRenderer; { movableRenderer = MovableRenderer.Create(new Teapot()); //movableRenderer.Initialize(); movableRenderer.Scale = 0.1f; var obj = new SceneObject(); obj.Renderer = movableRenderer; this.scene.RootObject.Children.Add(obj); } { BillboardRenderer billboardRenderer = BillboardRenderer.GetRenderer(new BillboardModel()); //billboardRenderer.Initialize(); var obj = new SceneObject(); obj.Renderer = billboardRenderer; var updatePosition = new UpdateBillboardPosition(movableRenderer); obj.ScriptList.Add(updatePosition); this.scene.RootObject.Children.Add(obj); } { var labelRenderer = new LabelRenderer(); labelRenderer.Initialize(); 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), -100, 100); //uiAxis.Initialize(); this.scene.UIRoot.Children.Add(uiAxis); } { var frmPropertyGrid = new FormProperyGrid(this.scene); frmPropertyGrid.Show(); } { var frmPropertyGrid = new FormProperyGrid(this.glCanvas1); frmPropertyGrid.Show(); } { this.scene.Start(); } }