public void CreateDefaultVertexArrayForTriangle()
        {
            var reader = new ObjReader();
            var objects = reader.Read(@"Models\obj\Triangle.obj");

            Assert.AreEqual(1, objects.Count);

            var geometry = objects[0].Geometry;
            var model = new MeshGeometryModel3D { Geometry = geometry };

            var canvas = new CanvasMock();
            model.Attach(canvas);

            Assert.AreEqual(true, model.IsAttached);
        }
示例#2
0
        private MeshGeometryModel3D CreateBall(HelixToolkit.Wpf.SharpDX.Material mat)
        {
            MeshGeometryModel3D mgm = new MeshGeometryModel3D();
            MeshBuilder         mb  = new MeshBuilder();

            //mb.AddSphere(MapReader.P2V(p), 2);
            mb.AddSphere(Vector3.Zero, 0.5);
            //mb.AddArrow(Vector3.Zero, new Vector3(0, 0, 2), 0.1);

            mgm.Geometry = mb.ToMeshGeometry3D();
            mgm.Material = mat;
            mViewModel.PlayersGeometry.Add(mgm);

            mgm.Attach(mViewModel.modelView.RenderHost);
            return(mgm);
        }
示例#3
0
 public void AttachModelList(List <Object3D> objs)
 {
     this.ModelTransform = new TranslateTransform3D(0, 0, 0);
     this.ModelGeometry  = new Element3DCollection();
     foreach (var ob in objs)
     {
         var s = new MeshGeometryModel3D
         {
             Geometry = ob.Geometry,
             Material = ob.Material,
         };
         this.ModelGeometry.Add(s);
         s.Attach(modelView.RenderHost);
     }
     this.OnPropertyChanged("ModelGeometry");
 }
示例#4
0
        public void CreateDefaultVertexArrayForTriangle()
        {
            var reader  = new ObjReader();
            var objects = reader.Read(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Models\obj\Triangle.obj"));

            Assert.AreEqual(1, objects.Count);

            var geometry = objects[0].Geometry;
            var model    = new MeshGeometryModel3D {
                Geometry = geometry
            };

            var canvas = new CanvasMock();

            model.Attach(canvas);

            Assert.AreEqual(true, model.IsAttached);
        }
示例#5
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");
        }
示例#6
0
        public void LoadMap(string bytesFileName)
        {
            bool succ = false;

            if (dh.MapLoaded)
            {
                dh.Unload();
            }
            succ = dh.Load(bytesFileName);
            if (succ)
            {
                DHTriangle[] triangles = dh.GetTriangles();
                DHVertex[]   verts     = dh.GetVertexes();
                var          lb        = new LineBuilder();
                groundGroup.Children.Clear();
                mViewModel.ModelTransform = new TranslateTransform3D();
                for (int i = 0; i < triangles.Length; i++)
                {
                    var node = triangles[i];

                    lb.AddLine(MapReader.U2V(node.vertices0), MapReader.U2V(node.vertices1));
                    lb.AddLine(MapReader.U2V(node.vertices1), MapReader.U2V(node.vertices2));
                    lb.AddLine(MapReader.U2V(node.vertices2), MapReader.U2V(node.vertices0));

                    MeshGeometryModel3D mgm = MapReader.MakeMeshGeometryModel3DUnity(node, mViewModel.Material);

                    groundGroup.Children.Add(mgm);
                    mgm.Attach(mViewModel.modelView.RenderHost);
                }
                mViewModel.LineGeometry          = lb.ToLineGeometry3D();
                lineTriangulatedPolygon.Geometry = mViewModel.LineGeometry;
            }

            //icon = AddOrUpdatePlayerPosition("player", 0, 0, 0, 0.5f, 0, 0, 0);
            //icon.LastUpdateTime = DateTime.Now.AddSeconds(1);
            //Ray r = new Ray(mViewModel.Camera.Position,);
        }