My Object3D just dont want to rotate.

Started by Melssj5, February 23, 2018, 12:12:15 AM

Previous topic - Next topic

Melssj5

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?
Nada por ahora

AeroShark333

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);

Melssj5

The Rotation Pivot is relative to the object?? OMG..... Thanks, I will try it
Nada por ahora

Melssj5

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.
Nada por ahora