Geometry from a .obj file

Introduced properties

fun is_coherent: Bool

gamnit :: ObjDef :: is_coherent

Check the coherence of the model
fun material_libs: Set[String]

gamnit :: ObjDef :: material_libs

Relative paths to referenced material libraries
fun normals: Array[Vec3]

gamnit :: ObjDef :: normals

Normals
protected fun normals=(normals: Array[Vec3])

gamnit :: ObjDef :: normals=

Normals
fun objects: Array[ObjObj]

gamnit :: ObjDef :: objects

Sub-objects
protected fun objects=(objects: Array[ObjObj])

gamnit :: ObjDef :: objects=

Sub-objects
fun params: Array[Vec3]

gamnit :: ObjDef :: params

Surface parameters
protected fun params=(params: Array[Vec3])

gamnit :: ObjDef :: params=

Surface parameters
fun texture_coords: Array[Vec3]

gamnit :: ObjDef :: texture_coords

Texture coordinates
protected fun texture_coords=(texture_coords: Array[Vec3])

gamnit :: ObjDef :: texture_coords=

Texture coordinates
fun vertex_points: Array[Vec4]

gamnit :: ObjDef :: vertex_points

Vertex coordinates
protected fun vertex_points=(vertex_points: Array[Vec4])

gamnit :: ObjDef :: vertex_points=

Vertex coordinates

Redefined properties

redef type SELF: ObjDef

gamnit $ ObjDef :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_coherent: Bool

gamnit :: ObjDef :: is_coherent

Check the coherence of the model
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun material_libs: Set[String]

gamnit :: ObjDef :: material_libs

Relative paths to referenced material libraries
fun normals: Array[Vec3]

gamnit :: ObjDef :: normals

Normals
protected fun normals=(normals: Array[Vec3])

gamnit :: ObjDef :: normals=

Normals
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun objects: Array[ObjObj]

gamnit :: ObjDef :: objects

Sub-objects
protected fun objects=(objects: Array[ObjObj])

gamnit :: ObjDef :: objects=

Sub-objects
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun params: Array[Vec3]

gamnit :: ObjDef :: params

Surface parameters
protected fun params=(params: Array[Vec3])

gamnit :: ObjDef :: params=

Surface parameters
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun texture_coords: Array[Vec3]

gamnit :: ObjDef :: texture_coords

Texture coordinates
protected fun texture_coords=(texture_coords: Array[Vec3])

gamnit :: ObjDef :: texture_coords=

Texture coordinates
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun vertex_points: Array[Vec4]

gamnit :: ObjDef :: vertex_points

Vertex coordinates
protected fun vertex_points=(vertex_points: Array[Vec4])

gamnit :: ObjDef :: vertex_points=

Vertex coordinates
package_diagram gamnit::ObjDef ObjDef core::Object Object gamnit::ObjDef->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

gamnit $ ObjDef
# 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