Hi,
I want to create dynamically-sized walls in my game. I am able to achieve that using a (1,1,1) sized box and scaling it to the right size. However, I do not wish the texture of the wall to get scaled as well. I'd like it to repeat. Is this possible?
Thanks
repeat texture instead of scaling it
Re: repeat texture instead of scaling it
your texture is not scaled, it is mapped one time to your scaled box. (u=1,v=1)
so you have to scale your uv-coords to get repetition by say u=width, v=height times.
so:
core::matrix4 scale;
scale.setTextureScale( (f32)width/10.0f, (f32)height / 10.0f);
node->getMaterial(0).setTextureMatrix(0, scale);
so you have to scale your uv-coords to get repetition by say u=width, v=height times.
so:
core::matrix4 scale;
scale.setTextureScale( (f32)width/10.0f, (f32)height / 10.0f);
node->getMaterial(0).setTextureMatrix(0, scale);
Re: repeat texture instead of scaling it
In SMaterial you can change the wrap-mode for each texture in the corresponding TextureLayer. There is TextureWrapU and TextureWrapV which take one of the values from E_TEXTURE_CLAMP: http://irrlicht.sourceforge.net/docu/na ... f84b39811f
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: repeat texture instead of scaling it
Thanks for the replies!
I tried to play with setTextureScale() for a while, but I can't get it to work for all 3 dimensions.
Here's what I'm trying to to:
data->SceneNode = m_SceneManager->addCubeSceneNode( 1.0f, NULL, -1, IrrUtils::Convert(wall->GetLocation()) );
data->SceneNode->setScale( wall->GetSizes() );
data->SceneNode->setMaterialTexture( 0, m_Driver->getTexture("Data/Graphics/Textures/wall.jpg") );
core::matrix4 scale;
scale.setTextureScale( wall->GetSizes().x / 10.0f, wall->GetSizes().y / 10.0f );
data->SceneNode->getMaterial(0).setTextureMatrix( 0, scale );
I can see the mistake - assuming the wall is scaled (0.5, 2.0, 25) I'm ignoring the Y scaling. However, I'm not sure how to fix this without neglecting one of the axises.
Do you have an idea?
Thanks
I tried to play with setTextureScale() for a while, but I can't get it to work for all 3 dimensions.
Here's what I'm trying to to:
data->SceneNode = m_SceneManager->addCubeSceneNode( 1.0f, NULL, -1, IrrUtils::Convert(wall->GetLocation()) );
data->SceneNode->setScale( wall->GetSizes() );
data->SceneNode->setMaterialTexture( 0, m_Driver->getTexture("Data/Graphics/Textures/wall.jpg") );
core::matrix4 scale;
scale.setTextureScale( wall->GetSizes().x / 10.0f, wall->GetSizes().y / 10.0f );
data->SceneNode->getMaterial(0).setTextureMatrix( 0, scale );
I can see the mistake - assuming the wall is scaled (0.5, 2.0, 25) I'm ignoring the Y scaling. However, I'm not sure how to fix this without neglecting one of the axises.
Do you have an idea?
Thanks
Re: repeat texture instead of scaling it
In other words - perhaps I'd like to have every face of the cube to treat the texture independently. Is that possible?
Re: repeat texture instead of scaling it
If the sides need to be completely independent then you need one meshbuffer for each side (more or less the definition of a meshbuffer - a part of the mesh with an own material). Meaning you have to create your own cube.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: repeat texture instead of scaling it
where can I see an example of creating a cube (or any other mesh) from scratch?
I found something called MeshWriter, but i don't think it's what i need...
Thanks!
I found something called MeshWriter, but i don't think it's what i need...
Thanks!
Re: repeat texture instead of scaling it
I think example 23.MeshHandling is about creating a mesh from scratch.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm