billboard suggestion

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
morris
Posts: 36
Joined: Tue Jul 10, 2007 10:10 am

billboard suggestion

Post by morris »

hi,

i've recently found a good and clean way to render billboards. i basically use the inverse of the view matrix and set it as "world transformation" in the driver. i believe this is much cleaner and maybe faster, although i havent tested that.

Code: Select all

/* put this in constructor */

Indices[0] = 0;
Indices[1] = 2;
Indices[2] = 1;
Indices[3] = 0;
Indices[4] = 3;
Indices[5] = 2;

Vertices[0].Pos = Size*vector3df(1,1,0);
Vertices[1].Pos = Size*vector3df(-1,1,0);
Vertices[2].Pos = Size*vector3df(-1,-1,0);
Vertices[3].Pos = Size*vector3df(1,-1,0);

Vertices[0].TCoords.set(1.0f, 1.0f);
Vertices[0].Color = shade_down;

Vertices[1].TCoords.set(1.0f, 0.0f);
Vertices[1].Color = shade_top;

Vertices[2].TCoords.set(0.0f, 0.0f);
Vertices[2].Color = shade_top;

Vertices[3].TCoords.set(0.0f, 1.0f);
Vertices[3].Color = shade_down;

/* new render method */

void CBillboardSceneNode::render() {

  // ...

  matrix4 mv = SMGR->getActiveCamera()->getViewMatrix();
  mv.makeInverse();
  mv.setTranslation(getPosition());

  // draw
  Driver->setTransform(ETS_WORLD, mv);
  Driver->setMaterial(Material);
  Driver->drawIndexedTriangleList(Vertices, 4, Indices, 2);
}
i'm currently planning to use this technique for a 3d-style HUD (heads-up-display), with rotating images which constantly are attached to the camera. i think this gives a lot of freedom for designing HUDs, especially for FPS and other action games where you dont have a mouse interactive interface.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Re: billboard suggestion

Post by MasterGod »

morris wrote:i'm currently planning to use this technique for a 3d-style HUD (heads-up-display), with rotating images which constantly are attached to the camera. i think this gives a lot of freedom for designing HUDs, especially for FPS and other action games where you dont have a mouse interactive interface.
I don't understand how this can't be done with the current code?
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
morris
Posts: 36
Joined: Tue Jul 10, 2007 10:10 am

Post by morris »

i don't want to use the billboardscenenode for that; just the view matrix technique.

you sure can do a 3d hud manually, but i think it would be nice to have an API for HUD-designing. irr's GUI does not have good elements for 3d huds. i'll post some screenshots these days so you can see what i mean.
Post Reply