Author Topic: Object3D.translate precision  (Read 2412 times)

Offline Mr_Chaos

  • int
  • **
  • Posts: 57
    • View Profile
Object3D.translate precision
« on: January 19, 2015, 09:18:46 pm »
I have a very strange problem.

I move some objects using based, but when the speed gets low, my calculations seem to go wrong.

I run my program at 16ms pr. tick

I have an object moving at 0.5 pr second, with a vector of (-0.65774244,0.0,0.7532429)

Code: [Select]
    _translation.set(_currentDirection);
    _translation.scalarMul((_currentSpeed * time) / 1000f);
    _object.translate(_translation);

But the tote doesn't follow the line at all, so I'm wondering if I'm hitting the edge of what a float and thereby Object3D.translate can support ?

If it runs at

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Object3D.translate precision
« Reply #1 on: January 19, 2015, 11:13:24 pm »
If it runs at
Isn't there something missing?  ???

Apart from that...maybe. Have you printed out the actual values that you are getting? You can always try to make the calculations on your own as doubles and only feed the result back into the SimpleVector for the translation. If accuracy is a problem, that might help. Another option is you blow up your complete scale by some factor, but depending on your scene setup, this might require some work...

Offline Mr_Chaos

  • int
  • **
  • Posts: 57
    • View Profile
Re: Object3D.translate precision
« Reply #2 on: January 20, 2015, 08:36:03 am »
If it runs at
Isn't there something missing?  ???

Apart from that...maybe. Have you printed out the actual values that you are getting? You can always try to make the calculations on your own as doubles and only feed the result back into the SimpleVector for the translation. If accuracy is a problem, that might help. Another option is you blow up your complete scale by some factor, but depending on your scene setup, this might require some work...

My bad, think I hit enter too quickly. It turns out my problem was the precision of floats, not anything JPCT related.

I get my data from some other database, to the model is not centered around 0,0,0, but around some arbitrary point, which in this case means my object is located at 53434.4,-2.1790001,-83023.28 and I want to translate it (-0.65774244,0.0,0.7532429), which doesn't work.

By changing my models to be centered around 0,0,0 the translation works perfectly.