Page 11/36
2. Back properties same as front properties but for faces that would be normally invisible.
The back faces become visible only if the material is transparent and if back face culling is
off.
3. Texture in order for the texture to become visible you have to set disabled property off.
This property is by default on which means that the object is not using any texture. It is
colored and shaded with settings described by front and back properties. If you want to apply a
texture to the material uncheck disabled checkbox and load an image. Formats supported by
GLScene are bmp, jpg and tga. Then you have to set texture modulation to tmModulate for
realistic lightning. Remember that a light has to illuminate the object so you can see the
material. Another important thing is that texture should have the size of power of two. It
means 4,8,16,32,64,128,512
The length and width dont have to be the same. You can have
a texture 32 x 512. If you use a texture with size other than power of two it will be displayed
but it will also be much slower because GLScene will have to resize it.
At bottom of material editor there is material blending mode listbox selection. You can
specify how the material will blend or overlay other materials. Opaque blending mode creates a
solid surfaced object. Transparent blending will make it possible to see through the object. The
object can be uniformly transparent or the transparency can be defined by texture. Additive blending
combines the colors of the object with colors behind it.
Although each object can have its own material it is strongly advised to store the materials
you use in material library. Especially if many objects share the same texture. If you have 100 cubes
with the same texture and you load the texture to each cube it will occupy the memory of 100
textures. You can load this texture in material library once and let the 100 cubes refer to that texture.
To do this set Material.MaterialLibrary to the material library and Material.LibMaterialName to
the name of the material you want to use. Warning ! Objects have MaterialLibrary property
themselves, you have to use Material.MaterialLibrary !
Material library has one handy function: AddTextureMaterial. In this function you specify
new material name and image file to be loaded. A new material is added to the material library with
Texture.Disabled:=false and Texture.Modulation:=tmModulate.
GLCadencer
Most of the GLScene applications do real time rendering. The time element takes important
part here. We need some kind of time manager to deal with it. It is not a simple thing at all. First of
all we do not know how long will it take for the computer to render the scene. The camera may be
looking at complex geometry with a lot of polygons or the user may turn the camera away and no
polygons will be rendered. The program may run on an old hardware configuration or a top high-
tech PC with the latest CPU and graphics accelerator. These are factors you dont know in advance
and you must take them into account.
If you want to progress you scene over time add TGLCadencer on the form. It will take care
of proper synchronizing and updating objects frame by frame. You must assign it to
TGLScene.Cadencer property.
The process of rendering a frame results in event called Progress in GLScene. Every
GLScene object has onProgress event where you can code all extra actions to be executed every
time the scene is rendered. Double clicking on an object in object inspector adds onProgress event
to the form.
The progress procedure passes one important variable: deltaTime. It is a time period in
seconds that took since the last frame was rendered. The longer it is the more jerky the motion in the
scene will be. Ideal frame rate is 30 frames per second. DeltaTime would be 0.033333. Any time
GLScene beginner's guide, Jan Zizka, 2005