Search Unity

Blender to Unity exporter/importer, with animation support (usable at runtime)

Discussion in 'Works In Progress - Archive' started by Venryx, Feb 24, 2015.

?

How much would you pay for a runtime ThreeJS model importer, with animation support?

  1. Not interested.

    15.4%
  2. $0/only if it's free

    46.2%
  3. $5

    0 vote(s)
    0.0%
  4. $10

    7.7%
  5. $20

    23.1%
  6. $50

    7.7%
  1. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Needing an at-runtime model importer for my project, I couldn't find much out there, and decided to write my own. I decided to base it on the ThreeJS Model spec seen here (the lower one), because of its simplicity and human readability.

    The current pipeline for my use is like this:
    1) Import model into Blender.
    2) Export to ThreeJS model file (json).
    3) Import into Unity using my ThreeJS importer.

    Currently the only thing it supports is the base mesh--the vertices and faces. I'm thinking of adding normal and animation support, but would like to know if there's actually any demand for it.

    I know there are some other runtime model importer extensions out there, but every one I know of either:

    1) Has the import code locked in a DLL, meaning if something breaks, you might have to completely abandon it for another solution:
    https://www.assetstore.unity3d.com/en/#!/content/12757
    https://www.assetstore.unity3d.com/en/#!/content/3147
    https://www.assetstore.unity3d.com/en/#!/content/18268 (also doesn't support animations)
    https://www.assetstore.unity3d.com/en/#!/content/15428 (also doesn't support animations)

    2) Doesn't support animations:
    https://www.assetstore.unity3d.com/en/#!/content/19579
    https://www.assetstore.unity3d.com/en/#!/content/22195

    So my question here is (as seen by the poll options): How much interest would there be in a runtime model importer (based on the ThreeJS model format), with support for animation and other standard features?
     
    Last edited: Feb 25, 2015
  2. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Well I went ahead and built it anyway. I now have a custom exporter for blender, and importer for Unity, able to transfer:
    * vertices
    * normals
    * uvs
    * bone-weights
    * animations
    * etc.

    I'll probably put it online at some point, but for now I'll just be focusing back on the main game project that I had to make it for. (the runtime importer is for letting the user add their own trees, units, etc.)
     
  3. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Here is an example of the VModel file format: (it's just a textured cube, with a basic roll forward animation)
    Code (csharp):
    1. {^}
    2.     objects:{^}
    3.         Root:{^}
    4.             position:[0 0 0]
    5.             rotation:[0 0 0 1]
    6.             scale:[1 1 1]
    7.             children:{^}
    8.                 Armature:{^}
    9.                     position:[0 0 .5]
    10.                     rotation:[0 0 0 1]
    11.                     scale:[1 1 1]
    12.                     armature:{^}
    13.                         bones:{^}
    14.                             Bone:{position:[0 0 0] rotation:[0 0 0 1] scale:[1 1 1]}
    15.                     animations:{^}
    16.                         RollForward:{^}
    17.                             fps:30
    18.                             length:100
    19.                             boneKeyframes:{^}
    20.                                 Bone:{^}
    21.                                     0:{position:[0 0 0] rotation:[0 0 0 1] scale:[1 1 1]}
    22.                                     100:{position:[0 0 -1] rotation:[-.707107 0 0 .707107] scale:[1 1 1]}
    23.                 Mesh:{^}
    24.                     position:[0 0 .5]
    25.                     rotation:[0 0 0 1]
    26.                     scale:[1 1 1]
    27.                     mesh:{^}
    28.                         vertices:[^]
    29.                             {position:[-.5 -.5 -.5] normal:[-.577349 -.577349 -.577349] uv_face0:[.666667 .333333] uv_face3:[.666667 .666667] uv_face4:[1 0] boneWeights:{Bone:1}}
    30.                             {position:[-.5 .5 -.5] normal:[-.577349 .577349 -.577349] uv_face0:[.666667 0] uv_face1:[.333333 .666667] uv_face4:[1 .333333] boneWeights:{Bone:1}}
    31.                             {position:[.5 .5 -.5] normal:[.577349 .577349 -.577349] uv_face1:[.333333 .333333] uv_face2:[.333333 .333333] uv_face4:[.666667 .333333] boneWeights:{Bone:1}}
    32.                             {position:[.5 -.5 -.5] normal:[.577349 -.577349 -.577349] uv_face2:[.333333 0] uv_face3:[.333333 .666667] uv_face4:[.666667 0] boneWeights:{Bone:1}}
    33.                             {position:[-.5 -.5 .5] normal:[-.577349 -.577349 .577349] uv_face0:[.333333 .333333] uv_face3:[.666667 .333333] uv_face5:[0 1] boneWeights:{Bone:1}}
    34.                             {position:[-.5 .5 .5] normal:[-.577349 .577349 .577349] uv_face0:[.333333 0] uv_face1:[0 .666667] uv_face5:[.333333 1] boneWeights:{Bone:1}}
    35.                             {position:[.5 .5 .5] normal:[.577349 .577349 .577349] uv_face1:[0 .333333] uv_face2:[0 .333333] uv_face5:[.333333 .666667] boneWeights:{Bone:1}}
    36.                             {position:[.5 -.5 .5] normal:[.577349 -.577349 .577349] uv_face2:[0 0] uv_face3:[.333333 .333333] uv_face5:[0 .666667] boneWeights:{Bone:1}}
    37.                         faces:[[1 0 4 5] [5 6 2 1] [6 7 3 2] [0 3 7 4] [0 1 2 3] [7 6 5 4]]
    38.                         materials:[^]
    39.                             {diffuseColor:"ffffff" texture:"MainTexture.png"}
    40.                         armature:"Armature"
     
    Last edited: May 18, 2015
  4. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Well, finally took the time to put it on GitHub: https://github.com/Venryx/VModel

    The code has quite a bit of cruft left over from the json exporter I based it on, but this should slowly fade out as I "consistentize" and simplify the code base. (for side-projects, I follow the philosophy of "lazy updating", where I only update a section when a problem is being caused by it, or when leaving it as is would slow down the adding of new features)

    That said, it's working well for my current project. I continue to add features/fixes as I need them.

    Note: I also heavily use a Blender tool package that I put together here, to help speed up various operations/processes: https://github.com/Venryx/VTools
     
    GameTechnix and CWolf like this.
  5. Rajawat

    Rajawat

    Joined:
    Oct 1, 2016
    Posts:
    25
    Hey Venryx,
    I was looking for some way of importing the threejs' scene extract into Unity.
    Could you help me out .

    Cheers