Mesh and Material, loaded from the assets folder by defaultInstances can be created at any time and must be loaded after or at the end of create_scene.
If loading fails, the model is replaced by placeholder_model.
import gamnit::depth
var model = new Model("path/in/assets.obj")
model.load
The most simple model is LeafModel, composed of a single Mesh and Material.
It can be easily created programmatically to display simple geometries.
Whereas CompositeModel is composed of one or many LeafModel and is usually
loaded from the assets folder as a ModelAsset.
Instances of ModelAsset must be in the format OBJ and MAT,
and their texture in PNG or JPG.
gamnit :: Model :: _dimensions
Dimensions of the bounding box containing all verticesgamnit :: Model :: _named_parts
Sub-models with names, usually declared in the asset filegamnit :: Model :: defaultinit
gamnit :: Model :: dimensions
Dimensions of the bounding box containing all verticesgamnit :: Model :: dimensions=
Dimensions of the bounding box containing all verticesgamnit :: Model :: named_parts
Sub-models with names, usually declared in the asset filegamnit :: Model :: named_parts=
Sub-models with names, usually declared in the asset filegamnit :: Model :: _dimensions
Dimensions of the bounding box containing all verticesgamnit :: Model :: _named_parts
Sub-models with names, usually declared in the asset filecore :: Object :: class_factory
Implementation used byget_class to create the specific class.
gamnit :: Model :: defaultinit
core :: Object :: defaultinit
gamnit :: Model :: dimensions
Dimensions of the bounding box containing all verticesgamnit :: Model :: dimensions=
Dimensions of the bounding box containing all verticescore :: Object :: is_same_instance
Return true ifself and other are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself the same as other in a serialization context?
core :: Object :: is_same_type
Return true ifself and other have the same dynamic type.
gamnit :: Model :: named_parts
Sub-models with names, usually declared in the asset filegamnit :: Model :: named_parts=
Sub-models with names, usually declared in the asset filecore :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).
# 3D model composed of `Mesh` and `Material`, loaded from the assets folder by default
#
# Instances can be created at any time and must be loaded after or at the end of `create_scene`.
# If loading fails, the model is replaced by `placeholder_model`.
#
# ~~~
# import gamnit::depth
#
# var model = new Model("path/in/assets.obj")
# model.load
# ~~~
#
# The most simple model is `LeafModel`, composed of a single `Mesh` and `Material`.
# It can be easily created programmatically to display simple geometries.
# Whereas `CompositeModel` is composed of one or many `LeafModel` and is usually
# loaded from the assets folder as a `ModelAsset`.
# Instances of `ModelAsset` must be in the format OBJ and MAT,
# and their texture in PNG or JPG.
abstract class Model
# Load this model in memory
fun load do end
# Errors raised at loading
var errors = new Array[Error]
# All `LeafModel` composing this model
#
# Usually, there is one `LeafModel` per material.
# At each frame, each material is asked to draw all the live `LeafModel` instaces.
fun leaves: Array[LeafModel] is abstract
# Sub-models with names, usually declared in the asset file
var named_parts = new Map[Text, Model]
end
lib/gamnit/depth/depth_core.nit:85,1--119,3
redef class Model
# Dimensions of the bounding box containing all vertices
var dimensions = new Point3d[Float](max.x-min.x, max.y-min.y, max.z-min.z) is lazy, writable
# Center coordinates of all the vertices
var center = new Point3d[Float]((min.x+max.x)/2.0, (min.y+max.y)/2.0, (min.z+max.z)/2.0) is lazy, writable
# Minimum coordinates of all vertices on each axes
#
# This is a corner of the bounding box.
var min: Point3d[Float] is lazy do
var mx = inf
var my = inf
var mz = inf
for leaf in leaves do
var lm = leaf.mesh.min
mx = mx.min(lm.x)
my = my.min(lm.y)
mz = mz.min(lm.z)
end
return new Point3d[Float](mx, my, mz)
end
# Maximum coordinates of all vertices on each axes
#
# This is a corner of the bounding box.
var max: Point3d[Float] is lazy do
var mx = -inf
var my = -inf
var mz = -inf
for leaf in leaves do
var lm = leaf.mesh.max
mx = mx.max(lm.x)
my = my.max(lm.y)
mz = mz.max(lm.z)
end
return new Point3d[Float](mx, my, mz)
end
end
lib/gamnit/depth/model_dimensions.nit:20,1--59,3