Tiling Textures?

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
DarkDepths
Posts: 126
Joined: Sun Apr 02, 2006 1:21 am
Location: Canada

Tiling Textures?

Post by DarkDepths »

Hey. I've been trying to find out how to repeat textures over a cube, but have been unsuccessful.

I think you can guess what I want to do, but in case you can't:

I want to create a CubeSceneNode and then apply a texture to it. However, I'm using this cube as a floor, and each level is a different size (though always a multiple of 32), so I want to be able to make a texture that is 32x32 and then repeat it however many times is needed for that particular level. Essentially, I want to be able to make it look like a grid across the floor that always has the same sized cells, no matter the size of cube.

But alas, I can't find anything anywhere about this, aside from on TerrainSceneNodes'.

Any help would be appreciated, thanks!
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

This is for S3DVertex2TCoords, but adapting it to other types isn't hard at all.

I use this for my custom terrain loaded as a mesh.

It needs a mesh, so if you don't mind using the extra memory, you could use the geometry creator to create a cube and then add an IMeshSceneNode.

Code: Select all

for(u32 i=0; i < mesh2->getMeshBufferCount(); ++i)
{
	irr::video::S3DVertex2TCoords* mb_vertices = (irr::video::S3DVertex2TCoords*)mesh2->getMeshBuffer(i)->getVertices();
	for(int j=0; j<mesh2->getMeshBuffer(i)->getVertexCount(); ++j)
	{
		mb_vertices[j].TCoords2.X *= 100;
		mb_vertices[j].TCoords2.Y *= 100;
	}
}

I hope it helps you.

- Josiah
Josiah Hartzell
Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

You shouldn't need to use the two texture coords vertices if you just want to tile the texture, you don't even need to edit the mesh.

Just set a texture matrix in the first TextureLayer of the material, and make sure the clamping settings don't prevent the texture from repeating.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

bitplane wrote:You shouldn't need to use the two texture coords vertices if you just want to tile the texture, you don't even need to edit the mesh.

Just set a texture matrix in the first TextureLayer of the material, and make sure the clamping settings don't prevent the texture from repeating.

My code tiles the second set of texture coordinates because I only wanted to tile the detail map. :wink:
Josiah Hartzell
Image
DarkDepths
Posts: 126
Joined: Sun Apr 02, 2006 1:21 am
Location: Canada

Post by DarkDepths »

Ah, thank you guys, I've got it working!
Post Reply