geo3d 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +24 -1
- data/geo3d.gemspec +0 -1
- data/lib/geo3d/matrix.rb +4 -5
- data/lib/geo3d/triangle.rb +0 -31
- data/lib/geo3d/version.rb +1 -1
- data/spec/opengl/matrix_spec.rb +11 -2
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dce039052c8be50a88c59d44885cc4673bb9995
|
4
|
+
data.tar.gz: 8c8e0c900000eff135456ec98ff9360d50d39c31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebf820b44fea39262570b2345e6cabc0ba21ce0bf2e0a7be420a4873afb850d76b30611a8ccee5ec8b05d8dac9428aa46e69fd8b784519ef80a0a89f7f1d314b
|
7
|
+
data.tar.gz: efc8897b94f0f45ae833ac230f86dcb6ad1ca83f7254b877fc04817ea27cac6b667c26e9cb82963c1da2631bcac93e2f8c09b0243c54e61c61581cfdbfdd6c3a
|
data/README.md
CHANGED
@@ -219,6 +219,10 @@ Normalize
|
|
219
219
|
plane.normalize #returns a normalized version of the plane
|
220
220
|
plane.normalize! #normalizes the plane in place
|
221
221
|
```
|
222
|
+
Normal
|
223
|
+
```
|
224
|
+
plane.normal #returns the normal of the plane
|
225
|
+
```
|
222
226
|
Line intersection
|
223
227
|
```
|
224
228
|
plane.line_intersection line_start, line_end #returns the intersection of the line onto the plane
|
@@ -312,8 +316,27 @@ Constructors
|
|
312
316
|
Geo3d::Triangle.from_axis rotation_axis, radians #returns a quaternion from an axis and angle
|
313
317
|
Geo3d::Quaternion.from_matrix m #returns a quaternion from a rotation matrix
|
314
318
|
Geo3d::Quaternion.identity #returns the identity quaternion
|
315
|
-
|
316
319
|
```
|
320
|
+
Normal
|
321
|
+
```
|
322
|
+
triangle.normal #returns the normal of the plane
|
323
|
+
```
|
324
|
+
Winding
|
325
|
+
```
|
326
|
+
triangle.clockwise? #is the triangle winded clockwise?
|
327
|
+
triangle.counter_clockwise? #is the triangle winded counter clockwise?
|
328
|
+
```
|
329
|
+
Flipping
|
330
|
+
```
|
331
|
+
triangle.flip #returns a flipped version of the triangle (reverses the winding)
|
332
|
+
triangle.flip! #flips the triangle in place
|
333
|
+
```
|
334
|
+
signed area
|
335
|
+
```
|
336
|
+
triangle.signed_area
|
337
|
+
```
|
338
|
+
|
339
|
+
|
317
340
|
|
318
341
|
|
319
342
|
|
data/geo3d.gemspec
CHANGED
@@ -21,6 +21,5 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
|
-
spec.add_development_dependency "misha-ruby-sdl-ffi"
|
25
24
|
spec.add_development_dependency "ruby-opengl"
|
26
25
|
end
|
data/lib/geo3d/matrix.rb
CHANGED
@@ -455,21 +455,21 @@ module Geo3d
|
|
455
455
|
self.gl_frustum -range*aspect, range*aspect, -range, range, zn, zf
|
456
456
|
end
|
457
457
|
|
458
|
-
def self.gl_frustum l, r,
|
458
|
+
def self.gl_frustum l, r, bottom, t, zn, zf
|
459
459
|
l = l.to_f
|
460
460
|
r = r.to_f
|
461
|
-
|
461
|
+
bottom = bottom.to_f
|
462
462
|
t = t.to_f
|
463
463
|
zn = zn.to_f
|
464
464
|
zf = zf.to_f
|
465
465
|
a = (r+l) / (r-l)
|
466
|
-
b = (t+
|
466
|
+
b = (t+bottom) / (t-bottom)
|
467
467
|
c = -(zf + zn) / (zf - zn)
|
468
468
|
d = -(2 * zf * zn) / (zf - zn)
|
469
469
|
matrix = self.new
|
470
470
|
matrix._11 = 2.0 * zn / (r-l)
|
471
471
|
matrix._31 = a
|
472
|
-
matrix._22 = zn / (t-
|
472
|
+
matrix._22 = 2.0 * zn / (t-bottom)
|
473
473
|
matrix._32 = b
|
474
474
|
matrix._33 = c
|
475
475
|
matrix._43 = d
|
@@ -478,7 +478,6 @@ module Geo3d
|
|
478
478
|
end
|
479
479
|
|
480
480
|
|
481
|
-
|
482
481
|
def self.perspective_fov_rh fovy, aspect, zn, zf
|
483
482
|
fovy = fovy.to_f
|
484
483
|
aspect = aspect.to_f
|
data/lib/geo3d/triangle.rb
CHANGED
@@ -26,37 +26,6 @@ module Geo3d
|
|
26
26
|
(b - a).cross(c - a).normalize
|
27
27
|
end
|
28
28
|
|
29
|
-
=begin this needs to be done at a mesh level
|
30
|
-
def tangent_and_bitangent
|
31
|
-
return [nil, nil] unless @a.kind_of?(TexturedVertex) && @b.kind_of?(TexturedVertex) && @c.kind_of?(TexturedVertex)
|
32
|
-
|
33
|
-
v1 = @a
|
34
|
-
v2 = @b
|
35
|
-
v3 = @c
|
36
|
-
|
37
|
-
w1 = @a.texcoord
|
38
|
-
w2 = @b.texcoord
|
39
|
-
w3 = @c.texcoord
|
40
|
-
|
41
|
-
x1 = v2.x - v1.x
|
42
|
-
x2 = v3.x - v1.x
|
43
|
-
y1 = v2.y - v1.y
|
44
|
-
y2 = v3.y - v1.y
|
45
|
-
z1 = v2.z - v1.z
|
46
|
-
z2 = v3.z - v1.z
|
47
|
-
|
48
|
-
s1 = w2.x - w1.x
|
49
|
-
s2 = w3.x - w1.x
|
50
|
-
t1 = w2.y - w1.y
|
51
|
-
t2 = w3.y - w1.y
|
52
|
-
|
53
|
-
r = 1.0 / (s1 * t2 - s2 * t1)
|
54
|
-
tangent += Geo3d::Vector.new (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r
|
55
|
-
bitangent += Geo3d::Vector.new (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r
|
56
|
-
|
57
|
-
end
|
58
|
-
=end
|
59
|
-
|
60
29
|
def signed_area reference_normal = Vector.new(0,0,-1)
|
61
30
|
sum = Vector.new 0, 0, 0, 0
|
62
31
|
points.each_with_index do |current_point, i|
|
data/lib/geo3d/version.rb
CHANGED
data/spec/opengl/matrix_spec.rb
CHANGED
@@ -3,9 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe Geo3d::Matrix do
|
4
4
|
before :each do
|
5
5
|
@gl_initialized = false
|
6
|
-
require "ruby-sdl-ffi"
|
6
|
+
#require "ruby-sdl-ffi"
|
7
7
|
require "opengl"
|
8
|
+
include Gl,Glu,Glut
|
8
9
|
|
10
|
+
glutInit
|
11
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
12
|
+
glutInitWindowSize(500, 500)
|
13
|
+
glutInitWindowPosition(100, 100)
|
14
|
+
glutCreateWindow('test')
|
15
|
+
|
16
|
+
=begin
|
9
17
|
if SDL.Init(SDL::INIT_VIDEO) < 0
|
10
18
|
puts "not able to init"
|
11
19
|
else
|
@@ -22,7 +30,8 @@ describe Geo3d::Matrix do
|
|
22
30
|
@gl_initialized = true
|
23
31
|
end
|
24
32
|
end
|
25
|
-
|
33
|
+
=end
|
34
|
+
# raise "opengl not able to initialize" unless @gl_initialized
|
26
35
|
end
|
27
36
|
|
28
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo3d
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Misha Conway
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: misha-ruby-sdl-ffi
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: ruby-opengl
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|