diff options
| author | jussi | 2022-04-03 19:23:26 +0300 |
|---|---|---|
| committer | jussi | 2022-04-03 19:23:26 +0300 |
| commit | 5eadd7d1d85879541f304737178eee2bd671bb5f (patch) | |
| tree | 58e3f31cc39fa20dbc72e702f03429713bbd8ed0 /src/models.c | |
| parent | 7665cf4bc16a423d4cd98174853dcc36de08787e (diff) | |
| download | reilua-enhanced-5eadd7d1d85879541f304737178eee2bd671bb5f.tar.gz reilua-enhanced-5eadd7d1d85879541f304737178eee2bd671bb5f.tar.bz2 reilua-enhanced-5eadd7d1d85879541f304737178eee2bd671bb5f.zip | |
Model set/get transform and bug fixes.
Diffstat (limited to 'src/models.c')
| -rw-r--r-- | src/models.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/models.c b/src/models.c index f105991..483d0f8 100644 --- a/src/models.c +++ b/src/models.c @@ -1765,6 +1765,59 @@ int lmodelsDrawBillboardRec( lua_State *L ) { } /* +> success = RL_SetModelTransform( Model model, Matrix transform ) + +Set model transform matrix + +- Failure return false +- Success return true +*/ +int lmodelsSetModelTransform( lua_State *L ) { + if ( !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetModelTransform( Model model, Matrix transform )" ); + lua_pushboolean( L, false ); + return 1; + } + Matrix transform = uluaGetMatrix( L ); + lua_pop( L, 1 ); + size_t modelId = lua_tointeger( L, -1 ); + + if ( !validModel( modelId ) ) { + lua_pushboolean( L, false ); + return 1; + } + state->models[ modelId ]->transform = transform; + lua_pushboolean( L, true ); + + return 1; +} + +/* +> transform = RL_GetModelTransform( Model model ) + +Get model transform matrix + +- Failure return false +- Success return Matrix +*/ +int lmodelsGetModelTransform( lua_State *L ) { + if ( !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetModelTransform( Model model )" ); + lua_pushboolean( L, false ); + return 1; + } + size_t modelId = lua_tointeger( L, -1 ); + + if ( !validModel( modelId ) ) { + lua_pushboolean( L, false ); + return 1; + } + uluaPushMatrix( L, state->models[ modelId ]->transform ); + + return 1; +} + +/* ## Model - Animations */ |
