public MainViewModel() { EffectsManager = new DefaultEffectsManager(); var builder = new MeshBuilder(); builder.AddSphere(new Vector3(), 2); builder.AddTorus(5, 1); MeshModel = builder.ToMesh(); var lineBuilder = new LineBuilder(); lineBuilder.AddGrid(BoxFaces.All, 10, 10, 10, 10); LineModel = lineBuilder.ToLineGeometry3D(); var offset = new Vector3(-4, 0, 0); PointModel = new PointGeometry3D() { Positions = new HelixToolkit.Wpf.SharpDX.Core.Vector3Collection(MeshModel.Positions.Select(x => x + offset)) }; ExportCommand = new RelayCommand((o) => { Export(); }); ImportCommand = new RelayCommand((o) => { Import(); }); ExportSingleTechnique = new RelayCommand((o) => { Export(SelectedTechnique); }); }
public MainViewModel() { //Make sure to manually set device index to the default device(integrated graphics card) if using laptop with multiple graphics card. //Reference: https://social.msdn.microsoft.com/Forums/vstudio/en-US/9189da74-7b83-4a20-b0c1-7218ea38d633/does-desktop-duplication-api-work-only-on-default-graphics-adapter?forum=vcgeneral EffectsManager = new DefaultEffectsManager(0); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.ScreenDuplication]; }
private void ClearView() { // floor plane grid var Maxreset = 100; var Minreset = -100; EffectsManager.Dispose(); EffectsManager = new DefaultEffectsManager(); var points = new PointGeometry3D(); var col = new Color4Collection(); // gradient na kolory var ptPos = new Vector3Collection(); // pozycje punktów var ptIdx = new IntCollection(); // indeksy punktów arrows = lines = new LineBuilder(); points.Positions = ptPos; points.Indices = ptIdx; points.Colors = col; PointsColor = Colors.White; // <- nie pamiętam po co to tutaj ale bez tego nie działa Points = points; PointsTransform = new Media3D.TranslateTransform3D(0, 0, Minreset); CreateGrid(Maxreset, Minreset, Maxreset, Maxreset, Minreset); Grid = lines.ToLineGeometry3D(); GridColor = new Color4(153 / 255.0f, 204 / 255.0f, 255 / 255.0f, (float)0.3).ToColor();; GridTransform = new Media3D.TranslateTransform3D(0, 0, Minreset); // strzałki CreateArrows(Maxreset, Minreset, Maxreset, Minreset, Maxreset, Minreset); Arrow = arrows.ToLineGeometry3D(); ArrowColor = new Color4(0, 255 / 255.0f, 255 / 255.0f, (float)0.5).ToColor();; ArrowTransform = new Media3D.TranslateTransform3D(0, 0, Minreset); }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); // titles Title = "Viewer"; SubTitle = "Marine Technology"; // camera setup Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera { Position = new Point3D(0, -5, 5), LookDirection = new Vector3D(0, 10, 5),//z kamerą jest problem przy przybliżaniu prawdopodobnie przez ten LookDirection albo sposób poruszania kamerą UpDirection = new Vector3D(0, 0, 1), FarPlaneDistance = 5000000 }; // setup lighting AmbientLightColor = Colors.DimGray; DirectionalLightColor = Colors.White; // światełko musi być DirectionalLightDirection = Camera.LookDirection; MainView(); AddPointCloud(); UpXCommand = new RelayCommand(x => { UpDirection = new Vector3D(1, 0, 0); }); UpYCommand = new RelayCommand(x => { UpDirection = new Vector3D(0, 1, 0); }); UpZCommand = new RelayCommand(x => { UpDirection = new Vector3D(0, 0, 1); }); }
public MainViewModel() { // titles this.Title = "DynamicTexture Demo"; this.SubTitle = "WPF & SharpDX"; EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; this.Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera { Position = new Point3D(30, 30, 30), LookDirection = new Vector3D(-30, -30, -30), UpDirection = new Vector3D(0, 1, 0) }; this.Light1Color = Colors.White; this.Light1Direction = new Vector3D(-10, -10, -10); this.AmbientLightColor = Colors.DimGray; SetupCameraBindings(this.Camera); LineColor = Colors.Blue; Items = new ObservableCollection<DataModel>(); var sw = Stopwatch.StartNew(); CreateDefaultModels(); sw.Stop(); Console.WriteLine("Create Models total time =" + sw.ElapsedMilliseconds + " ms"); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(50); timer.Tick += Timer_Tick; AddModelCommand = new RelayCommand(AddModel); RemoveModelCommand = new RelayCommand(RemoveModel); ClearModelCommand = new RelayCommand(ClearModel); AutoTestCommand = new RelayCommand(AutoTestAddRemove); MultiViewportCommand = new RelayCommand((o) => { var win = new MultiviewportWin() { DataContext = this }; win.Show(); }); }
public MainViewModel() { this.Title = "Environment Mapping Demo"; this.SubTitle = "HelixToolkitDX"; // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(10, 0, 0), LookDirection = new Vector3D(-10, 0, 0), UpDirection = new Vector3D(0, 1, 0) }; //this.Camera = new OrthographicCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) }; // lighting setup this.AmbientLightColor = new Color4(0.5f, 0.5f, 0.5f, 1.0f); this.DirectionalLightColor = Color.White; this.DirectionalLightDirection = new Vector3(-2, -1, 1); // scene model3d var b1 = new MeshBuilder(true); b1.AddSphere(new Vector3(0, 0, 0), 1.0, 64, 64); b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 3, BoxFaces.All); this.Model = b1.ToMeshGeometry3D(); this.ModelTransform = new Media3D.TranslateTransform3D(); this.ModelMaterial = PhongMaterials.Copper; RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; // titles this.Title = "Post Processing Effects Demo"; this.SubTitle = "WPF & SharpDX"; // ---------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(0, -30, 0), LookDirection = new Vector3D(0, 30, 0), UpDirection = new Vector3D(0, 0, 1) }; var m1 = Load3ds("suzanne.obj").Select(x => x.Geometry).ToArray(); MeshModel1 = m1[0]; var m2 = Load3ds("skeleton.3ds").Select(x => x.Geometry).ToArray(); MeshModel2 = m2[0]; Model1Transform = new Media3D.TranslateTransform3D(new Vector3D(7, 0, 0)); Model2Transform = new Media3D.TranslateTransform3D(new Vector3D(-5, 0, 0)); var builder = new MeshBuilder(); builder.AddBox(new Vector3(0, 0, -5), 15, 15, 0.2); FloorModel = builder.ToMesh(); }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); 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 = Colors.DimGray; this.DirectionalLightColor = Colors.White; this.DirectionalLightDirection = new Vector3D(-2, -5, -2); // floor plane grid this.Grid = LineBuilder.GenerateGrid(); this.GridColor = Media.Colors.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); //this.Lines = e1.ToLineGeometry3D().ToUnshared(); this.Lines = e1.ToLineGeometry3D(true); this.Lines.Colors = new Color4Collection(); var linesCount = this.Lines.Indices.Count; var rnd = new Random(); while (linesCount-- > 0) { this.Lines.Colors.Add(rnd.NextColor()); } // 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 CanvasMock() { RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Phong]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); Device = EffectsManager.Device; }
public MainViewModel() { this.Title = "ImageViewDemo"; this.SubTitle = "WPF & SharpDX"; EffectsManager = new DefaultEffectsManager(); this.OpenCommand = new RelayCommand((x) => this.OnOpenClick()); // camera setup this.defaultPerspectiveCamera = new PerspectiveCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 0.5, FarPlaneDistance = 150 }; this.defaultOrthographicCamera = new OrthographicCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 0, FarPlaneDistance = 100 }; this.Camera = this.defaultPerspectiveCamera; // setup lighting this.AmbientLightColor = new Color4(0f, 0f, 0f, 0f); this.DirectionalLightColor = Color.White; this.DirectionalLightDirection = new Vector3D(-0, -0, -10); // floor plane grid this.Grid = LineBuilder.GenerateGrid(Vector3.UnitZ, -5, 5, -5, 5); this.GridColor = Color.Black; this.GridTransform = new Media3D.TranslateTransform3D(0, 0, 0); // plane var b2 = new MeshBuilder(); b2.AddBox(new Vector3(0, 0, 0), 10, 10, 0, BoxFaces.PositiveZ); this.Plane = b2.ToMeshGeometry3D(); this.PlaneMaterial = PhongMaterials.Blue; this.PlaneTransform = new Media3D.TranslateTransform3D(-0, -0, -0); //this.PlaneMaterial.ReflectiveColor = Color.Black; this.PlaneTransform = new Media3D.TranslateTransform3D(0, 0, 0); }
public MainViewModel() { RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); Title = "Shadow Map Demo"; SubTitle = "WPF & SharpDX"; // setup lighting this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f); this.DirectionalLightColor = Color.White; this.DirectionalLightDirection = new Vector3(-0, -1, -1); this.LightDirectionTransform = CreateAnimatedTransform(-DirectionalLightDirection.ToVector3D(), new Vector3D(0, 1, -1), 24); this.ShadowMapResolution = new Vector2(2048, 2048); // camera setup this.Camera = new PerspectiveCamera { Position = (Point3D)(-DirectionalLightDirection.ToVector3D()), LookDirection = DirectionalLightDirection.ToVector3D(), UpDirection = new Vector3D(0, 1, 0) }; Camera1 = new PerspectiveCamera { Position = (Point3D)(-DirectionalLightDirection.ToVector3D()), LookDirection = DirectionalLightDirection.ToVector3D(), UpDirection = new Vector3D(0, 1, 0) }; Camera2 = new PerspectiveCamera { Position = (Point3D)(-DirectionalLightDirection.ToVector3D()), LookDirection = DirectionalLightDirection.ToVector3D(), UpDirection = new Vector3D(0, 1, 0) }; // floor plane grid //Grid = LineBuilder.GenerateGrid(); //GridColor = SharpDX.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.25, 2, BoxFaces.All); Model = b1.ToMeshGeometry3D(); //Instances = new[] { Matrix.Translation(0, 0, -1.5f), Matrix.Translation(0, 0, 1.5f) }; var b2 = new MeshBuilder(); b2.AddBox(new Vector3(0, 0, 0), 10, 0, 10, BoxFaces.PositiveY); Plane = b2.ToMeshGeometry3D(); PlaneTransform = new Media3D.TranslateTransform3D(-0, -2, -0); GrayMaterial = PhongMaterials.LightGray; //GrayMaterial.TextureMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)); // lines model3d Lines = LineBuilder.GenerateBoundingBox(Model); // model trafos 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.Glass; GreenMaterial = PhongMaterials.Green; BlueMaterial = PhongMaterials.Blue; }
public MainViewModel(MainWindow window) { this.mainWindow = window; this.Title = "My helix practise"; this.SubTitle = "WPF & SharpDX"; EffectsManager = new DefaultEffectsManager(); /* * Camera = new OrthographicCamera() * { * LookDirection = new System.Windows.Media.Media3D.Vector3D(0, -10, -10), * Position = new System.Windows.Media.Media3D.Point3D(0, 10, 10), * UpDirection = new System.Windows.Media.Media3D.Vector3D(0, 1, 0), * FarPlaneDistance = 5000, * NearPlaneDistance = 0.1f * }; */ /**/ this.Camera = new PerspectiveCamera { Position = new Media3D.Point3D(50, 50, 50), LookDirection = new Media3D.Vector3D(-50, -50, -50), UpDirection = new Media3D.Vector3D(0, 1, 0), NearPlaneDistance = 1, FarPlaneDistance = 20000, FieldOfView = 15 }; InitBindingCommand(); }
/// <summary> /// constructor /// </summary> public mainViewModel() { showCurves = true; showFaces = false; showPanels = true; effectsManager = new DefaultEffectsManager(); helixMaterials = Enum.GetValues(typeof(projectMaterials)).Cast <projectMaterials>(); updateProperties = new relayCommand(x => updatePanelProperties(selection)); changePreviewMaterial = new relayCommand(x => previewSelectionMaterial()); // titles title = "App"; subTitle = "Test"; // camera setup camera = new PerspectiveCamera { Position = new Point3D(1500, 1500, 2500), LookDirection = new Vector3D(-60, -60, -100), UpDirection = upDirection, FarPlaneDistance = 1e4, NearPlaneDistance = 0.01, }; camera2d = new OrthographicCamera { Position = new Point3D(0, 0, 55), LookDirection = new Vector3D(0, 0, -25), UpDirection = upDirection2d, FarPlaneDistance = 1e4, NearPlaneDistance = 0.01, }; // setup lighting ambientLightColor = Colors.DimGray; directionalLightColor = Colors.White; // selection options //selectionColor = Color.FromRgb(91, 198, 208); selectionColor = Colors.Red; selectionMaterial = new DiffuseMaterial() { DiffuseColor = new Color4(91, 198, 208, 255) }; // floor plane grid (1') majorGrid = LineBuilder.GenerateGrid(new Vector3(1, 1, 0), -100, 100, -100, 100); majorGridColor = Color.FromArgb(150, 200, 200, 200); majorGridTransform = new Media3D.TranslateTransform3D(0, 0, -0.01); // grid (1') panelGrid = LineBuilder.GenerateGrid(new Vector3(1, 1, 0), -10, 10, -10, 10); panelGridColor = Color.FromArgb(255, 100, 100, 100); panelGridTransform = new Media3D.TranslateTransform3D(0, 0, -0.01); addCubes(); }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); Camera = new PerspectiveCamera { }; // 座標面の作成 GridGeometry3D = LineBuilder.GenerateGrid(10); LineBuilder lineBuilderX = new LineBuilder(); lineBuilderX.AddLine(new Vector3(0, 0, 0), new Vector3(1, 0, 0)); AxisX = lineBuilderX.ToLineGeometry3D(); LineBuilder lineBuilderY = new LineBuilder(); lineBuilderY.AddLine(new Vector3(0, 0, 0), new Vector3(0, 1, 0)); AxisY = lineBuilderY.ToLineGeometry3D(); LineBuilder lineBuilderZ = new LineBuilder(); lineBuilderZ.AddLine(new Vector3(0, 0, 0), new Vector3(0, 0, 1)); AxisZ = lineBuilderZ.ToLineGeometry3D(); // 座標面のトランスフォーム作成 GridGeometry3DTransform = new System.Windows.Media.Media3D.TranslateTransform3D(-5, 0, -5); }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; // ---------------------------------------------- // titles this.Title = "SwapChain Top Surface Rendering Demo"; this.SubTitle = "WPF & SharpDX"; // ---------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(20, 20, 20), LookDirection = new Vector3D(-20, -20, -20), UpDirection = new Vector3D(0, 1, 0) }; // ---------------------------------------------- // setup scene this.Light1Color = Colors.White; var builder = new MeshBuilder(true, false, false); builder.AddBox(new Vector3(), 40, 0.1, 40); Plane1Model = FloorModel = builder.ToMeshGeometry3D(); builder = new MeshBuilder(true, false, false); builder.AddBox(new Vector3(), 0.1, 40, 40); Plane2Model = builder.ToMeshGeometry3D(); FloorMaterial = new PhongMaterial(); FloorMaterial.DiffuseColor = new Color4(1f, 1f, 1f, 0.2f); FloorMaterial.AmbientColor = new Color4(0, 0, 0, 0); FloorMaterial.ReflectiveColor = new Color4(0, 0, 0, 0); FloorMaterial.SpecularColor = new Color4(0, 0, 0, 0); PlaneMaterial = new PhongMaterial() { DiffuseColor = new Color4(0.1f, 0.1f, 0.8f, 0.2f) }; var landerItems = Load3ds("Car.3ds").Select(x => x.Geometry as MeshGeometry3D).ToArray(); Model = MeshGeometry3D.Merge(landerItems); Model.UpdateOctree(); ModelMaterial = PhongMaterials.Bronze; var transGroup = new Media3D.Transform3DGroup(); transGroup.Children.Add(new Media3D.ScaleTransform3D(0.01, 0.01, 0.01)); transGroup.Children.Add(new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Media3D.Vector3D(1, 0, 0), -90))); transGroup.Children.Add(new Media3D.TranslateTransform3D(new Media3D.Vector3D(0, 6, 0))); ModelTransform = transGroup; Plane1Transform = new TranslateTransform3D(new Vector3D(0, 15, 0)); Plane2Transform = new TranslateTransform3D(new Vector3D(15, 0, 0)); }
public MainViewModel() { // titles this.Title = "Simple Demo (Workitem 10048 and 10052)"; this.SubTitle = "Select lines with left mouse button.\nRotate or zoom around a point on a line if the cursor is above one."; EffectsManager = new DefaultEffectsManager(); }
public MainViewModel() { this.ModelTransform = new TranslateTransform3D(0, 0, 0); this.ModelGeometry = new Element3DCollection(); RenderTechniquesManager = new DefaultRenderTechniquesManager(); EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); }
public MainViewModel() { // titles this.Title = "Simple Demo (Workitem 10044)"; this.SubTitle = "Please note that this scene is defined completely in XAML."; EffectsManager = new DefaultEffectsManager(); }
// public DefaultRenderTechniquesManager RenderTechniquesManager { get; private set; } public MainViewModel() { this.ModelTransform = new TranslateTransform3D(0, 0, 0); this.ModelGeometry = new GroupModel3D(); // RenderTechniquesManager = new DefaultRenderTechniquesManager(); EffectsManager = new DefaultEffectsManager(); }
//public Camera Camera2 { private set; get; } public MainViewModel() { EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; Title = "Shadow Map Demo"; SubTitle = "WPF & SharpDX"; // setup lighting this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f); this.DirectionalLightColor = Media.Colors.White; //this.DirectionalLightDirection = new Vector3(-1, -1, -1); // this.LightDirectionTransform = CreateAnimatedTransform(-DirectionalLightDirection.ToVector3D(), new Vector3D(0, 1, -1), 24); this.ShadowMapResolution = new Size(2048, 2048); // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(0, 1, 1), LookDirection = new Vector3D(0, -1, -1), UpDirection = new Vector3D(0, 1, 0) }; Camera1 = new PerspectiveCamera { Position = new Point3D(0, 5, 0), LookDirection = new Vector3D(0, -1, 0), UpDirection = new Vector3D(1, 0, 0) }; // scene model3d var b1 = new MeshBuilder(); b1.AddSphere(new Vector3(0, 0, 0), 0.5); b1.AddBox(new Vector3(0, 0, 0), 1, 0.25, 2, BoxFaces.All); Model = b1.ToMeshGeometry3D(); Instances = new[] { Matrix.Translation(0, 0, -1.5f), Matrix.Translation(0, 0, 1.5f) }; var b2 = new MeshBuilder(); b2.AddBox(new Vector3(0, 0, 0), 10, 0, 10, BoxFaces.PositiveY); Plane = b2.ToMeshGeometry3D(); PlaneTransform = new Media3D.TranslateTransform3D(-0, -2, -0); GrayMaterial = PhongMaterials.Indigo; // lines model3d Lines = LineBuilder.GenerateBoundingBox(Model); //this.PropertyChanged += MainViewModel_PropertyChanged; // model trafos 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.Glass; GreenMaterial = PhongMaterials.Green; BlueMaterial = PhongMaterials.Blue; GrayMaterial.RenderShadowMap = RedMaterial.RenderShadowMap = GreenMaterial.RenderShadowMap = BlueMaterial.RenderShadowMap = true; //var b3 = new MeshBuilder(); //b3.AddBox(new Vector3(), 0.3f, 0.3f, 0.3f, BoxFaces.All); //b3.AddCone(new Vector3(0, 0.3f, 0), new Vector3(0, 0f, 0), 0.2f, true, 24); //LightCameraModel = b3.ToMesh(); //LightCameraTransform.Children.Add(new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(1, 0, 0), -135))); //LightCameraTransform.Children.Add(new Media3D.TranslateTransform3D(0, 3, 3)); //UpdateCamera(); }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); 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 = Colors.DimGray; this.DirectionalLightColor = Colors.White; this.DirectionalLightDirection = new Vector3D(-2, -5, -2); // floor plane grid this.Grid = LineBuilder.GenerateGrid(); this.GridColor = Colors.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(); var m1 = Load3ds("suzanne.3ds"); this.Model2 = m1[0].Geometry as MeshGeometry3D; //Manully set an offset for test for(int i=0; i < Model2.Positions.Count; ++i) { Model2.Positions[i] = Model2.Positions[i] + new Vector3(2, 3, 4); } Model2.UpdateBounds(); // 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 = new TranslateTransform3D(0, 0, 0); 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 = Colors.DarkRed; Console.WriteLine(dr); ResetTransformsCommand = new RelayCommand((o) => { this.Model1Transform = new TranslateTransform3D(0, 0, 0); this.Model2Transform = new TranslateTransform3D(-3, 0, 0); this.Model3Transform = new TranslateTransform3D(+3, 0, 0); }); }
public MainViewModel() { // titles this.Title = "Simple Demo (Workitem 10044)"; this.SubTitle = "Please note that this scene is defined completely in XAML."; EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; }
public MainViewModel() { // titles this.Title = "Simple Demo (Workitem 10051)"; this.SubTitle = "LineGeometryModel3D now works with OrthographicCamera and Intel HD 3000."; this.PropertyChanged += this.OnPropertyChanged; EffectsManager = new DefaultEffectsManager(); }
// public DefaultRenderTechniquesManager RenderTechniquesManager { get; private set; } public MainViewModel() { this.ModelTransform = new TranslateTransform3D(0, 0, 0); this.ModelGeometry = new GroupModel3D(); this.ModelGeometry.ItemsSource = new ObservableCollection <Element3D>(); // RenderTechniquesManager = new DefaultRenderTechniquesManager(); EffectsManager = new DefaultEffectsManager(); }
public MainViewModel() { EffectsManager = new DefaultEffectsManager(); RenderTechnique = EffectsManager[DefaultRenderTechniqueNames.Blinn]; // ---------------------------------------------- // titles this.Title = "Hardware Tessellation Demo"; this.SubTitle = "WPF & SharpDX"; // --------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(7, 10, 12), LookDirection = new Vector3D(-7, -10, -12), UpDirection = new Vector3D(0, 1, 0) }; // --------------------------------------------- // setup lighting this.AmbientLightColor = Color.FromArgb(1, 12, 12, 12); this.DirectionalLightColor = Colors.White; this.DirectionalLightDirection1 = new Vector3D(-0, -20, -20); this.DirectionalLightDirection2 = new Vector3D(-0, -1, +50); this.DirectionalLightDirection3 = new Vector3D(0, +1, 0); // --------------------------------------------- // model trafo this.DefaultTransform = new Media3D.TranslateTransform3D(0, -0, 0); // --------------------------------------------- // model material this.DefaultMaterial = new PhongMaterial { AmbientColor = Colors.Gray.ToColor4(), DiffuseColor = Colors.Red.ToColor4(), // Colors.LightGray, SpecularColor = Colors.White.ToColor4(), SpecularShininess = 100f, DiffuseMap = LoadFileToMemory(new System.Uri(@"./Media/TextureCheckerboard2.dds", System.UriKind.RelativeOrAbsolute).ToString()), NormalMap = LoadFileToMemory(new System.Uri(@"./Media/TextureCheckerboard2_dot3.dds", System.UriKind.RelativeOrAbsolute).ToString()), EnableTessellation = true, RenderShadowMap = true }; FloorMaterial.RenderShadowMap = true; // --------------------------------------------- // init model this.LoadModel(@"./Media/teapot_quads_tex.obj", this.meshTopology == MeshTopologyEnum.PNTriangles ? MeshFaces.Default : MeshFaces.QuadPatches); // --------------------------------------------- // floor plane grid this.Grid = LineBuilder.GenerateGrid(10); this.GridColor = Colors.Black; this.GridTransform = new Media3D.TranslateTransform3D(-5, -4, -5); var builder = new MeshBuilder(true, true, true); builder.AddBox(new Vector3(0, -5, 0), 60, 0.5, 60, BoxFaces.All); FloorModel = builder.ToMesh(); Instances = new Matrix[] { Matrix.Identity, Matrix.Translation(10, 0, 10), Matrix.Translation(-10, 0, 10), Matrix.Translation(10, 0, -10), Matrix.Translation(-10, 0, -10), }; }
public MultiAngleViewModel(MultiAngleView multiview) { RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); _multiview = multiview; SetLight(); SetCamera(); }
//---------------------- private void Clear() { EffectsManager.Dispose(); EffectsManager = new DefaultEffectsManager(); VisualizationTools.ClearView(out PointModel points, out GridModel grid, out AxisModel axis); this.Points = points; this.Grid = grid; this.Axis = axis; this.PointGrid = new GridModel(); }
public TestWindowViewModel() { this.Camera = new PerspectiveCamera { Position = new Media3D.Point3D(8, 9, 7), LookDirection = new Media3D.Vector3D(-5, -12, -5), UpDirection = new Media3D.Vector3D(0, 1, 0) }; EffectsManager = new DefaultEffectsManager(); var builder = new MeshBuilder(); builder.AddBox(new SDX.Vector3(), 2, 2, 2); Mesh = builder.ToMesh(); }
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() { // titles this.Title = "Bug? BillboardText3D not visible until origin comes in sight."; this.SubTitle = "Please move or rotate the view and see how the BillboardText suddenly appears when the origin (right front edge of the grid) comes into view."; // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(4.4, 2.2, -4.4), LookDirection = new Vector3D(0, -4, 10), UpDirection = new Vector3D(0, 1, 0) }; EffectsManager = new DefaultEffectsManager(); // setup lighting this.AmbientLightColor = Colors.Black; this.DirectionalLightColor = Colors.White; // floor plane grid this.Grid = LineBuilder.GenerateGrid(); this.GridColor = SharpDX.Color.Black; // scene model3d var b1 = new MeshBuilder(); b1.AddSphere(new Vector3(0, 0, 0), 0.05); var meshGeometry = b1.ToMeshGeometry3D(); meshGeometry.Colors = new Color4Collection(meshGeometry.TextureCoordinates.Select(x => x.ToColor4())); this.Model = meshGeometry; // Create Billboard Text float offset = 4.5f; float scale = 0.8f; // Text3D.TextInfo.Add(new TextInfo("Origin", new Vector3(0,0,0)) { Foreground = SharpDX.Color.Red, Scale = scale * 2 }); // Text3D.TextInfo.Add(new TextInfo("1", new Vector3(1,0,0)) { Foreground = SharpDX.Color.Blue, Scale = scale * 2 }); Text3D.TextInfo.Add(new TextInfo("2", new Vector3(2, 0, 0)) { Foreground = SharpDX.Color.Blue, Scale = scale * 2 }); Text3D.TextInfo.Add(new TextInfo("3", new Vector3(3, 0, 3)) { Foreground = SharpDX.Color.Blue, Scale = scale * 2 }); Text3D.TextInfo.Add(new TextInfo("4", new Vector3(4, 0, 3)) { Foreground = SharpDX.Color.Blue, Scale = scale * 2 }); Text3D.TextInfo.Add(new TextInfo("5", new Vector3(5, 0, 3)) { Foreground = SharpDX.Color.Blue, Scale = scale * 2 }); }
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() { this.Items = new ObservableCollection<Shape> { new Sphere { Transform = new TranslateTransform3D(0, 0, 0), Material = PhongMaterials.Red }, new Cube { Transform = new TranslateTransform3D(1, 0, 0), Material = PhongMaterials.Green }, new Cube { Transform = new TranslateTransform3D(-1, 0, 0), Material = PhongMaterials.Blue } }; RenderTechniquesManager = new DefaultRenderTechniquesManager(); EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); }
public MainViewModel() { RenderTechniquesManager = new DefaultRenderTechniquesManager(); RenderTechnique = RenderTechniquesManager.RenderTechniques[DefaultRenderTechniqueNames.Blinn]; EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); // ---------------------------------------------- // titles this.Title = "Lighting Demo"; this.SubTitle = "WPF & SharpDX"; // ---------------------------------------------- // camera setup this.Camera = new PerspectiveCamera { Position = new Point3D(8, 9, 7), LookDirection = new Vector3D(-5, -12, -5), UpDirection = new Vector3D(0, 1, 0) }; // ---------------------------------------------- // setup scene this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f); this.RenderLight1 = true; this.RenderLight2 = true; this.RenderLight3 = true; this.RenderLight4 = true; this.Light1Color = (Color4)Color.White; this.Light2Color = (Color4)Color.Red; this.Light3Color = (Color4)Color.LightYellow; this.Light4Color = (Color4)Color.LightBlue; this.Light2Attenuation = new Vector3(1.0f, 0.5f, 0.10f); this.Light3Attenuation = new Vector3(1.0f, 0.1f, 0.05f); this.Light4Attenuation = new Vector3(1.0f, 0.2f, 0.0f); this.Light1Direction = new Vector3(0, -10, -10); this.Light1Transform = new TranslateTransform3D(-Light1Direction.ToVector3D()); this.Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction.ToVector3D(), new Vector3D(0, 1, -1), 24); this.Light2Transform = CreateAnimatedTransform1(new Vector3D(-4, 0, 0), new Vector3D(0, 0, 1), 3); this.Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 0, 4), new Vector3D(0, 1, 0), 5); this.Light4Direction = new Vector3(0, -5, 0); this.Light4Transform = new TranslateTransform3D(-Light4Direction.ToVector3D()); this.Light4DirectionTransform = CreateAnimatedTransform2(-Light4Direction.ToVector3D(), new Vector3D(1, 0, 0), 12); // ---------------------------------------------- // light model3d var sphere = new MeshBuilder(); sphere.AddSphere(new Vector3(0, 0, 0), 0.2); Sphere = sphere.ToMeshGeometry3D(); this.LightModelMaterial = new PhongMaterial { AmbientColor = Color.Gray, DiffuseColor = Color.Gray, EmissiveColor = Color.Yellow, SpecularColor = Color.Black, }; // ---------------------------------------------- // scene model3d var b1 = new MeshBuilder(true, true, true); b1.AddSphere(new Vector3(0.25f, 0.25f, 0.25f), 0.75, 64, 64); b1.AddBox(-new Vector3(0.25f, 0.25f, 0.25f), 1, 1, 1, BoxFaces.All); b1.AddBox(-new Vector3(5.0f, 0.0f, 0.0f), 1, 1, 1, BoxFaces.All); b1.AddSphere(new Vector3(5f, 0f, 0f), 0.75, 64, 64); b1.AddCylinder(new Vector3(0f, -3f, -5f), new Vector3(0f, 3f, -5f), 1.2, 64); this.Model = b1.ToMeshGeometry3D(); this.ModelTransform = new Media3D.TranslateTransform3D(0, 0, 0); this.ModelMaterial = PhongMaterials.Chrome; //this.ModelMaterial.TextureMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)); this.ModelMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute)); //odelMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureNoise1_dot3.jpg", System.UriKind.RelativeOrAbsolute)); // ---------------------------------------------- // floor model3d var b2 = new MeshBuilder(true, true, true); b2.AddBox(new Vector3(0.0f, -5.0f, 0.0f), 15, 0.1, 15, BoxFaces.All); b2.AddSphere(new Vector3(-5.0f, -5.0f, 5.0f), 4, 64, 64); b2.AddCone(new Vector3(6f, -9f, -6f), new Vector3(6f, -1f, -6f), 4f, true, 64); this.Floor = b2.ToMeshGeometry3D(); this.FloorTransform = new Media3D.TranslateTransform3D(0, 0, 0); this.FloorMaterial = new PhongMaterial { AmbientColor = Color.Gray, DiffuseColor = new Color4(0.75f, 0.75f, 0.75f, 1.0f), SpecularColor = Color.White, SpecularShininess = 100f, DiffuseMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)), NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute)), }; }
/// <summary> /// /// </summary> private void StartD3D() { if (EffectsManager == null || RenderTechniquesManager == null) { // Make sure both are null RenderTechniquesManager = null; EffectsManager = null; RenderTechniquesManager = new DefaultRenderTechniquesManager(); EffectsManager = new DefaultEffectsManager(RenderTechniquesManager); return; // StardD3D() is called from DP changed handler } surfaceD3D = new DX11ImageSource(EffectsManager.AdapterIndex); surfaceD3D.IsFrontBufferAvailableChanged += OnIsFrontBufferAvailableChanged; device = EffectsManager.Device; deferredRenderer = new DeferredRenderer(); renderRenderable.DeferredRenderer = deferredRenderer; CreateAndBindTargets(); SetDefaultRenderTargets(); Source = surfaceD3D; InvalidateRender(); }
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()); }