Welcome

This is a blog sharing what i have learn and experience from my internship in A*Star IHPC
- Zac Kwan

Thursday, December 30, 2010

Day 60 - Last day of 2010 work in the office

Today came back to the office and started to continue working on the problem we identify as the translation issues from different object. First, we manage to fix the translation on the different z axis that each object have from the clip. This make the translation more accurate although from the visual we couldn't really tell.

After that we went on to the second problem. The translation for different object seems to be the problem with their different unit of axes. We try importing different object first to see if we get the same result but apparently it doesn't. However, the object work fine individually. So alex continue meddle with it. He then found out that because the object is too small so he scale up, and this cause the axes of x,y,z to unit to be larger.

So now we found of is the scaling problem, we went on to search the libraries for methods to reading the scaling matrix. We went on to fix it after working on the formula for a while. Everything for the translation seems to be working perfectly find now. What a good way to end our work in 2010 =)

Wednesday, December 29, 2010

Day 59 - Where are you?

.... still working on the translation issue. Seem to me as not able to get it. Kevin came over and i explain to him about what i think. This time round i think that it get more clearer now.

After a while, the translation start to yield result. Just as the path that i expected. Mange to move on working on the other translation issue.

Work with alex to get some other working like the translation when not selecting any object moving to a object cause it to fly. Also the problem of not going into gesture began when it is call.
Everything seems to work for the first node that is draw.

The other node that is imported from other file to the pod scene fail to work when drawn. The translation value is the same for both object, but it seems to translate more than the other those. Believe is the problem in generating the pod scence.

Tuesday, December 28, 2010

Day 58 - Exploded

Yesterday before leaving office, found out that the exploded formula have problem with node count of 4 and lesser. as 360/4 or less would result a value of 90+. This would cause tan(degree) to produce a result that is not correct.

So i went on to fix this problem by specifying the exploded view of the translation when the model have less than 5 node count. The time require was actually quite short as i only have 3 scenario to do.

After lunch, i went on to help Alex with his problem the translation of the object. I believe that the formula that he did earlier was the correct 1, rather than finding other solution i decide to dive into the problem that might cause this formula not working to the result we expected. The first thing i did was to draw a plane at the near clipping plane. After doing this i found out that there must be a distance from the camera to the object even if the object is not being translated.

I did manage to prove what i thought and explained that to Alex to let him know about the chance that this could happen.

“Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime”—Author unknown

“Give a man a fish; you have fed him for today. Teach a man to fish; and you will not have to listen to his incessant whining about how hungry he is.”—Author unknown

Monday, December 27, 2010

Day 57 - First day of work after Christmas

Its monday and the day after christmas, it hard to get my engine started for work.

Kevin back to work after his holiday, we explain to him about what we done and what we have not done. It slightly embarrassed to say that we got more than half of the task still not yet complete. I told him about the problem in translation and how did i plan to get it working. He describe to be a more simple one that is still logical.

Went on to work on the exploding of the object for the remaining of the day. Spend time calculating the formula of the object to be divided by 360 den * tan(degree) and blablahblah. Trying to get the formula working before i even started to code. So i spent almost more than half a day to do that.

At least my effort did paid off. Manage to set up the exploded view just as expected from my formula result but still translation is a bit of the problem.

Friday, December 24, 2010

Day 56 - Half Day Work at office today

Today is Xmas Eve, Merry Xmas if you are from US and Happy Xmas if u are from UK =)

Well although is Xmas eve, still got to come over to the office to complete a half day work. It seems that everyone looking really happy today, even the strangers in the train, or colleague in the office or maybe it just me.

The mood now is definitely Xmas mood, but still need to get some of the leftover work done like the changing of texture while translating. After yesterday understood about how the binding of the texture work, it wasn't much of a difficulty to change according to the translation. Just calculate the differences in the axis when the value is translated and change the texture according to the full screen bounds. Manage to get it done pretty quickly thou but still have way to optimize it.

So while i still have time i write up a simple if else to only change the texture when the translation to another texture so that it will not alway be binding texture to the plane even when the texture currently displayed. This way only the texture that is going to be shown will be bind, this would improve the processing speed.

Thursday, December 23, 2010

Day 55 - Texture and Translation on Cutting Plane

Day 55 is Xmas Eve's eve.. Already can feel the xmas mood now. Town, shopping center, mrt are all decorate with xmas item!

