项目作者: lmarz

项目描述 :
Animated OBJ file format
高级语言:
项目地址: git://github.com/lmarz/animated_obj.git
创建时间: 2020-02-02T15:46:12Z
项目社区:https://github.com/lmarz/animated_obj

开源协议:

下载


Animated OBJ

Animated OBJ is an extension to the Wavefront OBJ format, which adds animation functionality.
Disclaimer: This file format is currently completely theoretical and hasn’t been tested yet. Major issues might occur

Table of Contents



Animated Object

  1. ao <name>

Instead of o, you can specify this keyword to make sure the file loader interprets the animation keywords the right way. o can be used for inanimate objects

argument type description
<name> string the name of the animated object

Vertex Joints

  1. vj <joint> <joint> <joint> <joint>

Adds a joint attribute to a vertex. Each joint is able to influence the position and rotation of the vertex. A vertex can be influenced by up to 4 joints.

argument type description
<joint> int the index of the affecting joint. If there are less than 4 joints affecting the vertex, all other joint ids should be set to 0 with a weight of 0

Vertex Weights

  1. vw <weight> <weight> <weight> <weight>

Adds a weight attribute to a vertex. The weight sets the influence of the joints. It is directly linked with vj

argument type description
<weight> float the influence of the corresponding joint. The four values should be normalized, that means the sum of the four weights should be 1

Addition to Faces

  1. f <pos>/<uv>/<normal>/<joints>/<weights>

Instead of the usual 3 attributes, you now have five attributes

argument type description
<pos> int the index of the vertex position
<uv> int the index of the vertex uv
<normal> int the index of the vertex normal
<joints> int the index of the vertex joints (not the real joints)
<weights> int the index of the vertex weights

Joints

  1. j <name> <joint>

Specifies one joint/bone with its name and its parent. It works of the same principal as the vertex implementation. So the first j has index 1, the second j index 2, etc. The example at the end of this file should clarify it

argument type description
<name> string the name of the joint
<joint> int the index of the parent joint. If the joint is the root joint (no parent), this value should be set as -1

Animation group

  1. a <name>

All animation keywords after this command get grouped together, so you can create different animations for the same object (idle, walking, etc.)

argument type description
<name> string the name of the animation

Animate Position

  1. ap <timestamp> <joint> <x> <y> <z>

Adds an animation keyframe for the position

argument type description
<timestamp> float the timestamp at which the object should have this pose. Timestamp 0 is required
<joint> int the index of the joint, which position will be changed
<x>, <y>, <z> float the new position of the joint

Animate Rotation

  1. ar <timestamp> <joint> <x> <y> <z> <w>

Adds an animation keyframe for the rotation. Warning: The rotation is in quaternions and not in the usual euler rotation format

argument type description
<timestamp> float the timestamp at which the object should have this pose. Timestamp 0 is required
<joint> int the index of the joint, which rotation will be changed
<x>, <y>, <z>, <w> float the new rotation of the joint in quaternions

Example

  1. # Animated OBJ example
  2. ao cube
  3. # The vertex positions
  4. v 1.0 1.0 -1.0
  5. v 1.0 -1.0 -1.0
  6. v 1.0 1.0 1.0
  7. v 1.0 -1.0 1.0
  8. v -1.0 1.0 -1.0
  9. v -1.0 -1.0 -1.0
  10. v -1.0 1.0 1.0
  11. v -1.0 -1.0 1.0
  12. # The vertex uvs
  13. vt 0.625 0.00
  14. vt 0.375 0.25
  15. vt 0.375 0.00
  16. vt 0.625 0.25
  17. vt 0.375 0.50
  18. vt 0.375 0.25
  19. vt 0.625 0.50
  20. vt 0.375 0.75
  21. vt 0.625 0.75
  22. vt 0.375 1.00
  23. vt 0.375 0.50
  24. vt 0.125 0.75
  25. vt 0.125 0.50
  26. vt 0.875 0.50
  27. vt 0.625 0.50
  28. vt 0.625 0.25
  29. vt 0.625 0.75
  30. vt 0.625 1.00
  31. vt 0.375 0.75
  32. vt 0.875 0.75
  33. # the vertex normals
  34. vn 0.0 1.0 0.0
  35. vn 0.0 0.0 1.0
  36. vn -1.0 0.0 1.0
  37. vn 0.0 -1.0 0.0
  38. vn 0.0 -1.0 0.0
  39. vn 1.0 0.0 0.0
  40. vn 0.0 0.0 -1.0
  41. # the vertex joints
  42. vj 1 -1 -1 -1
  43. vj 1 2 -1 -1
  44. # the vertex weights
  45. vw 1 0 0 0
  46. vw 0 1 0 0
  47. # the faces for the object with the additional vertex joints and vertex weights
  48. f 5/1/1/1/1 3/2/1/1/1 1/3/1/1/1
  49. f 3/4/2/1/1 8/5/2/1/1 4/6/2/1/1
  50. f 7/7/3/1/1 6/8/3/1/1 8/5/3/1/1
  51. f 2/9/4/1/1 8/10/4/1/1 6/8/4/1/1
  52. f 1/11/5/1/1 4/12/5/1/1 2/13/5/1/1
  53. f 5/14/6/1/1 2/9/6/1/1 6/15/6/1/1
  54. f 5/1/1/2/2 7/16/1/2/2 3/2/1/2/2
  55. f 3/4/2/2/2 7/7/2/2/2 8/5/2/2/2
  56. f 7/7/3/2/2 5/17/3/2/2 6/8/3/2/2
  57. f 2/9/4/2/2 4/18/4/2/2 8/10/4/2/2
  58. f 1/11/5/2/2 3/19/5/2/2 4/12/5/2/2
  59. f 5/14/6/2/2 1/20/6/2/2 2/9/6/2/2
  60. # the joints. The first one is the root joint with index 1 and is referenced in vj 1
  61. j Joint_1 -1
  62. j Joint_2 1
  63. # Now follows the idle animation
  64. a idle
  65. # the animation. Move joint 1 to (1.0, 1.0, 1.0) and then to (-2.0, -2.0, -2.0)
  66. ap 0 2 1.0 1.0 1.0
  67. ap 0.5 2 -2.0 -2.0 -2.0
  68. # rotate joint 1
  69. ar 0 1 0.0 0.0 1.0 0.0

Available Tools

  • AmoAddon: Blender addon for exporting objects as Animated OBJ files
  • editamo: Coversion tool from the glTF file format to the Animated OBJ file format
  • amoloader: Simple library that loads and parses Animated OBJ files written in C89

License

Public Domain
This work is free of known copyright restrictions.