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:
2019-02-20 10:49:56 -06:00
parent df05ec5150
commit 7b903fbdb9
27 changed files with 288 additions and 385 deletions

View File

@@ -35,7 +35,7 @@ class IMICFPS
@bounding_boxes[mesh_object_id] = {}
@bounding_boxes[mesh_object_id] = {object: object, box: box, color: color, objects: []}
box = object.normalize_bounding_box(box)
box = object.normalize_bounding_box
normals = mesh_normals
colors = mesh_colors(color)
@@ -50,7 +50,7 @@ class IMICFPS
object.model.objects.each do |mesh|
data = {}
box = object.normalize_bounding_box(mesh.bounding_box)
box = object.normalize_bounding_box
normals = mesh_normals
colors = mesh_colors(mesh.debug_color)
@@ -217,7 +217,7 @@ class IMICFPS
glPopMatrix
found = @game_state.game_objects.detect { |o| o == bounding_box[:object] }
found = @game_state.entities.detect { |o| o == bounding_box[:object] }
unless found
@vertex_count -= @bounding_boxes[key][:vertices_size]

View File

@@ -20,10 +20,10 @@ class IMICFPS
glEnable(GL_NORMALIZE)
glPushMatrix
glTranslatef(object.x, object.y, object.z)
glRotatef(object.x_rotation,1.0, 0, 0)
glRotatef(object.y_rotation,0, 1.0, 0)
glRotatef(object.z_rotation,0, 0, 1.0)
glTranslatef(object.position.x, object.position.y, object.position.z)
glRotatef(object.rotation.x, 1.0, 0, 0)
glRotatef(object.rotation.y, 0, 1.0, 0)
glRotatef(object.rotation.z, 0, 0, 1.0)
handleGlError
@@ -48,7 +48,7 @@ class IMICFPS
def draw_mesh(model)
model.objects.each_with_index do |o, i|
glEnable(GL_CULL_FACE) if model.game_object.backface_culling
glEnable(GL_CULL_FACE) if model.entity.backface_culling
glEnable(GL_COLOR_MATERIAL)
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)
glShadeModel(GL_FLAT) unless o.faces.first[4]
@@ -100,7 +100,7 @@ class IMICFPS
# glBindTexture(GL_TEXTURE_2D, 0)
glDisable(GL_TEXTURE_2D)
end
glDisable(GL_CULL_FACE) if model.game_object.backface_culling
glDisable(GL_CULL_FACE) if model.entity.backface_culling
glDisable(GL_COLOR_MATERIAL)
end
end

View File

@@ -13,7 +13,7 @@ class IMICFPS
end
def draw
@game_state.game_objects.each do |object|
@game_state.entities.each do |object|
if object.visible && object.renderable
# Render bounding boxes before transformation is applied
@bounding_box_renderer.create_bounding_box(object, object.model.bounding_box, object.debug_color, object.object_id) if $debug

View File

@@ -54,7 +54,7 @@ class IMICFPS
log = ' ' * @error_buffer_size
glGetShaderInfoLog(@vertex, @error_buffer_size, nil, log)
puts "Shader Error: Program \"#{@name}\""
puts " Vertex Shader InfoLog:", " #{log.strip.split("\n").join("\n ")}\n\n"
puts " Vector Shader InfoLog:", " #{log.strip.split("\n").join("\n ")}\n\n"
puts " Shader Compiled status: #{compiled}"
puts " NOTE: assignment of uniforms in shaders is illegal!"
puts