Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- when isMainModule:
- import
- atlas,
- skeleton_json,
- yaml.serialization as yaml,
- streams,
- tables
- type
- SkeletonJson = object
- skeleton: Skeleton
- bones: seq[Bone]
- slots: seq[Slot]
- path: seq[Path]
- skins: Table[string, Table[string, Table[string, Attachment]]]
- animations: Table[string, Animation]
- Skeleton = object
- hash: string
- spine: string
- width: float
- height: float
- fps: int
- images: string
- Bone = object
- name: string
- parent: string
- length: float
- rotation: float
- x, y: float
- color: string
- Slot = object
- name: string
- bone: string
- attachment: string
- RotateMode {.pure.} = enum
- ChainScale = "chainScale"
- Path = object
- name: string
- order: int
- bones: seq[string]
- target: string
- rotateMode: RotateMode
- AttachmentType {.pure.} = enum
- Mesh = "mesh", Path = "path"
- Attachment = object
- `type`: AttachmentType
- uvs: seq[float]
- triangles: seq[int]
- vertices: seq[float]
- hull: int
- edges: seq[int]
- width: int
- height: int
- lengths: seq[float]
- vertexCount: int
- Animation = object
- slots: Table[string, SlotTimeline]
- bones: Table[string, BoneTimeline]
- SlotTimeline = object
- color: seq[ColorKeyframe]
- attachment: seq[AttachmentKeyframe]
- AttachmentKeyframe = object
- time: float
- name: string
- ColorKeyframe = object
- time: float
- color: string
- curve: seq[float]
- BoneTimeline = object
- rotate: seq[RotateKeyframe]
- translate: seq[TranslateKeyframe]
- scale: seq[ScaleKeyframe]
- shear: seq[ShearKeyframe]
- RotateKeyframe = object
- time: float
- curve: seq[float]
- angle: float
- TransformKeyframe = object
- time: float
- curve: seq[float]
- x, y: float
- TranslateKeyframe = TransformKeyframe
- ScaleKeyframe = TransformKeyframe
- ShearKeyframe = TransformKeyframe
- var sk: SkeletonJson
- var s = newFileStream("../spine-sfml/data/vine.json")
- setDefaultValue(Bone, parent, nil)
- setDefaultValue(Bone, length, 0.0)
- setDefaultValue(Bone, rotation, 0.0)
- setDefaultValue(Bone, x, 0.0)
- setDefaultValue(Bone, y, 0.0)
- setDefaultValue(Bone, color, nil)
- setDefaultValue(Attachment, triangles, nil)
- setDefaultValue(Attachment, uvs, nil)
- setDefaultValue(Attachment, hull, 0)
- setDefaultValue(Attachment, edges, nil)
- setDefaultValue(Attachment, width, 0)
- setDefaultValue(Attachment, height, 0)
- setDefaultValue(Attachment, lengths, nil)
- setDefaultValue(Attachment, vertexCount, 0)
- setDefaultValue(SlotTimeline, attachment, nil)
- setDefaultValue(SlotTimeline, color, nil)
- setDefaultValue(BoneTimeline, rotate, nil)
- setDefaultValue(BoneTimeline, translate, nil)
- setDefaultValue(BoneTimeline, scale, nil)
- setDefaultValue(BoneTimeline, shear, nil)
- setDefaultValue(ColorKeyframe, curve, nil)
- setDefaultValue(RotateKeyframe, curve, nil)
- setDefaultValue(TransformKeyframe, curve, nil)
- yaml.load(s, sk)
- s.close()
- echo repr sk.animations["animation"].slots["vine"].color[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement