domenica 18 aprile 2010

Opening Sopcast links from within Firefox on Ubuntu Karmic 9.10

I'd like to open sop:// protocol links automatically in Firefox. The most popular solution I found is:

 1. In Firefox, in the Location bar, type about:config and press Enter.
 2. Right-click anywhere in the grid, choose New, then String.
 3. In the Enter the preference name prompt, type in network.protocol-handler.app.sop and press OK.
 4. In the Enter string value prompt, type sopcast-player and press OK.
 5. Try to open sop:// link on your favorite website and you will be presented with dialog box where you can search location of sopcast player. Navigate to ~/usr/bin and point to sopcast-player and click OK.
 6. OK out of dialog box and now all sop:// links should open sopcast player automatically.

This solution doesn't work for me. When I try to to open sop:// link, I'm not presented with "Open with..." dialog box. I receive an error message like:

Firefox doesn't know how to open this address, because the protocol (sop) isn't associated with any program.

In my case Firefox 3 does not actually launch sopcast-player using the network.protocol-handler.app configuration option.
If I go to Edit -> Preferences -> Applications, the sop protocol is not listed and I cannot add it there.
So I tought to retrieve all needed parameters from Windows and add the protocol manually via config file. mimeTypes.rdf stores information about which action is to be performed when downloading certain types of files, such as opening the file in a specific program or saving it to disk. mimeTypes.rdf is stored on our hard drive in ~/.mozilla/firefox/xxxxxxxx.default/
1.  Quit Firefox
2. we can back up the profile directory: if something goes wrong we can restore original files.
3. Let's open up mimeTypes.rdf. We have to find the section and modify it in this way (adding the line <RDF:li RDF:resource="urn:scheme:sop"/>):

<RDF:Seq RDF:about="urn:schemes:root">
    <RDF:li RDF:resource="urn:scheme:mailto"/>
    <RDF:li RDF:resource="urn:scheme:irc"/>
    <RDF:li RDF:resource="urn:scheme:ircs"/>
    <RDF:li RDF:resource="urn:scheme:webcal"/>
    <RDF:li RDF:resource="urn:scheme:dlc"/>
    <RDF:li RDF:resource="urn:scheme:sop"/>
</RDF:Seq>

4. Now we have to add these parameters below the line </RDF:Seq>:

<RDF:Description RDF:about="urn:scheme:sop"
                              NC:value="sop">
   <NC:handlerProp RDF:resource="urn:scheme:handler:sop"/>
</RDF:Description>
<RDF:Description RDF:about="urn:scheme:handler:sop"
                              NC:alwaysAsk="true" />


Done! Now if we open sop:// protocol links in Firefox, we will be presented with "Open with..." dialog box. Or, once Firefox is loaded, we can go to to Edit -> Preferences -> Applications and set the location of sopcast-player.

EDIT (09/12/2010):
It may be necessary to modify the boolean value of network.protocol-handler.expose-all on Ubuntu 10.04:

 1. In Firefox, in the Location bar, type about:config and press Enter.
 2. Set the value of network.protocol-handler.expose-all to false .
 3. Try to open sop:// link on your favorite website and you will be presented with dialog box where you can search location of sopcast player. Navigate to ~/usr/bin and point to sopcast-player and click OK.
 4. OK out of dialog box and now all sop:// links should open sopcast player automatically
 5. We can restore the value of network.protocol-handler.expose-all to true.

Best regards.

venerdì 16 aprile 2010

CGPersia toolbar for Firefox

CGPersia is a great forum dedicated to 3D arts and related softwares. CGPersia has a lot of sections and sub-sections. Since I visit CGPersia every day, I created a toolbar extension for Firefox to speed up my navigation and to easily search threads and posts.


The very early version of the toolbar is available here.
It does not contain all of the features that are planned for the final version, but it works fine for me.
Probably I will add drop-down menus with dynamic links to hottest and most  viewed threads and a window for advanced search.
I'm releasing it because a 3d passionate could find it useful.

Best regards.

mercoledì 14 aprile 2010

Creating a 3D terrain from height measurements

