Page 1 of 1

Decals, Materials and Texturing

PostPosted: Tue Mar 16, 2010 4:14 pm
by sacrebleu
can you elaborate on the details of the material class, its implementation of decals, texturing, color, whatever other parameters? tia


Re: Decals, Materials and Texturing

PostPosted: Mon Apr 05, 2010 8:59 pm
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
   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.

Re: Decals, Materials and Texturing

PostPosted: Sun Jun 27, 2010 4:21 pm
by sacrebleu
Your previous message didn't handle "decals"