Ejemplo n.º 1
0
        public MainViewModel()
        {
            // ----------------------------------------------
            // titles
            this.Title = "Screen Space Ambient Occlusion Demo";
            this.SubTitle = "WPF & SharpDX";

            // camera setup
            this.Camera = new PerspectiveCamera { Position = new Point3D(1.5, 2.5, 2.5), LookDirection = new Vector3D(-1.5, -2.5, -2.5), UpDirection = new Vector3D(0, 1, 0) };

            // default render technique
            RenderTechniquesManager = new DeferredTechniquesManager();
            RenderTechnique = RenderTechniquesManager.RenderTechniques.Get(DeferredRenderTechniqueNames.Deferred);
            EffectsManager = new DeferredEffectsManager(RenderTechniquesManager);

            // background
            this.BackgroundColor = (Color4)Color.White;

            // setup lighting
            this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection1 = new Vector3(-2, -5, -2);
            this.DirectionalLightDirection2 = new Vector3(+2, +5, +5);

            // model materials
            this.DefaultMaterial = PhongMaterials.DefaultVRML;

            //load model
            var reader = new ObjReader();
            var objModel = reader.Read(@"./Media/CornellBox-Glossy.obj");

            this.ModelGeometry = new Element3DCollection();
            this.ModelGeometry.AddRange(objModel.Select(x => new MeshGeometryModel3D() { Geometry = x.Geometry as MeshGeometry3D, Material = x.Material, }));

            // model trafos
            this.ModelTransform = new Media3D.TranslateTransform3D(0, 0, 0);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// load the model from obj-file
 /// </summary>
 /// <param name="filename">filename</param>
 /// <param name="faces">Determines if facades should be treated as triangles (Default) or as quads (Quads)</param>
 private void LoadModel(string filename, MeshFaces faces)
 {
     // load model
     var reader = new ObjReader();
     var objModel = reader.Read(filename, new ModelInfo() { Faces = faces });
     this.DefaultModel = objModel[0].Geometry as MeshGeometry3D;
     this.DefaultModel.Colors = new Color4Collection(this.DefaultModel.Positions.Select(x => new Color4(1, 0, 0, 1)));
 }