collada 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +0 -5
- data/README.md +53 -1
- data/bin/collada-convert +55 -0
- data/collada.gemspec +19 -15
- data/lib/collada/conversion/mesh.rb +144 -0
- data/lib/collada/conversion/skeleton.rb +84 -0
- data/lib/collada/conversion/tagged_format.rb +172 -0
- data/lib/collada/parser/animation.rb +57 -0
- data/lib/collada/parser/controller.rb +152 -0
- data/lib/collada/parser/geometry.rb +88 -145
- data/lib/collada/parser/library.rb +17 -12
- data/lib/collada/parser/scene.rb +1 -132
- data/lib/collada/parser/support.rb +353 -0
- data/lib/collada/parser/visual_scene.rb +159 -11
- data/lib/collada/transforms.rb +111 -0
- data/lib/collada/version.rb +1 -1
- data/test/animation.dae +165 -0
- data/test/sample.dae +211 -0
- data/test/test_parsing_animation.rb +96 -0
- data/test/test_parsing_geometry.rb +187 -0
- data/test/test_transforms.rb +56 -0
- metadata +70 -20
- data/test/test_parser.rb +0 -105
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'pathname'
|
22
|
+
require 'test/unit'
|
23
|
+
require 'stringio'
|
24
|
+
|
25
|
+
require 'collada/transforms'
|
26
|
+
|
27
|
+
class TestTransforms < Test::Unit::TestCase
|
28
|
+
def test_scale
|
29
|
+
m = Collada::Transforms.scale(2, 4, 6)
|
30
|
+
v = Vector[1, 1, 1, 0]
|
31
|
+
|
32
|
+
assert_equal Vector[2, 4, 6, 0], (m * v)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_translate
|
36
|
+
m = Collada::Transforms.translate(2, 4, 6)
|
37
|
+
v = Vector[1, 1, 1, 1]
|
38
|
+
|
39
|
+
assert_equal Vector[3, 5, 7, 1], (m * v)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_rotate
|
43
|
+
m = Collada::Transforms.rotate(1, 0, 0, 90)
|
44
|
+
v = Vector[0, 0, 1, 0]
|
45
|
+
|
46
|
+
assert_equal Vector[0, -1.0, 0, 0], (m * v).collect{|i| i.round(2)}
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_quaternions
|
50
|
+
m = Collada::Transforms.rotate(1, 0, 0, 90)
|
51
|
+
|
52
|
+
puts m
|
53
|
+
|
54
|
+
puts Collada::Transforms.rotation_matrix_to_quaternion(m)
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,22 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collada
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Samuel Williams
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
date: 2013-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rainbow
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: trollop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: libxml-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: ! "\tThis library provides support for loading and processing data from
|
56
|
+
Collada \n\tDigital Asset Exchange files. These files are typically used for sharing\n\tgeometry
|
57
|
+
and scenes.\n"
|
17
58
|
email:
|
18
59
|
- samuel.williams@oriontransfer.co.nz
|
19
|
-
executables:
|
60
|
+
executables:
|
61
|
+
- collada-convert
|
20
62
|
extensions: []
|
21
63
|
extra_rdoc_files: []
|
22
64
|
files:
|
@@ -25,45 +67,53 @@ files:
|
|
25
67
|
- Gemfile
|
26
68
|
- README.md
|
27
69
|
- Rakefile
|
70
|
+
- bin/collada-convert
|
28
71
|
- collada.gemspec
|
29
72
|
- lib/collada.rb
|
73
|
+
- lib/collada/conversion/mesh.rb
|
74
|
+
- lib/collada/conversion/skeleton.rb
|
75
|
+
- lib/collada/conversion/tagged_format.rb
|
30
76
|
- lib/collada/parser.rb
|
77
|
+
- lib/collada/parser/animation.rb
|
78
|
+
- lib/collada/parser/controller.rb
|
31
79
|
- lib/collada/parser/geometry.rb
|
32
80
|
- lib/collada/parser/library.rb
|
33
81
|
- lib/collada/parser/scene.rb
|
34
82
|
- lib/collada/parser/support.rb
|
35
83
|
- lib/collada/parser/visual_scene.rb
|
84
|
+
- lib/collada/transforms.rb
|
36
85
|
- lib/collada/version.rb
|
37
|
-
- test/
|
86
|
+
- test/animation.dae
|
87
|
+
- test/sample.dae
|
88
|
+
- test/test_parsing_animation.rb
|
89
|
+
- test/test_parsing_geometry.rb
|
90
|
+
- test/test_transforms.rb
|
38
91
|
homepage: ''
|
39
92
|
licenses: []
|
93
|
+
metadata: {}
|
40
94
|
post_install_message:
|
41
95
|
rdoc_options: []
|
42
96
|
require_paths:
|
43
97
|
- lib
|
44
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
99
|
requirements:
|
47
100
|
- - ! '>='
|
48
101
|
- !ruby/object:Gem::Version
|
49
102
|
version: '0'
|
50
|
-
segments:
|
51
|
-
- 0
|
52
|
-
hash: 2074081511210776165
|
53
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
104
|
requirements:
|
56
105
|
- - ! '>='
|
57
106
|
- !ruby/object:Gem::Version
|
58
107
|
version: '0'
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
hash: 2074081511210776165
|
62
108
|
requirements: []
|
63
109
|
rubyforge_project:
|
64
|
-
rubygems_version:
|
110
|
+
rubygems_version: 2.0.2
|
65
111
|
signing_key:
|
66
|
-
specification_version:
|
112
|
+
specification_version: 4
|
67
113
|
summary: A library for loading and manipulating Collada .dae files.
|
68
114
|
test_files:
|
69
|
-
- test/
|
115
|
+
- test/animation.dae
|
116
|
+
- test/sample.dae
|
117
|
+
- test/test_parsing_animation.rb
|
118
|
+
- test/test_parsing_geometry.rb
|
119
|
+
- test/test_transforms.rb
|
data/test/test_parser.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright, 2012, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'pathname'
|
24
|
-
require 'test/unit'
|
25
|
-
require 'stringio'
|
26
|
-
|
27
|
-
require 'collada/parser'
|
28
|
-
|
29
|
-
class TestParser < Test::Unit::TestCase
|
30
|
-
def test_accessors
|
31
|
-
parameters = [
|
32
|
-
Collada::Parser::Geometry::Mesh::Parameter.new('X', :float),
|
33
|
-
Collada::Parser::Geometry::Mesh::Parameter.new(nil, :float),
|
34
|
-
Collada::Parser::Geometry::Mesh::Parameter.new('Z', :float),
|
35
|
-
]
|
36
|
-
|
37
|
-
accessor = Collada::Parser::Geometry::Mesh::Accessor.new(
|
38
|
-
[1, 2, 3, 4, 5, 6],
|
39
|
-
parameters
|
40
|
-
)
|
41
|
-
|
42
|
-
assert_equal [['X', 1], ['Z', 3]], accessor[0]
|
43
|
-
assert_equal [['X', 4], ['Z', 6]], accessor[1]
|
44
|
-
|
45
|
-
assert_equal 2, accessor.size
|
46
|
-
assert_equal [[["X", 1], ["Z", 3]], [["X", 4], ["Z", 6]]], accessor.to_a
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_sources
|
50
|
-
chunk = <<-EOF
|
51
|
-
<?xml version="1.0" encoding="utf-8"?>
|
52
|
-
<mesh>
|
53
|
-
<source id="position">
|
54
|
-
<float_array name="values" count="30">
|
55
|
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
56
|
-
</float_array>
|
57
|
-
<technique_common>
|
58
|
-
<accessor source="#values" count="3" stride="10">
|
59
|
-
<param name="PX" type="float"/>
|
60
|
-
<param name="PY" type="float"/>
|
61
|
-
<param name="PZ" type="float"/>
|
62
|
-
</accessor>
|
63
|
-
</technique_common>
|
64
|
-
</source>
|
65
|
-
<source id="normal">
|
66
|
-
<technique_common>
|
67
|
-
<accessor source="#values" offset="3" count="3" stride="10">
|
68
|
-
<param name="NX" type="float"/>
|
69
|
-
<param name="NY" type="float"/>
|
70
|
-
<param name="NZ" type="float"/>
|
71
|
-
</accessor>
|
72
|
-
</technique_common>
|
73
|
-
</source>
|
74
|
-
<source id="mapping">
|
75
|
-
<technique_common>
|
76
|
-
<accessor source="#values" offset="6" count="3" stride="10">
|
77
|
-
<param name="TU" type="float"/>
|
78
|
-
<param name="TV" type="float"/>
|
79
|
-
</accessor>
|
80
|
-
</technique_common>
|
81
|
-
</source>
|
82
|
-
|
83
|
-
<triangles count="1">
|
84
|
-
<input semantic="POSITION" source="#position" offset="0"/>
|
85
|
-
<input semantic="NORMAL" source="#normal" offset="0"/>
|
86
|
-
<input semantic="TEXCOORD" source="#mapping" offset="0"/>
|
87
|
-
<p>1 2 3</p>
|
88
|
-
</triangles>
|
89
|
-
</mesh>
|
90
|
-
EOF
|
91
|
-
|
92
|
-
doc = REXML::Document.new(chunk)
|
93
|
-
mesh = Collada::Parser::Geometry::Mesh.parse(doc, doc.elements['mesh'])
|
94
|
-
|
95
|
-
expected = [
|
96
|
-
[[["PX", 1.0], ["PY", 2.0], ["PZ", 3.0]], [["NX", 4.0], ["NY", 5.0], ["NZ", 6.0]], [["TU", 7.0], ["TV", 8.0]]],
|
97
|
-
[[["PX", 11.0], ["PY", 12.0], ["PZ", 13.0]], [["NX", 14.0], ["NY", 15.0], ["NZ", 16.0]], [["TU", 17.0], ["TV", 18.0]]],
|
98
|
-
[[["PX", 21.0], ["PY", 22.0], ["PZ", 23.0]], [["NX", 24.0], ["NY", 25.0], ["NZ", 26.0]], [["TU", 27.0], ["TV", 28.0]]],
|
99
|
-
]
|
100
|
-
|
101
|
-
assert_equal expected[0], mesh.polygons[0]
|
102
|
-
assert_equal expected[1], mesh.polygons[1]
|
103
|
-
assert_equal expected[2], mesh.polygons[2]
|
104
|
-
end
|
105
|
-
end
|