Example #1
0
 private void Form_Load(object sender, EventArgs e)
 {
     {
         var camera = new Camera(
             new vec3(5, 4, 3) * 0.5f, 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.camera            = camera;
         this.rotator           = rotator;
         this.scene             = new Scene(camera, this.glCanvas1);
         this.glCanvas1.Resize += this.scene.Resize;
     }
     {
         const int           particleCount = 10000;
         PointSpriteRenderer renderer      = PointSpriteRenderer.Create(particleCount);
         this.renderer = renderer;
         SceneObject obj = renderer.WrapToSceneObject(generateBoundingBox: true);
         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 builder = new StringBuilder();
         builder.AppendLine("O: to select image.");
         builder.AppendLine("1: Scene's property grid.");
         builder.AppendLine("2: Canvas' property grid.");
         MessageBox.Show(builder.ToString());
     }
 }
Example #2
0
 private void Form_Load(object sender, EventArgs e)
 {
     {
         var camera = new Camera(
             new vec3(0, 0, 1), 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.camera            = camera;
         this.rotator           = rotator;
         this.scene             = new Scene(camera, this.glCanvas1);
         this.glCanvas1.Resize += this.scene.Resize;
     }
     {
         var renderer = new PointSpriteRenderer(10000);
         renderer.Initialize();
         this.renderer = renderer;
         SceneObject obj = renderer.WrapToSceneObject();
         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();
     }
 }
        public static PointSpriteRenderer Create(int particleCount)
        {
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\PointSprite.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\PointSprite.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("position", PointSpriteModel.strposition);
            var model = new PointSpriteModel(particleCount);
            var renderer = new PointSpriteRenderer(model, shaderCodes, map, new PointSpriteState());
            renderer.ModelSize = model.Lengths;

            return renderer;
        }
Example #4
0
        public static PointSpriteRenderer Create(int particleCount)
        {
            var shaderCodes = new ShaderCode[2];

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

            map.Add("position", PointSpriteModel.strposition);
            var model    = new PointSpriteModel(particleCount);
            var renderer = new PointSpriteRenderer(model, shaderCodes, map, new PointSpriteState());

            renderer.ModelSize = model.Lengths;

            return(renderer);
        }
Example #5
0
        private void Form02OrderIndependentTransparency_Load(object sender, EventArgs e)
        {
            {
                var camera = new Camera(
                    new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0),
                    CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);

                var rotator = new SatelliteRotator(camera);
                this.camera  = camera;
                this.rotator = rotator;
            }
            {
                var renderer = new PointSpriteRenderer(10000);
                renderer.Initialize();
                this.renderer = renderer;
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.renderer);
                frmPropertyGrid.Show();
                this.formPropertyGrid = frmPropertyGrid;
            }
        }
Example #6
0
        private void Form_Load(object sender, EventArgs e)
        {
            {
                var camera = new Camera(
                    new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0),
                    CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);

                var rotator = new SatelliteRotator(camera);
                this.camera = camera;
                this.rotator = rotator;
            }
            {
                var renderer = new PointSpriteRenderer(10000);
                renderer.Initialize();
                this.renderer = renderer;
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.renderer);
                frmPropertyGrid.Show();
                this.formPropertyGrid = frmPropertyGrid;
            }
        }
Example #7
0
        public static RendererBase Create(Type rendererType)
        {
            RendererBase renderer = null;

            if (rendererType == typeof(AnalyzedPointSpriteRenderer))
            {
                int particleCount = 10000;
                renderer = AnalyzedPointSpriteRenderer.Create(particleCount);
            }
            else if (rendererType == typeof(BufferBlockRenderer))
            {
                renderer = BufferBlockRenderer.Create();
            }
            else if (rendererType == typeof(ConditionalRenderer))
            {
                renderer = ConditionalRenderer.Create();
            }
            else if (rendererType == typeof(EmitNormalLineRenderer))
            {
                var model = new Teapot();
                renderer = EmitNormalLineRenderer.Create(model, Teapot.strPosition, Teapot.strNormal, model.Lengths);
            }
            else if (rendererType == typeof(ImageProcessingRenderer))
            {
                renderer = new ImageProcessingRenderer();
            }
            else if (rendererType == typeof(KleinBottleRenderer))
            {
                renderer = KleinBottleRenderer.Create(new KleinBottleModel());
            }
            else if (rendererType == typeof(OrderDependentTransparencyRenderer))
            {
                var model = new Teapot();
                renderer = OrderDependentTransparencyRenderer.Create(model, model.Lengths, Teapot.strPosition, Teapot.strColor);
            }
            else if (rendererType == typeof(OrderIndependentTransparencyRenderer))
            {
                var model = new Teapot();
                renderer = new OrderIndependentTransparencyRenderer(model, model.Lengths, Teapot.strPosition, Teapot.strColor);
            }
            else if (rendererType == typeof(ParticleSimulatorRenderer))
            {
                renderer = new ParticleSimulatorRenderer();
            }
            else if (rendererType == typeof(PointCloudRenderer))
            {
                var list = new List <vec3>();

                using (var reader = new StreamReader(@"Resources\data\19PointCloud.txt"))
                {
                    while (!reader.EndOfStream)
                    {
                        string   line  = reader.ReadLine();
                        string[] parts = line.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        float    x     = float.Parse(parts[0]);
                        float    y     = float.Parse(parts[1]);
                        float    z     = float.Parse(parts[2]);
                        list.Add(new vec3(x, y, z));
                    }
                }
                renderer = PointCloudRenderer.Create(new PointCloudModel(list));
            }
            else if (rendererType == typeof(PointSpriteRenderer))
            {
                const int particleCount = 10000;
                renderer = PointSpriteRenderer.Create(particleCount);
            }
            else if (rendererType == typeof(RaycastVolumeRenderer))
            {
                renderer = new RaycastVolumeRenderer();
            }
            else if (rendererType == typeof(RayTracingRenderer))
            {
                renderer = RayTracingRenderer.Create();
            }
            else if (rendererType == typeof(ShaderToyRenderer))
            {
                renderer = ShaderToyRenderer.Create();
            }
            else if (rendererType == typeof(SimpleComputeRenderer))
            {
                renderer = SimpleComputeRenderer.Create();
            }
            else if (rendererType == typeof(SimplexNoiseRenderer))
            {
                renderer = SimplexNoiseRenderer.Create();
            }
            else if (rendererType == typeof(UniformArrayRenderer))
            {
                renderer = UniformArrayRenderer.Create();
            }
            else if (rendererType == typeof(UniformBlockRenderer))
            {
                renderer = UniformBlockRenderer.Create();
            }
            else if (rendererType == typeof(UniformStructRenderer))
            {
                renderer = UniformStructRenderer.Create();
            }
            else if (rendererType == typeof(WaterRenderer))
            {
                renderer = WaterRenderer.Create(waterPlaneLength: 4);
            }
            else if (rendererType == typeof(ZeroAttributeRenderer))
            {
                renderer = ZeroAttributeRenderer.Create();
            }

            return(renderer);
        }