UnloadModelAnimations and IsModelAnimationValid.
This commit is contained in:
18
API.md
18
API.md
@@ -4252,6 +4252,24 @@ Update model animation pose
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> success = RL_UnloadModelAnimations( ModelAnimations animations )
|
||||||
|
|
||||||
|
Unload animation data
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return true
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> valid = RL_IsModelAnimationValid( Model model, ModelAnimations animations )
|
||||||
|
|
||||||
|
Check model animation skeleton match
|
||||||
|
|
||||||
|
- Failure return nil
|
||||||
|
- Success return bool
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
> boneCount = RL_GetModelAnimationBoneCount( ModelAnimations animations, int animation )
|
> boneCount = RL_GetModelAnimationBoneCount( ModelAnimations animations, int animation )
|
||||||
|
|
||||||
Return modelAnimation bone count
|
Return modelAnimation bone count
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ function draw()
|
|||||||
RL_DrawRectangle( { 200, 120, 40, 50 }, { 100, 170, 255 } )
|
RL_DrawRectangle( { 200, 120, 40, 50 }, { 100, 170, 255 } )
|
||||||
RL_DrawTexturePro( tex, { 166, 138, 128, 128 }, { pos[1], pos[2], 128, 128 }, { 16, 16 }, 0.0, WHITE )
|
RL_DrawTexturePro( tex, { 166, 138, 128, 128 }, { pos[1], pos[2], 128, 128 }, { 16, 16 }, 0.0, WHITE )
|
||||||
RL_DrawText( 0, "Cat MIAU!!", { 16, 32 }, 10, 1, { 255, 180, 155 } )
|
RL_DrawText( 0, "Cat MIAU!!", { 16, 32 }, 10, 1, { 255, 180, 155 } )
|
||||||
|
RL_DrawTriangle( { 0, 32 }, { 32, 16 }, { 0, 0 }, RED )
|
||||||
RL_EndTextureMode()
|
RL_EndTextureMode()
|
||||||
|
|
||||||
RL_SetTextureSource( TEXTURE_SOURCE_RENDER_TEXTURE )
|
RL_SetTextureSource( TEXTURE_SOURCE_RENDER_TEXTURE )
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ int lmodelsGetModelTransform( lua_State *L );
|
|||||||
/* Animations. */
|
/* Animations. */
|
||||||
int lmodelsLoadModelAnimations( lua_State *L );
|
int lmodelsLoadModelAnimations( lua_State *L );
|
||||||
int lmodelsUpdateModelAnimation( lua_State *L );
|
int lmodelsUpdateModelAnimation( lua_State *L );
|
||||||
|
int lmodelsUnloadModelAnimations( lua_State *L );
|
||||||
|
int lmodelsIsModelAnimationValid( lua_State *L );
|
||||||
int lmodelsGetModelAnimationBoneCount( lua_State *L );
|
int lmodelsGetModelAnimationBoneCount( lua_State *L );
|
||||||
int lmodelsGetModelAnimationFrameCount( lua_State *L );
|
int lmodelsGetModelAnimationFrameCount( lua_State *L );
|
||||||
/* Collision. */
|
/* Collision. */
|
||||||
|
|||||||
@@ -1029,6 +1029,8 @@ void luaRegister() {
|
|||||||
/* Animations. */
|
/* Animations. */
|
||||||
lua_register( L, "RL_LoadModelAnimations", lmodelsLoadModelAnimations );
|
lua_register( L, "RL_LoadModelAnimations", lmodelsLoadModelAnimations );
|
||||||
lua_register( L, "RL_UpdateModelAnimation", lmodelsUpdateModelAnimation );
|
lua_register( L, "RL_UpdateModelAnimation", lmodelsUpdateModelAnimation );
|
||||||
|
lua_register( L, "RL_UnloadModelAnimations", lmodelsUnloadModelAnimations );
|
||||||
|
lua_register( L, "RL_IsModelAnimationValid", lmodelsIsModelAnimationValid );
|
||||||
lua_register( L, "RL_GetModelAnimationBoneCount", lmodelsGetModelAnimationBoneCount );
|
lua_register( L, "RL_GetModelAnimationBoneCount", lmodelsGetModelAnimationBoneCount );
|
||||||
lua_register( L, "RL_GetModelAnimationFrameCount", lmodelsGetModelAnimationFrameCount );
|
lua_register( L, "RL_GetModelAnimationFrameCount", lmodelsGetModelAnimationFrameCount );
|
||||||
/* Collision. */
|
/* Collision. */
|
||||||
|
|||||||
55
src/models.c
55
src/models.c
@@ -2146,6 +2146,61 @@ int lmodelsUpdateModelAnimation( lua_State *L ) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> success = RL_UnloadModelAnimations( ModelAnimations animations )
|
||||||
|
|
||||||
|
Unload animation data
|
||||||
|
|
||||||
|
- Failure return false
|
||||||
|
- Success return true
|
||||||
|
*/
|
||||||
|
int lmodelsUnloadModelAnimations( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, -1 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_UnloadModelAnimations( ModelAnimations animations )" );
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t animId = lua_tointeger( L, -1 );
|
||||||
|
|
||||||
|
if ( !validAnimation( animId ) ) {
|
||||||
|
lua_pushboolean( L, false );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
UnloadModelAnimation( *state->animations[ animId ]->animations );
|
||||||
|
state->animations[ animId ]->animCount = 0;
|
||||||
|
state->animations[ animId ] = NULL;
|
||||||
|
|
||||||
|
lua_pushboolean( L, true );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> valid = RL_IsModelAnimationValid( Model model, ModelAnimations animations )
|
||||||
|
|
||||||
|
Check model animation skeleton match
|
||||||
|
|
||||||
|
- Failure return nil
|
||||||
|
- Success return bool
|
||||||
|
*/
|
||||||
|
int lmodelsIsModelAnimationValid( lua_State *L ) {
|
||||||
|
if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
|
||||||
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_IsModelAnimationValid( Model model, ModelAnimations animations )" );
|
||||||
|
lua_pushnil( L );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
size_t animId = lua_tointeger( L, -1 );
|
||||||
|
size_t modelId = lua_tointeger( L, -2 );
|
||||||
|
|
||||||
|
if ( !validModel( modelId ) || !validAnimation( animId ) ) {
|
||||||
|
lua_pushnil( L );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
lua_pushboolean( L, IsModelAnimationValid( *state->models[ modelId ], *state->animations[ animId ]->animations ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> boneCount = RL_GetModelAnimationBoneCount( ModelAnimations animations, int animation )
|
> boneCount = RL_GetModelAnimationBoneCount( ModelAnimations animations, int animation )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user