Rotation madness


I’m hoping someone is willing to give me a hand here, I have a pretty annoying lil problem:

geom.rotate((float)(((block&4)==4?1:0)*Math.PI), (float)(((block&2)==2?1:0)*Math.PI), (float)((block&1)*Math.PI));

I call this line for 8 different blocks numbered 2-10, but somehow it doesnt rotate around one axis it seems to me. I have the feeling Im overlooking or not understanding something…

Any help would be nice :slight_smile:

It isnt so much copypaste coding, its more that I SUCK at 3d math :frowning:

Btw, I figured out was I was doing wrong :slight_smile: I was using x y and z rotation which made my rotations double up. I only need to use x and y…

Try write it into more than one line, maybee i can get what you are doing there then…

Also what is block?

block is an integer ranging from 2 to 255 (but could be further theoretically that wouldnt matter)




// integer has bit 4, then rotate => (1 * Math.PI) else => (0 * Math.PI)


// Pi for rotation


// repeat for last two bits on y (secondlast bit: 2) and z (last bit: 1)




I’m thinking that maybe the error could be in the fact that im using unsigned integers, but at second thought that wouldnt matter in java, it would in c. I hope its a bit clearer my problem now.

Lol, copy&paste coding sucks, eh? How about you try to do what you want using jME math?