mirror of https://github.com/axmolengine/axmol.git
Merge pull request #11854 from samuele3hu/v3_physics3d
Add Lua bindings for Physics3D and related test case,then update template project
This commit is contained in:
commit
4000797ee7
|
@ -18,6 +18,7 @@ include_directories(
|
|||
${cocos_root}/cocos/editor-support
|
||||
${cocos_root}/cocos/platform
|
||||
${cocos_root}/cocos/audio/include
|
||||
${cocos_root}/cocos/physics3d
|
||||
manual
|
||||
manual/extension
|
||||
manual/cocostudio
|
||||
|
@ -108,6 +109,7 @@ set(lua_bindings_manual_files
|
|||
manual/ui/lua_cocos2dx_ui_manual.cpp
|
||||
manual/video/lua_cocos2dx_experimental_video_manual.cpp
|
||||
manual/audioengine/lua_cocos2dx_audioengine_manual.cpp
|
||||
manual/physics3d/lua_cocos2dx_physics3d_manual.cpp
|
||||
)
|
||||
|
||||
set(lua_bindings_auto_files
|
||||
|
@ -125,6 +127,7 @@ set(lua_bindings_auto_files
|
|||
auto/lua_cocos2dx_csloader_auto.cpp
|
||||
auto/lua_cocos2dx_ui_auto.cpp
|
||||
auto/lua_cocos2dx_audioengine_auto.cpp
|
||||
auto/lua_cocos2dx_physics3d_auto.cpp
|
||||
)
|
||||
|
||||
if(MACOSX)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "lua_cocos2dx_3d_auto.hpp"
|
||||
#include "LuaBasicConversions.h"
|
||||
#include "CCLuaEngine.h"
|
||||
#include "3d/CCBundle3D.h"
|
||||
|
||||
extern int lua_cocos2dx_3d_Sprite3D_setBlendFunc(lua_State* L);
|
||||
|
||||
|
@ -231,9 +232,9 @@ bool luaval_to_terraindata(lua_State* L, int lo, cocos2d::Terrain::TerrainData*
|
|||
{
|
||||
lua_pushstring(L, "_chunkSize");
|
||||
lua_gettable(L,lo);
|
||||
if (!lua_isnil(L, -1))
|
||||
if (!lua_isnil(L, lua_gettop(L)))
|
||||
{
|
||||
luaval_to_size(L, -1, &(outValue->_chunkSize));
|
||||
luaval_to_size(L, lua_gettop(L), &(outValue->_chunkSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -526,6 +527,56 @@ static void extendTerrain(lua_State* L)
|
|||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int lua_cocos2dx_3d_Bundle3D_getTrianglesList(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(L,1,"cc.Bundle3D",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
std::string arg0;
|
||||
ok &= luaval_to_std_string(L, 2,&arg0, "cc.Bundle3D:getTrianglesList");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_3d_Bundle3D_getTrianglesList'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<cocos2d::Vec3> ret = cocos2d::Bundle3D::getTrianglesList(arg0);
|
||||
std_vector_vec3_to_luaval(L,ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Bundle3D:getTrianglesList",argc, 1);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_3d_Bundle3D_getTrianglesList'.",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extendBundle3D(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "cc.Bundle3D");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "getTrianglesList", lua_cocos2dx_3d_Bundle3D_getTrianglesList);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
|
||||
static int register_all_cocos2dx_3d_manual(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
|
@ -533,6 +584,7 @@ static int register_all_cocos2dx_3d_manual(lua_State* L)
|
|||
|
||||
extendSprite3D(L);
|
||||
extendTerrain(L);
|
||||
extendBundle3D(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -2243,6 +2243,49 @@ bool luaval_to_std_vector_vec2(lua_State* L, int lo, std::vector<cocos2d::Vec2>*
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool luaval_to_std_vector_vec3(lua_State* L, int lo, std::vector<cocos2d::Vec3>* ret, const char* funcName)
|
||||
{
|
||||
if (nullptr == L || nullptr == ret || lua_gettop(L) < lo)
|
||||
return false;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
bool ok = true;
|
||||
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err))
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err,funcName);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
size_t len = lua_objlen(L, lo);
|
||||
cocos2d::Vec3 value;
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
lua_pushnumber(L, i + 1);
|
||||
lua_gettable(L,lo);
|
||||
if (lua_istable(L, lua_gettop(L)))
|
||||
{
|
||||
ok &= luaval_to_vec3(L, lua_gettop(L), &value);
|
||||
if (ok)
|
||||
{
|
||||
ret->push_back(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "vec3 type is needed");
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool luaval_to_std_vector_v3f_c4b_t2f(lua_State* L, int lo, std::vector<cocos2d::V3F_C4B_T2F>* ret, const char* funcName)
|
||||
{
|
||||
if (nullptr == L || nullptr == ret || lua_gettop(L) < lo)
|
||||
|
@ -3270,3 +3313,20 @@ void texParams_to_luaval(lua_State* L, const cocos2d::Texture2D::TexParams& inVa
|
|||
lua_pushnumber(L, (lua_Number) inValue.wrapT); /* L: table key value*/
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
void std_vector_vec3_to_luaval(lua_State* L, const std::vector<cocos2d::Vec3>& inValue)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return;
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
int index = 1;
|
||||
for (const cocos2d::Vec3& value : inValue)
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
vec3_to_luaval(L, value);
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -818,6 +818,17 @@ extern bool luaval_to_std_vector_v3f_c4b_t2f(lua_State* L, int lo, std::vector<c
|
|||
*/
|
||||
extern bool luaval_to_std_vector_vec2(lua_State* L, int lo, std::vector<cocos2d::Vec2>* ret, const char* funcName = "");
|
||||
|
||||
/**
|
||||
* Get a pointer points to a std::vector<cocos2d::Vec3> from a Lua array table in the stack.
|
||||
*
|
||||
* @param L the current lua_State.
|
||||
* @param lo the given accpetable index of stack.
|
||||
* @param ret a pointer points to a std::vector<cocos2d::Vec3>.
|
||||
* @param funcName the name of calling function, it is used for error output in the debug model.
|
||||
* @return Return true if the value at the given accpetable index of stack is a table, otherwise return false.
|
||||
*/
|
||||
extern bool luaval_to_std_vector_vec3(lua_State* L, int lo, std::vector<cocos2d::Vec3>* ret, const char* funcName = "");
|
||||
|
||||
/**@}**/
|
||||
|
||||
// from native
|
||||
|
@ -1263,6 +1274,14 @@ void quaternion_to_luaval(lua_State* L,const cocos2d::Quaternion& inValue);
|
|||
*/
|
||||
void texParams_to_luaval(lua_State* L, const cocos2d::Texture2D::TexParams& inValue);
|
||||
|
||||
/**
|
||||
* Push a Lua array table converted from a std::vector<cocos2d::Vec3> into the Lua stack.
|
||||
* The format of table as follows: {vec3Value1, vec3Value2, ..., vec3ValueSize}
|
||||
*
|
||||
* @param L the current lua_State.
|
||||
* @param inValue a std::vector<cocos2d::Vec3> vaule.
|
||||
*/
|
||||
void std_vector_vec3_to_luaval(lua_State* L, const std::vector<cocos2d::Vec3>& inValue);
|
||||
// end group
|
||||
/// @}
|
||||
#endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__
|
||||
|
|
|
@ -4657,6 +4657,106 @@ tolua_lerror:
|
|||
|
||||
#endif //CC_USE_PHYSICS
|
||||
|
||||
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
#include "physics3d/CCPhysics3DWorld.h"
|
||||
int lua_cocos2dx_Scene_getPhysics3DWorld(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Scene* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Scene",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Scene*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Scene_getPhysics3DWorld'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Scene_getPhysics3DWorld'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cocos2d::Physics3DWorld* ret = cobj->getPhysics3DWorld();
|
||||
object_to_luaval<cocos2d::Physics3DWorld>(tolua_S, "cc.Physics3DWorld",(cocos2d::Physics3DWorld*)ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scene:getPhysics3DWorld",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scene_getPhysics3DWorld'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_cocos2dx_Scene_setPhysics3DDebugCamera(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Scene* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Scene",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Scene*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Scene_setPhysics3DDebugCamera'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S, 2, "cc.Camera", 0, &tolua_err)) {
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
|
||||
cocos2d::Camera* camera = (cocos2d::Camera*)tolua_tousertype(tolua_S,2,0);
|
||||
cobj->setPhysics3DDebugCamera(camera);
|
||||
return 0;
|
||||
}
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Scene:setPhysics3DDebugCamera",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Scene_setPhysics3DDebugCamera'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void extendScene(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "cc.Scene");
|
||||
|
@ -4664,12 +4764,12 @@ static void extendScene(lua_State* tolua_S)
|
|||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
lua_pushstring(tolua_S, "getPhysicsWorld");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_Scene_getPhysicsWorld);
|
||||
lua_rawset(tolua_S, -3);
|
||||
lua_pushstring(tolua_S, "createWithPhysics");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_Scene_createWithPhysics);
|
||||
lua_rawset(tolua_S, -3);
|
||||
tolua_function(tolua_S, "getPhysicsWorld", lua_cocos2dx_Scene_getPhysicsWorld);
|
||||
tolua_function(tolua_S, "createWithPhysics", lua_cocos2dx_Scene_createWithPhysics);
|
||||
#endif
|
||||
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
tolua_function(tolua_S, "getPhysics3DWorld", lua_cocos2dx_Scene_getPhysics3DWorld);
|
||||
tolua_function(tolua_S, "setPhysics3DDebugCamera", lua_cocos2dx_Scene_setPhysics3DDebugCamera);
|
||||
#endif
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
|
@ -8008,6 +8108,253 @@ tolua_lerror:
|
|||
#endif
|
||||
}
|
||||
|
||||
int tolua_cocos2d_Mat4_translate(lua_State* tolua_S)
|
||||
{
|
||||
bool ok = true;
|
||||
int argc = lua_gettop(tolua_S);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
if (argc == 1)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
||||
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
|
||||
!tolua_istable(tolua_S, 2, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cocos2d::Mat4 mat;
|
||||
cocos2d::Vec3 vec3;
|
||||
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
||||
if (!ok)
|
||||
return 0;
|
||||
|
||||
ok &= luaval_to_vec3(tolua_S, 2, &vec3);
|
||||
if (!ok)
|
||||
return 0;
|
||||
|
||||
mat.translate(vec3);
|
||||
mat4_to_luaval(tolua_S, mat);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Mat4_translate'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int tolua_cocos2d_Mat4_createRotationZ(lua_State* tolua_S)
|
||||
{
|
||||
bool ok = true;
|
||||
int argc = lua_gettop(tolua_S);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
if (argc == 2)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
||||
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cocos2d::Mat4 mat;
|
||||
float angle;
|
||||
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
||||
if (!ok)
|
||||
return 0;
|
||||
angle = lua_tonumber(tolua_S, 2);
|
||||
cocos2d::Mat4::createRotationZ(angle, &mat);
|
||||
mat4_to_luaval(tolua_S, mat);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Mat4_createRotationZ'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int tolua_cocos2d_Mat4_setIdentity(lua_State* tolua_S)
|
||||
{
|
||||
bool ok = true;
|
||||
int argc = lua_gettop(tolua_S);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
if (argc == 1)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
||||
if (!tolua_istable(tolua_S, 1, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cocos2d::Mat4 mat;
|
||||
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
||||
if (!ok)
|
||||
return 0;
|
||||
mat.setIdentity();
|
||||
mat4_to_luaval(tolua_S, mat);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Mat4_setIdentity'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int tolua_cocos2d_Mat4_createTranslation(lua_State* tolua_S)
|
||||
{
|
||||
bool ok = true;
|
||||
int argc = lua_gettop(tolua_S);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
if (argc == 4)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
||||
if ( !tolua_isnumber(tolua_S, 1, 0, &tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 2, 0, &tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
|
||||
!tolua_istable(tolua_S, 4, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cocos2d::Mat4 dst;
|
||||
ok &= luaval_to_mat4(tolua_S, 4, &dst, "cc.Mat4.createTranslation");
|
||||
if (!ok)
|
||||
return 0;
|
||||
|
||||
float xTranslation = (float)lua_tonumber(tolua_S, 1);
|
||||
float yTranslation = (float)lua_tonumber(tolua_S, 2);
|
||||
float zTranslation = (float)lua_tonumber(tolua_S, 3);
|
||||
|
||||
cocos2d::Mat4::createTranslation(xTranslation, yTranslation, zTranslation, &dst);
|
||||
mat4_to_luaval(tolua_S, dst);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (argc == 2)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
||||
if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) ||
|
||||
!tolua_istable(tolua_S, 2, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cocos2d::Vec3 translation;
|
||||
cocos2d::Mat4 dst;
|
||||
|
||||
ok &= luaval_to_vec3(tolua_S, 1, &translation, "cc.Mat4.createTranslation");
|
||||
ok &= luaval_to_mat4(tolua_S, 2, &dst, "cc.Mat4.createTranslation");
|
||||
if (!ok)
|
||||
return 0;
|
||||
|
||||
cocos2d::Mat4::createTranslation(translation, &dst);
|
||||
mat4_to_luaval(tolua_S, dst);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Mat4_createTranslation'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int tolua_cocos2d_Mat4_createRotation(lua_State* tolua_S)
|
||||
{
|
||||
bool ok = true;
|
||||
int argc = lua_gettop(tolua_S);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
if (argc == 2)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
||||
if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) ||
|
||||
!tolua_istable(tolua_S, 2, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cocos2d::Quaternion quat;
|
||||
cocos2d::Mat4 dst;
|
||||
|
||||
ok &= luaval_to_quaternion(tolua_S, 1, &quat, "cc.Mat4.createRotation");
|
||||
ok &= luaval_to_mat4(tolua_S, 2, &dst, "cc.Mat4.createRotation");
|
||||
if (!ok)
|
||||
return 0;
|
||||
|
||||
cocos2d::Mat4::createRotation(quat, &dst);
|
||||
mat4_to_luaval(tolua_S, dst);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (argc == 3)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
|
||||
if ( !tolua_istable(tolua_S, 1, 0, &tolua_err) ||
|
||||
!tolua_isnumber(tolua_S, 2, 0, &tolua_err) ||
|
||||
!tolua_istable(tolua_S, 3, 0, &tolua_err))
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cocos2d::Vec3 axis;
|
||||
cocos2d::Mat4 dst;
|
||||
|
||||
ok &= luaval_to_vec3(tolua_S, 1, &axis, "cc.Mat4.createRotation");
|
||||
ok &= luaval_to_mat4(tolua_S, 3, &dst, "cc.Mat4.createRotation");
|
||||
if (!ok)
|
||||
return 0;
|
||||
|
||||
float angle = (float)tolua_tonumber(tolua_S, 2, 0);
|
||||
|
||||
cocos2d::Mat4::createRotation(axis, angle, &dst);
|
||||
mat4_to_luaval(tolua_S, dst);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'tolua_cocos2d_Mat4_createRotation'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int register_all_cocos2dx_math_manual(lua_State* tolua_S)
|
||||
{
|
||||
if (nullptr == tolua_S)
|
||||
|
@ -8020,6 +8367,11 @@ int register_all_cocos2dx_math_manual(lua_State* tolua_S)
|
|||
tolua_function(tolua_S, "mat4_transformVector", tolua_cocos2d_Mat4_transformVector);
|
||||
tolua_function(tolua_S, "mat4_decompose", tolua_cocos2d_Mat4_decompose);
|
||||
tolua_function(tolua_S, "mat4_multiply", tolua_cocos2d_Mat4_multiply);
|
||||
tolua_function(tolua_S, "mat4_translate", tolua_cocos2d_Mat4_translate);
|
||||
tolua_function(tolua_S, "mat4_createRotationZ", tolua_cocos2d_Mat4_createRotationZ);
|
||||
tolua_function(tolua_S, "mat4_setIdentity", tolua_cocos2d_Mat4_setIdentity);
|
||||
tolua_function(tolua_S, "mat4_createTranslation", tolua_cocos2d_Mat4_createTranslation);
|
||||
tolua_function(tolua_S, "mat4_createRotation", tolua_cocos2d_Mat4_createRotation);
|
||||
tolua_function(tolua_S, "vec3_cross", tolua_cocos2d_Vec3_cross);
|
||||
tolua_endmodule(tolua_S);
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,826 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "platform/CCPlatformConfig.h"
|
||||
#include "base/ccConfig.h"
|
||||
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
#include "lua_cocos2dx_physics3d_manual.h"
|
||||
#include "lua_cocos2dx_physics3d_auto.hpp"
|
||||
#include "tolua_fix.h"
|
||||
#include "LuaBasicConversions.h"
|
||||
#include "CCLuaEngine.h"
|
||||
#include "physics3d/CCPhysics3D.h"
|
||||
|
||||
bool luaval_to_Physics3DRigidBodyDes(lua_State* L,int lo,cocos2d::Physics3DRigidBodyDes* outValue, const char* funcName)
|
||||
{
|
||||
if (nullptr == L || nullptr == outValue)
|
||||
return false;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err) )
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err,funcName);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
lua_pushstring(L, "mass");
|
||||
lua_gettable(L, lo);
|
||||
outValue->mass = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "localInertia");
|
||||
lua_gettable(L, lo);
|
||||
if (!lua_istable(L, -1))
|
||||
{
|
||||
outValue->localInertia = cocos2d::Vec3(0.0, 0.0, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
luaval_to_vec3(L, lua_gettop(L), &outValue->localInertia);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "shape");
|
||||
lua_gettable(L, lo);
|
||||
if (!tolua_isusertype(L, -1, "cc.Physics3DShape", 0, &tolua_err))
|
||||
{
|
||||
outValue->shape = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
outValue->shape = static_cast<cocos2d::Physics3DShape*>(tolua_tousertype(L, lua_gettop(L), nullptr));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "originalTransform");
|
||||
lua_gettable(L, lo);
|
||||
if (!lua_istable(L, -1))
|
||||
{
|
||||
outValue->originalTransform = cocos2d::Mat4();
|
||||
}
|
||||
else
|
||||
{
|
||||
luaval_to_mat4(L, lua_gettop(L), &outValue->originalTransform);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "disableSleep");
|
||||
lua_gettable(L, lo);
|
||||
outValue->disableSleep = lua_isnil(L, -1) ? false : lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool luaval_to_Physics3DWorld_HitResult(lua_State* L,int lo, cocos2d::Physics3DWorld::HitResult* outValue, const char* funcName)
|
||||
{
|
||||
if (nullptr == L || nullptr == outValue)
|
||||
return false;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err) )
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err,funcName);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
lua_pushstring(L, "hitPosition");
|
||||
lua_gettable(L, lo);
|
||||
if (!lua_istable(L, -1))
|
||||
{
|
||||
outValue->hitPosition = cocos2d::Vec3();
|
||||
}
|
||||
else
|
||||
{
|
||||
luaval_to_vec3(L, lua_gettop(L), &(outValue->hitPosition));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "hitNormal");
|
||||
lua_gettable(L, lo);
|
||||
if (!lua_istable(L, -1))
|
||||
{
|
||||
outValue->hitNormal = cocos2d::Vec3();
|
||||
}
|
||||
else
|
||||
{
|
||||
luaval_to_vec3(L, lua_gettop(L), &(outValue->hitNormal));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "hitObj");
|
||||
lua_gettable(L, lo);
|
||||
if (!tolua_isusertype(L, -1, "cc.Physics3DObject", 0, &tolua_err))
|
||||
{
|
||||
outValue->hitObj = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
outValue->hitObj = static_cast<cocos2d::Physics3DObject*>(tolua_tousertype(L, lua_gettop(L), nullptr));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Physics3DWorld_HitResult_to_luaval(lua_State* L, const cocos2d::Physics3DWorld::HitResult& hitResult)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return;
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "hitPosition");
|
||||
vec3_to_luaval(L, hitResult.hitPosition);
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "hitNormal");
|
||||
vec3_to_luaval(L, hitResult.hitNormal);
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "hitObj");
|
||||
if (nullptr == hitResult.hitObj)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
}
|
||||
else
|
||||
{
|
||||
object_to_luaval<cocos2d::Physics3DObject>(L, "cc.Physics3DObject",hitResult.hitObj);
|
||||
}
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics3d_PhysicsSprite3D_create(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(L,1,"cc.PhysicsSprite3D",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
std::string arg0;
|
||||
cocos2d::Physics3DRigidBodyDes arg1;
|
||||
ok &= luaval_to_std_string(L, 2,&arg0, "cc.PhysicsSprite3D:create");
|
||||
ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsSprite3D:create");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_create'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1);
|
||||
object_to_luaval<cocos2d::PhysicsSprite3D>(L, "cc.PhysicsSprite3D",(cocos2d::PhysicsSprite3D*)ret);
|
||||
return 1;
|
||||
}
|
||||
if (argc == 3)
|
||||
{
|
||||
std::string arg0;
|
||||
cocos2d::Physics3DRigidBodyDes arg1;
|
||||
cocos2d::Vec3 arg2;
|
||||
ok &= luaval_to_std_string(L, 2,&arg0, "cc.PhysicsSprite3D:create");
|
||||
ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsSprite3D:create");
|
||||
ok &= luaval_to_vec3(L, 4, &arg2, "cc.PhysicsSprite3D:create");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_create'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1, arg2);
|
||||
object_to_luaval<cocos2d::PhysicsSprite3D>(L, "cc.PhysicsSprite3D",(cocos2d::PhysicsSprite3D*)ret);
|
||||
return 1;
|
||||
}
|
||||
if (argc == 4)
|
||||
{
|
||||
std::string arg0;
|
||||
cocos2d::Physics3DRigidBodyDes arg1;
|
||||
cocos2d::Vec3 arg2;
|
||||
cocos2d::Quaternion arg3;
|
||||
ok &= luaval_to_std_string(L, 2,&arg0, "cc.PhysicsSprite3D:create");
|
||||
ok &= luaval_to_Physics3DRigidBodyDes(L, 3, &arg1, "cc.PhysicsSprite3D:create");
|
||||
ok &= luaval_to_vec3(L, 4, &arg2, "cc.PhysicsSprite3D:create");
|
||||
ok &= luaval_to_quaternion(L, 5, &arg3);
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_create'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1, arg2, arg3);
|
||||
object_to_luaval<cocos2d::PhysicsSprite3D>(L, "cc.PhysicsSprite3D",(cocos2d::PhysicsSprite3D*)ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.PhysicsSprite3D:create",argc, 2);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_PhysicsSprite3D_create'.",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extendPhysicsSprite3D(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "cc.PhysicsSprite3D");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "create", lua_cocos2dx_physics3d_PhysicsSprite3D_create);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics3d_Physics3DRigidBody_create(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(L,1,"cc.Physics3DRigidBody",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
cocos2d::Physics3DRigidBodyDes arg0;
|
||||
ok &= luaval_to_Physics3DRigidBodyDes(L, 2, &arg0, "cc.Physics3DRigidBody:create");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DRigidBody_create'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cocos2d::Physics3DRigidBody* ret = cocos2d::Physics3DRigidBody::create(&arg0);
|
||||
object_to_luaval<cocos2d::Physics3DRigidBody>(L, "cc.Physics3DRigidBody",(cocos2d::Physics3DRigidBody*)ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Physics3DRigidBody:create",argc, 1);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DRigidBody_create'.",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extendPhysics3DRigidBody(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "cc.Physics3DRigidBody");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "create", lua_cocos2dx_physics3d_Physics3DRigidBody_create);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics3d_Physics3DComponent_create(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(L,1,"cc.Physics3DComponent",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L)-1;
|
||||
|
||||
do
|
||||
{
|
||||
if (argc == 1)
|
||||
{
|
||||
cocos2d::Physics3DObject* arg0;
|
||||
ok &= luaval_to_object<cocos2d::Physics3DObject>(L, 2, "cc.Physics3DObject",&arg0);
|
||||
if (!ok) { break; }
|
||||
cocos2d::Physics3DComponent* ret = cocos2d::Physics3DComponent::create(arg0);
|
||||
object_to_luaval<cocos2d::Physics3DComponent>(L, "cc.Physics3DComponent",(cocos2d::Physics3DComponent*)ret);
|
||||
return 1;
|
||||
}
|
||||
} while (0);
|
||||
ok = true;
|
||||
do
|
||||
{
|
||||
if (argc == 2)
|
||||
{
|
||||
cocos2d::Physics3DObject* arg0;
|
||||
ok &= luaval_to_object<cocos2d::Physics3DObject>(L, 2, "cc.Physics3DObject",&arg0);
|
||||
if (!ok) { break; }
|
||||
cocos2d::Vec3 arg1;
|
||||
ok &= luaval_to_vec3(L, 3, &arg1, "cc.Physics3DComponent:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::Physics3DComponent* ret = cocos2d::Physics3DComponent::create(arg0, arg1);
|
||||
object_to_luaval<cocos2d::Physics3DComponent>(L, "cc.Physics3DComponent",(cocos2d::Physics3DComponent*)ret);
|
||||
return 1;
|
||||
}
|
||||
} while (0);
|
||||
ok = true;
|
||||
do
|
||||
{
|
||||
if (argc == 3)
|
||||
{
|
||||
cocos2d::Physics3DObject* arg0;
|
||||
ok &= luaval_to_object<cocos2d::Physics3DObject>(L, 2, "cc.Physics3DObject",&arg0);
|
||||
if (!ok) { break; }
|
||||
cocos2d::Vec3 arg1;
|
||||
ok &= luaval_to_vec3(L, 3, &arg1, "cc.Physics3DComponent:create");
|
||||
if (!ok) { break; }
|
||||
cocos2d::Quaternion arg2;
|
||||
ok &= luaval_to_quaternion(L, 4, &arg2);
|
||||
if (!ok) { break; }
|
||||
cocos2d::Physics3DComponent* ret = cocos2d::Physics3DComponent::create(arg0, arg1, arg2);
|
||||
object_to_luaval<cocos2d::Physics3DComponent>(L, "cc.Physics3DComponent",(cocos2d::Physics3DComponent*)ret);
|
||||
return 1;
|
||||
}
|
||||
} while (0);
|
||||
ok = true;
|
||||
do
|
||||
{
|
||||
if (argc == 0)
|
||||
{
|
||||
cocos2d::Physics3DComponent* ret = cocos2d::Physics3DComponent::create();
|
||||
object_to_luaval<cocos2d::Physics3DComponent>(L, "cc.Physics3DComponent",(cocos2d::Physics3DComponent*)ret);
|
||||
return 1;
|
||||
}
|
||||
} while (0);
|
||||
ok = true;
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d", "cc.Physics3DComponent:create",argc, 0);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DComponent_create'.",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extendPhysics3DComponent(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "cc.Physics3DComponent");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "create", lua_cocos2dx_physics3d_Physics3DComponent_create);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics3d_Physics3DWorld_rayCast(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Physics3DWorld* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(L,1,"cc.Physics3DWorld",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Physics3DWorld*)tolua_tousertype(L,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_rayCast'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L)-1;
|
||||
if (argc == 3)
|
||||
{
|
||||
cocos2d::Vec3 arg0;
|
||||
cocos2d::Vec3 arg1;
|
||||
cocos2d::Physics3DWorld::HitResult arg2;
|
||||
|
||||
ok &= luaval_to_vec3(L, 2, &arg0, "cc.Physics3DWorld:rayCast");
|
||||
|
||||
ok &= luaval_to_vec3(L, 3, &arg1, "cc.Physics3DWorld:rayCast");
|
||||
|
||||
ok &= luaval_to_Physics3DWorld_HitResult(L, 4, &arg2, "cc.Physics3DWorld:rayCast");
|
||||
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_rayCast'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
bool ret = cobj->rayCast(arg0, arg1, &arg2);
|
||||
tolua_pushboolean(L,(bool)ret);
|
||||
Physics3DWorld_HitResult_to_luaval(L, arg2);
|
||||
return 2;
|
||||
}
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:rayCast",argc, 3);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_rayCast'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extendPhysics3DWorld(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "cc.Physics3DWorld");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "rayCast", lua_cocos2dx_physics3d_Physics3DWorld_rayCast);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics3d_Physics3DShape_createMesh(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(L,1,"cc.Physics3DShape",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
std::vector<Vec3> arg0;
|
||||
int arg1;
|
||||
ok &= luaval_to_std_vector_vec3(L, 2, &arg0, "cc.Physics3DShape:createMesh");
|
||||
ok &= luaval_to_int32(L, 3,(int *)&arg1, "cc.Physics3DShape:createMesh");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DShape_createMesh'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createMesh(&arg0[0], arg1);
|
||||
object_to_luaval<cocos2d::Physics3DShape>(L, "cc.Physics3DShape",(cocos2d::Physics3DShape*)ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Physics3DShape:createMesh",argc, 2);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DShape_createMesh'.",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics3d_Physics3DShape_createHeightfield(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(L,1,"cc.Physics3DShape",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (argc == 8)
|
||||
{
|
||||
int arg0;
|
||||
int arg1;
|
||||
std::vector<float> arg2;
|
||||
double arg3;
|
||||
double arg4;
|
||||
double arg5;
|
||||
bool arg6;
|
||||
bool arg7;
|
||||
ok &= luaval_to_int32(L, 2,(int *)&arg0, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_int32(L, 3,(int *)&arg1, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_std_vector_float(L, 4, &arg2,"cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_number(L, 5,&arg3, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_number(L, 6,&arg4, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_number(L, 7,&arg5, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_boolean(L, 8,&arg6, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_boolean(L, 9,&arg7, "cc.Physics3DShape:createHeightfield");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DShape_createHeightfield'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], arg3, arg4, arg5, arg6, arg7);
|
||||
object_to_luaval<cocos2d::Physics3DShape>(L, "cc.Physics3DShape",(cocos2d::Physics3DShape*)ret);
|
||||
return 1;
|
||||
}
|
||||
if (argc == 9)
|
||||
{
|
||||
int arg0;
|
||||
int arg1;
|
||||
std::vector<float> arg2;
|
||||
double arg3;
|
||||
double arg4;
|
||||
double arg5;
|
||||
bool arg6;
|
||||
bool arg7;
|
||||
bool arg8;
|
||||
ok &= luaval_to_int32(L, 2,(int *)&arg0, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_int32(L, 3,(int *)&arg1, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_std_vector_float(L, 4, &arg2,"cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_number(L, 5,&arg3, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_number(L, 6,&arg4, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_number(L, 7,&arg5, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_boolean(L, 8,&arg6, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_boolean(L, 9,&arg7, "cc.Physics3DShape:createHeightfield");
|
||||
ok &= luaval_to_boolean(L, 10,&arg8, "cc.Physics3DShape:createHeightfield");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(L,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DShape_createHeightfield'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], arg3, arg4, arg5, arg6, arg7, arg8);
|
||||
object_to_luaval<cocos2d::Physics3DShape>(L, "cc.Physics3DShape",(cocos2d::Physics3DShape*)ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Physics3DShape:createHeightfield",argc, 8);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DShape_createHeightfield'.",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics3d_Physics3DShape_createCompoundShape(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
bool ok = true;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertable(L,1,"cc.Physics3DShape",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L) - 1;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
|
||||
std::vector<std::pair<cocos2d::Physics3DShape *, cocos2d::Mat4>> shapes;
|
||||
if (!tolua_istable(L, 2, 0, &tolua_err) )
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err,"cc.Physics3DShape:createCompoundShape");
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
size_t len = lua_objlen(L, 2);
|
||||
cocos2d::Physics3DShape* shape = nullptr;
|
||||
cocos2d::Mat4 mat;
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
lua_pushnumber(L,i + 1);
|
||||
lua_gettable(L,2);
|
||||
if (lua_istable(L, -1))
|
||||
{
|
||||
lua_pushnumber(L, 1);
|
||||
lua_gettable(L, -2);
|
||||
luaval_to_object(L, lua_gettop(L), "cc.Physics3DShape", &shape);
|
||||
lua_pop(L,1);
|
||||
|
||||
lua_pushnumber(L, 2);
|
||||
lua_gettable(L, -2);
|
||||
luaval_to_mat4(L, lua_gettop(L), &mat);
|
||||
lua_pop(L,1);
|
||||
|
||||
shapes.push_back(std::make_pair(shape, mat));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createCompoundShape(shapes);
|
||||
object_to_luaval<cocos2d::Physics3DShape>(L, "cc.Physics3DShape",(cocos2d::Physics3DShape*)ret);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Physics3DShape:createCompoundShape",argc, 1);
|
||||
return 0;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DShape_createCompoundShape'.",&tolua_err);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extendPhysics3DShape(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "cc.Physics3DShape");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "createMesh", lua_cocos2dx_physics3d_Physics3DShape_createMesh);
|
||||
tolua_function(L, "createHeightfield", lua_cocos2dx_physics3d_Physics3DShape_createHeightfield);
|
||||
tolua_function(L, "createCompoundShape", lua_cocos2dx_physics3d_Physics3DShape_createCompoundShape);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
void CollisionPoint_to_luaval(lua_State* L,const cocos2d::Physics3DCollisionInfo::CollisionPoint& collisionPoint)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return;
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "localPositionOnA");
|
||||
vec3_to_luaval(L, collisionPoint.localPositionOnA);
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "worldPositionOnA");
|
||||
vec3_to_luaval(L, collisionPoint.worldPositionOnA);
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "localPositionOnB");
|
||||
vec3_to_luaval(L, collisionPoint.localPositionOnB);
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "worldPositionOnB");
|
||||
vec3_to_luaval(L, collisionPoint.worldPositionOnB);
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "worldNormalOnB");
|
||||
vec3_to_luaval(L, collisionPoint.worldNormalOnB);
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics3d_Physics3DObject_setCollisionCallback(lua_State* L)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Physics3DObject* cobj = nullptr;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(L,1,"cc.Physics3DObject",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Physics3DObject*)tolua_tousertype(L,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DObject_setCollisionCallback'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(L)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) {
|
||||
goto tolua_lerror;
|
||||
}
|
||||
#endif
|
||||
LUA_FUNCTION handler = toluafix_ref_function(L,2,0);
|
||||
cobj->setCollisionCallback([=](const cocos2d::Physics3DCollisionInfo& ci){
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "objA");
|
||||
if (nullptr == ci.objA)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
}
|
||||
else
|
||||
{
|
||||
object_to_luaval(L, "cc.Physics3DObject", ci.objA);
|
||||
}
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "objB");
|
||||
if (nullptr == ci.objB)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
}
|
||||
else
|
||||
{
|
||||
object_to_luaval(L, "cc.Physics3DObject", ci.objB);
|
||||
}
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "collisionPointList");
|
||||
if (ci.collisionPointList.empty())
|
||||
{
|
||||
lua_pushnil(L);
|
||||
}
|
||||
else
|
||||
{
|
||||
int vecIndex = 1;
|
||||
lua_newtable(L);
|
||||
for (auto value : ci.collisionPointList)
|
||||
{
|
||||
lua_pushnumber(L, vecIndex);
|
||||
CollisionPoint_to_luaval(L, value);
|
||||
lua_rawset(L, -3);
|
||||
++vecIndex;
|
||||
}
|
||||
}
|
||||
lua_rawset(L, -3);
|
||||
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1);
|
||||
});
|
||||
|
||||
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)cobj, handler);
|
||||
return 0;
|
||||
}
|
||||
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DObject:setCollisionCallback",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DObject_setCollisionCallback'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extendPhysics3DObject(lua_State* L)
|
||||
{
|
||||
lua_pushstring(L, "cc.Physics3DObject");
|
||||
lua_rawget(L, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(L,-1))
|
||||
{
|
||||
tolua_function(L, "setCollisionCallback", lua_cocos2dx_physics3d_Physics3DObject_setCollisionCallback);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int register_all_physics3d_manual(lua_State* L)
|
||||
{
|
||||
if (nullptr == L)
|
||||
return 0;
|
||||
|
||||
extendPhysicsSprite3D(L);
|
||||
extendPhysics3DRigidBody(L);
|
||||
extendPhysics3DComponent(L);
|
||||
extendPhysics3DWorld(L);
|
||||
extendPhysics3DShape(L);
|
||||
extendPhysics3DObject(L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int register_physics3d_module(lua_State* L)
|
||||
{
|
||||
lua_getglobal(L, "_G");
|
||||
if (lua_istable(L,-1))//stack:...,_G,
|
||||
{
|
||||
register_all_cocos2dx_physics3d(L);
|
||||
register_all_physics3d_manual(L);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#ifndef COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_PHYSICS3D_LUA_COCOS2DX_PHYSICS3D_MANUAL_H__
|
||||
#define COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_PHYSICS3D_LUA_COCOS2DX_PHYSICS3D_MANUAL_H__
|
||||
|
||||
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "tolua++.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup lua
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Call this function can import the lua bindings for the physics3d module.
|
||||
* After registering, we could call the related physics3d code conveniently in the lua.
|
||||
* If you don't want to use the physics3d module in the lua, you only don't call this registering function.
|
||||
* If you don't register the physics3d module, the package size would become smaller .
|
||||
* The current mechanism,this function is called in the lua_module_register.h
|
||||
*/
|
||||
|
||||
TOLUA_API int register_physics3d_module(lua_State* L);
|
||||
|
||||
// end group
|
||||
/// @}
|
||||
|
||||
#endif // #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
#endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_MANUAL_PHYSICS3D_LUA_COCOS2DX_PHYSICS3D_MANUAL_H__
|
|
@ -116,6 +116,10 @@ LOCAL_SRC_FILES += ../manual/ui/lua_cocos2dx_experimental_webview_manual.cpp \
|
|||
LOCAL_SRC_FILES += ../manual/extension/lua_cocos2dx_extension_manual.cpp \
|
||||
../auto/lua_cocos2dx_extension_auto.cpp \
|
||||
|
||||
#physics3d
|
||||
LOCAL_SRC_FILES += ../manual/physics3d/lua_cocos2dx_physics3d_manual.cpp \
|
||||
../auto/lua_cocos2dx_physics3d_auto.cpp \
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../external/lua/tolua \
|
||||
$(LOCAL_PATH)/../../../../external/lua/luajit/include \
|
||||
$(LOCAL_PATH)/../../../2d \
|
||||
|
@ -126,6 +130,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../external/lua/tolua \
|
|||
$(LOCAL_PATH)/../../../editor-support/cocostudio/ActionTimeline \
|
||||
$(LOCAL_PATH)/../../../editor-support/spine \
|
||||
$(LOCAL_PATH)/../../../ui \
|
||||
$(LOCAL_PATH)/../../../physics3d \
|
||||
$(LOCAL_PATH)/../../../../extensions \
|
||||
$(LOCAL_PATH)/../auto \
|
||||
$(LOCAL_PATH)/../manual \
|
||||
|
|
|
@ -151,6 +151,14 @@
|
|||
159552411A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1595523E1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp */; };
|
||||
159552421A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1595523F1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp */; };
|
||||
159552431A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1595523F1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp */; };
|
||||
15A561E51B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15A561E31B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.cpp */; };
|
||||
15A561E61B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15A561E31B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.cpp */; };
|
||||
15A561E71B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15A561E41B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.hpp */; };
|
||||
15A561E81B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15A561E41B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.hpp */; };
|
||||
15A561EC1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15A561EA1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp */; };
|
||||
15A561ED1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15A561EA1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp */; };
|
||||
15A561EE1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A561EB1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h */; };
|
||||
15A561EF1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 15A561EB1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h */; };
|
||||
15AC69D519876E9300D17520 /* lua_cocos2dx_physics_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AACE75218BC45C200215002 /* lua_cocos2dx_physics_auto.cpp */; };
|
||||
15AC69D619876EA200D17520 /* lua_cocos2dx_physics_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1AACE75318BC45C200215002 /* lua_cocos2dx_physics_auto.hpp */; };
|
||||
15AC69D91987710400D17520 /* tolua_event.c in Sources */ = {isa = PBXBuildFile; fileRef = 1ABCA1F918CD8F6E0087CE3A /* tolua_event.c */; };
|
||||
|
@ -316,6 +324,10 @@
|
|||
159552391A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_csloader_auto.hpp; sourceTree = "<group>"; };
|
||||
1595523E1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_csloader_manual.cpp; sourceTree = "<group>"; };
|
||||
1595523F1A25E4B8001E9FC9 /* lua_cocos2dx_csloader_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_csloader_manual.hpp; sourceTree = "<group>"; };
|
||||
15A561E31B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_physics3d_auto.cpp; sourceTree = "<group>"; };
|
||||
15A561E41B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_physics3d_auto.hpp; sourceTree = "<group>"; };
|
||||
15A561EA1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lua_cocos2dx_physics3d_manual.cpp; path = physics3d/lua_cocos2dx_physics3d_manual.cpp; sourceTree = "<group>"; };
|
||||
15A561EB1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lua_cocos2dx_physics3d_manual.h; path = physics3d/lua_cocos2dx_physics3d_manual.h; sourceTree = "<group>"; };
|
||||
15B5754D1A6F4D1500041C20 /* lua-cocos-studio-conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "lua-cocos-studio-conversions.cpp"; sourceTree = "<group>"; };
|
||||
15B5754E1A6F4D1500041C20 /* lua-cocos-studio-conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "lua-cocos-studio-conversions.h"; sourceTree = "<group>"; };
|
||||
15C1BCC019864D8700A46ACC /* lua_cocos2dx_cocosbuilder_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_cocosbuilder_auto.cpp; sourceTree = "<group>"; };
|
||||
|
@ -476,6 +488,15 @@
|
|||
path = 3d;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
15A561E91B00A3D0005D4720 /* physics3d */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
15A561EA1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp */,
|
||||
15A561EB1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h */,
|
||||
);
|
||||
name = physics3d;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
15C1BCD21986525900A46ACC /* cocos2d */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -572,6 +593,8 @@
|
|||
1AACE74818BC45C200215002 /* auto */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
15A561E31B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.cpp */,
|
||||
15A561E41B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.hpp */,
|
||||
15C9A10C1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.cpp */,
|
||||
15C9A10D1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.hpp */,
|
||||
159552381A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp */,
|
||||
|
@ -608,6 +631,7 @@
|
|||
1AACE75B18BC45C200215002 /* manual */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
15A561E91B00A3D0005D4720 /* physics3d */,
|
||||
3E2BDB0719C5E6100055CDCD /* audioengine */,
|
||||
158C128419A0FA1300781A76 /* 3d */,
|
||||
15427D41198F73F700DC375D /* cocosdenshion */,
|
||||
|
@ -779,6 +803,7 @@
|
|||
15EFA1F71989E582000C57D3 /* lua_cocos2dx_experimental_auto.hpp in Headers */,
|
||||
15415AA719A71A53004F1E71 /* auxiliar.h in Headers */,
|
||||
155C7E1019A71C9D00F08B25 /* lua_extensions.h in Headers */,
|
||||
15A561E71B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.hpp in Headers */,
|
||||
15415ABF19A71A53004F1E71 /* mime.h in Headers */,
|
||||
15AC69E21987712500D17520 /* tolua_event.h in Headers */,
|
||||
15415AD719A71A53004F1E71 /* udp.h in Headers */,
|
||||
|
@ -820,6 +845,7 @@
|
|||
15C1C2DC19874B4400A46ACC /* xxtea.h in Headers */,
|
||||
15415AD319A71A53004F1E71 /* timeout.h in Headers */,
|
||||
15C1C2D5198749BC00A46ACC /* LuaOpengl.h in Headers */,
|
||||
15A561EE1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h in Headers */,
|
||||
155C7E2819A71CE600F08B25 /* lua_cocos2dx_ui_manual.hpp in Headers */,
|
||||
15C1C2D6198749BC00A46ACC /* lua_cocos2dx_deprecated.h in Headers */,
|
||||
15C1C2D7198749BC00A46ACC /* lua_cocos2dx_experimental_manual.hpp in Headers */,
|
||||
|
@ -860,6 +886,7 @@
|
|||
15EFA650198B3342000C57D3 /* lualib.h in Headers */,
|
||||
155C7E1519A71CAA00F08B25 /* Lua_web_socket.h in Headers */,
|
||||
15EFA64B198B3320000C57D3 /* tolua_event.h in Headers */,
|
||||
15A561EF1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h in Headers */,
|
||||
15EFA64C198B3320000C57D3 /* tolua++.h in Headers */,
|
||||
155C7DF919A71C4500F08B25 /* lua_cocos2dx_cocosdenshion_manual.h in Headers */,
|
||||
15415AB019A71A53004F1E71 /* except.h in Headers */,
|
||||
|
@ -900,6 +927,7 @@
|
|||
15EFA622198B2E74000C57D3 /* lua_cocos2dx_experimental_auto.hpp in Headers */,
|
||||
15EFA623198B2E74000C57D3 /* lua_cocos2dx_auto.hpp in Headers */,
|
||||
155C7E0119A71C6300F08B25 /* CCBProxy.h in Headers */,
|
||||
15A561E81B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.hpp in Headers */,
|
||||
15415AC819A71A53004F1E71 /* select.h in Headers */,
|
||||
155C7E1D19A71CC300F08B25 /* lua_cocos2dx_spine_manual.hpp in Headers */,
|
||||
15EFA624198B2E74000C57D3 /* lua_cocos2dx_physics_auto.hpp in Headers */,
|
||||
|
@ -984,6 +1012,7 @@
|
|||
15B5754F1A6F4D1500041C20 /* lua-cocos-studio-conversions.cpp in Sources */,
|
||||
15415A7619A718FB004F1E71 /* lua_cocos2dx_ui_auto.cpp in Sources */,
|
||||
15415A7719A718FB004F1E71 /* lua_cocos2dx_spine_auto.cpp in Sources */,
|
||||
15A561E51B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.cpp in Sources */,
|
||||
15415A7819A718FB004F1E71 /* lua_cocos2dx_studio_auto.cpp in Sources */,
|
||||
155C7DEC19A71BF200F08B25 /* lua_cocos2dx_cocosdenshion_auto.cpp in Sources */,
|
||||
15AC69D91987710400D17520 /* tolua_event.c in Sources */,
|
||||
|
@ -1035,6 +1064,7 @@
|
|||
155C7DF619A71C3E00F08B25 /* lua_cocos2dx_cocosdenshion_manual.cpp in Sources */,
|
||||
15415AA519A71A53004F1E71 /* auxiliar.c in Sources */,
|
||||
155C7E1A19A71CBC00F08B25 /* lua_cocos2dx_spine_manual.cpp in Sources */,
|
||||
15A561EC1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp in Sources */,
|
||||
15C1C2D01987498B00A46ACC /* lua_cocos2dx_experimental_manual.cpp in Sources */,
|
||||
15C1C2D11987498B00A46ACC /* lua_cocos2dx_manual.cpp in Sources */,
|
||||
15C1C2D21987498B00A46ACC /* lua_cocos2dx_physics_manual.cpp in Sources */,
|
||||
|
@ -1052,6 +1082,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
15415AC619A71A53004F1E71 /* select.c in Sources */,
|
||||
15A561ED1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp in Sources */,
|
||||
15EFA646198B3311000C57D3 /* tolua_event.c in Sources */,
|
||||
3E2BDB0A19C5E6100055CDCD /* lua_cocos2dx_audioengine_manual.cpp in Sources */,
|
||||
15415AA619A71A53004F1E71 /* auxiliar.c in Sources */,
|
||||
|
@ -1076,6 +1107,7 @@
|
|||
15415AD219A71A53004F1E71 /* timeout.c in Sources */,
|
||||
F4FE0D5819ECD00100B8B12B /* luasocket_scripts.c in Sources */,
|
||||
15EFA639198B328B000C57D3 /* tolua_fix.cpp in Sources */,
|
||||
15A561E61B00A09A005D4720 /* lua_cocos2dx_physics3d_auto.cpp in Sources */,
|
||||
155C7DFF19A71C5C00F08B25 /* CCBProxy.cpp in Sources */,
|
||||
1595523B1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp in Sources */,
|
||||
15C9A1121AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.cpp in Sources */,
|
||||
|
@ -1142,6 +1174,7 @@
|
|||
"COCOS2D_DEBUG=1",
|
||||
USE_FILE32API,
|
||||
"CC_ENABLE_CHIPMUNK_INTEGRATION=1",
|
||||
"CC_ENABLE_BULLET_INTEGRATION=1",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
|
@ -1159,7 +1192,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../.. $(SRCROOT)/../../../base $(SRCROOT)/../../../3d $(SRCROOT)/../../../2d $(SRCROOT)/../../../deprecated $(SRCROOT)/../../../physics $(SRCROOT)/../../../math/kazmath $(SRCROOT)/../../../2d/platform $(SRCROOT)/../../../audio/include $(SRCROOT)/../../../editor-support $(SRCROOT)/../../../editor-support/spine $(SRCROOT)/../../../editor-support/cocostudio $(SRCROOT)/../../../editor-support/cocosbuilder $(SRCROOT)/../../../ui $(SRCROOT)/../../../storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external/lua $(SRCROOT)/../../../../external/lua/luajit/include $(SRCROOT)/../../../../external/lua/tolua $(SRCROOT)/../../../editor-support/cocostudio/ActionTimeline";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../.. $(SRCROOT)/../../../base $(SRCROOT)/../../../3d $(SRCROOT)/../../../2d $(SRCROOT)/../../../deprecated $(SRCROOT)/../../../physics $(SRCROOT)/../../../math/kazmath $(SRCROOT)/../../../2d/platform $(SRCROOT)/../../../audio/include $(SRCROOT)/../../../editor-support $(SRCROOT)/../../../editor-support/spine $(SRCROOT)/../../../editor-support/cocostudio $(SRCROOT)/../../../editor-support/cocosbuilder $(SRCROOT)/../../../ui $(SRCROOT)/../../../storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external/lua $(SRCROOT)/../../../../external/lua/luajit/include $(SRCROOT)/../../../../external/lua/tolua $(SRCROOT)/../../../editor-support/cocostudio/ActionTimeline $(SRCROOT)/../../../physics3d";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
|
@ -1176,6 +1209,7 @@
|
|||
"CC_ENABLE_CHIPMUNK_INTEGRATION=1",
|
||||
NDEBUG,
|
||||
USE_FILE32API,
|
||||
"CC_ENABLE_BULLET_INTEGRATION=1",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
|
@ -1192,7 +1226,7 @@
|
|||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../.. $(SRCROOT)/../../../base $(SRCROOT)/../../../3d $(SRCROOT)/../../../2d $(SRCROOT)/../../../deprecated $(SRCROOT)/../../../physics $(SRCROOT)/../../../math/kazmath $(SRCROOT)/../../../2d/platform $(SRCROOT)/../../../audio/include $(SRCROOT)/../../../editor-support $(SRCROOT)/../../../editor-support/spine $(SRCROOT)/../../../editor-support/cocostudio $(SRCROOT)/../../../editor-support/cocosbuilder $(SRCROOT)/../../../ui $(SRCROOT)/../../../storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external/lua $(SRCROOT)/../../../../external/lua/luajit/include $(SRCROOT)/../../../../external/lua/tolua $(SRCROOT)/../../../editor-support/cocostudio/ActionTimeline";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../.. $(SRCROOT)/../../../base $(SRCROOT)/../../../3d $(SRCROOT)/../../../2d $(SRCROOT)/../../../deprecated $(SRCROOT)/../../../physics $(SRCROOT)/../../../math/kazmath $(SRCROOT)/../../../2d/platform $(SRCROOT)/../../../audio/include $(SRCROOT)/../../../editor-support $(SRCROOT)/../../../editor-support/spine $(SRCROOT)/../../../editor-support/cocostudio $(SRCROOT)/../../../editor-support/cocosbuilder $(SRCROOT)/../../../ui $(SRCROOT)/../../../storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external/lua $(SRCROOT)/../../../../external/lua/luajit/include $(SRCROOT)/../../../../external/lua/tolua $(SRCROOT)/../../../editor-support/cocostudio/ActionTimeline $(SRCROOT)/../../../physics3d";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
<ClCompile Include="..\auto\lua_cocos2dx_experimental_video_auto.cpp" />
|
||||
<ClCompile Include="..\auto\lua_cocos2dx_experimental_webview_auto.cpp" />
|
||||
<ClCompile Include="..\auto\lua_cocos2dx_extension_auto.cpp" />
|
||||
<ClCompile Include="..\auto\lua_cocos2dx_physics3d_auto.cpp" />
|
||||
<ClCompile Include="..\auto\lua_cocos2dx_physics_auto.cpp" />
|
||||
<ClCompile Include="..\auto\lua_cocos2dx_spine_auto.cpp" />
|
||||
<ClCompile Include="..\auto\lua_cocos2dx_studio_auto.cpp" />
|
||||
|
@ -71,6 +72,7 @@
|
|||
<ClCompile Include="..\manual\network\lua_extensions.c" />
|
||||
<ClCompile Include="..\manual\network\Lua_web_socket.cpp" />
|
||||
<ClCompile Include="..\manual\network\lua_xml_http_request.cpp" />
|
||||
<ClCompile Include="..\manual\physics3d\lua_cocos2dx_physics3d_manual.cpp" />
|
||||
<ClCompile Include="..\manual\spine\LuaSkeletonAnimation.cpp" />
|
||||
<ClCompile Include="..\manual\spine\lua_cocos2dx_spine_manual.cpp" />
|
||||
<ClCompile Include="..\manual\tolua_fix.cpp" />
|
||||
|
@ -111,6 +113,7 @@
|
|||
<ClInclude Include="..\auto\lua_cocos2dx_experimental_video_auto.hpp" />
|
||||
<ClInclude Include="..\auto\lua_cocos2dx_experimental_webview_auto.hpp" />
|
||||
<ClInclude Include="..\auto\lua_cocos2dx_extension_auto.hpp" />
|
||||
<ClInclude Include="..\auto\lua_cocos2dx_physics3d_auto.hpp" />
|
||||
<ClInclude Include="..\auto\lua_cocos2dx_physics_auto.hpp" />
|
||||
<ClInclude Include="..\auto\lua_cocos2dx_spine_auto.hpp" />
|
||||
<ClInclude Include="..\auto\lua_cocos2dx_studio_auto.hpp" />
|
||||
|
@ -141,6 +144,7 @@
|
|||
<ClInclude Include="..\manual\network\lua_extensions.h" />
|
||||
<ClInclude Include="..\manual\network\Lua_web_socket.h" />
|
||||
<ClInclude Include="..\manual\network\lua_xml_http_request.h" />
|
||||
<ClInclude Include="..\manual\physics3d\lua_cocos2dx_physics3d_manual.h" />
|
||||
<ClInclude Include="..\manual\spine\LuaSkeletonAnimation.h" />
|
||||
<ClInclude Include="..\manual\spine\lua_cocos2dx_spine_manual.hpp" />
|
||||
<ClInclude Include="..\manual\tolua_fix.h" />
|
||||
|
@ -269,8 +273,8 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;$(EngineRoot)external\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;$(EngineRoot)external\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
|
@ -301,8 +305,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$
|
|||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\physics3d;$(EngineRoot)external;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>
|
||||
|
|
|
@ -73,6 +73,9 @@
|
|||
<Filter Include="manual\audioengine">
|
||||
<UniqueIdentifier>{08e7d51a-6f8a-4e54-8abe-a86101be8dad}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="manual\physics3d">
|
||||
<UniqueIdentifier>{3934b26e-18b0-465a-a89e-69a3417d107e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\auto\lua_cocos2dx_auto.cpp">
|
||||
|
@ -273,6 +276,12 @@
|
|||
<ClCompile Include="..\manual\ui\lua_cocos2dx_experimental_webview_manual.cpp">
|
||||
<Filter>manual\ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\auto\lua_cocos2dx_physics3d_auto.cpp">
|
||||
<Filter>auto</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\manual\physics3d\lua_cocos2dx_physics3d_manual.cpp">
|
||||
<Filter>manual\physics3d</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\auto\lua_cocos2dx_auto.hpp">
|
||||
|
@ -479,6 +488,12 @@
|
|||
<ClInclude Include="..\manual\ui\lua_cocos2dx_experimental_webview_manual.hpp">
|
||||
<Filter>manual\ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\auto\lua_cocos2dx_physics3d_auto.hpp">
|
||||
<Filter>auto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\manual\physics3d\lua_cocos2dx_physics3d_manual.h">
|
||||
<Filter>manual\physics3d</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\script\CCBReaderLoad.lua">
|
||||
|
|
|
@ -558,3 +558,23 @@ function cc.mat4.createRotation(q, dst)
|
|||
|
||||
return dst
|
||||
end
|
||||
|
||||
function cc.mat4.translate(self,vec3)
|
||||
return mat4_translate(self,vec3)
|
||||
end
|
||||
|
||||
function cc.mat4.createRotationZ(self,angle)
|
||||
return mat4_createRotationZ(self,angle)
|
||||
end
|
||||
|
||||
function cc.mat4.setIdentity(self)
|
||||
return mat4_setIdentity(self)
|
||||
end
|
||||
|
||||
function cc.mat4.createTranslation(...)
|
||||
return mat4_createTranslation(...)
|
||||
end
|
||||
|
||||
function cc.mat4.createRotation(...)
|
||||
return mat4_createRotation(...)
|
||||
end
|
|
@ -101,6 +101,9 @@ end
|
|||
-- cocosbuilder
|
||||
require "cocos.cocosbuilder.CCBReaderLoad"
|
||||
|
||||
-- physics3d
|
||||
require "cocos.physics3d.physics3d-constants"
|
||||
|
||||
if CC_USE_FRAMEWORK then
|
||||
require "cocos.framework.init"
|
||||
end
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
if nil == cc.Physics3DComponent then
|
||||
return
|
||||
end
|
||||
|
||||
cc.Physics3DComponent.PhysicsSyncFlag =
|
||||
{
|
||||
NONE = 0,
|
||||
NODE_TO_PHYSICS = 1,
|
||||
PHYSICS_TO_NODE = 2,
|
||||
NODE_AND_NODE = 3,
|
||||
}
|
||||
|
||||
cc.Physics3DObject.PhysicsObjType =
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
RIGID_BODY = 1,
|
||||
}
|
|
@ -34,6 +34,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${COCOS2D_ROOT}/cmake/Modules/")
|
|||
include(CocosBuildHelpers)
|
||||
|
||||
option(DEBUG_MODE "Debug or release?" ON)
|
||||
option(USE_BULLET "Use bullet for physics3d library" ON)
|
||||
|
||||
if(DEBUG_MODE)
|
||||
set(CMAKE_BUILD_TYPE DEBUG)
|
||||
|
@ -41,6 +42,11 @@ else(DEBUG_MODE)
|
|||
set(CMAKE_BUILD_TYPE RELEASE)
|
||||
endif(DEBUG_MODE)
|
||||
|
||||
if(USE_BULLET)
|
||||
add_definitions(-DCC_ENABLE_BULLET_INTEGRATION=1)
|
||||
add_definitions(-DCC_USE_PHYSICS=1)
|
||||
endif(USE_BULLET)
|
||||
|
||||
|
||||
# libcocos2d
|
||||
set(BUILD_CPP_TESTS OFF CACHE BOOL "turn off build cpp-tests")
|
||||
|
@ -129,5 +135,7 @@ pre_build(${APP_NAME}
|
|||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/extension ${APP_BIN_DIR}/Resources
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/network ${APP_BIN_DIR}/Resources
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/ui ${APP_BIN_DIR}/Resources
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/3d ${APP_BIN_DIR}/Resources
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua-bindings/script/physics3d ${APP_BIN_DIR}/Resources
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
APP_STL := gnustl_static
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCC_ENABLE_BULLET_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
|
||||
|
|
|
@ -830,6 +830,7 @@
|
|||
USE_FILE32API,
|
||||
"CC_LUA_ENGINE_ENABLED=1",
|
||||
"CC_ENABLE_CHIPMUNK_INTEGRATION=1",
|
||||
"CC_ENABLE_BULLET_INTEGRATION=1",
|
||||
GLFW_EXPOSE_NATIVE_COCOA,
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
|
@ -853,6 +854,7 @@
|
|||
USE_FILE32API,
|
||||
"CC_LUA_ENGINE_ENABLED=1",
|
||||
"CC_ENABLE_CHIPMUNK_INTEGRATION=1",
|
||||
"CC_ENABLE_BULLET_INTEGRATION=1",
|
||||
);
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;CC_ENABLE_BULLET_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||
|
@ -135,7 +135,7 @@ xcopy "$(ProjectDir)..\..\..\src" "$(ProjectDir)..\..\..\runtime\win32\src" /D /
|
|||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;CC_ENABLE_BULLET_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h"
|
||||
#include "3d/lua_cocos2dx_3d_manual.h"
|
||||
#include "audioengine/lua_cocos2dx_audioengine_manual.h"
|
||||
#include "physics3d/lua_cocos2dx_physics3d_manual.h"
|
||||
|
||||
|
||||
int lua_module_register(lua_State* L)
|
||||
|
@ -24,6 +25,9 @@ int lua_module_register(lua_State* L)
|
|||
register_cocosdenshion_module(L);
|
||||
register_cocos3d_module(L);
|
||||
register_audioengine_module(L);
|
||||
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
register_physics3d_module(L);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
|
@ -130,7 +130,7 @@ xcopy "$(OutDir)..\*.dll" "$(OutDir)" /D /Y</Command>
|
|||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
|
|
|
@ -0,0 +1,712 @@
|
|||
|
||||
local START_POS_X = -0.5
|
||||
local START_POS_Y = -2.5
|
||||
local START_POS_Z = -0.5
|
||||
|
||||
local ARRAY_SIZE_X = 4
|
||||
local ARRAY_SIZE_Y = 3
|
||||
local ARRAY_SIZE_Z = 4
|
||||
----------------------------------------
|
||||
----Physics3DTestDemo
|
||||
----------------------------------------
|
||||
local Physics3DTestDemo = class("Physics3DTestDemo", function ()
|
||||
-- body
|
||||
local layer = cc.Layer:create()
|
||||
return layer
|
||||
end)
|
||||
|
||||
function Physics3DTestDemo:ctor()
|
||||
|
||||
Helper.initWithLayer(self)
|
||||
Helper.titleLabel:setString(self:title())
|
||||
Helper.subtitleLabel:setString(self:subtitle())
|
||||
|
||||
local function onNodeEvent(event)
|
||||
if "enter" == event then
|
||||
self:onEnter()
|
||||
elseif "exit" == event then
|
||||
self:onExit()
|
||||
end
|
||||
end
|
||||
|
||||
self:registerScriptHandler(onNodeEvent)
|
||||
end
|
||||
|
||||
function Physics3DTestDemo:title()
|
||||
return "Physics3D Test"
|
||||
end
|
||||
|
||||
function Physics3DTestDemo:subtitle()
|
||||
return ""
|
||||
end
|
||||
|
||||
function Physics3DTestDemo:shootBox(des)
|
||||
local rbDes = {}
|
||||
local cameraPosition = self._camera:getPosition3D()
|
||||
local linearVec = cc.vec3normalize(cc.vec3(des.x - cameraPosition.x, des.y - cameraPosition.y, des.z - cameraPosition.z))
|
||||
linearVec = cc.vec3(linearVec.x * 100, linearVec.y * 100, linearVec.z * 100)
|
||||
|
||||
rbDes.originalTransform = cc.mat4.translate(cc.mat4.createIdentity(), self._camera:getPosition3D())
|
||||
rbDes.mass = 1.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(0.5, 0.5, 0.5))
|
||||
|
||||
local sprite = cc.PhysicsSprite3D:create("Sprite3DTest/box.c3t", rbDes)
|
||||
sprite:setTexture("Images/Icon.png")
|
||||
|
||||
local rigidBody = sprite:getPhysicsObj()
|
||||
rigidBody:setLinearFactor(cc.vec3(1.0, 1.0, 1.0))
|
||||
rigidBody:setLinearVelocity(linearVec)
|
||||
rigidBody:setAngularVelocity(cc.vec3(0.0, 0.0, 0.0))
|
||||
rigidBody:setCcdMotionThreshold(0.5)
|
||||
rigidBody:setCcdSweptSphereRadius(0.4)
|
||||
|
||||
self:addChild(sprite)
|
||||
sprite:setPosition3D(self._camera:getPosition3D())
|
||||
sprite:setScale(0.5)
|
||||
sprite:syncToNode()
|
||||
|
||||
--optimize, only sync node to physics
|
||||
sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) --sync node to physics
|
||||
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
end
|
||||
|
||||
function Physics3DTestDemo:onEnter()
|
||||
local scene = cc.Director:getInstance():getRunningScene()
|
||||
if nil ~= scene then
|
||||
self._physicsScene = scene
|
||||
local physics3DWorld = scene:getPhysics3DWorld()
|
||||
physics3DWorld:setDebugDrawEnable(false)
|
||||
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
self._camera = cc.Camera:createPerspective(30.0, size.width / size.height, 1.0, 1000.0)
|
||||
self._camera:setPosition3D(cc.vec3(0.0, 50.0, 100.0))
|
||||
self._camera:lookAt(cc.vec3(0.0, 0.0, 0.0), cc.vec3(0.0, 1.0, 0.0))
|
||||
self._camera:setCameraFlag(cc.CameraFlag.USER1)
|
||||
self:addChild(self._camera)
|
||||
|
||||
if Helper.index ~= 2 then
|
||||
local listener = cc.EventListenerTouchAllAtOnce:create()
|
||||
listener:registerScriptHandler(function(touches, event)
|
||||
self._needShootBox = true
|
||||
end,cc.Handler.EVENT_TOUCHES_BEGAN)
|
||||
|
||||
listener:registerScriptHandler(function(touches, event)
|
||||
|
||||
if #touches > 0 and self._camera ~= nil then
|
||||
local touch = touches[1]
|
||||
local delta = touch:getDelta()
|
||||
|
||||
self._angle = self._angle - delta.x * math.pi / 180.0
|
||||
self._camera:setPosition3D(cc.vec3(100.0 * math.sin(self._angle), 50.0, 100.0 * math.cos(self._angle)))
|
||||
self._camera:lookAt(cc.vec3(0.0, 0.0, 0.0), cc.vec3(0.0, 1.0, 0.0))
|
||||
|
||||
if (delta.x * delta.x + delta.y * delta.y) > 16 then
|
||||
self._needShootBox = false
|
||||
end
|
||||
end
|
||||
end, cc.Handler.EVENT_TOUCHES_MOVED)
|
||||
|
||||
listener:registerScriptHandler(function(touches, event)
|
||||
if self._needShootBox == false then
|
||||
return
|
||||
end
|
||||
|
||||
if #touches > 0 then
|
||||
local location = touches[1]:getLocationInView()
|
||||
local nearP = cc.vec3(location.x, location.y, -1.0)
|
||||
local farP = cc.vec3(location.x, location.y, 1.0)
|
||||
nearP = self._camera:unproject(nearP)
|
||||
farP = self._camera:unproject(farP)
|
||||
|
||||
local dir = cc.vec3(farP.x - nearP.x, farP.y - nearP.y, farP.z - nearP.z)
|
||||
local cameraPosition = self._camera:getPosition3D()
|
||||
self:shootBox(cc.vec3(cameraPosition.x + dir.x * 10, cameraPosition.y + dir.y * 10, cameraPosition.z + dir.z * 10))
|
||||
end
|
||||
end, cc.Handler.EVENT_TOUCHES_ENDED)
|
||||
|
||||
local eventDispatcher = self:getEventDispatcher()
|
||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self)
|
||||
end
|
||||
|
||||
local ttfConfig = {}
|
||||
ttfConfig.fontFilePath = "fonts/arial.ttf"
|
||||
ttfConfig.fontSize = 10
|
||||
local label = cc.Label:createWithTTF(ttfConfig,"DebugDraw OFF")
|
||||
local menuItem = cc.MenuItemLabel:create(label)
|
||||
menuItem:registerScriptTapHandler(function (tag, sender)
|
||||
if physics3DWorld:isDebugDrawEnabled() then
|
||||
physics3DWorld:setDebugDrawEnable(false)
|
||||
label:setString("DebugDraw OFF")
|
||||
else
|
||||
physics3DWorld:setDebugDrawEnable(true)
|
||||
label:setString("DebugDraw ON")
|
||||
end
|
||||
end)
|
||||
|
||||
local menu = cc.Menu:create(menuItem)
|
||||
menu:setPosition(cc.p(0.0,0.0))
|
||||
menuItem:setAnchorPoint(cc.p(0.0, 1.0))
|
||||
menuItem:setPosition(cc.p(VisibleRect:left().x, VisibleRect:top().y-50))
|
||||
self:addChild(menu)
|
||||
|
||||
self._angle = 0.0
|
||||
|
||||
self:extend()
|
||||
end
|
||||
end
|
||||
|
||||
function Physics3DTestDemo:onExit()
|
||||
|
||||
end
|
||||
|
||||
function Physics3DTestDemo:extend()
|
||||
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
----BasicPhysics3DDemo
|
||||
----------------------------------------
|
||||
local BasicPhysics3DDemo = class("BasicPhysics3DDemo", Physics3DTestDemo)
|
||||
|
||||
function BasicPhysics3DDemo:subtitle()
|
||||
return "Basic Physics3D"
|
||||
end
|
||||
|
||||
function BasicPhysics3DDemo:extend()
|
||||
local rbDes = {}
|
||||
rbDes.mass = 0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(60.0, 1.0, 60.0))
|
||||
|
||||
local floor = cc.PhysicsSprite3D:create("Sprite3DTest/box.c3t", rbDes)
|
||||
floor:setTexture("Sprite3DTest/plane.png")
|
||||
floor:setScaleX(60)
|
||||
floor:setScaleZ(60)
|
||||
self:addChild(floor)
|
||||
floor:setCameraMask(cc.CameraFlag.USER1)
|
||||
floor:syncToNode()
|
||||
floor:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE)
|
||||
|
||||
rbDes.mass = 1.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(0.8, 0.8, 0.8))
|
||||
|
||||
local start_x = START_POS_X - ARRAY_SIZE_X/2
|
||||
local start_y = START_POS_Y
|
||||
local start_z = START_POS_Z - ARRAY_SIZE_Z/2
|
||||
|
||||
for k = 1, ARRAY_SIZE_Y do
|
||||
for i = 1, ARRAY_SIZE_X do
|
||||
for j = 1, ARRAY_SIZE_Z do
|
||||
local x = 1.0 * (i - 1) + start_x
|
||||
local y = 5.0+1.0 * (k - 1) + start_y
|
||||
local z = 1.0 * (j - 1) + start_z
|
||||
|
||||
local sprite = cc.PhysicsSprite3D:create("Sprite3DTest/box.c3t", rbDes)
|
||||
sprite:setTexture("Images/CyanSquare.png")
|
||||
sprite:setPosition3D(cc.vec3(x, y, z))
|
||||
sprite:syncToNode()
|
||||
sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE)
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
sprite:setScale(0.8)
|
||||
self:addChild(sprite)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self._physicsScene:setPhysics3DDebugCamera(self._camera)
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
----Physics3DConstraintDemo
|
||||
----------------------------------------
|
||||
local Physics3DConstraintDemo = class("Physics3DConstraintDemo", Physics3DTestDemo)
|
||||
|
||||
function Physics3DConstraintDemo:subtitle()
|
||||
return "Physics3D Constraint"
|
||||
end
|
||||
|
||||
function Physics3DConstraintDemo:extend()
|
||||
|
||||
local listener = cc.EventListenerTouchAllAtOnce:create()
|
||||
listener:registerScriptHandler(function(touches, event)
|
||||
if nil ~= self._camera then
|
||||
local touch = touches[1]
|
||||
local location = touch:getLocationInView()
|
||||
local nearP = cc.vec3(location.x, location.y, 0.0)
|
||||
local farP = cc.vec3(location.x, location.y, 1.0)
|
||||
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
nearP = self._camera:unproject(size, nearP, nearP)
|
||||
farP = self._camera:unproject(size, farP, farP)
|
||||
|
||||
local physicsWorld = self._physicsScene:getPhysics3DWorld()
|
||||
local hitResult = {}
|
||||
local ret = false
|
||||
ret, hitResult = physicsWorld:rayCast(nearP, farP, hitResult)
|
||||
if true == ret and nil ~= hitResult.hitObj and hitResult.hitObj:getObjType() == cc.Physics3DObject.PhysicsObjType.RIGID_BODY then
|
||||
local mat = cc.mat4.getInversed(hitResult.hitObj:getWorldTransform())
|
||||
local position = {x = 0, y = 0, z = 0}
|
||||
position = cc.mat4.transformVector(mat, cc.vec4(hitResult.hitPosition.x, hitResult.hitPosition.y, hitResult.hitPosition.z, 1.0),position)
|
||||
|
||||
self._constraint = cc.Physics3DPointToPointConstraint:create(hitResult.hitObj, position)
|
||||
physicsWorld:addPhysics3DConstraint(self._constraint, true)
|
||||
self._pickingDistance = math.sqrt(math.pow(hitResult.hitPosition.x - nearP.x, 2) + math.pow(hitResult.hitPosition.y - nearP.y, 2) + math.pow(hitResult.hitPosition.z - nearP.z, 2))
|
||||
return
|
||||
end
|
||||
end
|
||||
self._needShootBox = false
|
||||
end,cc.Handler.EVENT_TOUCHES_BEGAN)
|
||||
|
||||
listener:registerScriptHandler(function(touches, event)
|
||||
|
||||
if self._constraint ~= nil then
|
||||
local touch = touches[1]
|
||||
local location = touch:getLocationInView()
|
||||
local nearP = cc.vec3(location.x, location.y, 0.0)
|
||||
local farP = cc.vec3(location.x, location.y, 1.0)
|
||||
|
||||
local size = cc.Director:getInstance():getWinSize()
|
||||
nearP = self._camera:unproject(size, nearP, nearP)
|
||||
farP = self._camera:unproject(size, farP, farP)
|
||||
local dir = cc.vec3normalize(cc.vec3(farP.x - nearP.x, farP.y - nearP.y, farP.z - nearP.z))
|
||||
self._constraint:setPivotPointInB(cc.vec3(nearP.x + dir.x * self._pickingDistance, nearP.y + dir.y * self._pickingDistance, nearP.z + dir.z * self._pickingDistance))
|
||||
return
|
||||
end
|
||||
|
||||
if #touches > 0 and self._camera ~= nil then
|
||||
local touch = touches[1]
|
||||
local delta = touch:getDelta()
|
||||
|
||||
self._angle = self._angle - delta.x * math.pi / 180.0
|
||||
self._camera:setPosition3D(cc.vec3(100.0 * math.sin(self._angle), 50.0, 100.0 * math.cos(self._angle)))
|
||||
self._camera:lookAt(cc.vec3(0.0, 0.0, 0.0), cc.vec3(0.0, 1.0, 0.0))
|
||||
|
||||
if (delta.x * delta.x + delta.y * delta.y) > 16 then
|
||||
self._needShootBox = false
|
||||
end
|
||||
end
|
||||
end, cc.Handler.EVENT_TOUCHES_MOVED)
|
||||
|
||||
listener:registerScriptHandler(function(touches, event)
|
||||
|
||||
if self._constraint ~= nil then
|
||||
self._physicsScene:getPhysics3DWorld():removePhysics3DConstraint(self._constraint)
|
||||
self._constraint = nil
|
||||
return
|
||||
end
|
||||
|
||||
if self._needShootBox == false then
|
||||
return
|
||||
end
|
||||
|
||||
if #touches > 0 then
|
||||
local location = touches[1]:getLocationInView()
|
||||
local nearP = cc.vec3(location.x, location.y, -1.0)
|
||||
local farP = cc.vec3(location.x, location.y, 1.0)
|
||||
nearP = self._camera:unproject(nearP)
|
||||
farP = self._camera:unproject(farP)
|
||||
|
||||
local dir = cc.vec3(farP.x - nearP.x, farP.y - nearP.y, farP.z - nearP.z)
|
||||
local cameraPosition = self._camera:getPosition3D()
|
||||
self:shootBox(cc.vec3(cameraPosition.x + dir.x * 10, cameraPosition.y + dir.y * 10, cameraPosition.z + dir.z * 10))
|
||||
end
|
||||
end, cc.Handler.EVENT_TOUCHES_ENDED)
|
||||
|
||||
local eventDispatcher = self:getEventDispatcher()
|
||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self)
|
||||
|
||||
local rbDes = {}
|
||||
rbDes.disableSleep = true
|
||||
--create box
|
||||
local sprite = cc.Sprite3D:create("Sprite3DTest/orc.c3b")
|
||||
rbDes.mass = 10.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(5.0, 5.0, 5.0))
|
||||
local rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
|
||||
local quat = cc.quaternion_createFromAxisAngle(cc.vec3(0, 1, 0), math.pi)
|
||||
local component = cc.Physics3DComponent:create(rigidBody, cc.vec3(0.0, -3.0, 0.0), quat)
|
||||
|
||||
sprite:addComponent(component)
|
||||
self:addChild(sprite)
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
sprite:setScale(0.4)
|
||||
sprite:setPosition3D(cc.vec3(-20.0, 5.0, 0.0))
|
||||
--sync node position to physics
|
||||
component:syncToNode()
|
||||
--physics controlled, we will not set position for it, so we can skip sync node position to physics
|
||||
component:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE)
|
||||
|
||||
self._physicsScene:setPhysics3DDebugCamera(self._camera)
|
||||
|
||||
local physicsWorld = self._physicsScene:getPhysics3DWorld()
|
||||
--create point to point constraint
|
||||
local constraint = cc.Physics3DPointToPointConstraint:create(rigidBody, cc.vec3(2.5, 2.5, 2.5))
|
||||
physicsWorld:addPhysics3DConstraint(constraint)
|
||||
|
||||
--create hinge constraint
|
||||
rbDes.mass = 1.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(8.0, 8.0, 1.0))
|
||||
rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
component = cc.Physics3DComponent:create(rigidBody)
|
||||
sprite = cc.Sprite3D:create("Sprite3DTest/box.c3t")
|
||||
sprite:setTexture("Sprite3DTest/plane.png")
|
||||
sprite:setScaleX(8.0)
|
||||
sprite:setScaleY(8.0)
|
||||
sprite:setPosition3D(cc.vec3(5.0, 0.0, 0.0))
|
||||
sprite:addComponent(component)
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
self:addChild(sprite)
|
||||
component:syncToNode()
|
||||
rigidBody:setAngularVelocity(cc.vec3(0,3,0))
|
||||
constraint = cc.Physics3DHingeConstraint:create(rigidBody, cc.vec3(4.0, 4.0, 0.5), cc.vec3(0.0, 1.0, 0.0))
|
||||
physicsWorld:addPhysics3DConstraint(constraint)
|
||||
|
||||
--create slider constraint
|
||||
rbDes.mass = 1.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(3.0, 2.0, 3.0))
|
||||
rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
component = cc.Physics3DComponent:create(rigidBody)
|
||||
sprite = cc.Sprite3D:create("Sprite3DTest/box.c3t")
|
||||
sprite:setTexture("Sprite3DTest/plane.png")
|
||||
sprite:setScaleX(3.0)
|
||||
sprite:setScaleZ(3.0)
|
||||
sprite:setPosition3D(cc.vec3(30.0, 15.0, 0.0))
|
||||
sprite:addComponent(component)
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
self:addChild(sprite)
|
||||
component:syncToNode()
|
||||
rigidBody:setLinearVelocity(cc.vec3(0,3,0))
|
||||
|
||||
rbDes.mass = 0.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(3.0, 3.0, 3.0))
|
||||
local rigidBodyB = cc.Physics3DRigidBody:create(rbDes)
|
||||
component = cc.Physics3DComponent:create(rigidBodyB)
|
||||
sprite = cc.Sprite3D:create("Sprite3DTest/box.c3t")
|
||||
sprite:setTexture("Sprite3DTest/plane.png")
|
||||
sprite:setScale(3.0)
|
||||
sprite:setPosition3D(cc.vec3(30.0, 5.0, 0.0))
|
||||
sprite:addComponent(component)
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
self:addChild(sprite)
|
||||
component:syncToNode()
|
||||
|
||||
local frameInA = cc.mat4.createRotationZ(cc.mat4.createIdentity(), math.pi / 2)
|
||||
local frameInB = frameInA
|
||||
frameInA[14] = -5.0
|
||||
frameInB[14] = 5.0
|
||||
constraint = cc.Physics3DSliderConstraint:create(rigidBody, rigidBodyB, frameInA, frameInB, false)
|
||||
physicsWorld:addPhysics3DConstraint(constraint)
|
||||
constraint:setLowerLinLimit(-5.0)
|
||||
constraint:setUpperLinLimit(5.0)
|
||||
|
||||
--create ConeTwist constraint
|
||||
rbDes.mass = 1.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(3.0, 3.0, 3.0))
|
||||
rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
component = cc.Physics3DComponent:create(rigidBody)
|
||||
sprite = cc.Sprite3D:create("Sprite3DTest/box.c3t")
|
||||
sprite:setTexture("Sprite3DTest/plane.png")
|
||||
sprite:setScale(3.0)
|
||||
sprite:setPosition3D(cc.vec3(-10.0, 5.0, 0.0))
|
||||
sprite:addComponent(component)
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
self:addChild(sprite)
|
||||
component:syncToNode()
|
||||
|
||||
frameInA = cc.mat4.createRotationZ(frameInA, math.pi / 2)
|
||||
frameInA[13] = 0.0
|
||||
frameInA[14] = -10.0
|
||||
frameInA[15] = 0.0
|
||||
constraint = cc.Physics3DConeTwistConstraint:create(rigidBody, frameInA)
|
||||
physicsWorld:addPhysics3DConstraint(constraint, true)
|
||||
constraint:setLimit(math.pi / 180 * 10, math.pi / 180 * 10, math.pi / 180 * 40)
|
||||
|
||||
--reate 6 dof constraint
|
||||
rbDes.mass = 1.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(3.0, 3.0, 3.0))
|
||||
rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
component = cc.Physics3DComponent:create(rigidBody)
|
||||
sprite = cc.Sprite3D:create("Sprite3DTest/box.c3t")
|
||||
sprite:setTexture("Sprite3DTest/plane.png")
|
||||
sprite:setScale(3.0)
|
||||
sprite:setPosition3D(cc.vec3(30.0, -5.0, 0.0))
|
||||
sprite:addComponent(component)
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
self:addChild(sprite)
|
||||
component:syncToNode()
|
||||
frameInA = cc.mat4.setIdentity(frameInA)
|
||||
constraint = cc.Physics3D6DofConstraint:create(rigidBody, frameInA, false)
|
||||
physicsWorld:addPhysics3DConstraint(constraint)
|
||||
constraint:setAngularLowerLimit(cc.vec3(0,0,0))
|
||||
constraint:setAngularUpperLimit(cc.vec3(0,0,0))
|
||||
constraint:setLinearLowerLimit(cc.vec3(-10,0,0))
|
||||
constraint:setLinearUpperLimit(cc.vec3(10,0,0))
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
----Physics3DKinematicDemo
|
||||
----------------------------------------
|
||||
local Physics3DKinematicDemo = class("Physics3DKinematicDemo", Physics3DTestDemo)
|
||||
|
||||
function Physics3DKinematicDemo:subtitle()
|
||||
return "Physics3D Kinematic"
|
||||
end
|
||||
|
||||
function Physics3DKinematicDemo:extend()
|
||||
local rbDes = {}
|
||||
rbDes.mass = 0.0
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(60.0, 1.0, 60.0))
|
||||
local floor = cc.PhysicsSprite3D:create("Sprite3DTest/box.c3t", rbDes)
|
||||
floor:setTexture("Sprite3DTest/plane.png")
|
||||
floor:setScaleX(60)
|
||||
floor:setScaleZ(60)
|
||||
floor:setPosition3D(cc.vec3(0.0, -1.0, 0.0))
|
||||
self:addChild(floor)
|
||||
floor:setCameraMask(cc.CameraFlag.USER1)
|
||||
floor:syncToNode()
|
||||
--static object sync is not needed
|
||||
floor:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE)
|
||||
|
||||
for i=1, 3 do
|
||||
|
||||
rbDes.mass = 0.0 --kinematic objects. zero mass so that it can not be affected by other dynamic objects
|
||||
rbDes.shape = cc.Physics3DShape:createBox(cc.vec3(2.0, 2.0, 2.0))
|
||||
|
||||
local sprite = cc.PhysicsSprite3D:create("Sprite3DTest/box.c3t", rbDes)
|
||||
sprite:setTexture("Images/CyanSquare.png")
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
local rigidBody = sprite:getPhysicsObj()
|
||||
rigidBody:setKinematic(true)
|
||||
|
||||
self:addChild(sprite)
|
||||
|
||||
sprite:setScale(2.0)
|
||||
sprite:setPosition3D(cc.vec3(-15.0, 0.0, 15.0 - 15.0 * (i - 1) ))
|
||||
local moveby = cc.MoveBy:create(2.0 + (i - 1), cc.vec3(30.0, 0.0, 0.0))
|
||||
sprite:runAction(cc.RepeatForever:create(cc.Sequence:create(moveby, moveby:reverse())))
|
||||
end
|
||||
|
||||
--create Dynamic
|
||||
--create several spheres
|
||||
rbDes.mass = 1.0
|
||||
rbDes.shape = cc.Physics3DShape:createSphere(0.5)
|
||||
local start_x = START_POS_X - ARRAY_SIZE_X/2
|
||||
local start_y = START_POS_Y + 5.0
|
||||
local start_z = START_POS_Z - ARRAY_SIZE_Z/2
|
||||
|
||||
for k = 1,ARRAY_SIZE_Y do
|
||||
for i = 1,ARRAY_SIZE_X do
|
||||
for j = 1,ARRAY_SIZE_Z do
|
||||
local x = 1.0 * (i - 1) + start_x
|
||||
local y = 5.0 + 1.0 * (k - 1) + start_y
|
||||
local z = 1.0 * (j - 1) + start_z
|
||||
if rbDes.originalTransform == nil then
|
||||
rbDes.originalTransform = cc.mat4.createIdentity()
|
||||
else
|
||||
rbDes.originalTransform = cc.mat4.setIdentity(rbDes.originalTransform)
|
||||
end
|
||||
|
||||
rbDes.originalTransform = cc.mat4.translate(rbDes.originalTransform, cc.vec3(x, y, z))
|
||||
|
||||
local sprite = cc.PhysicsSprite3D:create("Sprite3DTest/sphere.c3b", rbDes)
|
||||
sprite:setTexture("Sprite3DTest/plane.png")
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
sprite:setScale(1.00 / sprite:getContentSize().width)
|
||||
self:addChild(sprite)
|
||||
sprite:setPosition3D(cc.vec3(x, y, z))
|
||||
sprite:syncToNode()
|
||||
sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self._physicsScene:setPhysics3DDebugCamera(self._camera)
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
----Physics3DCollisionCallbackDemo
|
||||
----------------------------------------
|
||||
local Physics3DCollisionCallbackDemo = class("Physics3DCollisionCallbackDemo", Physics3DTestDemo)
|
||||
|
||||
function Physics3DCollisionCallbackDemo:subtitle()
|
||||
return "Physics3D CollisionCallback"
|
||||
end
|
||||
|
||||
function Physics3DCollisionCallbackDemo:extend()
|
||||
local rbDes = {}
|
||||
|
||||
local scale = 2.0
|
||||
local trianglesList = cc.Bundle3D:getTrianglesList("Sprite3DTest/boss.c3b")
|
||||
for i = 1, #trianglesList do
|
||||
trianglesList[i] = {x = trianglesList[i].x * scale, y = trianglesList[i].y * scale, z = trianglesList[i].z * scale}
|
||||
end
|
||||
|
||||
rbDes.mass = 0.0
|
||||
rbDes.shape = cc.Physics3DShape:createMesh(trianglesList, math.floor(#trianglesList / 3))
|
||||
local rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
local component = cc.Physics3DComponent:create(rigidBody)
|
||||
local sprite = cc.Sprite3D:create("Sprite3DTest/boss.c3b")
|
||||
sprite:addComponent(component)
|
||||
sprite:setRotation3D(cc.vec3(-90.0, 0.0, 0.0))
|
||||
sprite:setScale(scale)
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
self:addChild(sprite)
|
||||
|
||||
rigidBody:setCollisionCallback(function (collisionInfo)
|
||||
if nil ~= collisionInfo.collisionPointList and #collisionInfo.collisionPointList > 0 then
|
||||
if collisionInfo.objA:getMask() ~= 0 then
|
||||
local ps = cc.PUParticleSystem3D:create("Particle3D/scripts/mp_hit_04.pu")
|
||||
ps:setPosition3D(collisionInfo.collisionPointList[1].worldPositionOnB)
|
||||
ps:setScale(0.05)
|
||||
ps:startParticleSystem()
|
||||
ps:setCameraMask(2)
|
||||
self:addChild(ps)
|
||||
ps:runAction(cc.Sequence:create(cc.DelayTime:create(1.0), cc.CallFunc:create(function()
|
||||
ps:removeFromParent()
|
||||
end)))
|
||||
collisionInfo.objA:setMask(0)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
self._physicsScene:setPhysics3DDebugCamera(self._camera)
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
----Physics3DTerrainDemo
|
||||
----------------------------------------
|
||||
local Physics3DTerrainDemo = class("Physics3DTerrainDemo", Physics3DTestDemo)
|
||||
|
||||
function Physics3DTerrainDemo:subtitle()
|
||||
return "Physics3D Terrain"
|
||||
end
|
||||
|
||||
function Physics3DTerrainDemo:extend()
|
||||
|
||||
local detailMapR = { _detailMapSrc = "TerrainTest/dirt.jpg", _detailMapSize = 35}
|
||||
local detailMapG = { _detailMapSrc = "TerrainTest/Grass2.jpg", _detailMapSize = 10}
|
||||
local detailMapB = { _detailMapSrc = "TerrainTest/road.jpg", _detailMapSize = 35}
|
||||
local detailMapA = { _detailMapSrc = "TerrainTest/GreenSkin.jpg", _detailMapSize = 20}
|
||||
local terrainData = { _heightMapSrc = "TerrainTest/heightmap129.jpg", _alphaMapSrc = "TerrainTest/alphamap.png" , _detailMaps = {detailMapR, detailMapG, detailMapB, detailMapA}, _detailMapAmount = 4, _mapHeight = 20.0, _mapScale = 1.0, _chunkSize = cc.size(32,32)}
|
||||
|
||||
local terrain = cc.Terrain:create(terrainData,cc.Terrain.CrackFixedType.SKIRT)
|
||||
terrain:setMaxDetailMapAmount(4)
|
||||
terrain:setCameraMask(2)
|
||||
terrain:setDrawWire(false)
|
||||
|
||||
terrain:setSkirtHeightRatio(3)
|
||||
terrain:setLODDistance(64,128,192)
|
||||
terrain:setCameraMask(cc.CameraFlag.USER1)
|
||||
|
||||
--create terrain
|
||||
local rbDes = {}
|
||||
rbDes.mass = 0.0
|
||||
local heidata = terrain:getHeightData()
|
||||
local size = terrain:getTerrainSize()
|
||||
rbDes.shape = cc.Physics3DShape:createHeightfield(size.width, size.height, heidata, 1.0, terrain:getMinHeight(), terrain:getMaxHeight(), true, false, true)
|
||||
local rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
local component = cc.Physics3DComponent:create(rigidBody)
|
||||
terrain:addComponent(component)
|
||||
self:addChild(terrain)
|
||||
component:syncToNode()
|
||||
component:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE)
|
||||
|
||||
--create several spheres
|
||||
rbDes.mass = 1.0
|
||||
rbDes.shape = cc.Physics3DShape:createSphere(0.5)
|
||||
local start_x = START_POS_X - ARRAY_SIZE_X/2 + 5.0
|
||||
local start_y = START_POS_Y + 20.0
|
||||
local start_z = START_POS_Z - ARRAY_SIZE_Z/2
|
||||
|
||||
for k = 1, ARRAY_SIZE_Y do
|
||||
for i = 1, ARRAY_SIZE_X do
|
||||
for j = 1, ARRAY_SIZE_Z do
|
||||
local x = 1.0 * (i - 1) + start_x
|
||||
local y = 5.0+1.0 * (k - 1) + start_y
|
||||
local z = 1.0 * (j - 1) + start_z
|
||||
|
||||
local sprite = cc.PhysicsSprite3D:create("Sprite3DTest/sphere.c3b", rbDes)
|
||||
sprite:setTexture("Sprite3DTest/plane.png")
|
||||
sprite:setCameraMask(cc.CameraFlag.USER1)
|
||||
sprite:setScale(1.0 / sprite:getContentSize().width)
|
||||
sprite:setPosition3D(cc.vec3(x, y, z))
|
||||
self:addChild(sprite)
|
||||
sprite:syncToNode()
|
||||
sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--create mesh
|
||||
local trianglesList = cc.Bundle3D:getTrianglesList("Sprite3DTest/boss.c3b")
|
||||
|
||||
rbDes.mass = 0.0
|
||||
rbDes.shape = cc.Physics3DShape:createMesh(trianglesList, math.floor(#trianglesList / 3))
|
||||
local rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
local component = cc.Physics3DComponent:create(rigidBody)
|
||||
local sprite = cc.Sprite3D:create("Sprite3DTest/boss.c3b")
|
||||
sprite:addComponent(component)
|
||||
sprite:setRotation3D(cc.vec3(-90.0, 0.0, 0.0))
|
||||
sprite:setPosition3D(cc.vec3(0.0, 15.0, 0.0))
|
||||
sprite:setCameraMask(2)
|
||||
self:addChild(sprite)
|
||||
|
||||
local shapeList = {}
|
||||
local localTrans = cc.mat4.createIdentity()
|
||||
local bodyshape = cc.Physics3DShape:createBox(cc.vec3(2.0, 4.0, 2.0))
|
||||
localTrans = cc.mat4.createTranslation(0.0, 2.0, 0.0, localTrans)
|
||||
table.insert(shapeList, {bodyshape, localTrans})
|
||||
|
||||
local headshape = cc.Physics3DShape:createSphere(1.5)
|
||||
localTrans = cc.mat4.createTranslation(0.6, 5.0, -1.5, localTrans)
|
||||
table.insert(shapeList, {headshape, localTrans})
|
||||
|
||||
local lhandshape = cc.Physics3DShape:createBox(cc.vec3(1.0, 3.0, 1.0))
|
||||
localTrans = cc.mat4.createRotation(cc.vec3(1.0, 0.0, 0.0), 15.0 * math.pi / 180, localTrans)
|
||||
localTrans[13] = -1.5
|
||||
localTrans[14] = 2.5
|
||||
localTrans[15] = -2.5
|
||||
table.insert(shapeList, {lhandshape, localTrans})
|
||||
|
||||
local rhandshape = cc.Physics3DShape:createBox(cc.vec3(1.0, 3.0, 1.0))
|
||||
localTrans = cc.mat4.createRotation(cc.vec3(1.0, 0.0, 0.0), -15.0 * math.pi / 180, localTrans)
|
||||
localTrans[13] = 2.0
|
||||
localTrans[14] = 2.5
|
||||
localTrans[15] = 1.0
|
||||
table.insert(shapeList, {rhandshape, localTrans})
|
||||
|
||||
rbDes.mass = 10.0
|
||||
rbDes.shape = cc.Physics3DShape:createCompoundShape(shapeList)
|
||||
rigidBody = cc.Physics3DRigidBody:create(rbDes)
|
||||
component = cc.Physics3DComponent:create(rigidBody)
|
||||
local sprite = cc.Sprite3D:create("Sprite3DTest/orc.c3b")
|
||||
sprite:addComponent(component)
|
||||
sprite:setRotation3D(cc.vec3(0.0, 180.0, 0.0))
|
||||
sprite:setPosition3D(cc.vec3(-5.0, 20.0, 0.0))
|
||||
sprite:setScale(0.4)
|
||||
sprite:setCameraMask(2)
|
||||
self:addChild(sprite)
|
||||
|
||||
self._physicsScene:setPhysics3DDebugCamera(self._camera)
|
||||
end
|
||||
|
||||
function Physics3DTest()
|
||||
|
||||
Helper.usePhysics = true
|
||||
|
||||
local scene = cc.Scene:createWithPhysics()
|
||||
|
||||
Helper.createFunctionTable =
|
||||
{
|
||||
BasicPhysics3DDemo.create,
|
||||
Physics3DConstraintDemo.create,
|
||||
Physics3DKinematicDemo.create,
|
||||
Physics3DCollisionCallbackDemo.create,
|
||||
Physics3DTerrainDemo.create,
|
||||
}
|
||||
|
||||
scene:addChild(BasicPhysics3DDemo.create())
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
|
||||
return scene
|
||||
end
|
|
@ -28,30 +28,6 @@ function CreateEnumTable(tbl, index)
|
|||
return enumTable
|
||||
end
|
||||
|
||||
-- back menu callback
|
||||
local function MainMenuCallback()
|
||||
local scene = cc.Scene:create()
|
||||
scene:addChild(CreateTestMenu())
|
||||
|
||||
cc.Director:getInstance():replaceScene(scene)
|
||||
end
|
||||
|
||||
-- add the menu item for back to main menu
|
||||
function CreateBackMenuItem()
|
||||
local label = cc.Label:createWithTTF("MainMenu", s_arialPath, 20)
|
||||
label:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
local MenuItem = cc.MenuItemLabel:create(label)
|
||||
MenuItem:registerScriptTapHandler(MainMenuCallback)
|
||||
|
||||
local s = cc.Director:getInstance():getWinSize()
|
||||
local Menu = cc.Menu:create()
|
||||
Menu:addChild(MenuItem)
|
||||
Menu:setPosition(0, 0)
|
||||
MenuItem:setPosition(s.width - 50, 25)
|
||||
|
||||
return Menu
|
||||
end
|
||||
|
||||
Helper = {
|
||||
index = 1,
|
||||
createFunctioinTable = nil,
|
||||
|
@ -59,6 +35,7 @@ Helper = {
|
|||
titleLabel = nil,
|
||||
subtitleLabel = nil
|
||||
}
|
||||
|
||||
function Helper.nextAction()
|
||||
Helper.index = Helper.index + 1
|
||||
if Helper.index > table.getn(Helper.createFunctionTable) then
|
||||
|
@ -131,6 +108,30 @@ function Helper.initWithLayer(layer)
|
|||
layer:addChild(background, -10)
|
||||
end
|
||||
|
||||
-- back menu callback
|
||||
local function MainMenuCallback()
|
||||
local scene = cc.Scene:create()
|
||||
scene:addChild(CreateTestMenu())
|
||||
Helper.usePhysics = false
|
||||
cc.Director:getInstance():replaceScene(scene)
|
||||
end
|
||||
|
||||
-- add the menu item for back to main menu
|
||||
function CreateBackMenuItem()
|
||||
local label = cc.Label:createWithTTF("MainMenu", s_arialPath, 20)
|
||||
label:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
local MenuItem = cc.MenuItemLabel:create(label)
|
||||
MenuItem:registerScriptTapHandler(MainMenuCallback)
|
||||
|
||||
local s = cc.Director:getInstance():getWinSize()
|
||||
local Menu = cc.Menu:create()
|
||||
Menu:addChild(MenuItem)
|
||||
Menu:setPosition(0, 0)
|
||||
MenuItem:setPosition(s.width - 50, 25)
|
||||
|
||||
return Menu
|
||||
end
|
||||
|
||||
function createTestLayer(title, subtitle)
|
||||
local layer = cc.Layer:create()
|
||||
Helper.initWithLayer(layer)
|
||||
|
|
|
@ -60,6 +60,7 @@ require "NewAudioEngineTest/NewAudioEngineTest"
|
|||
require "CocosStudio3DTest/CocosStudio3DTest"
|
||||
require "WebViewTest/WebViewTest"
|
||||
require "SpritePolygonTest/SpritePolygonTest"
|
||||
require "Physics3DTest/Physics3DTest"
|
||||
require "Scene3DTest/Scene3DTest"
|
||||
|
||||
local LINE_SPACE = 40
|
||||
|
@ -120,6 +121,7 @@ local _allTests = {
|
|||
{ isSupported = true, name = "Particle3D (PU)" , create_func = Particle3DTest },
|
||||
{ isSupported = true, name = "PerformanceTest" , create_func= PerformanceTestMain },
|
||||
{ isSupported = true, name = "PhysicsTest" , create_func = PhysicsTest },
|
||||
{ isSupported = true, name = "Physics3DTest" , create_func = Physics3DTest },
|
||||
{ isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain },
|
||||
{ isSupported = true, name = "RotateWorldTest" , create_func = RotateWorldTest },
|
||||
{ isSupported = true, name = "SceneTest" , create_func = SceneTestMain },
|
||||
|
@ -200,13 +202,17 @@ function CreateTestMenu()
|
|||
if cc.PLATFORM_OS_IPHONE ~= targetPlatform and cc.PLATFORM_OS_ANDROID ~= targetPlatform then
|
||||
testMenuItem:setEnabled(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if obj.name == "WebViewTest" then
|
||||
if cc.PLATFORM_OS_IPHONE ~= targetPlatform and cc.PLATFORM_OS_ANDROID ~= targetPlatform then
|
||||
testMenuItem:setEnabled(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if obj.name == "Physics3DTest" and nil == cc.Physics3DComponent then
|
||||
testMenuItem:setEnabled(false)
|
||||
end
|
||||
|
||||
testMenuItem:registerScriptTapHandler(menuCallback)
|
||||
testMenuItem:setPosition(cc.p(s.width / 2, (s.height - (index) * LINE_SPACE)))
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "spine/lua_cocos2dx_spine_manual.hpp"
|
||||
#include "3d/lua_cocos2dx_3d_manual.h"
|
||||
#include "audioengine/lua_cocos2dx_audioengine_manual.h"
|
||||
#include "physics3d/lua_cocos2dx_physics3d_manual.h"
|
||||
|
||||
static int lua_module_register(lua_State* L)
|
||||
{
|
||||
|
@ -23,6 +24,9 @@ static int lua_module_register(lua_State* L)
|
|||
register_spine_module(L);
|
||||
register_cocos3d_module(L);
|
||||
register_audioengine_module(L);
|
||||
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
register_physics3d_module(L);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ cxxgenerator_headers =
|
|||
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
|
||||
|
||||
# what headers to parse
|
||||
headers = %(cocosdir)s/cocos/cocos2d.h
|
||||
headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/3d/CCBundle3D.h
|
||||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard Sprite3DCache TextureCube Skybox Terrain
|
||||
classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard Sprite3DCache TextureCube Skybox Terrain Bundle3D
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
|
@ -41,7 +41,8 @@ skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getSkin getMeshInde
|
|||
Animation3D::[getBoneCurveByName getBoneCurves],
|
||||
BillBoard::[draw],
|
||||
Sprite3DCache::[addSprite3DData getSpriteData],
|
||||
Terrain::[lookForIndicesLODSkrit lookForIndicesLOD insertIndicesLOD insertIndicesLODSkirt getIntersectionPoint getAABB getQuadTree create getHeight getHeightData]
|
||||
Terrain::[lookForIndicesLODSkrit lookForIndicesLOD insertIndicesLOD insertIndicesLODSkirt getIntersectionPoint getAABB getQuadTree create ^getHeight$],
|
||||
Bundle3D::[calculateAABB loadMeshDatas getTrianglesList]
|
||||
|
||||
|
||||
rename_functions =
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
[cocos2dx_physics3d]
|
||||
# the prefix to be added to the generated functions. You might or might not use this in your own
|
||||
# templates
|
||||
prefix = cocos2dx_physics3d
|
||||
|
||||
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
|
||||
# all classes will be embedded in that namespace
|
||||
target_namespace = cc
|
||||
|
||||
macro_judgement = #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
||||
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||
clang_flags = -nostdinc -x c++ -std=c++11 -D CC_ENABLE_BULLET_INTEGRATION
|
||||
|
||||
win32_clang_flags = -U __SSE__
|
||||
|
||||
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external
|
||||
|
||||
cocos_flags = -DANDROID
|
||||
|
||||
cxxgenerator_headers =
|
||||
|
||||
# extra arguments for clang
|
||||
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
|
||||
|
||||
# what headers to parse
|
||||
headers = %(cocosdir)s/cocos/physics3d/CCPhysics3D.h
|
||||
|
||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||
classes = Physics3DWorld Physics3DShape PhysicsSprite3D Physics3DObject Physics3DRigidBody Physics3DShapesk Physics3DComponent Physics3DConstraint Physics3DPointToPointConstraint Physics3DHingeConstraint Physics3DSliderConstraint Physics3DConeTwistConstraint Physics3D6DofConstraint
|
||||
|
||||
# what should we skip? in the format ClassName::[function function]
|
||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
|
||||
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
|
||||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = Physics3DWorld::[getPhysicsObjects getPhysicsObject init rayCast sweepShape create],
|
||||
Physics3DShape::[createCompoundShape createMesh createHeightfield],
|
||||
PhysicsSprite3D::[create],
|
||||
Physics3DComponent::[setTransformInPhysics create],
|
||||
Physics3DRigidBody::[create],
|
||||
Physics3DHingeConstraint::[setMotorTarget],
|
||||
Physics3DConeTwistConstraint::[setMotorTarget setMotorTargetInConstraintSpace],
|
||||
Physics3DObject::[setCollisionCallback]
|
||||
|
||||
rename_functions =
|
||||
|
||||
rename_classes =
|
||||
|
||||
# for all class names, should we remove something when registering in the target VM?
|
||||
remove_prefix =
|
||||
|
||||
# classes for which there will be no "parent" lookup
|
||||
classes_have_no_parents =
|
||||
|
||||
# base classes which will be skipped when their sub-classes found them.
|
||||
base_classes_to_skip =
|
||||
|
||||
# classes that create no constructor
|
||||
# Set is special and we will use a hand-written constructor
|
||||
abstract_classes = Physics3DObject
|
||||
|
||||
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
||||
script_control_cpp = no
|
||||
|
|
@ -148,6 +148,7 @@ def main():
|
|||
'cocos2dx_audioengine.ini': ('cocos2dx_audioengine', 'lua_cocos2dx_audioengine_auto'), \
|
||||
'cocos2dx_csloader.ini' : ('cocos2dx_csloader', 'lua_cocos2dx_csloader_auto'), \
|
||||
'cocos2dx_experimental_webview.ini' : ('cocos2dx_experimental_webview', 'lua_cocos2dx_experimental_webview_auto'), \
|
||||
'cocos2dx_physics3d.ini' : ('cocos2dx_physics3d', 'lua_cocos2dx_physics3d_auto'), \
|
||||
}
|
||||
target = 'lua'
|
||||
generator_py = '%s/generator.py' % cxx_generator_root
|
||||
|
|
Loading…
Reference in New Issue