Removed WaveFont Model Object's knowledge of parenthood.

This commit is contained in:
2018-12-10 10:00:04 -06:00
parent 3ed09dd930
commit a7755dfbdf
3 changed files with 12 additions and 27 deletions

View File

@@ -27,7 +27,7 @@ class IMICFPS
if @bound_model
@bound_model.model.game_object = self
@bound_model.model.objects.each {|o| o.parent = self}
@bound_model.model.objects.each {|o| o.scale = self.scale}
box = normalize_bounding_box(@bound_model.model.bounding_box)
@width = box.max_x-box.min_x
@@ -42,7 +42,7 @@ class IMICFPS
raise "model isn't a model!" unless model.is_a?(ModelLoader)
@bound_model = model
@bound_model.model.game_object = self
@bound_model.model.objects.each {|o| o.parent = self}
@bound_model.model.objects.each {|o| o.scale = self.scale}
box = normalize_bounding_box(@bound_model.model.bounding_box)
@width = box.max_x-box.min_x
@height = box.max_y-box.min_y

View File

@@ -1,11 +1,10 @@
class IMICFPS
class Wavefront
class Object
attr_reader :parent, :name, :vertices, :textures, :normals, :bounding_box, :debug_color
attr_accessor :faces
attr_reader :name, :vertices, :textures, :normals, :bounding_box, :debug_color
attr_accessor :faces, :scale
def initialize(parent, name)
@parent = parent
def initialize(name)
@name = name
@vertices = []
@textures = []
@@ -13,7 +12,8 @@ class IMICFPS
@faces = []
@bounding_box = BoundingBox.new(0,0,0, 0,0,0)
@debug_color = Color.new(1.0,1.0,1.0)
@x,@y,@z = 0,0,0
@scale = 1.0
# Faces array packs everything:
# vertex = index[0]
@@ -22,10 +22,6 @@ class IMICFPS
# material = index[3]
end
def parent=(game_object)
@parent = game_object
end
def reflatten
@vertices_list = nil
@textures_list = nil
@@ -36,28 +32,17 @@ class IMICFPS
flattened_normals
end
def at_same_position?
if @x == @parent.x
if @y == @parent.y
if @z == @parent.z
true
end
end
end
end
def flattened_vertices
unless @vertices_list && at_same_position?
unless @vertices_list
@debug_color = @faces.first[3].diffuse
@x,@y,@z = @parent.x,@parent.y,@parent.z
list = []
@faces.each do |face|
[face[0]].each do |v|
next unless v
list << v.x*@parent.scale#+@parent.x
list << v.y*@parent.scale#+@parent.y
list << v.z*@parent.scale#+@parent.z
list << v.x*@scale
list << v.y*@scale
list << v.z*@scale
list << v.weight
end
end

View File

@@ -84,7 +84,7 @@ class IMICFPS
end
def change_object(name)
@objects << Object.new(self, name)
@objects << Object.new(name)
@current_object = @objects.last
end