【发布时间】:2011-12-11 11:13:17
【问题描述】:
我正在尝试从 assets/model.txt 加载我的顶点数组 我有 OpenGLActivity、GLRenderer 和 Mymodel 类 我将此行添加到 OpenGLActivity:
public static Context context;
这是 Mymodel 类:
Context context = OpenGLActivity.context;
AssetManager am = context.getResources().getAssets();
InputStream is = null;
try {
is = am.open("model.txt");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Scanner s = new Scanner(is);
long numfloats = s.nextLong();
float[] vertices = new float[(int) numfloats];
for (int ctr = 0; ctr < vertices.length; ctr++) {
vertices[ctr] = s.nextFloat();
}
但它不起作用(
【问题讨论】: