Some 3d classes can't be constructed with new in JS
This commit is contained in:
pandamicro 2015-07-28 18:31:04 +08:00
commit 8e883f9956
20 changed files with 328 additions and 72 deletions

View File

@ -177,8 +177,6 @@ public:
CC_CONSTRUCTOR_ACCESS:
Physics3DPointToPointConstraint();
virtual ~Physics3DPointToPointConstraint();
protected:
bool init(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA);
bool init(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB);

View File

@ -69,6 +69,7 @@ set(JSBINDING_SRC
manual/spine/jsb_cocos2dx_spine_manual.cpp
manual/ui/jsb_cocos2dx_ui_manual.cpp
manual/3d/jsb_cocos2dx_3d_manual.cpp
manual/3d/jsb_cocos2dx_3d_conversions.cpp
manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp
manual/navmesh/jsb_cocos2dx_navmesh_conversions.cpp
manual/navmesh/jsb_cocos2dx_navmesh_manual.cpp

View File

@ -0,0 +1,76 @@
/*
* Created by Huabin LING on 17/6/15.
* Copyright (c) 2015 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.
*/
#include "base/ccConfig.h"
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
#include "jsapi.h"
#include "jsb_cocos2dx_3d_conversions.h"
#include "js_manual_conversions.h"
#include "CCPhysics3DShape.h"
bool jsval_to_Physics3DRigidBodyDes(JSContext *cx, JS::HandleValue v, cocos2d::Physics3DRigidBodyDes** bodyDes)
{
JS::RootedObject tmp(cx);
JS::RootedValue massValue(cx);
JS::RootedValue localInertiaValue(cx);
JS::RootedValue shapeValue(cx);
JS::RootedValue originalTransformValue(cx);
JS::RootedValue disableSleepValue(cx);
double mass;
cocos2d::Vec3 localInertia;
cocos2d::Physics3DShape* shape = nullptr;
cocos2d::Mat4 originalTransform;
bool disableSleep;
bool ok = v.isObject() &&
JS_ValueToObject(cx, v, &tmp) &&
JS_GetProperty(cx, tmp, "mass", &massValue) &&
JS_GetProperty(cx, tmp, "localInertia", &localInertiaValue) &&
JS_GetProperty(cx, tmp, "shape", &shapeValue) &&
JS_GetProperty(cx, tmp, "originalTransform", &originalTransformValue) &&
JS_GetProperty(cx, tmp, "disableSleep", &disableSleepValue) &&
JS::ToNumber(cx, massValue, &mass) &&
jsval_to_vector3(cx, localInertiaValue, &localInertia) &&
jsval_to_matrix(cx, originalTransformValue, &originalTransform);
js_proxy_t *jsProxy = jsb_get_js_proxy(shapeValue.toObjectOrNull());
shape = (cocos2d::Physics3DShape*)(jsProxy ? jsProxy->ptr : nullptr);
disableSleep = JS::ToBoolean(disableSleepValue);
JSB_PRECONDITION3(ok, cx, false, "Error processing arguments");
cocos2d::Physics3DRigidBodyDes *bodyDesPtr = new cocos2d::Physics3DRigidBodyDes();
*bodyDes = bodyDesPtr;
(*bodyDes)->mass = mass;
(*bodyDes)->localInertia = localInertia;
(*bodyDes)->shape = shape;
(*bodyDes)->originalTransform = originalTransform;
(*bodyDes)->disableSleep = disableSleep;
return true;
}
#endif // CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION

View File

@ -0,0 +1,35 @@
/*
* Created by Huabin LING on 17/6/15.
* Copyright (c) 2015 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.
*/
#include "base/ccConfig.h"
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
#ifndef __cocos2d_js_bindings__jsb_cocos2dx_3d_conversions__
#define __cocos2d_js_bindings__jsb_cocos2dx_3d_conversions__
#include "jsapi.h"
#include "CCPhysics3DObject.h"
bool jsval_to_Physics3DRigidBodyDes(JSContext *cx, JS::HandleValue v, cocos2d::Physics3DRigidBodyDes** bodyDes);
#endif /* defined(__cocos2d_js_bindings__jsb_cocos2dx_3d_conversions__) */
#endif //#if CC_USE_3d

View File

@ -57,6 +57,7 @@ LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_3d_auto.cpp \
../manual/jsb_opengl_registration.cpp \
../manual/jsb_event_dispatcher_manual.cpp \
../manual/3d/jsb_cocos2dx_3d_manual.cpp \
../manual/3d/jsb_cocos2dx_3d_conversions.cpp \
../manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp \
../manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp \
../manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp \

View File

@ -12,6 +12,10 @@
0541A75B19738AD200E45470 /* JavaScriptObjCBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0541A74E1973876100E45470 /* JavaScriptObjCBridge.mm */; };
185664961B4253C7009EF2AE /* libjs_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A119F0D18BDF1FF00352BAA /* libjs_static.a */; };
185664971B4253CB009EF2AE /* libjs_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A119F0F18BDF20900352BAA /* libjs_static.a */; };
1866A6E31B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1866A6E11B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.cpp */; };
1866A6E41B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1866A6E11B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.cpp */; };
1866A6E51B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1866A6E21B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.h */; };
1866A6E61B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1866A6E21B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.h */; };
1A119E8318BDF19200352BAA /* jsb_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E2F18BDF19200352BAA /* jsb_cocos2dx_auto.cpp */; };
1A119E8418BDF19200352BAA /* jsb_cocos2dx_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A119E2F18BDF19200352BAA /* jsb_cocos2dx_auto.cpp */; };
1A119E8518BDF19200352BAA /* jsb_cocos2dx_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A119E3018BDF19200352BAA /* jsb_cocos2dx_auto.hpp */; };
@ -193,6 +197,8 @@
/* Begin PBXFileReference section */
0541A74D1973876100E45470 /* JavaScriptObjCBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JavaScriptObjCBridge.h; sourceTree = "<group>"; };
0541A74E1973876100E45470 /* JavaScriptObjCBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JavaScriptObjCBridge.mm; sourceTree = "<group>"; };
1866A6E11B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_3d_conversions.cpp; sourceTree = "<group>"; };
1866A6E21B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_3d_conversions.h; sourceTree = "<group>"; };
1A119E2F18BDF19200352BAA /* jsb_cocos2dx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_auto.cpp; sourceTree = "<group>"; };
1A119E3018BDF19200352BAA /* jsb_cocos2dx_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_auto.hpp; sourceTree = "<group>"; };
1A119E3218BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_builder_auto.cpp; sourceTree = "<group>"; };
@ -544,6 +550,8 @@
420BBCF41AA48EE900493976 /* 3d */ = {
isa = PBXGroup;
children = (
1866A6E11B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.cpp */,
1866A6E21B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.h */,
420BBCF51AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp */,
420BBCF61AA48EE900493976 /* jsb_cocos2dx_3d_manual.h */,
);
@ -592,6 +600,7 @@
1A119F0118BDF19200352BAA /* ScriptingCore.h in Headers */,
1A119EBD18BDF19200352BAA /* cocos2d_specifics.hpp in Headers */,
83A5661B18DA878400FC31A0 /* jsb_socketio.h in Headers */,
1866A6E51B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.h in Headers */,
1A1D3B7A18C44FD000922D3C /* jsb_event_dispatcher_manual.h in Headers */,
1A119EF518BDF19200352BAA /* js_bindings_system_registration.h in Headers */,
BAFA59051B319F38004F9246 /* jsb_cocos2dx_navmesh_manual.h in Headers */,
@ -688,6 +697,7 @@
4BE089EC1ADF967400D65D4B /* jsb_cocos2dx_experimental_webView_manual.h in Headers */,
BAFA58FE1B319F05004F9246 /* jsb_cocos2dx_navmesh_auto.hpp in Headers */,
1A119EB218BDF19200352BAA /* js_bindings_chipmunk_functions_registration.h in Headers */,
1866A6E61B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.h in Headers */,
1A119EF218BDF19200352BAA /* js_bindings_system_functions_registration.h in Headers */,
1A119E8618BDF19200352BAA /* jsb_cocos2dx_auto.hpp in Headers */,
1A119F0818BDF19200352BAA /* jsb_cocos2dx_spine_manual.h in Headers */,
@ -765,6 +775,7 @@
buildActionMask = 2147483647;
files = (
1A119E8918BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */,
1866A6E31B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.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 */,
@ -851,6 +862,7 @@
BA4095C31A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp in Sources */,
BAFA590A1B319F7E004F9246 /* jsb_cocos2dx_navmesh_conversions.cpp in Sources */,
1A119F0018BDF19200352BAA /* ScriptingCore.cpp in Sources */,
1866A6E41B67202C00E31E2F /* jsb_cocos2dx_3d_conversions.cpp in Sources */,
B38AD56A1B1D384A0057DD7F /* jsb_cocos2dx_experimental_video_manual.cpp in Sources */,
1A1D3B7918C44FD000922D3C /* jsb_event_dispatcher_manual.cpp in Sources */,
);

View File

@ -21,6 +21,7 @@
<ClCompile Include="..\auto\jsb_cocos2dx_spine_auto.cpp" />
<ClCompile Include="..\auto\jsb_cocos2dx_studio_auto.cpp" />
<ClCompile Include="..\auto\jsb_cocos2dx_ui_auto.cpp" />
<ClCompile Include="..\manual\3d\jsb_cocos2dx_3d_conversions.cpp" />
<ClCompile Include="..\manual\3d\jsb_cocos2dx_3d_manual.cpp" />
<ClCompile Include="..\manual\chipmunk\js_bindings_chipmunk_auto_classes.cpp" />
<ClCompile Include="..\manual\chipmunk\js_bindings_chipmunk_functions.cpp" />
@ -61,6 +62,7 @@
<ClInclude Include="..\auto\jsb_cocos2dx_spine_auto.hpp" />
<ClInclude Include="..\auto\jsb_cocos2dx_studio_auto.hpp" />
<ClInclude Include="..\auto\jsb_cocos2dx_ui_auto.hpp" />
<ClInclude Include="..\manual\3d\jsb_cocos2dx_3d_conversions.h" />
<ClInclude Include="..\manual\3d\jsb_cocos2dx_3d_manual.h" />
<ClInclude Include="..\manual\chipmunk\js_bindings_chipmunk_auto_classes.h" />
<ClInclude Include="..\manual\chipmunk\js_bindings_chipmunk_auto_classes_registration.h" />
@ -204,4 +206,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*"
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -161,6 +161,9 @@
<ClCompile Include="..\manual\navmesh\jsb_cocos2dx_navmesh_conversions.cpp">
<Filter>manual\navmesh</Filter>
</ClCompile>
<ClCompile Include="..\manual\3d\jsb_cocos2dx_3d_conversions.cpp">
<Filter>manual\3d</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\auto\jsb_cocos2dx_auto.hpp">
@ -298,5 +301,8 @@
<ClInclude Include="..\manual\navmesh\jsb_cocos2dx_navmesh_conversions.h">
<Filter>manual\navmesh</Filter>
</ClInclude>
<ClInclude Include="..\manual\3d\jsb_cocos2dx_3d_conversions.h">
<Filter>manual\3d</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -24,6 +24,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_spine_auto.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_studio_auto.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_ui_auto.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_conversions.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_manual.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\chipmunk\js_bindings_chipmunk_auto_classes.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\chipmunk\js_bindings_chipmunk_auto_classes_registration.h" />
@ -72,6 +73,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_spine_auto.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_studio_auto.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_ui_auto.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_conversions.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_manual.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\chipmunk\js_bindings_chipmunk_auto_classes.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\chipmunk\js_bindings_chipmunk_functions.cpp" />

View File

@ -59,9 +59,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\spidermonkey_specifics.h">
<Filter>manual</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_manual.h">
<Filter>manual</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\chipmunk\js_bindings_chipmunk_auto_classes.h">
<Filter>manual\chipmunk</Filter>
</ClInclude>
@ -137,6 +134,12 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_navmesh_auto.hpp">
<Filter>auto</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_manual.h">
<Filter>manual\3d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_conversions.h">
<Filter>manual\3d</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_3d_auto.cpp">
@ -187,9 +190,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\ScriptingCore.cpp">
<Filter>manual</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_manual.cpp">
<Filter>manual</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\chipmunk\js_bindings_chipmunk_auto_classes.cpp">
<Filter>manual\chipmunk</Filter>
</ClCompile>
@ -253,6 +253,12 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\auto\jsb_cocos2dx_navmesh_auto.cpp">
<Filter>auto</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_manual.cpp">
<Filter>manual\3d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\manual\3d\jsb_cocos2dx_3d_conversions.cpp">
<Filter>manual\3d</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="auto">

View File

@ -279,3 +279,118 @@ jsb.BillBoard.prototype._ctor = function(filename, rect, mode = jsb.BillBoard.Mo
this.setMode(filename);
}
}
jsb._Animation3D = jsb.Animation3D;
jsb.Animation3D = function(fileName, animationName = ""){
if (!(this instanceof jsb.Animation3D))
throw new Error("Constructor can not called as a function, Please use new");
return jsb._Animation3D.create(fileName, animationName);
}
jsb.Animation3D.create = function(fileName, animationName = ""){
return jsb._Animation3D.create(fileName, animationName);
}
/* static Animate3D* create(Animation3D* animation);
static Animate3D* create(Animation3D* animation, float fromTime, float duration);
static Animate3D* createWithFrames(Animation3D* animation, int startFrame, int endFrame, float frameRate = 30.f);
*/
jsb.Animate3D.prototype._ctor = function(first, second, third, fourth){
if (arguments.length === 1) {
this.init(first);
}
else if (arguments.length === 3){
this.init(first, second, third);
}
else if (arguments.length === 4) {
this.init(first, second, third, fourth);
}
else
{
throw new Error("jsb.Animate3D constructor: arguments error");
}
}
jsb.Skybox.prototype._ctor = function(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z){
if (arguments.length === 0 ) {
this.init();
}
else if (arguments.length === 6 ) {
this.init(positive_x, negative_x, positive_y, negative_y, positive_z, negative_z);
}
else
{
throw new Error("jsb.Skybox constructor: arguments error");
}
}
jsb.DirectionLight.prototype._ctor = function(direction, color){
if (arguments.length === 2 ) {
this.setDirection(direction);
this.setColor(color);
}
else
{
throw new Error("jsb.DirectionLight constructor: arguments error");
}
}
jsb.AmbientLight.prototype._ctor = function(color){
if (arguments.length === 1 ) {
this.setColor(color);
}
else {
throw new Error("jsb.AmbientLight constructor: arguments error");
}
}
jsb.Physics3DComponent.prototype._ctor = function(physicsObj, translateInPhysics = cc.math.vec3(), rotInPhsyics = new cc.math.Quaternion()){
if (arguments.length > 3 || arguments.length < 1) {
throw new Error("jsb.Physics3DComponent constructor: arguments error");
}
else
{
this.init();
this.setPhysics3DObject(physicsObj);
this.setTransformInPhysics(translateInPhysics, rotInPhsyics);
}
}
/*
static Physics3DPointToPointConstraint* create(Physics3DRigidBody* rbA, const cocos2d::Vec3& pivotPointInA);
static Physics3DPointToPointConstraint* create(Physics3DRigidBody* rbA, Physics3DRigidBody* rbB, const cocos2d::Vec3& pivotPointInA, const cocos2d::Vec3& pivotPointInB);
*/
jsb.Physics3DPointToPointConstraint.prototype._ctor = function(first, second, third, fourth){
if (arguments.length === 2 ) {
this.init(first, second);
}
else if (arguments.length === 4 ) {
this.init(first, second, third, fourth);
}
else
{
throw new Error("jsb.Physics3DPointToPointConstraint constructor: arguments error");
}
}
jsb.Physics3DRigidBody.prototype._ctor = function(rigidBodyInfo){
if (arguments.length === 1 ) {
this.init(rigidBodyInfo);
}
else {
throw new Error("jsb.Physics3DRigidBody constructor: arguments error");
}
}
jsb.Physics3DWorld.prototype._ctor = function(worldDesInfo){
if (arguments.length === 1 ) {
this.init(worldDesInfo);
}
else {
throw new Error("jsb.Physics3DWorld constructor: arguments error");
}
}

