JSR 184: 3D co-ordinates and orientation overview | ||||||||
| ||||||||
This article gives a brief introduction to the 3D co-ordinate system and orientation in the 3D world using the JSR 184 API. Download MIDlet and source code>>
In addition to the world co-ordinates, each object also has a local co-ordinate system and the figures can also be moved within the local co-ordinate system (Figure 2). The big difference between the co-ordinate systems is that the local co-ordinate system's orientation may change; the local co-ordinate system is actually rotated with the figure if the figure is rotated (Figure 3).
In JSR 184 it is also possible to add a mesh to a group. For example if a group is added to the world and then a mesh is added to the group, the translation of the node will be in the co-ordinate system of the parent. The basic functions are: Transformable: - postRotate(float angle, float ax, float ay, float az) - translate(float tx, float ty, float tz) Transform: - postRotate(float angle, float ax, float ay, float az) - postTranslate(float tx, float ty, float tz) mesh.postRotate(3.0f, 1.0f, 0.0f, 0.0f); When rotation is made directly on the transformable object the rotation will be made around the origo of the local co-ordinate system. transform.postRotate(3.0f, 1.0f, 0.0f, 0.0f); mesh.setTransform(transform); When the rotation is made using the transform class the object will rotate around its center. mesh.translate(0.0f, 0.0f, 5.0f); When the object is moved using methods in the transformable class the object is moved in the co-ordinate system of the parent node. transform.postTranslate(0.0f, 0.0f, 5.0f); mesh.setTransform(transform) When the object is moved using the transform class the object is moved in the local co-ordinate system. To get a visual effect of the different methods download the source code and example MIDlet here >> |
Open Source is good idea for sharing our knowledge, because knowledge is belong to the world and not for sale.
Friday, June 1, 2007
Mobile Java 3D Tips, Tricks & Code
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment