I abandoned my previous project as I discovered someone else had a very similiar idea, and had much more done. So starting from scratch again.
-- First I would like to point out that it's far from done. I don't even know where I should create the VBO's, yet alone draw them. So here you go.
My loading screen activity:
package com.braindrool.game;import java.io.IOException;import java.io.InputStream;import java.nio.BufferOverflowException;import java.nio.ByteBuffer;import java.nio.ByteOrder;import java.nio.FloatBuffer;import java.nio.ReadOnlyBufferException;import java.nio.ShortBuffer;import java.util.ArrayList;import java.util.List;import java.util.StringTokenizer;import android.app.Activity;import android.content.res.AssetManager;import android.os.Bundle;import android.view.Window;import android.view.WindowManager;public class LoadingScreen extends Activity {FloatBuffer vertexBuffer;ShortBuffer indexBuffer;List<Float> vertices = new ArrayList<Float>();List<Short> indices = new ArrayList<Short>();@Overrideprotected void onCreate(Bundle savedInstanceState) {requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);super.onCreate(savedInstanceState);initializeModels();setContentView(R.layout.loading_screen);}@Overrideprotected void onPause() {// TODO Auto-generated method stubsuper.onPause();}private void initializeModels() {ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.size() * 4);vbb.order(ByteOrder.nativeOrder());ByteBuffer ibb = ByteBuffer.allocateDirect(indices.size() * 2);ibb.order(ByteOrder.nativeOrder());ibb.position(0);AssetManager am = getAssets();try {String[] files = am.list("models");System.out.println(files);for (int i = 0; i < files.length; i++) {loadModel("models/" + files[i]);}float[] floatArray = new float[vertices.size()];for (int i = 0; i < vertices.size(); i++) {Float f = vertices.get(i);floatArray[i] = (f != null ? f : Float.NaN);}System.out.println(vertices);System.out.println(indices);vbb.position(0);} catch (IOException e) {e.printStackTrace();} catch (BufferOverflowException e) {e.printStackTrace();} catch (ReadOnlyBufferException e) {e.printStackTrace();} catch (IndexOutOfBoundsException e) {e.printStackTrace();}}private void loadModel(String modelName) {AssetManager am = getAssets();System.out.println("Loading " + modelName);try {InputStream input = am.open(modelName);int size = input.available();byte[] buffer = new byte[size];input.read(buffer);input.close();String[] text = new String(buffer).split("¶");for (int i = 0; i < text.length; i++) {StringTokenizer vt = new StringTokenizer(text[i]);StringTokenizer it = new StringTokenizer(text[i]);while (vt.hasMoreTokens()) {if (vt.nextToken().endsWith("v")) {vertices.add(Float.parseFloat(vt.nextToken()));vertices.add(Float.parseFloat(vt.nextToken()));vertices.add(Float.parseFloat(vt.nextToken()));}}while (it.hasMoreTokens()) {if (it.nextToken().endsWith("f")) {indices.add(Short.parseShort(it.nextToken()));indices.add(Short.parseShort(it.nextToken()));indices.add(Short.parseShort(it.nextToken()));}}}}catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}
To summarize that, it loads in all models and adds them to an array successfully. Problem is not there. How would I go about actually creating the VBO's and implementing them into an OpenGL ES 1 renderer?
Help greatly appreciated!
~Braindrool
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment