Saturday, May 25, 2013

Sky simulation for dome theater




Wow, long time since I've wrote something here, sorry for that. University is keeping me busy :)
One of things I've been working on is this sky simulation for a dome theater at Visualiseringscenter in Norrköping, along with my classmates Aron Tornberg and Sebastian Piwell. It's done with C++, OpenGL and the library SGCT.

SGCT distributes the workload to 6 different nodes, one for every projector. You can read more about it in the link above. I wrote an external GUI in C# for easy tweaking of some parameters.

All the viewports for the dome projection

Fisheye projection
As the screenshots shows, performance is kind of slow on my laptop, but this is work in progress without any optimizations. Besides, the method we use for the clouds is kinda brute force. This probably won't be a problem in the dome theater, since every node renders a relatively small part of the sky.

I'll update/create a new post with more details once we have finished this. I'll try and get some footage from the dome theater as well :)

Additional credit:
Miroslav Andel, for all the support concerning SGCT

Thursday, May 23, 2013

Summer Of Code @ Linköping University

During April, a mail was sent out to all student at our university talking about a new project the university had started: "Summer of Code"(SOC for short). SOC gives students the possibility to develop one of their own projects during the summer and getting payed by the university. It would be  5 projects would be accepted for this opportunity. A total of 70 projects applied, we were one of them and...


Our projects was accepted!


Fredrik and I had discussed an idea for an smartphone app earlier this year that we wanted to create, and decided to apply to SOC with this idea. The final idea, we will keep a secret for now, but I thought we could still discuss parts of it.

None of us have really worked with app-development before, but you have to start somewhere. Our intentions are to develop for the android platform first and perhap, later for iOS since our target audience is students, and a lot of students use iPads. But we also want to keep developing costs down at a start.

The project consists of 3 major parts: Drawing, Detecting, and Evaluating. The biggest challenge for us right now is the second one, Detecting. None of use have worked with image recognition before. We've been looking into using OpenCV as a framework to help us in this stage. The detection should also be "on the fly" while the user is still drawing to give direct feedback to the user.

We are both looking forward to this July when we will start working and we will do some more updates on the blog for each part during development!

Sunday, January 20, 2013

Debugging follow-up: Eclipse

So as a follow up to my previous post, this one is more specific to where you'll find some of the tools of debugging in the IDE Eclipse. Both this and the previous post is targeted to my classmates to help them get started with debugging, but anyone that uses eclipse can check it out!

Lets start off the same place as the previous post, Breakpoints.

In Eclipse there are two simple ways of setting breakpoints. First one is to hit "Ctrl+shift+b". This will create a breakpoint on the current line your typing cursor is.
The other way is to double-click in the white space just left of the line numbers.

You can see in the picture below how there is an indication now of a blue ball on the line you've set your breakpoint on. If you right click this ball and pick breakpoint Properties... you'll get access to edit the conditional breakpoint options I mentioned in the advanced techniques on previous post.

on row 32 we can see the indication that we have a breakpoint set.

So how do we start debugging? Easy, on your toolbar you have these 3 buttons:


The middle one is the regular "build and run", the one to the right is just "run without rebuild".
But it's the one to the left we want to click to start debugging.
When we do this Eclipse tells us that it wants to change "Perspective". When we get this option, we want to press "yes". Now, DON'T PANIC! Your eclipse will change its layout.
So first, I'll tell you how to revert back. In the upper right corner you have buttons for changing the perspective or layout. the one to the very right is our debug perspective, and the one next to it is our regular coding perspective. So a perspective is just another word for "layout to fit what your current doing".

from left to right: open list of all perspective, Java EE persp(never used). Java persp., debugging persp.


We will now have some new windows to look at. One of these is the Variables window, this will show us the variables being changed in the current scope. We can also edit these values here.


If you right click a variable in the editor window of this perspective and pick "watch" you'll get another tab in this window that contains  your "watch list" of variables you want to keep watch on.

