Switching the pattern using dynamic polygons
MascotCapsule V3 can contain multiple patterns in the model data. You can render the model by specifying these multiple patterns.
Use the Figure.setPattern( int idx ) method in order to specify the model pattern.
The number of patterns within the model data is determined when the data is created. Use the Figure.getNumPattern() method in order to obtain the number of patterns.
There is a maximum of 33 model patterns including a common set. Assume each pattern as a bit in a 32bit data (the common set is 0), and then pass it in the Figure.setPattern() method.
This sample has the following 4 appearance patterns including the common set.
- Pattern 0: The face (this is the common set to all the patterns)
- Pattern 1: The face without eyes
- Pattern 2: The face with open eyes
- Pattern 3: The face with closed eyes
The rendering output becomes as described below:
- Figure.setPattern( 0 ) is a face of the common set.
- Figure.setPattern( ( 1 << 0 ) ) is a face without eyes.
- Figure.setPattern( ( 1 << 1 ) ) is a face with eyes open.
- Figure.setPattern( ( 1 << 2 ) ) is a face with eyes closed.
sample_comdot_v3_dynamic screenshots (from the left: Pattern 1, Pattern 2, and Pattern 3)
If the model has multiple independent appearance patterns, multiple portions can be simultaneously moved, for example, by specifying the method as follows:
Figure.setPattern ( ( ( 1 << 1 ) | ( 1 << 5 ) ) )
In this sample, the appearance pattern changes every time the soft key is pressed.
/* MascotCapsule work data for controlling the appearance */
private int pattern = 0; // Current appearance pattern
private int max_pattern = 0; // Total number of appearance patterns
figure = new Figure( "cap_dynamic.mbac" );
/* Obtaining the total number of appearance patterns */
max_pattern = figure.getNumPattern();
/* Specifying the appearance pattern setting */
if ( pattern >= max_pattern ) {
pattern -= max_pattern;
figure.setPattern( ( 1 << pattern ) );
/* Changing the appearance pattern */
public void commandAction( Command c, Displayable d ) {
/* Changing the appearance pattern */
if( label.equals( commandLabel ) ) {
pattern++;
}
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

