segunda-feira, 15 de julho de 2013

Blender doesn't do Constructive solid geometry

On a presentation on FISL14 about the metamaquina I first heard about the openscad language. Openscad is a language to build 3D objects.
There are many advantages when using a language to build a 3d object instead of using a interactive editor.
You can use version control on your model, so you can see why something was changed or why it was build in that way.
Changes on your model are also easier. For example, if you want to change the size of a hole on a cube, you have to change just one line of code, instead of a minute fiddling with your 3d editor.
But the problem is that the openscad has its quirks. For example, the variable scope is really, really weird.
Here is a sample from a openscad wikibook :

p = 4;
test(5);
echo(p); 
p = 6;
test(8);
echo(p);
 
module test(q)
{
    p = 2 + q;
    echo(p);
 
    p = 4 + q;
    echo(p);
}
Which outputs:

ECHO: 9
ECHO: 9
ECHO: 6
ECHO: 12
ECHO: 12
ECHO: 6

WTF!!
So, I thought why would I learn yet another language when I could use python and use an editor to wich I was already familiar?
At first, Blender seems to have all the functionalities openscad has, and even if it doesn't, it's easy to add them.
To prove it could be done I started rewriting the openscad examples as python scripts for blender on blender 2.67.
The first example worked, but I couldn't make the second example. Turns out there's a bug on blender when you try to use the boolean modifier union on two meshes that have a intersection on a plane and vertices on the same coordinate.
On this screenshot the rigth part is what you expect blender to do and the left is what it actually does. I moved the central cube a little on the left example so the union worked.

Blender file



Blender is not supposed to be used as a cad program, and from the looks of it, this bug will not be fixed .

So, back to openscad ....

segunda-feira, 1 de julho de 2013

Trying to add 3d models on photos using blender

From the office's window:


 This image uses the model created by Pjotr Batmobile-89-92 available on Blender swap

Using plasma material on blender cycles to make an wallpaper

I was trying to achieve a plasma effect with a velvet shader on blender but the result was really disappointing.
While searching on the blender forum I stumbled upon this great plasma material implementation
This is a abstract wallpaper I've made using the plasma material
And the blender file