private Model3DCollection Create_Sbox() { Model3DCollection col = new Model3DCollection(); double offsetX = 7, offsetY = 3, offsetZ = -7, scale = 1.9; for (int r = 0; r < 16; r++) { for (int a = 0; a < 4; a++) { gma3D_sbox[r, a] = eBuilder.CreateCube(0.5, new Point3D(offsetX + a / scale, offsetY - r / scale, offsetZ)); col.Add(gma3D_sbox[r, a]); } for (int b = 0; b < 4; b++) { gma3D_sbox[r, b + 4] = eBuilder.CreateCube(0.5, new Point3D(offsetX + (b + 5) / scale, offsetY - r / scale, offsetZ)); col.Add(gma3D_sbox[r, b + 4]); } GeometryModel3D ar = eBuilder.CreateArrowRight(0.3, 0.2, new Point3D(offsetX + 4.35 / scale, offsetY - r / scale, offsetZ), Colors.Blue, 0.6); col.Add(ar); } GeometryModel3D lblsbox = eBuilder.CreateLabel(4, 2, new Point3D(offsetX, offsetY + 2, offsetZ), Colors.Transparent, "S-Box", Colors.Black, 1); col.Add(lblsbox); return(col); }
/// <summary> /// Adds ambientlight and directionallight to the scene /// </summary> protected void AddDefaultLight() { var dir = new DirectionalLight(Color.FromRgb(255, 255, 255), new Vector3D(1, -5, 1)); var amb = new AmbientLight(Color.FromRgb(170, 170, 170)); _collection.Add(dir); _collection.Add(amb); }
// clears model without deleting light objects public void clearModel(Model3DCollection models) { Model3D light1 = models[0]; Model3D light2 = models[1]; models.Clear(); models.Add(light1); models.Add(light2); }
private Model3DCollection Create_State() { Model3DCollection col = new Model3DCollection(); for (int i = 63; i >= 0; i--) { gma3D_state[i] = eBuilder.CreateCube(0.8, GetCubePos(i)); gma3D_statetemp[i] = eBuilder.CreateCube(0.8, GetCubePos(i), null); col.Add(gma3D_statetemp[i]); col.Add(gma3D_state[i]); } return(col); }
private void btnOpenSandbox_Click(object sender, RoutedEventArgs e) { var ofd = new OpenFileDialog(); if ((bool)ofd.ShowDialog()) { var h3 = new Halo3(ofd.FileName); lblSandboxPath.Text = ofd.FileName; var container = new Model3DCollection(); foreach (var placedObject in h3.SandboxObjects.Where(placedObject => placedObject.TagIndex != -1)) { // Try to load Model if (placedObject.TagEntry.Tag.TagPath.Contains("spawning")) { } string gameAssetPath; try { gameAssetPath = VariousFunctions.GetGameAsset(Halo3.GameId, placedObject.TagEntry.Tag.TagPath); } catch (FileNotFoundException) { ActionLog.AddEntry("Missing Game Asset"); continue; } var model = (Model3D)ModelImporter.Load(gameAssetPath); model.Transform = CreateTransformGroup(placedObject); container.Add(model); } ModelViewport.Children.Clear(); ModelViewport.Children.Add(new GridLines()); foreach (var model in container) { ModelViewport.Children.Add(new ModelVisual3D { Content = model }); } var light = new LightVisual3D(); var ambientLight = new AmbientLight(Colors.WhiteSmoke) { Transform = new MatrixTransform3D(new Matrix3D { OffsetX = 0, OffsetY = 0, OffsetZ = 100 }) }; light.Content = ambientLight; ModelViewport.Children.Add(light); ModelViewport.ShowCameraInfo = true; ModelViewport.ZoomExtents(); ModelViewport.IsHeadLightEnabled = true; } }
private Model3DCollection Create_RoundCounter() { Model3DCollection col = new Model3DCollection(); Point3D pos; for (int i = 0; i < 5; i++) { pos = GetRingPos(i + 15); gma3D_roundcountertemp[i] = eBuilder.CreateCube(0.3, pos, null); col.Add(gma3D_roundcountertemp[i]); pos.Y += 1.2; gma3D_roundcounter[i] = eBuilder.CreateCube(0.3, pos); col.Add(gma3D_roundcounter[i]); } return(col); }
private Model3DCollection Create_Label() { Point3D pos; Material mat; GeometryModel3D num; Model3DCollection col = new Model3DCollection(); for (int i = 0; i < 80; i++) { pos = GetRingPos(i); pos.Y -= 0.3; mat = new DiffuseMaterial(new VisualBrush(new TextBlock() { Text = i.ToString(), Background = new SolidColorBrush(Colors.Transparent), Foreground = new SolidColorBrush(Colors.Black), Padding = new Thickness(1) }) { Stretch = Stretch.Uniform }); num = eBuilder.CreateCubeLabel(0.3, pos, mat); double a = Math.Atan2((parent.KS_Cam.Position.X - pos.X), (parent.KS_Cam.Position.Z - pos.Z)) / Math.PI * 180; RotateTransform3D rt = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), a), pos); num.Transform = rt; col.Add(num); } return(col); }
// http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Components-PostAttachments/00-04-01-86-12/SceneSortingHelper_2E00_cs /// <summary> /// Sort Modelgroups in Farthest to Closest order, to enable transparency /// Should be applied whenever the scene is significantly re-oriented /// </summary> public static void AlphaSort(Point3D cameraPosition, Model3DCollection models, Transform3D worldTransform) { var sortedList = models.OrderBy(model => Point3D.Subtract(cameraPosition, worldTransform.Transform(model.Bounds.Location)).Length); models.Clear(); foreach (var model in sortedList) { models.Add(model); } }
private static Model3DCollection MakeModelCollection(Variation v, string namePrefix) { // Meta-symbology: // { }* == Klene star, or 0 or more occurrances of the stuff inside the brackets // { }? == Optional, the stuff inside the brackets may or may not exist // < > == Description of what's parsed, the stuff inside the brackets is not a literal string // You can specify up to 10 children per model group (0-9) // namePrefix has format: "Child{n}*" Model3DCollection collection = new Model3DCollection(); for (int i = 0; i < 10; i++) { string modelName = namePrefix + i.ToString(); string modelValue = v[modelName]; if (modelValue == null) { break; } string materialName = modelName.Replace("Child", "Material"); string backMaterialName = modelName.Replace("Child", "BackMaterial"); string transformName = modelName.Replace("Child", "ModelTransform"); try { Model3D model = ModelFactory.MakeModel(modelValue); if (model is GeometryModel3D) { Material front = MakeMaterial(v, materialName); Material back = MakeMaterial(v, backMaterialName); if (front != null) { ((GeometryModel3D)model).Material = front; } ((GeometryModel3D)model).BackMaterial = back; } model.Transform = TransformFactory.MakeTransform(v[transformName]); if (model is Model3DGroup && v[modelName + "0"] != null) { ((Model3DGroup)model).Children = MakeModelCollection(v, modelName); } collection.Add(model); } catch (ArgumentException) { throw new ApplicationException("Confused by attribute (" + modelName + " = " + modelValue + ")"); } } return(collection); }
public Model3DCollection GetModel3D() { var Model = new Model3DCollection(); foreach (var seg in this) { Model.Add(new GeometryModel3D { Geometry = seg.Model, Material = Material }); } return(Model); }
private Model3DCollection Create_Ring() { Model3DCollection col = new Model3DCollection(); double size = 0.3; for (int i = 0; i < 80; i++) { gma3D_keyreg[i] = eBuilder.CreateCube(size, GetRingPos(i)); col.Add(gma3D_keyreg[i]); } return(col); }
public void Redraw(Model3DCollection geometry) { geometry.Clear(); for (var i = 0; i < 3; i++) { for (var j = 0; j < 3; j++) { for (var k = 0; k < 3; k++) { geometry.Add(_cubicles[i, j, k].GetGeometry(i, j, k)); } } } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var engines = value as IEnumerable<EngineViewModel>; if (engines == null) return null; var collection = new Model3DCollection(); foreach (var engine in engines) { collection.Add(ConvertOne(engine)); } return collection; }
object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { IList<TileViewModel> tileViewModels = value as IList<TileViewModel>; //Debug.Assert(tileMappingViewModel != null); if (tileViewModels == null) return new Model3DCollection(); Model3DCollection ModelCollection = new Model3DCollection(tileViewModels.Count<TileViewModel>()); foreach (TileViewModel t in tileViewModels) { ModelCollection.Add(t.Model); } return ModelCollection; }
public void AddElem(ViewportElementVM elem) { if (!_elementMap.ContainsKey(elem.RefElem)) { // Not already added _elementMap[elem.RefElem] = elem; foreach (var geom in elem.GeometryElements) { _geometryCollection.Add(geom); } } foreach (var child in elem.Children) { AddElem(child); } NotifyPropertyChanged(nameof(GeometryCollection)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is IEnumerable <Geometry3D> geometries) { Model3DCollection collection = new Model3DCollection(); foreach (Geometry3D mesh in geometries) { GeometryModel3D model = new GeometryModel3D(mesh, new DiffuseMaterial(Brushes.White)); collection.Add(model); } return(collection); } return(null); }
private Model3DCollection Create_RoundKeyCubes() { Model3DCollection col = new Model3DCollection(); for (int r = 31; r >= 0; r--) { mdc3D_roundkeys[r] = new Model3DCollection(); mdl3D_roundkey[r] = new Model3DGroup(); for (int i = 63; i >= 0; i--) { gma3D_roundkeys[r, i] = eBuilder.CreateCube(0.8, GetCubePos(i), null); mdc3D_roundkeys[r].Add(gma3D_roundkeys[r, i]); } mdl3D_roundkey[r].Children = mdc3D_roundkeys[r]; col.Add(mdl3D_roundkey[r]); } return(col); }
public GeometryModel3D draw(Model3DCollection container, Sphere sphere, int offsetX) { MeshGeometry3D mesh = new MeshGeometry3D(); for (int pi = 0; pi <= sphere.getAccurasy(); pi++) { for (int ti = 0; ti <= sphere.getAccurasy(); ti++) { mesh.Positions.Add(new Point3D(sphere.getPoints()[pi, ti].X + offsetX, sphere.getPoints()[pi, ti].Y, sphere.getPoints()[pi, ti].Z)); mesh.Normals.Add((Vector3D)sphere.getPoints()[pi, ti]); //mesh.TextureCoordinates.Add(new Point(theta / (2 * Math.PI), phi / (Math.PI))); } } for (int pi = 0; pi < sphere.getAccurasy(); pi++) { for (int ti = 0; ti < sphere.getAccurasy(); ti++) { int x0 = ti; int x1 = (ti + 1); int y0 = pi * (sphere.getAccurasy() + 1); int y1 = (pi + 1) * (sphere.getAccurasy() + 1); mesh.TriangleIndices.Add(x0 + y0); mesh.TriangleIndices.Add(x0 + y1); mesh.TriangleIndices.Add(x1 + y0); mesh.TriangleIndices.Add(x1 + y0); mesh.TriangleIndices.Add(x0 + y1); mesh.TriangleIndices.Add(x1 + y1); } } GeometryModel3D mGeometry = new GeometryModel3D(mesh, new DiffuseMaterial(new SolidColorBrush(sphere.getColor()))); mGeometry.Transform = new Transform3DGroup(); container.Add(mGeometry); return(mGeometry); }
private void UpdateScene() { var models = new Model3DCollection(); models.Add(this.ambientLight); if (this.bsp == null) { return; } var selModelSource = this.rdoTexture.IsChecked == true ? this.bsp.mipModels : this.bsp.lightModels; var currLeaf = GetCurrLeaf(); int leafIdx = 0; int visLeafNum = this.bsp.models[0].numleafs; if ((bool)this.chkNoVis.IsChecked || currLeaf == this.bsp.leafs[0]) { while (leafIdx < visLeafNum) { var leaf = this.bsp.leafs[leafIdx + 1]; for (int lFaceId = leaf.lface_id, cnt = 0; cnt < leaf.lface_num; lFaceId++, cnt++) { int surfaceId = this.bsp.lface[lFaceId]; models.Add(selModelSource[surfaceId]); } leafIdx++; } } else { int visOffset = currLeaf.visOffset; while (leafIdx < visLeafNum) { if (this.bsp.vislist[visOffset] == 0) { leafIdx += this.bsp.vislist[visOffset + 1] * 8; visOffset += 2; } else { for (int i = 0; i < 8; i++) { if ((this.bsp.vislist[visOffset] & (1 << i)) != 0) { var leaf = this.bsp.leafs[leafIdx + 1]; for (int lFaceId = leaf.lface_id, cnt = 0; cnt < leaf.lface_num; lFaceId++, cnt++) { int surfaceId = this.bsp.lface[lFaceId]; models.Add(selModelSource[surfaceId]); } } leafIdx++; } visOffset++; } } } // non pvs leaf (trigger, gate...) if ((bool)this.chkDrawEntity.IsChecked) { leafIdx = visLeafNum; int allLeafNum = this.bsp.leafs.Length; while (leafIdx < allLeafNum - 1) { var leaf = this.bsp.leafs[leafIdx + 1]; for (int lFaceId = leaf.lface_id, cnt = 0; cnt < leaf.lface_num; lFaceId++, cnt++) { int surfaceId = this.bsp.lface[lFaceId]; models.Add(selModelSource[surfaceId]); } leafIdx++; } } this.modelGroup.Children = new Model3DCollection(models.Distinct()); this.tbkFace.Text = $"face:{this.modelGroup.Children.Count}"; }
private void CreateSpawn(GroundSpawn 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); } } Point3D p = new Point3D( (spawn.MaxX + spawn.MinX) / 2, (spawn.MaxY + spawn.MinY) / 2, spawn.MaxZ); if (!Clipping.DrawPoint(p)) return; var xlen = spawn.MaxX - spawn.MinX; var ylen = spawn.MaxY - spawn.MinY; xlen = xlen <= 0 ? 4 : xlen; ylen = ylen <= 0 ? 4 : ylen; MeshBuilder builder = new MeshBuilder(); builder.AddBox(p, ylen, xlen, 2); GeometryModel3D box = new GeometryModel3D(builder.ToMesh(), Materials.Gold); collection.Add(box); if ( flags != DisplayFlags.None ) { var scale = 1.25; builder = new MeshBuilder(); if (flags.HasFlag(DisplayFlags.DarkGrayAura)) { builder.AddBox(p, ylen * scale, xlen * scale, 1); box = new GeometryModel3D(builder.ToMesh(), Materials.DarkGray); collection.Add(box); } else if (flags.HasFlag(DisplayFlags.GreenAura)) { builder.AddBox(p, ylen * scale, xlen * scale, 1); box = new GeometryModel3D(builder.ToMesh(), Materials.Green); collection.Add(box); } } _mapping[spawn] = collection; foreach (Model3D model in collection) { group.Children.Add(model); } }
private void CreateArea(LineOfSightArea area) { Model3DGroup group = Model as Model3DGroup; Model3DCollection collection = new Model3DCollection(); try { if (_mapping[area] != null) { foreach (Model3D model in _mapping[area]) { group.Children.Remove(model); } } } catch (KeyNotFoundException) { //nothing needs to be done } foreach (var vertex in area.Vertices) { MeshBuilder builder = new MeshBuilder(); Point3D p1 = new Point3D(vertex.X, vertex.Y, area.MaxZ); Point3D p2 = new Point3D(vertex.X, vertex.Y, area.MinZ); //if (Clipping != null && !Clipping.DrawPoint(p)) continue; builder.AddBox(p1, 4, 4, 4); builder.AddBox(p2, 4, 4, 4); builder.AddPipe(p1, p2, 1.5, 1.5, 50); GeometryModel3D box = new GeometryModel3D(builder.ToMesh(), Materials.Yellow); collection.Add(box); builder = new MeshBuilder(); Point3D next; if (vertex == area.Vertices.Last()) { next = area.Vertices[0]; } else { next = area.Vertices.ElementAt(area.Vertices.IndexOf(vertex) + 1); } Point3D n1 = new Point3D(next.X, next.Y, area.MaxZ); Point3D n2 = new Point3D(next.X, next.Y, area.MinZ); //builder.AddPipe(p1, p2); builder.AddPipe(p1, n1, 0.5, 0.5, 50); builder.AddPipe(p2, n2, 0.5, 0.5, 50); collection.Add(new GeometryModel3D(builder.ToMesh(), Materials.Yellow)); } _mapping[area] = collection; foreach (Model3D model in collection) { group.Children.Add(model); } }
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); } }
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); } }
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]); }
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); } }
private void CreateArea(RoamArea area) { Model3DGroup group = Model as Model3DGroup; Model3DCollection collection = new Model3DCollection(); if (_mapping.ContainsKey(area)) { foreach (Model3D model in _mapping[area]) { group.Children.Remove(model); } } foreach (var vertex in area.Vertices) { MeshBuilder builder = new MeshBuilder(); Point3D p1 = new Point3D(vertex.X, vertex.Y, area.MaxZ); Point3D p2 = new Point3D(vertex.X, vertex.Y, area.MinZ); //if (Clipping != null && !Clipping.DrawPoint(p)) continue; builder.AddBox(p1, 4, 4, 4); builder.AddBox(p2, 4, 4, 4); builder.AddPipe(p1, p2, 1.5, 1.5, 50); GeometryModel3D box = new GeometryModel3D(builder.ToMesh(), Materials.Yellow); collection.Add(box); builder = new MeshBuilder(); Point3D next = new Point3D(); if (vertex == area.Vertices.Last()) { next.X = area.Vertices[0].X; next.Y = area.Vertices[0].Y; } else { next.X = area.Vertices.ElementAt(area.Vertices.IndexOf(vertex) + 1).X; next.Y = area.Vertices.ElementAt(area.Vertices.IndexOf(vertex) + 1).Y; } Point3D n1 = new Point3D(next.X, next.Y, area.MaxZ); Point3D n2 = new Point3D(next.X, next.Y, area.MinZ); //builder.AddPipe(p1, p2); builder.AddPipe(p1, n1, 0.5, 0.5, 50); builder.AddPipe(p2, n2, 0.5, 0.5, 50); collection.Add(new GeometryModel3D(builder.ToMesh(), Materials.Yellow)); } _mapping[area] = collection; foreach (Model3D model in collection) { group.Children.Add(model); } }