Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Handling m3g format (3D files for mobiles) in J2ME

Thu Oct 21, 2010 12:37 pm

Hai,

I am new to this forum. I am developing my first application in J2ME of handling m3g files which includes Loading of Model,Loading of Texture, Rotate Right, Rotate Left, Zoom in and Zoom Out.

Now loading of m3g image is done. Texture Loading is not happening.

I am loading car model as m3g file. For the same car the texture is not loading which is in Jpg or png formats.

Can you guide me how to load the texture.

The code which I am trying is given below for loading of model and texture.
java code
// loading of model 

G3D = Graphics3D.getInstance();
world = (World)Loader.load("/Swift/car.m3g")[0];
Object3D root[];
root=Loader.load(name);
world = (World) root[0];
mesh=(Mesh)world.find(4);

// loading of Texture

try
{
Image2D image2D = (Image2D) (Loader.load("/Swift/car_256.jpg")[0]);
//Image2D image2D = (Image2D) (Loader.load("/Swift/car_256.png")[0]);
Texture2D myTexture = new Texture2D(image2D);
myTexture.setFiltering(Texture2D.FILTER_NEAREST,Texture2D.FILTER_NEAREST);
myTexture.setWrapping(Texture2D.WRAP_CLAMP,Texture2D.WRAP_CLAMP);
myTexture.setBlending(Texture2D.FUNC_DECAL);

Appearance myAppearance = mesh.getAppearance(0);
myAppearance.setTexture(0, myTexture);
// myAppearance.setMaterial(iMaterial);
// iMaterial.setColor(Material.DIFFUSE, 0xFFFFFFFF); // white
//iMaterial.setColor(Material.SPECULAR, 0xFFFFFFFF); // white
//iMaterial.setShininess(100.0f);



} catch (Exception e) {
System.out.println("Error loading image " + "textureFile");
e.printStackTrace();
}
camera = world.getActiveCamera();
//camera.setScale((float)a, (float)b, (float)c);
camera.setScale(a,b,c);


What is happening with the above code is model is loading properly and able to rotate and zoom but the texture is not at all loading.

Then I interacted with the Graphics Team and finally they have given me m3g format file only which consists of its own textures as inbuilt. In this case what is happening is, the model is loading properly with the textures. But I am unable to rotate or zoom the model. If I click for rotate or zoom the model is hiding out of the screen and unable to monitor the X,Y,Z co-ordinates and Camera position.

I have referred and used the code which is given in the following link :
Code:
http://www.j2meforums.com/forum/index.php?topic=21154.0


So, please suggest me which is the best way for handling m3g and if possible please give me source code.



Post a reply
  Related Posts  to : Handling m3g format (3D files for mobiles) in J2ME
 PDF Format     -  
 Format Specifier in C     -  
 Format Debugging Messages     -  
 Number format for current     -  
 Number format function prototype     -  
 i want to draw a circle on a image(any format bmp,jpeg etc.)     -  
 Printing today+ current date with different format     -  
 database contents display in table format in swing     -  
 What is Event Handling?     -  
 Exception handling     -