Sometimes we architects have to create a digital representation of a ground surface topography (DEM) for 3D visualizations. I usually start with a .dwg file and a bunch of  height measurements. The image on the left is a typical case.
I invented an "original" way to crank out a digital elevation model.
I usually use AutoCAD Map and a couple of extra tools.
I export all measurements in a text file and then import it into AutoCAD Map. Exporting all measurements is quite simple: I use CAD2FILE, a free Lisp program that allows me to export all needed parameters into a text file.

We can select the file type to create (on the left) and the properties to send to the file. In my case I select Insertion Point and click  Okay.

The result is a text file with this structure:

Start X,Start Y,Start Z,Text Value,
2318050.04,4644289.52,0,12.4,
2318382.41,4643741.07,0,12.4,
2318385,4643737.46,0,12.4,
2318387.03,4643734.37,0,12.4,
...

Start X, Start Y,Start Z are the coordinates of the insertion point of the measurement. Value is the measurement.

Cool! What I wanna do now is fix this file because AutoCAD Map can import a series of x, y and z coordinates only, without other parameters.
To do this I wrote a simple Java program named Virgola:




// Author: Stefano Bolli
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;

public class Virgola {

public static void main(String[] args) {
Virgola virgola = new Virgola();
}

public Virgola() {

// Text directory
File textDir = new File(".");
// Filter for text files
TextFilter tfilter = new TextFilter();
// Text files
String[] textList = textDir.list(tfilter);

if (textList.length == 1 ) {
System.out.println("I found the file:" + "\n");
System.out.println(textList[0] + "\n");
System.out.println("I'm fixing the file...");
readFile(textList[0]);
}
else if (textList.length > 0) {
System.out.println("\nFound multiple files. Indicate the file you wanna fix:");
System.out.println("\n");

for (int i = 0; i < textList.length; i++)
System.out.println(i + ") " + textList[i]);
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String fileChoosen = in.readLine();
int x = Integer.parseInt(fileChoosen);
readFile(textList[x]);
} catch (IOException e) { }
}
else
System.out.println("No text file found");
}

public void readFile(String fileToRead) {
try {
BufferedReader br = new BufferedReader(new FileReader(new File(fileToRead)));
String line;
Vector vector = new Vector();
while ((line = br.readLine()) != null) {
// Store the row in the vector.
vector.addElement(line);
}
br.close();
SaveFile(vector, changeNameToFile(fileToRead));
}
catch (IOException e) { } }
public String changeNameToFile(String name) {
String newName = name.substring(0, name.lastIndexOf(".")) + "_fixed_by_Virgola.txt";
return newName;
}
public void SaveFile(Vector v, String fileToSave) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(fileToSave));
for (int i = 0; i < v.size(); i++) {
String s = (String)v.elementAt(i);
if (!s.startsWith("Start")) {
out.write(cleanLine(s) + "\n");
}
}
out.flush();
out.close();
} catch (IOException e) {
}
}
public String cleanLine(String line) {
String oldLine = line.substring(0, line.lastIndexOf(","));
String newLine = oldLine.substring(0, oldLine.indexOf(",0,")) + oldLine.substring(oldLine.lastIndexOf(","));
return newLine;
}
/** * Filter for text files. */
class TextFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
boolean acceptFile = false;
if (name.endsWith(".txt"))
acceptFile = true;
return acceptFile;
}
}
}


If someone needs this program, I can compile it and send as .exe file.


Ok, now we can import the text file into AutoCAD Map and create the terrain.
The final mesh is a triangular irregular network and can be imported into 3d softwares like Maya o 3DS Max: as you can see, I was working on a level land with a river. There are a few errors I can fix quickly before smoothing the mesh.

Best regards.

JDownloader Click'N'Load on Ubuntu Karmic

JDownloader is a terrific Java software to simplify downloading files from One-Click-Hosters like Rapidshare.com or Megaupload.com. These sites allow us to upload any kind of file that can be downloaded by other users. If the file size exceeds the allowed limit, the data are splitted into a lot of parts, zipped and uploaded to the hosters. If we don't have a Premium Account, we have to download one part at time. Click'N'Load is a JDownloader's built-in technology to downloading a container file that lists the different parts. Installing Click'N'Load on Windows is pretty simple. On Ubuntu we have to install it by ourself:

Download the Linux/Mac Installer/Starter, open it and change the path to the Installation folder, make it executable with the terminal command:

 stefano@SERVER:~$ chmod +x jd.sh

