www.jpct.net
jPCT-AE - a 3d engine for Android => Support => Topic started by: Melssj5 on February 23, 2018, 12:12:15 am
-
Hi guys, I am building a car instrument cluster with jpct, I am trying to move the rpm and speedometer needles but they just dont rotate.
I have a small object where the needle pivot should be. I am doing this:
speed_neddle.setRotationPivot(speed_pivot.getROtationPivot());
speed_neddle.rotateZ(any value);
but it just wont move.
Any ideas?
-
I don't think you want to use the rotation pivot like this:
speed_neddle.setRotationPivot(speed_pivot.getROtationPivot());
A rotation pivot is a point relative to the Object3D where you want to pivot around.
So I'd think you'll need to SimpleVector that's the difference between the two Object3D's.
SimpleVector diff = speed_pivot.getTransformedCenter();
diff.sub(speed_neddle.getTransformedCenter());
speed_neddle.setRotationPivot(diff);
-
The Rotation Pivot is relative to the object?? OMG..... Thanks, I will try it
-
SOLVED: The problem was neither the pivot center nor the maths. The problem was that I was referencing and moving an Object3D and adding another one to the world. I fixed this and everything is working.