How to use TextureAthlas?

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
askona
Posts: 14
Joined: Wed Jun 01, 2011 3:45 pm
Location: Ukraine

How to use TextureAthlas?

Post 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: Image

I loading textures for road from file:

Code: Select all

 irr::video::SMaterial* roadMaterial = new SMaterial();
	roadMaterial->setTexture(0,driver->getTexture("models/road.psd"));
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Post 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.
askona
Posts: 14
Joined: Wed Jun 01, 2011 3:45 pm
Location: Ukraine

Post 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);
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

Be aware that a texture atlas like this can cause mipmapping artifacts for smaller mipmaps
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Post 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
askona
Posts: 14
Joined: Wed Jun 01, 2011 3:45 pm
Location: Ukraine

Post by askona »

I found that my .psd file contents 16 equal parts
Image
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?
CondeNostaw
Posts: 20
Joined: Sun Jan 04, 2009 2:47 pm
Location: Brazil

Post 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.
Obey.
Post Reply