Jump to content
  • Advertisement
Sign in to follow this  
iwoplaza

OpenGL Vertex/Model Selection in my Modeler Program.

This topic is 2296 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a problem. I wrote a modeler to create models with my format, but I want to be able to select individual vertices with my mouse or select which model I want to edit. Screen of the program:

someq.png

So can you give me some tutorials or tips.

I'm using:
OpenGL - drawing.
DevIL - images.
fStream - FileLoader.

I'm from Poland so if you could use some clear language.

Thanks in advance. Edited by iwoplaza

Share this post


Link to post
Share on other sites
Advertisement
you have to first get the screen coordinates of your mouse, you convert it from camera space to model space and cast a ray from that point in the direction of the camera normal and then, the closest face you hit, you check which model it belongs to and then, you add the model to the select list or however you handle selection.
For vertices, from the closest face you hit if any, you check each of its vertices and then, add a padding or radius to each vertex which probably should get smaller based on distance from the camera and then, check if the ray collides with the sphere surrounding any vertex given the radius or padding. Then if any collision to any vertex occurs, choose the closest. I think this should do it.

Share this post


Link to post
Share on other sites
Thanks man. I was thinking of it before but i was wondering if there is better way to do it.
But thanks :). If anyone knows another way of doing it please tell me.

Share this post


Link to post
Share on other sites
The easiest way to do this is use an offline buffer (or alpha if you don't do blending) to render an ID number and then do glReadPixels() with mouse coordinates and read back your ID. That way you can pick anything that you draw, no complex math involved, nothing can go wrong and it doesn't slow you down a lot. Readback from GPU isn't that fast, but going through massive amounts of geometry (if you plan on having such) a second time and on the CPU is way slower than reading a value you've already calculated.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!