/* public void updateheadingdirection(double _angle) * { * contentlayer.Children.Clear(); * // var axis = new Vector3D(0, 0, 1); * // var angle = m_Heading; * // var matrix = device3D.Transform.Value; * // matrix.Rotate(new Quaternion(axis, angle)); * // device3D.Transform = new MatrixTransform3D(matrix); * contentlayer.Children.Add(device3D); * }*/ public Robot3D(String robotname, ModelVisual3D _contentlayer) { robot3DInfo = new Robot3DInfo(); contentlayer = _contentlayer; device3D = new ModelVisual3D(); robot3DInfo.version = GlobalVariables.getPathRobot3DModel(); device3D.SetName(robotname); device3D.Content = Display3d(robot3DInfo.version); //device3D.Content =Display3d(robot3DInfo.modelPath); }
public MainWindow() { InitializeComponent(); setCameraPosition = new SetCameraPosition(SetPosition); setModelColor = new SetModelColor(ViewControl.SetColor); setFocus = new SetFocus(SetViewportFocus); device3D = new ModelVisual3D(); device3D.Content = Display3d(MODEL_PATH); device3D.SetName("worldModel"); // Add to view port viewport.Children.Add(device3D); }
private void CreateTestScene() { MainViewport.Children.Clear(); string fileName = AppDomain.CurrentDomain.BaseDirectory + @"Resources\ObjFiles\house with trees.obj"; var readerObj = new Ab3d.ReaderObj(); var sceneModel3D = readerObj.ReadModel3D(fileName); LogMessage("Loaded:\r\n" + Ab3d.Utilities.Dumper.GetObjectHierarchyString(sceneModel3D)); Ab3d.Utilities.ModelUtils.CenterAndScaleModel3D(sceneModel3D, centerPosition: new Point3D(0, 0, 0), finalSize: new Size3D(100, 100, 100), preserveAspectRatio: true); _sceneVisual3D = new ModelVisual3D(); _sceneVisual3D.Content = sceneModel3D; _sceneVisual3D.SetName("SceneVisual3D"); // Set Name dependency properties so that we can read then when getting hit test result MainViewport.Children.Add(_sceneVisual3D); _glassPlaneVisual3D = new Ab3d.Visuals.PlaneVisual3D() { CenterPosition = new Point3D(0, 0, 45), Size = new Size(70, 10), Normal = new Vector3D(0, 0, 1), HeightDirection = new Vector3D(0, 1, 0), Material = new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(100, 200, 200, 255))) }; _glassPlaneVisual3D.BackMaterial = _glassPlaneVisual3D.Material; _glassPlaneVisual3D.SetName("GlassPlaneVisual3D"); MainViewport.Children.Add(_glassPlaneVisual3D); Camera1.Refresh(); // This will recreate camera's light that was removed when we called MainViewport.Children.Clear() }
private void AddModelVisual3DObjects() { var rootModelVisual3D = new ModelVisual3D(); var transform3DGroup = new Transform3DGroup(); transform3DGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), -90))); transform3DGroup.Children.Add(new TranslateTransform3D(0, 0, 200)); rootModelVisual3D.Transform = transform3DGroup; rootModelVisual3D.SetName("Root_ModelVisual3D"); MainViewport.Children.Add(rootModelVisual3D); var bottomModelVisual3D = new ModelVisual3D(); bottomModelVisual3D.SetName("Bottom_ModelVisual3D"); var bottomBox3D = new BoxVisual3D() { CenterPosition = new Point3D(0, 0, 0), Size = new Size3D(200, 20, 120), Material = new DiffuseMaterial(Brushes.Blue) }; bottomModelVisual3D.Children.Add(bottomBox3D); // You can add child Visual3D objects to ModelVisual3D rootModelVisual3D.Children.Add(bottomModelVisual3D); var left1ModelVisual3D = new ModelVisual3D(); left1ModelVisual3D.SetName("Left_1_ModelVisual3D"); var left1Box3D = new BoxVisual3D() { CenterPosition = new Point3D(-50, 50, 0), Size = new Size3D(80, 60, 100), Material = new DiffuseMaterial(Brushes.DodgerBlue) }; left1ModelVisual3D.Children.Add(left1Box3D); var right1ModelVisual3D = new ModelVisual3D(); right1ModelVisual3D.SetName("Right_1_ModelVisual3D"); var right1Box3D = new BoxVisual3D() { CenterPosition = new Point3D(50, 40, 0), Size = new Size3D(80, 20, 100), Material = new DiffuseMaterial(Brushes.DodgerBlue) }; right1ModelVisual3D.Children.Add(right1Box3D); bottomModelVisual3D.Children.Add(left1ModelVisual3D); bottomModelVisual3D.Children.Add(right1ModelVisual3D); var right21ModelVisual3D = new ModelVisual3D(); right21ModelVisual3D.SetName("Right_2_1_ModelVisual3D"); var right2_1Box3D = new BoxVisual3D() { CenterPosition = new Point3D(30, 70, 0), Size = new Size3D(30, 20, 80), Material = new DiffuseMaterial(Brushes.LightSkyBlue) }; right21ModelVisual3D.Children.Add(right2_1Box3D); var right22ModelVisual3D = new ModelVisual3D(); right22ModelVisual3D.SetName("Right_2_2_ModelVisual3D"); // With ModelVisual3D we can also show Model3D (GeometryModel3D or Model3DGroup) objects. // To do that we set it to ModelVisual3D.Content property or specify it in the constructor. var right2_2Model3D = Ab3d.Models.Model3DFactory.CreateBox(new Point3D(70, 70, 0), new Size3D(30, 20, 80), new DiffuseMaterial(Brushes.LightSkyBlue)); right22ModelVisual3D.Content = right2_2Model3D; right1ModelVisual3D.Children.Add(right21ModelVisual3D); right1ModelVisual3D.Children.Add(right22ModelVisual3D); Ab3d.Utilities.ModelIterator.IterateModelVisualsObjects(rootModelVisual3D.Children, null, delegate(ModelVisual3D visual3D, Transform3D transform3D) { CreateIsVisibleCheckBoxes(visual3D, ModelVisualStackPanel); }); }
private void CreateTestModels() { _rootModelVisual3D = new ModelVisual3D(); MainViewport3D.Children.Add(_rootModelVisual3D); // SphereVisual3D _sphereVisual3D = new Ab3d.Visuals.SphereVisual3D() { CenterPosition = new Point3D(-50, 0, -50), Radius = 30, Material = new DiffuseMaterial(Brushes.Silver) }; _sphereVisual3D.SetName("SphereVisual3D"); _rootModelVisual3D.Children.Add(_sphereVisual3D); var readerObj = new ReaderObj(); var teapotModel = readerObj.ReadModel3D(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\Models\teapot-hires.obj")); Ab3d.Utilities.ModelUtils.CenterAndScaleModel3D(teapotModel, centerPosition: new Point3D(50, 0, -50), finalSize: new Size3D(80, 80, 80), preserveAspectRatio: true); _teapotModelVisual3D = new ModelVisual3D() { Content = teapotModel }; teapotModel.SetName("teapot Model3D"); _teapotModelVisual3D.SetName("teapot ModelVisual3D"); _rootModelVisual3D.Children.Add(_teapotModelVisual3D); // InstancedMeshGeometryVisual3D var boxMesh3D = new Ab3d.Meshes.BoxMesh3D(new Point3D(0, 0, 0), new Size3D(6, 6, 6), 1, 1, 1); InstanceData[] instancedData = DXEnginePerformance.InstancedMeshGeometry3DTest.CreateInstancesData(center: new Point3D(-50, 0, 50), size: new Size3D(80, 50, 80), modelScaleFactor: 1, xCount: 5, yCount: 1, zCount: 5, useTransparency: false); _instancedMeshGeometryVisual3D = new InstancedMeshGeometryVisual3D(boxMesh3D.Geometry); _instancedMeshGeometryVisual3D.InstancesData = instancedData; _instancedMeshGeometryVisual3D.SetName("InstancedMeshGeometryVisual3D"); _rootModelVisual3D.Children.Add(_instancedMeshGeometryVisual3D); // MeshObjectNode and SceneNodeVisual3D var meshGeometry3D = new Ab3d.Meshes.PyramidMesh3D(new Point3D(50, -20, 50), new Size3D(80, 40, 80)).Geometry; var dxMeshGeometry3D = new Ab3d.DirectX.Models.DXMeshGeometry3D(meshGeometry3D); var standardMaterial = new StandardMaterial() { DiffuseColor = Colors.Gold.ToColor3() }; _pyramidMeshObjectNode = new Ab3d.DirectX.MeshObjectNode(dxMeshGeometry3D, standardMaterial); _disposables.Add(dxMeshGeometry3D); _disposables.Add(_pyramidMeshObjectNode); var sceneNodeVisual3D = new SceneNodeVisual3D(_pyramidMeshObjectNode); sceneNodeVisual3D.SetName("SceneNodeVisual3D"); _rootModelVisual3D.Children.Add(sceneNodeVisual3D); }