Pages

Wednesday, July 23, 2014

Learning Blender

Hello everyone!

Guess what I've been up to: learning how to use Blender.
I must confess I am loving it! When I get to see the final result, I get a pretty similar feeling to the one I get when I finish programming some cool feature on a project.

I haven't done anything of my own just yet. I'm still just watching some tutorials and repeating what I watch but tweaking some details. I'll leave some screenshots here of what I've done so far and the link to the video tutorial.

By the way, I find these tutorials GREAT. They are simple, concise and assertive making it easy for anyone to follow up. Congratulations to tutor4u for making such a nice playlist of tutorials.

Screenshots



Cloth napkin


Icy text


Realistic chain


Planet bursting into pieces



Wooden cup



Stuffed bear


Dissolve Animation

Sunday, July 20, 2014

[Minix] Posts index

Minix

Final result preview

I thought it would be appropriate to have a preview of the final result of the project covered in these tutorial series in it's index, so here it is:


Table of contents

Introduction
You can actually skip this and head to the first tutorial right away.

Tutorial 1
How to install Minix and setup VMware Player

Tutorial 2
RSE and Minix commands

Tutorial 3
Setting up a project with some useful scripts

Tutorial 4
Adding graphics to a project

Tutorial 5
Adding keyboard input to a project

Tutorial 6
Adding a timer to a project

Tutorial 7
Adding a mouse to a project

Tutorial 8
Loading bmp images

Tutorial 9
Creating a state machine and a main menu

Tutorial 10
Creating the game state, adding a moving background and ground

Tutorial 11
Adding flappy and the mario pipes

Main menu screenshot

[Minix][Tutorial 2] RSE and Minix commands

In this tutorial I will teach you how to link Eclipse with Minix through RSE and the infamous Hello world program.

RSE, also known as Remote System Explorer, is a plug-in for eclipse which will be essential to develop Minix applications.

First of all, open Eclipse and boot Minix.
Log in minix. If you did not catch this in the previous tutorial, both the username and password are lcom.



In eclipse, open the Remote System Explorer perspective.



If RSE is not on the list, you will need to install it:
  • go to Help > Install New Software;
  • paste the url of the repository of your eclipse version. In my case it is:
    http://download.eclipse.org/releases/luna/
  • type "remote" in the filter
  • select Remote System Explorer End-User Runtime
  • click next, I agree and finish

We now have the RSE perspective up and running, but we still have to configure the connection to Minix.

Click the button to add a new connection:



Select SSH Only and press Next.
Name the connection minix and press Finish.



The minix connection should now appear on the list of Remote Systems:



Right-click Sftp Files and choose Properties.
Under Subsystem, change the port to 2222 and save by pressing OK.



If you try to open My Home, you will be prompted to enter a password. Again, use lcom for both User ID and Password and press OK:



Since it is the first time we are opening the connection, some messages will pop up...
Just press Yes, Yes, Yes and Ok.



Now that we have everything set, let's create our first program via RSE!
Right-click My Home > New > Folder and name it hello-world.



Right-click hello-world > New > File and name it main.c.



You should end up with:



So, what we've done so far was to create a folder and a file inside it using RSE. Let's switch to VMware and see if the folder is really there.

Right after logging in, type ls and press Enter. This command lists the content of the current folder we're in. If you did everything correctly so far, there should be a folder called hello-world!



Now, let's navigate to hello-world and check it's content.
To navigate to another folder, use the command cd destiny-folder. So in our case, just type: cd hello-world. If you now list the current folder's content using ls, the result should look like this:



I really hope you are getting the hang of this and hopefully everything is making sense.

Let me teach you a little trick that is REALLY useful.
First, navigate to the folder that contains hello-world, in other words, go up in the folders tree using the command "cd ..".
Just to make sure we're where we wanted, type ls. The result should be:



The trick I wanted to show you is the auto-completion. Trust me, it is VERY useful.
I want you to navigate to the hello-world folder again, remember the command? Yes, it is cd hello-world. BUT DON'T TYPE IT JUST YET! I want you to type cd h and afterwards to press Tab on your keyboard. Hopefully, after pressing tab, the command auto-completed to ch hello-world/.



