04-25-2006 06:59 AM
04-25-2006 07:40 AM
04-26-2006 01:00 AM
04-26-2006 03:39 AM
04-26-2006 07:17 AM - edited 04-26-2006 07:17 AM
Message Edited by Moh on 04-26-2006 07:18 AM
04-26-2006 07:30 AM
animating a model can be done with the picture control and a state machine. A simple 30 frames per second can be achieved by
1. get tick 0 (get clock count).
2. update the model (physics based calculation) ie position of pendulum at model time (can be clock for soft realtime simulations or a simulated clock)
3. Draw the model (for a pendulum this is easy, draw cord is draw line from origin to bob center from calculation and draw bob which is a simple draw circle where the diameter is proportional to the mass)
4. Get tick 1 if tick 1 -tick 0 > 1/30sec wait the difference. no sense updating faster than 30Hz
Paul
04-26-2006 07:41 AM
Thanks Paul,
The big deal is in step no. 3 . For a simple pendulum, yes, it is easy ... it needs some calculations to determine the x and y coordinates of the ball and the end point of the cord. the cord has constant length.
more complicated work is on the way 🙂
Moh
04-26-2006 09:37 AM
Modeling of 2-d structures are not very difficult, essentially you will have 2 common methods for transforming objects, rototion and translation which are accomplished using simple matrix math and have been discussed on this forum before. One additional transformation is applise globally which I find useful is to translate the world coortinated by .5 screen height and .5 screen width and a scale which is simple units_of_measurment/max(pixels_screen_height, pixels_screen width). this is a very simplified version of what a rendering engine does interms of vertex rendering in 2-d. Remember all objects can be represented py polygons (arrays of verticies) which have been transformed through scale rotation and translation. 3-d is much more complicated but still doable (I would look into the opengl toolkits).
Paul