Hi!
In your demo example, i'm trying to rotate object adround Y Axis like this:
public static final float NINETY_DEGREES = 1.570796327f;
.....
if (touchTurn != 0) {
cube.rotateY(NINETY_DEGREES);
touchTurn = 0;
}
and trying to get nomall vector of polygon, which i'm picking:
@Override
public void collision(CollisionEvent ce) {
ce.getTargets();
int[] ids = ce.getPolygonIDs();;
for (int i = 0; i < ids.length; i++){
Logger.log("poligon id is" + ids[i]);
}
Logger.log("name of picked object are " + this.getName());
TextureBox box = (TextureBox)ce.getObject();
if (box != null){
Logger.log("Normalized X Axis" + box.getXAxis().normalize().toString());
Logger.log("Normalized Y Axis" + box.getYAxis().normalize().toString());
Logger.log("Normalized Z Axis" + box.getZAxis().normalize().toString());
Logger.log("getTransformedNormals" + box.getPolygonManager().getTransformedNormal(ids[0]).toString());
}
}
so, i have only 4 direction when i'm rotating my cube. But i reciving a lot of different values when i try getAxis, and getTranformedNormall. Only at the first time i'm getting correct values. And i'm confused in this when i'm facing this problem.
Example:
1:
I/jPCT-AE ( 6221): Normalized X Axis(1.0,0.0,0.0)
I/jPCT-AE ( 6221): Normalized Y Axis(0.0,1.0,0.0)
I/jPCT-AE ( 6221): Normalized Z Axis(0.0,0.0,1.0)
I/jPCT-AE ( 6221): getTransformedNormals(-0.0,-0.0,-1.0)
2:
I/jPCT-AE ( 6221): Normalized X Axis(8.3051646E-7,0.0,1.0)
I/jPCT-AE ( 6221): Normalized Y Axis(0.0,1.0,-0.0)
I/jPCT-AE ( 6221): Normalized Z Axis(-1.0,0.0,8.3051646E-7)
I/jPCT-AE ( 6221): getTransformedNormals(-8.2651775E-7,-0.0,-1.0)
3:
I/jPCT-AE ( 6221): Normalized X Axis(-4.371139E-8,0.0,-1.0)
I/jPCT-AE ( 6221): Normalized Y Axis(0.0,1.0,-0.0)
I/jPCT-AE ( 6221): Normalized Z Axis(1.0,0.0,-4.371139E-8)
I/jPCT-AE ( 6221): getTransformedNormals(-6.357829E-8,-0.0,-1.0)
4:
I/jPCT-AE ( 6221): Normalized X Axis(-1.4424753E-6,0.0,-1.0)
I/jPCT-AE ( 6221): Normalized Y Axis(0.0,1.0,0.0)
I/jPCT-AE ( 6221): Normalized Z Axis(1.0,0.0,-1.4424753E-6)
I/jPCT-AE ( 6221): getTransformedNormals(-1.4623007E-6,-0.0,-1.0)
5:
I/jPCT-AE ( 6221): Normalized X Axis(-1.0,0.0,1.1364959E-6)
I/jPCT-AE ( 6221): Normalized Y Axis(-0.0,1.0,0.0)
I/jPCT-AE ( 6221): Normalized Z Axis(-1.1364959E-6,0.0,-1.0)
I/jPCT-AE ( 6221): getTransformedNormals(-1.1444092E-6,0.0,-1.0)
I don't the actual problem here...are you talking about these 1.1364959E-6-like things? If so, then these are inaccuracies that happen when dealing with floats and nothing to worry about.
Well, actually i confused about this values:
8.3051646E-7 or -4.371139E-8 or -6.357829E-8....
As said, these are inaccuracies due to the limitations of the floating point format. They are so close to 0 that it doesn't matter. Don't worry about them.
Hm, but with the normals vectors i,m tring to determine object position and orientation in world...
For it's rotation after picking, etc.
So , i thought use for this task unit vector, i mean polygon normals.
Maybe this task has another decision?
Well..yes...i don't get it... ???
What exactly, my task?) Or my decision? :)
Your actual problem...
Ok, i'll try to explain...
i have some object, and after picking it, i want to rotate it. Rotation can be in 4 directions - left, right, up, down.
For example:
i rotete object twice: to the left and to the right, rotation was around Y axis.
Then i rotate object up, and aafter i want to rotate it to the left. If i'll rotate it around y axis , that wil be wrong rotation, You agree?
Try to rotate it around the axes returned by get?Axis() instead.
Yes, i know, and i'm doing it right now. But i don't now the orentation of the object in the world.
So, at the moment i dont' know about which axish i must rotate object.
And for detection of orientation in the world i'm trying to use normalls, but they are returns some magic not normalls results(
It's bad practice to compare floating point numbers to a fixed value anyway. Us a range (-0.01-0.01 and 0.99-1.01 for example) and it should work fine.
Ok, thank you!
i will try!