我正在尝试从assets/model.txt加载我的顶点数组我有OpenGLActivity,GLRenderer和Mymodel类我将此行添加到OpenGLActivity:
public static Context context;
Run Code Online (Sandbox Code Playgroud)
这到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();
}
Run Code Online (Sandbox Code Playgroud)
但它确实不起作用(