19.7 Billboards


19.7 Billboards

The previous section demonstrated how textures can be defined in scripts, which can be loaded at run time by OGRE to texture models and other geometry. Some of the most common uses for manually defined materials is for billboards and particle systems, the subject of this section and the following one. A billboard, one of the simplest primitive types in 3D, is a one-sided rectangular surface that has width and height, but no depth-like a sheet of paper. Primarily, programmers assign materials to billboards to present them and their materials to the camera. Practically then, it's a simple way to quickly show a 2D image in a 3D world. The billboard has a position in 3D space in that it may be near or far from the camera, or it may not be visible to the camera at all; however, a billboard has no independent orientation. That is, the billboard will always rotate to face the camera directly, and so the camera-wherever it may be-can never see the billboard from any angle other than 90 degrees. It will always face the billboard and its texture head-on.

19.7.1 Creating Billboards

image from book
Figure 19.1

OGRE streamlines the process of creating billboards into two classes: BillboardSet and Billboard. The scene manager is used to create a BillboardSet, and this class holds a list of billboards and references a texture that is to be shared between all billboards in the set. By default, each created billboard of the set will use the whole texture, but it is possible for each billboard in the set to show a different portion of the whole texture, meaning each billboard will look different and can be used for all kinds of animation effects. Consider the following code. It creates a billboard set, assigns a material, then creates a billboard and adds the whole set to the scene hierarchy. This example set contains only one billboard.

      BillboardSet *BSet = mSceneMgr->createBillboardSet("My Billboard Set", 5);      BSet->setMaterialName("Examples/CloudySky");      Billboard *BBoard = Bset->createBillboard(0,0,0);      BBoard->setDimensions(300, 300);      Node->attachObject(BSet); 




Introduction to Game Programming with C++
Introduction to Game Programming with C++ (Wordware Game Developers Library)
ISBN: 1598220322
EAN: 2147483647
Year: 2007
Pages: 225
Authors: Alan Thorn

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net