Loading an animated MD2 file (min3D framework for Android)

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.

I just updated min3D for Android with an MD2 file importer.  MD2 is a format that was developed by ID Software and originally used for Quake II and other games. MD2 can be used for static models but the main reason for using it is animation.

Min3D is now able to import 3 different filetypes:

This is what the code looks like. Check out the min3D sample application to see it running:


package min3d.sampleProject1;

import min3d.animation.AnimationObject3d;
import min3d.core.RendererActivity;
import min3d.parser.IParser;
import min3d.parser.Parser;

public class ExampleLoadMD2File extends RendererActivity {
	private AnimationObject3d ogre;
	@Override
	public void initScene() {
		IParser parser = Parser.createParser(Parser.Type.MD2,
				getResources(), "min3d.sampleProject1:raw/ogro");
		parser.parse();

		ogre = parser.getParsedAnimationObject();
		ogre.scale().x = ogre.scale().y = ogre.scale().z = .07f;
		ogre.rotation().z = -90;
		ogre.rotation().x = -90;
		scene.addChild(ogre);
		ogre.setFps(70);
		ogre.play();
	}

	@Override
	public void updateScene() {

	}

}

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

Please note that it looks MUCH better on the phone.

Please note that it looks MUCH better on a handset.

  • Delicious
  • Facebook
  • Digg
  • Reddit
  • StumbleUpon
  • Twitter

11 thoughts on “Loading an animated MD2 file (min3D framework for Android)

  1. Luciano says:

    Very good your tutorial, thanks to him I’m using min3d md2 models in my project on Android, but do not know how can I detect which object in the User touched, I am tempted to onTouchEvent event but can not identify which model he selected on the screen, you know how I do it? sorry my English is bad.Any help is welcome thank you …

  2. Vladimir Milosevic says:

    Hi, example works great! I have one question, do you have to call parse on each initScene()? It can take a while to load file, I would rather remember state on pause/resume in member variable than to load from file each time.

    I tried keeping “ogre” object and adding it to scene on next init, but textures get lost during reset. Do you have some example of applying textures manually? I can solve it, but I would prefer to do it without changing your code.
    Thanks, Vladimir

  3. hello,, can you give me any hint how to link the skin files for .MD2 files?
    i use plugin for 3ds max and its only produce .pcx or .bmp for the skin file,
    i can load the model and animation,
    but the skin didnt loaded…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>