見下圖
展開後匯入Android並執行該程式,其執行結果如下圖:
下圖為上圖怪獸皮膚的貼圖
主要程式的列表如下:
package edu.android.suhas;
import java.io.IOException;
import java.io.InputStream;
import edu.union.graphics.IntMesh;
import edu.union.graphics.MD2Loader;
import edu.union.graphics.Model;
import android.app.Activity;
import android.os.Bundle;
public class suhas3d extends Activity {
InputStream is;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
is = getResources.openRawResource(R.drawable.tris);
MD2Loader ld = new MD2Loader();
ld.setFactory(IntMesh.factory());
try {
Model model = ld.load(is,0.1f,"skin.jpg");
if(model.getFrameCount() > 1)
setContentView(new GLView(this, model));
else
setContentView(R.layout.main);
}catch(IOException e) {
setContentView(R.layout.main);
}
}
}
沒有留言:
張貼留言