and run it. This file will download the latest Jdownloader.
Now, what we wanna do is add some protocols to Firefox to handle Click'N'Load.
On Linux/MAC, some needed protocols are not controlled by the OS. If you are using Firefox, you may add the protocols by ourself:
  1. Open Firefox advanced configs by typing “about:config” in the address bar.
  2. Right click –>new: create the following entries for each protocol:
    1. Replace PATH_TO_SCRIPT with the path to jd.sh. First Line is String
    2. Second Line is Boolean
  3.  Restart JDownloader
 network.protocol-handler.app.jd = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.jd=true
 network.protocol-handler.app.jdlist = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.jdlist=true
 network.protocol-handler.app.ccf = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.ccf=true
 network.protocol-handler.app.rsdf = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.rsdf=true
 network.protocol-handler.app.dlc = PATH_TO_SCRIPT/jd.sh
 network.protocol-handler.external.dlc=true

martedì 6 aprile 2010

Funky gallo

My brother Massimo manages a team of players in an Italian fantasy soccer league named Hattrick. The team is named Alligallya, a play of words from an old Italian song . He asked me for a logo for his team and I was very happy to sketch a funky cock (on the left... I'll buy a pen tablet as soon as possible, I think I need it :) ) and trace it in Photoshop. No special effects, I used transparent gradients for reflections and soft shadows to fake depth. This kind of works remembers me how lazy I'm: the head is good, the torso and everything else are not exceptional. But I need a rest after a couple of hours. Probably I'll fix the torso tomorrow. I like to help my brother, his team is quite scanty (lol, it's a joke, Max) :)
Best regards

giovedì 11 marzo 2010

A pilot for my Viper MK II: sculpting the head

My Viper needs a pilot, so I have just started to sculpt the head.

The first step: I have created a low poly head in Maya and then I have imported it into ZBrush. The goal is achieving the normal map from the hi-res model and using it in Maya. Nothing fancy here, I need a simple model: the pilot will be visible in a few frames during the animation, the fighters are very detailed and I can't "spend" a bunch of polygons. I found out some interesting photographs browsing the internet to use as reference for my 3D head.


The image on the left is the result of my work. Using the standard brush and the move tool, I have sculpted a simple head in 30 minutes. I'm pretty happy about my head, I'm creating a tough, die hard pilot! I have used a couple of alpha brushes to add details like the beard, the eyebrows and hair. Probably this step is useless, but ZBrush is so amusing! Now I can create the normal map to "smooth" my low poly head.



The next step is boring (for me): it's time to use Photoshop to paint a texture on the UV map. Probably it's the moment where I waste a lot ot time. I can create a model very quickly but I'm never satisfied when I use Photoshop. Actually I'd like  to send my model to the texturing department but I  dont'work for Pixar, it's all home made. In this case I created the texture in 3, 4 hours making it again, and again, and again. I used a lot of references I found in internet. The result is not phenomenal but I can live with it.  I really don't like flat hair but I cannot use fur, it's too expensive. No eyes at this moment, this guy is still blind!

The day after: I have tought of using a technique for video games to have my hair. The idea is simple: creating a lot of cards to fake the hair. The result should not be terrific but this guy will have a helmet and I won't spend a lot of resources for the hair. The problem is that I have to come back to Photoshop to create a new texture with a good alpha channel. The image on the right shows the cards on top of the head.




What a crew cut for this guy! I think the result is pretty good, considering I'll must model the helmet. It's very important to program what we are going to see in the animation not to waste useful resources. The final texture is a tga file with an alpha channel for the transparency. I used a single hair wisp scaled, mirrored and altered a lot of time to achieve a minimum of variety. 1 hour of Photoshop for this work. As said before, this result could be better but I have to model the helmet, the body, the boots and the hands yet. And this guy will be visible for a few frames. Ok for now, it's time to find a reference of the helmet used in Battlestar Galactica.
Best regards!


mercoledì 13 gennaio 2010

Creating a hostname that points to your IP address

If our computer has a dynamic IP, we can create a hostname that points to our IP address. A hostname is very useful because it allows us to use a static name (ie. myname.host.org) instead of a dynamic IP. For example, we can think to use a hostname to contact a remote computer with a dynamic IP address.
There's a very simple way to do that: we can use a free service provided by DynDNS.com:

