Im working on a map editor and i need to be able to "Justify" the textures (So there justified to the Left, Right, Top, Bottom, etc). To do that as far as i can tell id need to know the width and height of the face. So im wondering if anyone could point me in the right direction.
I don't know, whether I understand your question correctly, but if you mean to get the width and height of a texture by the id getting by opengl:
Imho it is not possible to get that, so you have to save the information if you load the image.
If I understand your question wrong, do that what everybody person does here:
Ignore me!
_________________ Denn wer nur schweigt, weil er Konflikte scheut, der macht Sachen, die er hinterher bereut. Und das ist verkehrt, denn es ist nicht so schwer, jeden Tag zu tun als ob's der letzte wär’. Und du schaust mich an und fragst ob ich das kann. Und ich denk, ich werd' mich ändern irgendwann. _________________Farin Urlaub - Bewegungslos
I mean the actual size of the Face. In map editors like Valves Hammer users have the ability to what they call "Justify" the images position so that it is shifted to the left, top etc. But to be able to work out the texture's shift i assume id need to know the actual size of the Face its self. I already store the Textures size in a object.
The problem is:
How do you define the size of an arbitrary orientated face?
How do you define "face"? Triangles? Quads? Convex Polygons? Arbitrary Polygons?
You could define it for example as the size of the bounding box. That's simple, find minimum and maximum on each coordinate axis separately and compute the differences.
You could also take one of the edges as artificial U-Axis and compute the perpendicular V-Axis. Then compute width and height according to these axes. But which edge do you take as U-Axis?
To compute the size according to an arbitrary Axis you need to project all vertices on this axis. You can do that using the dot-product of normalized axis and the vertex.
=> You need to specify EXACTLY what you want to compute. Otherwise nobody can help you.
How do you define "face"? Triangles? Quads? Convex Polygons? Arbitrary Polygons?
Should always be convex polygons in my case.
Coolcat hat geschrieben:
=> You need to specify EXACTLY what you want to compute. Otherwise nobody can help you.
Considering i haven't done this before i don't know the exact terminology which should be used to describe what i want to do. They say a picture is worth a thousand words, so iv made one. The image below shows the end goal. The ability to "Justify" (Its the same as Justify in word processing applications, just basically means that stuff is aligned to a side) the texture's position on a face. To do this, i am assuming that i first need to know the bounding box(Bounding box doesn't sound right for 2D stuff, as a box is 3d, hence why i used Width/Height in previous posts) of the face.
I assume ill need to do what you suggested in your post. "But which edge do you take as U-Axis?" is a good question. In objects that my editor creates it would be simple (Since all objects would be aligned to the normal axis's by default, so i could just rotate the axis's when the object is rotated), but maps that are imported from other editors it wouldn't be that simple.
Mitglieder in diesem Forum: 0 Mitglieder und 0 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.