5
« on: November 02, 2012, 12:54:33 pm »
Hi Egon,
Unfortunately I don't have access to any of those devices. I own a couple of devices, and the code works fine on them.
I don't set any texture on the mesh, I just light it with some color, like this:
mKeyLight = new Light(mWorld);
mKeyLight.setIntensity(Color.red(meshColor), Color.green(meshColor), Color.blue(meshColor));
SimpleVector sv = new SimpleVector(mMesh.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sv.rotateY((float)(-Math.PI / 8.0f));
mKeyLight.setPosition(sv);
Note that I use two more lights, a fill light and a rim light, but I don't think that really matters. The only other mesh I have in the scene beside the main mesh, is a simple billboarded plane with a 256x256 texture.
In total, there are 6 512x512 textures for the skybox and 1 256x256 texture for the billboarded plane (and I'm still getting OOM errors on some devices [mostly mdpi 320x480 devices]). Since you asked for it, here's the code that assigns a texture to the billboarded plane:
String sunName = "sun" + sufix;
int id = res.getIdentifier(sunName, "drawable", mContext.getPackageName());
Log.d(TAG, "Loading new texture " + sunName);
tm.addTexture("light", new Texture(res.getDrawable(id), true));
// Create sun billboarded plane
Object3D sun = Primitives.getPlane(1, 3.0f);
sun.setBillboarding(true);
sun.translate(1.0f, -2.5f, -3.5f);
sun.setTexture("light");
sun.setTransparency(1000);
sun.setLighting(Object3D.LIGHTING_NO_LIGHTS);
sun.setAdditionalColor(RGBColor.WHITE);
sun.build();
mWorld.addObject(sun);
Maybe it has something to do with the number of polygons in the main mesh ? It has 6432 triangles, 3218 vertices... but please notice that I just use one mesh in the scene besides the simple billboarded plane.
P.D: I serialize the mesh with this code:
Object3D[] objs = Loader.loadOBJ(inputFileName, null, 1.0f);
for (Object3D obj : objs) {
obj.build();
}
String outputFileName = inputFileName.substring(0, inputFileName.lastIndexOf('.')) + ".ser";
new DeSerializer().serializeArray(objs, new FileOutputStream(outputFileName), true);
Thank you for your support.