当前位置: 首页>>代码示例>>C#>>正文


C# MeshBuilder.AddArrow方法代码示例

本文整理汇总了C#中MeshBuilder.AddArrow方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddArrow方法的具体用法?C# MeshBuilder.AddArrow怎么用?C# MeshBuilder.AddArrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MeshBuilder的用法示例。


在下文中一共展示了MeshBuilder.AddArrow方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePoint

        private void CreatePoint(ZonePoint zp,DisplayFlags flags)
        {
            Model3DGroup group = Model as Model3DGroup;
            Model3DCollection collection = new Model3DCollection();

            if (_mapping.ContainsKey(zp))
            {
                foreach (Model3D model in _mapping[zp])
                {
                    group.Children.Remove(model);
                }
            }

            double px, py, pz;
            px = zp.X == 999999 ? 0 : zp.X;
            py = zp.Y == 999999 ? 0 : zp.Y;
            pz = zp.Z == 999999 ? 0 : zp.Z;

            Point3D p = new Point3D(px,py,pz);

            if (!Clipping.DrawPoint(p)) return;

            MeshBuilder builder = new MeshBuilder();
            builder.AddBox(p, 20, 20, 2);

            //connect box to destination
            px = zp.TargetX == 999999 ? px : zp.TargetX;
            py = zp.TargetY == 999999 ? py : zp.TargetY;
            pz = zp.TargetZ == 999999 ? pz : zp.TargetZ;

            GeometryModel3D box;
            box = new GeometryModel3D(builder.ToMesh(), Materials.Red);
            collection.Add(box);

            builder = new MeshBuilder();
            Point3D destP = new Point3D(px, py, pz);
            builder.AddArrow(p, destP, 0.5);
            builder.AddBox(destP, 20, 20, 2);

            if (zp.X == 999999 || zp.Y == 999999 || zp.Z == 999999 ||
                zp.TargetX == 999999 || zp.TargetY == 999999 || zp.TargetZ == 999999)
            {
                box = new GeometryModel3D(builder.ToMesh(), Materials.Gold);
            }
            else
            {
                box = new GeometryModel3D(builder.ToMesh(), Materials.White);
            }

            collection.Add(box);

            if (flags != DisplayFlags.None)
            {
                builder = new MeshBuilder();

                if (flags.HasFlag(DisplayFlags.DarkGrayAura))
                {
                    builder.AddBox(p, 25,25, 1);
                    builder.AddBox(destP, 25, 25, 1);
                    box = new GeometryModel3D(builder.ToMesh(), Materials.DarkGray);
                    collection.Add(box);
                }
                else if (flags.HasFlag(DisplayFlags.GreenAura))
                {
                    builder.AddBox(p, 25, 25, 1);
                    builder.AddBox(destP, 25, 25, 1);
                    box = new GeometryModel3D(builder.ToMesh(), Materials.Green);
                    collection.Add(box);
                }
            }

            _mapping[zp] = collection;

            foreach (Model3D model in collection)
            {
                group.Children.Add(model);
            }
        }
开发者ID:Unchated,项目名称:pogee-3d-editor,代码行数:78,代码来源:ZonePointsDisplay3D.cs

示例2: UpdateGeometry

 /// <summary>
 /// Updates the geometry.
 /// </summary>
 protected override void UpdateGeometry()
 {
     var mb = new MeshBuilder(false, false);
     var p0 = new Point3D(0, 0, 0);
     var d = this.Direction;
     d.Normalize();
     var p1 = p0 + (d * this.Length);
     mb.AddArrow(p0, p1, this.Diameter);
     this.Model.Geometry = mb.ToMesh();
 }
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:13,代码来源:TranslateManipulator.cs

