Loading a 3DS file (min3D framework for Android)

Posted by Dennis on May 19, 2010 in 3D, Android13 comments

NOTE: This OpenGL ES 1.1 framework isn’t maintained anymore. Check out the OpenGL ES 2.0 Rajawali framework which also supports live wallpapers.

Another update to the min3D framework for Android. A new parser that allows you to load in 3DS files (used by the Autodesk 3ds Max 3D modeling, animation and rendering software).

In the previous tutorials (Loading 3D models with the min3D framework for Android and Loading multiple 3D objects from an Obj file (min3D for Android)) there are some basic instructions regarding resource names that apply to this bit of code as well.

Here’s the code (can be found in the Google Code repository as well):


package min3d.sampleProject1;

import min3d.core.Object3dContainer;
import min3d.core.RendererActivity;
import min3d.parser.IParser;
import min3d.parser.Parser;

public class ExampleLoad3DSFile extends RendererActivity {
	private final float CAM_RADIUS_X = 20;
	private final float CAM_RADIUS_Y = 15;
	private final float CAM_RADIUS_Z = 30;
	private final float ROTATION_SPEED = 1;
	private Object3dContainer monster;
	private float degrees;

	@Override
	public void initScene() {
		IParser parser = Parser.createParser(Parser.Type.MAX_3DS,
				getResources(), "min3d.sampleProject1:raw/monster_high");
		parser.parse();

		monster = parser.getParsedObject();
		monster.scale().x = monster.scale().y = monster.scale().z  = .5f;
		monster.position().y = -10;
		scene.addChild(monster);

		scene.camera().target = monster.position();
	}

	@Override
	public void updateScene() {
		float radians = degrees * ((float)Math.PI / 180);

		scene.camera().position.x = (float)Math.cos(radians) * CAM_RADIUS_X;
		scene.camera().position.y = (float)Math.sin(radians) * CAM_RADIUS_Y;
		scene.camera().position.z = (float)Math.sin(radians) * CAM_RADIUS_Z;

		degrees += ROTATION_SPEED;
	}
}

Here’s the result (click the image to see the youtube video):



Tags: , , , , ,


13 comments

» Comments RSS Feed
  1. Wow you’re getting amazing performance in the emulator, I would have thought you’d only get a couple of FPS, have you installed a real libgl.so somehow? Obviously I expect this to FLY on the device ;)

  2. Haha no, I sped up the video a bit. Emulator performance is terrible to say the least. Do you happen to know of an application that can grab a video from the handset?

  3. Hmm none that I have heard of yet sorry. Maybe this:

    http://www.androidguys.com/2009/01/30/projecting-android-on-the-big-screen/

  4. I have DroidEx working now, don’t forget to also download the dependency args4j-2.0.16.jar, I can show you Thurs if you are around.

  5. Help! I am getting a Rescourses$NotFoundException when debugging ExampleLoadObjFile and ExampleKeyframeAnimation at the line that reads “parse.parse();” I have no idea why this is happening.

  6. The following wouldn’t work for me, because the parsing was involved

    ExampleKeyframeAnimation
    ExampleLoad3DSFile
    ExampleLoadMD2File
    ExampleLoadObjFile
    ExampleLoadObjFileMultiple
    SplashActivity

  7. I’ve downloaded and am able to run the example just fine – but when I try to export a very simple model (as either obj or 3ds) it crashes for me. Do you have any more specifics about how to export the model properly in 3DS Max 2010?

    Just FYI – it compiles fine, it just crashes when it tries to load my model as opposed to yours. I also tried with uv coordinates and without – but it made no apparent difference.

    I’d appreciate any help you might be able to offer.

    Thanks!

  8. Hi,

    Just passing by as I am interested in getting in to Android 3D graphics for game development and did wonder about whether somebody had done this. I am glad they have. Nice work. Any details on framerate on an HTC Desire handset with Froyo 2.2 or later?

    Anyway, exporting 3DS Max models has a lot of options and is very version dependent. It is critical to know the version used for this demo and its default settings for saving .3ds models. Then we can apply these settings to whatever version of 3DS Max we’re using and it should work – providing we are using the same version or later.

  9. I can also run the example and small sized(50kb) 3ds objects exported from blender. But when I try to load 500kb 3ds file, there is a crash. I would appreciate some help, thank you.

  10. Hi Kiran,
    There’s a limitation to the size of the objects that you can use. How many vertices are in the model?

  11. Hi,
    I’m just starting on android programming and still very early in the learning process, so i would like to ask, is it possible to load a 3ds model with a AnimationObject3d class? I’ve tried with Object3dContainer and it loads fine, but when i tried it with AnimationObject3d, i keep getting a null pointer exception.

    Thanks.

  12. oh sorry i realized your 3ds importer does not support animated objects.

  13. where can i get the Min#d library for android… Anyone plz reply ASAP

Leave a comment