Added Alternate Tank, go back to using glScalef for scaling models until shader based rendering is implemented, improved Map handling of scaling.

This commit is contained in:
2019-09-25 20:59:19 -05:00
parent ecee086590
commit 19f5a0cd9c
11 changed files with 2567 additions and 5 deletions

View File

@@ -0,0 +1,2 @@
name: "Alternate Tank"
model: "alternate_tank.obj"

View File

@@ -0,0 +1,42 @@
# Blender MTL File: 'alternate_tank.blend'
# Material Count: 4
newmtl Body
Ns 110.250015
Ka 0.900000 0.900000 0.900000
Kd 0.029064 0.018578 0.011797
Ks 0.883333 0.883333 0.883333
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 3
newmtl Material
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.527719 0.213857 0.101860
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl Material.001
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.029064 0.018578 0.011797
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
newmtl wheel
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.044455 0.044455 0.044455
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2

File diff suppressed because it is too large Load Diff

View File

@@ -2,3 +2,10 @@ name: "power_plant"
model: "power_plant.obj"
collision: "mesh"
collision_mesh: null # Use model mesh for collision detection
uses:
-
package: "base"
model: "purchase_terminal"
-
package: "base"
model: "information_panel"

BIN
blends/alternate_tank.blend Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -9,11 +9,11 @@ class IMICFPS
attr_accessor :position, :orientation, :velocity
attr_reader :name, :debug_color, :bounding_box, :collision, :physics, :mass, :drag, :camera
def initialize(manifest:, map_entity: nil, spawnpoint: nil, backface_culling: false, auto_manage: true)
def initialize(manifest:, map_entity: nil, spawnpoint: nil, backface_culling: true, auto_manage: true)
@manifest = manifest
@position = map_entity ? map_entity.position.clone : spawnpoint.position.clone
@orientation = map_entity ? map_entity.orientation.clone : spawnpoint.orientation.clone
@scale = map_entity ? map_entity.scale : 1.0
@scale = map_entity ? map_entity.scale.clone : Vector.new(1, 1, 1)
@backface_culling = backface_culling
@name = @manifest.name

View File

@@ -8,6 +8,8 @@ class IMICFPS
manifest_file = "#{IMICFPS.assets_path}/#{package}/#{model}/manifest.yaml"
end
raise "No manifest found at: #{manifest_file}" unless File.exist?(manifest_file)
@file = manifest_file
parse(manifest_file)
end

View File

@@ -34,7 +34,20 @@ class IMICFPS
@terrain.model = section["model"]
@terrain.position = Vector.new
@terrain.orientation = Vector.new
@terrain.scale = 1.0
if section["scale"]
if section["scale"].is_a?(Hash)
@terrain.scale = Vector.new(
section["scale"]["x"],
section["scale"]["y"],
section["scale"]["z"]
)
else
scale = Float(section["scale"])
@terrain.scale = Vector.new(scale, scale, scale)
end
else
@terrain.scale = Vector.new(1, 1, 1)
end
@terrain.water_level = section["water_level"]
else
raise "Map terrain data is missing!"
@@ -45,7 +58,20 @@ class IMICFPS
@skydome.model = section["model"]
@skydome.position = Vector.new
@skydome.orientation = Vector.new
@skydome.scale = section["scale"] ? section["scale"] : 1.0
if section["scale"]
if section["scale"].is_a?(Hash)
@skydome.scale = Vector.new(
section["scale"]["x"],
section["scale"]["y"],
section["scale"]["z"]
)
else
scale = Float(section["scale"])
@skydome.scale = Vector.new(scale, scale, scale)
end
else
@skydome.scale = Vector.new(1, 1, 1)
end
else
raise "Map skydome data is missing!"
end
@@ -65,7 +91,16 @@ class IMICFPS
ent["orientation"]["y"],
ent["orientation"]["z"]
)
entity.scale = ent["scale"]
if ent["scale"].is_a?(Hash)
entity.scale = Vector.new(
ent["scale"]["x"],
ent["scale"]["y"],
ent["scale"]["z"]
)
else
scale = Float(ent["scale"])
entity.scale = Vector.new(scale, scale, scale)
end
entity.scripts = ent["scripts"]
@entities << entity

View File

@@ -9,6 +9,7 @@ class IMICFPS
glPushMatrix
glTranslatef(object.position.x, object.position.y, object.position.z)
glScalef(object.scale.x, object.scale.y, object.scale.z)
glRotatef(object.orientation.x, 1.0, 0, 0)
glRotatef(object.orientation.y, 0, 1.0, 0)
glRotatef(object.orientation.z, 0, 0, 1.0)

View File

@@ -164,6 +164,22 @@
},
"scale": 1,
"scripts": []
},
{
"package":"base",
"model":"alternate_tank",
"position": {
"x":39.3939,
"y":0.799657,
"z":20.69697
},
"orientation": {
"x": 0,
"y": 0,
"z": 0
},
"scale": 1.0,
"scripts": []
}
],