obj_parser 0.0.7 → 0.0.8

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.
@@ -7,12 +7,15 @@ module ObjParser
7
7
 
8
8
  attr_accessor :normals
9
9
  attr_accessor :textures
10
+ attr_accessor :tangents
11
+
10
12
  attr_accessor :flag
11
13
 
12
14
  def initialize(point_data = [0, 0, 0])
13
15
  self.data = point_data.map(&:to_f)
14
16
  self.textures = []
15
17
  self.normals = []
18
+ self.tangents = []
16
19
  end
17
20
 
18
21
  def tangent
@@ -28,12 +28,13 @@ module ObjParser
28
28
  vertex = self.detailed_vertice[vertex_index]
29
29
  normal = vertex.normals.select{|n| n == self.normals[self.normals_indexes[index]] }.first
30
30
  texture = vertex.textures.select{|n| n == self.textures[self.textures_indexes[index]] }.first
31
+ tangent = vertex.tangents.select{|n| n == self.tangents[self.tangents_indexes[index]] }.first
31
32
  if(point_used_for_vertex_at_index?(normal, vertex_index) && point_used_for_vertex_at_index?(texture, vertex_index))
32
33
  candids = texture.flag[vertex_index] & normal.flag[vertex_index]
33
34
  vec_indexes << candids.first
34
35
  else
35
36
  temp_vertice << vertex
36
- temp_tangents << vertex.tangent if vertex.tangent
37
+ temp_tangents << tangent if tangent
37
38
  vec_indexes << temp_vertice.count - 1
38
39
  if(normal)
39
40
  temp_normals << normal
@@ -1,3 +1,3 @@
1
1
  module ObjParser
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -11,7 +11,7 @@ describe ObjParser::ObjParser do
11
11
  obj.textures.count.must_equal(4)
12
12
  obj.vertice_indexes.count.must_equal(36)
13
13
  obj.normals_indexes.count.must_equal(36)
14
- obj.textures_indexes.count.must_equal(36)
14
+ obj.textures_indexes.count.must_equal(36)
15
15
  end
16
16
 
17
17
  private
@@ -8,6 +8,9 @@ describe ObjParser::SingleIndexedObj do
8
8
  @obj.vertice_indexes = [0, 1, 2, 0, 2, 3]
9
9
  @obj.normals = [p([1.0,0.0,0.0]), p([0.0,1.0,0.0])]
10
10
  @obj.normals_indexes = [1, 0, 1, 1, 0, 0]
11
+ @obj.textures = [p([1.0,0.0,0.0]), p([0.0,1.0,0.0])]
12
+ @obj.textures_indexes = [1, 0, 1, 1, 0, 0]
13
+ @obj.compute_tangents
11
14
  @single_indexed_obj = ObjParser::SingleIndexedObj.build_with_obj(@obj)
12
15
  end
13
16
 
@@ -33,7 +36,7 @@ describe ObjParser::SingleIndexedObj do
33
36
  it 'reorganize normals, textures, ... based on vertices indexes' do
34
37
  @single_indexed_obj.normals.count.must_equal(@obj.vertice_indexes.uniq.count)
35
38
  @single_indexed_obj.normals.map(&:data).must_equal(
36
- [p([0.0,1.0,0.0]), p([1.0,0.0,0.0]), p([0.0,1.0,0.0]), p([0.0,1.0,0.0]), p([1.0,0.0,0.0]), p([1.0,0.0,0.0])].map(&:data))
39
+ [p([0.0,1.0,0.0]), p([1.0,0.0,0.0]), p([0.0,1.0,0.0]), p([1.0,0.0,0.0]), p([1.0,0.0,0.0])].map(&:data))
37
40
  end
38
41
 
39
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obj_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-24 00:00:00.000000000 Z
12
+ date: 2014-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler