Decals, Materials and Texturing

Help with the Ecere 3D Graphics Engine: Camera, Mesh, Object, Material, OpenGL integration, etc.
Post Reply
sacrebleu
Posts: 27
Joined: Sun Jan 17, 2010 12:37 pm

Decals, Materials and Texturing

Post by sacrebleu »

can you elaborate on the details of the material class, its implementation of decals, texturing, color, whatever other parameters? tia

-s
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: Decals, Materials and Texturing

Post by jerome »

At the moment the Material class is quite simplistic.

Code: Select all

public class MaterialFlags { public bool doubleSided:1, translucent:1, tile:1, noFog:1, singleSideLight:1; };
public class Material : struct
{
public:
   Material prev, next;
   char * name;
   float opacity;
   ColorRGB diffuse;
   ColorRGB ambient;
   ColorRGB specular;
   ColorRGB emissive;
   float power;
   Bitmap baseMap;
   Bitmap bumpMap;
   Bitmap envMap;
   MaterialFlags flags;
};
It supports separate diffuse, ambient, specular and emissive colors, which of course blend in with both the ambient light and the light sources in the scene. It has a separate opacity value, which can range from 0.0f to 1.0f. And a power (exponent) which defines the specular shininess.

Then you can specify a texture in 'baseMap', using the familiar 'Bitmap' object (which you can obtain from a loaded BitmapResource). The bumpMap and envMap are meant to be used for bump mapping and environment mapping, but are currently not implemented in any driver. Texture coordinates are specified in the Mesh class.

The flags 'member' lets you specify boolean options, such as whether the rendered geometry should be doubleSided, whether extra care should be taken because it is translucent, whether the texture should be tiled, whether fog should be applied, whether light computations should be done on a single side...

Materials, textures and meshes can be managed in a DisplaySystem by name using the methods AddMaterial(), GetMaterial(), RemoveMaterial(), ClearMaterials(), AddNamedMaterial(), AddTexture(), GetTexture(), RemoveRexture(), ClearTextures(), AddMesh(), RemoveMesh(), ClearMeshes(). Note that is is purely provided for convenience purposed and is fully optional. The 3DS model loader however will make use of this automatically (for textures and materials). Remember that multiple displays of the same type share a same DisplaySystem, so that e.g. you can have multiple OpenGL windows sharing all the same data. In full screen mode there is actually only one Display, and obviously only one DisplaySystem as well.

A material is usually set on a Mesh's PrimitiveGroup. It can also be set on an Object as a default for PrimitiveGroups that do not specify a material. ApplyMaterial() can be used to apply a material to all groups in a mesh. ApplyTranslucency() should be called on a mesh (after having properly set the 'translucent' flag to true in the translucent materials) so that translucency is rendered properly.
sacrebleu
Posts: 27
Joined: Sun Jan 17, 2010 12:37 pm

Re: Decals, Materials and Texturing

Post by sacrebleu »

Your previous message didn't handle "decals"
Post Reply