add physics3d auto binding

This commit is contained in:
joshuastray 2015-05-20 10:35:33 +08:00
parent 5d90a8725e
commit 712ba4f64c
8 changed files with 237 additions and 4 deletions

View File

@ -17,6 +17,7 @@
<ClCompile Include="..\auto\jsb_cocos2dx_builder_auto.cpp" />
<ClCompile Include="..\auto\jsb_cocos2dx_experimental.cpp" />
<ClCompile Include="..\auto\jsb_cocos2dx_extension_auto.cpp" />
<ClCompile Include="..\auto\jsb_cocos2dx_physics3d_auto.cpp" />
<ClCompile Include="..\auto\jsb_cocos2dx_spine_auto.cpp" />
<ClCompile Include="..\auto\jsb_cocos2dx_studio_auto.cpp" />
<ClCompile Include="..\auto\jsb_cocos2dx_ui_auto.cpp" />
@ -54,6 +55,7 @@
<ClInclude Include="..\auto\jsb_cocos2dx_builder_auto.hpp" />
<ClInclude Include="..\auto\jsb_cocos2dx_experimental.hpp" />
<ClInclude Include="..\auto\jsb_cocos2dx_extension_auto.hpp" />
<ClInclude Include="..\auto\jsb_cocos2dx_physics3d_auto.hpp" />
<ClInclude Include="..\auto\jsb_cocos2dx_spine_auto.hpp" />
<ClInclude Include="..\auto\jsb_cocos2dx_studio_auto.hpp" />
<ClInclude Include="..\auto\jsb_cocos2dx_ui_auto.hpp" />
@ -151,7 +153,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<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)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
@ -177,7 +179,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*"
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<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)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>None</DebugInformationFormat>

View File

@ -146,6 +146,9 @@
<ClCompile Include="..\manual\experimental\jsb_cocos2dx_experimental_manual.cpp">
<Filter>manual\experimental</Filter>
</ClCompile>
<ClCompile Include="..\auto\jsb_cocos2dx_physics3d_auto.cpp">
<Filter>auto</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\auto\jsb_cocos2dx_auto.hpp">
@ -274,5 +277,8 @@
<ClInclude Include="..\manual\experimental\jsb_cocos2dx_experimental_manual.h">
<Filter>manual\experimental</Filter>
</ClInclude>
<ClInclude Include="..\auto\jsb_cocos2dx_physics3d_auto.hpp">
<Filter>auto</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -188,6 +188,7 @@
"src/SpritePolygonTest/SpritePolygonTest.js",
"src/MaterialSystemTest/MaterialSystemTest.js",
"src/TerrainTest/TerrainTest.js"
"src/TerrainTest/TerrainTest.js",
"src/Physics3DTest/Physics3DTest.js"
]
}

View File

@ -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);

View File

@ -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 ]();
};

View File

@ -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,

View File

@ -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

View File

@ -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