Basic Architecture of MascotCapsule Applications
This tutorial is designed for the developers who want to start using MascotCapsule. Let's take a look at the basic architecture of MascotCapsule applications.
3D Rendering Process
Let's take a look at the Canvas class, which plays the primary role in 3D rendering. 3D rendering process can be categorized as follows:
Initialization
- Loading the 3D data, and setting up the parameters, etc.
Display update
- Setting up 3D rendering parameters, and processing 3D rendering (Periodic start-up)
User interface process
- Processing key input, etc.
Please note that display update is actually processed in the following two steps:Periodic start-up
- 3D rendering parameter set-up #1, and the rendering request by calling the repaint() method
Actual rendering process (paint())
- 3D rendering parameter set-up #2, and calling the 3D rendering method (drawFigure())
If the repaint() method is called at the end of periodic start-up process, the system calls the paint() method at appropriate timing. Then, the drawFigure() method executes 3D rendering.
MascotCapsule V3 and later versions are capable of executing a combination of multiple functions, in order to perform 3D rendering processes.
3D rendering parameter set-up can be included in initialization, display update process, or user interface process without any restrictions. However, let's take a look at typical cases as follows:
Initialization
Various parameters are generated and initialized, and the data for MascotCapsule is loaded. Initialization is performed in constructors and each initializer, as well as in the initializer block or in the loop preprocessing of the thread's run() method. Typically, the following processes are included:
Generation of each parameter/Initial set-up
- Viewpoint set-up
- Lighting set-up
- Lighting support mode set-up
- Others
Loading each 3D data
- Model data
- Action data
- Texture data
- Texture data for environment mapping (not necessary if you do not use environment mapping)
- Primitive rendering data
Finally, primitive rendering data's int[] array will be passed to the renderPrimitives() method. Prior to this, there are no particular restrictions concerning data format or loading method.
Note: MascotCapsule is loaded not only during initialization, but also in the middle of processes such as switching actions, etc.
User interface set-up
- Soft key set-up
- Others
Display update process
As stated above, display update is processed in the following two steps:
- Periodic start-up
3D rendering parameter set-up #1, and the rendering request by calling the repaint() method
- Actual rendering process (paint())
3D rendering parameter set-up #2, and calling the 3D rendering method (drawFigure() method)
3D rendering parameter set-up can allocate any proportion of these processes. However, the general rule of thumb is to limit the actual rendering process (handled by the paint() method) to a minimum.
Periodic start-up
Usually, it is initiated at regular intervals, as a loop process within the run() method of the thread, or as a timer event process. Necessary data for actual rendering is set up, then the repaint() method is called to initiate the actual rendering.
Actual rendering process (paint())
Actual rendering process is handled by the paint() method. After the rendering request (repaint() method), the system calls the paint() method at appropriate timing. In this case, the remaining set-up processes of the above-mentioned periodic start-up will be performed, then the display is cleared. Finally, the drawFigure() method, which is the only MascotCapsule rendering execution method, will be called.
Note: MascotCapsule uses a single method, the drawFigure() method in order to execute the process for a series of coordinate system transformation, hidden surface removal, and pixel rendering.
Main rendering parameters of MascotCapsule are as follows:
- Rendering mode-related setting parameters (each rendering mode, lighting setting, etc.)
- Model posture setting parameters (action index, action frame value)
- Coordinate transformation parameters (transformation matrix, screen center, scale)
- Primitive rendering parameters
Rendering mode-related setting parameters
The following items can be specified.
- Rendering mode setting:
- Lighting support rendering mode
- Environment mapping mode
- Toon shading mode
- Semi-transparency mode
- Lighting setting:
- Directional light (direction and intensity)
- Ambient light (intensity)
- Toon shading level setting (threshold value, high, low)
- Projection method setting:
- Parallel projection
- Perspective projection
Model posture setting parameters
Loaded action data is used for specifying which action (determined by the action index), and the state of that action (determined by the action frame value).
Usually, animation effect is achieved by increasing and decreasing the action frame values based on the passing of time.
Coordinate transformation parameters
The following items can be specified:
- View coordinate transformation (transformation matrix)
- Screen coordinate transformation (screen center, scale)
In the end, MascotCapsule passes only one transformation matrix to the drawFigure() method. Therefore, in order to obtain a single composite matrix, matrix product must be calculated from rotation or view transformation matrices, prior to set-up.
MascotCapsule provides a variety of supporting methods for coordinate system transformation.
User interface process
This process executes the model's scaling, rotation, etc. by reflecting user operations such as key inputs to 3D rendering. This process itself is not unique to MascotCapsule, and consists of the common input processes as follows:
- Key input (numeric keypad, etc.)
- Soft key input
- Other

