DrawGridEx.
This commit is contained in:
6
API.md
6
API.md
@@ -7310,6 +7310,12 @@ Draw a grid (Centered at ( 0, 0, 0 ))
|
||||
|
||||
---
|
||||
|
||||
> RL.DrawGridEx( Vector2 slices, Vector2 spacing, Matrix transform, Color color, Vector2|nil divider, Color|nil dividerColor )
|
||||
|
||||
Draw a grid with extended parameters. Optionally you can define divider with different color for every n slices
|
||||
|
||||
---
|
||||
|
||||
## Models - Model management functions
|
||||
|
||||
---
|
||||
|
||||
@@ -4495,6 +4495,16 @@ function RL.DrawRay( ray, color ) end
|
||||
---@return any RL.DrawGrid
|
||||
function RL.DrawGrid( slices, spacing ) end
|
||||
|
||||
---Draw a grid with extended parameters. Optionally you can define divider with different color for every n slices
|
||||
---@param slices table
|
||||
---@param spacing table
|
||||
---@param transform table
|
||||
---@param color table
|
||||
---@param divider table|nil
|
||||
---@param dividerColor table|nil
|
||||
---@return any RL.DrawGridEx
|
||||
function RL.DrawGridEx( slices, spacing, transform, color, divider, dividerColor ) end
|
||||
|
||||
-- Models - Model management functions
|
||||
|
||||
---Load model from files (Meshes and materials)
|
||||
|
||||
@@ -65,6 +65,7 @@ DETAILED CHANGES:
|
||||
- FIXED: ColorToInt cast to unsigned int.
|
||||
- ADDED: Many Gui controls accept now nil for text.
|
||||
- ADDED: Some raygui controls return 1 instead of 0 when pressed or scrolled.
|
||||
- ADDED: DrawGridEx.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
||||
|
||||
@@ -27,6 +27,7 @@ int lmodelsDrawPlane( lua_State* L );
|
||||
int lmodelDrawQuad3DTexture( lua_State* L );
|
||||
int lmodelsDrawRay( lua_State* L );
|
||||
int lmodelsDrawGrid( lua_State* L );
|
||||
int lmodelsDrawGridEx( lua_State* L );
|
||||
/* Model management functions. */
|
||||
int lmodelsLoadModel( lua_State* L );
|
||||
int lmodelsLoadModelFromMesh( lua_State* L );
|
||||
|
||||
@@ -1726,6 +1726,7 @@ void luaRegister() {
|
||||
assingGlobalFunction( "DrawQuad3DTexture", lmodelDrawQuad3DTexture );
|
||||
assingGlobalFunction( "DrawRay", lmodelsDrawRay );
|
||||
assingGlobalFunction( "DrawGrid", lmodelsDrawGrid );
|
||||
assingGlobalFunction( "DrawGridEx", lmodelsDrawGridEx );
|
||||
/* Model management functions. */
|
||||
assingGlobalFunction( "LoadModel", lmodelsLoadModel );
|
||||
assingGlobalFunction( "LoadModelFromMesh", lmodelsLoadModelFromMesh );
|
||||
|
||||
52
src/models.c
52
src/models.c
@@ -496,6 +496,58 @@ int lmodelsDrawGrid( lua_State* L ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL.DrawGridEx( Vector2 slices, Vector2 spacing, Matrix transform, Color color, Vector2|nil divider, Color|nil dividerColor )
|
||||
|
||||
Draw a grid with extended parameters. Optionally you can define divider with different color for every n slices
|
||||
*/
|
||||
int lmodelsDrawGridEx( lua_State* L ) {
|
||||
Vector2 slices = uluaGetVector2( L, 1 );
|
||||
Vector2 spacing = uluaGetVector2( L, 2 );
|
||||
Matrix transform = uluaGetMatrix( L, 3 );
|
||||
Color color = uluaGetColor( L, 4 );
|
||||
|
||||
Vector2 divider = { 0, 0 };
|
||||
Color divColor = WHITE;
|
||||
|
||||
if ( !lua_isnil( L, 5 ) && !lua_isnone( L, 5 ) ) {
|
||||
divider = uluaGetVector2( L, 5 );
|
||||
}
|
||||
if ( !lua_isnil( L, 6 ) && !lua_isnone( L, 6 ) ) {
|
||||
divColor = uluaGetColor( L, 6 );
|
||||
}
|
||||
|
||||
rlPushMatrix();
|
||||
rlMultMatrixf( MatrixToFloat( transform ) );
|
||||
|
||||
rlBegin( RL_LINES );
|
||||
for ( int x = 0; x < (int)slices.x + 1; x++ ) {
|
||||
if ( 0 < x && x < slices.x && 0 < divider.x && x % (int)divider.x == 0 ) {
|
||||
rlColor4ub( divColor.r, divColor.g, divColor.b, divColor.a );
|
||||
}
|
||||
else {
|
||||
rlColor4ub( color.r, color.g, color.b, color.a );
|
||||
}
|
||||
|
||||
rlVertex3f( spacing.x * x, 0, 0 );
|
||||
rlVertex3f( spacing.x * x, 0, slices.y * spacing.y );
|
||||
}
|
||||
for ( int y = 0; y < (int)slices.y + 1; y++ ) {
|
||||
if ( 0 < y && y < slices.y && 0 < divider.y && y % (int)divider.y == 0 ) {
|
||||
rlColor4ub( divColor.r, divColor.g, divColor.b, divColor.a );
|
||||
}
|
||||
else {
|
||||
rlColor4ub( color.r, color.g, color.b, color.a );
|
||||
}
|
||||
rlVertex3f( 0, 0, spacing.y * y );
|
||||
rlVertex3f( slices.x * spacing.x, 0, spacing.y * y );
|
||||
}
|
||||
rlEnd();
|
||||
rlPopMatrix();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
## Models - Model management functions
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user