${project.version}
GPL v3
${system.date}
Holger Machens
This is a collection of examples to demonstrate the use of Java .Blend.
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.src/*
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/org.cakelab.blender.io
. 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
.
.blend
to JSONjb-examples/org/cakelab/blender/io/input/ExampleConvert2Json.java
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.
jb-examples/org/cakelab/blender/io/output/ExampleCopybufferExchange.java
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 ExampleCopybufferExchange.java
demonstrates how to fill the copybuffer with a mesh (simple cube with texture).
jb-examples/org/cakelab/blender/io/output/ExampleCreateNewBlocks.java
The factory class of the generated data model (see gen/org/cakelab/blender/utils/BlenderFactory.java) 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".