1
Support / Odd behavior of the translation
« on: January 26, 2011, 10:35:24 pm »
Since I'm actually about to learn how to use the engine, I tried to order 4 cubes in a pattern shown below in the "intended" image. For doing this I first created an object which extends the Object3D class:
Then I overrided the constructor:
In onSurfaceChanged I add the 4 fields to the scene:
That seems to work. In the simulator will be 4 cubes visible. But they are not positioned as I intended them to.
How I intended them to be positioned.
How they are positioned
The System.out reads like this, which should be the correct translations:
I also checked the rotation (because It looks like they where rotated by 45° and then translated) but the rotation Matrix is 0 except on the diagonal which should be a zero rotation.
Code: [Select]
public class Field extends com.threed.jpct.Object3D
Then I overrided the constructor:
Code: [Select]
public Field(int posX, int posY, Field next){
super(Primitives.getCube(10));
setXY(); //<-stuff for the getX / getY functions
matrix.translate(getX()*30,0 , getY()*30);
this.setTranslationMatrix(matrix);
}
In onSurfaceChanged I add the 4 fields to the scene:
Code: [Select]
for (com.theDiceGame.Field f : fields){
f.strip();
f.build();
System.out.println("Translation: "+f.getTranslation());
world.addObject(f);
}
That seems to work. In the simulator will be 4 cubes visible. But they are not positioned as I intended them to.
How I intended them to be positioned.
How they are positioned
The System.out reads like this, which should be the correct translations:
Code: [Select]
Translation: (0.0,0.0,0.0)
Translation: (30.0,0.0,0.0)
Translation: (30.0,0.0,30.0)
Translation: (0.0,0.0,30.0)
I also checked the rotation (because It looks like they where rotated by 45° and then translated) but the rotation Matrix is 0 except on the diagonal which should be a zero rotation.