texcord : how to apply a image to a mesh
- big_daddy2
- Private First Class
- Posts: 131
- Joined: Sat May 06, 2006 1:06 am
- Location: the middle of nowhere, USA
texcord : how to apply a image to a mesh
i was wondering if u have an image how do u use a texcord with it?
<h1>Fun with texcoords:</h1> by Tedius
I am guessing by the way you phrased your question that you may have a few steps to go before you are able to use texcoords successfully. But just in case, you or someone else is bound to find this useful. I am hoping you can make a simple mesh face. The code may look something like this:
If you don't understand that, I dont blame you. Just stare at it for a while and you will eventually figure it out.
Take a picture such as http://images.bzflag.org/wtf.png and imagine that the bottom left corner is the point (0,0) and the upper right-hand corner is (1,1). Therefore, the four points we will refer to in texcoords are:
lower left -> 0 0
lower right -> 1 0
upper right -> 1 1
upper left -> 0 1
Below we will define the material as wtf, (I think it stands for wabbits taste funny), refer to the the material when we define the face, define the four corners as listed above, and then apply those corners to the vertices in the face. Here goes:
Now your homework is to change the texcoord part. You can double it so you have a bunny on top of another like so:
You can chop the bunny in half by putting in ".5" You can even skew the poor guy by putting in random numbers between 0 and 1 in those places.
mmm pancakes:
Edit: much apologies to big_daddy2. It turns out I underestimated him, he had no trouble with it at all.
Sorry, mate.
I am guessing by the way you phrased your question that you may have a few steps to go before you are able to use texcoords successfully. But just in case, you or someone else is bound to find this useful. I am hoping you can make a simple mesh face. The code may look something like this:
Code: Select all
mesh
vertex -16 75 0 #0
vertex 16 75 0 #1
vertex 16 75 24 #2
vertex -16 75 24 #3
face
vertices 0 1 2 3
endface
end
Take a picture such as http://images.bzflag.org/wtf.png and imagine that the bottom left corner is the point (0,0) and the upper right-hand corner is (1,1). Therefore, the four points we will refer to in texcoords are:
lower left -> 0 0
lower right -> 1 0
upper right -> 1 1
upper left -> 0 1
Below we will define the material as wtf, (I think it stands for wabbits taste funny), refer to the the material when we define the face, define the four corners as listed above, and then apply those corners to the vertices in the face. Here goes:
Code: Select all
material
name wtf
addtexture http://images.bzflag.org/wtf.png
end
mesh
vertex -16 75 0 #0
vertex 16 75 0 #1
vertex 16 75 24 #2
vertex -16 75 24 #3
texcoord 0 0 #0
texcoord 1 0 #1
texcoord 1 1 #2
texcoord 0 1 #3
face
vertices 0 1 2 3
texcoords 0 1 2 3
matref wtf
endface
end
Code: Select all
texcoord 0 0 #0
texcoord 1 0 #1
texcoord 1 2 #2
texcoord 0 2 #3
mmm pancakes:
Code: Select all
texcoord .15 .5625 #0
texcoord .625 .5625 #1
texcoord .625 .857 #2
texcoord .15 .857 #3
Sorry, mate.
this signature intentionally left blank
- big_daddy2
- Private First Class
- Posts: 131
- Joined: Sat May 06, 2006 1:06 am
- Location: the middle of nowhere, USA
Your texcoord should match up with the vertices. In my example, the vertices were listed in order from the lower left hand around to the upper left hand corner. If it is sideways, just switch your texcoords around like this:
or possibly this:
[/code]
Code: Select all
face
vertices 0 1 2 3
texcoords 1 2 3 0
matref wtf
endface
Code: Select all
face
vertices 0 1 2 3
texcoords 3 0 1 2
matref wtf
endface
this signature intentionally left blank
- big_daddy2
- Private First Class
- Posts: 131
- Joined: Sat May 06, 2006 1:06 am
- Location: the middle of nowhere, USA