How to get coordinates of a moved/rotated shape in OpenGL?
In order to perform picking in OpenGL, I need to cross the vector received by gluUnproject with开发者_StackOverflow社区 the shape. However as the shape has been rotated and translated, how can I get its new coordinates ?
This is not trivial. You will have to intersect your shape with the ray. You can do this in several spaces:
I assume your Ray is in world space. If it is, you can transform the ray into object space with the inverse of the ObjectToWorld matrix (taking care to transform the normal correctly). Or, you transform your object into ViewSpace and do the calculations there.
Can you be more specific? Are we talking about an analytical shape, or a mesh?
精彩评论