cr88192

CSG Animation Format Idea

Dec 29th, 2020
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.98 KB | None | 0 0
  1. CSG Animation Tool.
  2. * Combine CSG with skeletal animation.
  3. * The top level will exist as a list of objects.
  4. * References from one object to another will be based on name.
  5.  
  6. CSG Solids
  7. * CSG Solids will exist within Models.
  8. * CSG Solids will be applied in-order.
  9. * Solids may be either positive or negative.
  10. ** A negative solid will "cut a hole" in any preceding solids.
  11. * Rounded solids will be approximated via polyhedra.
  12. ** The tessellation of the surface will be implicit.
  13. * Solids with a transparent textures may only clip objects with the same texture.
  14. ** Likewise, they may only be clipped by the same texture.
  15.  
  16. Bones
  17. * A given Model may contain Bones.
  18. * CSG solids may be attached to bones.
  19. ** CSG solids assigned to different bones will not normally clip.
  20.  
  21.  
  22. Model notation will be based on objects and lists.
  23.  
  24. Object:
  25. ObjType {
  26. ...
  27. }
  28. ObjType objName {
  29. ...
  30. }
  31.  
  32. Objects will contain key-value pairs:
  33. * key: value
  34. ** Comma separators will be optional.
  35. * Objects may contain other objects.
  36. * Keys will be identifiers.
  37.  
  38. Identifier:
  39. * Consists of 'A'..'Z', 'a'..'z', '0'..'9', '_', and '$'.
  40. * Must start with a letter or underscore.
  41.  
  42.  
  43. Value types will be one of several types:
  44. * Integer literal
  45. ** 1234567
  46. ** 0x1234ABCD
  47. ** ...
  48. * Floating point literal
  49. ** 3.14159
  50. * String Literal
  51. ** "Foo"
  52. ** Adjacent string literals may merge without a separator.
  53. ** Escape sequences will be similar to those in C.
  54. * Symbol
  55. ** #name
  56. ** May be used as an identifier for another object.
  57. ** Functionally similar to a string in most other regards.
  58. * List / Array
  59. ** [ 1 2 3 ]
  60. ** Comma separators will be optional.
  61. ** Lists may contain arbitrary value types.
  62. * Vector
  63. ** #[ x y ]
  64. ** #[ x y z ]
  65. ** #[ x y z w ]
  66. ** Consists of 2-4 floating point numbers.
  67. * ...
  68.  
  69. Origins will be given with in a local or global XYZ space.
  70. Rotations will be given as axis/angle, with the angle given in degrees.
  71.  
  72. The coordinate space will not be formally specified here, but for now will assume a unit size roughly comparable to an inch.
  73.  
  74.  
  75. Objects:
  76. * Model
  77. ** Top-level model object, contains Bones and solids
  78. ** Models may be instanced.
  79. * Bone
  80. ** Defines part of a skeleton.
  81. ** Contains an origin and parent.
  82. ** Bones without a parent are relative to the model.
  83. * Solids
  84. ** Will come in various forms.
  85. ** Box: Box, given as min/max or origin/size
  86. *** May be given a rotation.
  87. ** Sphere: Spheroid, given as origin/radius.
  88. *** Radius may be either a floating point number or a vector.
  89. ** Cylinder: Cylinder, Flat Ends, given as start/end and radius.
  90. ** CappedCylinder: Cylinder, Round Ends, given as start/end and radius.
  91. ** ...
  92.  
  93. Model model1 {
  94. Bone base { origin: #[ 0 0 0] }
  95. Bone leftArm { origin: #[-10 0 10] parent: #base }
  96. Bone rightArm { origin: #[ 10 0 10] parent: #base }
  97. Bone leftHand { origin: #[-40 0 15] parent: #leftArm }
  98. Bone rightHand { origin: #[ 40 0 15] parent: #rightArm }
  99. Bone head { origin: #[ 0 0 20] parent: #base }
  100. Sphere torsoSphere { origin: #[ 0 0 0] radius: 20 bone: #base }
  101. Sphere headSphere { origin: #[ 0 0 25] radius: 10 bone: #head }
  102. Sphere lfHandSp { origin: #[-40 0 15] radius: 20 bone: #leftHand }
  103. Sphere rtHandSp { origin: #[ 40 0 15] radius: 20 bone: #rightHand }
  104. }
  105.  
  106. If a Solid is not given a bone, it will exist at a fixed location within the model.
  107.  
  108. Textures will be applied to solids rather than to individual faces.
  109. * Textures will contain of references to external texture images.
  110. ** One of several possible search paths may be used.
  111. ** File extension may be added implicitly.
  112. * A texture object will define the projection strategy.
  113. ** Sphere: Spherical coordinates relative to a local space.
  114. ** Box: Nearest face on a 6-sided box within local space.
  115. ** Plane:
  116.  
  117. Texture tex1 {
  118. image: "textures/foo/bar"
  119. proj_type: #Sphere
  120. proj_x: #[1 0 0]
  121. proj_y: #[0 1 0]
  122. proj_z: #[0 0 1]
  123. proj_origin: #[0 0 0]
  124. transparent: 1
  125. }
  126.  
  127. Polyhedra / Brush
  128. * Will define an arbitrary solid in terms of planes.
  129. * Each plane will contain a normal.
  130. ** The first three numbers will give the plane direction.
  131. ** The fourth number will give the distance.
  132.  
  133. Brush br1 {
  134. texture: tex1
  135. Plane { normal: #[-1 0 0 10] }
  136. Plane { normal: #[ 1 0 0 10] }
  137. Plane { normal: #[ 0 -1 0 10] }
  138. Plane { normal: #[ 0 1 0 10] }
  139. Plane { normal: #[ 0 0 -1 10] }
  140. Plane { normal: #[ 0 0 1 10] }
  141. }
  142.  
  143.  
  144. Animations:
  145. * Animations exist within a model.
  146. ** Each animation will consist of frames.
  147. ** The frames will define the bone positions at that time.
  148. *** These will either displace the origin or apply a rotation.
  149. *** Translations will be relative to the base origin.
  150. *** Rotations will be given in axis/angle.
  151. ** Each child bone will be relative to the position of the parent bone.
  152. *** In effect, the transforms will be combined.
  153. ** If a bone position is absent in a given frame, it will be interpolated.
  154.  
  155. Anim jump1 {
  156. frametime: 0.1 //10 frames per second
  157. Frame {
  158. BonePos base { org: #[0 0 0] }
  159. BonePos leftArm { rot: #[0 1 0 0] }
  160. BonePos rightArm { rot: #[0 1 0 0] }
  161. }
  162. Frame { }
  163. Frame { }
  164. Frame { }
  165. Frame { }
  166. Frame {
  167. BonePos base { org: #[0 0 15] }
  168. BonePos leftArm { rot: #[0 1 0 30] }
  169. BonePos rightArm { rot: #[0 1 0 -30] }
  170. }
  171. Frame { }
  172. Frame { }
  173. Frame { }
  174. Frame { }
  175. }
  176.  
  177.  
  178. === Scenes ===
  179.  
  180. Scene (If Relevant):
  181. * A Scene will be composed of Entities.
  182. ** Each Entity will be an instance of a Model.
  183. ** Entities may be given an origin and rotation, and given an animation.
  184. * Events will happen at time-codes.
  185.  
  186. Import { path: "models/model1" }
  187.  
  188. Entity ent1 {
  189. model: #model1
  190. origin: #[320 400 16]
  191. rotation: #[0 0 0]
  192. }
  193.  
  194. Event ev0 {
  195. time: 0.0
  196. entity: ent1
  197. anim: idle1
  198. }
  199. Event ev1 {
  200. time: 16.0
  201. entity: ent1
  202. anim: jump1
  203. }
  204.  
  205. If no events exist for an entity, it will exist as a static object.
  206.  
  207. Entities could also be assigned to scripts, in which case the script will manage any behaviors.
  208.  
  209.  
Advertisement
Add Comment
Please, Sign In to add comment