bvh 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -5
- data/.gitignore +29 -27
- data/EXAMPLES.rdoc +1 -1
- data/LICENSE +20 -20
- data/README.rdoc +97 -97
- data/Rakefile +58 -58
- data/VERSION +1 -1
- data/bvh.gemspec +69 -69
- data/ext/bvh/Makefile +96 -58
- data/ext/bvh/bvh.c +10 -10
- data/ext/bvh/bvh.h +18 -10
- data/ext/bvh/bvh_parser.c +65 -63
- data/ext/bvh/extconf.rb +4 -4
- data/lib/bvh.rb +74 -74
- data/lib/bvh/exporter.rb +86 -86
- data/lib/bvh/matrix.rb +19 -19
- data/lib/bvh/motion.rb +79 -79
- data/lib/bvh/motion/channel_data.rb +147 -147
- data/lib/bvh/motion/frame.rb +124 -124
- data/lib/bvh/parser.rb +177 -177
- data/lib/bvh/skeleton.rb +84 -84
- data/test/bvh_test.rb +62 -62
- data/test/data/in/karate.bvh +767 -767
- data/test/helper.rb +13 -13
- metadata +21 -9
data/ext/bvh/Makefile
CHANGED
@@ -4,65 +4,86 @@ SHELL = /bin/sh
|
|
4
4
|
#### Start of system configuration section. ####
|
5
5
|
|
6
6
|
srcdir = .
|
7
|
-
topdir = /
|
8
|
-
hdrdir =
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
topdir = /Users/colin/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1
|
8
|
+
hdrdir = /Users/colin/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1
|
9
|
+
arch_hdrdir = /Users/colin/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/$(arch)
|
10
|
+
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
11
|
+
prefix = $(DESTDIR)/Users/colin/.rvm/rubies/ruby-1.9.2-p0
|
12
|
+
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
13
13
|
exec_prefix = $(prefix)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
psdir = $(docdir)
|
14
|
+
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
15
|
+
sitehdrdir = $(rubyhdrdir)/site_ruby
|
16
|
+
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
|
17
|
+
vendordir = $(rubylibprefix)/vendor_ruby
|
18
|
+
sitedir = $(rubylibprefix)/site_ruby
|
19
|
+
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
20
|
+
mandir = $(datarootdir)/man
|
22
21
|
localedir = $(datarootdir)/locale
|
22
|
+
libdir = $(exec_prefix)/lib
|
23
|
+
psdir = $(docdir)
|
24
|
+
pdfdir = $(docdir)
|
25
|
+
dvidir = $(docdir)
|
23
26
|
htmldir = $(docdir)
|
24
|
-
datadir = $(datarootdir)
|
25
|
-
includedir = $(prefix)/include
|
26
27
|
infodir = $(datarootdir)/info
|
27
|
-
|
28
|
-
mandir = $(datarootdir)/man
|
29
|
-
libdir = $(exec_prefix)/lib
|
30
|
-
sharedstatedir = $(prefix)/com
|
28
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
31
29
|
oldincludedir = $(DESTDIR)/usr/include
|
32
|
-
|
33
|
-
sitearchdir = $(sitelibdir)/$(sitearch)
|
30
|
+
includedir = $(prefix)/include
|
34
31
|
localstatedir = $(prefix)/var
|
32
|
+
sharedstatedir = $(prefix)/com
|
33
|
+
sysconfdir = $(prefix)/etc
|
34
|
+
datadir = $(datarootdir)
|
35
|
+
datarootdir = $(prefix)/share
|
36
|
+
libexecdir = $(exec_prefix)/libexec
|
37
|
+
sbindir = $(exec_prefix)/sbin
|
35
38
|
bindir = $(exec_prefix)/bin
|
39
|
+
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
40
|
+
archdir = $(rubylibdir)/$(arch)
|
36
41
|
sitelibdir = $(sitedir)/$(ruby_version)
|
37
|
-
|
42
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
43
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
44
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
38
45
|
|
39
46
|
CC = gcc
|
40
|
-
|
47
|
+
CXX = g++
|
48
|
+
LIBRUBY = $(LIBRUBY_SO)
|
41
49
|
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
42
50
|
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
43
51
|
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
52
|
+
OUTFLAG = -o
|
53
|
+
COUTFLAG = -o
|
44
54
|
|
45
55
|
RUBY_EXTCONF_H =
|
46
|
-
|
47
|
-
|
56
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
57
|
+
optflags = -O3
|
58
|
+
debugflags = -ggdb
|
59
|
+
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long
|
60
|
+
CFLAGS = -fno-common $(cflags) -fno-common -pipe
|
61
|
+
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
48
62
|
DEFS =
|
49
|
-
CPPFLAGS =
|
50
|
-
CXXFLAGS = $(CFLAGS)
|
51
|
-
|
52
|
-
|
63
|
+
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
|
64
|
+
CXXFLAGS = $(CFLAGS) $(cxxflags)
|
65
|
+
ldflags = -L. -L/usr/local/lib
|
66
|
+
dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
|
67
|
+
ARCH_FLAG =
|
68
|
+
DLDFLAGS = $(ldflags) $(dldflags)
|
69
|
+
LDSHARED = $(CC) -dynamic -bundle
|
70
|
+
LDSHAREDXX = $(CXX) -dynamic -bundle
|
53
71
|
AR = ar
|
54
|
-
EXEEXT =
|
72
|
+
EXEEXT =
|
55
73
|
|
74
|
+
RUBY_BASE_NAME = ruby
|
56
75
|
RUBY_INSTALL_NAME = ruby
|
57
|
-
RUBY_SO_NAME =
|
58
|
-
arch =
|
59
|
-
sitearch =
|
60
|
-
ruby_version = 1.
|
61
|
-
ruby =
|
76
|
+
RUBY_SO_NAME = ruby.1.9.1
|
77
|
+
arch = x86_64-darwin10.4.0
|
78
|
+
sitearch = $(arch)
|
79
|
+
ruby_version = 1.9.1
|
80
|
+
ruby = /Users/colin/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
|
62
81
|
RUBY = $(ruby)
|
63
82
|
RM = rm -f
|
64
|
-
|
65
|
-
|
83
|
+
RM_RF = $(RUBY) -run -e rm -- -rf
|
84
|
+
RMDIRS = $(RUBY) -run -e rmdir -- -p
|
85
|
+
MAKEDIRS = /opt/local/bin/gmkdir -p
|
86
|
+
INSTALL = /usr/bin/install -c
|
66
87
|
INSTALL_PROG = $(INSTALL) -m 0755
|
67
88
|
INSTALL_DATA = $(INSTALL) -m 644
|
68
89
|
COPY = cp
|
@@ -77,44 +98,58 @@ DEFFILE =
|
|
77
98
|
|
78
99
|
CLEANFILES = mkmf.log
|
79
100
|
DISTCLEANFILES =
|
101
|
+
DISTCLEANDIRS =
|
80
102
|
|
81
103
|
extout =
|
82
104
|
extout_prefix =
|
83
105
|
target_prefix =
|
84
106
|
LOCAL_LIBS =
|
85
|
-
LIBS = $(LIBRUBYARG_SHARED) -
|
107
|
+
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
|
86
108
|
SRCS = bvh.c bvh_parser.c
|
87
109
|
OBJS = bvh.o bvh_parser.o
|
88
|
-
TARGET =
|
89
|
-
DLLIB = $(TARGET).
|
110
|
+
TARGET = bvh_c
|
111
|
+
DLLIB = $(TARGET).bundle
|
90
112
|
EXTSTATIC =
|
91
113
|
STATIC_LIB =
|
92
114
|
|
115
|
+
BINDIR = $(bindir)
|
93
116
|
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
94
117
|
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
95
118
|
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
119
|
+
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
120
|
+
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
96
121
|
|
97
122
|
TARGET_SO = $(DLLIB)
|
98
|
-
CLEANLIBS = $(TARGET).
|
99
|
-
CLEANOBJS = *.o
|
100
|
-
|
101
|
-
all:
|
102
|
-
static:
|
103
|
-
|
104
|
-
clean
|
123
|
+
CLEANLIBS = $(TARGET).bundle
|
124
|
+
CLEANOBJS = *.o *.bak
|
125
|
+
|
126
|
+
all: $(DLLIB)
|
127
|
+
static: $(STATIC_LIB)
|
128
|
+
.PHONY: all install static install-so install-rb
|
129
|
+
.PHONY: clean clean-so clean-rb
|
130
|
+
|
131
|
+
clean-rb-default::
|
132
|
+
clean-rb::
|
133
|
+
clean-so::
|
134
|
+
clean: clean-so clean-rb-default clean-rb
|
105
135
|
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
106
136
|
|
107
|
-
distclean
|
137
|
+
distclean-rb-default::
|
138
|
+
distclean-rb::
|
139
|
+
distclean-so::
|
140
|
+
distclean: clean distclean-so distclean-rb-default distclean-rb
|
108
141
|
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
109
142
|
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
143
|
+
@-$(RMDIRS) $(DISTCLEANDIRS)
|
110
144
|
|
111
|
-
realclean:
|
145
|
+
realclean: distclean
|
112
146
|
install: install-so install-rb
|
113
147
|
|
114
148
|
install-so: $(RUBYARCHDIR)
|
115
149
|
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
116
150
|
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
117
|
-
|
151
|
+
@-$(MAKEDIRS) $(@D)
|
152
|
+
$(INSTALL_PROG) $(DLLIB) $(@D)
|
118
153
|
install-rb: pre-install-rb install-rb-default
|
119
154
|
install-rb-default: pre-install-rb-default
|
120
155
|
pre-install-rb: Makefile
|
@@ -126,24 +161,27 @@ site-install: site-install-so site-install-rb
|
|
126
161
|
site-install-so: install-so
|
127
162
|
site-install-rb: install-rb
|
128
163
|
|
129
|
-
.SUFFIXES: .c .m .cc .cxx .cpp .o
|
164
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
130
165
|
|
131
166
|
.cc.o:
|
132
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
167
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
133
168
|
|
134
169
|
.cxx.o:
|
135
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
170
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
136
171
|
|
137
172
|
.cpp.o:
|
138
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
173
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
174
|
+
|
175
|
+
.C.o:
|
176
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
139
177
|
|
140
178
|
.c.o:
|
141
|
-
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
|
179
|
+
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
142
180
|
|
143
181
|
$(DLLIB): $(OBJS) Makefile
|
144
|
-
@-$(RM)
|
182
|
+
@-$(RM) $(@)
|
145
183
|
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
146
184
|
|
147
185
|
|
148
186
|
|
149
|
-
$(OBJS): ruby.h defines.h
|
187
|
+
$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
|
data/ext/bvh/bvh.c
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#include "bvh.h"
|
2
|
-
|
3
|
-
VALUE rb_cBvh = Qnil;
|
4
|
-
|
5
|
-
void
|
6
|
-
{
|
7
|
-
rb_cBvh = rb_define_class("Bvh", rb_cObject);
|
8
|
-
|
9
|
-
bvh_init_parser();
|
10
|
-
}
|
1
|
+
#include "bvh.h"
|
2
|
+
|
3
|
+
VALUE rb_cBvh = Qnil;
|
4
|
+
|
5
|
+
void Init_bvh_c()
|
6
|
+
{
|
7
|
+
rb_cBvh = rb_define_class("Bvh", rb_cObject);
|
8
|
+
|
9
|
+
bvh_init_parser();
|
10
|
+
}
|
data/ext/bvh/bvh.h
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
#ifndef BVH_EXT_H
|
2
|
-
#define BVH_EXT_H
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
#
|
1
|
+
#ifndef BVH_EXT_H
|
2
|
+
#define BVH_EXT_H
|
3
|
+
|
4
|
+
#include "ruby.h"
|
5
|
+
|
6
|
+
#ifndef RARRAY_PTR
|
7
|
+
#define RARRAY_PTR(x) RArray(x)->ptr
|
8
|
+
#endif
|
9
|
+
|
10
|
+
#ifndef RARRAY_LEN
|
11
|
+
#define RARRAY_LEN(x) RArray(x)->len
|
12
|
+
#endif
|
13
|
+
|
14
|
+
extern void bvh_init_parser();
|
15
|
+
|
16
|
+
extern VALUE rb_cBvh;
|
17
|
+
|
18
|
+
#endif//BVH_EXT_H
|
data/ext/bvh/bvh_parser.c
CHANGED
@@ -1,63 +1,65 @@
|
|
1
|
-
#include "bvh.h"
|
2
|
-
|
3
|
-
static VALUE rb_fParseChannelData(VALUE self, VALUE channels, VALUE bone);
|
4
|
-
|
5
|
-
static VALUE rb_cBvhParser = Qnil;
|
6
|
-
static VALUE rb_cMotion = Qnil;
|
7
|
-
static VALUE rb_cChannelData = Qnil;
|
8
|
-
|
9
|
-
void bvh_init_parser()
|
10
|
-
{
|
11
|
-
rb_cBvhParser = rb_define_class_under(rb_cBvh, "Parser", rb_cObject);
|
12
|
-
rb_cMotion = rb_define_class_under(rb_cBvh, "Motion", rb_cObject);
|
13
|
-
rb_cChannelData = rb_define_class_under(rb_cMotion, "ChannelData", rb_cHash);
|
14
|
-
|
15
|
-
rb_define_private_method(rb_cBvhParser, "channel_data", rb_fParseChannelData, 2);
|
16
|
-
}
|
17
|
-
|
18
|
-
static void debug(const char *text)
|
19
|
-
{
|
20
|
-
rb_funcall(rb_cObject, rb_intern("puts"), rb_str_new2(text));
|
21
|
-
}
|
22
|
-
|
23
|
-
static VALUE rb_fParseChannelData(VALUE self, VALUE channels, VALUE bone)
|
24
|
-
{
|
25
|
-
char buf[256];
|
26
|
-
|
27
|
-
VALUE data;
|
28
|
-
struct RArray *rchannels, *joints;
|
29
|
-
|
30
|
-
|
31
|
-
VALUE
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
data =
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
1
|
+
#include "bvh.h"
|
2
|
+
|
3
|
+
static VALUE rb_fParseChannelData(VALUE self, VALUE channels, VALUE bone);
|
4
|
+
|
5
|
+
static VALUE rb_cBvhParser = Qnil;
|
6
|
+
static VALUE rb_cMotion = Qnil;
|
7
|
+
static VALUE rb_cChannelData = Qnil;
|
8
|
+
|
9
|
+
void bvh_init_parser()
|
10
|
+
{
|
11
|
+
rb_cBvhParser = rb_define_class_under(rb_cBvh, "Parser", rb_cObject);
|
12
|
+
rb_cMotion = rb_define_class_under(rb_cBvh, "Motion", rb_cObject);
|
13
|
+
rb_cChannelData = rb_define_class_under(rb_cMotion, "ChannelData", rb_cHash);
|
14
|
+
|
15
|
+
rb_define_private_method(rb_cBvhParser, "channel_data", rb_fParseChannelData, 2);
|
16
|
+
}
|
17
|
+
|
18
|
+
static void debug(const char *text)
|
19
|
+
{
|
20
|
+
rb_funcall(rb_cObject, rb_intern("puts"), rb_str_new2(text));
|
21
|
+
}
|
22
|
+
|
23
|
+
static VALUE rb_fParseChannelData(VALUE self, VALUE channels, VALUE bone)
|
24
|
+
{
|
25
|
+
char buf[256];
|
26
|
+
|
27
|
+
VALUE data;
|
28
|
+
//struct RArray *rchannels, *joints;
|
29
|
+
VALUE rchannels, joints;
|
30
|
+
long i;
|
31
|
+
VALUE channel, joint;
|
32
|
+
VALUE r = rb_ary_new();
|
33
|
+
|
34
|
+
// return [] unless bone.respond_to? :channels
|
35
|
+
if (!rb_respond_to(bone, rb_intern("channels")))
|
36
|
+
return r;
|
37
|
+
|
38
|
+
// data = Bvh::Motion::ChannelData.new(bone)
|
39
|
+
data = rb_funcall(rb_cChannelData, rb_intern("new"), 1, bone);
|
40
|
+
|
41
|
+
// bone.channels.each { |channel| data[channel] = channels.shift }
|
42
|
+
//rchannels = RARRAY(rb_funcall(bone, rb_intern("channels"), 0));
|
43
|
+
rchannels = rb_funcall(bone, rb_intern("channels"), 0);
|
44
|
+
for (i = 0; i < RARRAY_LEN(rchannels); i++)
|
45
|
+
{
|
46
|
+
channel = *(RARRAY_PTR(rchannels)+i);
|
47
|
+
//... data[channel] = channels.shift ...
|
48
|
+
rb_hash_aset(data, channel, rb_funcall(channels, rb_intern("shift"), 0));
|
49
|
+
}
|
50
|
+
|
51
|
+
// r = [data]
|
52
|
+
rb_ary_push(r, data);
|
53
|
+
|
54
|
+
// bone.joints.each { |joint| r.concat channel_data(channels, joint) }
|
55
|
+
joints = rb_funcall(bone, rb_intern("joints"), 0);
|
56
|
+
for (i = 0; i < RARRAY_LEN(joints); i++)
|
57
|
+
{
|
58
|
+
joint = *(RARRAY_PTR(joints)+i);
|
59
|
+
// ... r.concat(channel_data(channels, joint)) ...
|
60
|
+
rb_funcall(r, rb_intern("concat"), 1, rb_fParseChannelData(self, channels, joint));
|
61
|
+
}
|
62
|
+
|
63
|
+
// r
|
64
|
+
return r;
|
65
|
+
}
|
data/ext/bvh/extconf.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'mkmf'
|
2
|
-
|
3
|
-
dir_config('bvh')
|
4
|
-
create_makefile('
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
dir_config('bvh')
|
4
|
+
create_makefile('bvh_c')
|
data/lib/bvh.rb
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
require '
|
2
|
-
require 'bvh/matrix'
|
3
|
-
require 'bvh/motion'
|
4
|
-
require 'bvh/motion/channel_data'
|
5
|
-
require 'bvh/motion/frame'
|
6
|
-
require 'bvh/skeleton'
|
7
|
-
require 'bvh/parser'
|
8
|
-
require 'bvh/exporter'
|
9
|
-
|
10
|
-
|
11
|
-
class Bvh
|
12
|
-
# The array of skeletons associated with this BVH.
|
13
|
-
attr_reader :skeletons
|
14
|
-
|
15
|
-
# The motion capture data associated with this BVH.
|
16
|
-
attr_reader :motion
|
17
|
-
|
18
|
-
def initialize
|
19
|
-
@motion = Bvh::Motion.new
|
20
|
-
@skeletons = []
|
21
|
-
end
|
22
|
-
|
23
|
-
# Assigns the root bone in #skeleton
|
24
|
-
def root=(a); skeleton.root = a; end
|
25
|
-
|
26
|
-
# Returns the root bone in #skeleton
|
27
|
-
def root; skeleton.root; end
|
28
|
-
|
29
|
-
# Returns the frame data associated with this BVH file.
|
30
|
-
def frames; motion.frames; end
|
31
|
-
|
32
|
-
# Returns the last frame associated with this animation.
|
33
|
-
def last_frame; frames.last; end
|
34
|
-
|
35
|
-
# Returns the amount of time, in seconds, each frame occupies. Most BVH files have this set to
|
36
|
-
# 0.333333, which is equal to 30 frames per second.
|
37
|
-
def frame_time; motion.frame_time; end
|
38
|
-
|
39
|
-
# Sets the amount of time, in seconds, each frame occupies. Most BVH files have this set to
|
40
|
-
# 0.333333, which is equal to 30 frames per second.
|
41
|
-
def frame_time=(a); motion.frame_time = a; end
|
42
|
-
|
43
|
-
# Returns the frames per second calculated by (1 / frame_time)
|
44
|
-
def frames_per_second; motion.frames_per_second; end
|
45
|
-
|
46
|
-
# Assigns the frame_time by calculating it from (1 / frames_per_second)
|
47
|
-
def frames_per_second=(a); motion.frames_per_second = a; end
|
48
|
-
|
49
|
-
# Returns the number of frames in the motion capture data.
|
50
|
-
def frame_count; motion.frame_count; end
|
51
|
-
|
52
|
-
# Returns the first (and usually the only) skeleton in the #skeletons array.
|
53
|
-
def skeleton; @skeletons.first; end
|
54
|
-
|
55
|
-
# Creates a new skeleton, adds it to the #skeletons array, and returns it.
|
56
|
-
def create_skeleton!; (@skeletons << Bvh::Skeleton.new).last; end
|
57
|
-
|
58
|
-
class << self
|
59
|
-
# Instantiates a new BVH and imports its data from the specified file
|
60
|
-
def import(file)
|
61
|
-
bvh = self.new
|
62
|
-
parser = Bvh::Parser.new(file)
|
63
|
-
parser.parse(bvh)
|
64
|
-
bvh
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Exports this BVH into the specified file.
|
69
|
-
def export(file)
|
70
|
-
exporter = Bvh::Exporter.new(file)
|
71
|
-
exporter.export(self)
|
72
|
-
self
|
73
|
-
end
|
74
|
-
end
|
1
|
+
require 'bvh_c'
|
2
|
+
require 'bvh/matrix'
|
3
|
+
require 'bvh/motion'
|
4
|
+
require 'bvh/motion/channel_data'
|
5
|
+
require 'bvh/motion/frame'
|
6
|
+
require 'bvh/skeleton'
|
7
|
+
require 'bvh/parser'
|
8
|
+
require 'bvh/exporter'
|
9
|
+
|
10
|
+
|
11
|
+
class Bvh
|
12
|
+
# The array of skeletons associated with this BVH.
|
13
|
+
attr_reader :skeletons
|
14
|
+
|
15
|
+
# The motion capture data associated with this BVH.
|
16
|
+
attr_reader :motion
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@motion = Bvh::Motion.new
|
20
|
+
@skeletons = []
|
21
|
+
end
|
22
|
+
|
23
|
+
# Assigns the root bone in #skeleton
|
24
|
+
def root=(a); skeleton.root = a; end
|
25
|
+
|
26
|
+
# Returns the root bone in #skeleton
|
27
|
+
def root; skeleton.root; end
|
28
|
+
|
29
|
+
# Returns the frame data associated with this BVH file.
|
30
|
+
def frames; motion.frames; end
|
31
|
+
|
32
|
+
# Returns the last frame associated with this animation.
|
33
|
+
def last_frame; frames.last; end
|
34
|
+
|
35
|
+
# Returns the amount of time, in seconds, each frame occupies. Most BVH files have this set to
|
36
|
+
# 0.333333, which is equal to 30 frames per second.
|
37
|
+
def frame_time; motion.frame_time; end
|
38
|
+
|
39
|
+
# Sets the amount of time, in seconds, each frame occupies. Most BVH files have this set to
|
40
|
+
# 0.333333, which is equal to 30 frames per second.
|
41
|
+
def frame_time=(a); motion.frame_time = a; end
|
42
|
+
|
43
|
+
# Returns the frames per second calculated by (1 / frame_time)
|
44
|
+
def frames_per_second; motion.frames_per_second; end
|
45
|
+
|
46
|
+
# Assigns the frame_time by calculating it from (1 / frames_per_second)
|
47
|
+
def frames_per_second=(a); motion.frames_per_second = a; end
|
48
|
+
|
49
|
+
# Returns the number of frames in the motion capture data.
|
50
|
+
def frame_count; motion.frame_count; end
|
51
|
+
|
52
|
+
# Returns the first (and usually the only) skeleton in the #skeletons array.
|
53
|
+
def skeleton; @skeletons.first; end
|
54
|
+
|
55
|
+
# Creates a new skeleton, adds it to the #skeletons array, and returns it.
|
56
|
+
def create_skeleton!; (@skeletons << Bvh::Skeleton.new).last; end
|
57
|
+
|
58
|
+
class << self
|
59
|
+
# Instantiates a new BVH and imports its data from the specified file
|
60
|
+
def import(file)
|
61
|
+
bvh = self.new
|
62
|
+
parser = Bvh::Parser.new(file)
|
63
|
+
parser.parse(bvh)
|
64
|
+
bvh
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Exports this BVH into the specified file.
|
69
|
+
def export(file)
|
70
|
+
exporter = Bvh::Exporter.new(file)
|
71
|
+
exporter.export(self)
|
72
|
+
self
|
73
|
+
end
|
74
|
+
end
|