Getting UV coordinates of a triangle from screen coordinates

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Getting UV coordinates of a triangle from screen coordinates

Post by Pyritie »

Alrighty, so here's what I want. I'm basically trying to make a "model painting" tool so by click-dragging on the screen you can paint on the model's texture.

I already know that I need to get a triangle from the collision manager. I know how to do that. But how do I get the texture coordinates of the closest texel based on a point on that triangle?
Hive Workshop | deviantART

I've moved to Ogre.
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

Post by porcus »

1.)pick the triangle
2.)check which triangle from the meshbuffers of your mesh matches the
picked triangle
3.)get the uv coordinates via TCoords (http://irrlicht.sourceforge.net/docu/st ... ertex.html)
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

Mkay, I'll give it a shot.
Hive Workshop | deviantART

I've moved to Ogre.
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

porcus wrote: 2.)check which triangle from the meshbuffers of your mesh matches the
picked triangle
Is there a way to do that without having to go through each vertex? D:
Hive Workshop | deviantART

I've moved to Ogre.
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

Mhh, I talked with bitplane over irc and it seems the most feasable way to do this is to stick every triangle in the mesh into a map and then use that to get the mesh triangle from the triangleselector triangle. Urgh.

I'll post the code when I'm done with this, in case anyone else wants it.
Hive Workshop | deviantART

I've moved to Ogre.
Post Reply