Hi,
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
It isnt so much copypaste coding, its more that I SUCK at 3d math
Btw, I figured out was I was doing wrong 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)
geom.rotate(
(float)
((
// integer has bit 4, then rotate => (1 * Math.PI) else => (0 * Math.PI)
(block&4)==4?1:0)
// Pi for rotation
*Math.PI),
// repeat for last two bits on y (secondlast bit: 2) and z (last bit: 1)
(float)(((block&2)==2?1:0)*Math.PI),
(float)((block&1)*Math.PI)
);
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? https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies