1
Support / Adding a 3DS model with a texture
« on: October 27, 2012, 11:52:55 pm »I have the texture in jpctLoadModel02/res/drawable-hdpi called leaf1.jpg and the leaf1.3ds file in jpctLoadModel02 default folder.
Code: [Select]
String[] leafTexture = {"leaf1"};
String leafModelName = "leaf1.3ds";
InputStream isLeaf;
Object3D[] leafModel;
Then in the onSurfaceChanged method
Code: [Select]
Texture leafTex = new Texture(600,600);
for (int i = 0; i < leafTexture.length; ++i) {
TextureManager.getInstance().addTexture("res/"+leafTexture[i] + ".jpg");
}
//Modelname string to inputstream
try {isLeaf = new ByteArrayInputStream(leafModelName.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace(); }
leafModel = Loader.load3DS(isLeaf,1);
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
SimpleVector sv = new SimpleVector();
for (int i = 0; i < leafModel.length; ++i) {
leafModel[i].build();
world.addObject(leafModel[i]);
cam.lookAt(leafModel[i].getTransformedCenter());
sv.set(leafModel[i].getTransformedCenter());
}
In the logcat it shows as:
10-27 21:33:22.549: E/AndroidRuntime(401): FATAL EXCEPTION: main |
10-27 21:33:22.549: E/AndroidRuntime(401): java.lang.NoClassDefFoundError: com.threed.jpct.RGBColor |
10-27 21:33:22.549: E/AndroidRuntime(401): at ian.capstone.JpctLoadModel02Activity.<init>(JpctLoadModel02Activity.java:54) |
10-27 21:33:22.549: E/AndroidRuntime(401): at java.lang.Class.newInstanceImpl(Native Method) |
10-27 21:33:22.549: E/AndroidRuntime(401): at java.lang.Class.newInstance(Class.java:1409) |
10-27 21:33:22.549: E/AndroidRuntime(401): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) |
10-27 21:33:22.549: E/AndroidRuntime(401): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1536) |
10-27 21:33:22.549: E/AndroidRuntime(401): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638) |
10-27 21:33:22.549: E/AndroidRuntime(401): at android.app.ActivityThread.access$1500(ActivityThread.java:117) |
10-27 21:33:22.549: E/AndroidRuntime(401): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928) |
10-27 21:33:22.549: E/AndroidRuntime(401): at android.os.Handler.dispatchMessage(Handler.java:99) |
10-27 21:33:22.549: E/AndroidRuntime(401): at android.os.Looper.loop(Looper.java:123) |
10-27 21:33:22.549: E/AndroidRuntime(401): at android.app.ActivityThread.main(ActivityThread.java:3647) |
10-27 21:33:22.549: E/AndroidRuntime(401): at java.lang.reflect.Method.invokeNative(Native Method) |
10-27 21:33:22.549: E/AndroidRuntime(401): at java.lang.reflect.Method.invoke(Method.java:507) |
10-27 21:33:22.549: E/AndroidRuntime(401): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) |
10-27 21:33:22.549: E/AndroidRuntime(401): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) |
10-27 21:33:22.549: E/AndroidRuntime(401): at dalvik.system.NativeStart.main(Native Method) |
Am i suppose to use another kind of Loader method or am i just looping through them incorrectly. I thought i would only get one Object3d file and then add that into the world, but it always crashes on me.