diff --git a/i-mic-fps.rb b/i-mic-fps.rb index 92c2ec2..dc080d2 100644 --- a/i-mic-fps.rb +++ b/i-mic-fps.rb @@ -62,7 +62,7 @@ $debug = ARGV.join.include?("--debug") ? true : false require_relative "lib/common_methods" -require_relative "lib/math/vertex" +require_relative "lib/math/vector" require_relative "lib/trees/aabb_tree" require_relative "lib/managers/input_mapper" diff --git a/lib/math/vector.rb b/lib/math/vector.rb new file mode 100644 index 0000000..8b7c184 --- /dev/null +++ b/lib/math/vector.rb @@ -0,0 +1,52 @@ +class IMICFPS + class Vector + + attr_accessor :x, :y, :z, :weight + def initialize(x = 0, y = 0, z = 0, weight = 0) + @x, @y, @z, @weight = x, y, z, weight + end + + def ==(other) + @x == other.x && + @y == other.y && + @z == other.z && + @weight == other.weight + end + + def +(other) + @x += other.x + @y += other.y + @z += other.z + @weight += other.weight + end + + def -(other) + @x -= other.x + @y -= other.y + @z -= other.z + @weight -= other.weight + end + + def *(other) + @x *= other.x + @y *= other.y + @z *= other.z + @weight *= other.weight + end + + def /(other) + @x /= other.x + @y /= other.y + @z /= other.z + @weight /= other.weight + end + + def to_a + [@x, @y, @z, @weight] + end + + def to_s + "X: #{@x}, Y: #{@y}, Z: #{@z}, Weight: #{@weight}" + end + end +end \ No newline at end of file diff --git a/lib/math/vertex.rb b/lib/math/vertex.rb deleted file mode 100644 index 8463a06..0000000 --- a/lib/math/vertex.rb +++ /dev/null @@ -1,3 +0,0 @@ -class IMICFPS - Vector = Struct.new(:x, :y, :z, :weight) -end \ No newline at end of file diff --git a/lib/objects/entities/camera.rb b/lib/objects/entities/camera.rb index e415c5b..e896718 100644 --- a/lib/objects/entities/camera.rb +++ b/lib/objects/entities/camera.rb @@ -94,8 +94,8 @@ class IMICFPS # if $debug && @entity # glBegin(GL_LINES) # glColor3f(1,0,0) - # glVector3f(@x, @y, @z) - # glVector3f(@entity.x, @entity.y, @entity.z) + # glVertex3f(@x, @y, @z) + # glVertex3f(@entity.x, @entity.y, @entity.z) # glEnd # end end diff --git a/lib/renderer/bounding_box_renderer.rb b/lib/renderer/bounding_box_renderer.rb index 375ffc3..e97f6a1 100644 --- a/lib/renderer/bounding_box_renderer.rb +++ b/lib/renderer/bounding_box_renderer.rb @@ -211,7 +211,7 @@ class IMICFPS @bounding_boxes.each do |key, bounding_box| glPushMatrix - glTranslatef(bounding_box[:object].x, bounding_box[:object].y, bounding_box[:object].z) + glTranslatef(bounding_box[:object].position.x, bounding_box[:object].position.y, bounding_box[:object].position.z) draw_bounding_box(bounding_box) @bounding_boxes[key][:objects].each {|o| draw_bounding_box(o)} diff --git a/lib/wavefront/model.rb b/lib/wavefront/model.rb index 33caccb..a2b8b5f 100644 --- a/lib/wavefront/model.rb +++ b/lib/wavefront/model.rb @@ -64,7 +64,7 @@ class IMICFPS # Allocate arrays for future use @vertex_array_id = nil buffer = " " * 4 - glGenVectorArrays(1, buffer) + glGenVertexArrays(1, buffer) @vertex_array_id = buffer.unpack('L2').first # Allocate buffers for future use @@ -101,9 +101,9 @@ class IMICFPS end def populate_arrays - glBindVectorArray(@vertex_array_id) + glBindVertexArray(@vertex_array_id) glBindBuffer(GL_ARRAY_BUFFER, @vertices_buffer) - glBindVectorArray(0) + glBindVertexArray(0) glBindBuffer(GL_ARRAY_BUFFER, 0) end