Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OGEX Blender exporter updated for 2.8 mesh api #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joeld42
Copy link

@joeld42 joeld42 commented May 27, 2021

This updates your blender exporter to use the new 2.8 mesh API and to use Node based materials (using Principled BSDF shader), as blender internal render is no longer supported.

I'm just using this for static scenes so I'm not sure if it works on animated characters. I didn't update the API for shape keys (morph targets) yet, so right now it just ignores shape keys, I'll try and go back and fix that in the future if I have a chance.

Thanks for the OpenGEX pipeline and all the resources you provide!

@miguelcartaxo
Copy link

miguelcartaxo commented Jun 20, 2021

First thanks for this, been waiting to have a way to export OpenGex from Blender for a long time, to try it out. A few things though.

  1. It fails to export when you choose "Export Selection Only" in the export options.
Python: Traceback (most recent call last):
  File "C:\Users\<UserName>\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\ExportOpenGex.py", line 2736, in execute
    self.ProcessNode(object)
  File "C:\Users\<UserName>\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\ExportOpenGex.py", line 711, in ProcessNode
    if ((self.exportAllFlag) or (node.select)):
AttributeError: 'Object' object has no attribute 'select'

location: <unknown location>:-1
  1. Also, in https://opengex.org/comparison.html the example opengex file has floats written in hex, which your script also does not support. I guess it wouldn't be hard to change, just need to change the WriteFloat() function to make the conversion. Something like:
import struct
def FloatToHex(self, f):
      i = struct.unpack('<I', struct.pack('<f', f))[0]
      return '0x{:08x}'.format(i)

I'm not a python expert, I just looked it up. I'm not sure what the other plugins (Max and Maya) do for it, maybe it should be an export option if the user wants hex or floats. This also makes the file smaller.

EDIT: I just noticed, the attributes say float but you're writing doubles, so you're adding way more precision, for reference:

import struct
def DoubleToHex(self, d):
      i = struct.unpack('<Q', struct.pack('<d', d))[0]
      return '0x{:016x}'.format(i)

EDIT 2: I downloaded a free blender 3d model with some animations, tried to export it and failed :(

Looks like every call:
scene.frame_set(currentFrame, currentSubframe)
needs to change to:
scene.frame_set(currentFrame, subframe = currentSubframe)
otherwise you get the following error:

  File "C:\Users\<UserName>\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\ExportOpenGex.py", line 1130, in ExportBoneSampledAnimation
    scene.frame_set(currentFrame, currentSubframe)
TypeError: Scene.frame_set(): required parameter "subframe" to be a keyword argument!

After that I managed to export, no idea if it exported everything from the .blend file imported, but at least it looks valid.

@joeld42
Copy link
Author

joeld42 commented Jun 20, 2021

I've been using it in batch mode on static scenes so I didn't test the export selection or much animation. I'll take a look at these issues in a couple of weeks when I'm back from vacation. The WriteFloat... stuff is from the old plugin, but adding the hex format shouldn't be too hard. Thanks for testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants