Advertisement

Texture Mapping Question

Started by May 16, 2003 04:58 AM
3 comments, last by shivaunicorn 21 years, 9 months ago
Hi. When use texture mapping,it seem that we must add the whole rectangle BitMap file to object. But what can we do if we only need a specific part picture,example picture of a chess-man.
Its all to do with the texture coordinates you use.

if you had a texture of size, say 256x256, and you wanted to texture an entire square with it, you''d use texture coordinates:

0,0
1,0
1,1
0,1

(or to simplify my example to come:
0/255,0/255
255/255,0/255
255/255,255/255
0/255,255/255)

so if you had a load of 32x32 sprites in a 256x256 image, to get the first top left sprite, you''d use texture coordinates:

0/255,0/255
31/255,0/255
31/255,31/255
0/255,31/255

(i think O.o)
Advertisement
quote:
Original post by wAVaRiaN
Its all to do with the texture coordinates you use.

if you had a texture of size, say 256x256, and you wanted to texture an entire square with it, you''d use texture coordinates:

0,0
1,0
1,1
0,1

(or to simplify my example to come:
0/255,0/255
255/255,0/255
255/255,255/255
0/255,255/255)

so if you had a load of 32x32 sprites in a 256x256 image, to get the first top left sprite, you''d use texture coordinates:

0/255,0/255
31/255,0/255
31/255,31/255
0/255,31/255

(i think O.o)


-------
thank for your help.but if i don not want to load a rectangle sprites,what should i do.
It''s the exact same principle as wAVaRiaN said... What are you trying to load?
the thing bout texture mapping is, u cant avoid the rectangular definition of a texture. no matter wat image u plan to use, u''re stuck to specifying the source in a rectangular space. which is y texture coordinate manipulation comes in. the coordinates denote WHERE in the image u want to apply to a vertex, so u can opt to use or completely neglect certain portions of a texture. but the texture itself is STILL a rectangular source.
- To learn, we share... Give some to take some -

This topic is closed to new replies.

Advertisement