示例3: CreateSpawn

        private void CreateSpawn(EQEmu.Spawns.Spawn2 spawn,DisplayFlags flags)
        {
            Model3DGroup group = Model as Model3DGroup;

            Model3DCollection collection = new Model3DCollection();

            if (_mapping.ContainsKey(spawn))
            {
                foreach (Model3D model in _mapping[spawn])
                {
                    group.Children.Remove(model);
                }
            }

            MeshBuilder builder = new MeshBuilder();
            Point3D p = new Point3D(spawn.X,spawn.Y,spawn.Z);

            if( !Clipping.DrawPoint(p) ) return;

            builder.AddBox(p,2,2,2);

            Transform3D headingRotate = new RotateTransform3D()
            {
                CenterX = p.X,
                CenterY = p.Y,
                CenterZ = p.Z,
                Rotation = new AxisAngleRotation3D(
                    new Vector3D(0,0,-1),spawn.HeadingDegrees)
            };

            GeometryModel3D box;
            Material mat = Materials.White;

            if (flags == DisplayFlags.None)
            {
                if (spawn.RoamAreaId > 0)
                {
                    mat = Materials.Red;
                }
                else if (spawn.GridId > 0)
                {
                    mat = Materials.Yellow;
                }
            }
            else if (flags == DisplayFlags.Green)
            {
                mat = Materials.Green;
            }
            else if (flags == DisplayFlags.DarkGray)
            {
                mat = Materials.DarkGray;
            }
            else if (flags == DisplayFlags.Rainbow)
            {
                mat = Materials.Rainbow;
            }
            else if (flags == DisplayFlags.Blue)
            {
                mat = Materials.Blue;
            }

            box = new GeometryModel3D(builder.ToMesh(), mat);
            box.Transform = headingRotate;
            collection.Add(box);

            builder = new MeshBuilder();
            float radius = 3.0f;
            double hx = spawn.X + Math.Cos((spawn.HeadingDegrees - 90) / 180 * Math.PI) * radius;
            double hy = spawn.Y + Math.Sin((spawn.HeadingDegrees + 90) / 180 * Math.PI) * radius;

            builder.AddArrow(new Point3D(spawn.X, spawn.Y, spawn.Z), new Point3D(hx, hy, spawn.Z), 0.5, 1);
            collection.Add(new GeometryModel3D(builder.ToMesh(), mat));

            _mapping[spawn] = collection;
            foreach (Model3D model in collection)
            {
                group.Children.Add(model);
            }
        }
开发者ID:Unchated,项目名称:pogee-3d-editor,代码行数:79,代码来源:Spawn2Display3D.cs

示例4: UpdateVisuals

        /// <summary>
        /// Updates the visuals.
        /// </summary>
        protected void UpdateVisuals()
        {
            this.vertexVisuals = new Dictionary<HalfEdgeMesh.Vertex, ModelUIElement3D>();
            this.halfEdgeVisuals = new Dictionary<HalfEdgeMesh.HalfEdge, ModelUIElement3D>();
            this.faceVisuals = new Dictionary<HalfEdgeMesh.Face, ModelUIElement3D>();
            this.Children.Clear();
            if (this.Mesh == null)
            {
                return;
            }

            if (this.VertexRadius > 0)
            {
                // Add the vertices
                foreach (var vertex in this.Mesh.Vertices)
                {
                    var gm = new MeshBuilder(false, false);
                    gm.AddSubdivisionSphere(vertex.Position, this.VertexRadius, 4);
                    var vertexElement = new ModelUIElement3D
                        {
                           Model = new GeometryModel3D(gm.ToMesh(), this.VertexMaterial)
                        };
                    var currentVertex = vertex;
                    vertexElement.MouseLeftButtonDown += (s, e) => this.HighlightVertex(currentVertex);
                    this.vertexVisuals.Add(vertex, vertexElement);
                    this.Add(vertexElement);
                }
            }

            var faceCenter = new Dictionary<HalfEdgeMesh.Face, Point3D>();

            foreach (var face in this.Mesh.Faces)
            {
                var faceVertices = face.Vertices.Select(v => v.Position).ToList();

                // Find the face centroid
                var center = this.FindCentroid(faceVertices);
                faceCenter.Add(face, center);

                if (this.ShrinkFactor < 1)
                {
                    // Add the faces
                    for (int i = 0; i < faceVertices.Count; i++)
                    {
                        faceVertices[i] += (center - faceVertices[i]) * this.ShrinkFactor;
                    }

                    var gm = new MeshBuilder(false, false);
                    gm.AddTriangleFan(faceVertices);
                    var faceElement = new ModelUIElement3D
                        {
                            Model =
                                new GeometryModel3D(gm.ToMesh(), this.FaceMaterial)
                                    {
                                       BackMaterial = this.FaceBackMaterial
                                    }
                        };
                    var currentFace = face;
                    faceElement.MouseLeftButtonDown += (s, e) => this.HighlightFace(currentFace);
                    this.faceVisuals.Add(face, faceElement);
                    this.Add(faceElement);
                }
            }

            if (this.EdgeDiameter > 0)
            {
                // Add the edges
                foreach (var edge in this.Mesh.Edges)
                {
                    var start = edge.StartVertex.Position;
                    var end = edge.EndVertex.Position;
                    var center = faceCenter[edge.Face];
                    start = start + (center - start) * this.ShrinkFactor;
                    end = end + (center - end) * this.ShrinkFactor;
                    var gm = new MeshBuilder(false, false);
                    gm.AddArrow(start, end, this.EdgeDiameter);
                    var edgeElement = new ModelUIElement3D
                        {
                           Model = new GeometryModel3D(gm.ToMesh(), this.EdgeMaterial)
                        };
                    var currentEdge = edge;
                    edgeElement.MouseLeftButtonDown += (s, e) => { this.HighlightEdge(currentEdge); };
                    this.halfEdgeVisuals.Add(edge, edgeElement);
                    this.Add(edgeElement);
                }
            }
        }
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:90,代码来源:HalfEdgeMeshVisual3D.cs

