← ziglang.inraylib-zigGitHub

models

3D shapes, models, meshes, materials and animation. 73 functions, from raylib's rmodels.

Basic geometric 3D shapes drawing functions

rl.drawPoint3D

Draw a point in 3D space, actually a small line

Zigfn drawPoint3D(position: Vector3, color: Color) void
Cvoid DrawPoint3D(Vector3 position, Color color);

Used in models_point_rendering.

rl.drawCircle3D

Draw a circle in 3D world space

Zigfn drawCircle3D(center: Vector3, radius: f32, rotationAxis: Vector3, rotationAngle: f32, color: Color) void
Cvoid DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color);

Used in models_rlgl_solar_system.

rl.drawTriangle3D

Draw a color-filled triangle, counter-clockwise vertex order

Zigfn drawTriangle3D(v1: Vector3, v2: Vector3, v3: Vector3, color: Color) void
Cvoid DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color);

rl.drawTriangleStrip3D

Draw a triangle strip defined by points

Zigfn drawTriangleStrip3D(points: []const Vector3, color: Color) void
Cvoid DrawTriangleStrip3D(const Vector3 *points, int pointCount, Color color);

rl.drawCylinderEx

Draw a cylinder with base at startPos and top at endPos

Zigfn drawCylinderEx(startPos: Vector3, endPos: Vector3, startRadius: f32, endRadius: f32, sides: i32, color: Color) void
Cvoid DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color);

rl.drawCylinderWiresEx

Draw a cylinder wires with base at startPos and top at endPos

Zigfn drawCylinderWiresEx(startPos: Vector3, endPos: Vector3, startRadius: f32, endRadius: f32, sides: i32, color: Color) void
Cvoid DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color);

rl.drawCapsule

Draw a capsule with the center of its sphere caps at startPos and endPos

Zigfn drawCapsule(startPos: Vector3, endPos: Vector3, radius: f32, rings: i32, slices: i32, color: Color) void
Cvoid DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int rings, int slices, Color color);

Used in models_geometric_shapes.

rl.drawCapsuleWires

Draw capsule wireframe with the center of its sphere caps at startPos and endPos

Zigfn drawCapsuleWires(startPos: Vector3, endPos: Vector3, radius: f32, rings: i32, slices: i32, color: Color) void
Cvoid DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int rings, int slices, Color color);

Used in models_geometric_shapes.

Model management functions

rl.isModelValid

Check if model is valid (loaded in GPU, VAO/VBOs)

Zigfn isModelValid(model: Model) bool
Cbool IsModelValid(Model model);

rl.getModelBoundingBox

Compute model bounding box limits (considers all meshes)

Zigfn getModelBoundingBox(model: Model) BoundingBox
CBoundingBox GetModelBoundingBox(Model model);

Used in models_loading_vox.

Model drawing functions

rl.drawModelWires

Draw a model wires (with texture if set)

Zigfn drawModelWires(model: Model, position: Vector3, scale: f32, tint: Color) void
Cvoid DrawModelWires(Model model, Vector3 position, float scale, Color tint);

rl.drawModelWiresEx

Draw a model wires with custom transform

Zigfn drawModelWiresEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void
Cvoid DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint);

rl.drawBillboard

Draw a billboard texture

Zigfn drawBillboard(camera: Camera, texture: Texture2D, position: Vector3, scale: f32, tint: Color) void
Cvoid DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float scale, Color tint);

Used in models_billboard_rendering.

rl.drawBillboardRec

Draw a billboard texture defined by rectangle

Zigfn drawBillboardRec(camera: Camera, texture: Texture2D, rec: Rectangle, position: Vector3, size: Vector2, tint: Color) void
Cvoid DrawBillboardRec(Camera camera, Texture2D texture, Rectangle rec, Vector3 position, Vector2 size, Color tint);

rl.drawBillboardPro

Draw a billboard texture defined by source rectangle with scaling and rotation

Zigfn drawBillboardPro(camera: Camera, texture: Texture2D, rec: Rectangle, position: Vector3, up: Vector3, size: Vector2, origin: Vector2, rotation: f32, tint: Color) void
Cvoid DrawBillboardPro(Camera camera, Texture2D texture, Rectangle rec, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint);

Used in models_billboard_rendering, models_directional_billboard.

Mesh management functions

rl.updateMeshBuffer

Update mesh vertex data in GPU for a specific buffer index