The fact i love xmas is whenever xmas is coming, a year is ending. Every time at this point, i will start thinking back on what had happen so far this year. Thinking back on the memories, epic moment and etc. Sometime couldn't believe that it happen so long ago. Anyway Merry Xmas everyone =)

Well still have to work today, cont working on the translation on the cutting plane. By apply texture on the cutting plane work fine. However i did notice that the animation start to get laggy because apply apply the plane cutting, where i suspect is due to the texture. I remenber that when reading on Jeff blog the texture should only be loaded one time if possible so that it will not cause memory issue. The way i am doing it is actually loading the texture to the texture2d every frame x30 per sec. This is really alot. i try various way but i cant because i have texture for the model node as well. After reading more and texture and see how the podloader applying the texture that don't cause any problem, i believe there must be a way to do it. So i decided to read up more before i start trying again. And YES! solve the problem with

glBindTexture(GL_TEXTURE_2D, m_gridTexture[0]);


So now will continue working on the translation to change the texture when moving in and out of the z axis. Its hardcoded still but it does look nice when u see the texture of the plane changing as u cutting.

Wednesday, December 22, 2010

Day 54 - Clipping Plane is Cutting

Continue yesterday work that is to calculate the normal of all the plane.

There is alot of project or sample code that i get from already have method to calculate the normal from the vertices of the object. I read through that and it is actually quite complication or overwhelming on what i need to do. All the previous project i dl-ing will calculate the vertices for a non-flat plane object which each set of vertices would have different normal. and some even go on to divide by the number of face being reuse to reduce the normal. I got really confuse at first so i read the iPhone 3D programming. The godly book that have been helping me for very long.

As i read the chapter i understood more about it although there isn't any build in method or provided method to calculate the normal. But at least i understood that i am creating a flat plane that mean all the normal from any set of vertices would produce the same result! So i went to read up jeff blog on calculating normal. Then i make use of some method he have in GLCommon.h to calculate the normal of my plane. After some try, finally to get it working. I also manage to apply rotation to both plane and the clipping. It wasn't difficult but the fact that it work prove that my understanding of drawing a plane at the clipping edge is correct!

Now got to hardcode some image and test the changing of texture when the clipping plane is translated tomorrow.

Tuesday, December 21, 2010

Day 53 - Finally Found Something

Still working on the clipping plane, after a lot of googling and research yesterday that is reaching nowhere, decided to start all this all over again.

As usual i open-ed my tab from last browsing session, i browse through some of the website that i already read before yesterday. Suddenly, i found out that this website is actually teaching how to do a clipping with stencil that is somehow related to what i need.

http://glbook.gamedev.net/moglgp/advclip.asp

Trying to find the pdf book online on this chapter, but look like it not available or i have to purchase it. So i just going to make do with the short tutorial. I try apply the clip function as my plane vertex and draw the plane on the object. This time finally the plane appear, but not at the right position.

I re-read and read the blogpost in the website again and finally notice a method that might be the cause of my problem.

get_plane_equation(verts[0], verts[1], verts[2], eq);

This equation is not being explain by the blog, at first i thgt i just pass in the vertex of my plane. But after remembering what was the parameter about the equation, i know that i have to pass in normal x, y,z to set up the clipping. I hard corded the normal and rotate the plane there and IT WORK! Long day but finally get it working. Going to calculate the normal using method tomorrow so it work for all plane!

Monday, December 20, 2010

Day 52 - Plane Cutting

After finishing with the rotation and fixing the bug in frame animation of the model, now i am moving on to working on plane cutting.

First up, i research the way of doing it. From what i have found, a the cutting of the model is usually use with the glClippingf function. This can be a user define equation to define where to cut the model. Just by hardcoded equation, i am able to see the 3d model being cut.

There still more to learn about how to write the equation, but now i am trying to draw a plane at the clipping part so that i can see the cutting visually. I spend the other half of the day researching on how to draw a plane at the clipping part of the model but found no answer. It was really bad when all the link in the google search result already turn purple. Not going to give up yet, will start all over the research again tomorrow!

Thursday, December 16, 2010

Day 51 - Fixed rotation and modelframe

Its day 51! Time seems to fly, i have been working here in IHPC for half of a hundred days. Really enjoy working here.

