Fabio Varesano wrote:

> However, I'm stuck on how to rotate my cuboid according to the angles
> calculated from the accelerometer. If I use the code posted above the
> animation become really slow and sloppy till almost not working.

If I understand your code correctly, you're reading one
sample from the accelerometer for each animation round.
But if the accelerometer is producing data faster than
the frame rate of your animation, this isn't going to
work.

For example, if your animation is running at 60fps and
the accelerometer is producing 300 readings/sec (as you
indicated in one of your posts), then your animation is
only using accelerometer data at one-fifth of the rate
needed to keep up, so it will lag further and further
behind.

What you need to do is, for each frame, take all the
accelerometer data that has come in since the last
frame, accumulate all their rotations and apply them
to the model, before rendering the frame. You may
want to use a separate thread to read the accelerometer
samples and put them in a queue for the animation
thread to process.

-- 
Greg

_______________________________________________
Soya-user mailing list
Soya-user@gna.org
https://mail.gna.org/listinfo/soya-user

Reply via email to