I am still having some issues with this. My current solution (which produces the correct results), calculates the intersections of an arbitrary view plane with the 3D geometry. I am sure that some kind of matrix operation will do the same, but I have been unable to calculate this. My algorithm for projecting a 3D point to a 2D point within an arbitrary plane is as follows :
Code: Select all
I2DPnt DCELFace::ProjectedPnt(const I3DPnt &pnt,const I3DPnt &From,const I3DPlane &Plane,I3DPnt &intp) const
{
I3DLine line(pnt,From - pnt);
bool Intersect = line.IntersectWith(Plane,intp,false);
if (!Intersect)
Trace(false,"ProjectedPnt problem");
return Plane.paramOf(intp);
}
pnt is the coordinate in 3D
From is the viewpoint (eye position)
Plane is the arbitrary view plane
intp is the returned 3D point of intersection
Plane.paramOf returns a 2D coordinate within the plane.
I am sure there must be a better (and faster) way of doing this.
Thanks
Anton