/// <summary> /// Adds the a voxel adjacent to the specified model. /// </summary> /// <param name="source">The source.</param> /// <param name="normal">The normal.</param> public void Add(Model3D source, Vector3D normal) { if (!ModelToVoxel.ContainsKey(source)) { return; } var v = ModelToVoxel[source]; AddVoxel(v.Position + normal); }
public void Remove(Model3D model) { if (!ModelToVoxel.ContainsKey(model)) { return; } var v = ModelToVoxel[model]; Voxels.Remove(v); UpdateModel(); }
public void UpdateModel() { Model.Children.Clear(); ModelToVoxel.Clear(); OriginalMaterial.Clear(); foreach (var v in Voxels) { var m = CreateVoxelModel3D(v); OriginalMaterial.Add(m, m.Material); Model.Children.Add(m); ModelToVoxel.Add(m, v); } RaisePropertyChanged("Model"); }
/// <summary> /// Highlights the specified voxel model. /// </summary> /// <param name="model">The model.</param> public void HighlightVoxel(Model3D model) { foreach (GeometryModel3D m in Model.Children) { if (!ModelToVoxel.ContainsKey(m)) { continue; } var v = ModelToVoxel[m]; var om = OriginalMaterial[m]; // highlight color var hc = Color.FromArgb(0x80, v.Colour.R, v.Colour.G, v.Colour.B); m.Material = m == model?MaterialHelper.CreateMaterial(hc) : om; } }
/// <summary> /// Shows a preview voxel adjacent to the specified model (source). /// If source is null, hide the preview. /// </summary> /// <param name="source">The source.</param> /// <param name="normal">The normal.</param> public void PreviewVoxel(Model3D source, Vector3D normal = default(Vector3D)) { if (PreviewModel != null) { Model.Children.Remove(PreviewModel); } PreviewModel = null; if (source == null) { return; } if (!ModelToVoxel.ContainsKey(source)) { return; } var v = ModelToVoxel[source]; var previewColor = Color.FromArgb(0x80, CurrentColor.R, CurrentColor.G, CurrentColor.B); var pv = new Voxel(v.Position + normal, previewColor); PreviewModel = CreateVoxelModel3D(pv); Model.Children.Add(PreviewModel); }