Redirect your browser here and create an account.
As you can see, "Dynamic DNS Free (DDNS) allows you to create a hostname that points to your home or office IP address, providing an easy-to-remember URL for quick access. We also provide an update mechanism which makes the hostname work with your dynamic IP address. We continue to offer this service free to the Internet community as we have done so for nearly 10 years."
The service is free so click on "Get Started".

Insert a name  and choose a domain from the combobox. Leave "Host with IP address" selected. Insert the remote IP or "use auto detect IP address". Leave "Mail Routing" unchecked.
Now we have to choose the services we would like to use with our hostname: in my case I selected Remote Desktop and SSH.
Click on "Add to cart" and don't worry: the service is free.

As you can see, our cart now contains free services only. We can activate our hostname.
Click on "Next >>" and then on "Activate Services".








Now we have to find a method to inform DynDNS' servers when our remote computer changes the IP address. Fortunately DynDNS allows us to download an update client: "The update client periodically checks your network's IP address; if it sees that your IP address has changed, it sends (updates) the new IP address to your hostname in your DynDNS.com account".

Cool! Redirect you browser here and download the client for your OS.

In my case, i will use the Linux/Unix client. If you have Ubuntu you can follow next steps:

unpack ddclient, run a terminal and type:

 stefano@SERVER:~$ sudo cp ddclient /usr/sbin/
 stefano@SERVER:~$ sudo mkdir /etc/ddclient
 stefano@SERVER:~$ sudo cp sample-etc_ddclient.conf /etc/ddclient/ddclient.conf
 stefano@SERVER:~$ sudo gedit /etc/ddclient/ddclient.conf

uncomment and use following parameters:

 protocol=dyndns2
 use=web, web=checkip.dyndns.com, web-skip='IP Address'
 server=members.dyndns.org
 login= your_username_at_DynDNS
 password=your_password_at_DynDNS
 your.hostname.org

Now we can run ddclient as a daemon at boot time. Run a terminal and type:

 stefano@SERVER:~$ sudo cp sample-etc_rc.d_init.d_ddclient.ubuntu /etc/init.d/ddclient
 stefano@SERVER:~$ sudo update-rc.d ddclient defaults
 stefano@SERVER:~$ sudo /etc/init.d/ddclient start

Done!
Best regards.

martedì 12 gennaio 2010

Documenting architectural facades with a photogrammetry software



The image on the left is a mosaic of several photos traced in AutoCAD and representing the architectural facade of San Macuto in Rome. In this case my CAD drawing is superimposed on the mosaic.
All photographs I took contained perspective distortions which were eliminated with a freeware photogrammetry software called RDF. Then all images were composited in Photoshop and, as said before, traced in AutoCAD.
I could take the entire facade of the church in just one photograph but I needed all architectural details. It's almost impossible to do a work like this with a single image.
Precision mosaicing would require a dedicated software solution because Photoshop leaves us the task of mounting all photos together as best we can. Anyway the result is pretty cool and suggestive. Some programs offer an automatic vectorialization of a photo but I often don't like the results.
RDF uses a method called photogrammetry with measurements: the image is straightened up through measurements taken on the object of photogrammetry. So we need at least two measures (one horizontal and one vertical).
The programs offers two ways to fix the perspective distortion: analytic and geometric. I prefer the second way because it's faster and more intituitive, so I realised a short video tutorial to explain the geometric mode to straighten up photos with RDF. 
English and Italian subtitles are available for this video. Locate the logo in the lower right corner and select the subtitles you prefer.





It's also possible to use this method to create perfect textures for 3D models.
The image on the left is a render of a 3D model (Concattedrale di Taranto by Gio Ponti) I made some years ago.
All textures were created straightening up several photos with RDF. If the model has a good UV Map  with the right aspect ratio, it's pretty simple to use photographs as textures.
In this case the result is often very realistic.

giovedì 7 gennaio 2010

Keeping up the (good?) 3D work : a simple animation of my Viper MK II


I'm just working on my 3D Viper MK II. Two months ago I rendered a simple shot with Autodesk Maya: I wanna publish my test to compare it to future results:


For this test, I used particles to realised two nebulas,  pure gases, the stars and the engine flames. No sound at this moment. I rendered a bunch  of passes  composited in Eyeon Fusion. Once my modeling work will done, I'll render a complete animation of a fight between Viper and Cylon Raider (already finished).

Best regards.