2

I'm working on a small 3D engine written in Java. Java is mainly used for portability (desktop and android) and available libraries. Blender provides tools for designing levels.

I wish to use the same java library for exporting and loading custom data.

How can I mix Blender, Python and Java ?

I thought about BlenderJava and Jython but this is very experimental.

Thanks

PS : Did anyone already use execnet with Blender ?

asked Aug 7, 2013 at 8:02
4
  • Uh? What is the point of porting Blender to Java? Commented Aug 7, 2013 at 8:08
  • I'm not trying to port blender to java but I want to glue blender and a java library. Commented Aug 7, 2013 at 8:20
  • I think you should write a Python script to export the data you want in the format you want for java. Python's actually a really nice language and it's easy to pickup. Commented Aug 7, 2013 at 10:19
  • I use Python everyday but if I stop using Blender I want to continue using the export library, rewriting the whole thing is costly. Testing is also simpler if I can export and load data with an unique library. Commented Aug 7, 2013 at 12:39

2 Answers 2

1

Blender + Java:

Well, if you're talking about creating a scene and then loading the .blend file, that not a good approach. You probably want to export the level/character/etc as something else. I've worked with openGL and java before. I recommend exporting as a collada (.dae file). Collada files are xml based (easy to parse using DOM or SAX) and dont carry any of the extra blender data that isn't useable by gl anyways. Collada files support animation frames, bone structures, light sources, materials, textures, colors, normals, and vertices. As well, since they are XML based files, it is easy to open them with a text editor and study the file type. Since java already has XML parsers in its library, this file type is easy to use and read. It data can almost immediately be dumped into a BufferObject or immediate render mode.

Fbx is another file type that supports all elements of blender. The problem with this type, is that is has both a binary and text format. The structure varies a little bit so it is difficult to find resources describing the binary file format. As well, it is a copyrighted file type.

Obj files are the easiest to read and use. However they store texture/material data in a separate external file. As well, they in no way support animation. Because of this, they are a poor choice for many reasons. However, if you have a static object (a box, or an inanimate tree) this file type may work for you.

As I mentioned before, it is difficult to directly mix blender and java without a file type easily readable by both sides, .blend files are not easily readable by java.

Java + Python:

This is a bit more tricky. I think Jython is a good place to start. Python can be used similarly to a scripting, at least when used with an engine. How you choose to implement it is entirely up to you.

Personally, I found to easer to create a game console with pre-made java commands. I have simple text files that invoke commands to the console for scripting usages. The scripts can define things such as ai movements and resource loading.

I struggle to find a strong set of reasons to incorporate a script-like-engine (what you would likely code in python) into a game engine. I'll admit this is not an area of engine development I have worked with a lot. I fell as though, either way, it will just be invoking commands (or methods) of your java classes. Perhaps someone can clarify stronger uses for python in a game engine for the both of us.

Lastly, I would recommend javaScript over python. Python is used because of it popularity and because most engines are coded in C++ or C#. Unlike java, these languages do not have a scripting "little brother". If you intend on making this a true java engine, it would be much easier to use JS as you scripting language of choice since libraries to use it are already packaged with the JDK.

Hope this helps some.

answered Aug 7, 2013 at 15:52
Sign up to request clarification or add additional context in comments.

3 Comments

No I don't want to load a blend file.But a file exported using a java library (part of my engine). Actually, I use XML and the associated Java tools.
Do you know a way to use Jython from Blender ?
I posted a new answer.
0

So, what I'm getting is that you want to both build and read your own file type? Perhaps XML based? The only to incorporate your own library into blender, is through python. I know people have build python extensions and plugins for blender (including an animation exporter).

People generally only use their own file type, with their own tool (e.g. if you created a program like blender). Because, say someone prefers to use a different 3D modeling software, they would then be unable to use your engine. Ideally, the tools and render engine function independently of each other. Blender can already export several standard filetypes that offer a much greater flexibility.

I would not create a library to export a custom file type, unless you make a custom tool as well. It will only encourage others to use a different engine, not yours.

By the way, this question belongs on stackexchange not stackoverflow.

answered Aug 8, 2013 at 15:02

2 Comments

I already built a library and now I want to integrate it into blender. Sharing or selling the engine doesn't really matter.
I'm not sure that's possible. From my experience blender is not structured that way.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.