Lighting
Two lighting methods, ambient light and directional light are available in MascotCapsule V3. In order to use the light, create a Light object, and specify the created Light object as the first parameter of the Effect3D object. Let's take a look at how to set ambient light and directional light, after specifying the Light object setting.
Table of contents
1. Ambient Light
Ambient light evenly shines the light in the world from all directions. Only the white light is available in MascotCapsule V3. For ambient light, specify the intensity from 0 to 4096 in the setAmbIntensity( int intensity ) method in the Light class. The value 4096 represents the original color of the texture. The intensity value 0 represents no ambient light.
2. Directional light
Directional light shines the light in the world from one direction. Only the white light is available in MascotCapsule V3.
For directional light, specify the direction in setDirection( Vector3D direction ) and the intensity from 0 to 4096 in setDirIntensity( int intensity ) in the Light class. The intensity value 0 represents no directional light.
Ambient light and directional light can be combined; however, the maximum intensity of combined lights is 4096, which represents the original texture color. When the sum of the ambient light and directional light intensity exceeds 4096, the brightest spots will be adjusted to the intensity 4096.
![]() |
![]() |
![]() |
![]() |
| Ambient light + Directional light | Ambient light only | Directional light only | No light |
3. Sample code
The following is light settings in the sample code. In this sample, the soft key enables/disables the ambient light and directional light, respectively. Also, direction keys specify the direction of directional light.
private Light light = new Light( lightDir, dirIntensity, ambIntensity );
// Creating the Effect3D object
effect = new Effect3D( light, Effect3D.NORMAL_SHADING, true, null );
/**
* commandAction() method
* Process when the soft key is pressed-down (changing the rendering parameter)
*/
public void commandAction( Command c, Displayable d ){
/* Switching the light */
if( label.equals( commandLabels[ 0 ] ) ){
}
Quick Links
- MIDP + com.mascotcapsule package (MascotCapsule V3 API)
- Basic rendering
- Rendering a 3D model / Semi-transparency using BlendHalf / Additive and subtractive blending effects / Switching the animation data / Switching the pattern using dynamic polygons / Lighting / Shading / Using the environment map / Rendering the primitives / Reducing the texture distortion / Preventing Z-sort rendering mistakes under certain circumstances / Coordinate systems and the camera / Projection methods
- Basic rendering
- Go back to Samples index