Well back to the topic, today was to fix the rotation by changing from the original swipe gesture to UIPangesture. It was not that difficult to rotate the whole model view matrix for the whole 3d object as i already manage to create the iVar and other, just have to get and set according to the translation of view.

However, for the individual node, as method and the UISwipeGesture was being done previously, there was quite alot to change to make use of this UIPanGesture matrixes. At first i manage to get the object rotate at the correct direction but the speed of the rotation is too much. I do not really understand what the reason at first because i did += the new value minus the old value which should not give any problem. But after more debugging and thinking i finally found the error with this that will only work for the first two step. So i fixed it.

The remaining of the day i spent trying to fix the modelframe animation as the sudden end of the animation and start doesn't look good at all. It seems to make the object jump from one frame to another frame without smooth transition. Manage to implement a pause and play function for the frame to have it connected to the last stop frame.

Wednesday, December 15, 2010

Day 50 - Rotation on ModelView

As stated yesterday, i have put the explode view on hold for the time being and move on to doing the rotation view.

I started to look for way of rotation the camera and then came across a post to say that in opengl es there issn't such thing of a camera in the first place. User is viewing at the 0,0,0 by default but because we applyed some transformation to the modelview like lookat and translate therefore the view changes. And this is also our so call camera. With this, i knew that i should also perform my rotation here to apply the rotation matrix to all the 3D object in the modelview scene.

I try using glrotate here before the push and pop matrix its call, but nothing seems to change. I still think that it is the correct 1, so i explore the rotation perform by the POD tutorial on all the object. I found that that they have their own build in rotation to be perform on the model matrix. Apply this rotation matrix at the same place, i finally manage to get the whole object to rotate together at the same axis. However the by using UISwipegesture, the rotation is quite stiff that doesn't feel nice in the user point of view. So i decided to change to UIPangesture to do the rotation.

Tuesday, December 14, 2010

Day 49 - Kevin is going on leave tmrw

Kevin our supervisor will be on leave starting from tmrw for the next 10day. We already have discussed on what need to be done in the next 10 day, hopefully we can complete it.

So started working on what was discussed, first i look at the technique for separation in the exploded view. I did some research and studies on this thinking that there should be some algorithm did by some people that i can simply make use of for my project. However after almost a whole day of searching, its simply wasn't the case.

I did some thinking and decide to put this to the last on my list and work on the other part first. I would get back to the exploded view when i completed the rest of the component even if i have to write my own algorithm to get it working.

Monday, December 13, 2010

Day 48 - Changes to Transformation

Previous as we create a objective class with c++ object inside, a lot of unnecessary warning occur, though it doesn't affect much, but is not very pleasant to have so many warning when running the application. Also because of this, we have to change the compiler use by objective c to a cpp objccpp compiler for every class that uses it. Which result in more warning.

Kevin told us about a possible solution to just have the c++ object remain in a the eaglView, by create a transformation class to pass the value to the c++ class in the eaglView method. This would just have to change the eaglView compiler to the objcpp which is unavoidable, but other class could remain using objc compile which will give us lesser warning.

We agreed and started changing it. At first we though that it would have a lot to change, but end up it was actually quite smooth during the changing processing. The error encounter was being solve pretty fast as we somehow already know what causes this to happen when the error occur.

Thursday, December 9, 2010

Day 47 - Adding gesture and colorpicker

As the layout of the iPad and iPhone is complete, we started working on the functionally today.

We spend the 1st of the day getting the color picker to work. Colorpicker is a technique to detect the object that is being touch by using unique color assigned. Was able to get it working without some depth buffer at first. But without depth buffer this would cause the object behind another object to never get selected which will not look nice. After that manage to solve it by enabling depth buffer but need to clear it before drawing again.

After that we went on to continue adding the gesture of rotation, translation and scale to the individual node. Rotation wasn't much of the problem, but translation doesn't seems to work well. Alex is still trying to fix the translation issues.

Wednesday, December 8, 2010

Day 46 - ScanViewController

After fixing the UISplitViewController yesterday, now the layout of the iPad is close to finish.

So now i when on to do the scanView that will show the dicomm image of the MRI scan of our project. It will just be a plain swipe on the view and the image will be changing according to the translation.

As Alex have already did UIGestureRecongizer before for the openGL object, all i have to do was create a controller and add in the UIGestureRecongizer of pan to get it working. It wasn't too touch of a job to do. Manage to finish all this before lunch thanks to alex code =)

