
|
May 2005 |
[Back] | ||||||||||
|
| |||||||||||
|
Here we describe how you can use 3D sprites, and take advantage of their special behaviour, in Sony Ericsson mobile phones based on JP 3 (Java Platform 3) and JP 4. Read about Sony Ericsson's Java Platforms here>> A Sprite3D is just a 2D image in 3D space. Regardless of the camera angle, or the rotation of the world, the sprite will always be facing the camera. There are two types of sprites, Unscaled and Scaled:
The sprite's special behavior can be seen when using Sprite3D on a real target device based on JP 3 or JP 4. The sprite is not rendered at the same position and as shown by the examples below:
Knowing this, developers need to adapt applications to the target devices when using Sprite3D.
Also note, when using scaled sprites, the sprite must be scaled up to the same amount as the number of frames in the sprite (this is not needed on the emulator and you should check your target device how this is implemented).
Here is an example:
CompositingMode cm = new CompositingMode();
cm.setBlending(CompositingMode.ALPHA); Appearance appearance = new Appearance();
appearance.setCompositingMode(cm); … sprite3D = new Sprite3D(false, new Image2D(Image2D.RGBA, texImg), appearance); sprite3D.scale(10.0f, 1.0f, 1.0f); // if the sprite is built of 10 frames sprite3D.setCrop(0, 0, 10, 10); To mask out a special color, first specify this color when creating the png image, and then create the Image2D using RGBA also adding the CompositingMode to the appearance.
If you do scale a sprite, you will notice that when using the Transform class to move the sprite, the sprite will be translated multiplied by the scaling.
sprite3D.scale(6.0f, 1.0f, 1.0f);
sprite3D.translate(6.0f, 0.0f, 0.0f); // same result as postTranslate(1.0f, 0.0f, 0.0f); transform.postTranslate(1.0f, 0.0f, 0.0f)
sprite3D.setTransform(transform); To find out which phones belong to which Java Platform, please refer to MIDP 2.0 Developers' Guidelines>>
| |||||||||||
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.