Jump to content
  • Advertisement
Sign in to follow this  
bargasteh

Texturing a mesh

This topic is 4977 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

what is the best way to texture a mesh or part of a mesh ? for example lets say we have a mesh with lots of triangles and we want to texture the whole mesh with one textrure and put another texture in the middle of it ? Is there any good tutorial to explain this? Thank you for your help.

Share this post


Link to post
Share on other sites
Advertisement
My screen flicker and blink alot when I enable the texture with
glEnable(GL_TEXTURE_2D);
what is going on ?

I do this :

//////////////////Texture///////////////
glEnable(GL_TEXTURE_2D); // This Enable the Texture mapping
id_texture=LoadBitmap("texture1.bmp"); // The Function LoadBitmap() return the current texture ID
// If the last function returns -1 it means the file was not found so we exit from the program
if (id_texture==-1)
{
MessageBox(NULL,"Image file: texture1.bmp not found", "NoImage",MB_OK | MB_ICONERROR);
exit (0);
}
//////////////////Texture///////////////
setupLights ();


please, why its like this?

Share this post


Link to post
Share on other sites
Let me draw it so you would undestand better what I meant:

..................
|\ |\ |\ |\ |
| \ | \ | \ | \ |
| \| \| \| \|
..................
..................
|\ |\ |\ |\ |
| \ | \ | \ | \ |
| \| \| \| \|
..................

Imagin this is my mesh with lots of triangles and I have a simple BMP file that should be textured at the top of that mesh.
what is the easiest way to do this?
I dont want a code from you, I just want to know when I put the texture in memory how I can apply it to all the triangle so at the end the final result will be the same as the original BMP file.
Thank you
for some reason the above text doesnt show properly when I press confirm

Share this post


Link to post
Share on other sites
Well your U,V texture coordiantes range from 0.0 to 1.0.
So when texturing your mesh, give the texture coordinates that represent the part of the image that is supposed to be covering than polygon.

for example you want to cover these QUADS with with a square texture.


._ ._ .
| | |
._ ._ .
| | |
._ ._ .


the coordiantes for the exture are
0.0 ....................... 1.0 U
. .
. .
. .
. .
. .
. .
. .
. .
. .
...........................
1.0 V

(i think I got the axis and direction right)



So the texture coordinates for the upper left quad are going to be


0.0,0.0 ______ 0.0,0.25
| |
| |
| |
0.25,0.0_______ 0.25,0.25

Share this post


Link to post
Share on other sites
Thank you snisarenko, I gave you an extremely helpful point :)
How do you put that white area in your posts (where you just typed)?
What you said is really cool but the problem is when I want to do it with Triangle, I dont know the algorithm to do it, I did it on paper for one day but at the end I couldnt cover all the triangles with that texture.!
Is there any specific algorithm that does this perfectly? or do you think about something helpful?

Thank you again

Share this post


Link to post
Share on other sites
Quote:
Original post by bargasteh
How do you put that white area in your posts (where you just typed)?


Enclose what you want in the box with a <source></source> tag, only use the square [] brackets instead of the <>'s.

So it should look something like this:

[ source]
//stuff in box
//more stuff in box
[ /source]

Without that space in the source tag.

Share this post


Link to post
Share on other sites
you can simply search the x and y min and max and then interpolate each point of each triangle in function of its x and y.

but i'm not and expert so...

Share this post


Link to post
Share on other sites
Thanks
When I hard code the texture in my code it works and its fine, but I just wanted a faster way to texture it on a mesh, because size of the mesh changes (the number of row, col), therfore I need to devide the width and height of my texture by the number of col and rows. well its a pain in ass but I am trying to do it. Is there any better way to do it?
Thanks

Share this post


Link to post
Share on other sites
Thanks
When I hard code the texture in my code it works and its fine, but I just wanted a faster way to texture it on a mesh, because size of the mesh changes (the number of row, col), therfore I need to devide the width and height of my texture by the number of col and rows. well its a pain in ass but I am trying to do it. Is there any better way to do it?
Thanks

//COOL I CAN PUT CODE HERE :)




[Edited by - bargasteh on March 2, 2005 9:02:50 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!