Wednesday, November 26, 2008

4-Player Pong in Quartz Composer

24 November 2008

Met Kevin while I went to collect the keys to open the "working space". He had returned from the Conference in the US and passed me some souvenirs he got for us. These are what he brought back for us:


Rested at my desk after opening until the rest returned from breakfast. I did not join them for breakfast as I was feeling unwell. I continued with the sample application to get a better idea of Quartz Composer. Managed to get the sample application to work the the Lightdraw through the OSC receiver.

After finishing, I helped Ming Hong in setting up the new DV Cam. Here's our new DV Cam:


We had some problems in getting it to work after setting up. So we requested help from Cheng Teng. After fiddling with the camera and its settings, we were able to get it working with Lightdraw before lunch.

After lunch, I continued working on the '4 Player Pong' on Quartz Composer while Ryan tried to modify the existing Lightdraw application,'Coverflow Gestures', for the rest of the day. The interface of the '4 Player Pong' and the modification of the 'Coverflow Gesture'  application were done by the end of the day. Here's the interface for the '4 Player Pong' on Quartz Composer:



25 November 2008

Joined the rest for breakfast today as I was feeling slightly better. Continue to work on the '4 Player Pong' after breakfast. Studied the javascript patches on the examples I had downloaded and tried to do something similar, but was unsuccessful due to the difference in versions. So at around 11.30am, we started setting up the applications we needed for the demo to Kevin before having lunch.

After lunch, we went to check whether the applications we needed were there for the demo. So around 2.30pm, Kevin came over and we showed him the applications we did for the past weeks. We also gave him an update on our progress so far. As soon as we finished the demo, Kevin brought us to visit Fusionworld, a state-of-the-art technology showroom by A*STAR. It's a very cool place. We visited there to check the set up for Lightdraw, so that You Hock and Leonard could get a rough idea on how to set up Lightdraw on the 3x2 Tile Display. We've also tried the "legendary touch table". Shall not comment on it much. Here are some pictures I took there: 



We got back to our work after the tour of Fusionworld. Ryan and I struggled getting the javascript to work for the rest of the day. I hope we could get something to work by tomorrow.


26 November 2008

Breakfast as usual with the rest before heading back to work. I was studying the applications I downloaded and decided to work with the existing patches in Quartz Composer instead of javascript. So by lunch time, I was able to get the ball to move.

After lunch, Bernard and Ming Hong brought us to visit the 'interns level' on level 14 before going to the sky gardens. Level 14 is totally different working environment from the environment we are in. After visiting level 14, I do really feel very lucky to be here working on Lightdraw. And Bernard have been joking about sending us to level 14 if we are unable to complete our tasks on time. Oh wells. Here are some pictures we took there:




Went to look for Kevin to give him an update on our progress after touring the building. Then we continued doing our work. Having some trouble to give the moving ball a constant speed after changing directions. The codes we used in the C++ version of '4 Player Pong' does not work nicely here in Quartz Composer. So I worked on getting the ball to move in a constant speed after changing direction for the entire day. However, I was still unsuccessful at the end of the day. Hopefully, I could complete this task by tomorrow and start doing the collision-checking between the ball and the paddles.


27 November 2008

Kevin and the rest are having their company retreat, so we were left to do our work by ourselves for the rest of the day. I tried getting the ball to move in random directions before lunch, but was unsuccessful. This is due to LFO patch not accepting negative values.

We had lunch by ourselves at the Dover Market nearby. The chicken rice there was great. Headed back to work after lunch. I decided to move on to working on other functions as I do not want to spend too much time on developing the '4 Player Pong' game because we still have other applications to work on. So I did the collision checking between the ball and the paddle for the rest of the day. Managed to check the collision for 1 paddle successfully at the end of the day. Hopefully, I could finish my part of the application by tomorrow so that Ryan and I could integrate our parts together.


28 November 2008

