private void Form_Load(object sender, EventArgs e)
        {
            {
                var camera = new Camera(
                    new vec3(0, 0, 5), new vec3(), 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;
            }
            {
                var simplexNoiseRenderer = new SimplexNoiseRenderer();
                simplexNoiseRenderer.Name = string.Format("Pickable: [{0}]", "Sphere");
                simplexNoiseRenderer.Initialize();
                this.simplexNoiseRenderer = simplexNoiseRenderer;
            }
            {
                var UIRoot = new UIRoot();
                UIRoot.Initialize();
                this.uiRoot = UIRoot;

                var glAxis = new UIAxis(AnchorStyles.Right | AnchorStyles.Bottom,
                    new Padding(3, 3, 3, 3), new Size(70, 70), -100, 100);
                glAxis.Initialize();
                this.glAxis = glAxis;

                UIRoot.Children.Add(glAxis);
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.simplexNoiseRenderer);
                frmPropertyGrid.Show();
            }
        }
Example #2
0
        private void Form01Renderer_Load(object sender, EventArgs e)
        {
            {
                var camera = new Camera(
                    new vec3(0, 0, 5), new vec3(), 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 simplexNoiseRenderer = new SimplexNoiseRenderer();
                simplexNoiseRenderer.Name = string.Format("Pickable: [{0}]", "Sphere");
                simplexNoiseRenderer.Initialize();
                this.simplexNoiseRenderer = simplexNoiseRenderer;
            }
            {
                var UIRoot = new GLControl(this.glCanvas1.Size, -100, 100);
                UIRoot.Initialize();
                this.uiRoot = UIRoot;

                var glAxis = new GLAxis(AnchorStyles.Right | AnchorStyles.Bottom,
                                        new Padding(3, 3, 3, 3), new Size(70, 70), -100, 100);
                glAxis.Initialize();
                this.glAxis = glAxis;

                UIRoot.Controls.Add(glAxis);
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.simplexNoiseRenderer);
                frmPropertyGrid.Show();
            }
        }
 private void Form_Load(object sender, EventArgs e)
 {
     {
         var camera = new Camera(
             new vec3(0, 0, 5), new vec3(), 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;
     }
     {
         var renderer = new SimplexNoiseRenderer();
         renderer.Initialize();
         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();
     }
 }
Example #4
0
        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 cameraManipulater = new SatelliteManipulater();
                cameraManipulater.Bind(camera, this.glCanvas1);
                this.cameraManipulater = cameraManipulater;
                this.scene             = new Scene(camera, this.glCanvas1);
                this.scene.ClearColor  = Color.SkyBlue;
                this.glCanvas1.Resize += this.scene.Resize;
            }
            {
                PointLightRenderer renderer = PointLightRenderer.Create();
                SceneObject        obj      = renderer.WrapToSceneObject(true, new ModelScript(this.glCanvas1, this.scene.FirstCamera));
                this.scene.RootObject.Children.Add(obj);
                this.renderer = renderer;

                var frmPropertyGrid = new FormProperyGrid(renderer);
                frmPropertyGrid.Show();
            }
            {
                SimplexNoiseRenderer renderer = SimplexNoiseRenderer.Create();
                renderer.Scale         = new vec3(0.2f);
                renderer.WorldPosition = new vec3(3, 3, 3);
                SceneObject obj = renderer.WrapToSceneObject(true, new LightScript(this.glCanvas1, this.scene.FirstCamera, renderer));
                this.scene.RootObject.Children.Add(obj);
                this.sunRenderer = renderer;
            }
            {
                SceneObject obj = this.renderer.BindingSceneObject;
                obj.Scripts.Add(new UpdatePointLightPosition(this.sunRenderer));
            }
            {
                var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom,
                                        new Padding(3, 3, 3, 3), new Size(128, 128));
                this.scene.RootUI.Children.Add(uiAxis);
            }
            {
                this.glCanvas1.MouseDown += glCanvas1_MouseDown;
                this.glCanvas1.MouseMove += glCanvas1_MouseMove;
                this.glCanvas1.MouseUp   += glCanvas1_MouseUp;
            }
            {
                var builder = new StringBuilder();
                builder.AppendLine("1: Scenes' property grid.");
                builder.AppendLine("2: Canvas' property grid.");
                MessageBox.Show(builder.ToString());
            }
            {
                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 cameraManipulater = new SatelliteManipulater();
                cameraManipulater.Bind(camera, this.glCanvas1);
                this.cameraManipulater = cameraManipulater;
                this.scene = new Scene(camera, this.glCanvas1);
                this.scene.RootViewPort.ClearColor = Color.SkyBlue;
                this.glCanvas1.Resize += this.scene.Resize;
            }
            {
                PointLightRenderer renderer = PointLightRenderer.Create();
                SceneObject obj = renderer.WrapToSceneObject(true, new ModelScript(this.glCanvas1, this.scene.FirstCamera));
                this.scene.RootObject.Children.Add(obj);
                this.renderer = renderer;

                var frmPropertyGrid = new FormProperyGrid(renderer);
                frmPropertyGrid.Show();
            }
            {
                SimplexNoiseRenderer renderer = SimplexNoiseRenderer.Create();
                renderer.Scale = new vec3(0.2f);
                renderer.WorldPosition = new vec3(3, 3, 3);
                SceneObject obj = renderer.WrapToSceneObject(true, new LightScript(this.glCanvas1, this.scene.FirstCamera, renderer));
                this.scene.RootObject.Children.Add(obj);
                this.sunRenderer = renderer;
            }
            {
                SceneObject obj = this.renderer.BindingSceneObject;
                obj.Scripts.Add(new UpdatePointLightPosition(this.sunRenderer));
            }
            {
                var uiAxis = new UIAxis(AnchorStyles.Left | AnchorStyles.Bottom,
                    new Padding(3, 3, 3, 3), new Size(128, 128));
                this.scene.RootUI.Children.Add(uiAxis);
            }
            {
                this.glCanvas1.MouseDown += glCanvas1_MouseDown;
                this.glCanvas1.MouseMove += glCanvas1_MouseMove;
                this.glCanvas1.MouseUp += glCanvas1_MouseUp;
            }
            {
                var builder = new StringBuilder();
                builder.AppendLine("1: Scenes' property grid.");
                builder.AppendLine("2: Canvas' property grid.");
                MessageBox.Show(builder.ToString());
            }
            {
                this.scene.Start();
            }
        }
        public static SimplexNoiseRenderer Create()
        {
            var model = new Sphere(1, 180, 360);
            var shaderCodes = new ShaderCode[2];
            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\SimplexNoise.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\SimplexNoise.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();
            map.Add("in_Position", Sphere.strPosition);
            var renderer = new SimplexNoiseRenderer(model, shaderCodes, map, Sphere.strPosition);
            renderer.ModelSize = model.Lengths;

            return renderer;
        }
