Tutorials

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.

Framework

Framework-related items are summarized under two headings: Program Architecture, and Execution of Animation.

Program Architecture

In the mobile phone Java environment, application is created on the assumption that VM and class libraries are implemented in the operating environment.
For easier understanding of MascotCapsule applications, let's examine the following two classes:

Application class

This class handles application's operation such as start-up, suspension, resuming, exiting, etc., as well as the Canvas class generation, etc. In MIDP environment, it is implemented as the extension of the MIDlet class.

Canvas class

This class handles the actual 3D rendering process. It defines various rendering parameters and methods, and executes initialization, display update, user interface process, etc. These processes are implemented as the extension of the Canvas class.


Execution of Animation

It is also important to know how the animation is executed. Let's briefly take a look at periodic display update, and double buffering.
Animation is executed by updating the display at regular intervals. In general, thread or timer event is used as a mechanism to initiate the display update process at regular intervals.

Using thread

Thread is generated and initiated during the initialization sequence. The code for processing the thread is written as the run() method of the associated objects. In the code, endless loop must be specified during the rendering. Typical looping constructs contain the following processes:

  • Pre-rendering process: Set-up, etc. for various rendering parameters
  • Rendering request: Normally, repaint() is called
  • Sleep mode at some interval: Normally, sleep() is called

After the rendering request (repaint() method), the system calls the actual rendering method (paint() method) at appropriate timing. The frame rate is determined according to the length of loop cycle.




Using timer event

Timer object is generated and initiated during the initialization sequence. The process to be initiated at regular intervals is written in the method that is called at timeout. The description includes the following processes:

  • Pre-rendering process: Set-up, etc. for various rendering parameters
  • Rendering request: Normally, repaint() is called
  • (Restarting the timer): Not necessary, if the repeat setting is available


Double buffering

In terms of animation, double buffering is also important. By separating the process for creating the next screen data to be rendered, and the process of actually rendering onto the screen, you can create the animation without flickers.

Among the embedded devices that currently support MascotCapsule, double buffering is often supported in the system itself. Therefore, we will not discuss the double buffering implementation in applications. If you need further information on implementation, please consult other reference materials that are commercially available.