What I want is to have static ray-traced shadows in a ITerrainSceneNode. I do know the algorithms to get the shadow map, but what I don't know is how to get that data into my ITerrainSceneNode.
I've searching through google and in the forums and got this thread: http://irrlicht.sourceforge.net/phpBB2/ ... 326efd542a
However they did not achieve anything at all.
What I was trying to do is to access each vertex and change the color, and this is the function I made using assembled pieces of code and my own xD:
Code: Select all
void setVertexLight(irr::scene::ITerrainSceneNode* node, unsigned char *lightmap)
{
irr::scene::CDynamicMeshBuffer* buffer = NULL;
unsigned int vertexCount = 0;
// we need to know the total number of vertices
const unsigned int numVertices = node->getMesh()->getMeshBuffer(0)->getVertexCount();
try
{
// a fount this in the Irllicht's sources of CTerrainSceneNode
if (numVertices <= 65536)
{
//small enough for 16bit buffers
buffer = new irr::scene::CDynamicMeshBuffer(irr::video::EVT_2TCOORDS, irr::video::EIT_16BIT);
}
else
{
//we need 32bit buffers
buffer = new irr::scene::CDynamicMeshBuffer(irr::video::EVT_2TCOORDS, irr::video::EIT_32BIT);
}
// get the mesh data for LOD 0
node->getMeshBufferForLOD(*buffer, 0);
// should be the same as the numVertices - you can test for that
vertexCount = buffer->getVertexCount();
}
catch (std::bad_alloc)
{
// If the heightMap allocation fails, this will be already allocated.
if (buffer != NULL) buffer->drop();
return;
}
for (unsigned int i = 0; i < vertexCount; i++)
{
buffer->getVertexBuffer()[i].Color.set(255, lightmap[i],lightmap[i],lightmap[i]);
}
buffer->drop();
}
And, maybe I'm wrong, but I supposed that changing the color of a vertex meant changing the color of the texture on top of it (something as OpenGL does).
Just to be sure that the piece of code that didn't work was that I changed lightmap with zeros and 255's and nothing happened.
I'm running out of ideas , please help.
And thanks in advance.