Developed by these Android 3D gamesArticleThe original article was written by Martin, a German at droidnova.com. lixinso was translated into Chinese.
In the third part of this series, I will show you how to stop the rotation of the triangle and tell you that the original rotation is actually only the rotation of the triangle, instead of rotating on the camera "camera.
We hope to have more control over the rotation. Therefore, this matrix is reset every time the ondrawframe () method is called. This will reset the angle of the triangle so that it can always rotate to the given angle.
In the vortexview class, you should delete "divided by 10" so that it can be rotated in a larger range.
If you try this, you will see that the rotation will only rotate according to the position of the touch. If you do not touch the screen, the rotation will not change.
Next thing: Do we rotate the triangle itself or the view/camera of rotation?
To verify it, the easiest way is to create a second non-rotating triangle for comparison.
The fastest and most stupid method is the copy & Paste inittriangle () method as a new method initstatictriangle (), copy & paste, copy & paste, and modify ondrawframe () the last four rows in the method.
Don't forget to change the color of the second triangle and change the coordinates of the second triangle, so that we can see two triangles. I changed 0.5f in every place to 0.4f.
Here is the entire class:
If you do the above, you will see that only one triangle can be rotated. If you want to rotate both of them, you only need to add a line next to the comment "Draw the static triangle ".CodeYou can.
Compile and run thisProgram, You can see that the green triangle is rotating, while the red triangle is still in the original place.
This fully verifies our answer. We rotate only triangles rather than the entire scenario.
Eclipse projectSource codeDownload: vortex Part III