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,7 +6261,189 @@ Draw a grid (Centered at ( 0, 0, 0 )) --- -## Models - Mesh +## Models - Model management functions + +--- + +> model = RL.LoadModel( string fileName ) + +Load model from files (Meshes and materials) + +- Failure return nil +- Success return Model + +--- + +> model = RL.LoadModelFromMesh( Mesh mesh ) + +Load model from generated mesh (Default material) + +- Success return Model + +--- + +> isReady = RL.IsModelReady( Model model ) + +Check if a model is ready + +- Success return bool + +--- + +> RL.UnloadModel( Model model ) + +Unload model (including meshes) from memory (RAM and/or VRAM) + +--- + +> boundingBox = RL.GetModelBoundingBox( Model model ) + +Compute model bounding box limits (considers all meshes) + +- Success return BoundingBox + +--- + +> RL.SetModelMaterial( Model model, Material modelMaterial, Material material ) + +Copies material to model material. (Model material is the material id in models.) + +--- + +> RL.SetModelMeshMaterial( Model model, int meshId, int materialId ) + +Set material for a mesh (Mesh and material on this model) + +--- + +> RL.SetModelTransform( Model model, Matrix transform ) + +Set model transform matrix + +--- + +> transform = RL.GetModelTransform( Model model ) + +Get model transform matrix + +- Success return Matrix + +--- + +## Models - Model drawing functions + +--- + +> RL.DrawModel( Model model, Vector3 position, float scale, Color tint ) + +Draw a model (With texture if set) + +--- + +> RL.DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint ) + +Draw a model with extended parameters + +--- + +> RL.DrawModelWires( Model model, Vector3 position, float scale, Color tint ) + +Draw a model wires (with texture if set) + +--- + +> RL.DrawModelWiresEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint ) + +Draw a model wires (with texture if set) with extended parameters + +--- + +> RL.DrawBoundingBox( BoundingBox box, Color color ) + +Draw bounding box (wires) + +--- + +> RL.DrawBillboard( Camera3D camera, Texture texture, Vector3 position, float size, Color tint ) + +Draw a billboard texture + +--- + +> 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 + +--- + +> RL.UpdateMesh( Mesh mesh, Mesh{} meshData ) + +Update mesh vertex data in GPU. +Note! Mainly intented to be used with custom meshes. + +--- + +> RL.UnloadMesh( Mesh mesh ) + +Unload mesh data from CPU and GPU + +--- + +> RL.DrawMesh( Mesh mesh, Material material, Matrix transform ) + +Draw a 3d mesh with material and transform + +--- + +> RL.DrawMeshInstanced( Mesh mesh, Material material, Matrix{} transforms, int instances ) + +Draw multiple mesh instances with material and different transforms + +--- + +> success = RL.SetMeshColor( Mesh mesh, Color color ) + +Updades mesh color vertex attribute buffer +NOTE: Currently only works on custom mesh + +- Failure return false +- Success return true + +--- + +> success = RL.ExportMesh( Mesh mesh, string fileName ) + +Export mesh data to file, returns true on success + +- Success return bool + +--- + +> boundingBox = RL.GetMeshBoundingBox( Mesh mesh ) + +Compute mesh bounding box limits + +- Success return BoundingBox + +--- + +> RL.GenMeshTangents( Mesh mesh ) + +Compute mesh tangents + +--- + +## Models - Mesh generation functions --- @@ -6337,6 +6519,14 @@ Generate heightmap mesh from image data --- +> mesh = RL.GenMeshCubicmap( Image cubicmap, Vector3 cubeSize ) + +Generate cubes-based map mesh from image data + +- Success return Mesh + +--- + > mesh = RL.GenMeshCustom( Mesh{} meshData, bool dynamic ) Generate custom mesh from vertex attribute data and uploads it into a VAO (if supported) and VBO @@ -6345,64 +6535,15 @@ Generate custom mesh from vertex attribute data and uploads it into a VAO (if su --- -> RL.UpdateMesh( Mesh mesh, Mesh{} meshData ) - -Update mesh vertex data in GPU. -Note! Mainly intented to be used with custom meshes. +## Models - Material management functions --- -> RL.UnloadMesh( Mesh mesh ) +> materials = RL.LoadMaterials( string fileName ) -Unload mesh data from CPU and GPU +Load materials from model file ---- - -> RL.DrawMesh( Mesh mesh, Material material, Matrix transform ) - -Draw a 3d mesh with material and transform - ---- - -> RL.DrawMeshInstanced( Mesh mesh, Material material, Matrix{} transforms, int instances ) - -Draw multiple mesh instances with material and different transforms - ---- - -> success = RL.SetMeshColor( Mesh mesh, Color color ) - -Updades mesh color vertex attribute buffer -NOTE: Currently only works on custom mesh - -- Failure return false -- Success return true - ---- - -> success = RL.ExportMesh( Mesh mesh, string fileName ) - -Export mesh data to file, returns true on success - -- Success return bool - ---- - -> boundingBox = RL.GetMeshBoundingBox( Mesh mesh ) - -Compute mesh bounding box limits - -- Success return BoundingBox - ---- - -> RL.GenMeshTangents( Mesh mesh ) - -Compute mesh tangents - ---- - -## Models - Material +- Success return Material{} --- @@ -6514,98 +6655,7 @@ Get material parameters --- -## Models - Model - ---- - -> model = RL.LoadModel( string fileName ) - -Load model from files (Meshes and materials) - -- Failure return nil -- Success return Model - ---- - -> model = RL.LoadModelFromMesh( Mesh mesh ) - -Load model from generated mesh (Default material) - -- Success return Model - ---- - -> isReady = RL.IsModelReady( Model model ) - -Check if a model is ready - -- Success return bool - ---- - -> RL.UnloadModel( Model model ) - -Unload model (including meshes) from memory (RAM and/or VRAM) - ---- - -> RL.DrawModel( Model model, Vector3 position, float scale, Color tint ) - -Draw a model (With texture if set) - ---- - -> RL.DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint ) - -Draw a model with extended parameters - ---- - -> RL.SetModelMaterial( Model model, Material modelMaterial, Material material ) - -Copies material to model material. (Model material is the material id in models.) - ---- - -> RL.SetModelMeshMaterial( Model model, int meshId, int materialId ) - -Set material for a mesh (Mesh and material on this model) - ---- - -> RL.DrawBillboard( Camera3D camera, Texture texture, Vector3 position, float size, Color tint ) - -Draw a billboard texture - ---- - -> 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 - ---- - -> RL.SetModelTransform( Model model, Matrix transform ) - -Set model transform matrix - ---- - -> transform = RL.GetModelTransform( Model model ) - -Get model transform matrix - -- Success return Matrix - ---- - -## 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 +-- Models - Material management functions ----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 +---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,317 +491,310 @@ 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; -} - -/* -> 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.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; + return 1; + } + TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 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 ) ); + return 1; +} - mesh.vertexCount = len; - mesh.triangleCount = len / 3; - mesh.vertices = (float*)MemAlloc( len * 3 * sizeof(float) ); +/* +> model = RL.LoadModelFromMesh( Mesh mesh ) - int t2 = lua_gettop( L ); - int i = 0; - lua_pushnil( L ); +Load model from generated mesh (Default material) - while ( lua_next( L, t2 ) != 0 ) { - Vector3 vec = uluaGetVector3( L, lua_gettop( L ) ); +- Success return Model +*/ +int lmodelsLoadModelFromMesh( lua_State *L ) { + Mesh *mesh = uluaGetMesh( L, 1 ); - 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 ); + 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; +} + +/* +> boundingBox = RL.GetModelBoundingBox( Model model ) + +Compute model bounding box limits (considers all meshes) + +- Success return BoundingBox +*/ +int lmodelsGetModelBoundingBox( lua_State *L ) { + Model *model = uluaGetModel( L, 1 ); + + uluaPushBoundingBox( L, GetModelBoundingBox( *model ) ); + + return 1; +} + +/* +> 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.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; +} + +/* +## Models - Model drawing functions +*/ + +/* +> 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.DrawModelWires( Model model, Vector3 position, float scale, Color tint ) + +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 ); + + DrawModelWires( *model, position, scale, tint ); + + return 0; +} + +/* +> RL.DrawModelWiresEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint ) + +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 ); + + DrawModelWiresEx( *model, position, rotationAxis, rotationAngle, scale, tint ); + + return 0; +} + +/* +> RL.DrawBoundingBox( BoundingBox box, Color color ) + +Draw bounding box (wires) +*/ +int lmodelsDrawBoundingBox( lua_State *L ) { + BoundingBox box = uluaGetBoundingBox( L, 1 ); + Color color = uluaGetColor( L, 2 ); + + DrawBoundingBox( box, color ); + + 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; +} + +/* +## Models - Mesh management functions +*/ + /* > RL.UpdateMesh( Mesh mesh, Mesh{} meshData ) @@ -1060,9 +1053,358 @@ 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() @@ -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 */