Japanese | English | Korean

Samples

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.

private Figure figure; // Model data

/* 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 ) {
/* Initialize if exceeded the total number of appearance patterns */
pattern -= max_pattern;
}
figure.setPattern( ( 1 << pattern ) );

/* Changing the appearance pattern */
public void commandAction( Command c, Displayable d ) {
String label = c.getLabel();

/* Changing the appearance pattern */
if( label.equals( commandLabel ) ) {
/* Incrementing the parameter that represents the appearance pattern */
pattern++;

}
}