view particuar face of object in 3d

hi

i am new to zith . so i need your help.

actually i have a 3d object with faces. now i wanna click on any face and then it should show the selected face by getting perpendicul to the eye(the place from where object is scene).

regards
rose

I don’t know, if I got you right. But have a look at PickingLibrary and ExtXith3DEnvironment.pick(…). They should do what you want.

Well its somewhat complicated ,
I am doing this ,i’ll share my algo.
so lets do this in step:

  1. All faces are taken as Shape3d object .
  2. On click we use Picking to get the face clicked.
  3. Now from this face take out 3 vertices .
  4. From two vectors from these 3 vertices : AB and BC
  5. Now cross these two to get a perpendicular vector to the Face. V
  6. This should be your view direction ,so use view.lookAt function with Object being centre of face and eye somewhere on a line parallel to V and passing through centre of face.
  7. Updirection you can decide depending on your requirement.

hope this will help… :slight_smile:

Interesting algorithm. Maybe we should add this functionality to the PickingLibrary, such that it saves the actually picked face of the geometry and it’s normal into the PickResult.

I think this is wrong. The face’s normal does not necessarily point to the eye’s position, well, in this special case it certainly does, but it is not general. So you’ll need to calculate the center point of the picked face and build a vector from this point to the eye’s position. the negation of this vector can serve as your new view’s direction vector. Correct me, if I’m wrong. But I think this should be correct. As the center point of a (non regular) face you can e.g. take its mass’ center point. This should be possible to calculate.

Marvin

Yaa you are right , but i was doing what rosemary is doing …i think so,
Basically you want face to be perpendicualr so for that your eye To Object vector has be perpendicular to face.
No you are not wrong infact in last two steps i have pointed out the same thing .
That is to figure a point on Face and drive a equation of line from that point and parallel to the calculated Normal to Face.

[quote]Interesting algorithm. Maybe we should add this functionality to the PickingLibrary, such that it saves the actually picked face of the geometry and it’s normal into the PickResult.
[/quote]
Yaa …if many people require this than we can add this to PickingLibray or we can have a separate Package dedicated to all Selection Problems but it depends what people are doing with Xith

thanks alot. really it will work.
Qudus, i guess khangharoth is genious.