Alex came after lunch cause he have a driving test in the morning. Congrats for passing! I give him a overview of what i have done so far when he is not around and also told him how i manage to overcome the bump that we encounter during the development.

Tuesday, December 7, 2010

Day 45 - More on the Interface Design

After solving the rotating in UISplitViewController, i now needed to set the eaglview as a delegate to send my podnode back to table. I created another table to set up the podNode. Working on iPad but when i try to implement on iPhone, i face some cycle dependencies issues.

I google it and i manage to understand what the dependencies is about. But at first thought my app does not have such thing occur. However when i go more deeply i notice this happen because that my iPad and iPhone share the same class which result in the problem. When i work individual everything would be fine. So i told kevin about this problem and now we decide to create a separate table class to solve this issue.

After solving this, i helped kevin with some html code that is not related to the current project. Have been long since i last touched the html code. Although not very difficult, but it is time consuming. Kevin also actually pull me in to sit for a presentation that conducted by some companies where we bought their product. It was a really interesting one, as they show us the potential of using their product to do stuff that we needed.

Monday, December 6, 2010

Day 44 - Continue on iPad design

Last friday, before we left the office, alex manage to set up the UISplitViewController on the iPad. It look really cool to have a popover on portrait and landscape to show them side by side.

However there are some bug to to it. Whenever we turn to landscape, the openglview is disappear. Not the object but the whole openglview, because the cleanscreen wasn't there. If we were to stop the animation and rotate it will appear, but once we start the animation again it disappear. Initally i concluded that this is the UISplitViewController problem because when we rotate on landscape on iphone, everything work fine. However the iPad with splitview it start to have some problem.

I spent half of the day googling and found no matching result. After that kevin came over, i told him about what i thought. He try re-adding the view but he accidentally resized the view and it disappear as well. So i start googling about this problem and finally found out that openGL view need a pixel dimension that is multiply of 32. But with the splitviewcontroller added, the openglviewer is automatically resize to another value which is not multiply of 32.

Friday, December 3, 2010

Day 43 - Just when everything went so smoothly

Friday, was really happy with the way the project progress. Although we move from obj loader to pod loader, but manage to set up everything in less than a week to do what it can do which is more than the obj loader that we did.

Alex also make progression on his animation with 3ds max. He manage to animation the object created the way he wanted to and also set up the camera and lighting. I am also able to load the podfile he create into my podloader. Everything was going so well.

Alex then went to find gimhan to take the obj file of the heart model. We find online for help on how to morph the heart model from 1 obj file to the 2nd obj file to the 3rd obj file. Of course we didnt know the technique was call morphing at first so we actually searched quite long for it.

However after watching the tutorial we manage to get the animation. BUT after exporting it to pod, the animation doesnt seem to work anymore. At this point, we found out podfile doesnt support vertex animation. Which causes us to have to move on when not having this animation.

Thursday, December 2, 2010

Day 42 - Depth Buffer

Although yesterday manage to set up the animation to run correctly, but there is still some problem in the drawing in the view. On my app, the last object that is being draw is on top of the object that draw 1st regardless of the z axis.

This is a problem because not every pod will be drawn from back to front. I believe that there is someway to set up the so that i could make use of the z-axis. Asked kevin for the book about the framebuffer that he actually read about as i suspect there is something to do with the setting up of framebuffer.

INDEED! the framebuffer needed to allow another depthbuffer to be enable to that they could allow the drawing of object according to the z axis. This way the object with z axis closer to the screen will be draw on top ignoring the order of drawing.

Wednesday, December 1, 2010

Day 41 - Animation

Will clear understand of what i need to do and what need to be done, i manage to head off to a good start.

I make changes to the modelapp to now take it camera and lighting from pod file. With this, i am also able to set animation. I manage to set up the app to load pod file with camera lighting texture before lunch.

After lunch i start to go and find out on how the animation of the pod file work. Found out from Alex that pod file is using key frame animation. With this type key frame, i believe that the animation is set by passing in and updating the frame number. So immediately i search for keyword frame in the training course, and i manage to found it. The code is written in c++ but comment did explain that it is passing in the frame number per ms that is pass to the next draw. I spend the day coming out with the algo to do time and set frame and manage to get the animation to work.