From 8b6337446dd79faf226ea9df40d4d06d81c38436 Mon Sep 17 00:00:00 2001 From: jussi Date: Tue, 25 Apr 2023 19:28:54 +0300 Subject: DrawCapsule and DrawCapsuleWires. Free Camera3D example. --- src/lua_core.c | 2 ++ src/models.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) (limited to 'src') diff --git a/src/lua_core.c b/src/lua_core.c index 6f593d2..8aeeafe 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1050,6 +1050,8 @@ void luaRegister() { assingGlobalFunction( "DrawCylinderEx", lmodelsDrawCylinderEx ); assingGlobalFunction( "DrawCylinderWires", lmodelsDrawCylinderWires ); assingGlobalFunction( "DrawCylinderWiresEx", lmodelsDrawCylinderWiresEx ); + assingGlobalFunction( "DrawCapsule", lmodelsDrawCapsule ); + assingGlobalFunction( "DrawCapsuleWires", lmodelsDrawCapsuleWires ); assingGlobalFunction( "DrawPlane", lmodelsDrawPlane ); assingGlobalFunction( "DrawQuad3DTexture", lmodelDrawQuad3DTexture ); assingGlobalFunction( "DrawRay", lmodelsDrawRay ); diff --git a/src/models.c b/src/models.c index 963bd56..6b0ff0a 100644 --- a/src/models.c +++ b/src/models.c @@ -523,6 +523,62 @@ int lmodelsDrawCylinderWiresEx( lua_State *L ) { return 1; } +/* +> success = RL.DrawCapsule( Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color ) + +Draw a capsule with the center of its sphere caps at startPos and endPos + +- Failure return false +- Success return true +*/ +int lmodelsDrawCapsule( lua_State *L ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) + || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCapsule( Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color )" ); + lua_pushboolean( L, false ); + return 1; + } + Vector3 startPos = uluaGetVector3Index( L, 1 ); + Vector3 endPos = uluaGetVector3Index( L, 2 ); + float radius = lua_tonumber( L, 3 ); + int slices = lua_tonumber( L, 4 ); + int rings = lua_tointeger( L, 5 ); + Color color = uluaGetColorIndex( L, 6 ); + + DrawCapsule( startPos, endPos, radius, slices, rings, color ); + lua_pushboolean( L, true ); + + return 1; +} + +/* +> success = RL.DrawCapsuleWires( Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color ) + +Draw capsule wireframe with the center of its sphere caps at startPos and endPos + +- Failure return false +- Success return true +*/ +int lmodelsDrawCapsuleWires( lua_State *L ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) + || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCapsuleWires( Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color )" ); + lua_pushboolean( L, false ); + return 1; + } + Vector3 startPos = uluaGetVector3Index( L, 1 ); + Vector3 endPos = uluaGetVector3Index( L, 2 ); + float radius = lua_tonumber( L, 3 ); + int slices = lua_tonumber( L, 4 ); + int rings = lua_tointeger( L, 5 ); + Color color = uluaGetColorIndex( L, 6 ); + + DrawCapsuleWires( startPos, endPos, radius, slices, rings, color ); + lua_pushboolean( L, true ); + + return 1; +} + /* > success = RL.DrawPlane( Vector3 centerPos, Vector2 size, Color color ) -- cgit v1.2.3