And that's it, try not to forget this and use it whenever you can, since it makes browsing through folders blazing fast and you will never misspell a folder again.
The auto-complete also works with files. You must notice though that when you have more than one folder starting with the same letter, the auto-complete will not work and you must provide an additional letter until the prefix on the command only matches to one folder.

Time to switch to Eclipse.

Open main.c and write a simple hello world program:
#include <stdio.h>

int main() {
    printf("Hello cruel world!\n");

    return 0;
}


Save main.c and switch to Minix.

You can type the command clear to clear the minix console.
You should still be inside hello-world folder, so the output of ls should currently only be main.c.

We now want to compile main.c to create an executable file.
The command goes like: gcc -Wall main.c -o hello

The output of ls should now consist of two files: main.c and hello, the latter being the result of the compilation of main.c.
Well, what are we waiting for?! Let's run it! Type: ./hello and the result should look like this:



And there is the expected output: Hello cruel world!

I guess this is enough for one tutorial!
Let's just turn off the virtual machine and review this tutorial's commands.

To turn off minix, type shutdown. Wait for it to work, and then type off.



Minix should have turned off as well as VMware.

Commands used on this tutorial:

ls
lists the content of the current folder

cd destiny-folder
navigates to the specified folder

cd ..
navigates up (in other words, to the folder containing the current folder)

clear
clears the console

gcc -Wall file.c -o result
compiles file.c to an executable named result
-Wall is a compile flag that activates the output of all the existing warnings on our program during compilation. For LCOM evaluation purposes, this flag must be active and no errors/warnings are admitted on the compilation output.

./executable-file
runs executable-file

shutdown
turns off minix

off
completely turns off minix and closes VMware

Back to index

Click here to go back to the index post.

Script to find repositories with unstaged/uncommited changes

I found this nice script that I often use to check if I did not forget to push the latest changes to git.

Here are some instructions on how to use it:
  1. Save the snippet below to a file and name it something like multipleStatus.sh;
  2. Place the file on the same folder of your repositories;
  3. To run the script, browse to that folder and type:
    source multipleStatus.sh; find-dirty

And here is the snippet you need to save:
#!/bin/bash

function unstaged_changes() {
    worktree=${1%/*};
    git --git-dir="$1" --work-tree="$worktree" diff-files --quiet --ignore-submodules --
}

function uncommited_changes() {
    worktree=${1%/*};
    git --git-dir="$1" --work-tree="$worktree" diff-index --cached --quiet HEAD --ignore-submodules --
}

function find-dirty () {
    for gitdir in `find . -name .git`;
    do
        worktree=${gitdir%/*};
        if ! unstaged_changes $gitdir
        then
            echo "unstaged     $gitdir"
        fi

        if ! uncommited_changes $gitdir
        then
            echo "uncommitted  $gitdir"
        fi
    done
}

How to install Eclipse Luna (4.4) on Ubuntu

Installing Eclipse

  1. Download Eclipse from here;
  2. Extract it. You will end up having a folder named eclipse, copy it;



  3. Press CTRL + ALT + T to open Terminal;
  4. Type the command:
    sudo nautilus
    and then insert your password;



  5. Browse to /opt/ and paste the extracted folder there.


Creating a shortcut

  1. Press CTRL + ALT + T to open Terminal;
  2. Type:
    sudo ln -s /opt/eclipse/eclipse /usr/bin/eclipse
    sudo gedit /usr/share/applications/eclipse.desktop
  3. After these commands, gedit (ubuntu's default text editor) should have opened. Copy this and paste it there:
    [Desktop Entry]
    Name=Eclipse
    Type=Application
    Exec=/opt/eclipse/eclipse
    Terminal=false
    Icon=/opt/eclipse/icon.xpm
    Comment=Integrated Development Environment
    NoDisplay=false
    Categories=Development;IDE;
    Name[en]=Eclipse
    X-Desktop-File-Install-Version=0.22


  4. Save the text file and close gedit;
  5. This should have successfully created a shortcut. You may have to log off and back in for it to show up.