Beispiel #1
0
        public void DemoInit()
        {
            InitializeRenderers();
            windowViewport           = new RenderStack.Viewport(this.Width, this.Height);
            Renderer.CurrentViewport = windowViewport;

            blinnPhong = Material.Create(Renderer.Programs.BlinnPhong);
            blinnPhong.Parameters.Add <Floats>("surface_color").Value     = new Floats(0.5f, 0.5f, 0.5f);
            blinnPhong.Parameters.Add <Floats>("surface_rim_color").Value = new Floats(0.1f, 0.2f, 0.5f);
            blinnPhong.Parameters.Add <Floats>("surface_diffuse_reflectance_color").Value     = new Floats(0.24f, 0.24f, 0.24f);
            blinnPhong.Parameters.Add <Floats>("surface_specular_reflectance_color").Value    = new Floats(0.8f, 0.8f, 0.8f);
            blinnPhong.Parameters.Add <Floats>("surface_specular_reflectance_exponent").Value = new Floats(200.0f);

            gridMaterial = Material.Create(Renderer.Programs.Grid);

#if false
            var mesh = PolyMesh.CreateGreatRhombicosidodecahedron(1.0);
#else
            var mesh   = PolyMesh.CreateTruncatedIcosahedron(1.0);
            var dodeca = PolyMesh.CreateDodecahedron(1.0);
            Attach(mesh, dodeca, 5);
#endif

            var subd1 = new SubdivideGeometryOperation(mesh.Geometry).Destination;
            var subd2 = new SubdivideGeometryOperation(subd1).Destination;
            var cc1   = new CatmullClarkGeometryOperation(subd2).Destination;
            var cc2   = new CatmullClarkGeometryOperation(cc1).Destination;
            cc2.ComputePolygonCentroids();
            cc2.ComputePolygonNormals();
            cc2.ComputeCornerNormals(2.0f * (float)Math.PI);
            //cc2.BuildEdges();

            mesh  = new GeometryMesh(cc2);
            model = Model.Create("model", mesh, blinnPhong);
            //model                   = Model.Create("model", mesh, gridMaterial);

            camera                   = Camera.Create();
            camera.FovXRadians       = OpenTK.MathHelper.DegreesToRadians(90.0f);
            camera.FovYRadians       = OpenTK.MathHelper.DegreesToRadians(90.0f);
            camera.ProjectionType    = ProjectionType.PerspectiveVertical;
            camera.Frame.Parent      = model.Frame;
            cameraPath               = new OrbitPath(camera.Frame);
            cameraPath.Points[0.0f]  = new OrbitPoint(0.0f, 0.0f, 20.0f);
            cameraPath.Points[2.0f]  = new OrbitPoint(0.0f, 0.0f, 12.0f);
            cameraPath.Points[3.0f]  = new OrbitPoint(0.5f, 0.2f, 15.0f);
            cameraPath.Points[4.0f]  = new OrbitPoint(1.0f, 0.5f, 12.0f);
            cameraPath.Points[5.0f]  = new OrbitPoint(1.4f, 1.0f, 16.0f);
            cameraPath.Points[7.0f]  = new OrbitPoint(2.0f, 1.5f, 13.0f);
            cameraPath.Points[10.0f] = new OrbitPoint(1.6f, 0.0f, 20.0f);

            exposure = new Signal();
            exposure.Values[0.0f]  = 0.0f;
            exposure.Values[1.0f]  = 1.0f;
            exposure.Values[2.0f]  = 2.0f;
            exposure.Values[3.0f]  = 1.0f;
            exposure.Values[4.0f]  = 5.0f;
            exposure.Values[8.0f]  = 1.0f;
            exposure.Values[10.0f] = 0.0f;

            InitializeRendererParameters();
            DemoStart();
        }