mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-16 08:02:36 +00:00
PhysicsManager now has a job, CollisionManager enabled, using Player velocity instead of position for movement controls, added Entity drag, added spaces
This commit is contained in:
@@ -6,9 +6,11 @@ class IMICFPS
|
||||
include OpenGL
|
||||
include GLU
|
||||
include CommonMethods
|
||||
|
||||
attr_accessor :scale, :visible, :renderable, :backface_culling
|
||||
attr_accessor :position, :rotation, :velocity
|
||||
attr_reader :model, :name, :debug_color, :bounding_box, :collision
|
||||
attr_reader :model, :name, :debug_color, :bounding_box, :collision, :physics, :mass, :drag
|
||||
|
||||
def initialize(x: 0, y: 0, z: 0, bound_model: nil, scale: MODEL_METER_SCALE, backface_culling: true, auto_manage: true, manifest_file: nil)
|
||||
@position = Vector.new(x, y, z)
|
||||
@scale = scale
|
||||
@@ -18,11 +20,15 @@ class IMICFPS
|
||||
@renderable = true
|
||||
@rotation = Vector.new(0, 0, 0)
|
||||
@velocity = Vector.new(0, 0, 0)
|
||||
@drag = 0.94
|
||||
|
||||
@debug_color = Color.new(0.0, 1.0, 0.0)
|
||||
|
||||
@collidable = [:static, :dynamic]
|
||||
@collision = :static # :dynamic => moves in response, :static => does not move ever, :none => no collision check, entities can pass through
|
||||
# :dynamic => moves in response,
|
||||
# :static => does not move ever,
|
||||
# :none => no collision check, entities can pass through
|
||||
@collision = :static
|
||||
@physics = false # Entity affected by gravity and what not
|
||||
@mass = 100 # kg
|
||||
|
||||
@@ -33,7 +39,7 @@ class IMICFPS
|
||||
|
||||
if @bound_model
|
||||
@bound_model.model.entity = self
|
||||
@bound_model.model.objects.each {|o| o.scale = self.scale}
|
||||
@bound_model.model.objects.each { |o| o.scale = self.scale }
|
||||
@normalized_bounding_box = normalize_bounding_box_with_offset
|
||||
|
||||
box = normalize_bounding_box
|
||||
@@ -52,7 +58,7 @@ class IMICFPS
|
||||
raise "model isn't a model!" unless model.is_a?(ModelLoader)
|
||||
@bound_model = model
|
||||
@bound_model.model.entity = self
|
||||
@bound_model.model.objects.each {|o| o.scale = self.scale}
|
||||
@bound_model.model.objects.each { |o| o.scale = self.scale }
|
||||
@bounding_box = normalize_bounding_box_with_offset
|
||||
|
||||
# box = normalize_bounding_box
|
||||
@@ -91,10 +97,6 @@ class IMICFPS
|
||||
@position == @last_position
|
||||
end
|
||||
|
||||
def distance(vertex, other)
|
||||
return Math.sqrt((vertex.x-other.x)**2 + (vertex.y-other.y)**2 + (vertex.z-other.z)**2)
|
||||
end
|
||||
|
||||
def normalize_bounding_box_with_offset
|
||||
@bound_model.model.bounding_box.normalize_with_offset(self)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user