Get Normal and TextureCoordinate by mouse via ray picking?

Thank you for view this topic at first Maybe this isn’t a advanced question,but it is really difficult for me,please help me.

I have useing gluUnProject() to get the vertex selected by mouse.Now i want to get the Normal and TextureCoordinate of this vertex.is there any easy way?

of course its difficult for a beginner, but thats why there is a beginners section. that doesnt mean “only amateurs to answer your question” but “ask beginner questions here”.

the function doesnt return a vertex, it returns a point you can use to build a ray that you can then use to check for intersection. there is no normal and no texture coordinate for this point.

Yeah it’s annoying to see your name appear 4 times with 4 different, but basic questions, on the advanced board.

gluUnproject does not know anything about “vertices”. It just returns a position in world space. You can then use it to generate a ray going from your camera “into the direction” of the pixel you clicked on, but then it’s up to you to intersect this ray with your world polygons. This should give you a list of triangles along that ray, and the points of intersection (there can be multiple points, you can keep the nearest one only if you want). Then, use barycentric coordinates (for example the well known area trick) to get 3 weights, for each vertex of your triangle. Simply use these weights to interpolate the normal or the tex coords (or anything else).

Y.

I’m sorry for my poor English.

I know what i get via ray picking—it is a point with true x,y and z.

I also know the way:
"Then, use barycentric coordinates (for example the well known area trick) to get 3 weights, for each vertex of your triangle. Simply use these weights to interpolate the normal or the tex coords (or anything else).
"

What I want to get is a more EASY way.is anybody know?

Thanks Jared and Ysaneya also.

Yes,I have post 4 basic questions.

I’m sorry to say that this IS the easy way :slight_smile: The trick is to perform fast scene/ray intersections, the rest is 30 lines of code, so i don’t know how you could expect it to be more simple…

Y.