nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gamnit: move `new SmoothMaterial::default` to `new Material`
[nit.git]
/
lib
/
gamnit
/
depth
/
more_models.nit
diff --git
a/lib/gamnit/depth/more_models.nit
b/lib/gamnit/depth/more_models.nit
index
a126223
..
8d7d8a1
100644
(file)
--- a/
lib/gamnit/depth/more_models.nit
+++ b/
lib/gamnit/depth/more_models.nit
@@
-50,7
+50,7
@@
class ModelAsset
if leaves.is_empty then
# Nothing was loaded, use a cube with the default material
if leaves.is_empty then
# Nothing was loaded, use a cube with the default material
- var leaf = new LeafModel(new Cube, new SmoothMaterial.default)
+ var leaf = placeholder_model
leaves.add leaf
end
end
leaves.add leaf
end
end
@@
-62,7
+62,7
@@
class ModelAsset
var content = text_asset.to_s
if content.is_empty then
print_error "Model failed to load: Asset empty at '{self.path}'"
var content = text_asset.to_s
if content.is_empty then
print_error "Model failed to load: Asset empty at '{self.path}'"
- leaves.add new LeafModel(new Cube, new SmoothMaterial.default)
+ leaves.add new LeafModel(new Cube, new Material)
return
end
return
end
@@
-71,7
+71,7
@@
class ModelAsset
var obj_def = parser.parse
if obj_def == null then
print_error "Model failed to load: .obj format error on '{self.path}'"
var obj_def = parser.parse
if obj_def == null then
print_error "Model failed to load: .obj format error on '{self.path}'"
- leaves.add new LeafModel(new Cube, new SmoothMaterial.default)
+ leaves.add new LeafModel(new Cube, new Material)
return
end
return
end
@@
-168,7
+168,7
@@
private class ModelFromObj
# Load textures need for these materials
for name in texture_names do
if not asset_textures_by_name.keys.has(name) then
# Load textures need for these materials
for name in texture_names do
if not asset_textures_by_name.keys.has(name) then
- var tex = new GamnitAssetTexture(name)
+ var tex = new TextureAsset(name)
asset_textures_by_name[name] = tex
end
end
asset_textures_by_name[name] = tex
end
end
@@
-212,7
+212,7
@@
private class ModelFromObj
# Create models and store them
for mesh, mtl_def in mesh_to_mtl do
var material = materials.get_or_null(mtl_def)
# Create models and store them
for mesh, mtl_def in mesh_to_mtl do
var material = materials.get_or_null(mtl_def)
- if material == null then material = new SmoothMaterial.default
+ if material == null then material = new Material
var model = new LeafModel(mesh, material)
array.add model
var model = new LeafModel(mesh, material)
array.add model
@@
-379,8
+379,13
@@
end
redef class Sys
# Textures loaded from .mtl files for models
redef class Sys
# Textures loaded from .mtl files for models
- var asset_textures_by_name = new Map[String, GamnitAssetTexture]
+ var asset_textures_by_name = new Map[String, TextureAsset]
# All instantiated asset models
var models = new Set[ModelAsset]
# All instantiated asset models
var models = new Set[ModelAsset]
+
+ # Blue cube of 1 unit on each side, acting as placeholder for models failing to load
+ #
+ # This model can be freely used by any `Actor` as placeholder or for debugging.
+ var placeholder_model = new LeafModel(new Cube, new Material) is lazy
end
end