Tuesday, November 16, 2010

16 November 2010

Completed the rotation of a single 3D model before lunch today. Did it by doing some matrix multiplications. I first created the matrix for rotation on the y-axis, then another for rotation on the x-axis. By multiplying these 2 matrices, I was able to get the final rotation matrix, which is used to transform the 3D model. However, there are still some faults here and there. I brought this up to Kevin and was told that it is fine for now. He mentioned that in order to solve this, I had to look into an even more complex concept, quarternions.

With that, version 1.0 was up. However, all 3 of us realized that OpenGL ES 2.0 is stumbling us. After some discussions, we decided to move to OpenGL ES 1.1. Hence, Zac and I are required to archive what we have done in OpenGL ES 2.0, and then modify those codes to fit in OpenGL ES 1.1.

Many applications out there simply load an EAGLView for the whole application, without incorporating controls such as UITableViews, UINavigationBars, etc. Currently, we are being tasked to look into the proper way of having additional controls together with the EAGLView.

Oh and one more thing, we celebrated Calvin's birthday today at Infuse (level 14). Tomorrow's Calvin's birthday. Happy birthday Calvin! :)

Monday, November 15, 2010

15 November 2010

Continued working with user interactions today, and the focus was on the swipe gestures to rotate the 3D model that Zac has imported. I was able to get the up, down, right and left rotations up fairly quickly. However, that was not what I wanted. I was only either able to rotate up and down, OR right and left. If for example, I do a right rotation followed by an up rotation, the model goes haywire. It does not rotate properly.

I then moved on to find out how to do simultaneous rotations on both the x and y axes. From there, I looked into matrices as they are the ones controlling the model's transformations. I had a little knowledge on matrices as I took additional maths in secondary school, but I was not very good at it. Did some research by reading through the explanations on iphonedevelopment.blogspot.com blog and the OpenGL ES redbook. Got to understand matrices a bit more, and managed to improve the rotations. There is still some faults here and there though. Have to look into matrices more tomorrow!

Sunday, November 14, 2010

12 November 2010

Gained a better understanding of the glFrustumf today. Had some discussions with Kevin and some colleagues that he brought in. They were really helpful and seriously intelligent.

We realized that the normalized device coordinates always ranges from -1.0 to 1.0 on both the x and y axes. Hence, during the translation of window coordinates to normalized device coordinates, I have to scale the values down. With this, I was able to translate the positions properly.

The next thing that I am trying to solve is the problem with perspective. If the zNear and zFar values are not in the positive range, we would not be able to see any perspective. If we have perspective, the translation of coordinates would not be displayed in the way that we want it to be. Hence, I would have to spend more time trying to understand how this works on Monday.

Spent some time looking into swipe gestures as well. Earlier this week, I was only able to do swiping in one direction, left to right. I found out that we are actually able to swipe up, down, left and right. Now the next thing that I want to look into is if swipe gestures would work when I have pan gestures added to the view. These gestures does not seem to work well on the simulator. I might probably request to try this out on a real device to see if it's a limitation on the simulator.

Thursday, November 11, 2010

11 November 2010

Chanced upon this link as I revisited on drawing 3D cubes using OpenGL ES. He has some useful tutorials there for beginners. I did this thinking that I probably drew the cube wrongly, but that was not the case. Spent more than half of the day trying to draw cubes.

I then decided to revert back to what the template used to create the glFrustumf, and the cube was drawn nicely. However, the coordinate translation went haywire. Therefore, I suspect that my issue has got to do with the creation of the glFrustumf. Hence, I decided to do more research on this to gain a better understanding.

Kevin came in to check on us at the end of the day. I had the direction in mind, but once again, I failed to express what I have in mind properly, which caused confusion for Kevin and Zac. I probably went into too much details too. Kevin then told me to research on the following terms aside from just glFurstumf:
- glMatrixMode
- glViewPort
- glLoadIdentity

Gonna do some research back at home though Kevin says that I can get it done by Monday.

Wednesday, November 10, 2010

10 November 2010

Continued with the movement interaction today. Had a short meeting with Kevin and Zac to discuss on the formula to use for translation. That didn't seem to work well either. We went on to research more on glOrthof and glFrustumf. After some explanation by Kevin, I slowly got to understand more of what they can do.

Hence, I went on to work with glOrthof first, which is for 2D models. I applied the formula that I came up with and finally managed to get what I wanted. From there, I then moved on to make use of glFrustumf, to work with 3D models. All seem to work pretty well, but my cube doesn't seem to be a cube anymore. Or probably it is. Got to look more into this issue and solve it by tomorrow!

Looks like I would have to work with more mathematics in time to come. Wish I had put in more effort in mathematics during my secondary school days :S

Tuesday, November 9, 2010

09 November 2010

Continued working on the model interactions today. I decided to first work on the moving of the model. First I did some simple movement of subviews with the use of UIGestureRecognizer. It has quite a lot of similarities to UITouch.

With that done, I then moved on to try out the same interaction, but with the 3D model. I realized that I was able to do a glTranslatef on the model, however, the model does not seem to appear properly. Then I realized that I would have to do some translation of the coordinates. The UIGestureRecognizer uses the Window coordinate, while OpenGL ES uses the Normalized Device coordinate for model translation. Here are some pictures to illustrate the differences:


Therefore, I proceeded on to work on the coordinates translation. Still have yet to work things out properly. The problem now lies in the part where the model crosses x = 0 and y = 0. There's definitely something wrong with the formula that I have come up with. Gonna have to do more thinking, debugging and researching.

I tried to workaround by making use of UIAnimations. However, while doing that, I came to realize that the rendering method is already making use of UIAnimation.

Monday, November 8, 2010

08 November 2010 - Start of OpenGL ES & Project

Kick started the day by going through Stanford University's podcast lecture on OpenGL ES. Completed some basic sample codes of drawing 3D models and rotating them.

Once that was done, we gave Kevin a call and he came over to have a discussion with us. We discussed on the things to be done for our project and split the work among ourselves. Zac chose to work on the first stream, which is to work with the model. Thus, I would be working on the interaction stream.

Here is the picture of what we have discussed:

I would first have to complete the 3 basic interactions, namely rotation by flicking, scaling by pinching, and moving by dragging.