added width,height and depth vars to GameObjects, randomly position 25 trees about the terrain.

This commit is contained in:
2018-07-01 16:32:10 -05:00
parent 1eea3c92cb
commit 5fa2843de2
5 changed files with 33 additions and 17 deletions

View File

@@ -8,8 +8,8 @@ class IMICFPS
attr_accessor :x, :y, :z, :scale
attr_accessor :visible, :renderable, :backface_culling
attr_accessor :x_rotation, :y_rotation, :z_rotation
attr_reader :model, :name, :debug_color
def initialize(x: 0, y: 0, z: 0, bound_model: nil, scale: MODEL_METER_SCALE, backface_culling: true, auto_manage: true)
attr_reader :model, :name, :debug_color, :terrain, :width, :height, :depth
def initialize(x: 0, y: 0, z: 0, bound_model: nil, scale: MODEL_METER_SCALE, backface_culling: true, auto_manage: true, terrain: nil)
@x,@y,@z,@scale = x,y,z,scale
@bound_model = bound_model
@backface_culling = backface_culling
@@ -17,16 +17,29 @@ class IMICFPS
@renderable = true
@x_rotation,@y_rotation,@z_rotation = 0,0,0
@debug_color = Color.new(0.0, 1.0, 0.0)
@terrain = terrain
@width, @height, @depth = 0,0,0
ObjectManager.add_object(self) if auto_manage
setup
if @bound_model
box = normalize_bounding_box(@bound_model.model.bounding_box)
@width = box.max_x-box.min_x
@height = box.max_y-box.min_y
@depth = box.max_z-box.min_z
end
return self
end
def bind_model(model)
raise "model isn't a model!" unless model.is_a?(ModelLoader)
@bound_model = model
box = normalize_bounding_box(@bound_model.model.bounding_box)
@width = box.max_x-box.min_x
@height = box.max_y-box.min_y
@depth = box.max_z-box.min_z
end
def model