225e9689dd
- aggiunta funzione Exe e Lua Transform che porta gli oggetti nel globale de riferimento indicato.
276 lines
8.0 KiB
C++
276 lines
8.0 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : LUA_GeoTransform.cpp Data : 29.09.14 Versione : 1.5i5
|
|
// Contenuto : Funzioni di trasformazione geometrica per LUA.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 29.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LUA.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EXeConst.h"
|
|
#include "/EgtDev/Include/EGkLuaAux.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaTransform( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : Id/s, Frame [, nRefType]
|
|
INTVECTOR vId ;
|
|
LuaCheckParam( L, 1, vId)
|
|
Frame3d frRef ;
|
|
LuaCheckParam( L, 2, frRef)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 3, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// eseguo trasformazione
|
|
bool bOk = ExeTransform( vId, frRef, nRefType) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMove( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : Id/s, VtMove [, nRefType]
|
|
INTVECTOR vId ;
|
|
LuaCheckParam( L, 1, vId)
|
|
Vector3d vtMove ;
|
|
LuaCheckParam( L, 2, vtMove)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 3, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// eseguo traslazione
|
|
bool bOk = ExeMove( vId, vtMove, nRefType) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRotate( lua_State* L)
|
|
{
|
|
// 4 o 5 parametri : Id/s, PtAx, VtAx, dAngRotDeg [, nRefType]
|
|
INTVECTOR vId ;
|
|
LuaCheckParam( L, 1, vId)
|
|
Point3d ptAx ;
|
|
LuaCheckParam( L, 2, ptAx)
|
|
Vector3d vtAx ;
|
|
LuaCheckParam( L, 3, vtAx)
|
|
double dAngRotDeg ;
|
|
LuaCheckParam( L, 4, dAngRotDeg)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 5, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// eseguo rotazione
|
|
bool bOk = ExeRotate( vId, ptAx, vtAx, dAngRotDeg, nRefType) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaScale( lua_State* L)
|
|
{
|
|
// 5 o 6 parametri : Id/s, Frame, CoeffX, CoeffY, CoeffZ [, nRefType]
|
|
INTVECTOR vId ;
|
|
LuaCheckParam( L, 1, vId)
|
|
Frame3d frRef ;
|
|
LuaCheckParam( L, 2, frRef)
|
|
double dCoeffX ;
|
|
LuaCheckParam( L, 3, dCoeffX)
|
|
double dCoeffY ;
|
|
LuaCheckParam( L, 4, dCoeffY)
|
|
double dCoeffZ ;
|
|
LuaCheckParam( L, 5, dCoeffZ)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// eseguo scalatura
|
|
bool bOk = ExeScale( vId, frRef, dCoeffX, dCoeffY, dCoeffZ, nRefType) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMirror( lua_State* L)
|
|
{
|
|
// 3 o 4 parametri : Id/s, PtOn, VtN [, nRefType]
|
|
INTVECTOR vId ;
|
|
LuaCheckParam( L, 1, vId)
|
|
Point3d ptOn ;
|
|
LuaCheckParam( L, 2, ptOn)
|
|
Vector3d vtN ;
|
|
LuaCheckParam( L, 3, vtN)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 4, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// eseguo riflessione
|
|
bool bOk = ExeMirror( vId, ptOn, vtN, nRefType) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaShear( lua_State* L)
|
|
{
|
|
// 5 o 6 parametri : Id, PtOn, VtN, VtDir, Coeff [, nRefType]
|
|
INTVECTOR vId ;
|
|
LuaCheckParam( L, 1, vId)
|
|
Point3d ptOn ;
|
|
LuaCheckParam( L, 2, ptOn)
|
|
Vector3d vtN ;
|
|
LuaCheckParam( L, 3, vtN)
|
|
Vector3d vtDir ;
|
|
LuaCheckParam( L, 4, vtDir)
|
|
double dCoeff ;
|
|
LuaCheckParam( L, 5, dCoeff)
|
|
int nRefType = RTY_DEFAULT ;
|
|
LuaGetParam( L, 6, nRefType) ;
|
|
LuaClearStack( L) ;
|
|
// eseguo stiramento
|
|
bool bOk = ExeShear( vId, ptOn, vtN, vtDir, dCoeff, nRefType) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMoveGroup( lua_State* L)
|
|
{
|
|
// 2 parametri : Id, VtMove
|
|
int nId ;
|
|
LuaCheckParam( L, 1, nId)
|
|
Vector3d vtMove ;
|
|
LuaCheckParam( L, 2, vtMove)
|
|
LuaClearStack( L) ;
|
|
// eseguo traslazione
|
|
bool bOk = ExeMoveGroup( nId, vtMove) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRotateGroup( lua_State* L)
|
|
{
|
|
// 4 parametri : Id, PtAx, VtAx, dAngRotDeg
|
|
int nId ;
|
|
LuaCheckParam( L, 1, nId)
|
|
Point3d ptAx ;
|
|
LuaCheckParam( L, 2, ptAx)
|
|
Vector3d vtAx ;
|
|
LuaCheckParam( L, 3, vtAx)
|
|
double dAngRotDeg ;
|
|
LuaCheckParam( L, 4, dAngRotDeg)
|
|
LuaClearStack( L) ;
|
|
// eseguo rotazione
|
|
bool bOk = ExeRotateGroup( nId, ptAx, vtAx, dAngRotDeg) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaScaleGroup( lua_State* L)
|
|
{
|
|
// 5 parametri : Id, Frame, CoeffX, CoeffY, CoeffZ
|
|
int nId ;
|
|
LuaCheckParam( L, 1, nId)
|
|
Frame3d frRef ;
|
|
LuaCheckParam( L, 2, frRef)
|
|
double dCoeffX ;
|
|
LuaCheckParam( L, 3, dCoeffX)
|
|
double dCoeffY ;
|
|
LuaCheckParam( L, 4, dCoeffY)
|
|
double dCoeffZ ;
|
|
LuaCheckParam( L, 5, dCoeffZ)
|
|
LuaClearStack( L) ;
|
|
// eseguo scalatura
|
|
bool bOk = ExeScaleGroup( nId, frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMirrorGroup( lua_State* L)
|
|
{
|
|
// 3 parametri : Id, PtOn, VtN
|
|
int sId ;
|
|
LuaCheckParam( L, 1, sId)
|
|
Point3d ptOn ;
|
|
LuaCheckParam( L, 2, ptOn)
|
|
Vector3d vtN ;
|
|
LuaCheckParam( L, 3, vtN)
|
|
LuaClearStack( L) ;
|
|
// eseguo scalatura
|
|
bool bOk = ExeMirrorGroup( sId, ptOn, vtN) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaShearGroup( lua_State* L)
|
|
{
|
|
// 5 parametri : Id, PtOn, VtN, VtDir, Coeff
|
|
int nId ;
|
|
LuaCheckParam( L, 1, nId)
|
|
Point3d ptOn ;
|
|
LuaCheckParam( L, 2, ptOn)
|
|
Vector3d vtN ;
|
|
LuaCheckParam( L, 3, vtN)
|
|
Vector3d vtDir ;
|
|
LuaCheckParam( L, 4, vtDir)
|
|
double dCoeff ;
|
|
LuaCheckParam( L, 5, dCoeff)
|
|
LuaClearStack( L) ;
|
|
// eseguo scalatura
|
|
bool bOk = ExeShearGroup( nId, ptOn, vtN, vtDir, dCoeff) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallGeoTransform( LuaMgr& luaMgr)
|
|
{
|
|
bool bOk = ( &luaMgr != nullptr) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtTransform", LuaTransform) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMove", LuaMove) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtRotate", LuaRotate) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtScale", LuaScale) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMirror", LuaMirror) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtShear", LuaShear) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMoveGroup", LuaMoveGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtRotateGroup", LuaRotateGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtScaleGroup", LuaScaleGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMirrorGroup", LuaMirrorGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtShearGroup", LuaShearGroup) ;
|
|
return bOk ;
|
|
}
|