Ok. First part was simple:
CVector3 last_comp_coord; // Global space intersection
coord of component that we want to check
CVector3 last_comp_coord_screen_space;
in_ctxt.WorldToView(last_comp_coord, last_comp_coord_screen_space);
LONG x = (LONG)last_comp_coord_screen_space.GetX();
LONG y = (LONG)last_comp_coord_screen_space.GetY();
PolygonMesh curMesh( in_obj.GetActivePrimitive().GetGeometry()
);
CTransformation localToGlobal =
in_obj.GetKinematics().GetGlobal().GetTransform();
CLongArray face_dumy;
if ( curMesh.SetupPointLocatorQueries(
siClosestSurfaceRaycastIntersection,&localToGlobal, -1,
face_dumy.GetArray(), 10 ) != CStatus::OK){
Application().LogMessage("INTERSECT ERROR:
SetupPointLocatorQueries");
return CStatus::False;
}
CLine l_ray;
in_ctxt.GetWorldRay(x,y,l_ray);
CVector3 rayt = l_ray.GetTangent();
CVector3 rayp = l_ray.GetOrigin();
PointLocatorData locators;
locators = curMesh.GetRaycastIntersections( 1, (double*)&rayp,
(double*)&rayt, siSemiLineIntersection );
if ( !locators.IsPtLocatorValid(0) ){
Application().LogMessage("INTERSECT
ERROR::LastCompAvailable(): can't get intersection with mesh");
return CStatus::Fail;
}
if (curMesh.EvaluatePositions(locators, -1, 0,
(double*)&out_pos) != CStatus::OK){
Application().LogMessage("INTERSECT
ERROR::LastCompAvailable(): can't evaluate position on mesh");
return CStatus::Fail;
}
// translate it to obj global coords & check equality
// of src component intersection coord and curent viewport
intersection coord
out_pos.MulByTransformationInPlace(localToGlobal);
double treshold = 0.2; // <!> distance between
points
if(last_comp_coord.EpsilonEquals(out_pos, threshold)==true)
last_comp_available = true;
else
last_comp_available = false;
But if intersection point that we want to check lies on side of a object
like this: http://take.ms/ZfAZO
then we simply can't create PointLocator by raycast =\
locators = curMesh.GetRaycastIntersections( 1, (double*)&rayp,
(double*)&rayt, siSemiLineIntersection );
this part return invalid pointlocator.
How should i deal with this cases if i need a pointlocator ?
------
Softimage Mailing List.
To unsubscribe, send a mail to [email protected] with
"unsubscribe" in the subject, and reply to confirm.