00001
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #pragma once
00033
00034 #include "K3dLua.h"
00035 #include "../System/K3dScene.h"
00036 #include "../System/GameData/K3dGameData.h"
00037 #include "../MathCore/K3dIntrLinSph.h"
00038 #include "../System/Builder/K3dCameraBuild.h"
00039 #include "../System/Builder/K3dObjectBuild.h"
00040
00041 class K3dVM
00042 {
00043 static K3dLua *ms_pLua;
00044 static K3dGameData *ms_pGameData;
00045 static K3dScene *ms_pScene;
00046 static K3dCameraBuild *ms_pCameraBuild;
00047 static void *ms_pObject;
00048
00050 static int K3d_LoadMap ( lua_State *_pState );
00051 void LoadMap ( K3dString &_strFilename );
00052 static int K3d_Print ( lua_State *_pState );
00053 void Print ( const char* _str );
00054 static int K3d_PrintValue ( lua_State *_pState );
00055 void PrintValue ( const char* _strComment,const float _fValue );
00056 static int K3d_IsMouseLeft ( lua_State *_pState );
00057 bool IsMouseLeft();
00058 static int K3d_IsMouseRight ( lua_State *_pState );
00059 bool IsMouseRight();
00060 static int K3d_IsMouseLeftUp ( lua_State *_pState );
00061 bool IsMouseLeftUp();
00062 static int K3d_IsMouseRightUp ( lua_State *_pState );
00063 bool IsMouseRightUp();
00064 static int K3d_Wait ( lua_State *_pState );
00065 bool Wait ( const int _iMsec );
00066 static int K3d_IncludeScript ( lua_State *_pState );
00067 void IncludeScript ( const char* _strFileName );
00068 bool CheckKeyboardKey ( const char* _strKey );
00069 static int K3d_CheckKeyboardKey ( lua_State *_pState );
00070 void LoadNewScript ( const char* _strFileName );
00071 static int K3d_LoadNewScript ( lua_State *_pState );
00072 void Exit();
00073 static int K3d_Exit ( lua_State *_pState );
00074
00076 static int K3d_AddVertex ( lua_State *_pState );
00077 int AddVertex ( const float _x,const float _y,const float _z,const char _r,const char _g,const char _b,const int _size );
00078 K3dRay *GetAimRay();
00079 static int K3d_GetAimRay ( lua_State *_pState );
00080 static int K3d_GetCamPos ( lua_State *_pState );
00081 void GetCamPos ( const int _iId, K3dVector3 &_rkCamPos );
00082 static int K3d_GetCamDir ( lua_State *_pState );
00083 void GetCamDir ( const int _iId, K3dVector3 &_rkCamDir );
00084 static int K3d_GetObject ( lua_State *_pState );
00085 int GetObject ( const char* _strObjName, const int _iObjType );
00086 static int K3d_GetRayOrigDir ( lua_State *_pState );
00087 K3dRayObj *GetRayOrigDir ( const int _iRayId );
00088 static int K3d_Hide ( lua_State *_pState );
00089 void Hide ( const int _iObjId, const int _iObjType, const bool _bHide );
00090 static int K3d_SetLine ( lua_State *_pState );
00091 void SetLine ( const int _iLineId, const float _origx,const float _origy,const float _origz,const float _dirx,const float _diry,const float _dirz );
00092 static int K3d_SetColor ( lua_State *_pState );
00093 void SetColor ( const int _iObjId, const int _iObjType, const char _r,const char _g,const char _b );
00094 static int K3d_SetRay ( lua_State *_pState );
00095 void SetRay ( const int _iRayId, const float _origx,const float _origy,const float _origz,const float _dirx,const float _diry,const float _dirz );
00096 static int K3d_SetVertexPos ( lua_State *_pState );
00097 void SetVertexPos ( const int _iVertexId, const float _x,const float _y,const float _z );
00098 static int K3d_MoveByMouse ( lua_State *_pState );
00099 void MoveByMouse ( const int _iSphereId );
00100 static int K3d_GetSpherePos ( lua_State *_pState );
00101 void GetSpherePos ( const int _iId, K3dVector3 &_rkPos );
00102 static int K3d_Link ( lua_State *_pState );
00103 void Link ( const int _iObjId0, const int _iObjId1, const int _iObjType0, const int _iObjType1 );
00104
00106 static int K3d_GetIntersection ( lua_State *_pState );
00107 bool GetIntersection ( const int _iObjId0, const int _iObjId1, const int _iObjType0, const int _iObjType1, K3dVector3 &_rkInrPoint );
00108 bool GetIntersection ( const int _iObjId0, const int _iObjId1, const int _iObjType0, const int _iObjType1 );
00109 static int K3d_GetDistance ( lua_State *_pState );
00110 float GetDistance ( const int _iObjId0, const int _iObjId1, const int _iObjType0, const int _iObjType1 );
00111
00113 int GetGuiObject ( const char* _strObjName, const int _iObjType );
00114 static int K3d_GetGuiObject ( lua_State *_pState );
00115 bool ButtonIsPressed ( const int _iButtonId );
00116 static int K3d_ButtonIsPressed ( lua_State *_pState );
00117 void HideGui ( const int _iObjId, const int _iObjType );
00118 static int K3d_HideGui ( lua_State *_pState );
00119 void ShowGui ( const int _iObjId, const int _iObjType );
00120 static int K3d_ShowGui ( lua_State *_pState );
00121 void ShowFileListBox ( const int _iListModel, const char * _strPath );
00122 static int K3d_ShowFileListBox ( lua_State *_pState );
00123 bool LoadMapFromListBox ( const int _iListBoxId, const char * _strPath );
00124 static int K3d_LoadMapFromListBox ( lua_State *_pState );
00125
00126
00127
00128 public:
00129 K3dVM ( K3dGameData *_pGameData, K3dScene *_pScene );
00130 K3dVM() {}
00131 ~K3dVM();
00132
00133 void RegisterFunctions();
00134 void LoadScript ( K3dString _strFilename );
00135 void Engine_Init();
00136 void Engine_Update();
00137 void Engine_Delete();
00138
00139 K3dLua *GetLua()
00140 {
00141 return ms_pLua;
00142 }
00143 };
00144
00145
00146