GetMeshData.
This commit is contained in:
8
API.md
8
API.md
@@ -7548,6 +7548,14 @@ Compute mesh tangents
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> meshData = RL.GetMeshData( Mesh mesh )
|
||||||
|
|
||||||
|
Get mesh data as table.
|
||||||
|
|
||||||
|
- Success return Mesh{}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Models - Mesh generation functions
|
## Models - Mesh generation functions
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -4738,6 +4738,12 @@ function RL.GetMeshBoundingBox( mesh ) end
|
|||||||
---@return any RL.GenMeshTangents
|
---@return any RL.GenMeshTangents
|
||||||
function RL.GenMeshTangents( mesh ) end
|
function RL.GenMeshTangents( mesh ) end
|
||||||
|
|
||||||
|
---Get mesh data as table.
|
||||||
|
---- Success return Mesh{}
|
||||||
|
---@param mesh any
|
||||||
|
---@return any meshData
|
||||||
|
function RL.GetMeshData( mesh ) end
|
||||||
|
|
||||||
-- Models - Mesh generation functions
|
-- Models - Mesh generation functions
|
||||||
|
|
||||||
---Generate polygonal mesh
|
---Generate polygonal mesh
|
||||||
|
|||||||
@@ -44,8 +44,10 @@ DETAILED CHANGES:
|
|||||||
- ADDED: glEnable, glDisable, glGetString and glClear.
|
- ADDED: glEnable, glDisable, glGetString and glClear.
|
||||||
- ADDED: Stencil reflection example.
|
- ADDED: Stencil reflection example.
|
||||||
- ADDED: Math Sign.
|
- ADDED: Math Sign.
|
||||||
- FIXED: Camera3D lib Fix up down movement invertion when looking up
|
- FIXED: Camera3D lib Fix up down movement invertion when looking up.
|
||||||
- ADDED: Bitwise operations for cross Lua compatibility.
|
- ADDED: Bitwise operations for cross Lua compatibility.
|
||||||
|
- ADDED: GetMeshData.
|
||||||
|
- FIXED: GenMeshCustom indices wasn't changing triangleCount.
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
||||||
|
|||||||
2
devnotes
2
devnotes
@@ -20,7 +20,7 @@ Backlog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bugs {
|
Bugs {
|
||||||
* glfwSet*Callback functions segfault on Windows. Should keep Lua events off.
|
* glfwSet*Callback functions segfault on Windows. Should keep Lua events off for now.
|
||||||
}
|
}
|
||||||
|
|
||||||
Needs Testing {
|
Needs Testing {
|
||||||
|
|||||||
@@ -32,10 +32,6 @@ local shadowMesh = nil
|
|||||||
local lights = {}
|
local lights = {}
|
||||||
local camera = nil -- 3D camera for shadow rendering.
|
local camera = nil -- 3D camera for shadow rendering.
|
||||||
|
|
||||||
local kissa = Color:new( 255, 255, 255 )
|
|
||||||
|
|
||||||
print( "Kissa", kissa )
|
|
||||||
|
|
||||||
-- Init.
|
-- Init.
|
||||||
|
|
||||||
local function addLight( pos, color, radius )
|
local function addLight( pos, color, radius )
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ int lmodelsSetMeshColor( lua_State* L );
|
|||||||
int lmodelsExportMesh( lua_State* L );
|
int lmodelsExportMesh( lua_State* L );
|
||||||
int lmodelsGetMeshBoundingBox( lua_State* L );
|
int lmodelsGetMeshBoundingBox( lua_State* L );
|
||||||
int lmodelsGenMeshTangents( lua_State* L );
|
int lmodelsGenMeshTangents( lua_State* L );
|
||||||
|
int lmodelsGetMeshData( lua_State* L );
|
||||||
/* Mesh generation functions. */
|
/* Mesh generation functions. */
|
||||||
int lmodelsGenMeshPoly( lua_State* L );
|
int lmodelsGenMeshPoly( lua_State* L );
|
||||||
int lmodelsGenMeshPlane( lua_State* L );
|
int lmodelsGenMeshPlane( lua_State* L );
|
||||||
|
|||||||
229
src/lua_core.c
229
src/lua_core.c
@@ -1034,16 +1034,16 @@ static void logCustom( int logLevel, const char* text, va_list args ) {
|
|||||||
|
|
||||||
vsprintf( string, text, args );
|
vsprintf( string, text, args );
|
||||||
|
|
||||||
switch ( logLevel ) {
|
switch ( logLevel ) {
|
||||||
case LOG_ALL: sprintf( msg, "ALL: %s", string ); break;
|
case LOG_ALL: sprintf( msg, "ALL: %s", string ); break;
|
||||||
case LOG_TRACE: sprintf( msg, "TRACE: %s", string ); break;
|
case LOG_TRACE: sprintf( msg, "TRACE: %s", string ); break;
|
||||||
case LOG_DEBUG: sprintf( msg, "DEBUG: %s", string ); break;
|
case LOG_DEBUG: sprintf( msg, "DEBUG: %s", string ); break;
|
||||||
case LOG_INFO: sprintf( msg, "INFO: %s", string ); break;
|
case LOG_INFO: sprintf( msg, "INFO: %s", string ); break;
|
||||||
case LOG_WARNING: sprintf( msg, "WARNING: %s", string ); break;
|
case LOG_WARNING: sprintf( msg, "WARNING: %s", string ); break;
|
||||||
case LOG_ERROR: sprintf( msg, "ERROR: %s", string ); break;
|
case LOG_ERROR: sprintf( msg, "ERROR: %s", string ); break;
|
||||||
case LOG_FATAL: sprintf( msg, "FATAL: %s", string ); break;
|
case LOG_FATAL: sprintf( msg, "FATAL: %s", string ); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
printf( "%s\n", msg );
|
printf( "%s\n", msg );
|
||||||
|
|
||||||
/* Call Lua log function if exists. */
|
/* Call Lua log function if exists. */
|
||||||
@@ -1076,7 +1076,7 @@ bool luaInit( int argn, const char** argc ) {
|
|||||||
state->luaState = luaL_newstate();
|
state->luaState = luaL_newstate();
|
||||||
lua_State* L = state->luaState;
|
lua_State* L = state->luaState;
|
||||||
|
|
||||||
luaL_openlibs( L );
|
luaL_openlibs( L );
|
||||||
|
|
||||||
if ( L == NULL ) {
|
if ( L == NULL ) {
|
||||||
TraceLog( LOG_WARNING, "%s", "Failed to init Lua" );
|
TraceLog( LOG_WARNING, "%s", "Failed to init Lua" );
|
||||||
@@ -1166,7 +1166,7 @@ bool luaCallMain() {
|
|||||||
snprintf( path, STRING_LEN, "%smain", state->exePath );
|
snprintf( path, STRING_LEN, "%smain", state->exePath );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
luaL_dofile( L, path );
|
luaL_dofile( L, path );
|
||||||
|
|
||||||
/* Check errors in main.lua */
|
/* Check errors in main.lua */
|
||||||
if ( lua_tostring( state->luaState, -1 ) ) {
|
if ( lua_tostring( state->luaState, -1 ) ) {
|
||||||
@@ -1190,8 +1190,8 @@ bool luaCallMain() {
|
|||||||
//TODO Should this be removed?
|
//TODO Should this be removed?
|
||||||
else {
|
else {
|
||||||
TraceLog( LOG_ERROR, "%s", "No Lua init found!" );
|
TraceLog( LOG_ERROR, "%s", "No Lua init found!" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
lua_pop( L, -1 );
|
lua_pop( L, -1 );
|
||||||
|
|
||||||
return state->run;
|
return state->run;
|
||||||
@@ -1202,7 +1202,7 @@ void luaCallUpdate() {
|
|||||||
#if defined PLATFORM_DESKTOP_SDL && defined LUA_EVENTS
|
#if defined PLATFORM_DESKTOP_SDL && defined LUA_EVENTS
|
||||||
platformSendEvents();
|
platformSendEvents();
|
||||||
#endif
|
#endif
|
||||||
lua_State* L = state->luaState;
|
lua_State* L = state->luaState;
|
||||||
|
|
||||||
lua_pushcfunction( L, luaTraceback );
|
lua_pushcfunction( L, luaTraceback );
|
||||||
int tracebackidx = lua_gettop(L);
|
int tracebackidx = lua_gettop(L);
|
||||||
@@ -1210,16 +1210,16 @@ void luaCallUpdate() {
|
|||||||
lua_getglobal( L, "RL" );
|
lua_getglobal( L, "RL" );
|
||||||
lua_getfield( L, -1, "update" );
|
lua_getfield( L, -1, "update" );
|
||||||
|
|
||||||
if ( lua_isfunction( L, -1 ) ) {
|
if ( lua_isfunction( L, -1 ) ) {
|
||||||
lua_pushnumber( L, GetFrameTime() );
|
lua_pushnumber( L, GetFrameTime() );
|
||||||
|
|
||||||
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
if ( lua_pcall( L, 1, 0, tracebackidx ) != 0 ) {
|
||||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||||
state->run = false;
|
state->run = false;
|
||||||
lua_pop( L, -1 );
|
lua_pop( L, -1 );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lua_pop( L, -1 );
|
lua_pop( L, -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1231,16 +1231,16 @@ void luaCallDraw() {
|
|||||||
lua_getglobal( L, "RL" );
|
lua_getglobal( L, "RL" );
|
||||||
lua_getfield( L, -1, "draw" );
|
lua_getfield( L, -1, "draw" );
|
||||||
|
|
||||||
if ( lua_isfunction( L, -1 ) ) {
|
if ( lua_isfunction( L, -1 ) ) {
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
|
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
|
||||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||||
state->run = false;
|
state->run = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
lua_pop( L, -1 );
|
lua_pop( L, -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1252,13 +1252,13 @@ void luaCallExit() {
|
|||||||
lua_getglobal( L, "RL" );
|
lua_getglobal( L, "RL" );
|
||||||
lua_getfield( L, -1, "exit" );
|
lua_getfield( L, -1, "exit" );
|
||||||
|
|
||||||
if ( lua_isfunction( L, -1 ) ) {
|
if ( lua_isfunction( L, -1 ) ) {
|
||||||
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
|
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
|
||||||
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
|
||||||
state->run = false;
|
state->run = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lua_pop( L, -1 );
|
lua_pop( L, -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1761,6 +1761,7 @@ void luaRegister() {
|
|||||||
assingGlobalFunction( "ExportMesh", lmodelsExportMesh );
|
assingGlobalFunction( "ExportMesh", lmodelsExportMesh );
|
||||||
assingGlobalFunction( "GetMeshBoundingBox", lmodelsGetMeshBoundingBox );
|
assingGlobalFunction( "GetMeshBoundingBox", lmodelsGetMeshBoundingBox );
|
||||||
assingGlobalFunction( "GenMeshTangents", lmodelsGenMeshTangents );
|
assingGlobalFunction( "GenMeshTangents", lmodelsGenMeshTangents );
|
||||||
|
assingGlobalFunction( "GetMeshData", lmodelsGetMeshData );
|
||||||
/* Mesh generation functions. */
|
/* Mesh generation functions. */
|
||||||
assingGlobalFunction( "GenMeshPoly", lmodelsGenMeshPoly );
|
assingGlobalFunction( "GenMeshPoly", lmodelsGenMeshPoly );
|
||||||
assingGlobalFunction( "GenMeshPlane", lmodelsGenMeshPlane );
|
assingGlobalFunction( "GenMeshPlane", lmodelsGenMeshPlane );
|
||||||
@@ -2377,10 +2378,10 @@ bool uluaGetBoolean( lua_State* L, int index ) {
|
|||||||
|
|
||||||
Color uluaGetColor( lua_State* L, int index ) {
|
Color uluaGetColor( lua_State* L, int index ) {
|
||||||
luaL_checktype( L, index, LUA_TTABLE );
|
luaL_checktype( L, index, LUA_TTABLE );
|
||||||
Color color = { 0, 0, 0, 255 };
|
Color color = { 0, 0, 0, 255 };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
if ( lua_isnumber( L, -1 ) ) {
|
if ( lua_isnumber( L, -1 ) ) {
|
||||||
@@ -2419,18 +2420,18 @@ Color uluaGetColor( lua_State* L, int index ) {
|
|||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 uluaGetVector2( lua_State* L, int index ) {
|
Vector2 uluaGetVector2( lua_State* L, int index ) {
|
||||||
luaL_checktype( L, index, LUA_TTABLE );
|
luaL_checktype( L, index, LUA_TTABLE );
|
||||||
Vector2 vector = { 0.0f, 0.0f };
|
Vector2 vector = { 0.0f, 0.0f };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
if ( lua_isnumber( L, -1 ) ) {
|
if ( lua_isnumber( L, -1 ) ) {
|
||||||
if ( lua_isnumber( L, -2 ) ) {
|
if ( lua_isnumber( L, -2 ) ) {
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
@@ -2455,19 +2456,19 @@ Vector2 uluaGetVector2( lua_State* L, int index ) {
|
|||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 uluaGetVector3( lua_State* L, int index ) {
|
Vector3 uluaGetVector3( lua_State* L, int index ) {
|
||||||
luaL_checktype( L, index, LUA_TTABLE );
|
luaL_checktype( L, index, LUA_TTABLE );
|
||||||
Vector3 vector = { 0.0f, 0.0f, 0.0f };
|
Vector3 vector = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
if ( lua_isnumber( L, -1 ) ) {
|
if ( lua_isnumber( L, -1 ) ) {
|
||||||
if ( lua_isnumber( L, -2 ) ) {
|
if ( lua_isnumber( L, -2 ) ) {
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -2494,22 +2495,22 @@ Vector3 uluaGetVector3( lua_State* L, int index ) {
|
|||||||
vector.z = lua_tonumber( L, -1 );
|
vector.z = lua_tonumber( L, -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 uluaGetVector4( lua_State* L, int index ) {
|
Vector4 uluaGetVector4( lua_State* L, int index ) {
|
||||||
luaL_checktype( L, index, LUA_TTABLE );
|
luaL_checktype( L, index, LUA_TTABLE );
|
||||||
Vector4 vector = { 0.0f, 0.0f, 0.0f, 0.0f };
|
Vector4 vector = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
if ( lua_isnumber( L, -1 ) ) {
|
if ( lua_isnumber( L, -1 ) ) {
|
||||||
if ( lua_isnumber( L, -2 ) ) {
|
if ( lua_isnumber( L, -2 ) ) {
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -2542,22 +2543,22 @@ Vector4 uluaGetVector4( lua_State* L, int index ) {
|
|||||||
vector.w = lua_tonumber( L, -1 );
|
vector.w = lua_tonumber( L, -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle uluaGetRectangle( lua_State* L, int index ) {
|
Rectangle uluaGetRectangle( lua_State* L, int index ) {
|
||||||
luaL_checktype( L, index, LUA_TTABLE );
|
luaL_checktype( L, index, LUA_TTABLE );
|
||||||
Rectangle rect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
Rectangle rect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
if ( lua_isnumber( L, -1 ) ) {
|
if ( lua_isnumber( L, -1 ) ) {
|
||||||
if ( lua_isnumber( L, -2 ) ) {
|
if ( lua_isnumber( L, -2 ) ) {
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -2590,22 +2591,22 @@ Rectangle uluaGetRectangle( lua_State* L, int index ) {
|
|||||||
rect.height = lua_tonumber( L, -1 );
|
rect.height = lua_tonumber( L, -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
Quaternion uluaGetQuaternion( lua_State* L, int index ) {
|
Quaternion uluaGetQuaternion( lua_State* L, int index ) {
|
||||||
luaL_checktype( L, index, LUA_TTABLE );
|
luaL_checktype( L, index, LUA_TTABLE );
|
||||||
Quaternion quaternion = { 0.0f, 0.0f, 0.0f, 0.0f };
|
Quaternion quaternion = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
if ( lua_isnumber( L, -1 ) ) {
|
if ( lua_isnumber( L, -1 ) ) {
|
||||||
if ( lua_isnumber( L, -2 ) ) {
|
if ( lua_isnumber( L, -2 ) ) {
|
||||||
switch ( i ) {
|
switch ( i ) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -2638,11 +2639,11 @@ Quaternion uluaGetQuaternion( lua_State* L, int index ) {
|
|||||||
quaternion.w = lua_tonumber( L, -1 );
|
quaternion.w = lua_tonumber( L, -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
return quaternion;
|
return quaternion;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix uluaGetMatrix( lua_State* L, int index ) {
|
Matrix uluaGetMatrix( lua_State* L, int index ) {
|
||||||
@@ -2651,10 +2652,10 @@ Matrix uluaGetMatrix( lua_State* L, int index ) {
|
|||||||
float m[4][4];
|
float m[4][4];
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
if ( lua_istable( L, -1 ) ) {
|
if ( lua_istable( L, -1 ) ) {
|
||||||
int t2 = lua_gettop( L ), j = 0;
|
int t2 = lua_gettop( L ), j = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
@@ -2678,10 +2679,10 @@ Matrix uluaGetMatrix( lua_State* L, int index ) {
|
|||||||
j++;
|
j++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
matrix.m0 = m[0][0]; matrix.m1 = m[0][1]; matrix.m2 = m[0][2]; matrix.m3 = m[0][3];
|
matrix.m0 = m[0][0]; matrix.m1 = m[0][1]; matrix.m2 = m[0][2]; matrix.m3 = m[0][3];
|
||||||
matrix.m4 = m[1][0]; matrix.m5 = m[1][1]; matrix.m6 = m[1][2]; matrix.m7 = m[1][3];
|
matrix.m4 = m[1][0]; matrix.m5 = m[1][1]; matrix.m6 = m[1][2]; matrix.m7 = m[1][3];
|
||||||
matrix.m8 = m[2][0]; matrix.m9 = m[2][1]; matrix.m10 = m[2][2]; matrix.m11 = m[2][3];
|
matrix.m8 = m[2][0]; matrix.m9 = m[2][1]; matrix.m10 = m[2][2]; matrix.m11 = m[2][3];
|
||||||
@@ -2695,7 +2696,7 @@ BoundingBox uluaGetBoundingBox( lua_State* L, int index ) {
|
|||||||
BoundingBox box = { .min = { 0.0, 0.0, 0.0 }, .max = { 0.0, 0.0, 0.0 } };
|
BoundingBox box = { .min = { 0.0, 0.0, 0.0 }, .max = { 0.0, 0.0, 0.0 } };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
if ( lua_istable( L, -1 ) ) {
|
if ( lua_istable( L, -1 ) ) {
|
||||||
@@ -2722,7 +2723,7 @@ BoundingBox uluaGetBoundingBox( lua_State* L, int index ) {
|
|||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2767,7 +2768,7 @@ NPatchInfo uluaGetNPatchInfo( lua_State* L, int index ) {
|
|||||||
NPatchInfo npatch = { .source = { 0.0, 0.0, 0.0, 0.0 }, .left = 0, .top = 0, .right = 0, .bottom = 0, .layout = NPATCH_NINE_PATCH };
|
NPatchInfo npatch = { .source = { 0.0, 0.0, 0.0, 0.0 }, .left = 0, .top = 0, .right = 0, .bottom = 0, .layout = NPATCH_NINE_PATCH };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
/* Do not check type since there should be table and ints. */
|
/* Do not check type since there should be table and ints. */
|
||||||
@@ -2817,7 +2818,7 @@ NPatchInfo uluaGetNPatchInfo( lua_State* L, int index ) {
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
return npatch;
|
return npatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2826,7 +2827,7 @@ BoneInfo uluaGetBoneInfo( lua_State* L, int index ) {
|
|||||||
BoneInfo bone = { 0 };
|
BoneInfo bone = { 0 };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
/* Do not check type since there should be table and ints. */
|
/* Do not check type since there should be table and ints. */
|
||||||
@@ -2854,7 +2855,7 @@ BoneInfo uluaGetBoneInfo( lua_State* L, int index ) {
|
|||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bone;
|
return bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2863,7 +2864,7 @@ Transform uluaGetTransform( lua_State* L, int index ) {
|
|||||||
Transform transform = { 0 };
|
Transform transform = { 0 };
|
||||||
|
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
/* Do not check type since there should be table and ints. */
|
/* Do not check type since there should be table and ints. */
|
||||||
@@ -2897,7 +2898,7 @@ Transform uluaGetTransform( lua_State* L, int index ) {
|
|||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3045,32 +3046,32 @@ AutomationEventList* uluaGetAutomationEventList( lua_State* L, int index ) {
|
|||||||
|
|
||||||
void uluaPushColor( lua_State* L, Color color ) {
|
void uluaPushColor( lua_State* L, Color color ) {
|
||||||
lua_createtable( L, 3, 0 );
|
lua_createtable( L, 3, 0 );
|
||||||
lua_pushnumber( L, color.r );
|
lua_pushnumber( L, color.r );
|
||||||
lua_rawseti( L, -2, 1 );
|
lua_rawseti( L, -2, 1 );
|
||||||
lua_pushnumber( L, color.g );
|
lua_pushnumber( L, color.g );
|
||||||
lua_rawseti( L, -2, 2 );
|
lua_rawseti( L, -2, 2 );
|
||||||
lua_pushnumber( L, color.b );
|
lua_pushnumber( L, color.b );
|
||||||
lua_rawseti( L, -2, 3 );
|
lua_rawseti( L, -2, 3 );
|
||||||
lua_pushnumber( L, color.a );
|
lua_pushnumber( L, color.a );
|
||||||
lua_rawseti( L, -2, 4 );
|
lua_rawseti( L, -2, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void uluaPushVector2( lua_State* L, Vector2 vector ) {
|
void uluaPushVector2( lua_State* L, Vector2 vector ) {
|
||||||
lua_createtable( L, 2, 0 );
|
lua_createtable( L, 2, 0 );
|
||||||
lua_pushnumber( L, vector.x );
|
lua_pushnumber( L, vector.x );
|
||||||
lua_rawseti( L, -2, 1 );
|
lua_rawseti( L, -2, 1 );
|
||||||
lua_pushnumber( L, vector.y );
|
lua_pushnumber( L, vector.y );
|
||||||
lua_rawseti( L, -2, 2 );
|
lua_rawseti( L, -2, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void uluaPushVector3( lua_State* L, Vector3 vector ) {
|
void uluaPushVector3( lua_State* L, Vector3 vector ) {
|
||||||
lua_createtable( L, 3, 0 );
|
lua_createtable( L, 3, 0 );
|
||||||
lua_pushnumber( L, vector.x );
|
lua_pushnumber( L, vector.x );
|
||||||
lua_rawseti( L, -2, 1 );
|
lua_rawseti( L, -2, 1 );
|
||||||
lua_pushnumber( L, vector.y );
|
lua_pushnumber( L, vector.y );
|
||||||
lua_rawseti( L, -2, 2 );
|
lua_rawseti( L, -2, 2 );
|
||||||
lua_pushnumber( L, vector.z );
|
lua_pushnumber( L, vector.z );
|
||||||
lua_rawseti( L, -2, 3 );
|
lua_rawseti( L, -2, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void uluaPushVector4( lua_State* L, Vector4 vector ) {
|
void uluaPushVector4( lua_State* L, Vector4 vector ) {
|
||||||
@@ -3359,13 +3360,13 @@ void uluaPushAutomationEventList( lua_State* L, AutomationEventList eventList )
|
|||||||
int uluaGetTableLen( lua_State* L, int index ) {
|
int uluaGetTableLen( lua_State* L, int index ) {
|
||||||
luaL_checktype( L, index, LUA_TTABLE );
|
luaL_checktype( L, index, LUA_TTABLE );
|
||||||
int t = index, i = 0;
|
int t = index, i = 0;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
|
|
||||||
while ( lua_next( L, t ) != 0 ) {
|
while ( lua_next( L, t ) != 0 ) {
|
||||||
i++;
|
i++;
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Accepts no arg and nil. */
|
/* Accepts no arg and nil. */
|
||||||
|
|||||||
143
src/models.c
143
src/models.c
@@ -1260,6 +1260,139 @@ int lmodelsGenMeshTangents( lua_State* L ) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
> meshData = RL.GetMeshData( Mesh mesh )
|
||||||
|
|
||||||
|
Get mesh data as table.
|
||||||
|
|
||||||
|
- Success return Mesh{}
|
||||||
|
*/
|
||||||
|
int lmodelsGetMeshData( lua_State* L ) {
|
||||||
|
Mesh* mesh = uluaGetMesh( L, 1 );
|
||||||
|
|
||||||
|
lua_createtable( L, 2, 0 );
|
||||||
|
|
||||||
|
/* Vertices. */
|
||||||
|
|
||||||
|
if ( mesh->vertices != NULL ) {
|
||||||
|
lua_createtable( L, mesh->vertexCount, 0 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < mesh->vertexCount; i++ ) {
|
||||||
|
lua_createtable( L, 3, 0 );
|
||||||
|
lua_pushnumber( L, mesh->vertices[i * 3 + 0] );
|
||||||
|
lua_rawseti( L, -2, 1 );
|
||||||
|
lua_pushnumber( L, mesh->vertices[i * 3 + 1] );
|
||||||
|
lua_rawseti( L, -2, 2 );
|
||||||
|
lua_pushnumber( L, mesh->vertices[i * 3 + 2] );
|
||||||
|
lua_rawseti( L, -2, 3 );
|
||||||
|
lua_rawseti( L, -2, i + 1 );
|
||||||
|
}
|
||||||
|
lua_setfield( L, -2, "vertices" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Texcoords. */
|
||||||
|
|
||||||
|
if ( mesh->texcoords != NULL ) {
|
||||||
|
lua_createtable( L, mesh->vertexCount, 0 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < mesh->vertexCount; i++ ) {
|
||||||
|
lua_createtable( L, 2, 0 );
|
||||||
|
lua_pushnumber( L, mesh->texcoords[i * 2 + 0] );
|
||||||
|
lua_rawseti( L, -2, 1 );
|
||||||
|
lua_pushnumber( L, mesh->texcoords[i * 2 + 1] );
|
||||||
|
lua_rawseti( L, -2, 2 );
|
||||||
|
lua_rawseti( L, -2, i + 1 );
|
||||||
|
}
|
||||||
|
lua_setfield( L, -2, "texcoords" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mesh->texcoords2 != NULL ) {
|
||||||
|
lua_createtable( L, mesh->vertexCount, 0 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < mesh->vertexCount; i++ ) {
|
||||||
|
lua_createtable( L, 2, 0 );
|
||||||
|
lua_pushnumber( L, mesh->texcoords2[i * 2 + 0] );
|
||||||
|
lua_rawseti( L, -2, 1 );
|
||||||
|
lua_pushnumber( L, mesh->texcoords2[i * 2 + 1] );
|
||||||
|
lua_rawseti( L, -2, 2 );
|
||||||
|
lua_rawseti( L, -2, i + 1 );
|
||||||
|
}
|
||||||
|
lua_setfield( L, -2, "texcoords2" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Normals. */
|
||||||
|
|
||||||
|
if ( mesh->normals != NULL ) {
|
||||||
|
lua_createtable( L, mesh->vertexCount, 0 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < mesh->vertexCount; i++ ) {
|
||||||
|
lua_createtable( L, 3, 0 );
|
||||||
|
lua_pushnumber( L, mesh->normals[i * 3 + 0] );
|
||||||
|
lua_rawseti( L, -2, 1 );
|
||||||
|
lua_pushnumber( L, mesh->normals[i * 3 + 1] );
|
||||||
|
lua_rawseti( L, -2, 2 );
|
||||||
|
lua_pushnumber( L, mesh->normals[i * 3 + 2] );
|
||||||
|
lua_rawseti( L, -2, 3 );
|
||||||
|
lua_rawseti( L, -2, i + 1 );
|
||||||
|
}
|
||||||
|
lua_setfield( L, -2, "normals" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tangents. */
|
||||||
|
|
||||||
|
if ( mesh->tangents != NULL ) {
|
||||||
|
lua_createtable( L, mesh->vertexCount, 0 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < mesh->vertexCount; i++ ) {
|
||||||
|
lua_createtable( L, 4, 0 );
|
||||||
|
lua_pushnumber( L, mesh->tangents[i * 4 + 0] );
|
||||||
|
lua_rawseti( L, -2, 1 );
|
||||||
|
lua_pushnumber( L, mesh->tangents[i * 4 + 1] );
|
||||||
|
lua_rawseti( L, -2, 2 );
|
||||||
|
lua_pushnumber( L, mesh->tangents[i * 4 + 2] );
|
||||||
|
lua_rawseti( L, -2, 3 );
|
||||||
|
lua_pushnumber( L, mesh->tangents[i * 4 + 3] );
|
||||||
|
lua_rawseti( L, -2, 4 );
|
||||||
|
lua_rawseti( L, -2, i + 1 );
|
||||||
|
}
|
||||||
|
lua_setfield( L, -2, "tangents" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Colors. */
|
||||||
|
|
||||||
|
if ( mesh->colors != NULL ) {
|
||||||
|
lua_createtable( L, mesh->vertexCount, 0 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < mesh->vertexCount; i++ ) {
|
||||||
|
lua_createtable( L, 4, 0 );
|
||||||
|
lua_pushinteger( L, mesh->colors[i * 4 + 0] );
|
||||||
|
lua_rawseti( L, -2, 1 );
|
||||||
|
lua_pushinteger( L, mesh->colors[i * 4 + 1] );
|
||||||
|
lua_rawseti( L, -2, 2 );
|
||||||
|
lua_pushinteger( L, mesh->colors[i * 4 + 2] );
|
||||||
|
lua_rawseti( L, -2, 3 );
|
||||||
|
lua_pushinteger( L, mesh->colors[i * 4 + 3] );
|
||||||
|
lua_rawseti( L, -2, 4 );
|
||||||
|
lua_rawseti( L, -2, i + 1 );
|
||||||
|
}
|
||||||
|
lua_setfield( L, -2, "colors" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Indices. */
|
||||||
|
|
||||||
|
if ( mesh->indices != NULL ) {
|
||||||
|
lua_createtable( L, mesh->triangleCount * 3, 0 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < mesh->triangleCount * 3; i++ ) {
|
||||||
|
lua_pushinteger( L, mesh->indices[i] );
|
||||||
|
lua_rawseti( L, -2, i + 1 );
|
||||||
|
}
|
||||||
|
lua_setfield( L, -2, "indices" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
## Models - Mesh generation functions
|
## Models - Mesh generation functions
|
||||||
*/
|
*/
|
||||||
@@ -1461,6 +1594,7 @@ int lmodelsGenMeshCustom( lua_State* L ) {
|
|||||||
bool dynamic = uluaGetBoolean( L, 2 );
|
bool dynamic = uluaGetBoolean( L, 2 );
|
||||||
|
|
||||||
Mesh mesh = { 0 };
|
Mesh mesh = { 0 };
|
||||||
|
int indiceCount = 0;
|
||||||
|
|
||||||
int t = 1;
|
int t = 1;
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
@@ -1584,6 +1718,7 @@ int lmodelsGenMeshCustom( lua_State* L ) {
|
|||||||
}
|
}
|
||||||
else if ( strcmp( "indices", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
|
else if ( strcmp( "indices", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
|
||||||
size_t len = uluaGetTableLen( L, lua_gettop( L ) );
|
size_t len = uluaGetTableLen( L, lua_gettop( L ) );
|
||||||
|
indiceCount = len;
|
||||||
|
|
||||||
mesh.indices = (unsigned short*)MemAlloc( len * sizeof(unsigned short) );
|
mesh.indices = (unsigned short*)MemAlloc( len * sizeof(unsigned short) );
|
||||||
|
|
||||||
@@ -1599,6 +1734,12 @@ int lmodelsGenMeshCustom( lua_State* L ) {
|
|||||||
}
|
}
|
||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We have to set this here since it's not known if vertices or indices are set first. */
|
||||||
|
if ( 0 < indiceCount ) {
|
||||||
|
mesh.triangleCount = indiceCount / 3;
|
||||||
|
}
|
||||||
|
|
||||||
UploadMesh( &mesh, dynamic );
|
UploadMesh( &mesh, dynamic );
|
||||||
uluaPushMesh( L, mesh );
|
uluaPushMesh( L, mesh );
|
||||||
|
|
||||||
@@ -2099,7 +2240,7 @@ int lmodelsSetModelAnimationName( lua_State* L ) {
|
|||||||
|
|
||||||
strncpy( animation->name, name, 32 );
|
strncpy( animation->name, name, 32 );
|
||||||
|
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user