mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
Refactored GameObject to Entity, replaced @x,@y,@z with @position, added @velocity vector to Entity, bricked Player terrain interaction while authoring Axis Aligned Bounding Box Tree for CollisionManager to handle all collision interaction. Added PhysicsManager stub.
This commit is contained in:
@@ -11,16 +11,16 @@ class IMICFPS
|
||||
include Parser
|
||||
|
||||
attr_accessor :objects, :materials, :vertices, :texures, :normals, :faces
|
||||
attr_accessor :x, :y, :z, :scale, :game_object
|
||||
attr_reader :bounding_box, :model_has_texture, :textured_material
|
||||
attr_accessor :scale, :entity
|
||||
attr_reader :position, :bounding_box, :model_has_texture, :textured_material
|
||||
|
||||
attr_reader :normals_buffer, :uvs_buffer, :vertices_buffer
|
||||
attr_reader :vertices_buffer_data, :uvs_buffer_data, :normals_buffer_data
|
||||
attr_reader :vertex_array_id
|
||||
|
||||
def initialize(file_path:, game_object: nil)
|
||||
@game_object = game_object
|
||||
update if @game_object
|
||||
def initialize(file_path:, entity: nil)
|
||||
@entity = entity
|
||||
update if @entity
|
||||
@file_path = file_path
|
||||
@file = File.open(file_path, 'r')
|
||||
@material_file = nil
|
||||
@@ -64,7 +64,7 @@ class IMICFPS
|
||||
# Allocate arrays for future use
|
||||
@vertex_array_id = nil
|
||||
buffer = " " * 4
|
||||
glGenVertexArrays(1, buffer)
|
||||
glGenVectorArrays(1, buffer)
|
||||
@vertex_array_id = buffer.unpack('L2').first
|
||||
|
||||
# Allocate buffers for future use
|
||||
@@ -101,17 +101,17 @@ class IMICFPS
|
||||
end
|
||||
|
||||
def populate_arrays
|
||||
glBindVertexArray(@vertex_array_id)
|
||||
glBindVectorArray(@vertex_array_id)
|
||||
glBindBuffer(GL_ARRAY_BUFFER, @vertices_buffer)
|
||||
glBindVertexArray(0)
|
||||
glBindVectorArray(0)
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0)
|
||||
end
|
||||
|
||||
def update
|
||||
@x, @y, @z = @game_object.x, @game_object.y, @game_object.z
|
||||
@scale = @game_object.scale
|
||||
# if @scale != @game_object.scale
|
||||
# puts "oops for #{self}: #{@scale} != #{@game_object.scale}"
|
||||
@position = @entity.position
|
||||
@scale = @entity.scale
|
||||
# if @scale != @entity.scale
|
||||
# puts "oops for #{self}: #{@scale} != #{@entity.scale}"
|
||||
# self.objects.each(&:reflatten) if self.objects && self.objects.count > 0
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -114,9 +114,9 @@ class IMICFPS
|
||||
@vertex_count+=1
|
||||
vert = nil
|
||||
if array.size == 5
|
||||
vert = Vertex.new(Float(array[1]), Float(array[2]), Float(array[3]), Float(array[4]))
|
||||
vert = Vector.new(Float(array[1]), Float(array[2]), Float(array[3]), Float(array[4]))
|
||||
elsif array.size == 4
|
||||
vert = Vertex.new(Float(array[1]), Float(array[2]), Float(array[3]), 1.0)
|
||||
vert = Vector.new(Float(array[1]), Float(array[2]), Float(array[3]), 1.0)
|
||||
else
|
||||
raise
|
||||
end
|
||||
@@ -127,9 +127,9 @@ class IMICFPS
|
||||
def add_normal(array)
|
||||
vert = nil
|
||||
if array.size == 5
|
||||
vert = Vertex.new(Float(array[1]), Float(array[2]), Float(array[3]), Float(array[4]))
|
||||
vert = Vector.new(Float(array[1]), Float(array[2]), Float(array[3]), Float(array[4]))
|
||||
elsif array.size == 4
|
||||
vert = Vertex.new(Float(array[1]), Float(array[2]), Float(array[3]), 1.0)
|
||||
vert = Vector.new(Float(array[1]), Float(array[2]), Float(array[3]), 1.0)
|
||||
else
|
||||
raise
|
||||
end
|
||||
@@ -140,9 +140,9 @@ class IMICFPS
|
||||
def add_texture_coordinate(array)
|
||||
texture = nil
|
||||
if array.size == 4
|
||||
texture = Vertex.new(Float(array[1]), 1-Float(array[2]), Float(array[3]))
|
||||
texture = Vector.new(Float(array[1]), 1-Float(array[2]), Float(array[3]))
|
||||
elsif array.size == 3
|
||||
texture = Vertex.new(Float(array[1]), 1-Float(array[2]), 1.0)
|
||||
texture = Vector.new(Float(array[1]), 1-Float(array[2]), 1.0)
|
||||
else
|
||||
raise
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user