gamnit :: Mesh :: defaultinit
gamnit :: Mesh :: dimensions
Dimensions of the bounding box containing all verticesgamnit :: Mesh :: dimensions=
Dimensions of the bounding box containing all verticesGLDrawMode
used to display this mesh, defaults to gl_TRIANGLES
gamnit :: Mesh :: indices_c=
gamnit :: Mesh :: texture_coords
Coordinates on the texture, 2 floats per vertexgamnit :: Mesh :: texture_coords=
Coordinates on the texture, 2 floats per vertexcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
gamnit :: Mesh :: defaultinit
gamnit :: Mesh :: dimensions
Dimensions of the bounding box containing all verticesgamnit :: Mesh :: dimensions=
Dimensions of the bounding box containing all verticesGLDrawMode
used to display this mesh, defaults to gl_TRIANGLES
gamnit :: Mesh :: indices_c=
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.
core :: Object :: output_class_name
Display class name on stdout (debug only).gamnit :: Mesh :: texture_coords
Coordinates on the texture, 2 floats per vertexgamnit :: Mesh :: texture_coords=
Coordinates on the texture, 2 floats per vertex
# Mesh with all geometry data
#
# May be created via `Plane`, `Cube` or `UVSphere`,
# or loaded from the assets folder indirectly with a `Model`.
#
# ~~~
# import gamnit::depth
#
# var plane = new Plane
# var cube = new Cube
# var sphere = new UVSphere(1.0, 32, 16)
# ~~~
class Mesh
# Number for vertices
fun n_vertices: Int do return vertices.length / 3
# Vertices relative coordinates, 3 floats per vertex
var vertices = new Array[Float] is lazy, writable
# Indices to draw triangles with `glDrawElements`
#
# If `not_empty`, use `glDrawElements`, otherwise use `glDrawArrays`.
var indices = new Array[Int] is lazy, writable
private var indices_c = new CUInt16Array.from(indices) is lazy, writable
# Normals, 3 floats per vertex
var normals = new Array[Float] is lazy, writable
# Coordinates on the texture, 2 floats per vertex
var texture_coords = new Array[Float] is lazy, writable
# `GLDrawMode` used to display this mesh, defaults to `gl_TRIANGLES`
fun draw_mode: GLDrawMode do return gl_TRIANGLES
end
lib/gamnit/depth/depth_core.nit:174,1--209,3
redef class Mesh
# 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
var i = 0
while i < vertices.length do
mx = mx.min(vertices[i])
my = my.min(vertices[i+1])
mz = mz.min(vertices[i+2])
i += 3
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
var i = 0
while i < vertices.length do
mx = mx.max(vertices[i])
my = my.max(vertices[i+1])
mz = mz.max(vertices[i+2])
i += 3
end
return new Point3d[Float](mx, my, mz)
end
end
lib/gamnit/depth/model_dimensions.nit:68,1--109,3