Android 3D game tutorial – Part III

转载 2011年01月13日 22:19:00

Updated to be Android 2.0.1 compatible.

You are new to this series? Please start with the first part .

The third part of this series will show you how to stop the rotation of the triangle and that the rotation really just work on the triangle and not the “camera”.

We want to have more control over the rotation. To get that, we reset the matrix on every call of the onDrawFrame() method. This will reset the angle of our triangle so it always it stays rotated at the given angle on initialization.

In the VortexView class you should remove the division by 10 to be able to rotate it more than a bit.

If you try this, you will see the rotation will only goes the way our touch motion goes. If you don’t move the finger over the screen, it doesn’t change the rotation.

The next thing: Do we rotate the triangle or the view/camera?
To check that, the easiest way is to create a second triangle which will not rotate.
The fastest but also dirtiest way to do this is to copy & paste the initTriangle() method to initStaticTriangle(), copy & paste both buffers and finally copy & paste and modify the last 4 lines of the onDrawFrame() method.
Don’t forget to change the color of the second triangle and reduce the coordinates of the second triangle, so we can see both. I changed the every 0.5f coordinate to 0.4f.
Here the full class:

If you try this, you will see only one triangle rotate. If you want to rotate both, simply change the place where the rotation will be called to right above the comment “draw the static triangle”.

Compile and run the application and you will see the green triangle rotate while the red triangle stays at the same angle.
That should be prove enough for the answer, that we really only rotate the triangle and not the whole scene.

Source as Eclipse project: Vortex Part III

3d-part-three-triangle 3d-part-three-triangle

Go to Android 3D game tutorial – Part IV

Android 3D game tutorial – Part IV

Updated to be Android 2.0.1 compatible.You are new to this series? Please start with the first part ...
  • virus026
  • virus026
  • 2011年01月13日 22:21
  • 434

Android 3D game tutorial – Part V

Updated to be Android 2.0.1 compatible.You are new to this series? Please start with the first part ...
  • virus026
  • virus026
  • 2011年01月13日 22:25
  • 429

Android 3D game tutorial – Part VI

Updated to be Android 2.0.1 compatible.You are new to this series? Please start with the first part ...
  • virus026
  • virus026
  • 2011年01月13日 22:29
  • 540

Android 3D game tutorial – Part I

http://www.droidnova.com/android-3d-game-tutorial-part-i,312.html
  • linbochen
  • linbochen
  • 2010年07月05日 14:54
  • 525

Android 3D game tutorial – Part II

Updated to be Android 2.0.1 compatible.You are new to this series? Please start with the first part ...
  • virus026
  • virus026
  • 2011年01月13日 22:16
  • 580

TheWavelet Tutorial Part III

转载自:http://users.rowan.edu/~polikar/WAVELETS/WTpart3.html
  • bluels01
  • bluels01
  • 2014年11月21日 16:54
  • 468

Django学习记录之Django 1.8 教程(我只是官网的搬运工)Tutorial Part 1

Part 1 第一步:创建项目 (确保你path 包含django)$django-admin startproject mysite(mysite为你的项目名字)这将会创建一个项目在你的当前目录...
  • Z_LiT0
  • Z_LiT0
  • 2015年11月30日 18:26
  • 268

OpenGL ES Tutorial for Android – Part III – Transformations

这篇文章里面介绍如何知道rotatef非常有用。在一个就是pushmatrix和popmatrix Last tutorial was about building your polygons. Th...
  • virus026
  • virus026
  • 2011年01月17日 23:29
  • 922

Mathematics for 3D Game Programming and Computer Graphics基础学习

主要结合opengl学习3d的中的数学知识,以后主要精力都集中在底层。 第一章 渲染流水线 (The Rendering Pipeline) 1.1 图像处理器...
  • WAN_EXE
  • WAN_EXE
  • 2017年09月21日 13:46
  • 240

Introduction to 3D Game Programming with DirectX 11学习笔记 4.2Direct3D进行初始化

我们将Direct3D的初始化过程分为如下几个步骤:1.使用D3D11CreateDevice方法创建ID3D11Device和ID3D11DeviceContext。 2.使用ID3D11Devic...
  • qq_23225317
  • qq_23225317
  • 2017年02月16日 17:21
  • 1272
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Android 3D game tutorial – Part III
举报原因:
原因补充:

(最多只允许输入30个字)