|
NeHe's OpenGL TutorialsWe never want to modify the object data in morph{1/2/3/4} directly. We modify the helper data to make it become one of the 4 shapes. Because we start out displaying morph1 (a sphere) we start the helper out as a sphere as well. After all of the objects are loaded, we set the source and destination objects (sour and dest) to equal morph1, which is the sphere. This way everything starts out as a sphere. objload("data/sphere.txt", &helper); // Load sphere.txt Object Into Helper (Used As Starting Point) sour=dest=&morph1; // Source & Destination Are Set To Equal First Object (morph1) return TRUE; // Initialization Went OK } Now for the fun stuff. The actual rendering code :) We start off normal. Clear the screen, depth buffer and reset the modelview matrix. Then we position the object on the screen using the values stored in cx, cy and cz. Rotations are done using xrot, yrot and zrot. The rotation angle is increased based on xpseed, yspeed and zspeed. Finally 3 temporary variables are created tx, ty ...» | Код для вставки книги в блог HTML
phpBB
текст
|
|