public MainViewModel() { // titles this.Title = "Deferred Shading Demo"; // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) }; // clear color this.BackgroundColor = (Color4)Color.White; // default render technique this.RenderTechnique = Techniques.RenderDeferred; // setup lighting this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f); this.DirectionalLightColor2 = Color.Red; this.DirectionalLightColor1 = Color.Green; this.DirectionalLightColor3 = Color.Blue; this.DirectionalLightDirection1 = new Vector3(-0, -50, -0); this.DirectionalLightDirection2 = new Vector3(-0, -50, -50); this.DirectionalLightDirection3 = new Vector3(-50, -50, -0); // floor plane grid this.Grid = LineBuilder.GenerateGrid(); this.GridColor = SharpDX.Color.Black; this.GridTransform = new Media3D.TranslateTransform3D(-5, -1, -5); // scene model3d var b1 = new MeshBuilder(true,true,true); b1.AddSphere(new Vector3(0, 0, 0), 0.5); b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All); var meshGeometry = b1.ToMeshGeometry3D(); meshGeometry.Colors = meshGeometry.TextureCoordinates.Select(x => x.ToColor4()).ToArray(); this.Model = meshGeometry; // lines model3d var e1 = new LineBuilder(); e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2); this.Lines = e1.ToLineGeometry3D(); // model trafos this.Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0); this.Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0); this.Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0); // model materials this.RedMaterial = PhongMaterials.White; this.RedMaterial.DiffuseMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)); this.RedMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute)); this.GreenMaterial = PhongMaterials.DefaultVRML; //this.GreenMaterial.TextureMap = this.RedMaterial.TextureMap; this.BlueMaterial = PhongMaterials.Silver; //this.BlueMaterial.TextureMap = this.RedMaterial.TextureMap; }
public MainViewModel() { // titles this.Title = "Simple Demo"; this.SubTitle = "WPF & SharpDX"; // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) }; // default render technique this.RenderTechnique = Techniques.RenderBlinn; // setup lighting this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f); this.DirectionalLightColor = Color.White; this.DirectionalLightDirection = new Vector3(-2, -5, -2); // floor plane grid this.Grid = LineBuilder.GenerateGrid(); this.GridColor = SharpDX.Color.Black; this.GridTransform = new Media3D.TranslateTransform3D(-5, -1, -5); // scene model3d var b1 = new MeshBuilder(); b1.AddSphere(new Vector3(0, 0, 0), 0.5); b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All); var meshGeometry = b1.ToMeshGeometry3D(); meshGeometry.Colors = meshGeometry.TextureCoordinates.Select(x => x.ToColor4()).ToArray(); this.Model = meshGeometry; // lines model3d var e1 = new LineBuilder(); e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2); this.Lines = e1.ToLineGeometry3D(); // model trafos this.Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0); this.Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0); this.Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0); // model materials this.RedMaterial = PhongMaterials.Red; this.GreenMaterial = PhongMaterials.Green; this.BlueMaterial = PhongMaterials.Blue; }
public MainViewModel() { this.Title = "Manipulator Demo"; this.SubTitle = null; // camera setup this.Camera = new OrthographicCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), UpDirection = new Vector3D(0, 1, 0) }; // setup lighting this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f); this.DirectionalLightColor = Color.White; this.DirectionalLightDirection = new Vector3(-2, -5, -2); // floor plane grid this.Grid = LineBuilder.GenerateGrid(); this.GridColor = SharpDX.Color.Black; this.GridTransform = new TranslateTransform3D(-5, -1, -5); // scene model3d var b1 = new MeshBuilder(); b1.AddSphere(new Vector3(0, 0, 0), 0.5); b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 1.5, BoxFaces.All); this.Model = b1.ToMeshGeometry3D(); // lines model3d var e1 = new LineBuilder(); e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 1.5); this.Lines = e1.ToLineGeometry3D(); // model trafos this.Model1Transform = CreateAnimatedTransform(new Vector3D(0, 0, 0), new Vector3D(1, 1, 1), 20); this.Model2Transform = new TranslateTransform3D(-3, 0, 0); this.Model3Transform = new TranslateTransform3D(+3, 0, 0); // model materials this.Material1 = PhongMaterials.Orange; this.Material2 = PhongMaterials.Orange; this.Material3 = PhongMaterials.Red; var dr = Color.DarkRed; Console.WriteLine(dr); }
public MainViewModel() { Title = "Instancing Demo"; // camera setup Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) }; // setup lighting this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f); this.DirectionalLightColor = (Color4)Color.White; this.DirectionalLightDirection = new Vector3(-2, -5, -2); // scene model3d var b1 = new MeshBuilder(); b1.AddBox(new Vector3(0, 0, 0), 0.8, 0.8, 0.5, BoxFaces.All); Model = b1.ToMeshGeometry3D(); var l1 = new LineBuilder(); l1.AddBox(new Vector3(0, 0, 0), 0.8, 0.8, 0.5); Lines = l1.ToLineGeometry3D(); int num = 10; var instances = new List<Matrix>(); for (int i = -num; i < num; i++) { for (int j = -num; j < num; j++) { instances.Add(Matrix.Translation(new Vector3(i / 1.0f, j / 1.0f, 0f))); } } ModelInstances = instances; SubTitle = "Number of Instances: " + instances.Count.ToString(); // model trafo ModelTransform = Media3D.Transform3D.Identity;// new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(0, 0, 1), 45)); // model material ModelMaterial = PhongMaterials.Glass; }