Hello,
I try to create an array of 3D boxes and give them a particular color. My problem
is that the boxes stay gray.
// Add a light.
scene::ILightSceneNode* dirLight = smgr->addLightSceneNode(0, camera.getPosition(), video::SColorf(.5f, .5f, .5f), 50.f);
// Create 3D array of boxes.
for (int x = -50, i = 0; x < 50; ++x)
{
for (int y = -50; y < 50; ++y)
{
for (int z = -50; z < 50; ++z, ++i)
{
int r = rand() % 200;
if (r == 0)
{
core::vector3df pos;
pos.X = (f32) x;
pos.Y = (f32) y;
pos.Z = (f32) z;
f32 s = .25f + ((rand() % 25) / 25.f);
scene::ISceneNode* n = smgr->addCubeSceneNode(s, 0, i, pos);
for (u32 j = 0; j < n->getMaterialCount(); ++j)
{
n->getMaterial(j).DiffuseColor = video::SColor(255, 255, 0, 255);
n->getMaterial(j).AmbientColor = video::SColor(255, 127, 127, 127);
n->getMaterial(j).MaterialType = video::EMT_SOLID;
n->getMaterial(j).GouraudShading = false;
n->getMaterial(j).FogEnable = true;
n->getMaterial(j).NormalizeNormals = true;
}
}
}
}
Thank you for your answers,
azerty
Should be obvious
Re: Should be obvious
I wrote down some options for doing this in a recent post: viewtopic.php?t=53033
Hope that helps.
Hope that helps.
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: Should be obvious
Hello,
Thank you for your reply. Using EmissiveColor helped.
Thanks again,
azerty
Thank you for your reply. Using EmissiveColor helped.
Thanks again,
azerty