decal texture

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
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

decal texture

Post by Seven »

Trying to create a decal system which seems to be working as expected, except that the textures do not appear.

Code: Select all

 
inside the custom scenenode
 
                array<S3DVertex> m_Vertices;
 
            for (int z = 0; z < m_TempSize.Height; z++)
            for (int x = 0; x < m_TempSize.Width; x++)
            {
                m_Vertices.push_back(S3DVertex(x, 0, z, 0, 1, 0, SColor(255, 255, 255, 255), float(x/m_TempSize.Width), float(z/m_Size.Height)));
            }
 
            Material.Wireframe = false;
            Material.Lighting = false;
            Material.BackfaceCulling = false;
            Material.MaterialType = EMT_SOLID;
 
 
and I set the texture this way

Code: Select all

 
                  Node->setMaterialTexture(0, getDriver()->getTexture(MEDIAPATH("_Assets\\GUI\\physx.bmp")));
 
as I say, the wireframe mode works fine, so does the solid color mode, but I cant seem to ge the textures to show.
any help is appreciated.

Seven
manni63
Posts: 12
Joined: Tue Sep 27, 2016 6:23 am

Re: decal texture

Post by manni63 »

There is an error in your code calculating the texture coordinates:
When you calculate float(x/m_TempSize.Width) and x and m_TempSize.Width are integers, this is an integer division. According to C conventions, the result is the nearest integer below the resultof a float division. In your case this is 0 for all values except the last one which is 1. You should first convert your variables to float and then divide:

Code: Select all

 
m_Vertices.push_back(S3DVertex(x, 0, z, 0, 1, 0, SColor(255, 255, 255, 255), float(x)/float(m_TempSize.Width), float(z)/float(m_Size.Height)));
 
I assume m_Size.Height should be m_TempSize.Height ?
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

Re: decal texture

Post by Seven »

and that is what I enjoy about this forum. thanks for the help! all working fine now.
Post Reply