bvh 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,27 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ viewer
23
+ test/data/in/lady.*
24
+ test/data/out/*
25
+ .idea
26
+ *.o
27
+ *.so
@@ -0,0 +1 @@
1
+ Coming soon.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Colin MacKenzie IV
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,97 @@
1
+ = BVH
2
+
3
+ This library allows you to parse, manipulate and save files in the BVH motion capture format.
4
+
5
+ To get started, remember to add the obligatory "require" statements:
6
+
7
+ require 'rubygems'
8
+ require 'bvh'
9
+
10
+ Once done, you can load a BVH file pretty easily:
11
+
12
+ bvh = Bvh.import("path/to/animation.bvh")
13
+
14
+ And you can export them just so:
15
+
16
+ bvh.export("path/to/copy_of_animation.bvh")
17
+
18
+ For a more exhaustive set of examples, see EXAMPLES.
19
+
20
+ == IMPORTANT
21
+
22
+ Although BVH is marked as 1.0, there is some functionality I haven't yet tested. In particular, the transform matrices
23
+ may or may not be accurate. The numbers look right from my command line, but I haven't had a chance to plug BVH into my
24
+ graphics engine, so they may in fact be wrong. Please let me know what you learn if you've tested this!
25
+
26
+ == The Format
27
+
28
+ What follows is a run-down of what I've learned about the BVH file format while researching and coding this library.
29
+ I reserve the right to be mistaken (but I don't think I am).
30
+
31
+ The BVH format was developed by a now-defunct company called Biovision, and stands for Biovision Hierarchical data
32
+ format. Used to store motion capture data, a BVH file consists of two sections: a HIERARCHY section, which describes
33
+ the skeletal structure that the motion capture data pertains to; and a MOTION section, which stores the motion capture
34
+ data itself.
35
+
36
+ === Hierarchy
37
+
38
+ The HIERARCHY section contains a set of nested nodes which describe a character. Most of these nodes are named. Though
39
+ the name of a given node seems to be rarely used within the context of the BVH file itself, I suspect it will be quite
40
+ useful when biping 3D models to various body parts -- but that's well beyond the scope of this library.
41
+
42
+ Each node name is expected to be unique, regardless of usage, and this library enforces that. Every node in the
43
+ HIERARCHY section is referred to by this library as a Bone, and a collection of Bones (beginning with the ROOT node) is
44
+ referred to as a Skeleton.
45
+
46
+ The first (outermost) node is tagged "ROOT" and is, obviously, considered the root of the skeleton. (Technically, there
47
+ may be more than one ROOT in a BVH file, but this is atypical. This library does support multiple roots, however.)
48
+ Following the tag is the node name, and on the next line is an opening curly brace ("{").
49
+
50
+ Information about the current Bone follows the curly braces, and includes OFFSET and CHANNELS data. OFFSET information
51
+ specifies the offset from the parent Bone, or an offset from the origin for a root. Offset information of joints are
52
+ also used to infer length and orientation for their parent bone. If multiple joints are found, the length and
53
+ orientation are determined from the first of them.
54
+
55
+ By convention, the data for a given node is preceded by a tab character for readability. This is not technically
56
+ necessary, but some stricter BVH parsers require this explicitly and cannot support other forms of white space. This
57
+ library supports arbitrary amounts and types of white space.
58
+
59
+ Child nodes, which are tagged "JOINT", follow the OFFSET and CHANNELS data, and recursively define the tree until an
60
+ "End Site" node is detected. The "End Site" node contains only OFFSET information, which is used exclusively to infer
61
+ length and orientation of the last node in the list.
62
+
63
+ The CHANNELS information for each node specifies the order in which the channel information will appear; this applies
64
+ to OFFSET data (even though the Xposition, Yposition and Zposition channels are generally only declared at the root
65
+ level, and generally follow in the expected order) as well as the frame data in the MOTION segment.
66
+
67
+ === Motion
68
+
69
+ The Motion section of the file contains the motion capture data itself. There are generally 2 lines preceding the data:
70
+ "Frames" and "Frame Time". The "Frames" line specifies the number of frames that will follow, and the "Frame Time" field
71
+ indicates how many seconds will pass per frame. Most BVH files specify the Frame Time as 0.0333333, or 30 frames per
72
+ second, but this can vary.
73
+
74
+ This BVH library dynamically counts the number of frames, and only uses the "Frames" field to verify that all available
75
+ data has been loaded. If the "Frames" field is missing, this library will not raise an error -- it will simply be unable
76
+ to verify the number of frames after a file has been loaded. (An error will be raised if the "Frames" field is supplied
77
+ and the numbers do not match, however.)
78
+
79
+ Finally, the remainder of the file consists of numbers delimited by a tab character and a space (though, again, this
80
+ library isn't particularly picky about the white space). Each line constitutes a single frame, and the series of numbers
81
+ on each line apply to the CHANNELS information in the order it was seen in the file. Because the same order is
82
+ maintained, the first several numbers usually correspond to translation (usually X, Y and Z), while the remainder of
83
+ the numbers correspond to rotation.
84
+
85
+ == Note on Patches/Pull Requests
86
+
87
+ * Fork the project.
88
+ * Make your feature addition or bug fix.
89
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
90
+ * Commit -- do not mess with rakefile, version, or history.
91
+ (If you want to have your own version, that's fine, but bump version in a commit by itself so that I can ignore it
92
+ when I pull.)
93
+ * Send me a pull request. Bonus points for topic branches.
94
+
95
+ == Copyright
96
+
97
+ Copyright (c) 2009 Colin MacKenzie IV. See LICENSE for details.
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "bvh"
8
+ gem.summary = %Q{A library for loading, modifying and saving BVH motion capture files.}
9
+ gem.description = %Q{A library for loading, modifying and saving BVH motion capture files.}
10
+ gem.email = "sinisterchipmunk@gmail.com"
11
+ gem.homepage = "http://github.com/sinisterchipmunk/bvh"
12
+ gem.authors = ["Colin MacKenzie IV (sinisterchipmunk)"]
13
+ gem.add_development_dependency "shoulda", ">= 0"
14
+ gem.extensions = FileList["ext/**/extconf.rb"].to_a
15
+ gem.files.concat FileList["ext/**/*.c"].to_a
16
+ gem.files.concat FileList["ext/**/*.h"].to_a
17
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/*_test.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/test_*.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
42
+ end
43
+
44
+ task :test => :check_dependencies
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "BVH #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('EXAMPLES*')
56
+ rdoc.rdoc_files.include('LICENSE')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{bvh}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Colin MacKenzie IV (sinisterchipmunk)"]
12
+ s.date = %q{2009-12-08}
13
+ s.description = %q{A library for loading, modifying and saving BVH motion capture files.}
14
+ s.email = %q{sinisterchipmunk@gmail.com}
15
+ s.extensions = ["ext/bvh/extconf.rb"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "EXAMPLES.rdoc",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bvh.gemspec",
29
+ "ext/bvh/Makefile",
30
+ "ext/bvh/bvh.c",
31
+ "ext/bvh/bvh.h",
32
+ "ext/bvh/bvh_parser.c",
33
+ "ext/bvh/extconf.rb",
34
+ "lib/bvh.rb",
35
+ "lib/bvh/exporter.rb",
36
+ "lib/bvh/matrix.rb",
37
+ "lib/bvh/motion.rb",
38
+ "lib/bvh/motion/channel_data.rb",
39
+ "lib/bvh/motion/frame.rb",
40
+ "lib/bvh/parser.rb",
41
+ "lib/bvh/skeleton.rb",
42
+ "test/bvh_test.rb",
43
+ "test/data/in/karate.bvh",
44
+ "test/helper.rb"
45
+ ]
46
+ s.homepage = %q{http://github.com/sinisterchipmunk/bvh}
47
+ s.rdoc_options = ["--charset=UTF-8"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = %q{1.3.5}
50
+ s.summary = %q{A library for loading, modifying and saving BVH motion capture files.}
51
+ s.test_files = [
52
+ "test/bvh_test.rb",
53
+ "test/helper.rb"
54
+ ]
55
+
56
+ if s.respond_to? :specification_version then
57
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
61
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<shoulda>, [">= 0"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<shoulda>, [">= 0"])
67
+ end
68
+ end
69
+
@@ -0,0 +1,149 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = .
7
+ topdir = /c/ruby186-mingw/lib/ruby/1.8/i386-mingw32
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+
11
+ DESTDIR = c:
12
+ prefix = $(DESTDIR)/ruby186-mingw
13
+ exec_prefix = $(prefix)
14
+ sitedir = $(exec_prefix)/lib/ruby/site_ruby
15
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
16
+ docdir = $(datarootdir)/doc/$(PACKAGE)
17
+ dvidir = $(docdir)
18
+ datarootdir = $(prefix)/share
19
+ archdir = $(rubylibdir)/$(arch)
20
+ sbindir = $(exec_prefix)/sbin
21
+ psdir = $(docdir)
22
+ localedir = $(datarootdir)/locale
23
+ htmldir = $(docdir)
24
+ datadir = $(datarootdir)
25
+ includedir = $(prefix)/include
26
+ infodir = $(datarootdir)/info
27
+ sysconfdir = $(prefix)/etc
28
+ mandir = $(datarootdir)/man
29
+ libdir = $(exec_prefix)/lib
30
+ sharedstatedir = $(prefix)/com
31
+ oldincludedir = $(DESTDIR)/usr/include
32
+ pdfdir = $(docdir)
33
+ sitearchdir = $(sitelibdir)/$(sitearch)
34
+ localstatedir = $(prefix)/var
35
+ bindir = $(exec_prefix)/bin
36
+ sitelibdir = $(sitedir)/$(ruby_version)
37
+ libexecdir = $(exec_prefix)/libexec
38
+
39
+ CC = gcc
40
+ LIBRUBY = lib$(LIBRUBY_SO).a
41
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
42
+ LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
43
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
44
+
45
+ RUBY_EXTCONF_H =
46
+ CFLAGS = -g -O2
47
+ INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
48
+ DEFS =
49
+ CPPFLAGS = $(DEFS)
50
+ CXXFLAGS = $(CFLAGS)
51
+ DLDFLAGS = -L. -Wl,--enable-auto-image-base,--enable-auto-import,--export-all
52
+ LDSHARED = gcc -shared -s
53
+ AR = ar
54
+ EXEEXT = .exe
55
+
56
+ RUBY_INSTALL_NAME = ruby
57
+ RUBY_SO_NAME = msvcrt-ruby18
58
+ arch = i386-mingw32
59
+ sitearch = i386-msvcrt
60
+ ruby_version = 1.8
61
+ ruby = c:/ruby186-mingw/bin/ruby
62
+ RUBY = $(ruby)
63
+ RM = rm -f
64
+ MAKEDIRS = mkdir -p
65
+ INSTALL = /bin/install -c
66
+ INSTALL_PROG = $(INSTALL) -m 0755
67
+ INSTALL_DATA = $(INSTALL) -m 644
68
+ COPY = cp
69
+
70
+ #### End of system configuration section. ####
71
+
72
+ preload =
73
+
74
+ libpath = . $(libdir)
75
+ LIBPATH = -L. -L$(libdir)
76
+ DEFFILE =
77
+
78
+ CLEANFILES = mkmf.log
79
+ DISTCLEANFILES =
80
+
81
+ extout =
82
+ extout_prefix =
83
+ target_prefix =
84
+ LOCAL_LIBS =
85
+ LIBS = $(LIBRUBYARG_SHARED) -lshell32 -lws2_32
86
+ SRCS = bvh.c bvh_parser.c
87
+ OBJS = bvh.o bvh_parser.o
88
+ TARGET = bvh
89
+ DLLIB = $(TARGET).so
90
+ EXTSTATIC =
91
+ STATIC_LIB =
92
+
93
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
94
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
95
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
96
+
97
+ TARGET_SO = $(DLLIB)
98
+ CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
99
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
100
+
101
+ all: $(DLLIB)
102
+ static: $(STATIC_LIB)
103
+
104
+ clean:
105
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
106
+
107
+ distclean: clean
108
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
109
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
110
+
111
+ realclean: distclean
112
+ install: install-so install-rb
113
+
114
+ install-so: $(RUBYARCHDIR)
115
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
116
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
117
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
118
+ install-rb: pre-install-rb install-rb-default
119
+ install-rb-default: pre-install-rb-default
120
+ pre-install-rb: Makefile
121
+ pre-install-rb-default: Makefile
122
+ $(RUBYARCHDIR):
123
+ $(MAKEDIRS) $@
124
+
125
+ site-install: site-install-so site-install-rb
126
+ site-install-so: install-so
127
+ site-install-rb: install-rb
128
+
129
+ .SUFFIXES: .c .m .cc .cxx .cpp .o
130
+
131
+ .cc.o:
132
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
133
+
134
+ .cxx.o:
135
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
136
+
137
+ .cpp.o:
138
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
139
+
140
+ .c.o:
141
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
142
+
143
+ $(DLLIB): $(OBJS) Makefile
144
+ @-$(RM) $@
145
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
146
+
147
+
148
+
149
+ $(OBJS): ruby.h defines.h
@@ -0,0 +1,10 @@
1
+ #include "bvh.h"
2
+
3
+ VALUE rb_cBvh = Qnil;
4
+
5
+ void Init_bvh()
6
+ {
7
+ rb_cBvh = rb_define_class("Bvh", rb_cObject);
8
+
9
+ bvh_init_parser();
10
+ }