示例5: CreateNode

        private void CreateNode(EQEmu.Path.Node node)
        {
            Model3DGroup group = Model as Model3DGroup;
            MeshBuilder builder;

            Model3DCollection collection = new Model3DCollection();

            if (_mapping[node] != null)
            {
                foreach (Model3D model in _mapping[node])
                {
                    group.Children.Remove(model);
                }
            }

            if (Clipping != null && !Clipping.DrawPoint(node.Location)) return;

            //builder.AddBox(node.Location, 2, 2, 2);

            _mapping[node] = collection;

            GeometryModel3D box = GetNodeModel();
            box.Transform = new TranslateTransform3D(node.X,node.Y,node.Z);
            collection.Add(box);
            //collection.Add(new GeometryModel3D(builder.ToMesh(), Materials.Green));
            //_mapping[node] = new GeometryModel3D(builder.ToMesh(), Materials.Green);

            if (Options.ShowTextLabels)
            {
                GeometryModel3D text = TextCreator.CreateTextLabelModel3D(node.Id.ToString(), BrushHelper.CreateGrayBrush(5), true, 2,
                                                                            new Point3D(node.X, node.Y, node.Z + 5), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
                text.Transform = new ScaleTransform3D(new Vector3D(-1, 1, 1), new Point3D(node.X, node.Y, node.Z));
                collection.Add(text);
            }

            foreach (EQEmu.Path.Neighbor neighbor in node.Neighbors)
            {
                if (neighbor.Node == null) continue;

                builder = new MeshBuilder();
                builder.AddArrow(new Point3D(node.X, node.Y, node.Z), new Point3D(neighbor.Node.X, neighbor.Node.Y, neighbor.Node.Z), 0.5);
                //builder.AddPipe(new Point3D(n.X, n.Y, n.Z), new Point3D(neighbor.Node.X, neighbor.Node.Y, neighbor.Node.Z), 0.5, 0.5, 50);
                collection.Add(new GeometryModel3D(builder.ToMesh(), Materials.Yellow));
            }

            foreach (Model3D model in collection)
            {
                group.Children.Add(model);
            }

            //group.Children.Add(_mapping[node]);
        }
开发者ID:Unchated,项目名称:pogee-3d-editor,代码行数:52,代码来源:PathDisplay3D.cs

示例6: OnMeshChanged

        /// <summary>
        /// Updates the visuals.
        /// </summary>
        protected virtual void OnMeshChanged()
        {
            this.Children.Clear();

            var builder = new MeshBuilder();
            for (int i = 0; i < this.Mesh.Positions.Count; i++)
            {
                builder.AddArrow(
                    this.Mesh.Positions[i], this.Mesh.Positions[i] + this.Mesh.Normals[i], this.Diameter, 3, 10);
            }

            this.Content = new GeometryModel3D
                {
                   Geometry = builder.ToMesh(true), Material = MaterialHelper.CreateMaterial(this.Color)
                };
        }
开发者ID:chantsunman,项目名称:helix-toolkit,代码行数:19,代码来源:MeshNormalsVisual3D.cs

示例7: CreateGrid

        private void CreateGrid(Grid grid)
        {
            Model3DGroup group = Model as Model3DGroup;

            Model3DCollection collection = new Model3DCollection();

            if (_mapping.ContainsKey(grid))
            {
                foreach (Model3D model in _mapping[grid])
                {
                    group.Children.Remove(model);
                }
            }

            foreach (Waypoint wp in grid.Waypoints)
            {
                MeshBuilder builder = new MeshBuilder();
                Point3D p = new Point3D(wp.X,wp.Y,wp.Z);

                if (Clipping != null && !Clipping.DrawPoint(p)) continue;
                builder.AddBox(p, 2, 2, 2);

                Transform3D headingRotate = new RotateTransform3D()
                {
                    CenterX = wp.X,
                    CenterY = wp.Y,
                    CenterZ = wp.Z,
                    Rotation = new AxisAngleRotation3D(
                        new Vector3D(0, 0, -1), wp.HeadingDegrees)
                };

                GeometryModel3D box;
                Material mat;

                if (wp.PauseTime > 0)
                {
                    mat = Materials.Red;
                }
                else
                {
                    mat = Materials.DarkGray;
                }

                box = new GeometryModel3D(builder.ToMesh(),mat);
                box.Transform = headingRotate;
                collection.Add(box);

                builder = new MeshBuilder();
                float radius = 3.0f;
                double hx = wp.X + Math.Cos( (wp.HeadingDegrees-90) / 180 * Math.PI ) * radius;
                double hy = wp.Y + Math.Sin( (wp.HeadingDegrees + 90) / 180 * Math.PI ) * radius;

                builder.AddArrow(new Point3D(wp.X, wp.Y, wp.Z),new Point3D(hx, hy, wp.Z), 0.5,1);
                collection.Add(new GeometryModel3D(builder.ToMesh(), mat));

                //box = new GeometryModel3D(builder.ToMesh(), mat);
                //collection.Add(box);

                if(wp.Name != null && !String.IsNullOrWhiteSpace(wp.Name) )
                {
                    GeometryModel3D text = TextCreator.CreateTextLabelModel3D(wp.Name, BrushHelper.CreateGrayBrush(50), true, 2, new Point3D(p.X, p.Y, p.Z + 5), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
                    text.Transform = new ScaleTransform3D(new Vector3D(-1, 1, 1), new Point3D(p.X, p.Y, p.Z));
                    collection.Add(text);
                }

                //GeometryModel3D text = TextCreator.CreateTextLabelModel3D(wp.GridId.ToString() + "G:" + wp.Number.ToString() + "N:" + wp.PauseTime.ToString() + "P", BrushHelper.CreateGrayBrush(5), true, 2,
                  //                                                          new Point3D(p.X, p.Y, p.Z + 5), new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
                //text.Transform = new ScaleTransform3D(new Vector3D(-1, 1, 1), new Point3D(p.X, p.Y, p.Z));
                //collection.Add(text);

                builder = new MeshBuilder();

                if (grid.WanderType == Grid.WanderTypes.Patrol || grid.WanderType == Grid.WanderTypes.Circular)
                {
                    IEnumerable<Waypoint> nextWaypointQuery = grid.Waypoints.Where(
                        x => x.Number > wp.Number).OrderBy(y => y.Number);
                    if (nextWaypointQuery.Count() > 0)
                    {
                        Waypoint nextWaypoint = nextWaypointQuery.ElementAt(0);
                        builder.AddArrow(p, new Point3D(nextWaypoint.X, nextWaypoint.Y, nextWaypoint.Z), 0.5);

                        collection.Add(
                            new GeometryModel3D(builder.ToMesh(), Materials.White));
                    }
                }

                //collection.Add( new GeometryModel3D(builder.ToMesh(), Materials.
            }

            //collection.Add(new GeometryModel3D(builder.ToMesh(), Materials.White));

            _mapping[grid] = collection;
            foreach (Model3D model in collection)
            {
                group.Children.Add(model);
            }
        }
开发者ID:Unchated,项目名称:pogee-3d-editor,代码行数:97,代码来源:GridsDisplay3D.cs

示例8: UpdateAll

        public void UpdateAll()
        {
            Model3DGroup group = Model as Model3DGroup;
            Material mat = Materials.Red;

            BuildDoors();

            group.Children.Clear();

            if (_doorObjects != null)
            {
                foreach (var dr in _doorObjects)
                {
                    var builder = new MeshBuilder();
                    var transforms = dr.GetTransforms();
                    if (dr.Polygons.ElementAt(0).BitmapInfo != null)
                    {
                        var img = dr.Polygons.ElementAt(0).BitmapInfo.Image;
                        var brush = new System.Windows.Media.ImageBrush(img);
                        brush.ViewportUnits = System.Windows.Media.BrushMappingMode.Absolute;
                        brush.TileMode = System.Windows.Media.TileMode.Tile;
                        mat = HelixToolkit.Wpf.MaterialHelper.CreateMaterial(brush);
                    }
                    else
                    {
                        mat = Materials.LightGray;
                    }

                    foreach (var poly in dr.Polygons)
                    {
                        Point3D p1 = new Point3D(poly.V1.X, poly.V1.Y, poly.V1.Z);
                        Point3D p2 = new Point3D(poly.V2.X, poly.V2.Y, poly.V2.Z);
                        Point3D p3 = new Point3D(poly.V3.X, poly.V3.Y, poly.V3.Z);

                        foreach (var transform in transforms)
                        {
                            p1 = transform.Transform(p1);
                            p2 = transform.Transform(p2);
                            p3 = transform.Transform(p3);
                        }

                        if (!Clipping.DrawPoint(p1) || !Clipping.DrawPoint(p2) || !Clipping.DrawPoint(p3))
                        {
                            continue;
                        }

                        var t1 = new System.Windows.Point(poly.V1.U, 1 - poly.V1.V);
                        var t2 = new System.Windows.Point(poly.V2.U, 1 - poly.V2.V);
                        var t3 = new System.Windows.Point(poly.V3.U, 1 - poly.V3.V);
                        //builder.AddTriangle(p3, p2, p1, t3, t2, t1);
                        builder.AddTriangle(p1, p2, p3, t1, t2, t3);
                    }
                    group.Children.Add(new GeometryModel3D(builder.ToMesh(), mat));
                }
            }

            var rotate = new RotateTransform3D();
            rotate.Rotation = new AxisAngleRotation3D(new Vector3D(0, 0, 1), 90);
            foreach (var door in _manager.Doors)
            {
                var bbuilder = new MeshBuilder();
                Material mater = Materials.Red;

                if (_selected != null && _selected.Contains(door))
                {
                    mater = Materials.Blue;
                }

                var pcenter = new Point3D(door.X, door.Y, door.Z);
                rotate.CenterX = pcenter.X;
                rotate.CenterY = pcenter.Y;

                float radius = 3.0f;
                double hx = pcenter.X + Math.Cos((door.HeadingDegrees - 90) / 180 * Math.PI) * radius;
                double hy = pcenter.Y + Math.Sin((door.HeadingDegrees + 90) / 180 * Math.PI) * radius;

                var p = rotate.Transform(new Point3D(hx, hy, door.Z));

                //bbuilder.AddArrow(pcenter, new Point3D(hx, hy, door.Z), 0.5, 1);
                bbuilder.AddArrow(pcenter,p, 0.5, 1);
                bbuilder.AddBox(pcenter, 0.5, 0.5, 20);

                group.Children.Add(new GeometryModel3D(bbuilder.ToMesh(), mater));
            }
        }
开发者ID:Unchated,项目名称:pogee-3d-editor,代码行数:85,代码来源:DoorsDisplay3D.cs


注:本文中的MeshBuilder.AddArrow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。