Пример #1
0
static int luasrc_matrix3x4_t (lua_State *L) {
  if (lua_gettop(L) < 4) {
    matrix3x4_t matrix;
    memset( &matrix, 0, sizeof( matrix3x4_t ) );
    lua_pushmatrix(L, matrix);
  } else if (lua_gettop(L) < 12) {
    matrix3x4_t matrix = matrix3x4_t(luaL_checkvector(L, 1), luaL_checkvector(L, 2), luaL_checkvector(L, 3), luaL_checkvector(L, 4));
    lua_pushmatrix(L, matrix);
  } else {
    matrix3x4_t matrix = matrix3x4_t(luaL_checknumber(L, 1), luaL_checknumber(L, 2), luaL_checknumber(L, 3), luaL_checknumber(L, 4), luaL_checknumber(L, 5), luaL_checknumber(L, 6), luaL_checknumber(L, 7), luaL_checknumber(L, 8), luaL_checknumber(L, 9), luaL_checknumber(L, 10), luaL_checknumber(L, 11), luaL_checknumber(L, 12));
    lua_pushmatrix(L, matrix);
  }
  return 1;
}
int CLuaOOPDefs::GetCameraMatrix ( lua_State* luaVM )
{
    CMatrix matrix;
    m_pManager->GetCamera ()->GetMatrix ( matrix );

    lua_pushmatrix ( luaVM, matrix );
    return 1;
}
Пример #3
0
int CLuaMatrixDefs::Inverse ( lua_State* luaVM )
{
    CLuaMatrix* pMatrix1 = NULL;

    CScriptArgReader argStream ( luaVM );
    argStream.ReadUserData ( pMatrix1 );

    if ( !argStream.HasErrors () )
    {
        lua_pushmatrix ( luaVM, pMatrix1->Inverse ( ) );
        return 1;
    }
    else
    {
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );
    }

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #4
0
void lua_pushuserdata ( lua_State* luaVM, void* pData )
{
    if ( CClientEntity* pEntity = UserDataCast < CClientEntity > ( ( CClientEntity* ) NULL, pData, luaVM ) )
        return lua_pushelement ( luaVM, pEntity );
    else if ( CResource* pResource = UserDataCast < CResource > ( ( CResource* ) NULL, pData, luaVM ) )
        return lua_pushresource ( luaVM, pResource );
    else if ( CXMLNode* pNode = UserDataCast < CXMLNode > ( ( CXMLNode* ) NULL, pData, luaVM ) )
        return lua_pushxmlnode ( luaVM, pNode );
    else if ( CLuaTimer* pTimer = UserDataCast < CLuaTimer > ( ( CLuaTimer* ) NULL, pData, luaVM ) )
        return lua_pushtimer ( luaVM, pTimer );
    else if ( CLuaVector2D* pVector = UserDataCast < CLuaVector2D > ( (CLuaVector2D*) NULL, pData, luaVM ) )
        return lua_pushvector ( luaVM,* pVector );
    else if ( CLuaVector3D* pVector = UserDataCast < CLuaVector3D > ( (CLuaVector3D*) NULL, pData, luaVM ) )
        return lua_pushvector ( luaVM, *pVector );
    else if ( CLuaVector4D* pVector = UserDataCast < CLuaVector4D > ( (CLuaVector4D*) NULL, pData, luaVM ) )
        return lua_pushvector ( luaVM, *pVector );
    else if ( CLuaMatrix* pMatrix = UserDataCast < CLuaMatrix > ( (CLuaMatrix*) NULL, pData, luaVM ) )
        return lua_pushmatrix ( luaVM, *pMatrix );

    lua_pushobject ( luaVM, NULL, pData );
}
Пример #5
0
int CLuaMatrixDefs::Create(lua_State* luaVM)
{
    CMatrix matrix;

    CScriptArgReader argStream(luaVM);
    if (argStream.NextIsVector3D())
    {
        CVector vecPosition;
        argStream.ReadVector3D(vecPosition);
        if (argStream.NextIsVector3D())
        {
            CVector vecRotation;
            argStream.ReadVector3D(vecRotation);
            ConvertDegreesToRadiansNoWrap(vecRotation);
            matrix = CMatrix(vecPosition, vecRotation);
        }
        else
        {
            matrix = CMatrix(vecPosition);
        }
    }
    else if (argStream.NextIsUserDataOfType<CLuaMatrix>())
    {
        argStream.ReadMatrix(matrix);
        matrix = CMatrix(matrix);
    }
    else if (!argStream.NextIsNone())
    {
        argStream.SetCustomError("Expected vector3, matrix or nothing");
        m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());

        lua_pushboolean(luaVM, false);
        return 1;
    }

    lua_pushmatrix(luaVM, matrix);
    return 1;
}
Пример #6
0
int CLuaCameraDefs::OOP_getCameraMatrix ( lua_State* luaVM )
{
    // Needs further attention before adding
    CPlayer* pPlayer;

    CScriptArgReader argStream ( luaVM );

    argStream.ReadUserData ( pPlayer );

    if ( !argStream.HasErrors () )
    {
        CMatrix matrix;
        //pPlayer->GetCamera ()->GetMatrix ( matrix );

        lua_pushmatrix ( luaVM, matrix );
        return 1;
    }
    else
        m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );

    lua_pushboolean ( luaVM, false );
    return 1;
}
Пример #7
0
void lua_pushuserdata ( lua_State* luaVM, void* pData )
{
    if ( CElement* pEntity = UserDataCast < CElement > ( ( CElement* ) NULL, pData, NULL ) )
        return lua_pushelement ( luaVM, pEntity );
    if ( CPlayer* pEntity = UserDataCast < CPlayer > ( ( CPlayer* ) NULL, pData, NULL ) )
        return lua_pushelement ( luaVM, pEntity );
    else if ( CResource* pResource = UserDataCast < CResource > ( ( CResource* ) NULL, pData, NULL ) )
        return lua_pushresource ( luaVM, pResource );
    else if ( CXMLNode* pNode = UserDataCast < CXMLNode > ( ( CXMLNode* ) NULL, pData, NULL ) )
        return lua_pushxmlnode ( luaVM, pNode );
    else if ( CLuaTimer* pTimer = UserDataCast < CLuaTimer > ( ( CLuaTimer* ) NULL, pData, luaVM ) )
        return lua_pushtimer ( luaVM, pTimer );
    else if ( CLuaVector2D* pVector = UserDataCast < CLuaVector2D > ( (CLuaVector2D*) NULL, pData, luaVM ) )
        return lua_pushvector ( luaVM, *pVector );
    else if ( CLuaVector3D* pVector = UserDataCast < CLuaVector3D > ( (CLuaVector3D*) NULL, pData, luaVM ) )
        return lua_pushvector ( luaVM, *pVector );
    else if ( CLuaVector4D* pVector = UserDataCast < CLuaVector4D > ( (CLuaVector4D*) NULL, pData, luaVM ) )
        return lua_pushvector ( luaVM, *pVector );
    else if ( CLuaMatrix* pMatrix = UserDataCast < CLuaMatrix > ( (CLuaMatrix*) NULL, pData, luaVM ) )
        return lua_pushmatrix ( luaVM, *pMatrix );
    else if ( CAccount* pAccount = UserDataCast < CAccount > ( (CAccount*) NULL, pData, luaVM ) )
        return lua_pushaccount ( luaVM, pAccount );
    else if ( CAccessControlList* pACL = UserDataCast < CAccessControlList > ( (CAccessControlList*) NULL, pData, luaVM ) )
        return lua_pushacl ( luaVM, pACL );
    else if ( CAccessControlListGroup* pACLGroup = UserDataCast < CAccessControlListGroup > ( (CAccessControlListGroup*) NULL, pData, luaVM ) )
        return lua_pushaclgroup ( luaVM, pACLGroup );
    else if ( CBan* pBan = UserDataCast < CBan > ( (CBan*) NULL, pData, luaVM ) )
        return lua_pushban ( luaVM, pBan );
    else if ( CTextDisplay* pTextDisplay = UserDataCast < CTextDisplay > ( (CTextDisplay*) NULL, pData, luaVM ) )
        return lua_pushtextdisplay ( luaVM, pTextDisplay );
    else if ( CTextItem* pTextItem = UserDataCast < CTextItem > ( (CTextItem*) NULL, pData, luaVM ) )
        return lua_pushtextitem ( luaVM, pTextItem );
    else if ( CDbJobData* pQuery = UserDataCast < CDbJobData > ( (CDbJobData*) NULL, pData, luaVM ) )
        return lua_pushquery ( luaVM, pQuery );

    lua_pushobject ( luaVM, NULL, pData );
}