3D box or cube Basic question

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
grantkrieger
Posts: 25
Joined: Fri Jul 27, 2007 10:02 am

3D box or cube Basic question

Post by grantkrieger »

Hello ,

Is there an easy way to draw a 3D rectangle and specify its color and dimensions.

I have seen the following but could not get it to work. I do not think I am doing the right thing

Box3D Box1 = new Box3D(new Vector3D(200, 200, 200), new Vector3D(400, 400, 400));
smgr.VideoDriver.Draw3DBox(Box1, new Color(100, 0, 255, 255));
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The code you've written should display a wireframe representing the box, but you need to set the world transformation and the material before you draw it. In C++ the code would look something like this...

Code: Select all

const core::aabbox3df box(-10, -10, -10, 10, 10, 10);

// transformation matrix
core::matrix4 matrix;
matrix.setTranslation(core::vector3df(20, 20, 20));

// material that ignores lighting
video::SMaterial material;
material.Lighting = false;

while (device->run())
{
  if (driver->beginScene(true, true, video::SColor(255, 100, 100, 100))
  {
    // render the scene
    smgr->drawAll();

    // render the gui
    gui->drawAll();

    // begin render the box
    driver->setTransform(video::ETS_WORLD, matrix);
    driver->setMaterial(material);
    driver->draw3DBox(box, video::SColor(255, 0, 255, 255));
    // end rendering box

    driver->endScene();
  }
}

device->drop();
Travis
Post Reply