So now that we know where to look for our values and we're in debug perspective, we need to control the execution of our code. That's what these buttons in the toolbar are for:
From left to right we have: Step return (same as Step out), Step Over, and Step Into. Read my previous post to figure out what these do. The next one is the Resume button. and the last one to the right is terminate, it will shut down our program and stop debugging.

Lastly, we have a window simply called "debug". This window works as our callstack. So in the picture below we can see that we're right now in the function SetDate from the class Date that's been called from "dateTestProgram.main", the main function of our program and all of this happens in the main thread.


So there we go, you now have everything you will need to start being a more efficient coder!


Friday, January 18, 2013

Debugging tutorial

There is no denying that a good way to learn is to explain to others. That's why I thought I would do this write up of practical debugging tips and techniques.

 What is debugging and why do I need it? 

So, what is debugging? Its the part of software development when you hit the "build" button and you get no errors in the code. Yes, there are no problems with how you've written the code for the computer to interpret it, but what about the logical errors? What about the while-loops that never ends and the if-statments that never returns true? This is what debugging is, resolving your logical errors that cause your software to misbehave or crash.

Easiest way to debug is just put a "print(x);" somewhere in the code to see the value of  x at that point. We've all started out debugging this way. But there comes a time when the logic of the programs we write gets too big, and using this "print debugging" won't be enough. Either your code will be filled with loads of  print-calls to check why your code doesn't enter a if-clause or why the values of our variables doesn't make any sense. This type of debugging is also insufficient since it will never actually tell you where your problem is, just that somewhere after this, something is wrong. That's why you should use debugging tools that many (if not all) better IDEs (Integrated Development Environment) ships with. I will have Visual studios 2008 as a base when talking about most of the parts in this tutorial, but your IDE should have something similar.

Below are some of the key features to use when debugging.

Breakpoints:
One of the main tools you'll be using while debugging is the breakpoints. The name explains its purpose very good; it's a point within your code that will break(or halt) the execution of code. While the code is halted you'll be able to inspect values of variables and, in some cases, even edit them.
Note: The line with the break point has NOT been executed yet.  
Lets look at the code below:
int apples;
apples = 5;
apples = a + 5;

If our breakpoint is set on:
  • Line 1, apples will still not be declared, most (smarter) editors will just move your breakpoint down to line 2 since nothing in your program changes during deceleration.
  • Line 2, apples has been declared but has not been given a value, it will have something like -5468165819 as its value.
  • Line 3, apples has the value of 5.
  • Line 4(not shown), apples will have the value of 10.

But since we don't want to have breakpoints for every line, we have some tools that allow us to "step" in our code.
There are three types of stepping, Step over, Step into, Step out.

Step Over:  The most used one. This basically say "execute the line we're currently on, but halt at the next line".
Step Into: This stepping method allows us to go into functions. If we look at the code below. if we were to have a breakpoint on line 5 and use Step over we would go to line 6 and be able to see the value of ourApples after the function sum has been run. However, if we press Step into, we will jump into the sum function and halt execution on the first line of the function (line 12). We can then continue using Step over to look at every line in this function.
int main()
{
    int myApples = 5;
    int johnsApples = 10;
    int ourApples = Sum(myApples, johnsApples);
    print ourApples;
}

int Sum(int a, int b)
{
    //no need for this, but for showing debugging, we do this.
    int returnSum = a;
    returnSum += b;
    return returnSum;
}
Step Out: If we realize, "The error we're looking for isn't caused in this function", then Step out is used to exit that function and go back to the line that called the function (read more about keeping track of how other functions call functions in call stack part further down).
Let say we have a breakpoint at line 12 in the code above, if we would press Step out we would end up on line 6 again, with no need of stepping over line 14 to go back.

We also have Resume which will continue the execution of code until we hit the next breakpoint.

