collada 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/collada/conversion/tagged_format.rb +30 -7
- data/lib/collada/parser/visual_scene.rb +5 -2
- data/lib/collada/transforms.rb +5 -0
- data/lib/collada/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTJlZDlkNTNiNmRjYTYxZGE3OGNmZjFiODhmNjA2YmM2OTIzMjdmMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmUzNjhjY2UxMGZkYmNjYzhjM2ZkZWMxNTIyMTU4NjhiZWRkNjI0Mg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDdhYmU5NjdhYTQyZWQxYmE5NTVhYTJiNzIzYjJlNDFlZmFiNWNjNThlMDEz
|
10
|
+
ZDRkMmE3MTcyMGViZGYxMWZjYWQ3MTc2MjA0NjNiMTU0OWRhZWQxOTk5OGQ3
|
11
|
+
ZDNmOGY5NGZiMmNjOTk1NWQ1MTA1YjBmMGRmODhlNmY2MmE0NmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTg3OTAzNGRkNmM3NmZiZmNkMzcyYTRiMWViMTRmNjBkZTdlZjNhZWFkMjg3
|
14
|
+
NjVkNjhlYjQyODE3NzJmZTNiMzkzYTYzMDE3NjkxMDA2OTQ3YzM5ODAyZjM1
|
15
|
+
ZjY2YmJhZmI5ZmRkYzUwZDA2ZjVjNzcwY2I1ZWFhODQ2ODllYjU=
|
@@ -2,13 +2,18 @@
|
|
2
2
|
module Collada
|
3
3
|
module Conversion
|
4
4
|
class TaggedFormat
|
5
|
+
class GeometryError < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
TEXCOORD = lambda {|value| [value[:S], -value[:T] + 1.0]}
|
9
|
+
|
5
10
|
VERTEX_FORMATS = {
|
6
11
|
"p3n3" => VertexFormat[position: [:X, :Y, :Z], normal: [:X, :Y, :Z]],
|
7
|
-
"p3n3m2" => VertexFormat[position: [:X, :Y, :Z], normal: [:X, :Y, :Z], texcoord:
|
8
|
-
"p3n3m2b2" => VertexFormat[position: [:X, :Y, :Z], normal: [:X, :Y, :Z], texcoord:
|
9
|
-
"p3n3m2b4" => VertexFormat[position: [:X, :Y, :Z], normal: [:X, :Y, :Z], texcoord:
|
12
|
+
"p3n3m2" => VertexFormat[position: [:X, :Y, :Z], normal: [:X, :Y, :Z], texcoord: TEXCOORD],
|
13
|
+
"p3n3m2b2" => VertexFormat[position: [:X, :Y, :Z], normal: [:X, :Y, :Z], texcoord: TEXCOORD, bones: WeightFormat[4]],
|
14
|
+
"p3n3m2b4" => VertexFormat[position: [:X, :Y, :Z], normal: [:X, :Y, :Z], texcoord: TEXCOORD, bones: WeightFormat[4]],
|
10
15
|
}
|
11
|
-
|
16
|
+
|
12
17
|
def initialize(options, library, output = nil)
|
13
18
|
@options = options
|
14
19
|
@library = library
|
@@ -20,7 +25,13 @@ module Collada
|
|
20
25
|
@top = {}
|
21
26
|
@nodes = {}
|
22
27
|
end
|
23
|
-
|
28
|
+
|
29
|
+
def extract_axes(scene, node, instance)
|
30
|
+
node.children.collect do |child|
|
31
|
+
[child.name, *Transforms.extract_axis(child.local_transform_matrix)]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
24
35
|
def dump_geometry(scene, node, instance, skeleton = nil)
|
25
36
|
vertex_format = @output_vertex_format.with_vertex_index
|
26
37
|
geometry = instance.lookup(@library)
|
@@ -30,6 +41,10 @@ module Collada
|
|
30
41
|
weights = skeleton.indexed_weights if skeleton
|
31
42
|
|
32
43
|
geometry.mesh.polygons.each do |polygon|
|
44
|
+
if polygon.count != 3
|
45
|
+
raise GeometryError.new("Non-triangular surfaces ")
|
46
|
+
end
|
47
|
+
|
33
48
|
polygon.each do |vertex_attributes|
|
34
49
|
vertex = Collada::Conversion::Vertex.new(vertex_attributes, vertex_format)
|
35
50
|
|
@@ -38,9 +53,9 @@ module Collada
|
|
38
53
|
mesh << vertex
|
39
54
|
end
|
40
55
|
end
|
41
|
-
|
56
|
+
|
42
57
|
@output.puts "#{geometry.id}: mesh triangles"
|
43
|
-
|
58
|
+
|
44
59
|
@output.puts " indices: array index16"
|
45
60
|
mesh.indices.each_slice(12) do |indices|
|
46
61
|
@output.puts " #{indices.flatten.collect{|i| i.to_s.rjust(5)}.join}"
|
@@ -54,6 +69,14 @@ module Collada
|
|
54
69
|
end
|
55
70
|
@output.puts " end"
|
56
71
|
|
72
|
+
axes = extract_axes(scene, node, instance)
|
73
|
+
|
74
|
+
@output.puts " axes: array axis"
|
75
|
+
axes.each do |axis|
|
76
|
+
@output.puts " #{axis.collect{|i| i.to_s.rjust(12)}.join(' ')}"
|
77
|
+
end
|
78
|
+
@output.puts " end"
|
79
|
+
|
57
80
|
@output.puts "end"
|
58
81
|
|
59
82
|
@top[geometry.name || geometry.id] = geometry.id
|
@@ -67,8 +67,9 @@ module Collada
|
|
67
67
|
]
|
68
68
|
|
69
69
|
class Node
|
70
|
-
def initialize(id, type, transforms, instances, children, attributes = {})
|
70
|
+
def initialize(id, name, type, transforms, instances, children, attributes = {})
|
71
71
|
@id = id
|
72
|
+
@name = name
|
72
73
|
@type = type
|
73
74
|
|
74
75
|
@transforms = transforms
|
@@ -88,6 +89,7 @@ module Collada
|
|
88
89
|
attr :parent
|
89
90
|
|
90
91
|
attr :id
|
92
|
+
attr :name
|
91
93
|
attr :type
|
92
94
|
|
93
95
|
attr :transforms
|
@@ -158,13 +160,14 @@ module Collada
|
|
158
160
|
|
159
161
|
def self.parse(doc, element)
|
160
162
|
id = element.attributes['id']
|
163
|
+
name = element.attributes['name']
|
161
164
|
type = (element.attributes['type'] || 'node').downcase.to_sym
|
162
165
|
|
163
166
|
transforms = parse_transforms(doc, element)
|
164
167
|
instances = parse_instances(doc, element)
|
165
168
|
children = parse_children(doc, element)
|
166
169
|
|
167
|
-
self.new(id, type, transforms, instances, children, element.attributes)
|
170
|
+
self.new(id, name, type, transforms, instances, children, element.attributes)
|
168
171
|
end
|
169
172
|
end
|
170
173
|
|
data/lib/collada/transforms.rb
CHANGED
data/lib/collada/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collada
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|