I continued with the paddles' collision checking after breakfast. Managed to finish the collision checking before lunch. On our way out to buy lunch, we 'upgraded' our visitor's pass to a temporary pass(woots!). We packeted our lunch back from the hawker centre opposite Fusionopolis as the weather wasn't looking good.

After lunch, I tried to pause the application after the ball went out of bounds. Did some research, but wasn't able to implement it at the end of the day. Will do it by Monday. Kevin and the rest had a demo on Lightdraw and the 3x2 tile display to the JC students at 2pm. After the demo, we ended the day by having a meeting to update Kevin on our progress so far and the plan for next week.


Reflection for the week:

This week has been quite a struggle with the Quartz Composer. Perhaps I'm still not used to visual programming. Hopefully I'll get used to it by next week. I had also discovered a few things about Quartz Composer, like Quartz Composer is running on a while loop and some limitations like being unable to store a variable after generating a random number. However, all programming languages has its own limitations and we are taught to work around those limitations(at least for me as my Major Project is done in a programming language not taught in school). The journey here at IHPC has been very fruitful so far, and I hope that I will get to learn more in the next few months.

On a side note, I tested out something on the iMac after reading about it on Digital Life. We could actually play 'Tetris' on the Terminal. Here's a screenshot of it and the steps taken:


Steps taken To Play Tetris on Terminal:

  1. Open Terminal(duh)

  2. Type in 'emacs' and press Enter

  3. Once it's loaded, press Esc

  4. Type 'x'(At the bottom of the screen, you'll see M-x)

  5. Type tetris and press Enter(you are ready to play!)

Steps Taken to Exit Tetris on Terminal:

  1. Press Control-X

  2. Press Control-C
Hope this helps. Enjoy!

Tuesday, November 18, 2008

Working with Quartz Composer

17 November 2008

First day of the week again. Kevin is not around as he flew off to the USA for a conference. I started of the day by having breakfast with Bernard opposite Fusionopolis. After breakfast, I tried to make the 'Pong' game start when a laser is detected instead of pressing the spacebar. It doesn't work because Ming Hong said that it is due to the 'cvWaitkey()'. So I used the 'usleep()' method instead of the 'cvWaitkey()' and it worked fine. Ming Hong also showed us a video from a website. Here's the video:



Cool huh? Click here to find out more. Bought lunch from the 'Market Place' after watching the video as it was raining. After lunch, I worked on getting the paddles to move smoother; I reduced the movement to just 2% of the canvas's height. It seems to be moving a lot smoother compared to the last version. However, Leonard commented that the movement seemed a little slow. So I guess I'll fix that tomorrow or something.

Ryan spent the entire day trying to make the paddle move towards the laser while Leonard and You Hock worked on the 3x2 tile display. Here are some pictures of them working on the 3x2 tile display:



By the end of the day, Ryan only managed to make the paddle 'teleport' to where the laser was shone while I managed to read up on 3 chapters of the Quartz Composer notes given by Kevin. Shall try to complete reading and doing the tutorials on Quartz Composer by tomorrow so that we could start working on the application in Quartz Composer.


18 November 2008

Had breakfast with Bernard in the morning again. However, we were joined by Ryan, You Hock and Leonard. After breakfast, I started to do the tutorials for Quartz Composer. I followed the tutorial closely and managed to make my composition into a screensaver and a QuickTime Movie. Here are some screenshots of my work before lunch:





Continued on the tutorials after lunch. Managed to create 3 Cocoa applications based on the tutorials. The first example was fine, but I faced some problems on the second example. After I completed the second example and ran it, the example did not work properly. So I tried re-doing but still faced the same problem. So I decided to skip and move on. So by the end of the day, these are the Cocoa applications that I did:




So I'm left with the last 2 chapters of the tutorial. Shall complete it before lunch tomorrow and start fixing our 'Pong' game before converting it in Quartz Composer.


19 November 2008

Had breakfast with Bernard and the rest again today. After breakfast, I continued with my final 2 chapters of the tutorial. Had some difficulties with the first tutorial because the tutorial did not really give very clear directions on where to find the example files to edit. Managed to find the file and complete the 2 tutorials before lunch.

Wanted to continue fixing our 'Pong' game after lunch. However, I encountered some problems because the function I did 2 days ago, doesn't seem to work. The game does not start when it detects the laser. I still needed to press a key on the keyboard before the game starts. Ming Hong tried to help by using the Lightdraw's key listener for Mac. The game starts when a laser is shone, but is unable to exit because the key listener does not read from the keyboard(according to Ming Hong). At the end of the day, we decided to revert back to the previous version and ignore the laser problem. We had to move on to the Quartz Composer soon. Will start working for the 'Pong' on Quartz Composer by tomorrow.


20 November 2008

Met up with Bernard and the rest for breakfast in the office again. After breakfast, Ryan and I wanted to test and fix the 'Pong' game. However, we were unable to test it because there was a meeting going on. So I tried to get Lightdraw to work with one of the example provided in Quartz Composer. The example application was working fine with the X11, but I would like it to work with the OSC to enable a multi-user mode. With reference from the 'Clouds Multi-User' application, I tried doing it but was unsuccessful when tested.

Had lunch after testing and was asked by Ming Hong to try fixing the existing Quartz Composer's applications to work with the existing Lightdraw. He explained to me what was the difference between the old and the new Lightdraw. Here are the differences:

  • blobCount now sends an int of 0-12 instead of 1-12
  • hold now is a string type instead of a boolean 
After understanding the differences, I tested the Quartz Composer applications with the new Lightdraw. The 'Clouds Multi-User', 'Teapot 3D' and 'RollsRoyce 3D' application are working fine with the new Lightdraw as they do not require the hold function. So I spent the rest of the day studying the 'Fusionworld' application. Hopefully I could fix it by tomorrow before lunch as some kids will be coming over in the afternoon.


21 November 2008

Arrived early, but did not have breakfast with Bernard as he already ate. So I continued to study before modifying 'Fusionworld' application to make it work with the new Lightdraw. Before lunch, I managed to finish modifying the application. Waited till after lunch to test it. The application works with the new Lightdraw(yay!). However, only the 3D models are not displaying properly. The images and videos are all working fine. Ming Hong and Cheng Teng tried to see what was wrong, but was unsuccessful.

We decided to leave the application as it is and set up for 'Bring your kids to work day', where those working in IHPC could bring their kids to work for a day. The applications used for showing Lightdraw to the kids were:

  • Google Earth
  • Cooliris
  • Puzzle Game
  • Drawing Board

Here are the pictures I took for the day:





After the demo, we had some light refreshments in the pantry. After having our fill, I continued working on the sample application. By the end of the day, I was still unable to get the sample application to work with the OSC. I guess I'll continue with on Monday and get it to work by Monday.


Reflection for the week:

Learning a new programming language is never a simple task. Although we were given tutorials and notes, the best approach to learning a new programming language is still hands-on.

So my week was spent on learning the Quartz Composer, a node-based visual programming language provided as part of the Xcode development environment in Mac OS X v10.4 "Tiger" and Mac OS X v10.5 "Leopard" for processing and rendering graphical data(taken from wikipedia). Picking up this programming language is no easy task as "codings" are kept to the minimal. However, I managed to understand it rather quickly as I was given notes and tutorials on it. Moreover, help is easily available online.

I've heard that interns here have a 'special' floor in Fusionopolis where all interns are assigned to that level. However, Ryan, Leonard, You Hock and I are thankful that we were not on the same 'special' floor as them because we get a chance to experience more things than them.

Thursday, November 13, 2008

Making Pong Multi Player

10 November 2008

Upon reaching, I switched on the iMac and ran Linux on it. After some time, I realized that there was a problem with the mouse. The single click in Linux became a double click, which hindered me in doing my work in Linux. At first, I thought that something was wrong with my mouse. So I switched mouse with Ryan and Linux still gave me the same problem. With that, I conclude that there's some problem with the Linux OS.

I then switched back onto the Mac OS and did my work on it. After awhile, Ming Hong said that he had to modify the Lightdraw codes, so we had to wait for him to complete. Read up on some news while waiting for him. Ming Hong did not take long to modify Lightdraw and passed us the new Lightdraw and the codes for his laser-matching algorithm.

We worked on integrating with our current application with the new Lightdraw for the rest of the day as there were several lines of codes that we needed to modify. By the end of the day, we managed to integrate with the newer version of Lightdraw and added in the codes for laser-matching. We will test out the laser-matching function tomorrow.


11 November 2008

Kevin informed me that Ming Hong would not be here for today when I went to take the keys for the 'working space'. So when the rest arrived, I told them the news and we had the same response - "today is going to be a tough day".

Tested the laser-matching after informing them. However, it did not work as well as I expected. So we tried to debug it till Kevin arrived to check on our progress. He informed us that he would be going to the United States for a conference for a week and told us the plans when we are done with our application. Leonard and You Hock would be working on the 3x2 tile display while Ryan and I would be working on an application in Quartz Composer. This means that Ryan and I have to learn how to use the Quartz Composer. Kevin then demo-ed to us the Quartz Composer as none of us had used it before. Here's a screen shot of the Quartz Composer:

After the demo, Kevin left to do his work and we returned to do ours. We struggled throughout the day trying to get the laser-matching method to work.


12 November 2008

Kevin gave Ryan and I some notes to read up for Quartz Composer. Upon receiving, we went to print the notes. Not too long, Ming Hong came and helped us with our application. Within half an hour, our '4 Player Pong' application could be work with multiple lasers.

However, things are not looking so good for You Hock and Leonard as their application is more complicated. You Hock seemed stressed after our application could work with multiple lasers. Tried to get him to relax and stuff while we tidied up the codes for our application. 

After tidying up the codes, we had lunch and went shopping for fruits at 'Market Place'. Learnt quite a bit about fruits from Bernard. Did some testing to check if there's bugs after lunch. Harold then came over and took a peek at our application. He commented that the paddles are rather jumpy and if it moves smoother, our application would be better. We found a few bugs fixed. I guess we will get it done by tomorrow. Here's a picture of Ryan testing out our application on the big screen:



13 November 2008

Read a few pages of the Quartz Composer notes that Kevin gave us yesterday. After reading a few pages, I decided to save the notes for the weekends and started to fix the bugs on our application. By lunch, our application was running fine. However, the paddles are still jumpy and we will have to fix that soon.

We bought instant noodles and potato chips for our lunch from 'Market Place' as it was raining heavily. After lunch, Bernard brought us to see our department's computer cluster and the computers which are powering the 6 projectors for the 3x2 tile display. After the visit, we had a 'lesson' on how the computer cluster work and its architecture. After the short lesson, Bernard demo-ed to us how the 3x2 tile display work.

After the 'lesson', Ryan and I tried to enhance our application by adding sound and changing the winning message for the rest of the day.


14 November 2008

It's been a month since I've been at IHPC, time really flies fast. We started our day by presenting our applications to Kevin, Bernard and Harold and got some comments on how we could improve our presentation and applications. We had also learnt the 2 main important things for Lightdraw is the ease of use of Lightdraw with the applications and the visual effects of the application. Here's a picture of Kevin testing out Leonard's and You Hock's application, the 'Puzzle' game:


Ryan and I were told of the change of plans for us - to develop the '4 Player Pong' game on Quartz Composer first before the blackboard application. We then had lunch at Holland Village and I was taught an important lesson about responsibility and how different it is at work and in school.

After lunch, we were informed that we were supposed to demo our applications to Terence, our department's Programme Manager. So all 4 of us made changes to our applications after the comments we received in the morning. I then proceed to write down the enhancement we need for our application on the whiteboard before presenting our applications to Terence. The presentation went quite well, and Terence gave us his feedback on our applications and how we could improve on it. We also told Terence about what we had learnt so far in IHPC and our plans for the next week weeks.

After Terence left, Ryan and I discussed on what we are our plans for next week. Once the plans were finalized, we went to bind our Quartz Composer notes before calling it a day. It was our first time operating the binding machine, but things were fine as we managed to bind the notes successfully. It was a great and fun experience to operate the binding machine.


Reflection for the week:

I had truly learnt a lot at IHPC in the past 1 month. Apart from just programming language, I had also learnt other stuff such as how to choose a fruit and how to operate the binding machine. We were also given important lessons on how one should be responsible and true to oneself from experiences shared by our supervisor and colleague during lunch.

Even though we had numerous chances to practice our presentation skills in school, we had learnt that presenting during work is totally different as we have to maintain a certain level of professionalism and be prepared for the presentation. I hardly prepare much for presentation in school. However, it is different here as we only need to present our application and have to explain while doing it, which made me realize how important it is to be prepared. I will definitely bear this in mind and will not make the same mistake twice.

Apart from all these, the weeks here at IHPC has been very enjoyable and fruitful.

Monday, November 3, 2008

When Pong Meets OSC

3 November 2008

Monday blues! Got to work early and had breakfast there while reading up on YouTube in Wikipedia. Then started to work on the '4 Player Pong' game. Soon after, Ming Hong came in and told us that Kevin and him had to attend a seminar and won't be around till Wednesday. So there won't be any progress report or disscussion till Wednesday, which means more time to do enhancement to our application before trying to integrate it with Lightdraw.

Had lunch at Crystal Jade today. Most expensive lunch so far during the internship. I guess it should be fine to have lunch at such a place once in a while as we just received our first paycheck.

Headed back to Fusionopolis to continue with our work while Kevin and Ming Hong went to attend their seminar. We did not have much progress because I struggled with understanding the Mathematics calculation for the speed and angle of the ball. However, I manged to fix the bug with the help of Ming Hong during his tea-break. Took a short break and went to the pantry. Here's a few pictures of what our pantry looks like and the view from it:



By the end of the day, the bugs for the ball is fixed and I have also managed increase the speed of the ball after a certain number of hits. Ryan also managed to make the yellow paddle work with the mouse, which is great news. Tomorrow will be the integration with Ryan's part and more enhancement to our '4 Player Pong'.


4 November 2008

Kevin and Ming Hong are busy as they had to attend a course and seminar respectively. So we were left on our own for almost the entire day.

Managed to reflect the ball back to the previous paddle after a number of hits was done in less than 15mins after I reached the 'working space'. Waited for the rest to arrive before I tried to integrate with Ryan's part. As there were some changes and modifying of the codes to be done, we were only able to finish integrating it after lunch.

Took a short break after the integration. During the break, a friend of mine started asking me questions about Linux in aMSN. So I did some research regarding the questions and found this really good website for on Linux. Here's the link for it.

Went back to doing our application and tried to integrate sound into the game using the irrKlang library. By the end of the day, we managed to add the sound in. However, there was like a 2-3 seconds delay when the sound was supposed to be played. I guess we will just ask Kevin for his suggestion when we meet him tomorrow.


5 November 2008

Tried to do the winning message before Kevin came in, but was unsuccessful. So we showed him our progress and what we intend to do. We had also asked him about the sound thing, but he said focus on the OSC and get it working with Lightdraw first. Completed displaying the winning message before lunch. After we finished our parts, we played with the 'Drawing Board' done by Ming Hong. So this is what we drew:


It's the first time we interns had lunch by ourselves. For the past 2 weeks, we joined Kevin, Ming Hong, Harold and Bernard for lunch. However, they had to attend a farewell lunch at Harrys. So You Hock, Leonard and I went to lunch at the Dover Hawker Center nearby. Ryan did not join us as he felt unwell. We had chicken rice there as it was recommended by Bernard. We shared half a chicken and had a plate of vegetables, and we paid like only $4 each! Plus, we had free servings of rice and it tasted good.

Bought congee for Ryan and we got caught in the rain. Ran all the way back to Fusionopolis. Passed Ryan his congee and went to dry ourselves. Rested for a little and we went back to doing our applications. Managed to edit the OSC makefile with the help of You Hock. We had also made some changes to our source codes, with the help of Ming Hong, as some codes did not run on the Mac. In the process of changing some codes, I've learnt that by adding in a few lines of codes, we could make the compiler choose which lines of code to compile in both Mac and Linux.

By the end of the day, we had discovered that our application wasn't running with OSC. I hope that we will be able to integrate our application with the OSC smoothly.


6 November 2008

Tested our application with the OSC when I got to the office. To run the application in OSC, we first have to start Lightdraw. It did not run as smoothly as expected. So we had to modify the codes for our application. Time passes quickly whenever we concentrate on a task. Before Ryan and I know it, it was lunch time.

Went to have lunch with Kevin and the rest at Holland Village. During lunch, we were discussing on social and environmental issues. It was pretty interesting to listen on other people's views on such issue.

Created a C++ class after lunch to store the coordinates of a laser with the help of this website. I also managed to set the starting position of our application to the top left corner as Lightdraw takes in the coordinates of the screen instead of our application. This was done after a quick Google search, and here's the link for the site.

After we told Ming Hong our progress, he suggested for us to use an array of cvPoints instead of the trouble of using a single class. So we changed the codes and commented out the class I created. By the end of the day, our paddle was only able to move upwards. I guess it's all part of my wishful thinking that the integration of our application with the OSC could be done in a day. Hopefully, we would be able to integrate our application and the OSC by tomorrow.


7 November 2008

Reached the 'working space' early today. However, I was feeling rather unwell and rested till the rest arrived. When the rest arrived, we began to work on our applications. Ryan and I tried debugging and realized that we are unable to print out anything when we used the 'cout' function. So we used the 'printf' function and we were able to debug it finally. I've also found out that the 'printf' function could do formatting while the 'cout' function could not. Here's an example on how to format using the 'printf' function:

printf("Here is a number %d and a %s word.\n", number, pointer);

%d %s are the printf format identifiers

Here's a link on the other available printf format identifiers.

After testing and modifying the codes, Ming Hong suggest that we slow down the speed of the application because the our application speed might be faster than what the OSC could receive. So we tried slowing it down and we managed to make the yellow paddle moved.

We then help Ming Hong to clear the projector room to make way for our new projector. While the people where bringing in the new projector, we continued working on our application and did the checking for the collisions between the yellow paddles and the others. After finishing the collisions check, we tried running it on Linux. However, the application did not go well because the screen positioning of our application was different. Kevin suggested that we take a break and had our lunch at VivoCity.

After lunch, the installation of the new projector was done. Here's the pictures of our old and new projector:

Old Projector

New Projector


We waited for Ming Hong to change the settings of the new projector before we tested our application on it. And by the end of the day, we managed to make the other paddles move and checked the paddles collisions with just a single laser. So it wasn't wishful thinking after all.

So by next week, we would be able allow our application to support multi-lasers and invite Mr Yeak over to show him our progress.


Reflection for the week:

This week had been a very productive week for me as I had learnt alot about C++, OpenCV and even the C++ compiler. I'm getting pretty used to typing the codes in the text editor. It feels just like when I was in my first year in polytechnic when we used to do write an application, and only finding out that we forgot to add a semi-colon or close a bracket during compilation. I guess I have been spoiled by the IDEs these days as they would prompt what are the methods/functions available after we entered a '.' and just choose from the list.

I have also been more adapted to travelling from east to west. Spending my time during the journey to keep myself updated with local and world news. After spending so much time with Kevin and our collegues, I found out that by keeping myself updated with the news(this week is about Obama, of course), it is easier for us to find a topic to talk about.

On a side note, I think I would install Linux on my laptop in the future for development purpose.