holance on develop
Update CHANGELOG.md (compare)
holance on develop
Fix topmost group is not render… Merge pull request #1624 from h… (compare)
Hi!
Assume I have a model like this in Viewport3D. Now I want to have a Line or a Ray from the up high to bottom plane (Z = infinity → Z = 0). I want to return the intersection point of the ray/line and the the first facet it touches (probably the facet on top of the model)
How can I do that as I probably search around google but no solution so far.
I did try:
for (int i = 0; i < myPaintModelMeshGeometry3D.TriangleIndices.Count; i = i + 3)
{
int index1 = myPaintModelMeshGeometry3D.TriangleIndices[i];
int index2 = myPaintModelMeshGeometry3D.TriangleIndices[i + 1];
int index3 = myPaintModelMeshGeometry3D.TriangleIndices[i + 2];
Point3D point1 = myPaintModelMeshGeometry3D.Positions[index1];
Point3D point2 = myPaintModelMeshGeometry3D.Positions[index2];
Point3D point3 = myPaintModelMeshGeometry3D.Positions[index3];
Vector3D vectorA = point2 - point1;
Vector3D vectorB = point3 - point1;
Vector3D normal = Vector3D.CrossProduct(vectorA, vectorB);
normal.Normalize();
Plane3D facet = new Plane3D();
facet.Normal = normal;
facet.Position = point1;
Ray3D ray3D = new Ray3D();
ray3D.Direction = new Vector3D(0, 0, 1);
ray3D.Origin = new Point3D(250, 0, 0);
Point3D? IsIntersection = facet.LineIntersection(ray3D.Origin, ray3D.Origin + ray3D.Direction * myPaintModelBoundingBox.SizeZ);
}
But the result is a lots of "intersection" points since the Plane3D spreads to infinity, so each iteration of the facet cut the ray at one point....
GroupElement3D
, so i was thinking maybe override OnCreateSceneNode
and provide a custom scene node that makes itself renderable or not.
bool CanRender(RenderContext context)
but im not sure how often this gets called or if thats the right place to do it
bool TestViewFrustum(ref BoundingFrustum viewFrustum)
which might work if it gets called every time the camera moves and hence the frustrum changes