To set a breakpoint you often press to the left of the editor and some sort of indicator should appear. You can often right-click on a line and pick "set breakpoint" there aswell. There are some other, more advanced topics about breakpoints that you can read further below.

One key feature is the fact that when you hit a breakpoint, you can edit the values of variables! So lets say that right now you're not intersted why your variable's value makes no sense, but you want to try your an if-loop thats within a if-case. If you variable's value is hogwash, the if-case will never be true and you'll never enter the loop - make a breakpoint at the if-case and just change the value of the variable and try out your look!

Breakpoint has been hit, indicated by the yellow arrow, 
By hovering over a we can see that it has a very small value, 
we could draw the conclusion that it has only be declared bu never given a value.

Watch/Local Window:
These two windows help us keep track of our variables without having to hover over them in our editor. In Visual studios, we have both "watch window" and "local window". (some IDEs might not have the "local" one)

The Watch window is at first empty. You have to add variables to it by right clicking them in your editor and click "add watch". Then you'll be able to see the value of that variable as long as it remains in the memory or you remove them, which could be nice if that variable, for some reason, is not close to your current breakpoint.

The Local window shows all variables active in the current scope and therefore changes quite radical when changing scope (when you exit a loop or function).
The local window, the value of the calculate array is indicated by red, 
that means that the last row edited this variable

This way you can see how multiple variables are modified quickly.

Call Stack:
When your programs get more and more complicated and class-functions are called from multiple places, you sometimes what to know "From where is this function called?". This is what the window Call stack can do for you. In the picture below, 
  • The top row shows where our current breakpoint is, its in the function called MoreCalculations on line 39.
  • The next row shows us that MoreCalculations was called from another function, CalculateSum and it was called on line 24 of that function.
  • The rows after that get more complicated but shows us that CalculateSum was called from our windows main and after that we get to even more complicated entries.



But what to take away from this is that we can use this window to keep track of, when and where was this function called, and we can use the call stack to retrace those steps.
Advanced Techniques
Conditional Breakpoints
Sometimes when working with breakpoints within loops, it could be a pain in the butt to having to click resume 45 times, since the error we're looking for occurs on the 45th time the loop runs. That's why we want to use conditional breakpoints. There are often two methods for this.

  • The first one is to tell your editor "I only want to break when i've passed this breakpoint 45 times or more" (could be useful in a while(true) loop)
  • Second one is "I want to halt execution when this variable has the value of 45" (useful in for loops e.g i == 45).
This can be useful to speed our debugging processes up.

Disassembly Code
Just before your code is turned into binary, its first turned into Assembly Code. These are CPU specific instructions that are incredibly cryptic and quite difficult to read if you don't know how. This is a very advanced topic that related more to optimization debugging, but in certain cases, the assembler code can help you find the problem to why your software crashes.
I won't talk about it here, because at the time my knowledge for this is quite limited. But if you're intersted, I'd recommend Alex Darby's Low-level Curriculum series over at #AltDevBlogADay

Monday, December 31, 2012

Music of 2012

Both Fredrik and I enjoy music to a great extent. It's often weird music that none of our other friends get, so its our own little zone where we can go nuts and nerd about. So here is our picks for top 5 album of the year!

Erik's Top 5

  1. Converge - All We Love We Leave Behind
I'm not a big fan of hardcore music. But there is something with Converge and their albums that just strikes me right. 'Jane Doe' and 'You Fail Me' is pure gold in my sense. And now this album will now join with the same feeling of great music that, I believe, beats all other hardcore music out there.
  1. Nadja - Dagdröm
For a couple of years now, I've listened to this duo consisting of Aidan Baker and Leah Buckareff and even though I enjoy all most everything they release, this one has taken hold in me greatly. Its become a great way to introduce this band to my friends.
  1. Storm Corrosion - Storm Corrosion
