sinclairzx81 / zero

A 3D renderer written in JavaScript and rendered to the terminal.
Other
2.41k stars 143 forks source link

How to export from blender #8

Closed Rillian-Grant closed 4 years ago

sinclairzx81 commented 4 years ago

Hi, if you're referring to the ./scene/source/desk.blend blender file, there is no export functionality other than a small script that exports the camera animation.

For this demo, I just manually exported each object in the scene as a wavefront (.obj) file, as well as the textures that are baked for each object in the scene (or more accurately, for each object with an associated render texture in its material). As for the script, if you run the script inside the desk.blend blender file, it will write the camera animations based on the 'camera' and 'target' (the output file is `./scene/animation.json')

Its a rather manual process and could use automating, but its not something i bothered to do for this demo and only really focused on exporting the animation (as it would have been a pain to manually create that animation.json file by hand). Also, I'm not really a blender scripting expert.

In saying this, it is possible to create your own scenes in blender if you're fine with manually exporting your own geometry and textures....check the ./src/loader.ts file for how things are loaded in...

The requirements for the geometry are: 1) Exported geometry should be triangulated 2) The geometry should have vertex data for (position, normal, uv) 3) Saved as .obj (one object per .obj) 4) Each .obj should have a corresponding .jpg (as per loader.ts)

Or alternatively, look at FBX, GLTF formats, and just implement your own stuff from there.

That's all really, hope that helps :) S