ROXIGA・COM

How to use HyperMotion3D

On Eclipse HyperMotion3D displays 3D character animation.

Roxiga.com

Install Android SDK and Eclipse.

Download HyperMotion3D.zip, copy to Eclipse Workspace. On Eclipse 'File'→'Import' menu, 'General'→'Existing Projects into Workspace', 'Select root directory' select Workspace, Projects select HyperMotion3D.

Coding HyperMotion3D.java like this, display character.

package com.vixar;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.opengl.GLU;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import com.roxiga.hypermotion3d.*;
import com.roxiga.models.*;

public class HyperMotion3D implements GLSurfaceView.Renderer
{
	private Context _context;
	//①Character instance
	private Model3D _obj;
	private Vector3D _eye = new Vector3D(1000.0f, 1000.0f, 1000.0f);
	private Vector3D _lookAt = new Vector3D(0.0f, 0.0f, 0.0f);
	private Vector3D _up = new Vector3D(0.0f, 1.0f, 0.0f);

	public HyperMotion3D(Context context)
	{
		_context = context;
		//②Generate instance
		_obj = new SharpHair();
	}

	public void onDrawFrame(GL10 gl)
	{
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT
				| GL10.GL_DEPTH_BUFFER_BIT);

		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();

		GLU.gluLookAt(gl,
				_eye._x,_eye._y,_eye._z,
				_lookAt._x,_lookAt._y,_lookAt._z,
				_up._x,_up._y,_up._z);
		//③Draw animation character
		_obj.draw(gl);
	}

	public void onSurfaceChanged(
    		GL10 gl, int width, int height)
	{
		gl.glViewport(0, 0, width, height);
		float ratio = (float) width / height;
		gl.glMatrixMode(GL10.GL_PROJECTION);
		gl.glLoadIdentity();
		GLU.gluPerspective(gl, 30.0f, ratio, 10f, 10000f);
	}

	public void onSurfaceCreated(
    		GL10 gl, EGLConfig config)
	{
		gl.glDisable(GL10.GL_DITHER);
		gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
				GL10.GL_FASTEST);
		gl.glEnable(GL10.GL_CULL_FACE);
		gl.glFrontFace(GL10.GL_CCW);
		gl.glEnable(GL10.GL_DEPTH_TEST);
		gl.glEnable(GL10.GL_TEXTURE_2D);
		gl.glClearColor(0.6f,0.8f,1,1);
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

		//④Import texture
		_obj.setTexture(gl,_context.getResources(),R.drawable.sharphair);
	}
}
	  

Just coding red ①~④, display character.
①Model3D class is exported with TransMotion or Vixar Motion.
②SharpHair is boy exported to 'HyperMotion3D\src\com\roxiga\models' folder.
③Display Animation character.
④Import texture. Texture is copy to 'HyperMotion3D\res\drawable' folder sharphair.jpg.