Page 1 of 1
How to use TextureAthlas?
Posted: Thu Jun 02, 2011 12:20 pm
by askona
I have few textures in one .psd file. How can i use textures for road (for example),and not to receive picture like this:
I loading textures for road from file:
Code: Select all
irr::video::SMaterial* roadMaterial = new SMaterial();
roadMaterial->setTexture(0,driver->getTexture("models/road.psd"));
Posted: Thu Jun 02, 2011 12:22 pm
by Klunk
you need to set the uv coordinates of the model to the correct values, either in code of in the modeller/level editor.
Posted: Thu Jun 02, 2011 12:36 pm
by askona
How can i do that? I`m beginer in graphics and irrlicht, so don`t completely understand how to work with textures
Code: Select all
irr::video::SMaterial* roadMaterial = new SMaterial();
roadMaterial->setTexture(0,driver->getTexture("models/road.psd"));
roadMaterial->Lighting = false;
IMesh* fterr;
IMeshSceneNode* planeNode;
fterr = smgr->addHillPlaneMesh("",dimension2d<f32>(100,100),dimension2d<u32>(25,25),roadMaterial,1,dimension2d<f32>(200,200),dimension2d<f32>(3,3));
planeNode = smgr->addMeshSceneNode(fterr);
Posted: Thu Jun 02, 2011 12:36 pm
by Radikalizm
Be aware that a texture atlas like this can cause mipmapping artifacts for smaller mipmaps
Posted: Thu Jun 02, 2011 12:46 pm
by Klunk
something like ?
Code: Select all
planeNode->getMesh()->getMeshBuffer(mat)->getTCoords(i)
where mat is either a smaterial or its index and i is the vertex index. The trouble with handling uv in code is you need to know which vert is which. Its much easier to do this kind of thing in a modeling package/level editor as you get visual feed back to what you are doing.
otherwise just use non-atlas textures
Posted: Fri Jun 03, 2011 5:14 pm
by askona
I found that my .psd file contents 16 equal parts
maybe i can use it? i did`n understood what can i do with coords of my texture...even if i get few vector2df , what should i do with it?
Posted: Fri Jun 03, 2011 8:33 pm
by CondeNostaw
Jesus, man, go do your homework before asking:
http://www.dca.ufrn.br/~lmarcos/courses ... ter09.html
That is for OpenGL, but it will help you undestand the basics.