Zigfn updateMeshBuffer(mesh: Mesh, index: i32, data: []const u8, offset: i32) void
Cvoid UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset);

rl.drawMeshInstanced

Draw multiple mesh instances with material and different transforms

Zigfn drawMeshInstanced(mesh: Mesh, material: Material, transforms: []const Matrix) void
Cvoid DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances);

Used in shaders_mesh_instancing.

rl.exportMesh

Export mesh data to file, returns true on success

Zigfn exportMesh(mesh: Mesh, fileName: [:0]const u8) bool
Cbool ExportMesh(Mesh mesh, const char *fileName);

rl.exportMeshAsCode

Export mesh as code file (.h) defining multiple arrays of vertex attributes

Zigfn exportMeshAsCode(mesh: Mesh, fileName: [:0]const u8) bool
Cbool ExportMeshAsCode(Mesh mesh, const char *fileName);

Mesh generation functions

rl.genMeshHemiSphere

Generate half-sphere mesh (no bottom cap)

Zigfn genMeshHemiSphere(radius: f32, rings: i32, slices: i32) Mesh
CMesh GenMeshHemiSphere(float radius, int rings, int slices);

Used in models_mesh_generation.

rl.genMeshCone

Generate cone/pyramid mesh

Zigfn genMeshCone(radius: f32, height: f32, slices: i32) Mesh
CMesh GenMeshCone(float radius, float height, int slices);

rl.genMeshKnot

Generate trefoil knot mesh

Zigfn genMeshKnot(radius: f32, size: f32, radSeg: i32, sides: i32) Mesh
CMesh GenMeshKnot(float radius, float size, int radSeg, int sides);

Used in models_mesh_generation.

Material loading/unloading functions

rl.loadMaterials

Load materials from model file

Load materials from model file. Free each with `unloadMaterial`, then the array with `memFree`.

Zigfn loadMaterials(fileName: [:0]const u8) error{LoadFailed}![]Material
CMaterial *LoadMaterials(const char *fileName, int *materialCount);

rl.isMaterialValid

Check if material is valid (shader assigned, map textures loaded in GPU)

Zigfn isMaterialValid(material: Material) bool
Cbool IsMaterialValid(Material material);

rl.setMaterialTexture

Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)

Zigfn setMaterialTexture(material: *Material, mapType: MaterialMapIndex, texture: Texture2D) void
Cvoid SetMaterialTexture(Material *material, int mapType, Texture2D texture);

Used in models_loading_iqm.

rl.setModelMeshMaterial

Set material for a mesh

Zigfn setModelMeshMaterial(model: *Model, meshId: i32, materialId: i32) void
Cvoid SetModelMeshMaterial(Model *model, int meshId, int materialId);

Model animations loading/unloading functions

rl.updateModelAnimationEx

Update model animation pose, blending two animations

Zigfn updateModelAnimationEx(model: Model, animA: ModelAnimation, frameA: f32, animB: ModelAnimation, frameB: f32, blend: f32) void
Cvoid UpdateModelAnimationEx(Model model, ModelAnimation animA, float frameA, ModelAnimation animB, float frameB, float blend);

Used in models_animation_blend_custom, models_animation_blending.

rl.isModelAnimationValid

Check model animation skeleton match

Zigfn isModelAnimationValid(model: Model, anim: ModelAnimation) bool
Cbool IsModelAnimationValid(Model model, ModelAnimation anim);

Collision detection functions

rl.checkCollisionSpheres

Check collision between two spheres

Zigfn checkCollisionSpheres(center1: Vector3, radius1: f32, center2: Vector3, radius2: f32) bool
Cbool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2);

rl.checkCollisionBoxes

Check collision between two bounding boxes

Zigfn checkCollisionBoxes(box1: BoundingBox, box2: BoundingBox) bool
Cbool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);

Used in models_box_collisions.

rl.checkCollisionBoxSphere

Check collision between box and sphere

Zigfn checkCollisionBoxSphere(box: BoundingBox, center: Vector3, radius: f32) bool
Cbool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius);

Used in models_box_collisions.

rl.getRayCollisionSphere

Get collision info between ray and sphere

Zigfn getRayCollisionSphere(ray: Ray, center: Vector3, radius: f32) RayCollision
CRayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius);

Used in models_mesh_picking.

rl.getRayCollisionQuad

Get collision info between ray and quad

Zigfn getRayCollisionQuad(ray: Ray, p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) RayCollision
CRayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4);

Used in models_mesh_picking.