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

How to display an Animated .fbx 3D model ? #2

Open
SAGARSURI opened this issue Apr 9, 2017 · 12 comments
Open

How to display an Animated .fbx 3D model ? #2

SAGARSURI opened this issue Apr 9, 2017 · 12 comments

Comments

@SAGARSURI
Copy link

I want to display a animated 3D model in .fbx format. How can I achieve this ?

@smart-fun
Copy link
Owner

Hello Sagarsuri,

there is no support for FBX format or animated models so far. There are tools that convert FBX to OBJ, so it could be used as a workaround, but still not animated.

If I have time I'll have a look to the FBX format and see what is possible to do.

Arnaud.

@creek23
Copy link

creek23 commented Jul 2, 2017

Might be a good reference for FBX loader:
https://sourceforge.net/p/irrext/code/91/tree/trunk/extensions/scene/IMeshLoader/fbx/

It seems to handle FBX animations as well.

While it's itching me to try and attempt to convert the file to Java, I would still need to understand how smartGL is handling all the 3D data, which could take awhile.

~creek23

@smart-fun
Copy link
Owner

In the long run it would be great that the library supports animations. I have no idea which format must be used but:

  • I would like to support only 1 format
  • I would like to support a text format, not binary as text is easier to debug

maybe FBX is the one, but I don't have time for the moment on this. If someone wants to do a loader, go for it ^^

Here is some description taken from Autodesk:
http://download.autodesk.com/us/fbx/2010/fbx_sdk_help/index.html?url=WS1a9193826455f5ff-150b16da11960d83164-6c6f.htm,topicNumber=d0e127

Arnaud.

@creek23
Copy link

creek23 commented Jul 3, 2017

Your options are either FBX (widely used in game industry) or XML-based DAE (probably ranking next to FBX).

While FBX supports text and binary, seems Blender only exports binary.

The irrlicht FBX loader seems pretty readable. Any possible contributor would need help understanding how vertices/faces/materials are handled by smartGL to avoid duplicates in the library.

~creek23

@smart-fun
Copy link
Owner

Yes I could help on the smartGL architecture part ;)

Basically the scene is rendered using one or several RenderPass.

A RenderPass holds one or more RenderObject which can be Sprite or Object3D (the one which is interesting for us is Object3D)

Each RenderObject/Object3D holds a list of Face3D

Each Face3D holds a VertexList, and UVList + Texture (for textured objects) and NormalList when there is lightning in the scene (beta feature).

If you look at WavefrontModel.java, the loader for OBJ reads vertex / mapping UVs / normals and rebuild the faces and finally the full Object3D.

For animation we need to improve all this. Maybe people would like the mapping to be animated (like for a waterfall), or vertex to be animated (like for a bouncing ball), or even faces added / removed. There's a lot of possibilities.

Arnaud.

@creek23
Copy link

creek23 commented Jul 9, 2017

So, I was able to find time to look into Irrlicht's FBX Loader and tried translating the C++ code to Java. Now, I'm down to the last 13 lines of code that needs translation -- in this context, I mean translating between the difference on how Irrlicht and smartGL handles 3D object. For the most part, I simply created new classes to reflect how Irrlicht handles its 3D data -- suffice to say, it is currently in its stub form; this is where I particularly need some more detail about smartGL.

If I understand correctly, from what I learned so far is that these smartGL classes are somewhat similar to Irrlicht classes':

  • Object3D == ISkinnedMesh
  • Face3D == SSkinMeshBuffer

These I still have to identify:

  • S3DVertex (temporarily wrote Vertex3D)
  • IAnimatedMesh
  • SMaterial
  • SColor
  • vector3df

For Object3D and Face3D, either I would have to extend these classes to properly handle Irrlicht FBX Loader algorithm or completely alter the FBX Loader algorithm to fit into the existing classes' render pipe -- might take another week for this.

@arnaud: maybe you can read-up Irrlicht documentation and figure out from there which among your Classes are handling data from my needs indicated above: http://irrlicht.sourceforge.net/docu/

~creek23

@smart-fun
Copy link
Owner

Wow nice work!

I started to read the documentation.

The S3DVertex is the combination of vertex position, normal, color and UV. So it is stick altogether whereas in my lib there are lists for each in the Face3D class: a list of positions, a list of normals... So it cannot be mapped easily.

IAnimatedMesh. This concept does not exist in smartGL.

SMaterial seem close to my Texture class. I did not go into details but it seems it has more features than I have.

SColor represents a color in different format. In smartGL there are Face3D with ColorList which is an array of colors for each vertex. They are store as r,g,b,a floats. They are only used when there is no mapping / texture.

Vector3df is a x,y,z float vector. In smartGL in Face3D there is a VertexList with positions stored as floats: (x,y,z).

Probably the "easiest" approach would be to load the FBX object with all the original classes, and then parse the loaded FBX object and create a smartGL Object3D from it.

Arnaud.

@creek23
Copy link

creek23 commented Jul 11, 2017

Done some more stubs just to have a compilable code but I'm pretty sure the loading part is mostly intact. Now, I just need to feed the 3D data to smartGL's renderer, and your comments above would be helpful.

~creek23

@creek23
Copy link

creek23 commented Jul 13, 2017

Was able to compile and run the code but seems that it's not properly handling the data as expected... will try to debug the file-parser; might be problem with how I translated the C++ code to Java.

~creek23

@creek23
Copy link

creek23 commented Jul 13, 2017

Seems Irrlicht FBX Loader is 3 versions old -- the source code was last updated 2011, while FBX format had 3 more revisions after that.

Either the Blender-exported FBX ASCII-file isn't properly handled by Irrlicht FBX loader, or the Irrlicht FBX Loader wasn't mature enough to actually work -- I actually had to hack the file-parser to properly handle comma-delimited String values. This part is fixed now but the mesh-generating part of the code seems to have a problem as well. Not sure what to do next. :( -- I'll be busy over the weekend, not sure when I can have time long enough to debug the mesh-generating part. Possibly, the following weekend.

...even jMonkeyEngine has FBX Loader but not fully implemented, AFAIK.

~creek23

@shaojiepeng
Copy link

Hi guys, I wanna to know, how to convert obj file to animated FBX file in java? Any feeback is apperacited.

@creek23
Copy link

creek23 commented May 1, 2019

Hi guys, I wanna to know, how to convert obj file to animated FBX file in java? Any feeback is apperacited.

it's quite an old post, but replying anyway... so, you need to load OBJ file via Blender then export it as FBX file. you can google the necessary steps to do it. ;)

~creek23

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

No branches or pull requests

4 participants