Interacting with individual parts of a model

Hi guys,

first time poster here thats new(ish) to OpenGL. I’m currently using OpenGL ES for the iPhone. I’ve managed to make an articulated robotic arm, no problems there.

My question is, is there any way that I can reference different parts of the robotic arm, for example give the forearm and wrist variable names? as i’d like to be able to manipulate different parts of the arm individually through touching them, I just really dont know where to start with this and so far have been unable to find the right tutorial online, perhaps because I’m new to OpenGL’s terminology and an searching for the wrong things!

Any pointers/ suggestions you can give will be greatly appreciated.

Thanks in advance,

Dave

OpenGL does not provide any support for managing individual meshes besides or mesh parts. That all needs to be handled by the programmer or a library that sits on top of OpenGL. For example, your robot arm has five parts: wrist, forearm, etc. OpenGL doesn’t care. It knows it has five respective VBOs that draw each part, but it’s up to you to know which VBO goes to which part.

Anyway, you want to do mouse picking, which is relatively easy but there are a lot of different options out there. Here’s a really basic approach. Say for example you render your five parts to the back buffer, where each piece you give a flat color like red, green, blue, etc. (no shading). You then read a point back where the mouse is using glReadPixels. You match that color to the part and you know what the user is clicking on.

Another method is to use ray tracing, where you turn the mouse click and the camera into a ray and intersect it with your articulated arm. This method is a little more complex, but I think it’s a little more robust.