public MainViewModel() { // titles this.Title = "Simple Demo (Workitem 10043)"; this.SubTitle = "Please switch to Viewport 2 and then back to Viewport 1"; // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) }; if (this.RenderTechniquesManager != null) { // default render technique this.RenderTechnique = RenderTechniquesManager.RenderTechniques.Get(DefaultRenderTechniqueNames.Blinn); } // 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 = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); 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; //var diffColor = this.RedMaterial.DiffuseColor; //diffColor.Alpha = 0.5f; //this.RedMaterial.DiffuseColor = diffColor; }
public MainViewModel() { RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); this.Title = "Line Shading Demo (HelixToolkitDX)"; this.SubTitle = null; // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(0, 5, 5), LookDirection = new Vector3D(-0, -5, -5), UpDirection = new Vector3D(0, 1, 0) }; // 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 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); this.Model = b1.ToMeshGeometry3D(); // lines model3d var e1 = new LineBuilder(); e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2); //e1.AddLine(new Vector3(-1, 0, 0), new Vector3(1, 0, 0)); this.Lines = e1.ToLineGeometry3D(); // lines params this.LineThickness = 2; this.LineSmoothness = 2.0; this.LinesEnabled = true; this.GridEnabled = true; // model trafos this.Model1Transform = new TranslateTransform3D(0, 0, 0); this.Model2Transform = new TranslateTransform3D(-2, 0, 0); this.Model3Transform = new TranslateTransform3D(+2, 0, 0); // model materials this.Material1 = PhongMaterials.PolishedGold; this.Material2 = PhongMaterials.Copper; this.Material3 = PhongMaterials.Glass; }
public MainViewModel() { RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); 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; RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); }
public MainViewModel() { RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); // titles this.Title = "Mouse Drag Demo"; this.SubTitle = "WPF & SharpDX"; // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(0, 0, 9), LookDirection = new Vector3D(-0, -0, -9), UpDirection = new Vector3D(0, 1, 0) }; // default render technique this.RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; // 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(Vector3.UnitZ, -5, 5); this.GridColor = SharpDX.Color.Black; this.GridTransform = new Media3D.TranslateTransform3D(-0, -0, -0); // scene model3d var b1 = new MeshBuilder(); b1.AddSphere(new Vector3(0, 0, 0), 0.65); b1.AddBox(new Vector3(0, 0, 0), 1, 1, 1); var meshGeometry = b1.ToMeshGeometry3D(); meshGeometry.Colors = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); this.MeshGeometry = meshGeometry; this.Model1Instances = new List<Matrix>(); for (int i = 0; i < 5; i++) { this.Model1Instances.Add(Matrix.Translation(0, i, 0)); } // 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.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; // --- this.Shape3DCollection = new ObservableCollection<Shape3D> { new Shape3D() { Geometry = this.MeshGeometry, Material = this.BlueMaterial, Transform = this.Model3Transform, Instances = new List<Matrix>{Matrix.Identity}, DragZ = false, }, new Shape3D() { Geometry = this.MeshGeometry, Material = this.RedMaterial, Transform = this.Model1Transform, Instances = new List<Matrix>{Matrix.Identity}, DragZ = true, }, }; this.Element3DCollection = new ObservableCollection<Element3D>() { new DraggableGeometryModel3D() { Geometry = this.MeshGeometry, Material = this.BlueMaterial, Transform = this.Model3Transform, }, new DraggableGeometryModel3D() { Geometry = this.MeshGeometry, Material = this.RedMaterial, Transform = this.Model1Transform, }, }; this.AddCmd = new RelayCommand((o) => AddShape()); this.DelCmd = new RelayCommand((o) => DelShape()); }
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), FarPlaneDistance = 5000000 }; // 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 = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); 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; //var diffColor = this.RedMaterial.DiffuseColor; //diffColor.Alpha = 0.5f; //this.RedMaterial.DiffuseColor = diffColor; Points = new PointGeometry3D(); var ptPos = new Vector3Collection(); var ptIdx = new IntCollection(); for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { for (int z = 0; z < 10; z++) { ptIdx.Add(ptPos.Count); ptPos.Add(new Vector3(x, y, z)); } } } Points.Positions = ptPos; Points.Indices = ptIdx; Text = new BillboardText3D(); for (var i = 0; i < 50; i++) { for (var j = 0; j < 50; j++) { Text.TextInfo.Add(new TextInfo("Hello World", new Vector3(i,j,0))); } } }
public MainViewModel() { // titles Title = "Simple Demo"; SubTitle = "WPF & SharpDX"; // camera setup Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0), FarPlaneDistance = 5000000 }; // Create a custom render techniques manager that // only supports Phong and Blinn RenderTechniquesManager = new CustomRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques["RenderCustom"]; EffectsManager = new CustomEffectsManager(RenderTechniquesManager); // setup lighting AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f); DirectionalLightColor = Color.White; DirectionalLightDirection = new Vector3(-2, -5, -2); // floor plane grid Grid = LineBuilder.GenerateGrid(); GridColor = Color.Black; 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 = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); Model = meshGeometry; // lines model3d var e1 = new LineBuilder(); e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2); Lines = e1.ToLineGeometry3D(); // model transform Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0); Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0); Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0); // model materials RedMaterial = PhongMaterials.Red; GreenMaterial = PhongMaterials.Green; BlueMaterial = PhongMaterials.Blue; Points = new PointGeometry3D(); var ptPos = new Vector3Collection(); var ptIdx = new IntCollection(); Text = new BillboardText3D(); for (int x = -5; x <= 5; x++) { for (int y = -5; y <= 5; y++) { ptIdx.Add(ptPos.Count); ptPos.Add(new Vector3(x, -1, y)); Text.TextInfo.Add(new TextInfo(string.Format("{0}:{1}", x, y), new Vector3(x, -1, y))); } } Points.Positions = ptPos; Points.Indices = ptIdx; }