Example #7
0
        public static SimplexNoiseRenderer Create()
        {
            var model       = new Sphere(1, 180, 360);
            var shaderCodes = new ShaderCode[2];

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

            map.Add("in_Position", Sphere.strPosition);
            var renderer = new SimplexNoiseRenderer(model, shaderCodes, map, Sphere.strPosition);

            renderer.ModelSize = model.Lengths;

            return(renderer);
        }
 public UpdatePointLightPosition(SimplexNoiseRenderer simplexNoiseRenderer)
 {
     // TODO: Complete member initialization
     this.simplexNoiseRenderer = simplexNoiseRenderer;
 }
Example #9
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);
        }
        private List <PickableRenderer> GetPickableRenderers()
        {
            List <PickableRenderer> list = new List <PickableRenderer>();

            {
                SimpleRenderer pickableRenderer = SimpleRenderer.Create(new Tetrahedron());
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                SimpleRenderer pickableRenderer = SimpleRenderer.Create(new Teapot());
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                SimpleRenderer pickableRenderer = SimpleRenderer.Create(new Sphere());
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                SimpleRenderer pickableRenderer = SimpleRenderer.Create(new Chain());
                pickableRenderer.SwitchList.Add(new LineWidthSwitch(5));
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                SimpleRenderer pickableRenderer = SimpleRenderer.Create(new BigDipper());
                pickableRenderer.SwitchList.Add(new LineWidthSwitch(5));
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                SimpleRenderer pickableRenderer = SimpleRenderer.Create(new Axis(partCount: 6, radius: 1.0f));
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                SimpleRenderer pickableRenderer = SimpleRenderer.Create(new Cube(new vec3(5, 4, 3)));
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                var points = new List <vec3>()
                {
                    new vec3(-4.0f, 0.0f, 0.0f),
                    new vec3(-6.0f, 4.0f, 0.0f),
                    new vec3(6.0f, -4.0f, 0.0f),
                    new vec3(4.0f, 0.0f, 0.0f),
                };
                BezierRenderer pickableRenderer = BezierRenderer.Create(points, BezierType.Curve);
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                // note: the points are not centered at (0, 0, 0). Thus the renderer will not be placed at (0, 0, 0).
                var points = new List <vec3>()
                {
                    new vec3(-4.0f, 0.0f, 4.0f),
                    new vec3(-2.0f, 4.0f, 4.0f),
                    new vec3(4.0f, 0.0f, 4.0f),
                    new vec3(-4.0f, 0.0f, 0.0f),
                    new vec3(-2.0f, 4.0f, 0.0f),
                    new vec3(4.0f, 0.0f, 0.0f),
                    new vec3(-4.0f, 0.0f, -4.0f),
                    new vec3(-2.0f, 4.0f, -4.0f),
                    new vec3(4.0f, 0.0f, -4.0f)
                };
                BezierRenderer pickableRenderer = BezierRenderer.Create(points, BezierType.Surface);
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                SimplexNoiseRenderer pickableRenderer = SimplexNoiseRenderer.Create();
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            {
                KleinBottleRenderer pickableRenderer = KleinBottleRenderer.Create(new KleinBottleModel());
                pickableRenderer.Scale = new vec3(0.1f, 0.1f, 0.1f);
                pickableRenderer.Initialize();
                list.Add(pickableRenderer);
            }
            return(list);
        }
Example #11
0
 public UpdatePointLightPosition(SimplexNoiseRenderer simplexNoiseRenderer)
 {
     // TODO: Complete member initialization
     this.simplexNoiseRenderer = simplexNoiseRenderer;
 }
 public UpdateDirectionalLightDirection(SimplexNoiseRenderer simplexNoiseRenderer)
 {
     // TODO: Complete member initialization
     this.simplexNoiseRenderer = simplexNoiseRenderer;
 }
 public UpdateDirectionalLightDirection(SimplexNoiseRenderer simplexNoiseRenderer)
 {
     // TODO: Complete member initialization
     this.simplexNoiseRenderer = simplexNoiseRenderer;
 }