Should be obvious

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
azerty
Posts: 4
Joined: Wed Aug 07, 2024 6:08 pm

Should be obvious

Post by azerty »

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
CuteAlien
Admin
Posts: 9733
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Should be obvious

Post by CuteAlien »

I wrote down some options for doing this in a recent post: viewtopic.php?t=53033
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
azerty
Posts: 4
Joined: Wed Aug 07, 2024 6:08 pm

Re: Should be obvious

Post by azerty »

Hello,

Thank you for your reply. Using EmissiveColor helped.

Thanks again,
azerty
Post Reply