
|
A common feature in 3D games is to let the user change the viewpoint, thus enabling him or her to see the 3D world from different perspectives. This can sometimes be regarded as just a feature or a nice effect, but can sometimes be an integral part of the game. Whatever your objective, the technique to use isn't terriblly hard to master, however, the way to do it isn't quite what you'd expect. Rather than moving and rotating the camera to a different point in a 3D space before recalculating your scene, the common solution in 3D programming is to rotate and move your models while the camera remains still. Without going into any details, the reason for this behavior is purely practical. If you moved and rotated your camera, that would require more complicated 3D to 2D transformations than are necessary if you move and rotate the models instead. Note that you have to think a little "backwards" when rotating the world instead of the camera. A 20 degrees rotation of the camera must be simulated by rotating your models -20 degrees. Attached is a downloadable example MIDlet that shows you how to rotate your 3D models using the 3D engine in the Sony Ericsson K700. The code follows the basic idea of how a 3D animation should be handled. The 3D model and animation are created with a 3D modeling tool, then exported and converted to "mbac" files (the models), "mtra" files (the animation data) and ordinary "bmp" files (the textures). These files can easily be imported by the 3D engine, leaving more or less only the lighting settings, and of course in this case the rotation logic, to be done by Java code. Rotate the models with the joystick and change the animation by pressing fire. |
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.