Author Topic: Black texture loading .3ds model  (Read 2197 times)

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Black texture loading .3ds model
« on: May 05, 2013, 05:25:05 pm »
Hi Egon,

When I tried to load 3ds model into jpct-ae, it showed the 3D object with black texture. Did I miss something? I did exactly like in JPCT wiki tutorial. I'm using Blender 2.66a to export the 3ds. If I call calcTextureWrapSpherical(), the texture shows. Unfortunately, I want it to follow the texture mapping in 3ds instead of jpct texture wrapping.

Code:
Code: [Select]
//onSurfaceChanged
try {
Object3D obj = load3DSModel(context.getAssets().open("monkey.3ds"), 20);
obj.setName("monkey");
obj.build();
world.addObject(obj);
} catch (IOException e) {
Log.e("kkl", "Error reading 3ds", e);
}

private Object3D load3DSModel(InputStream is, float scale) {
Object3D[] model = Loader.load3DS(is, scale);
Object3D o3d = new Object3D(0);
Object3D temp = null;
for (int i = 0; i < model.length; i++) {
temp = model[i];
temp.setCenter(SimpleVector.ORIGIN);
temp.rotateX((float) (-.5 * Math.PI));
temp.rotateMesh();
temp.setRotationMatrix(new Matrix());
o3d = Object3D.mergeObjects(o3d, temp);
o3d.build();
}
return o3d;
}

Log:
Code: [Select]
05-05 23:23:04.348: I/jPCT-AE(15498): Loading file from InputStream
05-05 23:23:04.348: I/jPCT-AE(15498): Expanding buffers...16384 bytes
05-05 23:23:04.348: I/jPCT-AE(15498): File from InputStream loaded...16026 bytes
05-05 23:23:04.348: I/jPCT-AE(15498): Processing new material leafmat!
05-05 23:23:04.353: I/jPCT-AE(15498): Processing object from 3DS-file: Suzanne
05-05 23:23:04.418: I/jPCT-AE(15498): Object 'Suzanne_jPCT0' created using 968 polygons and 505 vertices.
05-05 23:23:04.468: I/jPCT-AE(15498): Normal vectors calculated in 37ms!
05-05 23:23:04.468: I/jPCT-AE(15498): Memory usage before compacting: 19105 KB used out of 19783 KB. Max. memory available to the VM is 49152 KB.
05-05 23:23:04.683: I/jPCT-AE(15498): Memory usage after compacting: 14468 KB used out of 19783 KB. Max. memory available to the VM is 49152 KB.
05-05 23:23:04.763: I/jPCT-AE(15498): Subobject of object 2/monkey compiled to indexed fixed point data using 2904/505 vertices in 55ms!
05-05 23:23:04.763: I/jPCT-AE(15498): Object 2/monkey compiled to 0 subobjects in 77ms!

« Last Edit: May 05, 2013, 05:39:29 pm by kkl »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Black texture loading .3ds model
« Reply #1 on: May 05, 2013, 06:59:50 pm »
If it appears after calling calcTextureWrap, i see no other reason than that the coordinates in the file aren't present or that they aren't correct. Can you upload the file for verification?

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Black texture loading .3ds model
« Reply #2 on: May 06, 2013, 03:58:46 am »
Ok. I've attached 3ds file and a snapshot from Blender.

[attachment deleted by admin]

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Black texture loading .3ds model
« Reply #3 on: May 06, 2013, 05:11:44 pm »
Hi Egon, I think I found the solution.

These are the following steps I did:
1. Create object
2. Open uv/image editor to open image in object editor mode. (I think this part does the texture coord mapping)
3. Set material and texture for the object by opening the same image (I think this part creates the texture name in order to link the texture name to TextureManager in JPCT, but not texture coord mapping)
4. Export the 3ds, and there, it worked!

I'm not sure if I'm doing it correctly, but somehow it worked! Hope this would help the rest of developers who have the same problem too ; )