Hey guys,
I've got a float array camObjCoord
declared as..
public static float camObjCoord[] = new float[8000];
I'm then filling its indexes in a class that does something like the following..
public void addcube(float highx, float lowx, float highz, float lowz){
//Constructing new cube...
System.out.println("f = " + f);
Global.cubes++;
float y = 1.5f;
System.out.println("highx = " + highx + "lowx = " + lowx + "highz = " + highz + "lowz = " + lowz);
//FRONT
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = highz;
//BACK
i++;
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = lowz;
i++;
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = lowz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = lowz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = lowz;
i++;
//LEFT
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = lowz;
i++;
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = lowz;
i++;
//RIGHT
camObjCoord[i] = highx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = lowz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = lowz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = highz;
i++;
//TOP
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = y;
i++;
camObjCoord[i] = lowz;
i++;
//BOTTOM
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = lowx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = lowz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = highz;
i++;
camObjCoord[i] = highx;
i++;
camObjCoord[i] = -y;
i++;
camObjCoord[i] = lowz;
i++;
int p = 0;
System.out.println("FULL ARRAY");
while(p < 72){
System.out.println(camObjCoord[p]);
p++;
}
}
I'm then calling makeview()
public void makeview() {
Intent myIntent = new Intent(this, GLCamTest.class);
Bundle b = new Bundle();
b.putFloatArray("tweets", camObjCoord);
myIntent.putExtras(b);
this.startActivity(myIntent);
}
and then in the new class it's doing...
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle b = this.getIntent().getExtras();
float original[] = b.getFloatArray("tweets");
camObjCoord = original;
counter++;
}
I then have another class class GLLayer
and it looks like the following.. http://pastebin.org/394884 inside this class I'm drawing the cube(s) from the float array, I've check and the values for the cube are indeed there and when I'm coding the array in it works but when I'm dynamically building the array then passing it the cube doesn't draw. I'm calling the class like so..
glView=new GLLayer(this);
mPreview = new CamLayer(this, glView);
Anyone have any idea why? How would I fix my problem? Just to add, I am giving the exact same values to the exact same indexes when drawing dynamically
final static float camObjCoord[] = new float[] {
// FRONT
-2.0f, -1.5f, 2.0f,
2.0f, -1.5f, 2.0f,
-2.0f, 1.5f, 2.0f,
2.0f, 1.5f, 2.0f,
// BACK
-2.0f, -1.5f, -2.0f,
-2.0f, 1.5f, -2.0f,
2.0f, -1.5f, -2.0f,
2.0f, 1.5f, -2.0f,
// LEFT
-2.0f, -1.5f, 2.0f,
-2.0f, 1.5f, 2.0f,
-2.0f, -1.5f, -2.0f,
-2.0f, 1.5f, -2.0f,
// RIGHT
2.0f, -1.5f, -2.0f,
2.0f, 1.5f, -2.0f,
2.0f, -1.5f, 2.0f,
2.0f, 1.5f, 2.0f,
// TOP
-2.0f, 1.5f, 2.0f,
2.0f, 1.5f, 2.0f,
-2.0f, 1.5f, -2.0f,
2.0f, 1.5f, -2.0f,
// BOTTOM
-2.0f, -1.5f, 2.0f,
-2.0f, -1.5f, -2.0f,
2.0f, -1.5f, 2.0f,
2.0f, -1.5f, -2.0f,
};
Then it will render this cube. It appears to not like that I'm making the array and then dynamically adding indexes. Why? how do I fix this? For the bounty I would also accept an appropriate workaround which will work in Android.
Thanks.
edit1: I've tried various things it's not the passing of the array causing the problems if I was to declare the array like so...
edit2: I've also tried printing the array as it goes into GLLayer (class which renders cubes) and everything is as you would expect. I've no idea why these cubes wouldn't be appearing :(
edit3: I've added how I'm constructing the float arrays.
edit4: I've also tried setting the size of the array equal to the number of values I'm inputting. Doesn't work.