From 712ba4f64c79d3eda14e9f97f15656652fbd158e Mon Sep 17 00:00:00 2001 From: joshuastray Date: Wed, 20 May 2015 10:35:33 +0800 Subject: [PATCH 1/4] add physics3d auto binding --- .../proj.win32/libjscocos2d.vcxproj | 6 +- .../proj.win32/libjscocos2d.vcxproj.filters | 6 + tests/js-tests/project.json | 3 +- .../js-tests/project/Classes/AppDelegate.cpp | 3 + .../src/Physics3DTest/Physics3DTest.js | 150 ++++++++++++++++++ tests/js-tests/src/tests-main.js | 8 + tools/tojs/cocos2dx_physics3d.ini | 62 ++++++++ tools/tojs/genbindings.py | 3 +- 8 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 tests/js-tests/src/Physics3DTest/Physics3DTest.js create mode 100644 tools/tojs/cocos2dx_physics3d.ini diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj index 8e09d72c6f..a5058fe632 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj @@ -17,6 +17,7 @@ + @@ -54,6 +55,7 @@ + @@ -151,7 +153,7 @@ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true false @@ -177,7 +179,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true None diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters index 45f154340e..fb4810374b 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters @@ -146,6 +146,9 @@ manual\experimental + + auto + @@ -274,5 +277,8 @@ manual\experimental + + auto + \ No newline at end of file diff --git a/tests/js-tests/project.json b/tests/js-tests/project.json index 1c1cd0bea3..a014ce397f 100644 --- a/tests/js-tests/project.json +++ b/tests/js-tests/project.json @@ -188,6 +188,7 @@ "src/SpritePolygonTest/SpritePolygonTest.js", "src/MaterialSystemTest/MaterialSystemTest.js", - "src/TerrainTest/TerrainTest.js" + "src/TerrainTest/TerrainTest.js", + "src/Physics3DTest/Physics3DTest.js" ] } diff --git a/tests/js-tests/project/Classes/AppDelegate.cpp b/tests/js-tests/project/Classes/AppDelegate.cpp index edbcae902c..94a5e16296 100644 --- a/tests/js-tests/project/Classes/AppDelegate.cpp +++ b/tests/js-tests/project/Classes/AppDelegate.cpp @@ -10,6 +10,7 @@ #include "jsb_cocos2dx_3d_auto.hpp" #include "jsb_cocos2dx_3d_extension_auto.hpp" #include "jsb_cocos2dx_experimental.hpp" +#include "jsb_cocos2dx_physics3d_auto.hpp" #include "experimental/jsb_cocos2dx_experimental_manual.h" #include "3d/jsb_cocos2dx_3d_manual.h" #include "extension/jsb_cocos2dx_extension_manual.h" @@ -109,6 +110,8 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_experimental); sc->addRegisterCallback(register_all_cocos2dx_experimental_manual); + + sc->addRegisterCallback(register_all_cocos2dx_physics3d); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) sc->addRegisterCallback(JavascriptJavaBridge::_js_register); diff --git a/tests/js-tests/src/Physics3DTest/Physics3DTest.js b/tests/js-tests/src/Physics3DTest/Physics3DTest.js new file mode 100644 index 0000000000..6deb9160b4 --- /dev/null +++ b/tests/js-tests/src/Physics3DTest/Physics3DTest.js @@ -0,0 +1,150 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-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. + ****************************************************************************/ +var Physics3DTestIdx = -1; + +var Physics3DTestDemo = cc.Layer.extend({ + _title:"", + _subtitle:"", + + ctor:function () { + this._super(); + }, + + // + // Menu + // + onEnter:function () { + this._super(); + + var label = new cc.LabelTTF(this._title, "Arial", 28); + this.addChild(label, 100, BASE_TEST_TITLE_TAG); + label.x = winSize.width / 2; + label.y = winSize.height - 50; + + var label2 = new cc.LabelTTF(this._subtitle, "Thonburi", 16); + this.addChild(label2, 101, BASE_TEST_SUBTITLE_TAG); + label2.x = winSize.width / 2; + label2.y = winSize.height - 80; + + var item1 = new cc.MenuItemImage(s_pathB1, s_pathB2, this.onBackCallback, this); + var item2 = new cc.MenuItemImage(s_pathR1, s_pathR2, this.onRestartCallback, this); + var item3 = new cc.MenuItemImage(s_pathF1, s_pathF2, this.onNextCallback, this); + + item1.tag = BASE_TEST_MENUITEM_PREV_TAG; + item2.tag = BASE_TEST_MENUITEM_RESET_TAG; + item3.tag = BASE_TEST_MENUITEM_NEXT_TAG; + + var menu = new cc.Menu(item1, item2, item3); + + menu.x = 0; + menu.y = 0; + var width = item2.width, height = item2.height; + item1.x = winSize.width/2 - width*2; + item1.y = height/2 ; + item2.x = winSize.width/2; + item2.y = height/2 ; + item3.x = winSize.width/2 + width*2; + item3.y = height/2 ; + + this.addChild(menu, 102, BASE_TEST_MENU_TAG); + }, + + onRestartCallback:function (sender) { + var s = new Physics3DTestScene(); + s.addChild(restartPhysics3DTest()); + director.runScene(s); + }, + + onNextCallback:function (sender) { + var s = new Physics3DTestScene(); + s.addChild(nextPhysics3DTest()); + director.runScene(s); + }, + + onBackCallback:function (sender) { + var s = new Physics3DTestScene(); + s.addChild(previousPhysics3DTest()); + director.runScene(s); + }, +}); + +var Physics3DTestScene = cc.Scene.extend({ + ctor:function () { + this._super(); + + var label = new cc.LabelTTF("Main Menu", "Arial", 20); + var menuItem = new cc.MenuItemLabel(label, this.onMainMenuCallback, this); + + var menu = new cc.Menu(menuItem); + menu.x = 0; + menu.y = 0; + menuItem.x = winSize.width - 50; + menuItem.y = 25; + this.addChild(menu); + }, + onMainMenuCallback:function () { + var scene = new cc.Scene(); + var layer = new TestController(); + scene.addChild(layer); + director.runScene(scene); + }, + runThisTest:function (num) { + Physics3DTestIdx = (num || num == 0) ? (num - 1) : -1; + var layer = nextPhysics3DTest(); + this.addChild(layer); + + director.runScene(this); + } +}); + +var BasicPhysics3DDemo = Physics3DTestDemo.extend({ + ctor:function(){ + this._super(); + } +}); +// +// Flow control +// +var arrayOfPhysics3DTest = [ + BasicPhysics3DDemo +]; + +var nextPhysics3DTest = function () { + Physics3DTestIdx++; + Physics3DTestIdx = Physics3DTestIdx % arrayOfPhysics3DTest.length; + + return new arrayOfPhysics3DTest[Physics3DTestIdx ](); +}; +var previousPhysics3DTest = function () { + Physics3DTestIdx--; + if (Physics3DTestIdx < 0) + Physics3DTestIdx += arrayOfPhysics3DTest.length; + + return new arrayOfPhysics3DTest[Physics3DTestIdx ](); +}; +var restartPhysics3DTest = function () { + return new arrayOfPhysics3DTest[Physics3DTestIdx ](); +}; diff --git a/tests/js-tests/src/tests-main.js b/tests/js-tests/src/tests-main.js index 11e930c843..eb632b6722 100644 --- a/tests/js-tests/src/tests-main.js +++ b/tests/js-tests/src/tests-main.js @@ -530,6 +530,14 @@ var testNames = [ return new PerformanceTestScene(); } }, + { + title:"Physics3D Test", + platforms: PLATFORM_JSB, + linksrc:"src/Physics3DTest/Physics3DTest.js", + testScene:function () { + return new Physics3DTestScene(); + } + }, { title:"ProgressActions Test", platforms: PLATFORM_ALL, diff --git a/tools/tojs/cocos2dx_physics3d.ini b/tools/tojs/cocos2dx_physics3d.ini new file mode 100644 index 0000000000..d8cb9123eb --- /dev/null +++ b/tools/tojs/cocos2dx_physics3d.ini @@ -0,0 +1,62 @@ +[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 + +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 -D CC_USE_3D_PHYSICS -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 = Physics3DShape::[createCompoundShape], + Physics3DObject::[setCollisionCallback], + Physics3DWorld::[getPhysicsObjects], + Physics3DConeTwistConstraint::[setMotorTarget setMotorTargetInConstraintSpace] + +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 = Ref + +# 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 diff --git a/tools/tojs/genbindings.py b/tools/tojs/genbindings.py index 11f861df39..10c4d58a16 100755 --- a/tools/tojs/genbindings.py +++ b/tools/tojs/genbindings.py @@ -142,7 +142,8 @@ def main(): 'cocos2dx_spine.ini' : ('cocos2dx_spine', 'jsb_cocos2dx_spine_auto'), \ 'cocos2dx_3d.ini' : ('cocos2dx_3d', 'jsb_cocos2dx_3d_auto'), \ 'cocos2dx_3d_ext.ini' : ('cocos2dx_3d_extension', 'jsb_cocos2dx_3d_extension_auto'), \ - 'cocos2dx_experimental.ini' : ('cocos2dx_experimental', 'jsb_cocos2dx_experimental') + 'cocos2dx_experimental.ini' : ('cocos2dx_experimental', 'jsb_cocos2dx_experimental'), \ + 'cocos2dx_physics3d.ini' : ('cocos2dx_physics3d', 'jsb_cocos2dx_physics3d_auto') } target = 'spidermonkey' generator_py = '%s/generator.py' % cxx_generator_root From 83237b8dbdbc303a53b53dc8e255df656019fb6b Mon Sep 17 00:00:00 2001 From: joshuastray Date: Thu, 21 May 2015 18:03:51 +0800 Subject: [PATCH 2/4] add physics3d js manual binding and tests --- cocos/scripting/js-bindings/CMakeLists.txt | 4 + .../manual/3d/jsb_cocos2dx_3d_manual.cpp | 61 +++ .../manual/js_manual_conversions.cpp | 61 ++- .../manual/js_manual_conversions.h | 2 + .../jsb_cocos2dx_physics3d_manual.cpp | 323 +++++++++++ .../physics3d/jsb_cocos2dx_physics3d_manual.h | 38 ++ .../js-bindings/proj.android/Android.mk | 10 +- cocos/scripting/js-bindings/script/jsb.js | 7 +- .../script/physics3d/jsb_physics3d.js | 43 ++ .../js-tests/project/Classes/AppDelegate.cpp | 2 + .../src/Physics3DTest/Physics3DTest.js | 505 +++++++++++++++++- tools/tojs/cocos2dx.ini | 9 +- tools/tojs/cocos2dx_3d.ini | 7 +- tools/tojs/cocos2dx_physics3d.ini | 6 +- 14 files changed, 1057 insertions(+), 21 deletions(-) create mode 100644 cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp create mode 100644 cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.h create mode 100644 cocos/scripting/js-bindings/script/physics3d/jsb_physics3d.js diff --git a/cocos/scripting/js-bindings/CMakeLists.txt b/cocos/scripting/js-bindings/CMakeLists.txt index 3f1a5d8f36..a233d6cf04 100644 --- a/cocos/scripting/js-bindings/CMakeLists.txt +++ b/cocos/scripting/js-bindings/CMakeLists.txt @@ -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 diff --git a/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp index 9085c4670d..87e22e3f36 100644 --- a/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp +++ b/cocos/scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.cpp @@ -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& 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 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); } diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp index 187ddadab5..5eea240502 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -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::vectorreserve(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* 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& 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& jsval std_vector_int_to_jsval( JSContext *cx, const std::vector& 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& v) return OBJECT_TO_JSVAL(jsretArr); } +jsval std_vector_float_to_jsval( JSContext *cx, const std::vector& 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)); diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 575dc940c6..9d9b1b8538 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -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* ret); bool jsval_to_std_vector_int( JSContext *cx, JS::HandleValue vp, std::vector* ret); +bool jsval_to_std_vector_float( JSContext *cx, JS::HandleValue vp, std::vector* 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& v); jsval std_vector_int_to_jsval( JSContext *cx, const std::vector& v); +jsval std_vector_float_to_jsval( JSContext *cx, const std::vector& 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); diff --git a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp new file mode 100644 index 0000000000..26c56c3ff4 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp @@ -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(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(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(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(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* 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 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(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(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(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 arg0; + std::shared_ptr 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 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(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 diff --git a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.h b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.h new file mode 100644 index 0000000000..da5ae10550 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.h @@ -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__ diff --git a/cocos/scripting/js-bindings/proj.android/Android.mk b/cocos/scripting/js-bindings/proj.android/Android.mk index 1246b0259f..d11ee2e017 100755 --- a/cocos/scripting/js-bindings/proj.android/Android.mk +++ b/cocos/scripting/js-bindings/proj.android/Android.mk @@ -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 diff --git a/cocos/scripting/js-bindings/script/jsb.js b/cocos/scripting/js-bindings/script/jsb.js index 1ae745a3c5..e88f281201 100644 --- a/cocos/scripting/js-bindings/script/jsb.js +++ b/cocos/scripting/js-bindings/script/jsb.js @@ -135,5 +135,8 @@ if (jsb.Sprite3D){ } if (jsb.ParticleSystem3D) { - require('script/3d/jsb_cocos2d_3d_ext.js'); -} \ No newline at end of file + require('script/3d/jsb_cocos2d_3d_ext.js'); +} + +if(cc.Physics3DObject) + require("script/physics3d/jsb_physics3d.js"); diff --git a/cocos/scripting/js-bindings/script/physics3d/jsb_physics3d.js b/cocos/scripting/js-bindings/script/physics3d/jsb_physics3d.js new file mode 100644 index 0000000000..932f74ea8c --- /dev/null +++ b/cocos/scripting/js-bindings/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 +}; diff --git a/tests/js-tests/project/Classes/AppDelegate.cpp b/tests/js-tests/project/Classes/AppDelegate.cpp index 94a5e16296..e799b8b750 100644 --- a/tests/js-tests/project/Classes/AppDelegate.cpp +++ b/tests/js-tests/project/Classes/AppDelegate.cpp @@ -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); diff --git a/tests/js-tests/src/Physics3DTest/Physics3DTest.js b/tests/js-tests/src/Physics3DTest/Physics3DTest.js index 6deb9160b4..41184ae602 100644 --- a/tests/js-tests/src/Physics3DTest/Physics3DTest.js +++ b/tests/js-tests/src/Physics3DTest/Physics3DTest.js @@ -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 () { diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 5f054a9171..c82f213259 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -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], diff --git a/tools/tojs/cocos2dx_3d.ini b/tools/tojs/cocos2dx_3d.ini index 4245fd6d2d..c582da19a2 100644 --- a/tools/tojs/cocos2dx_3d.ini +++ b/tools/tojs/cocos2dx_3d.ini @@ -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 = diff --git a/tools/tojs/cocos2dx_physics3d.ini b/tools/tojs/cocos2dx_physics3d.ini index d8cb9123eb..da01ab360d 100644 --- a/tools/tojs/cocos2dx_physics3d.ini +++ b/tools/tojs/cocos2dx_physics3d.ini @@ -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 = From 1366f615dd93a2e438193edee1c397c12df5321b Mon Sep 17 00:00:00 2001 From: joshuastray Date: Fri, 22 May 2015 10:41:22 +0800 Subject: [PATCH 3/4] mac && ios works --- .../project.pbxproj | 4 +- .../js-bindings/manual/cocos2d_specifics.cpp | 90 +++++++++++++++++++ .../jsb_cocos2dx_physics3d_manual.cpp | 19 ++-- .../project.pbxproj | 36 +++++++- tools/tojs/cocos2dx.ini | 9 +- tools/tojs/cocos2dx_physics3d.ini | 2 +- 6 files changed, 141 insertions(+), 19 deletions(-) diff --git a/build/cocos2d_js_tests.xcodeproj/project.pbxproj b/build/cocos2d_js_tests.xcodeproj/project.pbxproj index f69655eb62..20ca66c14a 100644 --- a/build/cocos2d_js_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_js_tests.xcodeproj/project.pbxproj @@ -821,7 +821,7 @@ ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual"; }; name = Debug; }; @@ -845,7 +845,7 @@ HEADER_SEARCH_PATHS = ""; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/physics $(SRCROOT)/../cocos/math/kazmath $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/.. $(SRCROOT)/../cocos $(SRCROOT)/../cocos/base $(SRCROOT)/../cocos/2d $(SRCROOT)/../cocos/gui $(SRCROOT)/../cocos/network $(SRCROOT)/../cocos/audio/include $(SRCROOT)/../cocos/editor-support $(SRCROOT)/../extensions $(SRCROOT)/../external $(SRCROOT)/../external/chipmunk/include/chipmunk $(SRCROOT)/../cocos/scripting/js-bindings/auto $(SRCROOT)/../cocos/scripting/js-bindings/manual"; }; name = Release; }; diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 1c53e0e0f0..392d8bf0db 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -5339,6 +5339,89 @@ void get_or_create_js_obj(JSContext* cx, JS::HandleObject obj, const std::string } } +#if CC_ENABLE_BULLET_INTEGRATION && CC_USE_3D_PHYSICS + +#include "physics3d/CCPhysics3D.h" + +bool js_cocos2dx_Scene_setPhysics3DDebugCamera(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_setPhysics3DDebugCamera : Invalid Native Object"); + if (argc == 1) + { + cocos2d::Camera* arg0; + do + { + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Camera*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scene_setPhysics3DDebugCamera : Error processing arguments"); + cobj->setPhysics3DDebugCamera(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_setPhysics3DDebugCamera : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Scene_initWithPhysics(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_initWithPhysics : Invalid Native Object"); + if (argc == 0) + { + bool ret = cobj->initWithPhysics(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_initWithPhysics : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Scene_getPhysics3DWorld(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Scene* cobj = (cocos2d::Scene *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Scene_getPhysics3DWorld : Invalid Native Object"); + if (argc == 0) + { + cocos2d::Physics3DWorld* ret = cobj->getPhysics3DWorld(); + jsval jsret = JSVAL_NULL; + do + { + if (ret) + { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Physics3DWorld*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else + { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Scene_getPhysics3DWorld : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +#endif //CC_ENABLE_BULLET_INTEGRATION && CC_USE_3D_PHYSICS + void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) { JS::RootedObject ccObj(cx); @@ -5633,4 +5716,11 @@ void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) get_or_create_js_obj(cx, global, "console", &tmpObj); JS_DefineFunction(cx, tmpObj, "log", js_console_log, 1, JSPROP_READONLY | JSPROP_PERMANENT); + +#if CC_ENABLE_BULLET_INTEGRATION && CC_USE_3D_PHYSICS + tmpObj.set(jsb_cocos2d_Scene_prototype); + JS_DefineFunction(cx, tmpObj, "setPhysics3DDebugCamera", js_cocos2dx_Scene_setPhysics3DDebugCamera, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "initWithPhysics", js_cocos2dx_Scene_initWithPhysics, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "getPhysics3DWorld", js_cocos2dx_Scene_getPhysics3DWorld, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); +#endif //CC_ENABLE_BULLET_INTEGRATION && CC_USE_3D_PHYSICS } diff --git a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp index 26c56c3ff4..0936ffb8f6 100644 --- a/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp +++ b/cocos/scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp @@ -144,23 +144,24 @@ bool js_cocos2dx_physics3d_Physics3DRigidBody_create(JSContext *cx, uint32_t arg return false; } -bool jsval_to_std_vector_vec3(JSContext* cx, JS::HandleValue v, std::vector* ret) +std::vector jsval_to_std_vector_vec3(JSContext* cx, JS::HandleValue v) { + std::vector ret; JS::RootedObject jsobj(cx, v.toObjectOrNull()); uint32_t length; JS_GetArrayLength(cx, jsobj, &length); - ret->reserve(length); + ret.reserve(length); for(size_t i = 0; i < length; ++i) { JS::RootedValue element(cx); - JS_GetElement(cx, jsobj, i, &element); + JS_GetElement(cx, jsobj, (uint32_t)i, &element); - Vec3 v; - jsval_to_vector3(cx, element, &v); - ret->push_back(v); + Vec3 v3; + jsval_to_vector3(cx, element, &v3); + ret.push_back(v3); } - return true; + return ret; } bool js_cocos2dx_physics3d_Physics3dShape_createMesh(JSContext *cx, uint32_t argc, jsval *vp) @@ -169,10 +170,10 @@ bool js_cocos2dx_physics3d_Physics3dShape_createMesh(JSContext *cx, uint32_t arg { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::vector arg0; + std::vector arg0 = jsval_to_std_vector_vec3(cx, args.get(0)); int arg1; - bool ok = jsval_to_std_vector_vec3(cx, args.get(0), &arg0) & jsval_to_int(cx, args.get(1), &arg1); + bool ok = 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); diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj index 5286614ffe..ea6cb6d59a 100644 --- a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -146,6 +146,14 @@ 420BBCF81AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */; }; 420BBCF91AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */; }; 420BBCFA1AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */; }; + 42638FFD1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42638FFB1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp */; }; + 42638FFE1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42638FFB1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp */; }; + 42638FFF1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 42638FFC1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp */; }; + 426390001B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 42638FFC1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp */; }; + 426390041B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 426390021B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp */; }; + 426390051B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 426390021B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp */; }; + 426390061B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 426390031B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h */; }; + 426390071B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 426390031B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h */; }; 42AD256C1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42AD256A1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp */; }; 42AD256D1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42AD256A1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp */; }; 42AD256E1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 42AD256B1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp */; }; @@ -263,6 +271,10 @@ 420BBCEF1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_3d_auto.hpp; sourceTree = ""; }; 420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_3d_manual.cpp; sourceTree = ""; }; 420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_3d_manual.h; sourceTree = ""; }; + 42638FFB1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_physics3d_auto.cpp; sourceTree = ""; }; + 42638FFC1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_physics3d_auto.hpp; sourceTree = ""; }; + 426390021B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_physics3d_manual.cpp; sourceTree = ""; }; + 426390031B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_physics3d_manual.h; sourceTree = ""; }; 42AD256A1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_experimental.cpp; sourceTree = ""; }; 42AD256B1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_experimental.hpp; sourceTree = ""; }; 42AD25711AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_cocos2dx_experimental_manual.cpp; path = experimental/jsb_cocos2dx_experimental_manual.cpp; sourceTree = ""; }; @@ -334,6 +346,8 @@ 1A119E2E18BDF19200352BAA /* auto */ = { isa = PBXGroup; children = ( + 42638FFB1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp */, + 42638FFC1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp */, 42AD256A1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp */, 42AD256B1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp */, 420BBCEE1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp */, @@ -362,6 +376,7 @@ 1A119E4118BDF19200352BAA /* manual */ = { isa = PBXGroup; children = ( + 426390011B0EC1C6004C53A2 /* physics3d */, 42AD25701AFF9DFC000176E2 /* experimental */, 420BBCF41AA48EE900493976 /* 3d */, 0541A74C1973876100E45470 /* ios */, @@ -538,6 +553,15 @@ path = 3d; sourceTree = ""; }; + 426390011B0EC1C6004C53A2 /* physics3d */ = { + isa = PBXGroup; + children = ( + 426390021B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp */, + 426390031B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h */, + ); + path = physics3d; + sourceTree = ""; + }; 42AD25701AFF9DFC000176E2 /* experimental */ = { isa = PBXGroup; children = ( @@ -603,7 +627,9 @@ 1AB5E63518D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h in Headers */, 1A119EE318BDF19200352BAA /* jsb_opengl_functions.h in Headers */, 42AD256E1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp in Headers */, + 42638FFF1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp in Headers */, 0541A74F1973876100E45470 /* JavaScriptObjCBridge.h in Headers */, + 426390061B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h in Headers */, 1AB5E62D18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp in Headers */, 420BBCF91AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */, 1A119ED918BDF19200352BAA /* js_bindings_opengl.h in Headers */, @@ -626,6 +652,7 @@ files = ( 1A119EA418BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp in Headers */, 1A119F0218BDF19200352BAA /* ScriptingCore.h in Headers */, + 426390071B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h in Headers */, 1A119EBE18BDF19200352BAA /* cocos2d_specifics.hpp in Headers */, 83A5661C18DA878400FC31A0 /* jsb_socketio.h in Headers */, 1A1D3B7B18C44FD000922D3C /* jsb_event_dispatcher_manual.h in Headers */, @@ -660,6 +687,7 @@ 1AB5E62E18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp in Headers */, 1A119EDA18BDF19200352BAA /* js_bindings_opengl.h in Headers */, 1A119EC818BDF19200352BAA /* jsb_cocos2dx_studio_manual.h in Headers */, + 426390001B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp in Headers */, 420BBCFA1AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */, BA623E0C191A195F00761F37 /* jsb_pluginx_extension_registration.h in Headers */, 1A119EAC18BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h in Headers */, @@ -749,6 +777,7 @@ 1A119E8918BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */, 1A119EAD18BDF19200352BAA /* js_bindings_chipmunk_functions.cpp in Sources */, 1A119EED18BDF19200352BAA /* js_bindings_system_functions.cpp in Sources */, + 426390041B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp in Sources */, 0541A7501973876100E45470 /* JavaScriptObjCBridge.mm in Sources */, 1A119EB318BDF19200352BAA /* js_bindings_chipmunk_manual.cpp in Sources */, 1A119EE918BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */, @@ -779,6 +808,7 @@ 420BBCF01AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp in Sources */, 83A5661918DA878400FC31A0 /* jsb_socketio.cpp in Sources */, 1A119EE118BDF19200352BAA /* jsb_opengl_functions.cpp in Sources */, + 42638FFD1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp in Sources */, 1A119EA718BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp in Sources */, 1A119EFF18BDF19200352BAA /* ScriptingCore.cpp in Sources */, 1A1D3B7818C44FD000922D3C /* jsb_event_dispatcher_manual.cpp in Sources */, @@ -809,6 +839,8 @@ 1A119EF418BDF19200352BAA /* js_bindings_system_registration.cpp in Sources */, 42AD256D1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp in Sources */, 1A119EBC18BDF19200352BAA /* cocos2d_specifics.cpp in Sources */, + 426390051B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp in Sources */, + 42638FFE1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp in Sources */, 1A119EE618BDF19200352BAA /* jsb_opengl_manual.cpp in Sources */, 1A119F0618BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp in Sources */, BA623E0F191A195F00761F37 /* jsb_pluginx_manual_protocols.cpp in Sources */, @@ -873,7 +905,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SKIP_INSTALL = YES; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../../../cocos $(SRCROOT)/../../../../cocos/base $(SRCROOT)/../../../../cocos/2d $(SRCROOT)/../../../../cocos/physics $(SRCROOT)/../../../../cocos/math/kazmath $(SRCROOT)/../../../../cocos/platform $(SRCROOT)/../../../../cocos/audio/include $(SRCROOT)/../../../../cocos/editor-support $(SRCROOT)/../../../../cocos/editor-support/cocosbuilder $(SRCROOT)/../../../../cocos/editor-support/cocostudio $(SRCROOT)/../../../../cocos/editor-support/spine $(SRCROOT)/../../../../cocos/ui $(SRCROOT)/../../../../cocos/storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external $(SRCROOT)/../auto $(SRCROOT)/../manual"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../../../cocos $(SRCROOT)/../../../../cocos/base $(SRCROOT)/../../../../cocos/3d $(SRCROOT)/../../../../cocos/2d $(SRCROOT)/../../../../cocos/physics3d $(SRCROOT)/../../../../cocos/platform $(SRCROOT)/../../../../cocos/audio/include $(SRCROOT)/../../../../cocos/editor-support $(SRCROOT)/../../../../cocos/editor-support/cocosbuilder $(SRCROOT)/../../../../cocos/editor-support/cocostudio $(SRCROOT)/../../../../cocos/editor-support/spine $(SRCROOT)/../../../../cocos/ui $(SRCROOT)/../../../../cocos/storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external $(SRCROOT)/../auto $(SRCROOT)/../manual"; }; name = Debug; }; @@ -907,7 +939,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SKIP_INSTALL = YES; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../../../cocos $(SRCROOT)/../../../../cocos/base $(SRCROOT)/../../../../cocos/2d $(SRCROOT)/../../../../cocos/physics $(SRCROOT)/../../../../cocos/math/kazmath $(SRCROOT)/../../../../cocos/platform $(SRCROOT)/../../../../cocos/audio/include $(SRCROOT)/../../../../cocos/editor-support $(SRCROOT)/../../../../cocos/editor-support/cocosbuilder $(SRCROOT)/../../../../cocos/editor-support/cocostudio $(SRCROOT)/../../../../cocos/editor-support/spine $(SRCROOT)/../../../../cocos/ui $(SRCROOT)/../../../../cocos/storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external $(SRCROOT)/../auto $(SRCROOT)/../manual"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../.. $(SRCROOT)/../../../../cocos $(SRCROOT)/../../../../cocos/base $(SRCROOT)/../../../../cocos/3d $(SRCROOT)/../../../../cocos/2d $(SRCROOT)/../../../../cocos/physics3d $(SRCROOT)/../../../../cocos/platform $(SRCROOT)/../../../../cocos/audio/include $(SRCROOT)/../../../../cocos/editor-support $(SRCROOT)/../../../../cocos/editor-support/cocosbuilder $(SRCROOT)/../../../../cocos/editor-support/cocostudio $(SRCROOT)/../../../../cocos/editor-support/spine $(SRCROOT)/../../../../cocos/ui $(SRCROOT)/../../../../cocos/storage $(SRCROOT)/../../../../extensions $(SRCROOT)/../../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../../external $(SRCROOT)/../auto $(SRCROOT)/../manual"; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index c82f213259..5f054a9171 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -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__ -D CC_USE_3D_PHYSICS -D CC_ENABLE_BULLET_INTEGRATION +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ 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 %(cocosdir)s/cocos/physics3d/CCPhysics3D.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 # 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 createWithPhysics getPhysicsWorld], + Scene::[getCameras getLights initWithPhysics createWithPhysics getPhysicsWorld getPhysics3DWorld setPhysics3DDebugCamera], Animate3D::[*], Sprite3D::[*], AttachNode::[*], @@ -137,8 +137,7 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat Camera::[unproject isVisibleInFrustum], ClippingNode::[init], SpritePolygonCache::[addSpritePolygonCache getSpritePolygonCache], - RenderState::[setStateBlock], - btActionInterface::[*] + RenderState::[setStateBlock] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], diff --git a/tools/tojs/cocos2dx_physics3d.ini b/tools/tojs/cocos2dx_physics3d.ini index da01ab360d..de99c51c80 100644 --- a/tools/tojs/cocos2dx_physics3d.ini +++ b/tools/tojs/cocos2dx_physics3d.ini @@ -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 -D CC_ENABLE_BULLET_INTEGRATION -D CC_USE_3D_PHYSICS -U __SSE__ +clang_flags = -nostdinc -x c++ -std=c++11 -D CC_ENABLE_BULLET_INTEGRATION -D CC_USE_3D_PHYSICS cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external From b1169c7d569ce74d9c32eb10e1a9f5900585b4df Mon Sep 17 00:00:00 2001 From: joshuastray Date: Fri, 22 May 2015 11:56:24 +0800 Subject: [PATCH 4/4] win32 and universal compile --- .../proj.win32/libjscocos2d.vcxproj | 6 +++-- .../proj.win32/libjscocos2d.vcxproj.filters | 9 +++++++ .../libjscocos2d.Shared.vcxitems | 4 ++++ .../libjscocos2d.Shared.vcxitems.filters | 15 ++++++++++++ .../libjscocos2d.Windows.vcxproj | 24 +++++++++---------- .../libjscocos2d.WindowsPhone.vcxproj | 16 ++++++------- tools/bindings-generator | 2 +- tools/tojs/cocos2dx_physics3d.ini | 2 ++ 8 files changed, 55 insertions(+), 23 deletions(-) diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj index a5058fe632..4eb40ed7af 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj @@ -44,6 +44,7 @@ + @@ -88,6 +89,7 @@ + @@ -153,7 +155,7 @@ Level3 Disabled WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true false @@ -179,7 +181,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" true true WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true None diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters index fb4810374b..c4e49936c6 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters @@ -39,6 +39,9 @@ {9f37ec66-1e00-4015-baa6-dabdf755f0ff} + + {3aaaf02d-80d8-4339-b4cd-89d89ade5293} + @@ -149,6 +152,9 @@ auto + + manual\physics3d + @@ -280,5 +286,8 @@ auto + + manual\physics3d + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems index 62ccfa022d..409eb85c05 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems @@ -20,6 +20,7 @@ + @@ -52,6 +53,7 @@ + @@ -65,6 +67,7 @@ + @@ -91,6 +94,7 @@ + diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters index e83c0ca52b..6824d69c63 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters @@ -128,6 +128,12 @@ manual\experimental + + auto + + + manual\physics3d + @@ -235,6 +241,12 @@ manual\experimental + + auto + + + manual\physics3d + @@ -276,6 +288,9 @@ {ddd3651e-c6e7-4dea-80c1-a0a3dc51a740} + + {511b128d-2604-48af-88e1-8cc0eba79e19} + diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj index bd38032fea..f740fc7a57 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj @@ -126,10 +126,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true @@ -146,10 +146,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions) false OldStyle @@ -168,10 +168,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true @@ -188,10 +188,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions) false OldStyle @@ -210,10 +210,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true @@ -230,10 +230,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions) false OldStyle diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj index 7db401debd..0d4d3dc118 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj @@ -91,10 +91,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true @@ -111,10 +111,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions) false OldStyle @@ -133,10 +133,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true @@ -153,10 +153,10 @@ NotUsing true false - $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;CC_ENABLE_BULLET_INTEGRATION=1;%(PreprocessorDefinitions) false OldStyle diff --git a/tools/bindings-generator b/tools/bindings-generator index 5a75fd5df1..0b64fbf99e 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 5a75fd5df1fbafc81093700deb67fce8cd4861c1 +Subproject commit 0b64fbf99ef824bc33a56fe584ec78aedbdb464f diff --git a/tools/tojs/cocos2dx_physics3d.ini b/tools/tojs/cocos2dx_physics3d.ini index de99c51c80..893c8a69d1 100644 --- a/tools/tojs/cocos2dx_physics3d.ini +++ b/tools/tojs/cocos2dx_physics3d.ini @@ -13,6 +13,8 @@ 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 -D CC_USE_3D_PHYSICS +win32_clang_flags = -U __SSE__ + cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external cocos_flags = -DANDROID