I think you're looking at an old version of the code, Greg; I just looked at http://pastebin.com/mYiB9dWh, and saw a thread that was used an infinite loop to poll the serial port.
Fabio, the easiest route would probably be keeping the previous rotation value around, finding the difference between the current and previous rotation values, and using that with turn_x(). I haven't seen APIs to support anything else (reset-then-turn, set-rotation), but if they're there (particularly set-rotation-relative-to-original-local-axis), that would be more straightforward. David Bliss Percopo 232 1-616-284-1273 CM 1534 On Sun, Aug 22, 2010 at 7:23 PM, Greg Ewing <[email protected]>wrote: > 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 > [email protected] > https://mail.gna.org/listinfo/soya-user >
_______________________________________________ Soya-user mailing list [email protected] https://mail.gna.org/listinfo/soya-user
