April 16, 2012

three.js and blender

Time for a new post.

All you need is the blender 2.x exporter available here github mrdoob. Then download the (customized) boilerplate here (the save button didn't work in my version of chrome but firefox was fine)

After leeching the boilerplate code, I removed the stats and other typography and looked at the examples on http://mrdoob.github.com/three.js/ and saw the walt disney head, and stared at the underlying code for a while and noticed code that resembled the expected geometry loading.
loader = new THREE.JSONLoader();
loader.load( 'obj/suzi.js', function ( geometry ) {
 var mesh = new THREE.Mesh(geometry, new THREE.MeshNormalMaterial({overdraw: true}));
 scene.add( mesh );
});
This suggested it would be easy to simply export suzanna from blender using the export script and stick it into a small html file. It was. It's a little sluggish on my slow machine with power saving switched on - but that's not three.js' fault.

However, there is more!

The following links may or may not work on your computer, if you know why that is then drop me a line.

This hasselblad projection painted model was done a while back and I never got around to really finishing the texture. The html/js still throws a small error, which is probably easy to crush, but the scene renders OK in Chrome. A Stackoverflow post gives slightly different code, but it helped figure out how to pack the texture into the material. Now I should really get comfy with the rotation code and tame this sucker.

Here is a version of the texture with wireframe to show the underlying quad geometry. Or this one, it's with tamed rotation

----------

original image obtained from: mrmartinweb.com, permission to use the image is pending

How to projection paint

Best watch this video by the guy that coded the projection painting features, you will need no other introduction

4 comments:

  1. hi :)
    may i have ur email? i want to ask about python in Blender. I'm beginner in those things. Thanks :)

    ReplyDelete
    Replies
    1. naninuneno, please ask any questions here instead - i won't bite :)

      Delete
  2. I have a question. My object is Black when I load it. I'm not sure why...

    http://stackoverflow.com/questions/15995050/how-can-i-import-my-object-with-its-inherent-textures-from-blender-to-threejs

    ReplyDelete
    Replies
    1. I've responded. should be simple enough!

      Delete

I recommend using Blender.StackExchange.com for python scripting questions. I will no longer be answering questions on this blog.