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

quinta-feira, 6 de maio de 2010

How to add an applet to your google site

I've had a google site for some time now. I've never really put an effort to do something with it until some weeks ago, when I decided to publish some applet games I've been working on.
First thing first, I clicked on  "More Actions>Manage site>Attachments>Upload" and uploaded my jar.
Well, I always used the <applet> tag to add applets to my sites (ok, I know it is deprecated but still...), so I clicked on the HTML button to add this:
<applet
code="main.MainGameApplet"
archive="pathgui.jar"
width="300" height="100"
>
Applet Didn't Load
</applet>
Just to find that Google sites erases the applet tag!

I knew that the applet tag was deprecated, and I've already saw a google site with an applet, so I knew it was possible to do it. And, after trying a lot of things I found on the Internet, the tag that worked was this little guy:

<!--[if !IE]> Firefox and others will use outer object -->
<object classid="java:main.MainGameApplet.class"
type="application/x-java-applet"
archive="http://sites.google.com/site/lucass/home/projects/path/pathgui-1.0-SNAPSHOT-jar-with-dependencies.jar"
height="505" width="500" >
<!-- Konqueror browser needs the following param -->
<param name="archive" value="http://sites.google.com/site/lucass/home/projects/path/pathgui-1.0-SNAPSHOT-jar-with-dependencies.jar" />
<!--<![endif]-->
<!-- MSIE (Microsoft Internet Explorer) will use inner object -->
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"
height="505" width="500" >
<param name="code" value="main.MainGameApplet" />
<param name="archive" value="http://sites.google.com/site/lucass/home/projects/path/pathgui-1.0-SNAPSHOT-jar-with-dependencies.jar" />
<strong>
This browser does not have a Java Plug-in.
<br />
<a href="http://java.sun.com/products/plugin/downloads/index.html">
Get the latest Java Plug-in here.
</a>
</strong>
</object>
<!--[if !IE]> close outer object -->
</object>
<!--<![endif]-->
And after that google sites wrapped my applet in a beautifull gadget box.