View File

@ -372,9 +372,9 @@ var Camera3DTest = (function(){
sprite.setPosition3D(postion);
sprite.setGlobalZOrder(globalZOrder);
if(playAnimation){
var animation = jsb.Animation3D.create(file, "Take 001");
var animation = new jsb.Animation3D(file, "Take 001");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}
}

View File

@ -182,9 +182,9 @@ var LightTest = LightTestDemo.extend({
orc.setScale(2.0);
var axe = new jsb.Sprite3D("Sprite3DTest/axe.c3b");
orc.getAttachNode("Bip001 R Hand").addChild(axe);
var animation = jsb.Animation3D.create("Sprite3DTest/orc.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/orc.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
orc.runAction(cc.repeatForever(animate));
}
this.addChild(orc);
@ -209,12 +209,12 @@ var LightTest = LightTestDemo.extend({
},
addLights:function(){
this._ambientLight = jsb.AmbientLight.create(cc.color(200, 200, 200));
this._ambientLight = new jsb.AmbientLight(cc.color(200, 200, 200));
this._ambientLight.setEnabled(true);
this.addChild(this._ambientLight);
this._ambientLight.setCameraMask(2);
this._directionalLight = jsb.DirectionLight.create(cc.math.vec3(-1, -1, 0), cc.color(200, 200, 200));
this._directionalLight = new jsb.DirectionLight(cc.math.vec3(-1, -1, 0), cc.color(200, 200, 200));
this._directionalLight.setEnabled(false);
this.addChild(this._directionalLight);
this._directionalLight.setCameraMask(2);

View File

@ -169,10 +169,10 @@ var Material_setTechnique = MaterialSystemTestDemo.extend({
sprite.setMaterial(mat);
//lights
var light1 = jsb.AmbientLight.create(cc.color.RED);
var light1 = new jsb.AmbientLight(cc.color.RED);
this.addChild(light1);
var light2 = jsb.DirectionLight.create(cc.math.vec3(-1, 1, 0), cc.color.GREEN);
var light2 = new jsb.DirectionLight(cc.math.vec3(-1, 1, 0), cc.color.GREEN);
this.addChild(light2);
sprite.runAction(cc.rotateBy(5, cc.math.vec3(30, 60, 270)).repeatForever());

View File

@ -76,8 +76,8 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
var rbDes = jsb.physics3DRigidBodyDes();
rbDes.mass = 0;
rbDes.shape = jsb.Physics3DShape.createMesh(trianglesList, trianglesList.length/3);
var rigidBody = jsb.Physics3DRigidBody.create(rbDes);
var component = jsb.Physics3DComponent.create(rigidBody);
var rigidBody = new jsb.Physics3DRigidBody(rbDes);
var component = new jsb.Physics3DComponent(rigidBody);
var sprite = jsb.Sprite3D.create("NavMesh/scene.obj");
sprite.addComponent(component);
sprite.setCameraMask(cc.CameraFlag.USER1);
@ -90,11 +90,11 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
physicsScene.setNavMesh(navMesh);
physicsScene.setNavMeshDebugCamera(this._camera);
var ambientLight = jsb.AmbientLight.create(cc.color(64, 64, 64));
var ambientLight = new jsb.AmbientLight(cc.color(64, 64, 64));
ambientLight.setCameraMask(cc.CameraFlag.USER1);
this.addChild(ambientLight);
var dirLight = jsb.DirectionLight.create(cc.math.vec3(1.2, -1.1, 0.5), cc.color(255, 255, 255));
var dirLight = new jsb.DirectionLight(cc.math.vec3(1.2, -1.1, 0.5), cc.color(255, 255, 255));
dirLight.setCameraMask(cc.CameraFlag.USER1);
this.addChild(dirLight);
},
@ -157,8 +157,8 @@ var NavMeshBaseTestDemo = NavMeshTestScene.extend({
node.setCameraMask(cc.CameraFlag.USER1);
physicsScene.addChild(node);
var animation = jsb.Animation3D.create(filePath);
var animate = jsb.Animate3D.create(animation);
var animation = new jsb.Animation3D(filePath);
var animate = new jsb.Animate3D(animation);
if (animate){
agentNode.runAction(new cc.RepeatForever(animate));

View File

@ -377,9 +377,9 @@ var Particle3DWithSprite3DDemo = Particle3DTestDemo.extend({
sprite.setPosition3D(cc.math.vec3(-20, 0, 0));
sprite.setRotation3D(cc.math.vec3(0, 180, 0));
sprite.setCameraMask(2);
var animation = jsb.Animation3D.create(c3bfileName);
var animation = new jsb.Animation3D(c3bfileName);
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}

View File

@ -302,9 +302,9 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
rbDes.mass = 10;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(5, 5, 5));
var rigidBody = jsb.Physics3DRigidBody.create(rbDes);
var rigidBody = new jsb.Physics3DRigidBody(rbDes);
var quat = cc.math.quaternion(cc.math.vec3(0, 1, 0), cc.degreesToRadians(180));
var component = jsb.Physics3DComponent.create(rigidBody, cc.math.vec3(0, -3, 0), quat);
var component = new jsb.Physics3DComponent(rigidBody, cc.math.vec3(0, -3, 0), quat);
var sprite = new jsb.Sprite3D("Sprite3DTest/orc.c3b");
sprite.addComponent(component);
@ -319,14 +319,14 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
this._world = physicsScene.getPhysics3DWorld();
//create point to point constraint
var constraint = jsb.Physics3DPointToPointConstraint.create(rigidBody, cc.math.vec3(2.5, 2.5, 2.5));
var constraint = new jsb.Physics3DPointToPointConstraint(rigidBody, cc.math.vec3(2.5, 2.5, 2.5));
this._world.addPhysics3DConstraint(constraint);
//create hinge constraint
rbDes.mass = 1;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(8, 8, 1));
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
rigidBody = new jsb.Physics3DRigidBody(rbDes);
component = new jsb.Physics3DComponent(rigidBody);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScaleX(8);
@ -343,8 +343,8 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
//create slider constraint
rbDes.mass = 1;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(3, 2, 3));
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
rigidBody = new jsb.Physics3DRigidBody(rbDes);
component = new jsb.Physics3DComponent(rigidBody);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScaleX(3);
@ -358,8 +358,8 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
rbDes.mass = 0;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
var rigidBodyB = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBodyB);
var rigidBodyB = new jsb.Physics3DRigidBody(rbDes);
component = new jsb.Physics3DComponent(rigidBodyB);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScale(3);
@ -379,8 +379,8 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
//create ConeTwist constraint
rbDes.mass = 1;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
rigidBody = new jsb.Physics3DRigidBody(rbDes);
component = new jsb.Physics3DComponent(rigidBody);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScale(3);
@ -398,8 +398,8 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
//create 6 dof constraint
rbDes.mass = 1;
rbDes.shape = jsb.Physics3DShape.createBox(cc.math.vec3(3, 3, 3));
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
rigidBody = new jsb.Physics3DRigidBody(rbDes);
component = new jsb.Physics3DComponent(rigidBody);
sprite = new jsb.Sprite3D("Sprite3DTest/box.c3t");
sprite.setTexture("Sprite3DTest/plane.png");
sprite.setScale(3);
@ -437,7 +437,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({
var mat = cc.math.mat4GetInversed(result.hitObj.getWorldTransform());
var position = cc.math.mat4TransformPoint(mat, result.hitPosition);
this._constraint = jsb.Physics3DPointToPointConstraint.create(result.hitObj, position);
this._constraint = new jsb.Physics3DPointToPointConstraint(result.hitObj, position);
this._world.addPhysics3DConstraint(this._constraint, true);
this._pickingDistance = cc.math.vec3Length(cc.math.vec3Sub(result.hitPosition, nearP));
return;
@ -570,8 +570,8 @@ var Physics3DCollisionCallbackDemo = Physics3DTestDemo.extend({
rbDes.mass = 0;
rbDes.shape = jsb.Physics3DShape.createMesh(trianglesList, trianglesList.length/3);
var rigidBody = jsb.Physics3DRigidBody.create(rbDes);
var component = jsb.Physics3DComponent.create(rigidBody);
var rigidBody = new jsb.Physics3DRigidBody(rbDes);
var component = new jsb.Physics3DComponent(rigidBody);
var sprite = new jsb.Sprite3D("Sprite3DTest/boss.c3b");
sprite.addComponent(component);
sprite.setRotation3D(cc.math.vec3(-90, 0, 0));
@ -633,8 +633,8 @@ var Physics3DTerrainDemo = Physics3DTestDemo.extend({
var heightData = terrain.getHeightData();
var size = terrain.getTerrainSize();
rbDes.shape = jsb.Physics3DShape.createHeightfield(size.width, size.height, heightData, 1.0, terrain.getMinHeight(), terrain.getMaxHeight(), true, false, true);
var rigidBody = jsb.Physics3DRigidBody.create(rbDes);
var component = jsb.Physics3DComponent.create(rigidBody);
var rigidBody = new jsb.Physics3DRigidBody(rbDes);
var component = new jsb.Physics3DComponent(rigidBody);
terrain.addComponent(component);
component.syncNodeToPhysics();
component.setSyncFlag(jsb.Physics3DComponent.PhysicsSyncFlag.NONE);
@ -671,8 +671,8 @@ var Physics3DTerrainDemo = Physics3DTestDemo.extend({
var trianglesList = jsb.Bundle3D.getTrianglesList("Sprite3DTest/boss.c3b");
rbDes.mass = 0;
rbDes.shape = jsb.Physics3DShape.createMesh(trianglesList, trianglesList.length/3);
rigidBody = jsb.Physics3DRigidBody.create(rbDes);
component = jsb.Physics3DComponent.create(rigidBody);
rigidBody = new jsb.Physics3DRigidBody(rbDes);
component = new jsb.Physics3DComponent(rigidBody);
var sprite = new jsb.Sprite3D("Sprite3DTest/boss.c3b");
sprite.addComponent(component);
sprite.setRotation3D(cc.math.vec3(-90, 0, 0));

View File

@ -306,9 +306,9 @@ var Sprite3DWithSkinTest = Sprite3DTestDemo.extend({
this.addChild(sprite);
sprite.setPosition(position);
var animation = jsb.Animation3D.create("Sprite3DTest/orc.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/orc.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
var inverse = Math.random() < 0.33 ? true : false;
var rand2 = Math.random();
@ -371,14 +371,14 @@ var Animate3DTest = (function(){
this.addChild(sprite);
this._sprite = sprite;
var animation = jsb.Animation3D.create("Sprite3DTest/tortoise.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/tortoise.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation, 0, 1.933);
var animate = new jsb.Animate3D(animation, 0, 1.933);
this._swim = new cc.RepeatForever(animate);
sprite.runAction(this._swim);
this._swim.retain();
this._hurt = jsb.Animate3D.create(animation, 1.933, 2.8);
this._hurt = new jsb.Animate3D(animation, 1.933, 2.8);
this._hurt.retain();
this._state = State.SWIMMING;
@ -484,9 +484,9 @@ var AttachmentTest = Sprite3DTestDemo.extend({
var sp = new jsb.Sprite3D("Sprite3DTest/axe.c3b");
sprite.getAttachNode("Bip001 R Hand").addChild(sp);
var animation = jsb.Animation3D.create("Sprite3DTest/orc.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/orc.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}
@ -566,9 +566,9 @@ var Sprite3DReskinTest = (function(){
sprite.setRotation3D(cc.math.vec3(0, 0, 0));
this.addChild(sprite);
sprite.setPosition(cc.p(position.x, position.y - 60));
var animation = jsb.Animation3D.create("Sprite3DTest/ReskinGirl.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/ReskinGirl.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}
this._sprite = sprite;
@ -700,9 +700,9 @@ var Sprite3DWithOBBPerformanceTest = Sprite3DTestDemo.extend({
this.addChild(sprite);
this._sprite = sprite;
var animation = jsb.Animation3D.create("Sprite3DTest/tortoise.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/tortoise.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}
@ -810,9 +810,9 @@ var Sprite3DMirrorTest = Sprite3DTestDemo.extend({
var sp = new jsb.Sprite3D("Sprite3DTest/axe.c3b");
sprite.getAttachNode("Bip001 R Hand").addChild(sp);
var animation = jsb.Animation3D.create(fileName);
var animation = new jsb.Animation3D(fileName);
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}
@ -829,9 +829,9 @@ var Sprite3DMirrorTest = Sprite3DTestDemo.extend({
sp = new jsb.Sprite3D("Sprite3DTest/axe.c3b");
sprite.getAttachNode("Bip001 R Hand").addChild(sp);
var animation = jsb.Animation3D.create(fileName);
var animation = new jsb.Animation3D(fileName);
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}
}
@ -854,9 +854,9 @@ var QuaternionTest = Sprite3DTestDemo.extend({
sprite.setPosition(cc.p(s.width/2 + this._radius * Math.cos(this._accAngle), s.height / 2 + this._radius * Math.sin(this._accAngle)));
this.addChild(sprite);
this._sprite = sprite;
var animation = jsb.Animation3D.create("Sprite3DTest/tortoise.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/tortoise.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation, 0, 1.933);
var animate = new jsb.Animate3D(animation, 0, 1.933);
sprite.runAction(cc.repeatForever(animate));
}
@ -937,9 +937,9 @@ var UseCaseSprite3D1 = Sprite3DTestDemo.extend({
var sprite = new jsb.Sprite3D("Sprite3DTest/girl.c3b");
sprite.setScale(0.15);
var animation = jsb.Animation3D.create("Sprite3DTest/girl.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/girl.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}
@ -1006,9 +1006,9 @@ var UseCaseSprite3D2 = Sprite3DTestDemo.extend({
var sprite = new jsb.Sprite3D("Sprite3DTest/girl.c3b");
sprite.setScale(0.5);
var animation = jsb.Animation3D.create("Sprite3DTest/girl.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/girl.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
sprite.runAction(cc.repeatForever(animate));
}
sprite.setPosition(s.width/4, s.height/4);
@ -1139,9 +1139,9 @@ var Sprite3DWithSkinOutlineTest = Sprite3DTestDemo.extend({
effect2.setOutlineWidth(0.02);
sprite.addEffect(effect2, -2);
var animation = jsb.Animation3D.create("Sprite3DTest/orc.c3b");
var animation = new jsb.Animation3D("Sprite3DTest/orc.c3b");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
var inverse = Math.random() < 0.33 ? true : false;
var rand2 = Math.random();
@ -1190,7 +1190,7 @@ var Sprite3DLightMapTest = Sprite3DTestDemo.extend({
var light = jsb.PointLight.create(cc.math.vec3(35, 75, -20.5), cc.color(255, 255, 255), 150);
this.addChild(light);
//set the ambient light
var ambient = jsb.AmbientLight.create(cc.color(55, 55, 55));
var ambient = new jsb.AmbientLight(cc.color(55, 55, 55));
this.addChild(ambient);
//create a listener

View File

@ -332,9 +332,9 @@ var TerrainWalkThru = (function(){
this._player.setScale(0.08);
this._player.y = this._terrain.getHeight(this._player.x, this._player.getVertexZ()) + PLAYER_HEIGHT;
var animation = jsb.Animation3D.create("Sprite3DTest/girl.c3b", "Take 001");
var animation = new jsb.Animation3D("Sprite3DTest/girl.c3b", "Take 001");
if(animation){
var animate = jsb.Animate3D.create(animation);
var animate = new jsb.Animate3D(animation);
this._player.runAction(cc.repeatForever(animate));
}

View File

@ -17,7 +17,7 @@ clang_flags = -nostdinc -x c++ -std=c++11 -D CC_ENABLE_BULLET_INTEGRATION -D CC_
win32_clang_flags = -U __SSE__
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external
cocos_flags = -DANDROID
@ -29,6 +29,8 @@ extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s
# what headers to parse
headers = %(cocosdir)s/cocos/physics3d/CCPhysics3D.h
cpp_headers = 3d/jsb_cocos2dx_3d_conversions.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