Class: Bvh

Inherits:
Object
  • Object
show all
Defined in:
lib/bvh.rb,
lib/bvh/motion.rb,
lib/bvh/parser.rb,
lib/bvh/exporter.rb,
lib/bvh/skeleton.rb,
lib/bvh/motion/frame.rb,
lib/bvh/motion/channel_data.rb

Defined Under Namespace

Classes: Exporter, Motion, Parser, Skeleton

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBvh

Returns a new instance of Bvh.



18
19
20
21
# File 'lib/bvh.rb', line 18

def initialize
  @motion = Bvh::Motion.new
  @skeletons = []
end

Instance Attribute Details

#motionObject (readonly)

The motion capture data associated with this BVH.



16
17
18
# File 'lib/bvh.rb', line 16

def motion
  @motion
end

#skeletonsObject (readonly)

The array of skeletons associated with this BVH.



13
14
15
# File 'lib/bvh.rb', line 13

def skeletons
  @skeletons
end

Class Method Details

.import(file) ⇒ Object

Instantiates a new BVH and imports its data from the specified file



60
61
62
63
64
65
# File 'lib/bvh.rb', line 60

def import(file)
  bvh = self.new
  parser = Bvh::Parser.new(file)
  parser.parse(bvh)
  bvh
end

Instance Method Details

#create_skeleton!Object

Creates a new skeleton, adds it to the #skeletons array, and returns it.



56
# File 'lib/bvh.rb', line 56

def create_skeleton!; (@skeletons << Bvh::Skeleton.new).last; end

#export(file) ⇒ Object

Exports this BVH into the specified file.



69
70
71
72
73
# File 'lib/bvh.rb', line 69

def export(file)
  exporter = Bvh::Exporter.new(file)
  exporter.export(self)
  self
end

#frame_countObject

Returns the number of frames in the motion capture data.



50
# File 'lib/bvh.rb', line 50

def frame_count; motion.frame_count; end

#frame_timeObject

Returns the amount of time, in seconds, each frame occupies. Most BVH files have this set to 0.333333, which is equal to 30 frames per second.



37
# File 'lib/bvh.rb', line 37

def frame_time; motion.frame_time; end

#frame_time=(a) ⇒ Object

Sets the amount of time, in seconds, each frame occupies. Most BVH files have this set to 0.333333, which is equal to 30 frames per second.



41
# File 'lib/bvh.rb', line 41

def frame_time=(a); motion.frame_time = a; end

#framesObject

Returns the frame data associated with this BVH file.



30
# File 'lib/bvh.rb', line 30

def frames; motion.frames; end

#frames_per_secondObject

Returns the frames per second calculated by (1 / frame_time)



44
# File 'lib/bvh.rb', line 44

def frames_per_second; motion.frames_per_second; end

#frames_per_second=(a) ⇒ Object

Assigns the frame_time by calculating it from (1 / frames_per_second)



47
# File 'lib/bvh.rb', line 47

def frames_per_second=(a); motion.frames_per_second = a; end

#last_frameObject

Returns the last frame associated with this animation.



33
# File 'lib/bvh.rb', line 33

def last_frame; frames.last; end

#rootObject

Returns the root bone in #skeleton



27
# File 'lib/bvh.rb', line 27

def root; skeleton.root; end

#root=(a) ⇒ Object

Assigns the root bone in #skeleton



24
# File 'lib/bvh.rb', line 24

def root=(a); skeleton.root = a; end

#skeletonObject

Returns the first (and usually the only) skeleton in the #skeletons array.



53
# File 'lib/bvh.rb', line 53

def skeleton; @skeletons.first; end