summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2023-11-09 20:48:16 +0200
committerjussi2023-11-09 20:48:16 +0200
commitef75e2530dd92c55ba6b2462fe71fa888e1883df (patch)
treea95469b8e5d83b601c998c32774ba5c1dd873a4e
parent28ac27fae16d5d2df6174564dde05c6064515a33 (diff)
downloadreilua-enhanced-ef75e2530dd92c55ba6b2462fe71fa888e1883df.tar.gz
reilua-enhanced-ef75e2530dd92c55ba6b2462fe71fa888e1883df.tar.bz2
reilua-enhanced-ef75e2530dd92c55ba6b2462fe71fa888e1883df.zip
GenMeshCubicmap, Organized model functions, GetModelBoundingBox, DrawModelWires and DrawModelWiresEx and LoadMaterials.
-rw-r--r--API.md278
-rw-r--r--ReiLua_API.lua369
-rw-r--r--changelog5
-rw-r--r--include/models.h62
-rw-r--r--src/lua_core.c61
-rw-r--r--src/models.c984
-rw-r--r--src/text.c4
7 files changed, 994 insertions, 769 deletions
diff --git a/API.md b/API.md
index c0651cf..7c5ba1b 100644
--- a/API.md
+++ b/API.md
@@ -6060,7 +6060,7 @@ Draw multiple character (codepoint)
> mouseCharId = RL.DrawTextBoxed(Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint )
-Draw text using font inside rectangle limits. Return character from mouse position. Function from raylib [text] example - Rectangle bounds.
+Draw text using font inside rectangle limits. Return character id from mouse position (default -1). Function from raylib [text] example - Rectangle bounds.
- Success return int
@@ -6068,7 +6068,7 @@ Draw text using font inside rectangle limits. Return character from mouse positi
> mouseCharId = RL.DrawTextBoxedTinted( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tints, Color backTints )
-Draw text using font inside rectangle limits with support for tint and background tint for each character. Return character from mouse position
+Draw text using font inside rectangle limits with support for tint and background tint for each character. Return character id from mouse position (default -1)
- Success return int
@@ -6143,7 +6143,7 @@ Get font texture atlas containing the glyphs. Return as lightuserdata
---
-## Models - Basic
+## Models - Basic geometric 3D shapes drawing functions
---
@@ -6261,87 +6261,128 @@ Draw a grid (Centered at ( 0, 0, 0 ))
---
-## Models - Mesh
+## Models - Model management functions
---
-> mesh = RL.GenMeshPoly( int sides, float radius )
+> model = RL.LoadModel( string fileName )
-Generate polygonal mesh
+Load model from files (Meshes and materials)
-- Success return Mesh
+- Failure return nil
+- Success return Model
---
-> mesh = RL.GenMeshPlane( float width, float length, int resX, int resZ )
+> model = RL.LoadModelFromMesh( Mesh mesh )
-Generate plane mesh (With subdivisions)
+Load model from generated mesh (Default material)
-- Success return Mesh
+- Success return Model
---
-> mesh = RL.GenMeshCube( Vector3 size )
+> isReady = RL.IsModelReady( Model model )
-Generate cuboid mesh
+Check if a model is ready
-- Success return Mesh
+- Success return bool
---
-> mesh = RL.GenMeshSphere( float radius, int rings, int slices )
+> RL.UnloadModel( Model model )
-Generate sphere mesh (Standard sphere)
+Unload model (including meshes) from memory (RAM and/or VRAM)
-- Success return Mesh
+---
+
+> boundingBox = RL.GetModelBoundingBox( Model model )
+
+Compute model bounding box limits (considers all meshes)
+
+- Success return BoundingBox
---
-> mesh = RL.GenMeshCylinder( float radius, float height, int slices )
+> RL.SetModelMaterial( Model model, Material modelMaterial, Material material )
-Generate cylinder mesh
+Copies material to model material. (Model material is the material id in models.)
-- Success return Mesh
+---
+
+> RL.SetModelMeshMaterial( Model model, int meshId, int materialId )
+
+Set material for a mesh (Mesh and material on this model)
---
-> mesh = RL.GenMeshCone( float radius, float height, int slices )
+> RL.SetModelTransform( Model model, Matrix transform )
-Generate cone/pyramid mesh
+Set model transform matrix
-- Success return Mesh
+---
+
+> transform = RL.GetModelTransform( Model model )
+
+Get model transform matrix
+
+- Success return Matrix
---
-> mesh = RL.GenMeshTorus( float radius, float size, int radSeg, int sides )
+## Models - Model drawing functions
-Generate torus mesh
+---
-- Success return Mesh
+> RL.DrawModel( Model model, Vector3 position, float scale, Color tint )
+
+Draw a model (With texture if set)
---
-> mesh = RL.GenMeshKnot( float radius, float size, int radSeg, int sides )
+> RL.DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
-Generate torus mesh
+Draw a model with extended parameters
-- Success return Mesh
+---
+
+> RL.DrawModelWires( Model model, Vector3 position, float scale, Color tint )
+
+Draw a model wires (with texture if set)
---
-> mesh = RL.GenMeshHeightmap( Image heightmap, Vector3 size )
+> RL.DrawModelWiresEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
-Generate heightmap mesh from image data
+Draw a model wires (with texture if set) with extended parameters
-- Success return Mesh
+---
+
+> RL.DrawBoundingBox( BoundingBox box, Color color )
+
+Draw bounding box (wires)
---
-> mesh = RL.GenMeshCustom( Mesh{} meshData, bool dynamic )
+> RL.DrawBillboard( Camera3D camera, Texture texture, Vector3 position, float size, Color tint )
-Generate custom mesh from vertex attribute data and uploads it into a VAO (if supported) and VBO
+Draw a billboard texture
-- Success return Mesh
+---
+
+> RL.DrawBillboardRec( Camera3D camera, Texture texture, Rectangle source, Vector3 position, Vector2 size, Color tint )
+
+Draw a billboard texture defined by source
+
+---
+
+> RL.DrawBillboardPro( Camera3D camera, Texture texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint )
+
+Draw a billboard texture defined by source and rotation
+
+---
+
+## Models - Mesh management functions
---
@@ -6402,210 +6443,219 @@ Compute mesh tangents
---
-## Models - Material
+## Models - Mesh generation functions
---
-> material = RL.GetMaterialDefault()
+> mesh = RL.GenMeshPoly( int sides, float radius )
-Default material for reference. Return as lightuserdata
+Generate polygonal mesh
-- Success return Material
+- Success return Mesh
---
-> material = RL.LoadMaterialDefault()
+> mesh = RL.GenMeshPlane( float width, float length, int resX, int resZ )
-Load default material as new object
+Generate plane mesh (With subdivisions)
-- Success return Material
+- Success return Mesh
---
-> material = RL.CreateMaterial( Material{} materialData )
+> mesh = RL.GenMeshCube( Vector3 size )
-Load material from table. See material table definition
+Generate cuboid mesh
-- Success return Material
+- Success return Mesh
---
-> isReady = RL.IsMaterialReady( Material material )
+> mesh = RL.GenMeshSphere( float radius, int rings, int slices )
-Check if a material is ready
+Generate sphere mesh (Standard sphere)
-- Success return bool
+- Success return Mesh
---
-> RL.UnloadMaterial( Material material )
-
-Unload material from GPU memory (VRAM)
-
----
+> mesh = RL.GenMeshCylinder( float radius, float height, int slices )
-> RL.SetMaterialTexture( Material material, int mapType, Texture texture )
+Generate cylinder mesh
-Set texture for a material map type (MATERIAL_MAP_ALBEDO, MATERIAL_MAP_METALNESS...)
+- Success return Mesh
---
-> RL.SetMaterialColor( Material material, int mapType, Color color )
+> mesh = RL.GenMeshCone( float radius, float height, int slices )
-Set color for a material map type
+Generate cone/pyramid mesh
+
+- Success return Mesh
---
-> RL.SetMaterialValue( Material material, int mapType, float value )
+> mesh = RL.GenMeshTorus( float radius, float size, int radSeg, int sides )
-Set value for a material map type
+Generate torus mesh
+
+- Success return Mesh
---
-> RL.SetMaterialShader( Material material, Shader shader )
+> mesh = RL.GenMeshKnot( float radius, float size, int radSeg, int sides )
-Set shader for material
+Generate torus mesh
+
+- Success return Mesh
---
-> RL.SetMaterialParams( Material material, float{} params )
+> mesh = RL.GenMeshHeightmap( Image heightmap, Vector3 size )
-Set material generic parameters (if required)
+Generate heightmap mesh from image data
+
+- Success return Mesh
---
-> texture = RL.GetMaterialTexture( Material material, int mapType )
+> mesh = RL.GenMeshCubicmap( Image cubicmap, Vector3 cubeSize )
-Get texture from material map type. Returns -1 if no texture
+Generate cubes-based map mesh from image data
-- Success return Texture
+- Success return Mesh
---
-> color = RL.GetMaterialColor( Material material, int mapType )
+> mesh = RL.GenMeshCustom( Mesh{} meshData, bool dynamic )
-Get color from material map type
+Generate custom mesh from vertex attribute data and uploads it into a VAO (if supported) and VBO
-- Success return Color
+- Success return Mesh
---
-> value = RL.GetMaterialValue( Material material, int mapType )
-
-Get color from material map type
-
-- Success return float
+## Models - Material management functions
---
-> shader = RL.GetMaterialShader( Material material )
+> materials = RL.LoadMaterials( string fileName )
-Get material shader
+Load materials from model file
-- Success return Shader. Return as lightuserdata
+- Success return Material{}
---
-> params = RL.GetMaterialParams( Material material )
+> material = RL.GetMaterialDefault()
-Get material parameters
+Default material for reference. Return as lightuserdata
-- Success return float{}
+- Success return Material
---
-## Models - Model
+> material = RL.LoadMaterialDefault()
+
+Load default material as new object
+
+- Success return Material
---
-> model = RL.LoadModel( string fileName )
+> material = RL.CreateMaterial( Material{} materialData )
-Load model from files (Meshes and materials)
+Load material from table. See material table definition
-- Failure return nil
-- Success return Model
+- Success return Material
---
-> model = RL.LoadModelFromMesh( Mesh mesh )
+> isReady = RL.IsMaterialReady( Material material )
-Load model from generated mesh (Default material)
+Check if a material is ready
-- Success return Model
+- Success return bool
---
-> isReady = RL.IsModelReady( Model model )
-
-Check if a model is ready
+> RL.UnloadMaterial( Material material )
-- Success return bool
+Unload material from GPU memory (VRAM)
---
-> RL.UnloadModel( Model model )
+> RL.SetMaterialTexture( Material material, int mapType, Texture texture )
-Unload model (including meshes) from memory (RAM and/or VRAM)
+Set texture for a material map type (MATERIAL_MAP_ALBEDO, MATERIAL_MAP_METALNESS...)
---
-> RL.DrawModel( Model model, Vector3 position, float scale, Color tint )
+> RL.SetMaterialColor( Material material, int mapType, Color color )
-Draw a model (With texture if set)
+Set color for a material map type
---
-> RL.DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
+> RL.SetMaterialValue( Material material, int mapType, float value )
-Draw a model with extended parameters
+Set value for a material map type
---
-> RL.SetModelMaterial( Model model, Material modelMaterial, Material material )
+> RL.SetMaterialShader( Material material, Shader shader )
-Copies material to model material. (Model material is the material id in models.)
+Set shader for material
---
-> RL.SetModelMeshMaterial( Model model, int meshId, int materialId )
+> RL.SetMaterialParams( Material material, float{} params )
-Set material for a mesh (Mesh and material on this model)
+Set material generic parameters (if required)
---
-> RL.DrawBillboard( Camera3D camera, Texture texture, Vector3 position, float size, Color tint )
+> texture = RL.GetMaterialTexture( Material material, int mapType )
-Draw a billboard texture
+Get texture from material map type. Returns -1 if no texture
+
+- Success return Texture
---
-> RL.DrawBillboardRec( Camera3D camera, Texture texture, Rectangle source, Vector3 position, Vector2 size, Color tint )
+> color = RL.GetMaterialColor( Material material, int mapType )
-Draw a billboard texture defined by source
+Get color from material map type
+
+- Success return Color
---
-> RL.DrawBillboardPro( Camera3D camera, Texture texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint )
+> value = RL.GetMaterialValue( Material material, int mapType )
-Draw a billboard texture defined by source and rotation
+Get color from material map type
+
+- Success return float
---
-> RL.SetModelTransform( Model model, Matrix transform )
+> shader = RL.GetMaterialShader( Material material )
-Set model transform matrix
+Get material shader
+
+- Success return Shader. Return as lightuserdata
---
-> transform = RL.GetModelTransform( Model model )
+> params = RL.GetMaterialParams( Material material )
-Get model transform matrix
+Get material parameters
-- Success return Matrix
+- Success return float{}
---
-## Model - Animations
+## Model - Model animations management functions
---
@@ -6648,7 +6698,7 @@ Return modelAnimation frame count
---
-## Model - Collision
+## Model - Collision detection functions
---
diff --git a/ReiLua_API.lua b/ReiLua_API.lua
index 65f98ce..98df0a4 100644
--- a/ReiLua_API.lua
+++ b/ReiLua_API.lua
@@ -3434,7 +3434,7 @@ function RL.DrawTextCodepoint( font, codepoint, position, fontSize, tint ) end
---@return any RL.DrawTextCodepoints
function RL.DrawTextCodepoints( font, codepoints, position, fontSize, spacing, tint ) end
----Draw text using font inside rectangle limits. Return character from mouse position. Function from raylib [text] example - Rectangle bounds.
+---Draw text using font inside rectangle limits. Return character id from mouse position (default -1). Function from raylib [text] example - Rectangle bounds.
---- Success return int
---@param font any
---@param text string
@@ -3446,7 +3446,7 @@ function RL.DrawTextCodepoints( font, codepoints, position, fontSize, spacing,
---@return any mouseCharId
function RL.DrawTextBoxed( font, text, rec, fontSize, spacing, wordWrap, tint ) end
----Draw text using font inside rectangle limits with support for tint and background tint for each character. Return character from mouse position
+---Draw text using font inside rectangle limits with support for tint and background tint for each character. Return character id from mouse position (default -1)
---- Success return int
---@param font any
---@param text string
@@ -3516,7 +3516,7 @@ function RL.GetFontGlyphPadding( font ) end
---@return any texture
function RL.GetFontTexture( font ) end
--- Models - Basic
+-- Models - Basic geometric 3D shapes drawing functions
---Draw a line in 3D world space
---@param startPos table
@@ -3674,7 +3674,197 @@ function RL.DrawRay( ray, color ) end
---@return any RL.DrawGrid
function RL.DrawGrid( slices, spacing ) end
--- Models - Mesh
+-- Models - Model management functions
+
+---Load model from files (Meshes and materials)
+---- Failure return nil
+---- Success return Model
+---@param fileName string
+---@return any model
+function RL.LoadModel( fileName ) end
+
+---Load model from generated mesh (Default material)
+---- Success return Model
+---@param mesh any
+---@return any model
+function RL.LoadModelFromMesh( mesh ) end
+
+---Check if a model is ready
+---- Success return bool
+---@param model any
+---@return any isReady
+function RL.IsModelReady( model ) end
+
+---Unload model (including meshes) from memory (RAM and/or VRAM)
+---@param model any
+---@return any RL.UnloadModel
+function RL.UnloadModel( model ) end
+
+---Compute model bounding box limits (considers all meshes)
+---- Success return BoundingBox
+---@param model any
+---@return any boundingBox
+function RL.GetModelBoundingBox( model ) end
+
+---Copies material to model material. (Model material is the material id in models.)
+---@param model any
+---@param modelMaterial any
+---@param material any
+---@return any RL.SetModelMaterial
+function RL.SetModelMaterial( model, modelMaterial, material ) end
+
+---Set material for a mesh (Mesh and material on this model)
+---@param model any
+---@param meshId integer
+---@param materialId integer
+---@return any RL.SetModelMeshMaterial
+function RL.SetModelMeshMaterial( model, meshId, materialId ) end
+
+---Set model transform matrix
+---@param model any
+---@param transform table
+---@return any RL.SetModelTransform
+function RL.SetModelTransform( model, transform ) end
+
+---Get model transform matrix
+---- Success return Matrix
+---@param model any
+---@return any transform
+function RL.GetModelTransform( model ) end
+
+-- Models - Model drawing functions
+
+---Draw a model (With texture if set)
+---@param model any
+---@param position table
+---@param scale number
+---@param tint table
+---@return any RL.DrawModel
+function RL.DrawModel( model, position, scale, tint ) end
+
+---Draw a model with extended parameters
+---@param model any
+---@param position table
+---@param rotationAxis table
+---@param rotationAngle number
+---@param scale table
+---@param tint table
+---@return any RL.DrawModelEx
+function RL.DrawModelEx( model, position, rotationAxis, rotationAngle, scale, tint ) end
+
+---Draw a model wires (with texture if set)
+---@param model any
+---@param position table
+---@param scale number
+---@param tint table
+---@return any RL.DrawModelWires
+function RL.DrawModelWires( model, position, scale, tint ) end
+
+---Draw a model wires (with texture if set) with extended parameters
+---@param model any
+---@param position table
+---@param rotationAxis table
+---@param rotationAngle number
+---@param scale table
+---@param tint table
+---@return any RL.DrawModelWiresEx
+function RL.DrawModelWiresEx( model, position, rotationAxis, rotationAngle, scale, tint ) end
+
+---Draw bounding box (wires)
+---@param box any
+---@param color table
+---@return any RL.DrawBoundingBox
+function RL.DrawBoundingBox( box, color ) end
+
+---Draw a billboard texture
+---@param camera any
+---@param texture any
+---@param position table
+---@param size number
+---@param tint table
+---@return any RL.DrawBillboard
+function RL.DrawBillboard( camera, texture, position, size, tint ) end
+
+---Draw a billboard texture defined by source
+---@param camera any
+---@param texture any
+---@param source table
+---@param position table
+---@param size table
+---@param tint table
+---@return any RL.DrawBillboardRec
+function RL.DrawBillboardRec( camera, texture, source, position, size, tint ) end
+
+---Draw a billboard texture defined by source and rotation
+---@param camera any
+---@param texture any
+---@param source table
+---@param position table
+---@param up table
+---@param size table
+---@param origin table
+---@param rotation number
+---@param tint table
+---@return any RL.DrawBillboardPro
+function RL.DrawBillboardPro( camera, texture, source, position, up, size, origin, rotation, tint ) end
+
+-- Models - Mesh management functions
+
+---Update mesh vertex data in GPU.
+---Note! Mainly intented to be used with custom meshes.
+---@param mesh any
+---@param meshData table
+---@return any RL.UpdateMesh
+function RL.UpdateMesh( mesh, meshData ) end
+
+---Unload mesh data from CPU and GPU
+---@param mesh any
+---@return any RL.UnloadMesh
+function RL.UnloadMesh( mesh ) end
+
+---Draw a 3d mesh with material and transform
+---@param mesh any
+---@param material any
+---@param transform table
+---@return any RL.DrawMesh
+function RL.DrawMesh( mesh, material, transform ) end
+
+---Draw multiple mesh instances with material and different transforms
+---@param mesh any
+---@param material any
+---@param transforms table
+---@param instances integer
+---@return any RL.DrawMeshInstanced
+function RL.DrawMeshInstanced( mesh, material, transforms, instances ) end
+
+---Updades mesh color vertex attribute buffer
+---NOTE: Currently only works on custom mesh
+---- Failure return false
+---- Success return true
+---@param mesh any
+---@param color table
+---@return any success
+function RL.SetMeshColor( mesh, color ) end
+
+---Export mesh data to file, returns true on success
+---- Success return bool
+---@param mesh any
+---@param fileName string
+---@return any success
+function RL.ExportMesh( mesh, fileName ) end
+
+---Compute mesh bounding box limits
+---- Success return BoundingBox
+---@param mesh any
+---@return any boundingBox
+function RL.GetMeshBoundingBox( mesh ) end
+
+---Compute mesh tangents
+---@param mesh any
+---@return any RL.GenMeshTangents
+function RL.GenMeshTangents( mesh ) end
+
+-- Models - Mesh generation functions
---Generate polygonal mesh
---- Success return Mesh
@@ -3747,6 +3937,13 @@ function RL.GenMeshKnot( radius, size, radSeg, sides ) end
---@return any mesh
function RL.GenMeshHeightmap( heightmap, size ) end
+---Generate cubes-based map mesh from image data
+---- Success return Mesh
+---@param cubicmap any
+---@param cubeSize table
+---@return any mesh
+function RL.GenMeshCubicmap( cubicmap, cubeSize ) end
+
---Generate custom mesh from vertex attribute data and uploads it into a VAO (if supported) and VBO
---- Success return Mesh
---@param meshData table
@@ -3754,61 +3951,13 @@ function RL.GenMeshHeightmap( heightmap, size ) end
---@return any mesh
function RL.GenMeshCustom( meshData, dynamic ) end
----Update mesh vertex data in GPU.
----Note! Mainly intented to be used with custom meshes.
----@param mesh any
----@param meshData table
----@return any RL.UpdateMesh
-function RL.UpdateMesh( mesh, meshData ) end
-
----Unload mesh data from CPU and GPU
----@param mesh any
----@return any RL.UnloadMesh
-function RL.UnloadMesh( mesh ) end
-
----Draw a 3d mesh with material and transform
----@param mesh any
----@param material any
----@param transform table
----@return any RL.DrawMesh
-function RL.DrawMesh( mesh, material, transform ) end
+-- Models - Material management functions
----Draw multiple mesh instances with material and different transforms
----@param mesh any
----@param material any
----@param transforms table
----@param instances integer
----@return any RL.DrawMeshInstanced
-function RL.DrawMeshInstanced( mesh, material, transforms, instances ) end
-
----Updades mesh color vertex attribute buffer
----NOTE: Currently only works on custom mesh
----- Failure return false
----- Success return true
----@param mesh any
----@param color table
----@return any success
-function RL.SetMeshColor( mesh, color ) end
-
----Export mesh data to file, returns true on success
----- Success return bool
----@param mesh any
+---Load materials from model file
+---- Success return Material{}
---@param fileName string
----@return any success
-function RL.ExportMesh( mesh, fileName ) end
-
----Compute mesh bounding box limits
----- Success return BoundingBox
----@param mesh any
----@return any boundingBox
-function RL.GetMeshBoundingBox( mesh ) end
-
----Compute mesh tangents
----@param mesh any
----@return any RL.GenMeshTangents
-function RL.GenMeshTangents( mesh ) end
-
--- Models - Material
+---@return any materials
+function RL.LoadMaterials( fileName ) end
---Default material for reference. Return as lightuserdata
---- Success return Material
@@ -3903,109 +4052,7 @@ function RL.GetMaterialShader( material ) end
---@return any params
function RL.GetMaterialParams( material ) end
--- Models - Model
-
----Load model from files (Meshes and materials)
----- Failure return nil
----- Success return Model
----@param fileName string
----@return any model
-function RL.LoadModel( fileName ) end
-
----Load model from generated mesh (Default material)
----- Success return Model
----@param mesh any
----@return any model
-function RL.LoadModelFromMesh( mesh ) end
-
----Check if a model is ready
----- Success return bool
----@param model any
----@return any isReady
-function RL.IsModelReady( model ) end
-
----Unload model (including meshes) from memory (RAM and/or VRAM)
----@param model any
----@return any RL.UnloadModel
-function RL.UnloadModel( model ) end
-
----Draw a model (With texture if set)
----@param model any
----@param position table
----@param scale number
----@param tint table
----@return any RL.DrawModel
-function RL.DrawModel( model, position, scale, tint ) end
-
----Draw a model with extended parameters
----@param model any
----@param position table
----@param rotationAxis table
----@param rotationAngle number
----@param scale table
----@param tint table
----@return any RL.DrawModelEx
-function RL.DrawModelEx( model, position, rotationAxis, rotationAngle, scale, tint ) end
-
----Copies material to model material. (Model material is the material id in models.)
----@param model any
----@param modelMaterial any
----@param material any
----@return any RL.SetModelMaterial
-function RL.SetModelMaterial( model, modelMaterial, material ) end
-
----Set material for a mesh (Mesh and material on this model)
----@param model any
----@param meshId integer
----@param materialId integer
----@return any RL.SetModelMeshMaterial
-function RL.SetModelMeshMaterial( model, meshId, materialId ) end
-
----Draw a billboard texture
----@param camera any
----@param texture any
----@param position table
----@param size number
----@param tint table
----@return any RL.DrawBillboard
-function RL.DrawBillboard( camera, texture, position, size, tint ) end
-
----Draw a billboard texture defined by source
----@param camera any
----@param texture any
----@param source table
----@param position table
----@param size table
----@param tint table
----@return any RL.DrawBillboardRec
-function RL.DrawBillboardRec( camera, texture, source, position, size, tint ) end
-
----Draw a billboard texture defined by source and rotation
----@param camera any
----@param texture any
----@param source table
----@param position table
----@param up table
----@param size table
----@param origin table
----@param rotation number
----@param tint table
----@return any RL.DrawBillboardPro
-function RL.DrawBillboardPro( camera, texture, source, position, up, size, origin, rotation, tint ) end
-
----Set model transform matrix
----@param model any
----@param transform table
----@return any RL.SetModelTransform
-function RL.SetModelTransform( model, transform ) end
-
----Get model transform matrix
----- Success return Matrix
----@param model any
----@return any transform
-function RL.GetModelTransform( model ) end
-
--- Model - Animations
+-- Model - Model animations management functions
---Load model animations from file
---- Failure return nil
@@ -4040,7 +4087,7 @@ function RL.GetModelAnimationBoneCount( animation ) end
---@return any frameCount
function RL.GetModelAnimationFrameCount( animation ) end
--- Model - Collision
+-- Model - Collision detection functions
---Check collision between two spheres
---- Success return bool
diff --git a/changelog b/changelog
index f135c4b..b13b598 100644
--- a/changelog
+++ b/changelog
@@ -42,6 +42,11 @@ DETAILED CHANGES:
- ADDED: ExportBuffer and LoadBufferFromFile.
- REMOVED: DrawTextBoxedSelectable.
- ADDED: DrawTextBoxedTinted.
+ - ADDED: GenMeshCubicmap.
+ - CHANGED: Organized model functions.
+ - ADDED: GetModelBoundingBox.
+ - ADDED: DrawModelWires and DrawModelWiresEx.
+ - ADDED: LoadMaterials.
------------------------------------------------------------------------
Release: ReiLua version 0.5.0 Using Raylib 4.5
diff --git a/include/models.h b/include/models.h
index e6e91a7..39e1da7 100644
--- a/include/models.h
+++ b/include/models.h
@@ -7,7 +7,7 @@ void UnloadModelKeepMeshes( Model model );
void DrawBillboardProNoRatio( Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint );
void DrawBillboardRecNoRatio( Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector2 size, Color tint );
-/* Basic. */
+/* Basic geometric 3D shapes drawing functions. */
int lmodelsDrawLine3D( lua_State *L );
int lmodelsDrawPoint3D( lua_State *L );
int lmodelsDrawCircle3D( lua_State *L );
@@ -27,7 +27,35 @@ int lmodelsDrawPlane( lua_State *L );
int lmodelDrawQuad3DTexture( lua_State *L );
int lmodelsDrawRay( lua_State *L );
int lmodelsDrawGrid( lua_State *L );
-/* Mesh. */
+/* Model management functions. */
+int lmodelsLoadModel( lua_State *L );
+int lmodelsLoadModelFromMesh( lua_State *L );
+int lmodelsIsModelReady( lua_State *L );
+int lmodelsUnloadModel( lua_State *L );
+int lmodelsGetModelBoundingBox( lua_State *L );
+int lmodelsSetModelMaterial( lua_State *L );
+int lmodelsSetModelMeshMaterial( lua_State *L );
+int lmodelsSetModelTransform( lua_State *L );
+int lmodelsGetModelTransform( lua_State *L );
+/* Model drawing functions. */
+int lmodelsDrawModel( lua_State *L );
+int lmodelsDrawModelEx( lua_State *L );
+int lmodelsDrawModelWires( lua_State *L );
+int lmodelsDrawModelWiresEx( lua_State *L );
+int lmodelsDrawBoundingBox( lua_State *L );
+int lmodelsDrawBillboard( lua_State *L );
+int lmodelsDrawBillboardRec( lua_State *L );
+int lmodelsDrawBillboardPro( lua_State *L );
+/* Mesh management functions. */
+int lmodelsUpdateMesh( lua_State *L );
+int lmodelsUnloadMesh( lua_State *L );
+int lmodelsDrawMesh( lua_State *L );
+int lmodelsDrawMeshInstanced( lua_State *L );
+int lmodelsSetMeshColor( lua_State *L );
+int lmodelsExportMesh( lua_State *L );
+int lmodelsGetMeshBoundingBox( lua_State *L );
+int lmodelsGenMeshTangents( lua_State *L );
+/* Mesh generation functions. */
int lmodelsGenMeshPoly( lua_State *L );
int lmodelsGenMeshPlane( lua_State *L );
int lmodelsGenMeshCube( lua_State *L );
@@ -37,16 +65,10 @@ int lmodelsGenMeshCone( lua_State *L );
int lmodelsGenMeshTorus( lua_State *L );
int lmodelsGenMeshKnot( lua_State *L );
int lmodelsGenMeshHeightmap( lua_State *L );
+int lmodelsGenMeshCubicmap( lua_State *L );
int lmodelsGenMeshCustom( lua_State *L );
-int lmodelsUpdateMesh( lua_State *L );
-int lmodelsUnloadMesh( lua_State *L );
-int lmodelsDrawMesh( lua_State *L );
-int lmodelsDrawMeshInstanced( lua_State *L );
-int lmodelsSetMeshColor( lua_State *L );
-int lmodelsExportMesh( lua_State *L );
-int lmodelsGetMeshBoundingBox( lua_State *L );
-int lmodelsGenMeshTangents( lua_State *L );
-/* Material. */
+/* Material management functions. */
+int lmodelsLoadMaterials( lua_State *L );
int lmodelsGetMaterialDefault( lua_State *L );
int lmodelsLoadMaterialDefault( lua_State *L );
int lmodelsCreateMaterial( lua_State *L );
@@ -62,27 +84,13 @@ int lmodelsGetMaterialColor( lua_State *L );
int lmodelsGetMaterialValue( lua_State *L );
int lmodelsGetMaterialShader( lua_State *L );
int lmodelsGetMaterialParams( lua_State *L );
-/* Model. */
-int lmodelsLoadModel( lua_State *L );
-int lmodelsLoadModelFromMesh( lua_State *L );
-int lmodelsIsModelReady( lua_State *L );
-int lmodelsUnloadModel( lua_State *L );
-int lmodelsDrawModel( lua_State *L );
-int lmodelsDrawModelEx( lua_State *L );
-int lmodelsSetModelMaterial( lua_State *L );
-int lmodelsSetModelMeshMaterial( lua_State *L );
-int lmodelsDrawBillboard( lua_State *L );
-int lmodelsDrawBillboardRec( lua_State *L );
-int lmodelsDrawBillboardPro( lua_State *L );
-int lmodelsSetModelTransform( lua_State *L );
-int lmodelsGetModelTransform( lua_State *L );
-/* Animations. */
+/* Model animations management functions. */
int lmodelsLoadModelAnimations( lua_State *L );
int lmodelsUpdateModelAnimation( lua_State *L );
int lmodelsIsModelAnimationValid( lua_State *L );
int lmodelsGetModelAnimationBoneCount( lua_State *L );
int lmodelsGetModelAnimationFrameCount( lua_State *L );
-/* Collision. */
+/* Collision detection functions. */
int lmodelsCheckCollisionSpheres( lua_State *L );
int lmodelsCheckCollisionBoxes( lua_State *L );
int lmodelsCheckCollisionBoxSphere( lua_State *L );
diff --git a/src/lua_core.c b/src/lua_core.c
index 0ea2f4e..89ca581 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1860,7 +1860,7 @@ void luaRegister() {
assingGlobalFunction( "GetPixelDataSize", ltexturesGetPixelDataSize );
/* Models. */
- /* Basic. */
+ /* Basic geometric 3D shapes drawing functions. */
assingGlobalFunction( "DrawLine3D", lmodelsDrawLine3D );
assingGlobalFunction( "DrawPoint3D", lmodelsDrawPoint3D );
assingGlobalFunction( "DrawCircle3D", lmodelsDrawCircle3D );
@@ -1880,7 +1880,35 @@ void luaRegister() {
assingGlobalFunction( "DrawQuad3DTexture", lmodelDrawQuad3DTexture );
assingGlobalFunction( "DrawRay", lmodelsDrawRay );
assingGlobalFunction( "DrawGrid", lmodelsDrawGrid );
- /* Mesh. */
+ /* Model management functions. */
+ assingGlobalFunction( "LoadModel", lmodelsLoadModel );
+ assingGlobalFunction( "LoadModelFromMesh", lmodelsLoadModelFromMesh );
+ assingGlobalFunction( "IsModelReady", lmodelsIsModelReady );
+ assingGlobalFunction( "UnloadModel", lmodelsUnloadModel );
+ assingGlobalFunction( "GetModelBoundingBox", lmodelsGetModelBoundingBox );
+ assingGlobalFunction( "SetModelMaterial", lmodelsSetModelMaterial );
+ assingGlobalFunction( "SetModelMeshMaterial", lmodelsSetModelMeshMaterial );
+ assingGlobalFunction( "SetModelTransform", lmodelsSetModelTransform );
+ assingGlobalFunction( "GetModelTransform", lmodelsGetModelTransform );
+ /* Model drawing functions. */
+ assingGlobalFunction( "DrawModel", lmodelsDrawModel );
+ assingGlobalFunction( "DrawModelEx", lmodelsDrawModelEx );
+ assingGlobalFunction( "DrawModelWires", lmodelsDrawModelWires );
+ assingGlobalFunction( "DrawModelWiresEx", lmodelsDrawModelWiresEx );
+ assingGlobalFunction( "DrawBoundingBox", lmodelsDrawBoundingBox );
+ assingGlobalFunction( "DrawBillboard", lmodelsDrawBillboard );
+ assingGlobalFunction( "DrawBillboardRec", lmodelsDrawBillboardRec );
+ assingGlobalFunction( "DrawBillboardPro", lmodelsDrawBillboardPro );
+ /* Mesh management functions. */
+ assingGlobalFunction( "UpdateMesh", lmodelsUpdateMesh );
+ assingGlobalFunction( "UnloadMesh", lmodelsUnloadMesh );
+ assingGlobalFunction( "DrawMesh", lmodelsDrawMesh );
+ assingGlobalFunction( "DrawMeshInstanced", lmodelsDrawMeshInstanced );
+ assingGlobalFunction( "SetMeshColor", lmodelsSetMeshColor );
+ assingGlobalFunction( "ExportMesh", lmodelsExportMesh );
+ assingGlobalFunction( "GetMeshBoundingBox", lmodelsGetMeshBoundingBox );
+ assingGlobalFunction( "GenMeshTangents", lmodelsGenMeshTangents );
+ /* Mesh generation functions. */
assingGlobalFunction( "GenMeshPoly", lmodelsGenMeshPoly );
assingGlobalFunction( "GenMeshPlane", lmodelsGenMeshPlane );
assingGlobalFunction( "GenMeshCube", lmodelsGenMeshCube );
@@ -1891,15 +1919,8 @@ void luaRegister() {
assingGlobalFunction( "GenMeshKnot", lmodelsGenMeshKnot );
assingGlobalFunction( "GenMeshHeightmap", lmodelsGenMeshHeightmap );
assingGlobalFunction( "GenMeshCustom", lmodelsGenMeshCustom );
- assingGlobalFunction( "UpdateMesh", lmodelsUpdateMesh );
- assingGlobalFunction( "UnloadMesh", lmodelsUnloadMesh );
- assingGlobalFunction( "DrawMesh", lmodelsDrawMesh );
- assingGlobalFunction( "DrawMeshInstanced", lmodelsDrawMeshInstanced );
- assingGlobalFunction( "SetMeshColor", lmodelsSetMeshColor );
- assingGlobalFunction( "ExportMesh", lmodelsExportMesh );
- assingGlobalFunction( "GetMeshBoundingBox", lmodelsGetMeshBoundingBox );
- assingGlobalFunction( "GenMeshTangents", lmodelsGenMeshTangents );
- /* Material. */
+ /* Material management functions. */
+ assingGlobalFunction( "LoadMaterials", lmodelsLoadMaterials );
assingGlobalFunction( "GetMaterialDefault", lmodelsGetMaterialDefault );
assingGlobalFunction( "LoadMaterialDefault", lmodelsLoadMaterialDefault );
assingGlobalFunction( "CreateMaterial", lmodelsCreateMaterial );
@@ -1915,27 +1936,13 @@ void luaRegister() {
assingGlobalFunction( "GetMaterialValue", lmodelsGetMaterialValue );
assingGlobalFunction( "GetMaterialShader", lmodelsGetMaterialShader );
assingGlobalFunction( "GetMaterialParams", lmodelsGetMaterialParams );
- /* Model. */
- assingGlobalFunction( "LoadModel", lmodelsLoadModel );
- assingGlobalFunction( "LoadModelFromMesh", lmodelsLoadModelFromMesh );
- assingGlobalFunction( "IsModelReady", lmodelsIsModelReady );
- assingGlobalFunction( "UnloadModel", lmodelsUnloadModel );
- assingGlobalFunction( "DrawModel", lmodelsDrawModel );
- assingGlobalFunction( "DrawModelEx", lmodelsDrawModelEx );
- assingGlobalFunction( "SetModelMaterial", lmodelsSetModelMaterial );
- assingGlobalFunction( "SetModelMeshMaterial", lmodelsSetModelMeshMaterial );
- assingGlobalFunction( "DrawBillboard", lmodelsDrawBillboard );
- assingGlobalFunction( "DrawBillboardRec", lmodelsDrawBillboardRec );
- assingGlobalFunction( "DrawBillboardPro", lmodelsDrawBillboardPro );
- assingGlobalFunction( "SetModelTransform", lmodelsSetModelTransform );
- assingGlobalFunction( "GetModelTransform", lmodelsGetModelTransform );
- /* Animations. */
+ /* Model animations management functions. */
assingGlobalFunction( "LoadModelAnimations", lmodelsLoadModelAnimations );
assingGlobalFunction( "UpdateModelAnimation", lmodelsUpdateModelAnimation );
assingGlobalFunction( "IsModelAnimationValid", lmodelsIsModelAnimationValid );
assingGlobalFunction( "GetModelAnimationBoneCount", lmodelsGetModelAnimationBoneCount );
assingGlobalFunction( "GetModelAnimationFrameCount", lmodelsGetModelAnimationFrameCount );
- /* Collision. */
+ /* Collision detection functions. */
assingGlobalFunction( "CheckCollisionSpheres", lmodelsCheckCollisionSpheres );
assingGlobalFunction( "CheckCollisionBoxes", lmodelsCheckCollisionBoxes );
assingGlobalFunction( "CheckCollisionBoxSphere", lmodelsCheckCollisionBoxSphere );
diff --git a/src/models.c b/src/models.c
index 2db4b5b..9ff64d8 100644
--- a/src/models.c
+++ b/src/models.c
@@ -127,7 +127,7 @@ void DrawBillboardRecNoRatio( Camera camera, Texture2D texture, Rectangle source
}
/*
-## Models - Basic
+## Models - Basic geometric 3D shapes drawing functions
*/
/*
@@ -491,318 +491,311 @@ int lmodelsDrawGrid( lua_State *L ) {
}
/*
-## Models - Mesh
+## Models - Model management functions
*/
/*
-> mesh = RL.GenMeshPoly( int sides, float radius )
+> model = RL.LoadModel( string fileName )
-Generate polygonal mesh
+Load model from files (Meshes and materials)
-- Success return Mesh
+- Failure return nil
+- Success return Model
*/
-int lmodelsGenMeshPoly( lua_State *L ) {
- int sides = luaL_checkinteger( L, 1 );
- float radius = luaL_checknumber( L, 2 );
+int lmodelsLoadModel( lua_State *L ) {
+ if ( FileExists( luaL_checkstring( L, 1 ) ) ) {
+ uluaPushModel( L, LoadModel( lua_tostring( L, 1 ) ) );
- uluaPushMesh( L, GenMeshPoly( sides, radius ) );
+ return 1;
+ }
+ TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) );
+ lua_pushnil( L );
return 1;
}
/*
-> mesh = RL.GenMeshPlane( float width, float length, int resX, int resZ )
+> model = RL.LoadModelFromMesh( Mesh mesh )
-Generate plane mesh (With subdivisions)
+Load model from generated mesh (Default material)
-- Success return Mesh
+- Success return Model
*/
-int lmodelsGenMeshPlane( lua_State *L ) {
- float width = luaL_checknumber( L, 1 );
- float length = luaL_checknumber( L, 2 );
- int resX = luaL_checkinteger( L, 3 );
- int resZ = luaL_checkinteger( L, 4 );
+int lmodelsLoadModelFromMesh( lua_State *L ) {
+ Mesh *mesh = uluaGetMesh( L, 1 );
- uluaPushMesh( L, GenMeshPlane( width, length, resX, resZ ) );
+ uluaPushModel( L, LoadModelFromMesh( *mesh ) );
return 1;
}
/*
-> mesh = RL.GenMeshCube( Vector3 size )
+> isReady = RL.IsModelReady( Model model )
-Generate cuboid mesh
+Check if a model is ready
-- Success return Mesh
+- Success return bool
*/
-int lmodelsGenMeshCube( lua_State *L ) {
- Vector3 size = uluaGetVector3( L, 1 );
+int lmodelsIsModelReady( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
- uluaPushMesh( L, GenMeshCube( size.x, size.y, size.z ) );
+ lua_pushboolean( L, IsModelReady( *model ) );
return 1;
}
/*
-> mesh = RL.GenMeshSphere( float radius, int rings, int slices )
-
-Generate sphere mesh (Standard sphere)
+> RL.UnloadModel( Model model )
-- Success return Mesh
+Unload model (including meshes) from memory (RAM and/or VRAM)
*/
-int lmodelsGenMeshSphere( lua_State *L ) {
- float radius = luaL_checknumber( L, 1 );
- int rings = luaL_checkinteger( L, 2 );
- int slices = luaL_checkinteger( L, 3 );
+int lmodelsUnloadModel( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
- uluaPushMesh( L, GenMeshSphere( radius, rings, slices ) );
+ UnloadModel( *model );
- return 1;
+ return 0;
}
/*
-> mesh = RL.GenMeshCylinder( float radius, float height, int slices )
+> boundingBox = RL.GetModelBoundingBox( Model model )
-Generate cylinder mesh
+Compute model bounding box limits (considers all meshes)
-- Success return Mesh
+- Success return BoundingBox
*/
-int lmodelsGenMeshCylinder( lua_State *L ) {
- float radius = luaL_checknumber( L, 1 );
- float height = luaL_checknumber( L, 2 );
- int slices = luaL_checkinteger( L, 3 );
+int lmodelsGetModelBoundingBox( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
- uluaPushMesh( L, GenMeshCylinder( radius, height, slices ) );
+ uluaPushBoundingBox( L, GetModelBoundingBox( *model ) );
return 1;
}
/*
-> mesh = RL.GenMeshCone( float radius, float height, int slices )
-
-Generate cone/pyramid mesh
+> RL.SetModelMaterial( Model model, Material modelMaterial, Material material )
-- Success return Mesh
+Copies material to model material. (Model material is the material id in models.)
*/
-int lmodelsGenMeshCone( lua_State *L ) {
- float radius = luaL_checknumber( L, 1 );
- float height = luaL_checknumber( L, 2 );
- int slices = luaL_checkinteger( L, 3 );
+int lmodelsSetModelMaterial( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
+ int modelMaterialId = luaL_checkinteger( L, 2 );
+ Material *material = uluaGetMaterial( L, 3 );
- uluaPushMesh( L, GenMeshCone( radius, height, slices ) );
+ //TODO Could maybe return old shader and textures for storage or get garbage collected?
- return 1;
+ /* Copy material data instead of using pointer. Pointer would result in double free error. */
+ model->materials[ modelMaterialId ].shader = material->shader;
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_ALBEDO ] = material->maps[ MATERIAL_MAP_ALBEDO ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_METALNESS ] = material->maps[ MATERIAL_MAP_METALNESS ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_NORMAL ] = material->maps[ MATERIAL_MAP_NORMAL ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_ROUGHNESS ] = material->maps[ MATERIAL_MAP_ROUGHNESS ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_OCCLUSION ] = material->maps[ MATERIAL_MAP_OCCLUSION ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_EMISSION ] = material->maps[ MATERIAL_MAP_EMISSION ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_HEIGHT ] = material->maps[ MATERIAL_MAP_HEIGHT ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_CUBEMAP ] = material->maps[ MATERIAL_MAP_CUBEMAP ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_IRRADIANCE ] = material->maps[ MATERIAL_MAP_IRRADIANCE ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_PREFILTER ] = material->maps[ MATERIAL_MAP_PREFILTER ];
+ model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_BRDF ] = material->maps[ MATERIAL_MAP_BRDF ];
+
+ for ( int i = 0; i < 4; i++ ) {
+ model->materials[ modelMaterialId ].params[i] = material->params[i];
+ }
+
+ return 0;
}
/*
-> mesh = RL.GenMeshTorus( float radius, float size, int radSeg, int sides )
-
-Generate torus mesh
+> RL.SetModelMeshMaterial( Model model, int meshId, int materialId )
-- Success return Mesh
+Set material for a mesh (Mesh and material on this model)
*/
-int lmodelsGenMeshTorus( lua_State *L ) {
- float radius = luaL_checknumber( L, 1 );
- float size = luaL_checknumber( L, 2 );
- int radSeg = luaL_checkinteger( L, 3 );
- int sides = luaL_checkinteger( L, 4 );
+int lmodelsSetModelMeshMaterial( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
+ int meshId = luaL_checkinteger( L, 2 );
+ int materialId = luaL_checkinteger( L, 3 );
- uluaPushMesh( L, GenMeshTorus( radius, size, radSeg, sides ) );
+ SetModelMeshMaterial( model, meshId, materialId );
- return 1;
+ return 0;
}
/*
-> mesh = RL.GenMeshKnot( float radius, float size, int radSeg, int sides )
-
-Generate torus mesh
+> RL.SetModelTransform( Model model, Matrix transform )
-- Success return Mesh
+Set model transform matrix
*/
-int lmodelsGenMeshKnot( lua_State *L ) {
- float radius = luaL_checknumber( L, 1 );
- float size = luaL_checknumber( L, 2 );
- int radSeg = luaL_checkinteger( L, 3 );
- int sides = luaL_checkinteger( L, 4 );
+int lmodelsSetModelTransform( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
+ Matrix transform = uluaGetMatrix( L, 2 );
- uluaPushMesh( L, GenMeshKnot( radius, size, radSeg, sides ) );
+ model->transform = transform;
- return 1;
+ return 0;
}
/*
-> mesh = RL.GenMeshHeightmap( Image heightmap, Vector3 size )
+> transform = RL.GetModelTransform( Model model )
-Generate heightmap mesh from image data
+Get model transform matrix
-- Success return Mesh
+- Success return Matrix
*/
-int lmodelsGenMeshHeightmap( lua_State *L ) {
- Image *heightmap = uluaGetImage( L, 1 );
- Vector3 size = uluaGetVector3( L, 2 );
+int lmodelsGetModelTransform( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
- uluaPushMesh( L, GenMeshHeightmap( *heightmap, size ) );
+ uluaPushMatrix( L, model->transform );
return 1;
}
/*
-> mesh = RL.GenMeshCustom( Mesh{} meshData, bool dynamic )
+## Models - Model drawing functions
+*/
-Generate custom mesh from vertex attribute data and uploads it into a VAO (if supported) and VBO
+/*
+> RL.DrawModel( Model model, Vector3 position, float scale, Color tint )
-- Success return Mesh
+Draw a model (With texture if set)
*/
-int lmodelsGenMeshCustom( lua_State *L ) {
- luaL_checktype( L, 1, LUA_TTABLE );
- bool dynamic = uluaGetBoolean( L, 2 );
-
- Mesh mesh = { 0 };
+int lmodelsDrawModel( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
+ Vector3 position = uluaGetVector3( L, 2 );
+ float scale = luaL_checknumber( L, 3 );
+ Color tint = uluaGetColor( L, 4 );
- int t = 1;
- lua_pushnil( L );
+ DrawModel( *model, position, scale, tint );
- while ( lua_next( L, t ) != 0 ) {
- if ( strcmp( "vertices", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
- size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+ return 0;
+}
- mesh.vertexCount = len;
- mesh.triangleCount = len / 3;
- mesh.vertices = (float*)MemAlloc( len * 3 * sizeof(float) );
+/*
+> RL.DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
- int t2 = lua_gettop( L );
- int i = 0;
- lua_pushnil( L );
+Draw a model with extended parameters
+*/
+int lmodelsDrawModelEx( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
+ Vector3 position = uluaGetVector3( L, 2 );
+ Vector3 rotationAxis = uluaGetVector3( L, 3 );
+ float rotationAngle = luaL_checknumber( L, 4 );
+ Vector3 scale = uluaGetVector3( L, 5 );
+ Color tint = uluaGetColor( L, 6 );
- while ( lua_next( L, t2 ) != 0 ) {
- Vector3 vec = uluaGetVector3( L, lua_gettop( L ) );
+ DrawModelEx( *model, position, rotationAxis, rotationAngle, scale, tint );
- mesh.vertices[(i*3)+0] = vec.x;
- mesh.vertices[(i*3)+1] = vec.y;
- mesh.vertices[(i*3)+2] = vec.z;
- i++;
- lua_pop( L, 1 );
- }
- }
- else if ( strcmp( "texcoords", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
- size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+ return 0;
+}
- mesh.texcoords = (float*)MemAlloc( len * 2 * sizeof(float) );
+/*
+> RL.DrawModelWires( Model model, Vector3 position, float scale, Color tint )
- int t2 = lua_gettop( L );
- int i = 0;
- lua_pushnil( L );
+Draw a model wires (with texture if set)
+*/
+int lmodelsDrawModelWires( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
+ Vector3 position = uluaGetVector3( L, 2 );
+ float scale = luaL_checknumber( L, 3 );
+ Color tint = uluaGetColor( L, 4 );
- while ( lua_next( L, t2 ) != 0 ) {
- Vector2 vec = uluaGetVector2( L, lua_gettop( L ) );
+ DrawModelWires( *model, position, scale, tint );
- mesh.texcoords[(i*2)+0] = vec.x;
- mesh.texcoords[(i*2)+1] = vec.y;
- i++;
- lua_pop( L, 1 );
- }
- }
- else if ( strcmp( "texcoords2", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
- size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+ return 0;
+}
- mesh.texcoords2 = (float*)MemAlloc( len * 2 * sizeof(float) );
+/*
+> RL.DrawModelWiresEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
- int t2 = lua_gettop( L );
- int i = 0;
- lua_pushnil( L );
+Draw a model wires (with texture if set) with extended parameters
+*/
+int lmodelsDrawModelWiresEx( lua_State *L ) {
+ Model *model = uluaGetModel( L, 1 );
+ Vector3 position = uluaGetVector3( L, 2 );
+ Vector3 rotationAxis = uluaGetVector3( L, 3 );
+ float rotationAngle = luaL_checknumber( L, 4 );
+ Vector3 scale = uluaGetVector3( L, 5 );
+ Color tint = uluaGetColor( L, 6 );
- while ( lua_next( L, t2 ) != 0 ) {
- Vector2 vec = uluaGetVector2( L, lua_gettop( L ) );
+ DrawModelWiresEx( *model, position, rotationAxis, rotationAngle, scale, tint );
- mesh.texcoords2[(i*2)+0] = vec.x;
- mesh.texcoords2[(i*2)+1] = vec.y;
- i++;
- lua_pop( L, 1 );
- }
- }
- else if ( strcmp( "normals", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
- size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+ return 0;
+}
- mesh.normals = (float*)MemAlloc( len * 3 * sizeof(float) );
+/*
+> RL.DrawBoundingBox( BoundingBox box, Color color )
- int t2 = lua_gettop( L );
- int i = 0;
- lua_pushnil( L );
+Draw bounding box (wires)
+*/
+int lmodelsDrawBoundingBox( lua_State *L ) {
+ BoundingBox box = uluaGetBoundingBox( L, 1 );
+ Color color = uluaGetColor( L, 2 );
- while ( lua_next( L, t2 ) != 0 ) {
- Vector3 vec = uluaGetVector3( L, lua_gettop( L ) );
+ DrawBoundingBox( box, color );
- mesh.normals[(i*3)+0] = vec.x;
- mesh.normals[(i*3)+1] = vec.y;
- mesh.normals[(i*3)+2] = vec.z;
- i++;
- lua_pop( L, 1 );
- }
- }
- else if ( strcmp( "tangents", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
- size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+ return 0;
+}
- mesh.tangents = (float*)MemAlloc( len * 4 * sizeof(float) );
+/*
+> RL.DrawBillboard( Camera3D camera, Texture texture, Vector3 position, float size, Color tint )
- int t2 = lua_gettop( L );
- int i = 0;
- lua_pushnil( L );
+Draw a billboard texture
+*/
+int lmodelsDrawBillboard( lua_State *L ) {
+ Camera3D *camera = uluaGetCamera3D( L, 1 );
+ Texture *texture = uluaGetTexture( L, 2 );
+ Vector3 position = uluaGetVector3( L, 3 );
+ float size = luaL_checknumber( L, 4 );
+ Color tint = uluaGetColor( L, 5 );
- while ( lua_next( L, t2 ) != 0 ) {
- Vector4 vec = uluaGetVector4( L, lua_gettop( L ) );
+ DrawBillboard( *camera, *texture, position, size, tint );
- mesh.tangents[(i*4)+0] = vec.x;
- mesh.tangents[(i*4)+1] = vec.y;
- mesh.tangents[(i*4)+2] = vec.z;
- mesh.tangents[(i*4)+3] = vec.w;
- i++;
- lua_pop( L, 1 );
- }
- }
- else if ( strcmp( "colors", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
- size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+ return 0;
+}
- mesh.colors = (unsigned char*)MemAlloc( len * 4 * sizeof(unsigned char) );
+/*
+> RL.DrawBillboardRec( Camera3D camera, Texture texture, Rectangle source, Vector3 position, Vector2 size, Color tint )
- int t2 = lua_gettop( L );
- int i = 0;
- lua_pushnil( L );
+Draw a billboard texture defined by source
+*/
+int lmodelsDrawBillboardRec( lua_State *L ) {
+ Camera3D *camera = uluaGetCamera3D( L, 1 );
+ Texture *texture = uluaGetTexture( L, 2 );
+ Rectangle source = uluaGetRectangle( L, 3 );
+ Vector3 position = uluaGetVector3( L, 4 );
+ Vector2 size = uluaGetVector2( L, 5 );
+ Color tint = uluaGetColor( L, 6 );
- while ( lua_next( L, t2 ) != 0 ) {
- Color color = uluaGetColor( L, lua_gettop( L ) );
+ DrawBillboardRecNoRatio( *camera, *texture, source, position, size, tint );
- mesh.colors[(i*4)+0] = color.r;
- mesh.colors[(i*4)+1] = color.g;
- mesh.colors[(i*4)+2] = color.b;
- mesh.colors[(i*4)+3] = color.a;
- i++;
- lua_pop( L, 1 );
- }
- }
- else if ( strcmp( "indices", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
- size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+ return 0;
+}
- mesh.indices = (unsigned short*)MemAlloc( len * sizeof(unsigned short) );
+/*
+> RL.DrawBillboardPro( Camera3D camera, Texture texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint )
- int t2 = lua_gettop( L );
- int i = 0;
- lua_pushnil( L );
+Draw a billboard texture defined by source and rotation
+*/
+int lmodelsDrawBillboardPro( lua_State *L ) {
+ Camera3D *camera = uluaGetCamera3D( L, 1 );
+ Texture *texture = uluaGetTexture( L, 2 );
+ Rectangle source = uluaGetRectangle( L, 3 );
+ Vector3 position = uluaGetVector3( L, 4 );
+ Vector3 up = uluaGetVector3( L, 5 );
+ Vector2 size = uluaGetVector2( L, 6 );
+ Vector2 origin = uluaGetVector2( L, 7 );
+ float rotation = luaL_checknumber( L, 8 );
+ Color tint = uluaGetColor( L, 9 );
- while ( lua_next( L, t2 ) != 0 ) {
- mesh.indices[i] = (unsigned short)lua_tointeger( L, -1 );
- i++;
- lua_pop( L, 1 );
- }
- }
- lua_pop( L, 1 );
- }
- UploadMesh( &mesh, dynamic );
- uluaPushMesh( L, mesh );
+ DrawBillboardProNoRatio( *camera, *texture, source, position, up, size, origin, rotation, tint );
- return 1;
+ return 0;
}
/*
+## Models - Mesh management functions
+*/
+
+/*
> RL.UpdateMesh( Mesh mesh, Mesh{} meshData )
Update mesh vertex data in GPU.
@@ -1060,10 +1053,359 @@ int lmodelsGenMeshTangents( lua_State *L ) {
}
/*
-## Models - Material
+## Models - Mesh generation functions
*/
/*
+> mesh = RL.GenMeshPoly( int sides, float radius )
+
+Generate polygonal mesh
+
+- Success return Mesh
+*/
+int lmodelsGenMeshPoly( lua_State *L ) {
+ int sides = luaL_checkinteger( L, 1 );
+ float radius = luaL_checknumber( L, 2 );
+
+ uluaPushMesh( L, GenMeshPoly( sides, radius ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshPlane( float width, float length, int resX, int resZ )
+
+Generate plane mesh (With subdivisions)
+
+- Success return Mesh
+*/
+int lmodelsGenMeshPlane( lua_State *L ) {
+ float width = luaL_checknumber( L, 1 );
+ float length = luaL_checknumber( L, 2 );
+ int resX = luaL_checkinteger( L, 3 );
+ int resZ = luaL_checkinteger( L, 4 );
+
+ uluaPushMesh( L, GenMeshPlane( width, length, resX, resZ ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshCube( Vector3 size )
+
+Generate cuboid mesh
+
+- Success return Mesh
+*/
+int lmodelsGenMeshCube( lua_State *L ) {
+ Vector3 size = uluaGetVector3( L, 1 );
+
+ uluaPushMesh( L, GenMeshCube( size.x, size.y, size.z ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshSphere( float radius, int rings, int slices )
+
+Generate sphere mesh (Standard sphere)
+
+- Success return Mesh
+*/
+int lmodelsGenMeshSphere( lua_State *L ) {
+ float radius = luaL_checknumber( L, 1 );
+ int rings = luaL_checkinteger( L, 2 );
+ int slices = luaL_checkinteger( L, 3 );
+
+ uluaPushMesh( L, GenMeshSphere( radius, rings, slices ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshCylinder( float radius, float height, int slices )
+
+Generate cylinder mesh
+
+- Success return Mesh
+*/
+int lmodelsGenMeshCylinder( lua_State *L ) {
+ float radius = luaL_checknumber( L, 1 );
+ float height = luaL_checknumber( L, 2 );
+ int slices = luaL_checkinteger( L, 3 );
+
+ uluaPushMesh( L, GenMeshCylinder( radius, height, slices ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshCone( float radius, float height, int slices )
+
+Generate cone/pyramid mesh
+
+- Success return Mesh
+*/
+int lmodelsGenMeshCone( lua_State *L ) {
+ float radius = luaL_checknumber( L, 1 );
+ float height = luaL_checknumber( L, 2 );
+ int slices = luaL_checkinteger( L, 3 );
+
+ uluaPushMesh( L, GenMeshCone( radius, height, slices ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshTorus( float radius, float size, int radSeg, int sides )
+
+Generate torus mesh
+
+- Success return Mesh
+*/
+int lmodelsGenMeshTorus( lua_State *L ) {
+ float radius = luaL_checknumber( L, 1 );
+ float size = luaL_checknumber( L, 2 );
+ int radSeg = luaL_checkinteger( L, 3 );
+ int sides = luaL_checkinteger( L, 4 );
+
+ uluaPushMesh( L, GenMeshTorus( radius, size, radSeg, sides ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshKnot( float radius, float size, int radSeg, int sides )
+
+Generate torus mesh
+
+- Success return Mesh
+*/
+int lmodelsGenMeshKnot( lua_State *L ) {
+ float radius = luaL_checknumber( L, 1 );
+ float size = luaL_checknumber( L, 2 );
+ int radSeg = luaL_checkinteger( L, 3 );
+ int sides = luaL_checkinteger( L, 4 );
+
+ uluaPushMesh( L, GenMeshKnot( radius, size, radSeg, sides ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshHeightmap( Image heightmap, Vector3 size )
+
+Generate heightmap mesh from image data
+
+- Success return Mesh
+*/
+int lmodelsGenMeshHeightmap( lua_State *L ) {
+ Image *heightmap = uluaGetImage( L, 1 );
+ Vector3 size = uluaGetVector3( L, 2 );
+
+ uluaPushMesh( L, GenMeshHeightmap( *heightmap, size ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshCubicmap( Image cubicmap, Vector3 cubeSize )
+
+Generate cubes-based map mesh from image data
+
+- Success return Mesh
+*/
+int lmodelsGenMeshCubicmap( lua_State *L ) {
+ Image *cubicmap = uluaGetImage( L, 1 );
+ Vector3 cubeSize = uluaGetVector3( L, 2 );
+
+ uluaPushMesh( L, GenMeshCubicmap( *cubicmap, cubeSize ) );
+
+ return 1;
+}
+
+/*
+> mesh = RL.GenMeshCustom( Mesh{} meshData, bool dynamic )
+
+Generate custom mesh from vertex attribute data and uploads it into a VAO (if supported) and VBO
+
+- Success return Mesh
+*/
+int lmodelsGenMeshCustom( lua_State *L ) {
+ luaL_checktype( L, 1, LUA_TTABLE );
+ bool dynamic = uluaGetBoolean( L, 2 );
+
+ Mesh mesh = { 0 };
+
+ int t = 1;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t ) != 0 ) {
+ if ( strcmp( "vertices", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
+ size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+
+ mesh.vertexCount = len;
+ mesh.triangleCount = len / 3;
+ mesh.vertices = (float*)MemAlloc( len * 3 * sizeof(float) );
+
+ int t2 = lua_gettop( L );
+ int i = 0;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t2 ) != 0 ) {
+ Vector3 vec = uluaGetVector3( L, lua_gettop( L ) );
+
+ mesh.vertices[(i*3)+0] = vec.x;
+ mesh.vertices[(i*3)+1] = vec.y;
+ mesh.vertices[(i*3)+2] = vec.z;
+ i++;
+ lua_pop( L, 1 );
+ }
+ }
+ else if ( strcmp( "texcoords", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
+ size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+
+ mesh.texcoords = (float*)MemAlloc( len * 2 * sizeof(float) );
+
+ int t2 = lua_gettop( L );
+ int i = 0;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t2 ) != 0 ) {
+ Vector2 vec = uluaGetVector2( L, lua_gettop( L ) );
+
+ mesh.texcoords[(i*2)+0] = vec.x;
+ mesh.texcoords[(i*2)+1] = vec.y;
+ i++;
+ lua_pop( L, 1 );
+ }
+ }
+ else if ( strcmp( "texcoords2", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
+ size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+
+ mesh.texcoords2 = (float*)MemAlloc( len * 2 * sizeof(float) );
+
+ int t2 = lua_gettop( L );
+ int i = 0;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t2 ) != 0 ) {
+ Vector2 vec = uluaGetVector2( L, lua_gettop( L ) );
+
+ mesh.texcoords2[(i*2)+0] = vec.x;
+ mesh.texcoords2[(i*2)+1] = vec.y;
+ i++;
+ lua_pop( L, 1 );
+ }
+ }
+ else if ( strcmp( "normals", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
+ size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+
+ mesh.normals = (float*)MemAlloc( len * 3 * sizeof(float) );
+
+ int t2 = lua_gettop( L );
+ int i = 0;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t2 ) != 0 ) {
+ Vector3 vec = uluaGetVector3( L, lua_gettop( L ) );
+
+ mesh.normals[(i*3)+0] = vec.x;
+ mesh.normals[(i*3)+1] = vec.y;
+ mesh.normals[(i*3)+2] = vec.z;
+ i++;
+ lua_pop( L, 1 );
+ }
+ }
+ else if ( strcmp( "tangents", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
+ size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+
+ mesh.tangents = (float*)MemAlloc( len * 4 * sizeof(float) );
+
+ int t2 = lua_gettop( L );
+ int i = 0;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t2 ) != 0 ) {
+ Vector4 vec = uluaGetVector4( L, lua_gettop( L ) );
+
+ mesh.tangents[(i*4)+0] = vec.x;
+ mesh.tangents[(i*4)+1] = vec.y;
+ mesh.tangents[(i*4)+2] = vec.z;
+ mesh.tangents[(i*4)+3] = vec.w;
+ i++;
+ lua_pop( L, 1 );
+ }
+ }
+ else if ( strcmp( "colors", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
+ size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+
+ mesh.colors = (unsigned char*)MemAlloc( len * 4 * sizeof(unsigned char) );
+
+ int t2 = lua_gettop( L );
+ int i = 0;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t2 ) != 0 ) {
+ Color color = uluaGetColor( L, lua_gettop( L ) );
+
+ mesh.colors[(i*4)+0] = color.r;
+ mesh.colors[(i*4)+1] = color.g;
+ mesh.colors[(i*4)+2] = color.b;
+ mesh.colors[(i*4)+3] = color.a;
+ i++;
+ lua_pop( L, 1 );
+ }
+ }
+ else if ( strcmp( "indices", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
+ size_t len = uluaGetTableLen( L, lua_gettop( L ) );
+
+ mesh.indices = (unsigned short*)MemAlloc( len * sizeof(unsigned short) );
+
+ int t2 = lua_gettop( L );
+ int i = 0;
+ lua_pushnil( L );
+
+ while ( lua_next( L, t2 ) != 0 ) {
+ mesh.indices[i] = (unsigned short)lua_tointeger( L, -1 );
+ i++;
+ lua_pop( L, 1 );
+ }
+ }
+ lua_pop( L, 1 );
+ }
+ UploadMesh( &mesh, dynamic );
+ uluaPushMesh( L, mesh );
+
+ return 1;
+}
+
+/*
+## Models - Material management functions
+*/
+
+/*
+> materials = RL.LoadMaterials( string fileName )
+
+Load materials from model file
+
+- Success return Material{}
+*/
+int lmodelsLoadMaterials( lua_State *L ) {
+ const char *fileName = luaL_checkstring( L, 1 );
+
+ int materialCount = 0;
+ Material *materials = LoadMaterials( fileName, &materialCount );
+ lua_createtable( L, materialCount, 0 );
+
+ for ( int i = 0; i < materialCount; i++ ) {
+ uluaPushMaterial( L, materials[i] );
+ lua_rawseti( L, -2, i + 1 );
+ }
+ return 1;
+}
+
+/*
> material = RL.GetMaterialDefault()
Default material for reference. Return as lightuserdata
@@ -1379,241 +1721,7 @@ int lmodelsGetMaterialParams( lua_State *L ) {
}
/*
-## Models - Model
-*/
-
-/*
-> model = RL.LoadModel( string fileName )
-
-Load model from files (Meshes and materials)
-
-- Failure return nil
-- Success return Model
-*/
-int lmodelsLoadModel( lua_State *L ) {
- if ( FileExists( luaL_checkstring( L, 1 ) ) ) {
- uluaPushModel( L, LoadModel( lua_tostring( L, 1 ) ) );
-
- return 1;
- }
- TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) );
- lua_pushnil( L );
-
- return 1;
-}
-
-/*
-> model = RL.LoadModelFromMesh( Mesh mesh )
-
-Load model from generated mesh (Default material)
-
-- Success return Model
-*/
-int lmodelsLoadModelFromMesh( lua_State *L ) {
- Mesh *mesh = uluaGetMesh( L, 1 );
-
- uluaPushModel( L, LoadModelFromMesh( *mesh ) );
-
- return 1;
-}
-
-/*
-> isReady = RL.IsModelReady( Model model )
-
-Check if a model is ready
-
-- Success return bool
-*/
-int lmodelsIsModelReady( lua_State *L ) {
- Model *model = uluaGetModel( L, 1 );
-
- lua_pushboolean( L, IsModelReady( *model ) );
-
- return 1;
-}
-
-/*
-> RL.UnloadModel( Model model )
-
-Unload model (including meshes) from memory (RAM and/or VRAM)
-*/
-int lmodelsUnloadModel( lua_State *L ) {
- Model *model = uluaGetModel( L, 1 );
-
- UnloadModel( *model );
-
- return 0;
-}
-
-/*
-> RL.DrawModel( Model model, Vector3 position, float scale, Color tint )
-
-Draw a model (With texture if set)
-*/
-int lmodelsDrawModel( lua_State *L ) {
- Model *model = uluaGetModel( L, 1 );
- Vector3 position = uluaGetVector3( L, 2 );
- float scale = luaL_checknumber( L, 3 );
- Color tint = uluaGetColor( L, 4 );
-
- DrawModel( *model, position, scale, tint );
-
- return 0;
-}
-
-/*
-> RL.DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
-
-Draw a model with extended parameters
-*/
-int lmodelsDrawModelEx( lua_State *L ) {
- Model *model = uluaGetModel( L, 1 );
- Vector3 position = uluaGetVector3( L, 2 );
- Vector3 rotationAxis = uluaGetVector3( L, 3 );
- float rotationAngle = luaL_checknumber( L, 4 );
- Vector3 scale = uluaGetVector3( L, 5 );
- Color tint = uluaGetColor( L, 6 );
-
- DrawModelEx( *model, position, rotationAxis, rotationAngle, scale, tint );
-
- return 0;
-}
-
-/*
-> RL.SetModelMaterial( Model model, Material modelMaterial, Material material )
-
-Copies material to model material. (Model material is the material id in models.)
-*/
-int lmodelsSetModelMaterial( lua_State *L ) {
- Model *model = uluaGetModel( L, 1 );
- int modelMaterialId = luaL_checkinteger( L, 2 );
- Material *material = uluaGetMaterial( L, 3 );
-
- //TODO Could maybe return old shader and textures for storage or get garbage collected?
-
- /* Copy material data instead of using pointer. Pointer would result in double free error. */
- model->materials[ modelMaterialId ].shader = material->shader;
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_ALBEDO ] = material->maps[ MATERIAL_MAP_ALBEDO ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_METALNESS ] = material->maps[ MATERIAL_MAP_METALNESS ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_NORMAL ] = material->maps[ MATERIAL_MAP_NORMAL ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_ROUGHNESS ] = material->maps[ MATERIAL_MAP_ROUGHNESS ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_OCCLUSION ] = material->maps[ MATERIAL_MAP_OCCLUSION ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_EMISSION ] = material->maps[ MATERIAL_MAP_EMISSION ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_HEIGHT ] = material->maps[ MATERIAL_MAP_HEIGHT ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_CUBEMAP ] = material->maps[ MATERIAL_MAP_CUBEMAP ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_IRRADIANCE ] = material->maps[ MATERIAL_MAP_IRRADIANCE ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_PREFILTER ] = material->maps[ MATERIAL_MAP_PREFILTER ];
- model->materials[ modelMaterialId ].maps[ MATERIAL_MAP_BRDF ] = material->maps[ MATERIAL_MAP_BRDF ];
-
- for ( int i = 0; i < 4; i++ ) {
- model->materials[ modelMaterialId ].params[i] = material->params[i];
- }
-
- return 0;
-}
-
-/*
-> RL.SetModelMeshMaterial( Model model, int meshId, int materialId )
-
-Set material for a mesh (Mesh and material on this model)
-*/
-int lmodelsSetModelMeshMaterial( lua_State *L ) {
- Model *model = uluaGetModel( L, 1 );
- int meshId = luaL_checkinteger( L, 2 );
- int materialId = luaL_checkinteger( L, 3 );
-
- SetModelMeshMaterial( model, meshId, materialId );
-
- return 0;
-}
-
-/*
-> RL.DrawBillboard( Camera3D camera, Texture texture, Vector3 position, float size, Color tint )
-
-Draw a billboard texture
-*/
-int lmodelsDrawBillboard( lua_State *L ) {
- Camera3D *camera = uluaGetCamera3D( L, 1 );
- Texture *texture = uluaGetTexture( L, 2 );
- Vector3 position = uluaGetVector3( L, 3 );
- float size = luaL_checknumber( L, 4 );
- Color tint = uluaGetColor( L, 5 );
-
- DrawBillboard( *camera, *texture, position, size, tint );
-
- return 0;
-}
-
-/*
-> RL.DrawBillboardRec( Camera3D camera, Texture texture, Rectangle source, Vector3 position, Vector2 size, Color tint )
-
-Draw a billboard texture defined by source
-*/
-int lmodelsDrawBillboardRec( lua_State *L ) {
- Camera3D *camera = uluaGetCamera3D( L, 1 );
- Texture *texture = uluaGetTexture( L, 2 );
- Rectangle source = uluaGetRectangle( L, 3 );
- Vector3 position = uluaGetVector3( L, 4 );
- Vector2 size = uluaGetVector2( L, 5 );
- Color tint = uluaGetColor( L, 6 );
-
- DrawBillboardRecNoRatio( *camera, *texture, source, position, size, tint );
-
- return 0;
-}
-
-/*
-> RL.DrawBillboardPro( Camera3D camera, Texture texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint )
-
-Draw a billboard texture defined by source and rotation
-*/
-int lmodelsDrawBillboardPro( lua_State *L ) {
- Camera3D *camera = uluaGetCamera3D( L, 1 );
- Texture *texture = uluaGetTexture( L, 2 );
- Rectangle source = uluaGetRectangle( L, 3 );
- Vector3 position = uluaGetVector3( L, 4 );
- Vector3 up = uluaGetVector3( L, 5 );
- Vector2 size = uluaGetVector2( L, 6 );
- Vector2 origin = uluaGetVector2( L, 7 );
- float rotation = luaL_checknumber( L, 8 );
- Color tint = uluaGetColor( L, 9 );
-
- DrawBillboardProNoRatio( *camera, *texture, source, position, up, size, origin, rotation, tint );
-
- return 0;
-}
-
-/*
-> RL.SetModelTransform( Model model, Matrix transform )
-
-Set model transform matrix
-*/
-int lmodelsSetModelTransform( lua_State *L ) {
- Model *model = uluaGetModel( L, 1 );
- Matrix transform = uluaGetMatrix( L, 2 );
-
- model->transform = transform;
-
- return 0;
-}
-
-/*
-> transform = RL.GetModelTransform( Model model )
-
-Get model transform matrix
-
-- Success return Matrix
-*/
-int lmodelsGetModelTransform( lua_State *L ) {
- Model *model = uluaGetModel( L, 1 );
-
- uluaPushMatrix( L, model->transform );
-
- return 1;
-}
-
-/*
-## Model - Animations
+## Model - Model animations management functions
*/
/*
@@ -1706,7 +1814,7 @@ int lmodelsGetModelAnimationFrameCount( lua_State *L ) {
}
/*
-## Model - Collision
+## Model - Collision detection functions
*/
/*
diff --git a/src/text.c b/src/text.c
index 205ad30..b72f9cd 100644
--- a/src/text.c
+++ b/src/text.c
@@ -395,7 +395,7 @@ int ltextDrawTextCodepoints( lua_State *L ) {
/*
> mouseCharId = RL.DrawTextBoxed(Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint )
-Draw text using font inside rectangle limits. Return character from mouse position. Function from raylib [text] example - Rectangle bounds.
+Draw text using font inside rectangle limits. Return character id from mouse position (default -1). Function from raylib [text] example - Rectangle bounds.
- Success return int
*/
@@ -416,7 +416,7 @@ int ltextDrawTextBoxed( lua_State *L ) {
/*
> mouseCharId = RL.DrawTextBoxedTinted( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tints, Color backTints )
-Draw text using font inside rectangle limits with support for tint and background tint for each character. Return character from mouse position
+Draw text using font inside rectangle limits with support for tint and background tint for each character. Return character id from mouse position (default -1)
- Success return int
*/