mirror of https://github.com/axmolengine/axmol.git
add physics3d js manual binding and tests
This commit is contained in:
parent
712ba4f64c
commit
83237b8dbd
|
@ -43,6 +43,7 @@ set(JSBINDING_SRC
|
|||
auto/jsb_cocos2dx_3d_auto.cpp
|
||||
auto/jsb_cocos2dx_3d_extension_auto.cpp
|
||||
auto/jsb_cocos2dx_experimental.cpp
|
||||
auto/jsb_cocos2dx_physics3d_auto.cpp
|
||||
manual/ScriptingCore.cpp
|
||||
manual/cocos2d_specifics.cpp
|
||||
manual/js_manual_conversions.cpp
|
||||
|
@ -69,6 +70,7 @@ set(JSBINDING_SRC
|
|||
manual/ui/jsb_cocos2dx_ui_manual.cpp
|
||||
manual/3d/jsb_cocos2dx_3d_manual.cpp
|
||||
manual/experimental/jsb_cocos2dx_experimental_manual.cpp
|
||||
manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp
|
||||
${cocos_root}/cocos/storage/local-storage/LocalStorage.cpp
|
||||
)
|
||||
|
||||
|
@ -80,11 +82,13 @@ include_directories(
|
|||
${cocos_root}/external/spidermonkey/include/${PLATFORM_FOLDER}
|
||||
${cocos_root}/cocos/base
|
||||
${cocos_root}/cocos/2d
|
||||
${cocos_root}/cocos/3d
|
||||
${cocos_root}/cocos/ui
|
||||
${cocos_root}/cocos/audio/include
|
||||
${cocos_root}/cocos/storage
|
||||
${cocos_root}/cocos/network
|
||||
${cocos_root}/cocos/platform
|
||||
${cocos_root}/cocos/physics3d
|
||||
${cocos_root}/extensions
|
||||
${cocos_root}/external
|
||||
${cocos_root}/cocos/editor-support
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "jsb_cocos2dx_3d_manual.h"
|
||||
#include "cocos2d_specifics.hpp"
|
||||
#include "jsb_cocos2dx_3d_auto.hpp"
|
||||
#include "3d/CCBundle3D.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
|
@ -284,6 +285,60 @@ bool js_cocos2dx_Terrain_create(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
return false;
|
||||
}
|
||||
|
||||
jsval std_vector_vec3_to_jsval(JSContext* cx, const std::vector<cocos2d::Vec3>& triangles)
|
||||
{
|
||||
JS::RootedObject jsarr(cx, JS_NewArrayObject(cx, triangles.size()));
|
||||
|
||||
uint32_t i = 0;
|
||||
for(auto iter = triangles.begin(); iter != triangles.end(); ++iter)
|
||||
{
|
||||
JS::RootedValue element(cx, vector3_to_jsval(cx, *iter));
|
||||
JS_SetElement(cx, jsarr, i, element);
|
||||
++i;
|
||||
}
|
||||
|
||||
return OBJECT_TO_JSVAL(jsarr);
|
||||
}
|
||||
|
||||
bool js_cocos2dx_Bundle3D_getTrianglesList(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
if(argc == 1)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
std::string path;
|
||||
bool ok = jsval_to_std_string(cx, args.get(0), &path);
|
||||
JSB_PRECONDITION2(ok, cx, false, "Error processing arguments");
|
||||
|
||||
std::vector<cocos2d::Vec3> triangles = cocos2d::Bundle3D::getTrianglesList(path);
|
||||
|
||||
JS::RootedValue ret(cx, std_vector_vec3_to_jsval(cx, triangles));
|
||||
args.rval().set(ret);
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool js_cocos2dx_Terrain_getHeightData(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
if(argc == 0)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Terrain_getHeightData : Invalid Native Object");
|
||||
|
||||
auto data = cobj->getHeightData();
|
||||
|
||||
args.rval().set(std_vector_float_to_jsval(cx, data));
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global)
|
||||
{
|
||||
JS::RootedValue tmpVal(cx);
|
||||
|
@ -299,9 +354,15 @@ void register_all_cocos2dx_3d_manual(JSContext *cx, JS::HandleObject global)
|
|||
tmpObj = tmpVal.toObjectOrNull();
|
||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_Terrain_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_GetProperty(cx, ccObj, "Bundle3D", &tmpVal);
|
||||
tmpObj = tmpVal.toObjectOrNull();
|
||||
JS_DefineFunction(cx, tmpObj, "getTrianglesList", js_cocos2dx_Bundle3D_getTrianglesList, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Sprite3D_prototype), "getAABB", js_cocos2dx_Sprite3D_getAABB, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Mesh_prototype), "getMeshVertexAttribute", js_cocos2dx_Mesh_getMeshVertexAttribute, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_TextureCube_prototype), "setTexParameters", js_cocos2dx_CCTextureCube_setTexParameters, 4, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Terrain_prototype), "getHeightData", js_cocos2dx_Terrain_getHeightData, 0, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
}
|
||||
|
|
|
@ -1337,7 +1337,7 @@ bool jsval_to_std_vector_string( JSContext *cx, JS::HandleValue vp, std::vector<
|
|||
|
||||
uint32_t len = 0;
|
||||
JS_GetArrayLength(cx, jsobj, &len);
|
||||
|
||||
ret->reserve(len);
|
||||
for (uint32_t i=0; i < len; i++)
|
||||
{
|
||||
JS::RootedValue value(cx);
|
||||
|
@ -1368,7 +1368,7 @@ bool jsval_to_std_vector_int( JSContext *cx, JS::HandleValue vp, std::vector<int
|
|||
|
||||
uint32_t len = 0;
|
||||
JS_GetArrayLength(cx, jsobj, &len);
|
||||
|
||||
ret->reserve(len);
|
||||
for (uint32_t i=0; i < len; i++)
|
||||
{
|
||||
JS::RootedValue value(cx);
|
||||
|
@ -1394,6 +1394,41 @@ bool jsval_to_std_vector_int( JSContext *cx, JS::HandleValue vp, std::vector<int
|
|||
return true;
|
||||
}
|
||||
|
||||
bool jsval_to_std_vector_float( JSContext *cx, JS::HandleValue vp, std::vector<float>* ret)
|
||||
{
|
||||
JS::RootedObject jsobj(cx);
|
||||
bool ok = vp.isObject() && JS_ValueToObject( cx, vp, &jsobj );
|
||||
JSB_PRECONDITION3( ok, cx, false, "Error converting value to object");
|
||||
JSB_PRECONDITION3( jsobj && JS_IsArrayObject( cx, jsobj), cx, false, "Object must be an array");
|
||||
|
||||
uint32_t len = 0;
|
||||
JS_GetArrayLength(cx, jsobj, &len);
|
||||
ret->reserve(len);
|
||||
for (uint32_t i=0; i < len; i++)
|
||||
{
|
||||
JS::RootedValue value(cx);
|
||||
if (JS_GetElement(cx, jsobj, i, &value))
|
||||
{
|
||||
if (value.isNumber())
|
||||
{
|
||||
double number = 0.0;
|
||||
ok = JS::ToNumber(cx, value, &number);
|
||||
if (ok)
|
||||
{
|
||||
ret->push_back(number);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JS_ReportError(cx, "not supported type in array");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool jsval_to_matrix(JSContext *cx, JS::HandleValue vp, cocos2d::Mat4* ret)
|
||||
{
|
||||
JS::RootedObject jsobj(cx);
|
||||
|
@ -2458,7 +2493,7 @@ jsval ssize_to_jsval(JSContext *cx, ssize_t v)
|
|||
|
||||
jsval std_vector_string_to_jsval( JSContext *cx, const std::vector<std::string>& v)
|
||||
{
|
||||
JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, v.size()));
|
||||
|
||||
int i = 0;
|
||||
for (const std::string obj : v)
|
||||
|
@ -2476,7 +2511,7 @@ jsval std_vector_string_to_jsval( JSContext *cx, const std::vector<std::string>&
|
|||
|
||||
jsval std_vector_int_to_jsval( JSContext *cx, const std::vector<int>& v)
|
||||
{
|
||||
JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 0));
|
||||
JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, v.size()));
|
||||
|
||||
int i = 0;
|
||||
for (const int obj : v)
|
||||
|
@ -2492,6 +2527,24 @@ jsval std_vector_int_to_jsval( JSContext *cx, const std::vector<int>& v)
|
|||
return OBJECT_TO_JSVAL(jsretArr);
|
||||
}
|
||||
|
||||
jsval std_vector_float_to_jsval( JSContext *cx, const std::vector<float>& v)
|
||||
{
|
||||
JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, v.size()));
|
||||
|
||||
int i = 0;
|
||||
for (const float obj : v)
|
||||
{
|
||||
JS::RootedValue arrElement(cx);
|
||||
arrElement = DOUBLE_TO_JSVAL(obj);
|
||||
|
||||
if (!JS_SetElement(cx, jsretArr, i, arrElement)) {
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return OBJECT_TO_JSVAL(jsretArr);
|
||||
}
|
||||
|
||||
jsval matrix_to_jsval(JSContext *cx, const cocos2d::Mat4& v)
|
||||
{
|
||||
JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, 16));
|
||||
|
|
|
@ -181,6 +181,7 @@ bool jsval_to_ccvaluevector(JSContext* cx, JS::HandleValue v, cocos2d::ValueVect
|
|||
bool jsval_to_ssize( JSContext *cx, JS::HandleValue vp, ssize_t* ret);
|
||||
bool jsval_to_std_vector_string( JSContext *cx, JS::HandleValue vp, std::vector<std::string>* ret);
|
||||
bool jsval_to_std_vector_int( JSContext *cx, JS::HandleValue vp, std::vector<int>* ret);
|
||||
bool jsval_to_std_vector_float( JSContext *cx, JS::HandleValue vp, std::vector<float>* ret);
|
||||
bool jsval_to_matrix(JSContext *cx, JS::HandleValue vp, cocos2d::Mat4* ret);
|
||||
bool jsval_to_vector2(JSContext *cx, JS::HandleValue vp, cocos2d::Vec2* ret);
|
||||
bool jsval_to_vector3(JSContext *cx, JS::HandleValue vp, cocos2d::Vec3* ret);
|
||||
|
@ -327,6 +328,7 @@ jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v);
|
|||
jsval ssize_to_jsval(JSContext *cx, ssize_t v);
|
||||
jsval std_vector_string_to_jsval( JSContext *cx, const std::vector<std::string>& v);
|
||||
jsval std_vector_int_to_jsval( JSContext *cx, const std::vector<int>& v);
|
||||
jsval std_vector_float_to_jsval( JSContext *cx, const std::vector<float>& v);
|
||||
jsval matrix_to_jsval(JSContext *cx, const cocos2d::Mat4& v);
|
||||
jsval vector2_to_jsval(JSContext *cx, const cocos2d::Vec2& v);
|
||||
jsval vector3_to_jsval(JSContext *cx, const cocos2d::Vec3& v);
|
||||
|
|
|
@ -0,0 +1,323 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
Copyright (c) 2013-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 "jsb_cocos2dx_physics3d_manual.h"
|
||||
|
||||
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
|
||||
#include "jsb_cocos2dx_physics3d_auto.hpp"
|
||||
#include "cocos2d_specifics.hpp"
|
||||
#include "physics3d/CCPhysics3D.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
bool jsval_to_physics3DRigidBodyDes(JSContext* cx, JS::HandleValue v, Physics3DRigidBodyDes* des)
|
||||
{
|
||||
JS::RootedObject jsobj(cx, v.toObjectOrNull());
|
||||
JS::RootedValue tmp(cx);
|
||||
|
||||
if(JS_GetProperty(cx, jsobj, "mass", &tmp))
|
||||
{
|
||||
des->mass = tmp.toNumber();
|
||||
}
|
||||
if(JS_GetProperty(cx, jsobj, "shape", &tmp))
|
||||
{
|
||||
js_proxy_t* proxy = jsb_get_js_proxy(tmp.toObjectOrNull());
|
||||
des->shape = proxy ? (cocos2d::Physics3DShape*)proxy->ptr : nullptr;
|
||||
}
|
||||
if(JS_GetProperty(cx, jsobj, "localInertia", &tmp))
|
||||
{
|
||||
Vec3 v3;
|
||||
jsval_to_vector3(cx, tmp, &v3);
|
||||
des->localInertia = v3;
|
||||
}
|
||||
if(JS_GetProperty(cx, jsobj, "originalTransform", &tmp))
|
||||
{
|
||||
Mat4 m4;
|
||||
jsval_to_matrix(cx, tmp, &m4);
|
||||
des->originalTransform = m4;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool js_cocos2dx_PhysicsSprite3D_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
if (argc == 2)
|
||||
{
|
||||
std::string arg0;
|
||||
cocos2d::Physics3DRigidBodyDes arg1;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
ok &= jsval_to_physics3DRigidBodyDes(cx, args.get(1), &arg1);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_PhysicsSprite3D_create : Error processing arguments");
|
||||
cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1);
|
||||
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PhysicsSprite3D>(cx, (cocos2d::PhysicsSprite3D*)ret);
|
||||
jsval jsret = jsProxy ? OBJECT_TO_JSVAL(jsProxy->obj) : JSVAL_VOID;
|
||||
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
if (argc == 3)
|
||||
{
|
||||
std::string arg0;
|
||||
cocos2d::Physics3DRigidBodyDes arg1;
|
||||
cocos2d::Vec3 arg2;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
ok &= jsval_to_physics3DRigidBodyDes(cx, args.get(1), &arg1);
|
||||
ok &= jsval_to_vector3(cx, args.get(2), &arg2);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_PhysicsSprite3D_create : Error processing arguments");
|
||||
cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1, arg2);
|
||||
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PhysicsSprite3D>(cx, (cocos2d::PhysicsSprite3D*)ret);
|
||||
jsval jsret = jsProxy ? OBJECT_TO_JSVAL(jsProxy->obj) : JSVAL_VOID;
|
||||
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
if (argc == 4)
|
||||
{
|
||||
std::string arg0;
|
||||
cocos2d::Physics3DRigidBodyDes arg1;
|
||||
cocos2d::Vec3 arg2;
|
||||
cocos2d::Quaternion arg3;
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
ok &= jsval_to_physics3DRigidBodyDes(cx, args.get(1), &arg1);
|
||||
ok &= jsval_to_vector3(cx, args.get(2), &arg2);
|
||||
ok &= jsval_to_quaternion(cx, args.get(3), &arg3);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_PhysicsSprite3D_create : Error processing arguments");
|
||||
cocos2d::PhysicsSprite3D* ret = cocos2d::PhysicsSprite3D::create(arg0, &arg1, arg2, arg3);
|
||||
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::PhysicsSprite3D>(cx, (cocos2d::PhysicsSprite3D*)ret);
|
||||
jsval jsret = jsProxy ? OBJECT_TO_JSVAL(jsProxy->obj) : JSVAL_VOID;
|
||||
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_physics3d_PhysicsSprite3D_create : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool js_cocos2dx_physics3d_Physics3DRigidBody_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
if (argc == 1)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
cocos2d::Physics3DRigidBodyDes arg0;
|
||||
ok &= jsval_to_physics3DRigidBodyDes(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DRigidBody_create : Error processing arguments");
|
||||
cocos2d::Physics3DRigidBody* ret = cocos2d::Physics3DRigidBody::create(&arg0);
|
||||
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::Physics3DRigidBody>(cx, (cocos2d::Physics3DRigidBody*)ret);
|
||||
jsval jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DRigidBody_create : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool jsval_to_std_vector_vec3(JSContext* cx, JS::HandleValue v, std::vector<Vec3>* ret)
|
||||
{
|
||||
JS::RootedObject jsobj(cx, v.toObjectOrNull());
|
||||
uint32_t length;
|
||||
JS_GetArrayLength(cx, jsobj, &length);
|
||||
ret->reserve(length);
|
||||
|
||||
for(size_t i = 0; i < length; ++i)
|
||||
{
|
||||
JS::RootedValue element(cx);
|
||||
JS_GetElement(cx, jsobj, i, &element);
|
||||
|
||||
Vec3 v;
|
||||
jsval_to_vector3(cx, element, &v);
|
||||
ret->push_back(v);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool js_cocos2dx_physics3d_Physics3dShape_createMesh(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
if(argc == 2)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
std::vector<Vec3> arg0;
|
||||
int arg1;
|
||||
|
||||
bool ok = jsval_to_std_vector_vec3(cx, args.get(0), &arg0) & jsval_to_int(cx, args.get(1), &arg1);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3dShape_createMesh : Error processing arguments");
|
||||
|
||||
Physics3DShape* ret = Physics3DShape::createMesh(&arg0[0], arg1);
|
||||
js_proxy_t* proxy = js_get_or_create_proxy<Physics3DShape>(cx, ret);
|
||||
jsval jsret = OBJECT_TO_JSVAL(proxy->obj);
|
||||
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3dShape_createMesh : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
jsval physics3d_collisionPoint_to_jsval(JSContext*cx, const Physics3DCollisionInfo::CollisionPoint& point)
|
||||
{
|
||||
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
|
||||
|
||||
JS_DefineProperty(cx, tmp, "localPositionOnA", JS::RootedValue(cx, vector3_to_jsval(cx, point.localPositionOnA)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
JS_DefineProperty(cx, tmp, "localPositionOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.localPositionOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
JS_DefineProperty(cx, tmp, "worldPositionOnA", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldPositionOnA)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
JS_DefineProperty(cx, tmp, "worldPositionOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldPositionOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
JS_DefineProperty(cx, tmp, "worldNormalOnB", JS::RootedValue(cx, vector3_to_jsval(cx, point.worldNormalOnB)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
return OBJECT_TO_JSVAL(tmp);
|
||||
}
|
||||
|
||||
jsval physics3d_collisioninfo_to_jsval(JSContext* cx, const Physics3DCollisionInfo& ci)
|
||||
{
|
||||
JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr()));
|
||||
|
||||
js_proxy_t* proxy = js_get_or_create_proxy<Physics3DObject>(cx, ci.objA);
|
||||
JS_DefineProperty(cx, tmp, "objA", JS::RootedValue(cx, OBJECT_TO_JSVAL(proxy->obj)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
proxy = js_get_or_create_proxy<Physics3DObject>(cx, ci.objB);
|
||||
JS_DefineProperty(cx, tmp, "objB", JS::RootedValue(cx, OBJECT_TO_JSVAL(proxy->obj)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
JS::RootedObject jsarr(cx, JS_NewArrayObject(cx, ci.collisionPointList.size()));
|
||||
uint32_t i = 0;
|
||||
for(auto iter = ci.collisionPointList.begin(); iter != ci.collisionPointList.end(); ++iter)
|
||||
{
|
||||
JS::RootedValue element(cx, physics3d_collisionPoint_to_jsval(cx, *iter));
|
||||
JS_SetElement(cx, jsarr, i++, element);
|
||||
}
|
||||
JS_DefineProperty(cx, tmp, "collisionPointList", JS::RootedValue(cx, OBJECT_TO_JSVAL(jsarr)), JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||
|
||||
return OBJECT_TO_JSVAL(tmp);
|
||||
}
|
||||
|
||||
bool jsb_cocos2d_Physics3DObject_setCollisionCallback(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
if(argc == 2)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Physics3DObject* cobj = (cocos2d::Physics3DObject *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "jsb_cocos2d_Physics3DObject_setCollisionCallback : Invalid Native Object");
|
||||
|
||||
std::function<void(const Physics3DCollisionInfo &)> arg0;
|
||||
std::shared_ptr<JSFunctionWrapper> func(new JSFunctionWrapper(cx, args.get(1).toObjectOrNull(), args.get(0)));
|
||||
auto lambda = [=](const Physics3DCollisionInfo &ci) -> void {
|
||||
JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET
|
||||
|
||||
jsval jsci = physics3d_collisioninfo_to_jsval(cx, ci);
|
||||
JS::RootedValue rval(cx);
|
||||
bool ok = func->invoke(1, &jsci, &rval);
|
||||
if (!ok && JS_IsExceptionPending(cx))
|
||||
{
|
||||
JS_ReportPendingException(cx);
|
||||
}
|
||||
};
|
||||
arg0 = lambda;
|
||||
cobj->setCollisionCallback(arg0);
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3dShape_createMesh : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool js_cocos2dx_physics3d_Physics3dShape_createHeightfield(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
if (argc == 8 || argc == 9)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
int arg0;
|
||||
int arg1;
|
||||
std::vector<float> arg2;
|
||||
double arg3;
|
||||
double arg4;
|
||||
double arg5;
|
||||
bool arg6;
|
||||
bool arg7;
|
||||
bool arg8;
|
||||
ok &= jsval_to_int32(cx, args.get(0), (int32_t *)&arg0);
|
||||
ok &= jsval_to_int32(cx, args.get(1), (int32_t *)&arg1);
|
||||
ok &= jsval_to_std_vector_float(cx, args.get(2), &arg2);
|
||||
ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3);
|
||||
ok &= JS::ToNumber( cx, args.get(4), &arg4) && !isnan(arg4);
|
||||
ok &= JS::ToNumber( cx, args.get(5), &arg5) && !isnan(arg5);
|
||||
arg6 = JS::ToBoolean(args.get(6));
|
||||
arg7 = JS::ToBoolean(args.get(7));
|
||||
if(argc == 9)
|
||||
arg8 = JS::ToBoolean(args.get(8));
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DShape_createHeightfield : Error processing arguments");
|
||||
|
||||
cocos2d::Physics3DShape* ret = nullptr;
|
||||
if(argc == 8)
|
||||
ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], arg3, arg4, arg5, arg6, arg7);
|
||||
else if(argc == 9)
|
||||
ret = cocos2d::Physics3DShape::createHeightfield(arg0, arg1, &arg2[0], arg3, arg4, arg5, arg6, arg7, arg8);
|
||||
|
||||
js_proxy_t *jsProxy = js_get_or_create_proxy<cocos2d::Physics3DShape>(cx, ret);
|
||||
jsval jsret = OBJECT_TO_JSVAL(jsProxy->obj);
|
||||
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DShape_createHeightfield : wrong number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
void register_all_cocos2dx_physics3d_manual(JSContext *cx, JS::HandleObject global)
|
||||
{
|
||||
JS::RootedObject ccObj(cx);
|
||||
get_or_create_js_obj(cx, global, "cc", &ccObj);
|
||||
|
||||
JS::RootedValue tmpVal(cx);
|
||||
JS_GetProperty(cx, ccObj, "PhysicsSprite3D", &tmpVal);
|
||||
JS::RootedObject tmpObj(cx, tmpVal.toObjectOrNull());
|
||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_PhysicsSprite3D_create, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_GetProperty(cx, ccObj, "Physics3DRigidBody", &tmpVal);
|
||||
tmpObj = tmpVal.toObjectOrNull();
|
||||
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_physics3d_Physics3DRigidBody_create, 1, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_GetProperty(cx, ccObj, "Physics3DShape", &tmpVal);
|
||||
tmpObj = tmpVal.toObjectOrNull();
|
||||
JS_DefineFunction(cx, tmpObj, "createMesh", js_cocos2dx_physics3d_Physics3dShape_createMesh, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
JS_DefineFunction(cx, tmpObj, "createHeightfield", js_cocos2dx_physics3d_Physics3dShape_createHeightfield, 8, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
|
||||
JS_DefineFunction(cx, JS::RootedObject(cx, jsb_cocos2d_Physics3DObject_prototype), "setCollisionCallback", jsb_cocos2d_Physics3DObject_setCollisionCallback, 2, JSPROP_READONLY | JSPROP_PERMANENT);
|
||||
}
|
||||
|
||||
#endif //CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
|
@ -0,0 +1,38 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2013-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 __jsb_cococs2dx_physics3d_manual_h__
|
||||
#define __jsb_cococs2dx_physics3d_manual_h__
|
||||
|
||||
#include "base/ccConfig.h"
|
||||
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
void register_all_cocos2dx_physics3d_manual(JSContext *cx, JS::HandleObject global);
|
||||
|
||||
#endif
|
||||
|
||||
#endif //__jsb_cococs2dx_physics3d_manual_h__
|
|
@ -44,6 +44,7 @@ LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_3d_auto.cpp \
|
|||
../auto/jsb_cocos2dx_builder_auto.cpp \
|
||||
../auto/jsb_cocos2dx_ui_auto.cpp \
|
||||
../auto/jsb_cocos2dx_experimental.cpp \
|
||||
../auto/jsb_cocos2dx_physics3d_auto.cpp \
|
||||
../manual/ScriptingCore.cpp \ \
|
||||
../manual/cocos2d_specifics.cpp \
|
||||
../manual/js_manual_conversions.cpp \
|
||||
|
@ -69,8 +70,9 @@ LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_3d_auto.cpp \
|
|||
../manual/network/XMLHTTPRequest.cpp \
|
||||
../manual/spine/jsb_cocos2dx_spine_manual.cpp \
|
||||
../manual/ui/jsb_cocos2dx_ui_manual.cpp \
|
||||
../manual/experimental/jsb_cocos2dx_experimental_manual.cpp
|
||||
|
||||
../manual/experimental/jsb_cocos2dx_experimental_manual.cpp \
|
||||
../manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp
|
||||
|
||||
|
||||
LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT
|
||||
|
||||
|
@ -81,6 +83,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual \
|
|||
$(LOCAL_PATH)/../manual/spine \
|
||||
$(LOCAL_PATH)/../auto \
|
||||
$(LOCAL_PATH)/../../../2d \
|
||||
$(LOCAL_PATH)/../../../3d \
|
||||
$(LOCAL_PATH)/../../../physics3d \
|
||||
$(LOCAL_PATH)/../../../base \
|
||||
$(LOCAL_PATH)/../../../ui \
|
||||
$(LOCAL_PATH)/../../../audio/include \
|
||||
|
@ -93,7 +97,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../manual \
|
|||
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../manual \
|
||||
$(LOCAL_PATH)/../auto \
|
||||
$(LOCAL_PATH)/../../../audio/include
|
||||
$(LOCAL_PATH)/../../../audio/include
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_js_android_static
|
||||
|
||||
|
|
|
@ -135,5 +135,8 @@ if (jsb.Sprite3D){
|
|||
}
|
||||
|
||||
if (jsb.ParticleSystem3D) {
|
||||
require('script/3d/jsb_cocos2d_3d_ext.js');
|
||||
}
|
||||
require('script/3d/jsb_cocos2d_3d_ext.js');
|
||||
}
|
||||
|
||||
if(cc.Physics3DObject)
|
||||
require("script/physics3d/jsb_physics3d.js");
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Chukong Technologies Inc.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
cc.Physics3DRigidBodyDes = function(){
|
||||
this.mass = 0;
|
||||
this.localInertia = cc.math.vec3(0, 0, 0);
|
||||
this.shape = null;
|
||||
this.originalTransform = [1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0];
|
||||
this.disableSleep = false;
|
||||
};
|
||||
|
||||
cc.physics3DRigidBodyDes = function(){
|
||||
return new cc.Physics3DRigidBodyDes();
|
||||
};
|
||||
|
||||
cc.Physics3DComponent.PhysicsSyncFlag = {
|
||||
NONE : 0,
|
||||
NODE_TO_PHYSICS : 1, //align node transform to the physics
|
||||
PHYSICS_TO_NODE : 2, // align physics transform to the node
|
||||
NODE_AND_NODE : 1 | 2, //pre simulation, align the physics object to the node and align the node transform according to physics object after simulation
|
||||
};
|
|
@ -11,6 +11,7 @@
|
|||
#include "jsb_cocos2dx_3d_extension_auto.hpp"
|
||||
#include "jsb_cocos2dx_experimental.hpp"
|
||||
#include "jsb_cocos2dx_physics3d_auto.hpp"
|
||||
#include "physics3d/jsb_cocos2dx_physics3d_manual.h"
|
||||
#include "experimental/jsb_cocos2dx_experimental_manual.h"
|
||||
#include "3d/jsb_cocos2dx_3d_manual.h"
|
||||
#include "extension/jsb_cocos2dx_extension_manual.h"
|
||||
|
@ -112,6 +113,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
sc->addRegisterCallback(register_all_cocos2dx_experimental_manual);
|
||||
|
||||
sc->addRegisterCallback(register_all_cocos2dx_physics3d);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_physics3d_manual);
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
sc->addRegisterCallback(JavascriptJavaBridge::_js_register);
|
||||
|
|
|
@ -25,12 +25,122 @@
|
|||
****************************************************************************/
|
||||
var Physics3DTestIdx = -1;
|
||||
|
||||
var physicsScene = null;
|
||||
|
||||
const START_POS_X = -0.5;
|
||||
const START_POS_Y = -2.5;
|
||||
const START_POS_Z = -0.5;
|
||||
|
||||
const ARRAY_SIZE_X = 4;
|
||||
const ARRAY_SIZE_Y = 3;
|
||||
const ARRAY_SIZE_Z = 4;
|
||||
|
||||
var Physics3DTestDemo = cc.Layer.extend({
|
||||
_title:"",
|
||||
_title:"Physics3D Test",
|
||||
_subtitle:"",
|
||||
_camera:null,
|
||||
_angle:0.0,
|
||||
_needShootBox:false,
|
||||
|
||||
ctor:function () {
|
||||
this._super();
|
||||
|
||||
var size = cc.winSize;
|
||||
this._camera = cc.Camera.createPerspective(30.0, size.width / size.height, 1.0, 1000.0);
|
||||
this._camera.setPosition3D(cc.math.vec3(0, 50, 100));
|
||||
this._camera.lookAt(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 1, 0));
|
||||
this._camera.setCameraFlag(cc.CameraFlag.USER1);
|
||||
this.addChild(this._camera);
|
||||
|
||||
cc.eventManager.addListener({
|
||||
event:cc.EventListener.TOUCH_ALL_AT_ONCE,
|
||||
onTouchesBegan:this.onTouchesBegan.bind(this),
|
||||
onTouchesMoved:this.onTouchesMoved.bind(this),
|
||||
onTouchesEnded:this.onTouchesEnded.bind(this)
|
||||
}, this);
|
||||
|
||||
var label = new cc.LabelTTF("DebugDraw OFF");
|
||||
var menuItem = new cc.MenuItemLabel(label, function(){
|
||||
if(physicsScene.getPhysics3DWorld().isDebugDrawEnabled()){
|
||||
physicsScene.getPhysics3DWorld().setDebugDrawEnable(false);
|
||||
label.setString("DebugDraw OFF");
|
||||
}else{
|
||||
physicsScene.getPhysics3DWorld().setDebugDrawEnable(true);
|
||||
label.setString("DebugDraw ON");
|
||||
}
|
||||
}, this);
|
||||
|
||||
var menu = new cc.Menu(menuItem);
|
||||
menu.setPosition(cc.p(0, 0));
|
||||
menuItem.setAnchorPoint(cc.p(0, 1));
|
||||
menuItem.setPosition(cc.p(cc.visibleRect.left.x, cc.visibleRect.top.y - 50));
|
||||
this.addChild(menu);
|
||||
},
|
||||
|
||||
onTouchesBegan:function(touches, event){
|
||||
this._needShootBox = true;
|
||||
},
|
||||
|
||||
onTouchesMoved:function(touches, event){
|
||||
if(touches.length > 0 && this._camera){
|
||||
var touch = touches[0];
|
||||
var delta = touch.getDelta();
|
||||
|
||||
this._angle -= cc.degreesToRadians(delta.x);
|
||||
this._camera.setPosition3D(cc.math.vec3(100*Math.sin(this._angle), 50, 100*Math.cos(this._angle)));
|
||||
this._camera.lookAt(cc.math.vec3(0, 0, 0), cc.math.vec3(0, 1, 0));
|
||||
|
||||
if(delta.x * delta.x + delta.y + delta.y > 16)
|
||||
this._needShootBox = false;
|
||||
}
|
||||
},
|
||||
|
||||
onTouchesEnded:function(touches, event){
|
||||
if(!this._needShootBox)
|
||||
return;
|
||||
if(touches.length > 0){
|
||||
var location = touches[0].getLocationInView();
|
||||
|
||||
var nearP = cc.math.vec3(location.x, location.y, -1);
|
||||
var farP = cc.math.vec3(location.x, location.y, 1);
|
||||
nearP = this._camera.unproject(nearP);
|
||||
farP = this._camera.unproject(farP);
|
||||
|
||||
var dir = cc.math.vec3Sub(farP, nearP);
|
||||
this.shootBox(cc.math.vec3Add(this._camera.getPosition3D(), cc.math.vec3(dir.x*10, dir.y*10, dir.z*10)));
|
||||
}
|
||||
},
|
||||
|
||||
shootBox:function(des){
|
||||
var rbDes = cc.physics3DRigidBodyDes();
|
||||
var linearVel = cc.math.vec3Sub(des, this._camera.getPosition3D());
|
||||
linearVel.normalize();
|
||||
linearVel.x *= 100;
|
||||
linearVel.y *= 100;
|
||||
linearVel.z *= 100;
|
||||
|
||||
rbDes.mass = 1;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(0.5, 0.5, 0.5));
|
||||
var v = this._camera.getPosition3D();
|
||||
rbDes.originalTransform[12] = v.x;
|
||||
rbDes.originalTransform[13] = v.y;
|
||||
rbDes.originalTransform[14] = v.z;
|
||||
var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/box.c3t", rbDes);
|
||||
sprite.setTexture("Images/Icon.png");
|
||||
|
||||
var rigidBody = sprite.getPhysicsObj();
|
||||
rigidBody.setLinearFactor(cc.math.vec3(1, 1, 1));
|
||||
rigidBody.setLinearVelocity(linearVel);
|
||||
rigidBody.setAngularVelocity(cc.math.vec3(0, 0, 0));
|
||||
rigidBody.setCcdMotionThreshold(0.5);
|
||||
rigidBody.setCcdSweptSphereRadius(0.4);
|
||||
|
||||
this.addChild(sprite);
|
||||
sprite.setPosition3D(this._camera.getPosition3D());
|
||||
sprite.setScale(0.5);
|
||||
sprite.syncToNode();
|
||||
sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
},
|
||||
|
||||
//
|
||||
|
@ -88,7 +198,7 @@ var Physics3DTestDemo = cc.Layer.extend({
|
|||
var s = new Physics3DTestScene();
|
||||
s.addChild(previousPhysics3DTest());
|
||||
director.runScene(s);
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
var Physics3DTestScene = cc.Scene.extend({
|
||||
|
@ -104,6 +214,10 @@ var Physics3DTestScene = cc.Scene.extend({
|
|||
menuItem.x = winSize.width - 50;
|
||||
menuItem.y = 25;
|
||||
this.addChild(menu);
|
||||
|
||||
this.initWithPhysics();
|
||||
this.getPhysics3DWorld().setDebugDrawEnable(false);
|
||||
physicsScene = this;
|
||||
},
|
||||
onMainMenuCallback:function () {
|
||||
var scene = new cc.Scene();
|
||||
|
@ -121,15 +235,400 @@ var Physics3DTestScene = cc.Scene.extend({
|
|||
});
|
||||
|
||||
var BasicPhysics3DDemo = Physics3DTestDemo.extend({
|
||||
_subtitle:"Basic Physics3D",
|
||||
|
||||
ctor:function(){
|
||||
this._super();
|
||||
|
||||
var rbDes = cc.physics3DRigidBodyDes();
|
||||
rbDes.mass = 0;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(60, 1, 60));
|
||||
|
||||
var floor = cc.PhysicsSprite3D.create("Sprite3DTest/box.c3t", rbDes);
|
||||
floor.setTexture("Sprite3DTest/plane.png");
|
||||
floor.setScaleX(60);
|
||||
floor.setScaleZ(60);
|
||||
this.addChild(floor);
|
||||
floor.setCameraMask(cc.CameraFlag.USER1);
|
||||
floor.syncToNode();
|
||||
//static object sync is not needed
|
||||
floor.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE);
|
||||
|
||||
//create several boxes using PhysicsSprite3D
|
||||
rbDes.mass = 1;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(0.8, 0.8, 0.8));
|
||||
var start_x = START_POS_X - ARRAY_SIZE_X/2;
|
||||
var start_y = START_POS_Y;
|
||||
var start_z = START_POS_Z - ARRAY_SIZE_Z/2;
|
||||
|
||||
for(var k = 0; k < ARRAY_SIZE_Y; ++k){
|
||||
for(var i = 0; i < ARRAY_SIZE_X; ++i){
|
||||
for(var j = 0; j < ARRAY_SIZE_Z; ++j){
|
||||
var x = i + start_x,
|
||||
y = 5 + k + start_y,
|
||||
z = j + start_z;
|
||||
var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/box.c3t", rbDes);
|
||||
sprite.setTexture("Images/CyanSquare.png");
|
||||
sprite.setPosition3D(cc.math.vec3(x, y, z));
|
||||
sprite.syncToNode();
|
||||
sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
sprite.setScale(0.8);
|
||||
this.addChild(sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
physicsScene.setPhysics3DDebugCamera(this._camera);
|
||||
}
|
||||
});
|
||||
|
||||
var Physics3DConstraintDemo = Physics3DTestDemo.extend({
|
||||
_subtitle:"Physics3D Constraint",
|
||||
|
||||
ctor:function(){
|
||||
this._super();
|
||||
|
||||
//PhysicsSprite3d = Sprite3D + Physics3DComponent
|
||||
var rbDes = cc.physics3DRigidBodyDes();
|
||||
rbDes.disableSleep = true;
|
||||
rbDes.mass = 10;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(5, 5, 5));
|
||||
|
||||
var rigidBody = cc.Physics3DRigidBody.create(rbDes);
|
||||
var quat = cc.math.quaternion(cc.math.vec3(0, 1, 0), cc.degreesToRadians(180));
|
||||
var component = cc.Physics3DComponent.create(rigidBody, cc.math.vec3(0, -3, 0), quat);
|
||||
|
||||
var sprite = new jsb.Sprite3D("Sprite3DTest/orc.c3b");
|
||||
sprite.addComponent(component);
|
||||
this.addChild(sprite);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
sprite.setScale(0.4);
|
||||
sprite.setPosition3D(cc.math.vec3(-20, 5, 0));
|
||||
component.syncToNode();
|
||||
component.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE);
|
||||
|
||||
physicsScene.setPhysics3DDebugCamera(this._camera);
|
||||
|
||||
//create point to point constraint
|
||||
var constraint = cc.Physics3DPointToPointConstraint.create(rigidBody, cc.math.vec3(2.5, 2.5, 2.5));
|
||||
physicsScene.getPhysics3DWorld().addPhysics3DConstraint(constraint);
|
||||
|
||||
//create hinge constraint
|
||||
rbDes.mass = 1;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(8, 8, 1));
|
||||
rigidBody = cc.Physics3DRigidBody.create(rbDes);
|
||||
component = cc.Physics3DComponent.create(rigidBody);
|
||||
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
|
||||
sprite.setTexture("Sprite3DTest/plane.png");
|
||||
sprite.setScaleX(8);
|
||||
sprite.setScaleZ(8);
|
||||
sprite.setPosition3D(cc.math.vec3(5, 0, 0));
|
||||
sprite.addComponent(component);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
this.addChild(sprite);
|
||||
component.syncToNode();
|
||||
rigidBody.setAngularVelocity(cc.math.vec3(0, 3, 0));
|
||||
constraint = cc.Physics3DHingeConstraint.create(rigidBody, cc.math.vec3(4, 4, 0.5), cc.math.vec3(0, 1, 0));
|
||||
physicsScene.getPhysics3DWorld().addPhysics3DConstraint(constraint);
|
||||
|
||||
//create slider constraint
|
||||
rbDes.mass = 1;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(3, 2, 3));
|
||||
rigidBody = cc.Physics3DRigidBody.create(rbDes);
|
||||
component = cc.Physics3DComponent.create(rigidBody);
|
||||
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
|
||||
sprite.setTexture("Sprite3DTest/plane.png");
|
||||
sprite.setScaleX(3);
|
||||
sprite.setScaleZ(3);
|
||||
sprite.setPosition3D(cc.math.vec3(30, 15, 0));
|
||||
sprite.addComponent(component);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
this.addChild(sprite);
|
||||
component.syncToNode();
|
||||
rigidBody.setLinearVelocity(cc.math.vec3(0, 3, 0));
|
||||
|
||||
rbDes.mass = 0;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
|
||||
var rigidBodyB = cc.Physics3DRigidBody.create(rbDes);
|
||||
component = cc.Physics3DComponent.create(rigidBodyB);
|
||||
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
|
||||
sprite.setTexture("Sprite3DTest/plane.png");
|
||||
sprite.setScale(3);
|
||||
sprite.setPosition3D(cc.math.vec3(30, 5, 0));
|
||||
sprite.addComponent(component);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
this.addChild(sprite);
|
||||
component.syncToNode();
|
||||
|
||||
var frameInA = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, -5, 0, 1];
|
||||
var frameInB = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, 5, 0, 1];
|
||||
constraint = cc.Physics3DSliderConstraint.create(rigidBody, rigidBodyB, frameInA, frameInB, false);
|
||||
physicsScene.getPhysics3DWorld().addPhysics3DConstraint(constraint);
|
||||
constraint.setLowerLinLimit(-5);
|
||||
constraint.setUpperLinLimit(5);
|
||||
|
||||
//create ConeTwist constraint
|
||||
rbDes.mass = 1;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
|
||||
rigidBody = cc.Physics3DRigidBody.create(rbDes);
|
||||
component = cc.Physics3DComponent.create(rigidBody);
|
||||
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
|
||||
sprite.setTexture("Sprite3DTest/plane.png");
|
||||
sprite.setScale(3);
|
||||
sprite.setPosition3D(cc.math.vec3(-10, 5, 5));
|
||||
sprite.addComponent(component);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
this.addChild(sprite);
|
||||
component.syncToNode();
|
||||
|
||||
frameInA = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, -10, 0, 1];
|
||||
constraint = cc.Physics3DConeTwistConstraint.create(rigidBody, frameInA);
|
||||
physicsScene.getPhysics3DWorld().addPhysics3DConstraint(constraint, true);
|
||||
constraint.setLimit(cc.degreesToRadians(10), cc.degreesToRadians(10), cc.degreesToRadians(40));
|
||||
|
||||
//create 6 dof constraint
|
||||
rbDes.mass = 1;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
|
||||
rigidBody = cc.Physics3DRigidBody.create(rbDes);
|
||||
component = cc.Physics3DComponent.create(rigidBody);
|
||||
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
|
||||
sprite.setTexture("Sprite3DTest/plane.png");
|
||||
sprite.setScale(3);
|
||||
sprite.setPosition3D(cc.math.vec3(30, -5, 0));
|
||||
sprite.addComponent(component);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
this.addChild(sprite);
|
||||
component.syncToNode();
|
||||
|
||||
frameInA = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
||||
constraint = cc.Physics3D6DofConstraint.create(rigidBody, frameInA, false);
|
||||
physicsScene.getPhysics3DWorld().addPhysics3DConstraint(constraint);
|
||||
constraint.setAngularLowerLimit(cc.math.vec3(0, 0, 0));
|
||||
constraint.setAngularUpperLimit(cc.math.vec3(0, 0, 0));
|
||||
constraint.setLinearLowerLimit(cc.math.vec3(-10, 0, 0));
|
||||
constraint.setLinearUpperLimit(cc.math.vec3(10, 0, 0));
|
||||
}
|
||||
});
|
||||
|
||||
var Physics3DKinematicDemo = Physics3DTestDemo.extend({
|
||||
_subtitle:"Physics3D Kinematic",
|
||||
|
||||
ctor:function(){
|
||||
this._super();
|
||||
|
||||
var rbDes = cc.physics3DRigidBodyDes();
|
||||
rbDes.mass = 0;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(60, 1, 60));
|
||||
|
||||
var floor = cc.PhysicsSprite3D.create("Sprite3DTest/box.c3t", rbDes);
|
||||
floor.setTexture("Sprite3DTest/plane.png");
|
||||
floor.setScaleX(60);
|
||||
floor.setScaleZ(60);
|
||||
floor.setPosition3D(cc.math.vec3(0, -1, 0));
|
||||
this.addChild(floor);
|
||||
floor.setCameraMask(cc.CameraFlag.USER1);
|
||||
floor.syncToNode();
|
||||
//static object sync is not needed
|
||||
floor.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE);
|
||||
|
||||
//create Kinematics
|
||||
for(let i = 0; i < 3; ++i){
|
||||
rbDes.mass = 0;
|
||||
rbDes.shape = cc.Physics3DShape.createBox(cc.math.vec3(2, 2, 2));
|
||||
|
||||
let sprite = cc.PhysicsSprite3D.create("Sprite3DTest/box.c3t", rbDes);
|
||||
sprite.setTexture("Images/CyanSquare.png");
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
let rigidBody = sprite.getPhysicsObj();
|
||||
rigidBody.setKinematic(true);
|
||||
|
||||
this.addChild(sprite);
|
||||
|
||||
sprite.setScale(2);
|
||||
sprite.setPosition3D(cc.math.vec3(-15, 0, 15-15*i));
|
||||
let moveby = cc.moveBy(2+i, cc.math.vec3(30, 0, 0));
|
||||
sprite.runAction(cc.sequence(moveby, moveby.reverse()).repeatForever());
|
||||
}
|
||||
|
||||
//create Dynamic
|
||||
rbDes.mass = 1;
|
||||
rbDes.shape = cc.Physics3DShape.createSphere(0.5);
|
||||
var start_x = START_POS_X - ARRAY_SIZE_X/2;
|
||||
var start_y = START_POS_Y + 5;
|
||||
var start_z = START_POS_Z - ARRAY_SIZE_Z/2;
|
||||
|
||||
for(var k = 0; k < ARRAY_SIZE_Y; ++k){
|
||||
for(var i = 0; i < ARRAY_SIZE_X; ++i){
|
||||
for(var j = 0; j < ARRAY_SIZE_Z; ++j){
|
||||
var x = i + start_x,
|
||||
y = 5 + k + start_y,
|
||||
z = j + start_z;
|
||||
|
||||
rbDes.originalTransform[12] = x;
|
||||
rbDes.originalTransform[13] = y;
|
||||
rbDes.originalTransform[14] = z;
|
||||
|
||||
var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/sphere.c3b", rbDes);
|
||||
sprite.setTexture("Sprite3DTest/plane.png");
|
||||
sprite.setPosition3D(cc.math.vec3(x, y, z));
|
||||
sprite.syncToNode();
|
||||
sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
sprite.setScale(1/sprite.getContentSize().width);
|
||||
this.addChild(sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
physicsScene.setPhysics3DDebugCamera(this._camera);
|
||||
}
|
||||
});
|
||||
|
||||
var Physics3DCollisionCallbackDemo = Physics3DTestDemo.extend({
|
||||
_subtitle:"Physics3D CollisionCallback",
|
||||
|
||||
ctor:function(){
|
||||
this._super();
|
||||
|
||||
var rbDes = cc.physics3DRigidBodyDes();
|
||||
|
||||
var scale = 2;
|
||||
var trianglesList = jsb.Bundle3D.getTrianglesList("Sprite3DTest/boss.c3b");
|
||||
|
||||
for(var i = 0; i < trianglesList.length; ++i){
|
||||
trianglesList[i].x *= scale;
|
||||
trianglesList[i].y *= scale;
|
||||
trianglesList[i].z *= scale;
|
||||
}
|
||||
|
||||
rbDes.mass = 0;
|
||||
rbDes.shape = cc.Physics3DShape.createMesh(trianglesList, trianglesList.length/3);
|
||||
|
||||
var rigidBody = cc.Physics3DRigidBody.create(rbDes);
|
||||
var component = cc.Physics3DComponent.create(rigidBody);
|
||||
var sprite = new jsb.Sprite3D("Sprite3DTest/boss.c3b");
|
||||
sprite.addComponent(component);
|
||||
sprite.setRotation3D(cc.math.vec3(-90, 0, 0));
|
||||
sprite.setScale(scale);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
this.addChild(sprite);
|
||||
|
||||
rigidBody.setCollisionCallback(function(collisionInfo){
|
||||
if(collisionInfo.collisionPointList.length > 0 && collisionInfo.objA.getMask() != 0){
|
||||
var ps = jsb.PUParticleSystem3D.create("Particle3D/scripts/mp_hit_04.pu");
|
||||
ps.setPosition3D(collisionInfo.collisionPointList[0].worldPositionOnB);
|
||||
ps.setScale(0.05);
|
||||
ps.startParticleSystem();
|
||||
ps.setCameraMask(2);
|
||||
this.addChild(ps);
|
||||
|
||||
ps.runAction(cc.sequence(cc.delayTime(1), cc.callFunc(function(){
|
||||
ps.removeFromParent();
|
||||
})));
|
||||
|
||||
collisionInfo.objA.setMask(0);
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
||||
physicsScene.setPhysics3DDebugCamera(this._camera);
|
||||
}
|
||||
});
|
||||
|
||||
var Physics3DTerrainDemo = Physics3DTestDemo.extend({
|
||||
_subtitle:"Physics3D Terrain",
|
||||
|
||||
ctor:function(){
|
||||
this._super();
|
||||
|
||||
var r = jsb.Terrain.detailMap("TerrainTest/dirt.jpg"),
|
||||
g = jsb.Terrain.detailMap("TerrainTest/Grass2.jpg", 10),
|
||||
b = jsb.Terrain.detailMap("TerrainTest/road.jpg"),
|
||||
a = jsb.Terrain.detailMap("TerrainTest/GreenSkin.jpg", 20);
|
||||
var data = jsb.Terrain.terrainData(
|
||||
"TerrainTest/heightmap129.jpg",
|
||||
"TerrainTest/alphamap.png",
|
||||
[r, g, b, a],
|
||||
cc.size(32,32),
|
||||
20,
|
||||
1
|
||||
);
|
||||
|
||||
var terrain = jsb.Terrain.create(data, jsb.Terrain.CrackFixedType.SKIRT);
|
||||
terrain.setSkirtHeightRatio(3);
|
||||
terrain.setLODDistance(64, 128, 192);
|
||||
terrain.setMaxDetailMapAmount(4);
|
||||
terrain.setCameraMask(2);
|
||||
terrain.setDrawWire(false);
|
||||
|
||||
var rbDes = cc.physics3DRigidBodyDes();
|
||||
rbDes.mass = 0;
|
||||
|
||||
var heightData = terrain.getHeightData();
|
||||
var size = terrain.getTerrainSize();
|
||||
rbDes.shape = cc.Physics3DShape.createHeightfield(size.width, size.height, heightData, 1.0, terrain.getMinHeight(), terrain.getMaxHeight(), true, false, true);
|
||||
var rigidBody = cc.Physics3DRigidBody.create(rbDes);
|
||||
var component = cc.Physics3DComponent.create(rigidBody);
|
||||
terrain.addComponent(component);
|
||||
component.syncToNode();
|
||||
component.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE);
|
||||
|
||||
this.addChild(terrain);
|
||||
|
||||
//create several spheres
|
||||
rbDes.mass = 1;
|
||||
rbDes.shape = cc.Physics3DShape.createSphere(0.5);
|
||||
var start_x = START_POS_X - ARRAY_SIZE_X/2 + 5;
|
||||
var start_y = START_POS_Y + 20;
|
||||
var start_z = START_POS_Z - ARRAY_SIZE_Z/2;
|
||||
|
||||
for(var k = 0; k < ARRAY_SIZE_Y; ++k){
|
||||
for(var i = 0; i < ARRAY_SIZE_X; ++i){
|
||||
for(var j = 0; j < ARRAY_SIZE_Z; ++j){
|
||||
var x = i + start_x,
|
||||
y = 5 + k + start_y,
|
||||
z = j + start_z;
|
||||
|
||||
var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/sphere.c3b", rbDes);
|
||||
sprite.setTexture("Sprite3DTest/plane.png");
|
||||
sprite.setPosition3D(cc.math.vec3(x, y, z));
|
||||
sprite.syncToNode();
|
||||
sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE);
|
||||
sprite.setCameraMask(cc.CameraFlag.USER1);
|
||||
sprite.setScale(1/sprite.getContentSize().width);
|
||||
this.addChild(sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//create mesh
|
||||
var trianglesList = jsb.Bundle3D.getTrianglesList("Sprite3DTest/boss.c3b");
|
||||
rbDes.mass = 0;
|
||||
rbDes.shape = cc.Physics3DShape.createMesh(trianglesList, trianglesList.length/3);
|
||||
rigidBody = cc.Physics3DRigidBody.create(rbDes);
|
||||
component = cc.Physics3DComponent.create(rigidBody);
|
||||
var sprite = new jsb.Sprite3D("Sprite3DTest/boss.c3b");
|
||||
sprite.addComponent(component);
|
||||
sprite.setRotation3D(cc.math.vec3(-90, 0, 0));
|
||||
sprite.setPosition3D(cc.math.vec3(0, 15, 0));
|
||||
sprite.setCameraMask(2);
|
||||
this.addChild(sprite);
|
||||
|
||||
|
||||
physicsScene.setPhysics3DDebugCamera(this._camera);
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Flow control
|
||||
//
|
||||
var arrayOfPhysics3DTest = [
|
||||
BasicPhysics3DDemo
|
||||
BasicPhysics3DDemo,
|
||||
Physics3DConstraintDemo,
|
||||
Physics3DKinematicDemo,
|
||||
Physics3DCollisionCallbackDemo,
|
||||
Physics3DTerrainDemo
|
||||
];
|
||||
|
||||
var nextPhysics3DTest = function () {
|
||||
|
|
|
@ -11,7 +11,7 @@ android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/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 -U __SSE__
|
||||
clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ -D CC_USE_3D_PHYSICS -D CC_ENABLE_BULLET_INTEGRATION
|
||||
|
||||
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external
|
||||
cocos_flags = -DANDROID
|
||||
|
@ -22,7 +22,7 @@ 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 %(cocosdir)s/cocos/audio/include/SimpleAudioEngine.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.h %(cocosdir)s/cocos/2d/SpritePolygonCache.h
|
||||
headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAudioEngine.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.h %(cocosdir)s/cocos/2d/SpritePolygonCache.h %(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*$".
|
||||
|
@ -121,7 +121,7 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat
|
|||
Component::[serialize],
|
||||
EventListenerCustom::[init],
|
||||
EventListener::[init],
|
||||
Scene::[getCameras getLights initWithPhysics createWithPhysics getPhysicsWorld getPhysics3DWorld setPhysics3DDebugCamera],
|
||||
Scene::[getCameras getLights createWithPhysics getPhysicsWorld],
|
||||
Animate3D::[*],
|
||||
Sprite3D::[*],
|
||||
AttachNode::[*],
|
||||
|
@ -137,7 +137,8 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat
|
|||
Camera::[unproject isVisibleInFrustum],
|
||||
ClippingNode::[init],
|
||||
SpritePolygonCache::[addSpritePolygonCache getSpritePolygonCache],
|
||||
RenderState::[setStateBlock]
|
||||
RenderState::[setStateBlock],
|
||||
btActionInterface::[*]
|
||||
|
||||
rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame],
|
||||
MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName],
|
||||
|
|
|
@ -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
|
||||
|
||||
classes_need_extend = Sprite3D
|
||||
|
||||
|
@ -43,7 +43,8 @@ skip = Skeleton3D::[create],
|
|||
Sprite3DCache::[addSprite3DData getSpriteData],
|
||||
Animation3D::[getBoneCurves],
|
||||
TextureCube::[setTexParameters],
|
||||
Terrain::[getAABB getQuadTree create getHeightData]
|
||||
Terrain::[getAABB getQuadTree create getHeightData],
|
||||
Bundle3D::[getTrianglesList calculateAABB]
|
||||
|
||||
|
||||
rename_functions =
|
||||
|
|
|
@ -36,10 +36,12 @@ classes = Physics3DWorld Physics3DShape PhysicsSprite3D Physics3DObject Physics3
|
|||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = Physics3DShape::[createCompoundShape],
|
||||
skip = Physics3DShape::[createCompoundShape createMesh createHeightfield],
|
||||
Physics3DObject::[setCollisionCallback],
|
||||
Physics3DWorld::[getPhysicsObjects],
|
||||
Physics3DConeTwistConstraint::[setMotorTarget setMotorTargetInConstraintSpace]
|
||||
Physics3DConeTwistConstraint::[setMotorTarget setMotorTargetInConstraintSpace],
|
||||
PhysicsSprite3D::[create],
|
||||
Physics3DRigidBody::[create]
|
||||
|
||||
rename_functions =
|
||||
|
||||
|
|
Loading…
Reference in New Issue