This is a musical collaboration I've been waiting for. One of my favorite musicians, Steven Wilson and another favorite aswell, Mikael Åkerfeldt. While the album really doesn't resemble either Porcupine Tree or Opeth, It's kinda creepy and still very beautiful and I've enjoyed it alot.
  1. Old Man Gloom - No
This collection of excellent musicians has done it again, a kick-ass album. While Christmas remains my absolute favorite OMG album, this one still has some great moments.
  1. How To Destroy Angels - An Omen EP_ 
This is the new creation of Nine Inch Nails's Trent reznor. Together with Atticus Ross and his wife Mariqueen aswell as Rob Sheridan. While its not spotless straight through, it has its great songs thrown in.

Fredrik's Top 5

--------------------------------------------------------------------
Extra: 'Godspeed You! Black Emperor! - Allelujah! Don't Bend! Ascend!'
We felt this album couldn't fit on the list, mostly because its not "new" songs, only that they've finally been recorded. The band have been playing these songs for quite some time live. Still - great to see one of our absolute favorite bands are on the move again and they deserve to get an extra mention!

Sunday, November 18, 2012

Stay Focusd!

Both me and Fredrik been busy for a while now with things happening in school and been quite bad at updating the blog.

But we have a recommendation for everyone out there: "Stay Focusd!"
It's an extension for chrome that helps you avoid procrastinating in different ways.
- Set a fixed amount of minutes to surf on specific websites
- "Nuke" the internet and stop you from checking twitter/facebook every second.
- A good system to make sure you don't disable the system.

It's a great system for making sure you don't keep watching youtube videos all day instead of actually doing work.

Check it out: https://chrome.google.com/webstore/detail/stayfocusd/laankejkbhbdhmipfmgcngdelahlfoji

Thursday, October 11, 2012

Did internet kill Point & Click Adventures?

When I heard that Revolution Software was going to go ahead and make 'Beneath a Steel Sky 2', I was so psyched! BASS was one of many 'Point and Click' games I played as a very young boy and I would consider it, along with 'Day of the Tentacle' and 'Simon the Sorcerer 2'. one of my favorite games of all time. I find myself coming back to this game and wishing that someone explored more of this fantastic setting... And finally it has come true.

But why did it take 18 years? And where did the classic 'Point and Click' game go?

'Exterminate! Exterminate!' Joey

When I played 'Simon the Sorcerer 2', I could go around trying to use everything together with anything else and see if that would do any progress(the fact that I was like 6 and didn't know any English at all didn't help). But then my uncle gave me a document with a full walkthrough, and I could finally finish the game. Even though you can think of walkthrough as cheating, I still felt pretty good about finish the game that way. Mostly because it took a lot of effort to actually find this walkthrough, it turned into a puzzle itself since finding things on the internet back then wasn't the easiest.
   Today, it takes just a few clicks to find a walkthrough games, and for point and click games.. that's a bad thing since the puzzles are the key challenge of the entire game. So I have to ask myself:

Did internet kill the classic point and click games?

Did people stop enjoying these type of games because of this easy access to walkthroughs? Or were people just tried to the gameplay? I believe that somewhere along the line, the games together with walkthroughs just turned into a series of necessary steps to complete the games. People didn't longer consider it a challenge since every solution was so simple to find. And gradually, these games stopped being released...

The latest point & click game I played was the 'Back To The Future' episode games. And being a big BTTF fan, I really enjoyed these games and their great storyline. But I'm not sure what I think of the clue system they have in that game. In one way it works good since you can get a hint but not the entire solution directly, But the easy access to actually getting the answer is even easier than the walkthroughs! You don't even have to switch to a web browser, the solution is inside of the game. It turned into a Pandora's box, you knew the solution was there so you wanted to look, but feel it would be wrong to do it.

I believe that games like these must add something more to their gameplay to make it more attractive on the market again.  And I wonder if BASS 2 and Double Fine Adventure will be a homage to the old classical games or if we will see a revolution and perhaps the reincarnation of point and click games?