<- previous index next ->
Motion can be useful and impressive. If your program must do a lot of computation for each movement, you will need to "double buffer". With double buffering your program is building the next screen in RAM while the previous screen is seen by the user. Then the buffers are swapped and the user sees the new screen and your program builds the next screen in the other RAM buffer. Examples to be demonstrated: 2D single_double.c - buffers in OpenGL (motion) (also multiple windows) 3D split_cube.c - speed control (motion) split_cube6.c - speed control (motion) robot2.c - connected limbs movement (motion) pilot.c - game, exercise (motion) planets.c - education, more on lighting later (motion) SphereMotion.java - moving 3D lights (motion) trackball.c - user control of view skyfly - game, training, demo (motion) draw3D1.java - evolving 3D data entry (multiple windows) threads, manual menu draw3D2.java - evolving four_windows.c - display multiple windows in OpenGL robot2.c was an interesting exercise. robot.c I considered not much to talk about dynamic.c A follow-on is some way, of robot.c was hard to read. My approach was to copy dynamic.c to robot2.c and make the following changes, in order, compiling (fixing) and running (fixing) each change. I could not see the lower leg from the upper leg, thus I changed the colors for various body parts. Since this was a 'lighting' scene, it was a matter of changing the emitted light to white and covering the various limbs with material of various colors. Now that I could see the motion better, I wanted to make the robot bend, not just turn. Yuk! The code used numbers, 1, 2, 3 ... rather than named numbers for the angles. Thus I went through and changed all references, menu, angle[?] and a few others to names, #define's. This really helped me understand the code because I had to look at every section. With menu and angles and rotations named, it was easy to add two menu items, one to increase motion per click, another to decrease motion per click. Now it was easy to add bend to the torso because I had seen that the head could both rotate and bend, just cut-and-paste with some name changing. When I lifted both legs, the robot did not lower itself, unreal. Thus I added keyboard function for 'x', 'X', 'y' and 'Y' so the robot could be moved. Future ideas are to "fix" the upper and lower limbs to both rotate up and down and sideways like real limbs. Then add "hands" with some kind of grip. Texture map the face. Change cylinders to ellipsoids. Be able to read and save a script of a sequence of motions. Oh! But if I did that, students could not use it as a project. P.S. somewhere along the way I added + and - so the "repeat" function of the keyboard would do what the mouse clicks would do, only faster. Thus there became a 'move' function, which now should be stripped of the cases and all of it executed every time.
<- previous index next ->