コード例 #1
2
        public override void Calculate()
        {
            if (InputPorts[0].Data == null) return;

            if (InputPorts[0].Data is string)
            {
                var extension = Path.GetExtension(InputPorts[0].Data as string);

                var flag = false;

                switch (extension)
                {
                    case ".obj":
                        var currentHelixObjReader = new ObjReader();
                        try
                        {
                            var objModel = currentHelixObjReader.Read((string) InputPorts[0].Data);
                            var modelGroup = new GroupModel3D();
                            var modelGeometry = new Element3DCollection();
                            modelGeometry.AddRange(
                                objModel.Select(
                                    x =>
                                        new MeshGeometryModel3D
                                        {
                                            Geometry = x.Geometry as MeshGeometry3D,
                                            Material = x.Material
                                        }));

                            modelGroup.Children = modelGeometry;

                            Dispatcher.BeginInvoke((Action) delegate { _control.ViewPort3D.Items.Add(modelGroup); });
                        }
                        catch (Exception)
                        {
                            // ignore
                        }
                        break;
                    case ".stl":
                        var currentHelixStlReader = new StLReader();
                        try
                        {
                            var myModel = currentHelixStlReader.Read((string) InputPorts[0].Data);
                            // _control.ViewPort3D.Items.Add(myModel);
                        }
                        catch (Exception)
                        {
                            // ignore
                        }
                        break;
                }
            }
        }
コード例 #2
0
ファイル: ViewController.cs プロジェクト: stefkeB/IfcEngineCS
 public void InitGraphics(Viewport3DX viewport, Element3DCollection model, TreeView _treeview)
 {
     this.model   = model;
     hVp3D        = viewport;
     _treeControl = _treeview;
     BindMouseHandler();
 }
コード例 #3
0
ファイル: ViewModel.cs プロジェクト: cokemal/IfcEngineCS
 public ViewModel(Viewport3DX viewport,TreeView _treeview)
 {
     Viewport3D = viewport;
     viewController = new ViewController();
     Model = new Element3DCollection();
     viewController.InitGraphics(Viewport3D, Model,_treeview);
 }
コード例 #4
0
ファイル: ViewModel.cs プロジェクト: cokemal/IfcEngineCS
 public ViewModel(Viewport3DX viewport, TreeView _treeview)
 {
     Viewport3D     = viewport;
     viewController = new ViewController();
     Model          = new Element3DCollection();
     viewController.InitGraphics(Viewport3D, Model, _treeview);
 }
コード例 #5
0
ファイル: ViewModel.cs プロジェクト: stefkeB/IfcEngineCS
        public MainViewModel(Viewport3DX viewport, TreeView treeview)
        {
            // ----------------------------------------------
            // titles
            this.Title    = "Ifc Viewer";
            this.SubTitle = "By LinJiarui";

            // ----------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera {
                Position = new Point3D(8, 9, 7), LookDirection = new Vector3D(-5, -12, -5), UpDirection = new Vector3D(0, 0, 1)
            };

            // ----------------------------------------------
            // setup scene
            this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);

            this.RenderLight1 = true;
            this.RenderLight2 = false;
            this.RenderLight3 = false;
            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,
            };


            viewController = new ViewController();
            Model          = new Element3DCollection();
            viewController.InitGraphics(viewport, Model, treeview);
        }
コード例 #6
0
        public override void Calculate()
        {
            if (InputPorts[0].Data == null)
            {
                return;
            }

            if (InputPorts[0].Data is string)
            {
                var extension = Path.GetExtension(InputPorts[0].Data as string);

                var flag = false;

                switch (extension)
                {
                case ".obj":
                    var currentHelixObjReader = new ObjReader();
                    try
                    {
                        var objModel      = currentHelixObjReader.Read((string)InputPorts[0].Data);
                        var modelGroup    = new GroupModel3D();
                        var modelGeometry = new Element3DCollection();
                        modelGeometry.AddRange(
                            objModel.Select(
                                x =>
                                new MeshGeometryModel3D
                        {
                            Geometry = x.Geometry as MeshGeometry3D,
                            Material = x.Material
                        }));

                        modelGroup.Children = modelGeometry;

                        Dispatcher.BeginInvoke((Action) delegate { _control.ViewPort3D.Items.Add(modelGroup); });
                    }
                    catch (Exception)
                    {
                        // ignore
                    }
                    break;

                case ".stl":
                    var currentHelixStlReader = new StLReader();
                    try
                    {
                        var myModel = currentHelixStlReader.Read((string)InputPorts[0].Data);
                        // _control.ViewPort3D.Items.Add(myModel);
                    }
                    catch (Exception)
                    {
                        // ignore
                    }
                    break;
                }
            }
        }
コード例 #7
0
        private void AttachParts()
        {
            Element3DCollection e3Collection = new Element3DCollection();

            foreach (Part part in parts)
            {
                part.mgmList = new List <MeshGeometryModel3D>();
                foreach (var ob in part.objList)
                {
                    var s = new MeshGeometryModel3D
                    {
                        Geometry = ob.Geometry,
                        Material = ob.Material,
                    };
                    part.mgmList.Add(s);
                    e3Collection.Add(s);
                    s.Attach(this.viewport.RenderHost);
                }
            }
            this.ModelGeometry = e3Collection;
            this.OnPropertyChanged("ModelGeometry");
        }
コード例 #8
0
 public void InitGraphics(Viewport3DX viewport,Element3DCollection model,TreeView _treeview)
 {
     this.model = model;
     hVp3D = viewport;
     _treeControl = _treeview;
     BindMouseHandler();
 }
コード例 #9
0
 public GroupElement3D()
 {
     this.Children = new Element3DCollection();
 }
コード例 #10
0
ファイル: ViewModel.cs プロジェクト: LinJiarui/IfcEngineCS
        public MainViewModel(Viewport3DX viewport, TreeView treeview)
        {
            // ----------------------------------------------
            // titles
            this.Title = "Ifc Viewer";
            this.SubTitle = "By LinJiarui";

            // ----------------------------------------------
            // camera setup
            this.Camera = new PerspectiveCamera { Position = new Point3D(8, 9, 7), LookDirection = new Vector3D(-5, -12, -5), UpDirection = new Vector3D(0, 0, 1) };

            // ----------------------------------------------
            // setup scene
            this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);

            this.RenderLight1 = true;
            this.RenderLight2 = false;
            this.RenderLight3 = false;
            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,
            };

            viewController = new ViewController();
            Model = new Element3DCollection();
            viewController.InitGraphics(viewport, Model, treeview);
        }
コード例 #11
0
ファイル: BaseIFCFileReader.cs プロジェクト: alir14/3DModel
 public BaseIFCFileReader(string path)
 {
     this.Path      = path;
     model          = new Element3DCollection();
     meshToIfcItems = new Dictionary <MeshGeometryModel3D, IFCItem>();
 }
コード例 #12
0
 public GroupElement3D()
 {
     this.Children = new Element3DCollection();
 }