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!
Tiling Textures?
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.
I hope it helps you.
- Josiah
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
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.
-
- Posts: 126
- Joined: Sun Apr 02, 2006 1:21 am
- Location: Canada