Stretched textures :o(

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Enxaqueca

Stretched textures :o(

Post by Enxaqueca »

As a test, i've createad a floor, like 100x100 pixels. So i put a texture 10x10 (exemple). Running this test the texture stretches. There is a way to not to do this with the image? I like to fill the poligon repeating the texture inside. Can it be?
thanks!
Guestola

Post by Guestola »

as far as i know, you can't do that
Enxaqueca

Post by Enxaqueca »

Realy??
i need to live with those distorced images? (Or enlarge what i have! :roll: )
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

in the 8. example "SpecialFX" Niko shows, that its possible bouldering a mesh with a texture

[code]
smgr->getMeshManipulator()->makePlanarTextureMapping(
mesh->getMesh(0), 0.008f);
[/code]
but thats not what you want to know ?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

UV coordinates are responsible for that, if your UV coordinates are bigger than 1,1 then you gona see texture repeat on that mesh.
Enxaqueca

Post by Enxaqueca »

These UV coordinates you talk about are inside the textures or in the code itself?
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

i again :)
have you tried to change the resolution-parameter of makePlanarTextureMapping ? I think that should work ?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

UV coordinates are coordinates of mesh wertices. Vertex have x/y/z coordinates in model space and U/V coordinates in texture space. Top left corner of your texture have coordinates U=0, V=0 and bottom right corner have coordinate U=1, V=1 where U is horizontal and V vertical coordinate.

Lets take example:
you have square plane mesh consisting of 4 vertices with coordinates:
v1. -x0,y0,z0
v2. -x1,y0,z0
v3. -x1,y1,z0
v4. -x0,y1,z0
(this is what makePlanarTextureMapping do by default I think)

you want texture to be maped on that square ...one texture for square:
v1. -u0, v1
v2. -u1, v1
v3. -u1, v0
v4. -u0, v0
(pleas note that UV is dependles on texture pixel size if texture is 128/256 pixels big than 1U=128 pixels and 1V=256 pixels)

if you want your texture to be mapped (repeated) 4 times verticaly and 4 times horizontaly ...means 4*4=16 texture tilles:
v1. -u0, v4
v2. -u4, v4
v3. -u4, v0
v4. -u0, v0

if you want only left half of your texture to be maped on your square:
v1. -u0, v1
v2. -u0.5, v1
v3. -u0.5, v0
v4. -u0, v0

if it is not giving you sense, draw it down at a piece of paper. Just remember UV starts in upper left corner, just like your screen and unlike model space.

U and V can have negative values as well, then texture will be fliped.

Hope this helps.
Enxaqueca

Post by Enxaqueca »

Hey knight, now u mention the exemple 8 i'd notice the textures are fine, so i made the universal copy/paste method end a got textures well fited. :P
Arras, thanks for the uv classes 8) , but the best part was the last line, ...then the texture will be flipped...Thats somethig im searching about, and almost become my next topic.

Thank you guys for the patience. :roll:
Post Reply