0
cutting mesh
This discussion was imported from CodePlex
edui wrote at 2013-03-05 07:20:
Hi All;
I'm very new in wpf and helix3d.
I have a 3d mesh model. The center of model positioned at Point3D(0,0,0). I want to cut the mesh which all vertices in positif Y axis.
Best Regards;
DM
I'm very new in wpf and helix3d.
I have a 3d mesh model. The center of model positioned at Point3D(0,0,0). I want to cut the mesh which all vertices in positif Y axis.
foreach (GeometryModel3D gm in mg.Children)
{
MeshGeometry3D mesh = (MeshGeometry3D)gm.Geometry;
Point3DCollection positions = mesh.Positions;
Vector3DCollection normals = mesh.Normals;
Int32Collection indices = mesh.TriangleIndices;
Point3DCollection newPositions = new Point3DCollection() ;
Vector3DCollection newNormals = new Vector3DCollection();
Int32Collection newIndices = new Int32Collection();
int c = 0;
foreach (Point3D p in positions)
{
if (p.Y >= 0)
{
newPositions.Add(p);
newNormals.Add(normals.ElementAt(c)); //I'm not sure in this line
newIndices.Add(indices.ElementAt(c));
}
c++;
}
GeometryModel3D gd = new GeometryModel3D();
MeshGeometry3D g = new MeshGeometry3D();
g.Positions = newPositions;
g.Normals = newNormals;
g.TriangleIndices = newIndices;
gd.Geometry = g;
gd.Material = MaterialHelper.CreateMaterial(Colors.Aquamarine);
nm.Children.Add(gd);
nm.Transform = new TranslateTransform3D(new Vector3D(d.Bounds.X, d.Bounds.Y, d.Bounds.Z)); //translate to another positioned
}
ModelVisual3D v = new ModelVisual3D();
v.Content = nm;
But i got the broken mesh. Any suggestions/ideas ? Best Regards;
DM
edui wrote at 2013-03-21 10:29:
Hi All;
I found the solution.
After rotating the mesh, I want to cut the mesh. But the cut direction still follow the mesh direction, not the viewport direction.
Any idea?
I found the solution.
var n = new Vector3D(0,0.2,1);
var p = new Point3D(0, 0.5, 0);
var geo = MeshGeometryHelper.Cut(mesh, p, n);
var m = new GeometryModel3D(geo, gm.Material);
m.BackMaterial = Materials.Red;
var mv = new ModelVisual3D();
mv.Content = m;
view1.Children.Add(mv);
But i've another problem. When I added the manipulator (CombinedManipulator) to the ModelVisual3D object.
After rotating the mesh, I want to cut the mesh. But the cut direction still follow the mesh direction, not the viewport direction.
Any idea?
edui wrote at 2013-03-25 08:45:
Hi All;
to precisely cut the mesh, i need to convert the model coordinate to global coordinate.
Regards;
DM
to precisely cut the mesh, i need to convert the model coordinate to global coordinate.
Regards;
DM
Customer support service by UserEcho