
|
September 2005 |
|
|
| |
|
Mascot Capsule v3 supports multiple textures for a figure, however multi-texturing is not supported, i.e. you can not add a texture on top of another texture. Keep in mind that all textures loaded in Mascot Capsule v3 are stored as 256x256 images on the heap regardless of previous size. Here we will create a MIDlet using two separate textures. Download example source code>>
When a figure is exported from a 3D authoring program, a BAC file is created. The BAC file is a text file that stores the figure data. The data in the file can be edited either with the PAC tool or manually. The BAC file can't be loaded as a Figure using the Mascot Capsule v3 API, so first a mbac file must be created from the BAC file using the "Micro3DConv_sony_Ericsson" tool. The "PVMicro" tool can be used to view the final result of the figure before using it in the MIDlet. If we take a look at the BAC file we can see the specified texture coordinates and last in the file we can see how the coordinates are used to build the figure. ( TextureCoords
( f2 0.0005 0.9995 ) ( f2 0.9995 0.9995 ) ( f2 0.9995 0.0005 ) ( f2 0.0005 0.0005 ) ) ; TextureCoords ( Polygons; number of faces: 6 ; mat vertex indices texture coord. indices ( face 0 ( i4 0 1 2 3 ) ( i4 2 3 0 1 ) ) ( face 0 ( i4 4 5 6 7 ) ( i4 2 1 0 3 ) ) ( face 0 ( i4 8 9 10 11 ) ( i4 2 1 0 3 ) ) ( face 0 ( i4 12 13 14 15 ) ( i4 2 3 0 1 ) ) ( face 0 ( i4 16 17 18 19 ) ( i4 0 3 2 1 ) ) ( face 1 ( i4 20 21 22 23 ) ( i4 1 0 3 2 ) ) ) In this table the "mat" (material) is zero for all faces except the last one, where it's 1. And the materials don't have the same texture.
When loading the textures we must store them in an array.
Here is a code example: cubeFigure = new Figure("/cube.mbac");
textures = new Texture[] {new Texture("/image.bmp", true), new Texture("/se_turtle.bmp", true)}; cubeFigure.setTexture(textures);
…
g3d.renderFigure(cubeFigure, 0, 0, layout, effect);
To achieve the same result for a primitive, we must merge the two images into one image. In this example, the two 96x96 images are merged into one 192x96 image. Note that it is also possible to use two textures within the same image for a figure.
![]() Here is how you specify the texture coordinates to make the turtle appear on one of the faces.
private int[] tex = {
192, 0, 96, 0, 96, 96, 192, 96, 0, 96, 96, 96, 96, 0, 0, 0, 0, 96, 96, 96, 95, 0, 0, 0, 0, 96, 96, 96, 95, 0, 0, 0, 0, 96, 96, 96, 95, 0, 0, 0, 0, 96, 96, 96, 95, 0, 0, 0}; The tools used can be found here>>
| |
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.