gamnit :: ObjDef :: defaultinit
gamnit :: ObjDef :: material_libs
Relative paths to referenced material librariesgamnit :: ObjDef :: texture_coords=
Texture coordinatesgamnit :: ObjDef :: vertex_points=
Vertex coordinatescore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
gamnit :: ObjDef :: defaultinit
core :: 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 :: ObjDef :: material_libs
Relative paths to referenced material librariescore :: 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).gamnit :: ObjDef :: texture_coords=
Texture coordinatesgamnit :: ObjDef :: vertex_points=
Vertex coordinates
# Geometry from a .obj file
class ObjDef
# Vertex coordinates
var vertex_points = new Array[Vec4]
# Texture coordinates
var texture_coords = new Array[Vec3]
# Normals
var normals = new Array[Vec3]
# Surface parameters
var params = new Array[Vec3]
# Sub-objects
var objects = new Array[ObjObj]
# Relative paths to referenced material libraries
fun material_libs: Set[String] do
var libs = new Set[String]
for obj in objects do
for face in obj.faces do
var lib = face.material_lib
if lib != null then libs.add lib
end
end
return libs
end
# Check the coherence of the model
#
# Returns `false` on error and prints details to stderr.
#
# This service can be useful for debugging, however it should not
# be executed at each execution of a game.
fun is_coherent: Bool
do
for obj in objects do
for f in obj.faces do
if f.vertices.length < 3 then return error("Face with less than 3 vertices")
end
for f in obj.faces do for v in f.vertices do
var i = v.vertex_point_index
if i < 1 then return error("Vertex point index < 1")
if i > vertex_points.length then return error("Vertex point index > than length")
var j = v.texture_coord_index
if j != null then
if j < 1 then return error("Texture coord index < 1")
if j > texture_coords.length then return error("Texture coord index > than length")
end
j = v.normal_index
if j != null then
if j < 1 then return error("Normal index < 1")
if j > normals.length then return error("Normal index > than length")
end
end
end
return true
end
# Service to print errors for `is_coherent`
private fun error(msg: Text): Bool
do
print_error "ObjDef Error: {msg}"
return false
end
end
lib/gamnit/model_parsers/obj.nit:149,1--218,3