Giter Site home page Giter Site logo

dancovich / libgdx_blender_g3d_exporter Goto Github PK

View Code? Open in Web Editor NEW
57.0 9.0 21.0 7.58 MB

Blender exporter to create G3D text files. The G3D format is a 3D model document format compatible with the LibGDX framework.

License: GNU General Public License v3.0

Python 96.74% Java 3.26%

libgdx_blender_g3d_exporter's Introduction

logo logo

Blender G3D Exporter

This is an addon for the Blender 3D modeling tool (http://www.blender.org). The purpose of this addon is to allow Blender to export 3D models as G3DJ files (G3D models written as JSON objects).

G3D is a custom 3D model file format compatible with the LibGDX framework (http://http://libgdx.badlogicgames.com/). The format is easy enough to allow use for other frameworks and is powerfull enough to support most features for game development, like multiple materials, multiple textures, different kinds of textures (diffuse maps, normal maps, etc.) and even armature based animations. The specification for this format can be found at the project's wiki page (work in progress).

This addon is currently compatible with Blender v2.76. I can't garantee compatibility with previous or future versions, but I'll try to update it if future Blender updates break compatibility.

This software is licensed under the GNU General Public License Version 3.0 (see LICENSE).

Installation and Usage

Check out the wiki page.

Features

These are some of the things that get exported by this script:

  • Multiple materials for the same mesh (will create multiple mesh parts)
  • Diffuse, specular, opacity and shininess material attributes
  • Multiple UV coordinates for texture mapping
  • Various kinds of texture mappings (diffuse, normal, transparency, specular)
  • Armatures
  • Multiple bone animations

About the license

The intention was to make this script licensed under the Apache License v2 (same as LibGDX) until I found out any Python scripts that use the Blender API need to be licensed under the GNU General Public License. The site says they're looking into a way to allow other licenses but until that this software will be licensed under GNU General Public License v3.

Any .g3dj/.g3db files exported by this script are considered program output and as such are copyrighted to the user. You are free to use them as you see fit.

This addon uses Simple UBJSON module for Python. Simple UBJSON is licensed under the BSD license, copyright information can be found in the LICENSE file contained inside the simpleubjson package. The source code was modified to generate binary JSON files that can be read by LibGDX UBJSON reader, this source code modification is permited by the author through the BSD license.

Changes

  • 0.2.7

    • Fixed bug where having multiple objects use the same mesh data on Blender would result in multiple meshes being exported
  • 0.2.6

    • Fixed crash when using Python version 3.5.2 and up (thanks to thbell for finding and fixing this: https://github.com/thbell).
  • 0.2.5

    • Fixed wrong size of exported COLOR attribute, was exporting 3 floats when LibGDX expect four.
  • 0.2.4.1

    • Ops, changed default log level to INFO again, was set to DEBUG last version.
  • 0.2.4

    • Added option to choose between old format and new format for UBJSON data types (default is old format as in LibGDX, read 'Usage' section).
  • 0.2.3

    • Added exporter option to apply modifiers during export. Original model won't be touched and exported model will be the one after applying modifiers.
    • Support for handling vertices generated after applying modifiers.
      • Support for correctly applying the Mirror modifier. The mirrored vertices will either inherit the bone weights of the original vertices or if you have mirrored bones (bone.L and bone.R) and the modifier option Mirror Vertex Groups is checked the exporter will correctly weight the mirrored vertices to the mirrored bone instead of the original one.
      • Support for correctly applying other modifiers that create vertices like subsurf, solidify and bevel. Generated vertices will inherit bone weights from the original one.
  • 0.2.2

    • Fixed bug where using the same material on more than one mesh caused the exported to export the material multiple times.
  • 0.2.1

    • Overall performance increase in export task.
  • 0.2.0

    • Overall refactoring of the addon. New options should be easier to implement from now on.
    • The exporter now supports both text and binary G3D formats.
    • Added option to convert coordinate systems.
    • Adjusted material exporting to match the ones generated by the FBX-CONV tool.
    • The exporter no longer creates a default material for objects missing one, now a warning message appears when such case occurs.
    • Added option to limit the number of bones per vertex, respecting LibGDX default of 4.
  • 0.1.0

    • First release

libgdx_blender_g3d_exporter's People

Contributors

blackears avatar dancovich avatar remoe avatar ryanastout avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libgdx_blender_g3d_exporter's Issues

Texture file name, and Material.emissive property

This is a good utility, but I encountered a couple of issues that needed to be worked around.

I'm not sure if this was intended, but, the file name for the texture is set to the texture path relative to the blender workspace. So when using the g3d file to a libgdx project, it looks for the texture using the wrong path and will throw an error unless you modify your libgdx project to have the same relative path to the texture. Alternatively, when working in Blender you could probably load your texture from a location that matches the location of the texture relative to your libgdx project texture before exporting, but I haven't tested this yet.

I believe the line is at 503 in g3d_exporter.py:
currentTexture.filename = (self.getCompatiblePath(slot.texture.image.filepath))

The other issue that I had is that exported models seem to always have emissive properties regardless of how their emissive properties are set in Blender. This results in a model that looks washed out if you did not intend for it to be emissive.

I think this stems from line 473 in g3d_exporter.py :
currentMaterial.emissive = [blMaterial.diffuse_color[0], blMaterial.diffuse_color[1], blMaterial.diffuse_color[2]]

I worked around this by removing emissive property in my libgdx project code, but of course that means you can't have an emissive model if you wanted.

Other than that, this has been extremely helpful for using Blender models with LibGDX, thanks!

2.78 support?

I seem to have a problem to enable the plugin with blender 2.78. Is that version supported?

Y-up and G3DB support

Without automatic Y-up conversion and possibility to export to G3DB directly, there still needs to be a post-processing step taken before being able to incorporate a model into a game, which makes this even worse solution than using blender->FBX->G3D

I know this ain't easy task, but this exporter isn't very useful without those options. At least the Y-up conversion would make quick prototyping much easier.

Export fail if scene only contains animation

Hello

I have some FBX that only contains animation, and it fail to export because it requeires a model with material

Would be cool if it was able to still export even if it is only for the animation

Export issues

Hello,

I'm attempting to use the Blender G3D plugin to export a animated, textured model using Cycles.

When I click "export", I get the following error message:
https://imgur.com/a/If57S0M

Here's my .blend file:

Let me know if you need any more information.

Dope sheet actions don't get exported

I am using the dope sheet to create keyframe actions, but they are not exported to the g3dj file. It works properly if I use the fbx exporter and convert it afterward, but it would be nice for it to work using this.

Exporting unused parts

To reproduce:
Create a model that has three materials. Do not assign one of the materials to the model. Export said model.

What happens:
In g3dj, there is an entry in "nodes" and "parts" for the material. Parts has no vertexes. If you try to import said model, g3dj will give you an error saying there's an invalid part. g3db gives a more cryptic error, but I assume it's the same thing under the hood. Manually deleting the node and part in g3dj makes the model work.

armature animation error

I found that if you create an animation it saves correctly but if you create two animations the first animation is the sum of the first and the second animation and the second animation is like the sum of that new first animation and the second animation.

Another export issue

Hi, I'm getting another export issue and was wondering if you had any insight into why it might be happening.

Why I export my model to a .g3db export, I get the following error message:
https://imgur.com/onc12gd

Here's my .blend file:
https://files.fm/u/576pcnmc

This error occurs in both Blender Render and Cycles Render.

Let me know if you'd like any more information.

Texture missing

Hi,

Here is a new issue, or maybe not but after some tests I do not succeed on exporting a textured model : the picture file (texture) is not referenced in the json output file.
I tried into obj to compare, and the image file is well referenced in the obj mtl file.

Is there a particular way of doing the material or texture ? or to export it ?
Thanks !

bpy.ops.export_json_g3d scene arguments

I can't put an argument to define the scene usint bpy.ops.export_json_g3d.
I had to export the data that is only in the scene I am in. But I want to pass the name of the scene that I need to export in order to export all the scenes separately.
It is for use with the bdx engine.
sorry for my English

Cycles node editor

Is it possible to include Cycles Render and node editor materials export in the future? Are there any limitations using such complex materials in libgdx?

Export doesn't include animations

I tried exporting the default blender scene with the cube and it works great. However when I add LocRotScale keyframe to frame 1, then scale and add another LocRotScale keyframe to the last frame and export it, there are no animations listed in the g3dj file, same result in the g3db file. The cube still shows fine. The animation works in blender. I tried playing a little with the Action Editor / Fake User in Dope View but couldn't get it to work that way either. What am I missing? Thanks

G3DB output

Would it be possible to output some g3db files too ?
g3dj is very useful to debug and check, but for database space saving the binary format is very useful.

Thanks !

Can't export with texture

Not sure if this is even still active but I have a problem that is probably just a settings issue.

I'm using this plug-in conveniently the version it's compatible with is the last version compatible with my dell dimension dinosaur. but every time I try to export my model with textures it throws this error:

Traceback (most recent call last):
File "c:...\io_scene_g3d_\g3d_exporter.py", line 116, in execute
return self.startExport(context)
File "c:...\io_scene_g3d_\profile.py", line 33, in profile_fun
return fun(*arts, **kwargs)
File "c:...\io_scene_g3d_\g3d_exporter.py", line 140, in startExport
materials = self.generateMaterials(context)
File "c:...\io_scene_g3d_\profile.py", line 33, in profile_fun
return fun(*arts, **kwargs)
File "c:...\io_scene_g3d_\g3d_exporter.py", line 495, in generateMaterials
util.debug("found texture {!s}. texture coords are {!s}, texture type is {!s}", slot.name, slot.texture_coords, slot.texture.type)
AttributeError: 'NoneType' object has no Attribute 'type'

location: :-1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.