Home Projects Research Misc. Contact

Java .Blend Viewer

Demo Application and Examples for Java .Blend


GPL v3


Holger Machens

This is a collection of examples to demonstrate the use of Java .Blend.

Project Contents

  • src: Source code of the viewer application.
  • jb-examples: Some examples demonstrating reading and writing of .blend files.
  • examples: Example blender files to be displayed by the viewer.
  • src-dna: Source code of Java .Blend DNA API for Blender v2.83.18 files.
  • src-io: Source code of the blender I/O utils required by DNA API.
  • src-soapbox: Source code of a simple render engine (beta).
  • resources: GLSL shader programs used by soapbox.
  • src-appbase: Source code of utilities used by soapbox.
  • src-json: Source code of a JSON API.
  • lib: Libraries (JAR) of LWJGL and JOML.


Import in Eclipse

  1. Extract downloaded zip-file
  2. In Eclipse create a new Java project and select the extracted directory as Location
  3. Click on Finish

Java .Blend Viewer

Source code: src/*
Main class: org.cakelab.blender.BlenderViewer

The application reads a given Blender file and displays it. It will start in a debug view, which shows normals and camera orientation as well as key-bindings (use F1-key to see regular view).

DISCLAIMER: This application and the underlying render engine is meant for demonstration purposes only!

The application is based on LWJGL, JOML and contains an object-oriented abstraction layer (packages org.cakelab.soapbox and org.cakelab.oge).

The most important part of the application is found in package src/ There is a class BlenderInput, which offers all kinds of methods to retrieve data from an associated blender file using the generated DNA classes for a specific render engine of course. BlenderInput uses a converter class ConvertBlender2OpenGL located in the same package. It converts data of the .blend file in internal representations used by the underlying render engine in org.cakelab.soapbox.

Example: Converting .blend to JSON

File: jb-examples/org/cakelab/blender/io/input/

This example demonstrates how to implement a class which converts the whole Blender file into a JSON representation. The example makes use of the java reflection API to perform its task on top of the generated data model. This approach was just used to further demonstrate the use of the data model.

The conversion allows to easily visualise the content of a Blender file which helps in understanding the meaning of member variables of classes in the generated data model.

Example: Exchanging Data with Blender via Copybuffer

File: jb-examples/org/cakelab/blender/io/output/

Blender provides a clipboard functionality of its own kind. On CTRL+C Blender copies selected objects into a temporary .blend file which is stored in /tmp/copybuffer.blend (I guess it's %APPDATA%/.. on windows). Accordingly, on CTRL+V the content of this file is pasted in the currently selected scene.

The example code in demonstrates how to fill the copybuffer with a mesh (simple cube with texture).

Example: Creating new Blocks

File: jb-examples/org/cakelab/blender/io/output/

The factory class of the generated data model (see gen/org/cakelab/blender/utils/ provides several methods to create new blocks for structs, arrays and pointers. This example provides multiple examples to demonstrate the use of those methods.


This work is published under GPL v3.0.

This work includes a copy of LWJGL 3 which is licensed under "a BSD license".

This work includes a copy of JOML which is published under an "MIT license".

Holger Machens, 11-Dec-2022