For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!
load models
it_test wrote at 2013-02-05 09:06:
Can anyone provide a working code for loading one\group of models from .obj .mtl and some .jpg files and rendering them on screen? I was trying to load models, but I cannot load or apply textures, and it gets messy.
I looked at example folder, but it only loads model with no texture.
I'm probably not applying them correctly, but there might be other errors.
I think there is a problem with materials; first I load the model
model = ModelImporter.Load("filename.obj");
material = (MaterialGroup)((GeometryModel3D)model.Children[0]).Material;
then return that material: this.theMaterial = (MaterialGroup)faceNeutral.getMaterial();
where <GeometryModel3D.Material>
<MaterialGroup x:Name="theMaterial">
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Color="LightBlue" Offset="0" />
<GradientStop Color="LightBlue" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>
but object still renders as LightBlue.also number of times I got
//Unable to cast object of type 'System.Windows.Media.Media3D.MaterialGroup' to type 'System.Windows.Media.Media3D.DiffuseMaterial'.
thanksobjo wrote at 2013-02-10 16:43:
Orthographic Cameras
ReedCopsey wrote at 2010-05-14 21:10:
Are there plans to add support for orthographic cameras, as well as perspective cameras?
objo wrote at 2010-05-15 00:00:
Yes, orthographic cameras should be supported, but there are a few other camera features I would like to add first (zoom to extents of model, rotate around a point that is not at the center of the view). Does anyone know how to do this?
objo wrote at 2010-05-15 00:07:
I added this to the issue tracker.
ReedCopsey wrote at 2010-05-15 01:56:
objo wrote:
(zoom to extents of model, rotate around a point that is not at the center of the view). Does anyone know how to do this?
For zooming to extents, it depends on whether you're orthographic or perspective.
In orthographic, you just set the camera's width to be wide enough to encompass the bounding box.
Perspective is a bit trickier. For this, you need the radius of a bounding sphere, and the camera's field of view. Basically, you just position the camera so that its at a distance (from the bounding sphere's center):
double cameraDistanceToWorld = worldBoundsRadius / Math.Sin(camera.FieldOfView * Math.PI / 360.0d);
For rotating around a point not at center, the main issue is that you need to track the rotation point separate from the camera itself. Right now, you're not rotating around the center of the model, but rather the point defined by the end of the look vector... To rotate around an arbitrary point, you'd need to track the rotation point. That being said, I'm not sure this is a good idea - it wouldn't behave like a standard trackball at this point, but rather have some very odd behavior...
objo wrote at 2010-05-16 22:37:
Thanks for your suggestions - I was thinking to implement zoom to extents using the 2D bounding box (see Eric Sink's blog post), but I can try the bounding sphere first. I will assume the center of the bounding sphere is the current camera target point. And maybe use the Visual3D.Bounds property (which is cached), even if it will not give the minimum bounding sphere?
The rotation around a point which is not in the center of the view is a behaviour I see in Google Earth and many CAD/modelling programs - the point where you press down the mouse button is used as the center of the rotation. Maybe this needs a special camera that derives from MatrixCamera? I tried changing both Position and Direction of the ProjectionCamera at the same time, but that solution was not very stable...
ReedCopsey wrote at 2010-05-17 20:28:
I'd avoid the 2D bounding box approach, at least as specified in that post. It goes through the entire world, and requires checking every single point's location. That's going to be pretty horribly slow, especially once you add the visual transform checks to world space (his current implementation in that post won't work if you have transforms on your objects...)
You should be able to use the Visual3D.Bounds property directly. Just use the center of the bounds as the center point, and 1/2 the bounds diagonal length as a radius, and you'll get a pretty decent implementation. It might, in some cases, be zoomed out slightly more than necessary (since the minimum bounding sphere could be smaller than the bounding box), but it should be pretty decent, and it's very fast - for any size model.
objo wrote at 2010-08-05 00:56:
The CameraController and HelixView3D controls now support orthographic cameras.
FindSharpEdges problems
Trezzy wrote at 2013-01-09 14:17:
Hello,
First of all, great toolkit you have here. I was up and running in minutes.
I am having some problems with the FindSharpEdges method in MeshGeometryHelper. Even if I set the angle to 0 i get no edges returned. Is this a known issue or am I missing something?
I was hoping to achieve some sort of Wireframe looking rendering.
Br,
Trezzy
Layers in 3DS
RusGIS wrote at 2012-02-23 04:57:
Hello!
When reading the model in 3DS format, broken into layers displayed
only a single layer.
objo wrote at 2012-03-10 16:03:
The figure only shows a black rectangle. Can you provide a .3ds file with layers that we can use for testing?
Wireframe
behnam263 wrote at 2014-04-16 16:25:
behnam263 wrote at 2014-04-18 21:13:
this is what page is:
http://blog.csharphelper.com/2014/04/17/draw-a-3d-wireframe-model-for-a-meshgeometry3d-using-wpf-and-xaml.aspx?ref=rss
MeshExtensions.cs is needed in your code
HelixToolkit (incompatible), cant run/build samples
Any solution that i try to open gives me this problem. I am using VS 2013
Intersection of an stl object and plane3d
abuseukk wrote at 2013-02-05 13:35:
I am trying to find the intersection points of GeometryModel3D and a plane. The model is STL file and loaded by the helix methods. I thought that I have all the triangles and with the implemented intersection of line and Plane3D i will find the points easily but that's not true. I don't know why I find so many points on the plane but not only the intersection points - What I mean is that Plane3D.LineIntersection(...) every time return some points but not null. If someone have an idea it will be grateful :) Thanks
MeshGeometry3D modelGeometry = (MeshGeometry3D)hitgeo.Geometry;
for (int i = 0; i < modelGeometry.TriangleIndices.Count; i=i+3)
{
int index1 = modelGeometry.TriangleIndices[i];
int index2 = modelGeometry.TriangleIndices[i+1];
int index3 = modelGeometry.TriangleIndices[i+2];
Point3D point1 = modelGeometry.Positions[index1];
Point3D point2 = modelGeometry.Positions[index2];
Point3D point3 = modelGeometry.Positions[index3];
Point3D? intersection1 = p3d.LineIntersection(point1, point2);
Point3D? intersection2 = p3d.LineIntersection(point1, point3);
Point3D? intersection3 = p3d.LineIntersection(point2, point3);
if(intersection1 != null)
{
IntersectionPoints.Add(intersection1);
}
if(intersection2 != null)
{
IntersectionPoints.Add(intersection2);
}
if(intersection3 != null)
{
IntersectionPoints.Add(intersection3);
}
}
abuseukk wrote at 2013-02-07 09:50:
objo wrote at 2013-02-07 19:59:
Also see the contouring example in Source\Examples\ExampleBrowser\Examples\Contour
Cylinder becomes Multilateral body in Helix 3D
musicxpg wrote at 2013-02-25 14:49:
I am using Helix 3D Toolkit. It is an amazing tool. I exported 3ds file from Skecthup. Then, I imported it into my WPF application. However, I found that the cylinder in Sketchup looks naturally, more like a cycle. However, in the WPF application, It changes to multilateral body. How to solve this problem?
objo wrote at 2013-03-13 07:09:
How to keep the coordinate system always at (0,0,0) point?
chinh_nguyen wrote at 2013-01-08 15:38:
Hi, first of all, thank you for the great work, now I can zoom, rotate with ease.
I have 1 question here: how to keep the coordinate system always at (0,0,0) point?. Because I am draw graph so I need to make it there.
chinh_nguyen wrote at 2013-01-10 09:16:
Hi all, I found my answer, I did not know about CoordinateSystemVisual3D, how silly of me.
MeshGeometryHelper Cut Method Help: Normals Flipping and Cannot Cut Twice
Good Day Everyone,
I'm having a hard time with cutting a model in my program. I import a STL file into a Model3DGroup, add that model to a MeshBuilder (true for include normals), and attempt to cut the model along the 0 z-axis (pInf and nInf) This is to ensure it has a flat base to 3D print on.
First issue:
The flat cut is inverted when added. If i add a larger model, it inverts all the normals and appear to be inside out.
Second issue:
I attempt to cut the model at 10 mm (pSup and nSup), but the attempt keeps failing. It will fail even if I comment out the 0 z-axis cut.
private void CutBottom() { //load the stl file to edit string file = @"E:\Test\test.stl"; var mi = new ModelImporter(); Model3DGroup model = mi.Load(file, System.Windows.Threading.Dispatcher.CurrentDispatcher); //convert model to Geometry3D MeshBuilder meshModel = new MeshBuilder(true, false); foreach (var m in model.Children) { var mGeo = m as GeometryModel3D; var tri = (MeshGeometry3D)mGeo.Geometry; if (tri != null) { meshModel.Append(tri); } } MeshGeometry3D mesh = meshModel.ToMesh(); //create a copy of the mesh var g = mesh as MeshGeometry3D; MeshGeometry3D gOrig = g.Clone(); //Cut the Mesh and then apply the cutplane var pInf = new Point3D(0, 0, 0); var nInf = new Vector3D(0, 0, 1); Plane3D cpInf = new Plane3D(pInf, nInf); var pSup = new Point3D(0, 0, 2); var nSup = new Vector3D(0, 0, 3); Plane3D cpSup = new Plane3D(pSup, nSup); //cp, p & n are the cut plane (Plane3D) and the position (Point3D) and the normal (Vector3D) of the plane g = MeshGeometryHelper.Cut(g, pInf, nInf); g = MeshPlaneCut(g, gOrig, cpInf); //g = MeshPlaneCut(g, gOrig, cpSup); DiffuseMaterial graySide = new DiffuseMaterial(new SolidColorBrush(Colors.Gray)); var meshGeo = new GeometryModel3D(g, graySide); Model3DGroup finalModel = new Model3DGroup(); finalModel.Children.Add(meshGeo); //remove gridlines bolusMesh.Content = finalModel; //export stl Viewport.Viewport.Children.Remove(grids); Viewport.Export(@"E:\Test\test_cut.stl"); Viewport.Viewport.Children.Add(grids); } private static MeshGeometry3D MeshPlaneCut(MeshGeometry3D meshCut, MeshGeometry3D meshOrig, Plane3D plane) { //Store the positions on the cut plane var segments = MeshGeometryHelper.GetContourSegments(meshOrig, plane.Position, plane.Normal).ToList(); //assumes largest contour is the outer contour! IList<Point3D> vertexPoints = MeshGeometryHelper.CombineSegments(segments, 1e-6).ToList().OrderByDescending(x => x.Count).First(); //meshCut the polygon opening and add to existing cut mesh var builder = new MeshBuilder(false, false); builder.Append(meshCut.Positions, meshCut.TriangleIndices); builder.AddPolygon(vertexPoints); MeshGeometry3D mg3D = builder.ToMesh(); return mg3D; }
Customer support service by UserEcho