Пример #1
0
 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();
     }
 }
Пример #2
0
        public static BillboardRenderer Create(IBufferable model)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\billboard.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\billboard.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("in_Positions", BillboardModel.strPosition);
            var billboardRenderer = new BillboardRenderer(model, shaderCodes, map);

            return(billboardRenderer);
        }
Пример #3
0
 private void Form02OrderIndependentTransparency_Load(object sender, EventArgs e)
 {
     {
         var camera = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
         camera.Position = new vec3(0, 0, 1);
         camera.Target   = new vec3(0, 0, 0);
         camera.UpVector = new vec3(0, 1, 0);
         var rotator = new SatelliteRotator(camera);
         this.camera  = camera;
         this.rotator = rotator;
     }
     {
         var renderer = new BillboardRenderer(10000);
         renderer.Initialize();
         this.renderer = renderer;
     }
     {
         var frmPropertyGrid = new FormProperyGrid();
         frmPropertyGrid.DisplayObject(this.renderer);
         frmPropertyGrid.Show();
         this.formPropertyGrid = frmPropertyGrid;
     }
 }
Пример #4
0
 public static BillboardRenderer Create(IBufferable model)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\billboard.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\billboard.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("in_Positions", BillboardModel.strPosition);
     var billboardRenderer = new BillboardRenderer(model, shaderCodes, map);
     return billboardRenderer;
 }
Пример #5
0
 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();
     }
 }