Problem with toxiclibs WETriangleMesh and intersectsRay method
in
Contributed Library Questions
•
2 years ago
Hi,
Hopefully someone knows enough about toxiclibs to help me out here...
I am trying to hide faces on a mesh that are hidden from the current camera position (obscured by some other face on the mesh). To do this I am trying to implement the intersectsRay method in the toxiclibs TriangleMesh class. However, when I retrieve the intersection pos vector from isectData3d it just spits out a bunch of points on a plane, not intersection points with the mesh. I have tried reversing the ray, which gives me some very wacky points - but still not intersection points on the mesh. Heres the function I am using:
Thanks
Hopefully someone knows enough about toxiclibs to help me out here...
I am trying to hide faces on a mesh that are hidden from the current camera position (obscured by some other face on the mesh). To do this I am trying to implement the intersectsRay method in the toxiclibs TriangleMesh class. However, when I retrieve the intersection pos vector from isectData3d it just spits out a bunch of points on a plane, not intersection points with the mesh. I have tried reversing the ray, which gives me some very wacky points - but still not intersection points on the mesh. Heres the function I am using:
- public void updateDisplayFaces(Vec3D fromPos){
//loop through faces
for(int i = 0;i<bounds.faces.size();i++){
WEFace f = (WEFace) bounds.faces.get(i);
//create an intersector between face center and camera pos
Vec3D target = f.getCentroid().copy();
Ray3D isec = new Ray3D(fromPos,target);
//intersect the mesh
if( bounds.intersectsRay(isec)){
IsectData3D data = bounds.getIntersectionData();
if(data.isIntersection){
Vec3D ipos = data.pos.copy();
parent.stroke(255);
parent.point(ipos.x,ipos.y,ipos.z);
}
}
}
}
Thanks
1