Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3-win32-warn

Conflicts:
	tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp
This commit is contained in:
Dhilan007 2014-10-10 17:02:45 +08:00
commit 89db9ecd3b
49 changed files with 3318 additions and 975 deletions

View File

@ -16,15 +16,21 @@ cocos2d-x-3.3-beta1
[FIX] Cocos Studio reader: UI animation playing crash if GUI JSON file is loaded again
[FIX] Cocos Studio reader: improvement ImageViewReader don't necessary loadTexture when imageFilePath is empty
[FIX] EditBox: view rendereed in wrong position if click EditBox on iOS 8
[FIX] FileUtils: can not remove files/directory on iOS devices
[FIX] GLProgram: crashed on some Android devices that do not support more than 8 attributes
[FIX] Label: getStringNumLines() may returns wrong result if label is dirty
[FIX] Label: can not change opacity if using FNT font
[FIX] Label: endless loop if not using system font, and constrained length is less than one character width
[FIX] LabelAtlas: opacity do not change when setting parent's opacity
[FIX] Lua-bindings: may crash if passing two-dimensional table from lua to c++
[FIX] New audio: can not play audio after playing some times on Android
[FIX] Node: macro scheduler_selector() superseded by CC_SCHEDULER_SELECTOR(). The same is true for the other schedule_ macros
[FIX] Node: unscheduleAllSelectors() deprecated in favor of unscheudleAllCallbacks()
[FIX] Node: crashed if remove/add child too quickly when using integrated physics
[FIX] TextFieldTTF: will get wrong characters if using Chinese input method on WP8
[FIX] UI: Button: button remains gray when releasing it, this issue only happened if enable scale9 and only has one texture
[FIX] UI: Button: when creating a button with a title only, button content size is not immediately updated
[FIX] UI: EditBox: setMaxLength is invalid on mac
cocos2d-x-3.3-beta0 Sep.20 2014
[NEW] 3d: added `BillBoard`

View File

@ -58,6 +58,8 @@
1503FAC418DA8B6C00F6518C /* tp.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB118DA8B6C00F6518C /* tp.lua */; };
1503FAC518DA8B6C00F6518C /* url.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB218DA8B6C00F6518C /* url.lua */; };
1503FAC618DA8B6C00F6518C /* url.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB218DA8B6C00F6518C /* url.lua */; };
150F918819DA409E00B89F57 /* lua_test_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */; };
150F918919DA409F00B89F57 /* lua_test_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */; };
15427B79198B879900DC375D /* libluacocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15EFA665198B33EE000C57D3 /* libluacocos2d iOS.a */; };
15427B7A198B87AA00DC375D /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2d iOS.a */; };
15427B7D198B880100DC375D /* lua_cocos2dx_controller_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15427B7B198B880100DC375D /* lua_cocos2dx_controller_manual.cpp */; };
@ -1160,6 +1162,8 @@
1503FAB018DA8B6C00F6518C /* socket.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = socket.lua; path = ../external/lua/luasocket/socket.lua; sourceTree = "<group>"; };
1503FAB118DA8B6C00F6518C /* tp.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tp.lua; path = ../external/lua/luasocket/tp.lua; sourceTree = "<group>"; };
1503FAB218DA8B6C00F6518C /* url.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = url.lua; path = ../external/lua/luasocket/url.lua; sourceTree = "<group>"; };
150F918619DA409E00B89F57 /* lua_test_bindings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_test_bindings.cpp; sourceTree = "<group>"; };
150F918719DA409E00B89F57 /* lua_test_bindings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_test_bindings.h; sourceTree = "<group>"; };
15427B76198B750300DC375D /* lua_module_register.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_module_register.h; sourceTree = "<group>"; };
15427B77198B843300DC375D /* lua_module_register.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_module_register.h; sourceTree = "<group>"; };
15427B7B198B880100DC375D /* lua_cocos2dx_controller_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lua_cocos2dx_controller_manual.cpp; path = "../../../../cocos/scripting/lua-bindings/manual/controller/lua_cocos2dx_controller_manual.cpp"; sourceTree = "<group>"; };
@ -6614,6 +6618,8 @@
1AC35D7C18CEE5B100F37B72 /* Classes */ = {
isa = PBXGroup;
children = (
150F918619DA409E00B89F57 /* lua_test_bindings.cpp */,
150F918719DA409E00B89F57 /* lua_test_bindings.h */,
15427B76198B750300DC375D /* lua_module_register.h */,
1AC35D7D18CEE5B100F37B72 /* AppDelegate.cpp */,
1AC35D7E18CEE5B100F37B72 /* AppDelegate.h */,
@ -8006,6 +8012,7 @@
files = (
1AC35D8118CEE5B100F37B72 /* AppDelegate.cpp in Sources */,
1AC35DB518CEE5DA00F37B72 /* LuaObjectCBridgeTest.mm in Sources */,
150F918819DA409E00B89F57 /* lua_test_bindings.cpp in Sources */,
1AC35DB618CEE5DA00F37B72 /* main.cpp in Sources */,
1AC35D8318CEE5B100F37B72 /* lua_assetsmanager_test_sample.cpp in Sources */,
);
@ -8015,6 +8022,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
150F918919DA409F00B89F57 /* lua_test_bindings.cpp in Sources */,
1AC35DA518CEE5D100F37B72 /* main.m in Sources */,
1AC35DA418CEE5D100F37B72 /* LuaObjectCBridgeTest.mm in Sources */,
1AC35D9818CEE5D100F37B72 /* AppController.mm in Sources */,

View File

@ -216,7 +216,15 @@ void AtlasNode::setBlendFunc(const BlendFunc &blendFunc)
void AtlasNode::updateBlendFunc()
{
if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha() )
{
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
setOpacityModifyRGB(false);
}
else
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setOpacityModifyRGB(true);
}
}
void AtlasNode::setTexture(Texture2D *texture)

View File

@ -233,6 +233,12 @@ void LabelAtlas::updateColor()
if (_textureAtlas)
{
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
if (_isOpacityModifyRGB)
{
color4.r *= _displayedOpacity/255.0f;
color4.g *= _displayedOpacity/255.0f;
color4.b *= _displayedOpacity/255.0f;
}
auto quads = _textureAtlas->getQuads();
ssize_t length = _string.length();
for (int index = 0; index < length; index++)

View File

@ -151,16 +151,20 @@ bool LabelTextFormatter::multilineText(Label *theLabel)
else
{
StringUtils::trimUTF16Vector(last_word);
if (isStartOfLine)
last_word.push_back(character);
last_word.push_back('\n');
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
last_word.clear();
if (!isStartOfLine)
--j;
isStartOfWord = false;
isStartOfLine = false;
startOfWord = -1;
startOfLine = -1;
--j;
}
}
else

View File

@ -7,7 +7,7 @@
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(EngineRoot)cocos;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos;$(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_VARIADIC_MAX=10;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ProjectReference>

View File

@ -1775,7 +1775,6 @@ NodeData* Bundle3D::parseNodesRecursivelyJson(const rapidjson::Value& jvalue)
if (modelnodedata->subMeshId == "" || modelnodedata->matrialId == "")
{
std::string err = "Node " + nodedata->id + " part is missing meshPartId or materialId";
CCLOG("warning: Node %s part is missing meshPartId or materialId", nodedata->id.c_str());
return nullptr;
}
@ -2085,22 +2084,23 @@ unsigned int Bundle3D::parseGLProgramAttribute(const std::string& str)
{
return GLProgram::VERTEX_ATTRIB_TEX_COORD3;
}
else if (str == "VERTEX_ATTRIB_TEX_COORD4")
{
return GLProgram::VERTEX_ATTRIB_TEX_COORD4;
}
else if (str == "VERTEX_ATTRIB_TEX_COORD5")
{
return GLProgram::VERTEX_ATTRIB_TEX_COORD5;
}
else if (str == "VERTEX_ATTRIB_TEX_COORD6")
{
return GLProgram::VERTEX_ATTRIB_TEX_COORD6;
}
else if (str == "VERTEX_ATTRIB_TEX_COORD7")
{
return GLProgram::VERTEX_ATTRIB_TEX_COORD7;
}
//comment out them
// else if (str == "VERTEX_ATTRIB_TEX_COORD4")
// {
// return GLProgram::VERTEX_ATTRIB_TEX_COORD4;
// }
// else if (str == "VERTEX_ATTRIB_TEX_COORD5")
// {
// return GLProgram::VERTEX_ATTRIB_TEX_COORD5;
// }
// else if (str == "VERTEX_ATTRIB_TEX_COORD6")
// {
// return GLProgram::VERTEX_ATTRIB_TEX_COORD6;
// }
// else if (str == "VERTEX_ATTRIB_TEX_COORD7")
// {
// return GLProgram::VERTEX_ATTRIB_TEX_COORD7;
// }
else if (str == "VERTEX_ATTRIB_NORMAL")
{
return GLProgram::VERTEX_ATTRIB_NORMAL;

View File

@ -44,7 +44,7 @@
NS_CC_BEGIN
std::string s_attributeNames[] = {GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::ATTRIBUTE_NAME_TEX_COORD1, GLProgram::ATTRIBUTE_NAME_TEX_COORD2,GLProgram::ATTRIBUTE_NAME_TEX_COORD3,GLProgram::ATTRIBUTE_NAME_TEX_COORD4,GLProgram::ATTRIBUTE_NAME_TEX_COORD5,GLProgram::ATTRIBUTE_NAME_TEX_COORD6,GLProgram::ATTRIBUTE_NAME_TEX_COORD7,GLProgram::ATTRIBUTE_NAME_NORMAL, GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT, GLProgram::ATTRIBUTE_NAME_BLEND_INDEX};
std::string s_attributeNames[] = {GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::ATTRIBUTE_NAME_TEX_COORD1, GLProgram::ATTRIBUTE_NAME_TEX_COORD2,GLProgram::ATTRIBUTE_NAME_TEX_COORD3,GLProgram::ATTRIBUTE_NAME_NORMAL, GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT, GLProgram::ATTRIBUTE_NAME_BLEND_INDEX};
Sprite3D* Sprite3D::create(const std::string &modelPath)
{

View File

@ -69,19 +69,15 @@ void DirectionLight::setDirection(const Vec3 &dir)
{
setRotationFromDirection(dir);
}
const Vec3& DirectionLight::getDirection() const
Vec3 DirectionLight::getDirection() const
{
static Vec3 dir;
Mat4 mat = getNodeToParentTransform();
dir.set(-mat.m[8], -mat.m[9], -mat.m[10]);
return dir;
return Vec3(-mat.m[8], -mat.m[9], -mat.m[10]);
}
const Vec3& DirectionLight::getDirectionInWorld() const
Vec3 DirectionLight::getDirectionInWorld() const
{
static Vec3 dir;
Mat4 mat = getNodeToWorldTransform();
dir.set(-mat.m[8], -mat.m[9], -mat.m[10]);
return dir;
return Vec3(-mat.m[8], -mat.m[9], -mat.m[10]);
}
DirectionLight::DirectionLight()
{
@ -131,20 +127,16 @@ void SpotLight::setDirection(const Vec3 &dir)
setRotationFromDirection(dir);
}
const Vec3& SpotLight::getDirection() const
Vec3 SpotLight::getDirection() const
{
static Vec3 dir;
Mat4 mat = getNodeToParentTransform();
dir.set(-mat.m[8], -mat.m[9], -mat.m[10]);
return dir;
return Vec3(-mat.m[8], -mat.m[9], -mat.m[10]);
}
const Vec3& SpotLight::getDirectionInWorld() const
Vec3 SpotLight::getDirectionInWorld() const
{
static Vec3 dir;
Mat4 mat = getNodeToWorldTransform();
dir.set(-mat.m[8], -mat.m[9], -mat.m[10]);
return dir;
return Vec3(-mat.m[8], -mat.m[9], -mat.m[10]);
}
void SpotLight::setInnerAngle(float angle)
@ -156,7 +148,7 @@ void SpotLight::setInnerAngle(float angle)
void SpotLight::setOuterAngle(float angle)
{
_outerAngle = angle;
_cosInnerAngle = cosf(angle);
_cosOuterAngle = cosf(angle);
}
SpotLight::SpotLight()

View File

@ -120,12 +120,12 @@ public:
/**
* Returns the Direction in parent.
*/
const Vec3& getDirection() const;
Vec3 getDirection() const;
/**
* Returns direction in world.
*/
const Vec3& getDirectionInWorld() const;
Vec3 getDirectionInWorld() const;
CC_CONSTRUCTOR_ACCESS:
DirectionLight();
@ -190,12 +190,12 @@ public:
/**
* Returns the Direction in parent.
*/
const Vec3& getDirection() const;
Vec3 getDirection() const;
/**
* Returns direction in world.
*/
const Vec3& getDirectionInWorld() const;
Vec3 getDirectionInWorld() const;
/**
* Sets the range of point or spot light.
@ -238,7 +238,7 @@ public:
float getOuterAngle() const { return _outerAngle; }
/** get cos outAngle */
float getCosOuterAngle() const { return _cosInnerAngle; }
float getCosOuterAngle() const { return _cosOuterAngle; }
CC_CONSTRUCTOR_ACCESS:
SpotLight();

View File

@ -115,7 +115,11 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* actionName)
{
auto iterator = _actionDic.find(jsonName);
std::string path = jsonName;
ssize_t pos = path.find_last_of("/");
std::string fileName = path.substr(pos+1,path.length());
CCLOG("find filename == %s",fileName.c_str());
auto iterator = _actionDic.find(fileName);
if (iterator == _actionDic.end())
{
return nullptr;

View File

@ -342,6 +342,14 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
createObject(subDict, gb, attachComponent);
}
const rapidjson::Value &canvasSizeDict = DICTOOL->getSubDictionary_json(dict, "CanvasSize");
if (DICTOOL->checkObjectExist_json(canvasSizeDict))
{
int width = DICTOOL->getIntValue_json(canvasSizeDict, "_width");
int height = DICTOOL->getIntValue_json(canvasSizeDict, "_height");
gb->setContentSize(Size(width, height));
}
return gb;
}

View File

@ -37,6 +37,10 @@ THE SOFTWARE.
#include "unzip.h"
#include <sys/stat.h>
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
#include <ftw.h>
#endif
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
#include <sys/types.h>
#include <errno.h>
@ -1103,6 +1107,18 @@ bool FileUtils::createDirectory(const std::string& path)
#endif
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
static int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
{
auto ret = remove(fpath);
if (ret) {
log("Fail to remove:%s ",fpath);
}
return ret;
}
#endif
bool FileUtils::removeDirectory(const std::string& path)
{
if (path.size() > 0 && path[path.size() - 1] != '/')
@ -1155,6 +1171,11 @@ bool FileUtils::removeDirectory(const std::string& path)
return true;
else
return false;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
if (nftw(path.c_str(),unlink_cb, 64, FTW_DEPTH | FTW_PHYS))
return false;
else
return true;
#else
std::string command = "rm -r ";
// Path may include space.
@ -1195,13 +1216,11 @@ bool FileUtils::removeFile(const std::string &path)
else
return false;
#else
std::string command = "rm -f ";
// Path may include space.
command += "\"" + path + "\"";
if (system(command.c_str()) >= 0)
return true;
else
if (remove(path.c_str())) {
return false;
} else {
return true;
}
#endif
}

View File

@ -226,7 +226,50 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
class cocos2dEGLConfigChooser implements GLSurfaceView.EGLConfigChooser
{
public int[] attribs;
protected int[] configAttribs;
public cocos2dEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)
{
configAttribs = new int[] {redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize};
}
public cocos2dEGLConfigChooser(int[] attribs)
{
configAttribs = attribs;
}
public EGLConfig selectConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs, int[] attribs)
{
for (EGLConfig config : configs) {
int d = findConfigAttrib(egl, display, config,
EGL10.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(egl, display, config,
EGL10.EGL_STENCIL_SIZE, 0);
if ((d >= attribs[4]) && (s >= attribs[5])) {
int r = findConfigAttrib(egl, display, config,
EGL10.EGL_RED_SIZE, 0);
int g = findConfigAttrib(egl, display, config,
EGL10.EGL_GREEN_SIZE, 0);
int b = findConfigAttrib(egl, display, config,
EGL10.EGL_BLUE_SIZE, 0);
int a = findConfigAttrib(egl, display, config,
EGL10.EGL_ALPHA_SIZE, 0);
if ((r >= attribs[0]) && (g >= attribs[1])
&& (b >= attribs[2]) && (a >= attribs[3])) {
return config;
}
}
}
return null;
}
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
EGLConfig config, int attribute, int defaultValue) {
int[] value = new int[1];
if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
return value[0];
}
return defaultValue;
}
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
{
@ -235,12 +278,13 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
{
EGLConfig[] configs = new EGLConfig[numConfigs[0]];
int[] EGLattribs = {
EGL10.EGL_RED_SIZE, attribs[0],
EGL10.EGL_GREEN_SIZE, attribs[1],
EGL10.EGL_BLUE_SIZE, attribs[2],
EGL10.EGL_ALPHA_SIZE, attribs[3],
EGL10.EGL_DEPTH_SIZE, attribs[4],
EGL10.EGL_STENCIL_SIZE,attribs[5],
EGL10.EGL_RED_SIZE, configAttribs[0],
EGL10.EGL_GREEN_SIZE, configAttribs[1],
EGL10.EGL_BLUE_SIZE, configAttribs[2],
EGL10.EGL_ALPHA_SIZE, configAttribs[3],
EGL10.EGL_DEPTH_SIZE, configAttribs[4],
EGL10.EGL_STENCIL_SIZE,configAttribs[5],
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
EGL10.EGL_NONE
};
int[] choosedConfigNum = new int[1];
@ -248,7 +292,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
egl.eglChooseConfig(display, EGLattribs, configs, numConfigs[0], choosedConfigNum);
if(choosedConfigNum[0]>0)
{
return configs[0];
return selectConfig(egl, display, configs, configAttribs);
}
else
{
@ -259,6 +303,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
EGL10.EGL_ALPHA_SIZE, 0,
EGL10.EGL_DEPTH_SIZE, 0,
EGL10.EGL_STENCIL_SIZE,0,
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
EGL10.EGL_NONE
};
int[] defaultEGLattribsAlpha = {
@ -268,17 +313,24 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
EGL10.EGL_ALPHA_SIZE, 4,
EGL10.EGL_DEPTH_SIZE, 0,
EGL10.EGL_STENCIL_SIZE,0,
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
EGL10.EGL_NONE
};
int[] attribs = null;
//choose one can use
if(this.attribs[3] == 0)
if(this.configAttribs[3] == 0)
{
egl.eglChooseConfig(display, defaultEGLattribs, configs, numConfigs[0], choosedConfigNum);
attribs = new int[]{5,6,5,0,0,0};
}
else
{
egl.eglChooseConfig(display, defaultEGLattribsAlpha, configs, numConfigs[0], choosedConfigNum);
attribs = new int[]{4,4,4,4,0,0};
}
if(choosedConfigNum[0] > 0)
{
Log.w(DEVICE_POLICY_SERVICE, "The EGLConfig can not be used for rendering, use a default one");
return configs[0];
return selectConfig(egl, display, configs, attribs);
}
else
{
@ -290,9 +342,9 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
Log.e(DEVICE_POLICY_SERVICE, "Can not select an EGLConfig for rendering.");
return null;
}
}
cocos2dEGLConfigChooser chooser = new cocos2dEGLConfigChooser();
chooser.attribs = this.glContextAttrs;
cocos2dEGLConfigChooser chooser = new cocos2dEGLConfigChooser(this.glContextAttrs);
glSurfaceView.setEGLConfigChooser(chooser);
return glSurfaceView;

View File

@ -100,10 +100,6 @@ const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD1 = "a_texCoord1";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD2 = "a_texCoord2";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD3 = "a_texCoord3";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD4 = "a_texCoord4";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD5 = "a_texCoord5";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD6 = "a_texCoord6";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD7 = "a_texCoord7";
const char* GLProgram::ATTRIBUTE_NAME_NORMAL = "a_normal";
const char* GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight";
const char* GLProgram::ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex";
@ -294,10 +290,6 @@ void GLProgram::bindPredefinedVertexAttribs()
{GLProgram::ATTRIBUTE_NAME_TEX_COORD1, GLProgram::VERTEX_ATTRIB_TEX_COORD1},
{GLProgram::ATTRIBUTE_NAME_TEX_COORD2, GLProgram::VERTEX_ATTRIB_TEX_COORD2},
{GLProgram::ATTRIBUTE_NAME_TEX_COORD3, GLProgram::VERTEX_ATTRIB_TEX_COORD3},
{GLProgram::ATTRIBUTE_NAME_TEX_COORD4, GLProgram::VERTEX_ATTRIB_TEX_COORD4},
{GLProgram::ATTRIBUTE_NAME_TEX_COORD5, GLProgram::VERTEX_ATTRIB_TEX_COORD5},
{GLProgram::ATTRIBUTE_NAME_TEX_COORD6, GLProgram::VERTEX_ATTRIB_TEX_COORD6},
{GLProgram::ATTRIBUTE_NAME_TEX_COORD7, GLProgram::VERTEX_ATTRIB_TEX_COORD7},
{GLProgram::ATTRIBUTE_NAME_NORMAL, GLProgram::VERTEX_ATTRIB_NORMAL},
};

View File

@ -87,14 +87,9 @@ public:
VERTEX_ATTRIB_TEX_COORD1,
VERTEX_ATTRIB_TEX_COORD2,
VERTEX_ATTRIB_TEX_COORD3,
VERTEX_ATTRIB_TEX_COORD4,
VERTEX_ATTRIB_TEX_COORD5,
VERTEX_ATTRIB_TEX_COORD6,
VERTEX_ATTRIB_TEX_COORD7,
VERTEX_ATTRIB_NORMAL,
VERTEX_ATTRIB_BLEND_WEIGHT,
VERTEX_ATTRIB_BLEND_INDEX,
VERTEX_ATTRIB_MAX,
// backward compatibility
@ -169,10 +164,6 @@ public:
static const char* ATTRIBUTE_NAME_TEX_COORD1;
static const char* ATTRIBUTE_NAME_TEX_COORD2;
static const char* ATTRIBUTE_NAME_TEX_COORD3;
static const char* ATTRIBUTE_NAME_TEX_COORD4;
static const char* ATTRIBUTE_NAME_TEX_COORD5;
static const char* ATTRIBUTE_NAME_TEX_COORD6;
static const char* ATTRIBUTE_NAME_TEX_COORD7;
static const char* ATTRIBUTE_NAME_NORMAL;
static const char* ATTRIBUTE_NAME_BLEND_WEIGHT;
static const char* ATTRIBUTE_NAME_BLEND_INDEX;

View File

@ -1,9 +1,5 @@
const char* cc3D_PositionNormalTex_vert = STRINGIFY(
\n#define MAX_DIRECTIONAL_LIGHT_NUM 1 \n
\n#define MAX_POINT_LIGHT_NUM 1 \n
\n#define MAX_SPOT_LIGHT_NUM 1 \n
\n#define MAX_AMBIENT_LIGHT_NUM 1 \n
\n#if (MAX_POINT_LIGHT_NUM > 0)\n
uniform vec3 u_PointLightSourcePosition[MAX_POINT_LIGHT_NUM];
@ -55,10 +51,6 @@ void main(void)
);
const char* cc3D_SkinPositionNormalTex_vert = STRINGIFY(
\n#define MAX_DIRECTIONAL_LIGHT_NUM 1 \n
\n#define MAX_POINT_LIGHT_NUM 1 \n
\n#define MAX_SPOT_LIGHT_NUM 1 \n
\n#define MAX_AMBIENT_LIGHT_NUM 1 \n
\n#if (MAX_POINT_LIGHT_NUM > 0)\n
uniform vec3 u_PointLightSourcePosition[MAX_POINT_LIGHT_NUM];

View File

@ -1,64 +0,0 @@
--------------------------------
-- @module AABB
-- @parent_module cc
--------------------------------
-- reset min and max value.
-- @function [parent=#AABB] reset
-- @param self
--------------------------------
-- Sets this bounding box to the specified values.
-- @function [parent=#AABB] set
-- @param self
-- @param #vec3_table min
-- @param #vec3_table max
--------------------------------
-- Transforms the bounding box by the given transformation matrix.
-- @function [parent=#AABB] transform
-- @param self
-- @param #mat4_table mat
--------------------------------
-- Gets the center point of the bounding box.
-- @function [parent=#AABB] getCenter
-- @param self
-- @return vec3_table#vec3_table ret (return value: vec3_table)
--------------------------------
--
-- @function [parent=#AABB] isEmpty
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
--
-- @function [parent=#AABB] getCorners
-- @param self
-- @param #vec3_table dst
--------------------------------
-- update the _min and _max from the given point.
-- @function [parent=#AABB] updateMinMax
-- @param self
-- @param #vec3_table point
-- @param #long num
--------------------------------
-- check whether the point is in.
-- @function [parent=#AABB] containPoint
-- @param self
-- @param #vec3_table point
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @overload self, vec3_table, vec3_table
-- @overload self
-- @function [parent=#AABB] AABB
-- @param self
-- @param #vec3_table min
-- @param #vec3_table max
return nil

View File

@ -1,40 +0,0 @@
--------------------------------
-- @module OBB
-- @parent_module cc
--------------------------------
--
-- @function [parent=#OBB] reset
-- @param self
--------------------------------
--
-- @function [parent=#OBB] set
-- @param self
-- @param #vec3_table center
-- @param #vec3_table _xAxis
-- @param #vec3_table _yAxis
-- @param #vec3_table _zAxis
-- @param #vec3_table _extents
--------------------------------
-- Transforms the obb by the given transformation matrix.
-- @function [parent=#OBB] transform
-- @param self
-- @param #mat4_table mat
--------------------------------
--
-- @function [parent=#OBB] getCorners
-- @param self
-- @param #vec3_table verts
--------------------------------
--
-- @function [parent=#OBB] containPoint
-- @param self
-- @param #vec3_table point
-- @return bool#bool ret (return value: bool)
return nil

View File

@ -1,16 +1,6 @@
--------------------------------
-- @module cc
--------------------------------------------------------
-- the cc AABB
-- @field [parent=#cc] AABB#AABB AABB preloaded module
--------------------------------------------------------
-- the cc OBB
-- @field [parent=#cc] OBB#OBB OBB preloaded module
--------------------------------------------------------
-- the cc Skeleton3D
-- @field [parent=#cc] Skeleton3D#Skeleton3D Skeleton3D preloaded module

View File

@ -5,712 +5,6 @@
int lua_cocos2dx_3d_AABB_reset(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_reset'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
cobj->reset();
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:reset",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_reset'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_AABB_set(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_set'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
cocos2d::Vec3 arg0;
cocos2d::Vec3 arg1;
ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.AABB:set");
ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.AABB:set");
if(!ok)
return 0;
cobj->set(arg0, arg1);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:set",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_set'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_AABB_transform(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_transform'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Mat4 arg0;
ok &= luaval_to_mat4(tolua_S, 2, &arg0, "cc.AABB:transform");
if(!ok)
return 0;
cobj->transform(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:transform",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_transform'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_AABB_getCenter(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_getCenter'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
cocos2d::Vec3 ret = cobj->getCenter();
vec3_to_luaval(tolua_S, ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:getCenter",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_getCenter'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_AABB_isEmpty(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_isEmpty'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
bool ret = cobj->isEmpty();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:isEmpty",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_isEmpty'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_AABB_getCorners(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_getCorners'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Vec3* arg0;
ok &= luaval_to_object<cocos2d::Vec3>(tolua_S, 2, "cc.Vec3",&arg0);
if(!ok)
return 0;
cobj->getCorners(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:getCorners",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_getCorners'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_AABB_updateMinMax(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_updateMinMax'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
const cocos2d::Vec3* arg0;
ssize_t arg1;
ok &= luaval_to_object<const cocos2d::Vec3>(tolua_S, 2, "cc.Vec3",&arg0);
ok &= luaval_to_ssize(tolua_S, 3, &arg1, "cc.AABB:updateMinMax");
if(!ok)
return 0;
cobj->updateMinMax(arg0, arg1);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:updateMinMax",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_updateMinMax'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_AABB_containPoint(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.AABB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::AABB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_AABB_containPoint'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Vec3 arg0;
ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.AABB:containPoint");
if(!ok)
return 0;
bool ret = cobj->containPoint(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:containPoint",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_containPoint'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_AABB_constructor(lua_State* tolua_S)
{
int argc = 0;
cocos2d::AABB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
argc = lua_gettop(tolua_S)-1;
do{
if (argc == 2) {
cocos2d::Vec3 arg0;
ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.AABB:AABB");
if (!ok) { break; }
cocos2d::Vec3 arg1;
ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.AABB:AABB");
if (!ok) { break; }
cobj = new cocos2d::AABB(arg0, arg1);
tolua_pushusertype(tolua_S,(void*)cobj,"cc.AABB");
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
return 1;
}
}while(0);
ok = true;
do{
if (argc == 0) {
cobj = new cocos2d::AABB();
tolua_pushusertype(tolua_S,(void*)cobj,"cc.AABB");
tolua_register_gc(tolua_S,lua_gettop(tolua_S));
return 1;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.AABB:AABB",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_AABB_constructor'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_3d_AABB_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (AABB)");
return 0;
}
int lua_register_cocos2dx_3d_AABB(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.AABB");
tolua_cclass(tolua_S,"AABB","cc.AABB","",nullptr);
tolua_beginmodule(tolua_S,"AABB");
tolua_function(tolua_S,"new",lua_cocos2dx_3d_AABB_constructor);
tolua_function(tolua_S,"reset",lua_cocos2dx_3d_AABB_reset);
tolua_function(tolua_S,"set",lua_cocos2dx_3d_AABB_set);
tolua_function(tolua_S,"transform",lua_cocos2dx_3d_AABB_transform);
tolua_function(tolua_S,"getCenter",lua_cocos2dx_3d_AABB_getCenter);
tolua_function(tolua_S,"isEmpty",lua_cocos2dx_3d_AABB_isEmpty);
tolua_function(tolua_S,"getCorners",lua_cocos2dx_3d_AABB_getCorners);
tolua_function(tolua_S,"updateMinMax",lua_cocos2dx_3d_AABB_updateMinMax);
tolua_function(tolua_S,"containPoint",lua_cocos2dx_3d_AABB_containPoint);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::AABB).name();
g_luaType[typeName] = "cc.AABB";
g_typeCast["AABB"] = "cc.AABB";
return 1;
}
int lua_cocos2dx_3d_OBB_reset(lua_State* tolua_S)
{
int argc = 0;
cocos2d::OBB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_reset'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
cobj->reset();
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:reset",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_reset'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_OBB_set(lua_State* tolua_S)
{
int argc = 0;
cocos2d::OBB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_set'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 5)
{
cocos2d::Vec3 arg0;
cocos2d::Vec3 arg1;
cocos2d::Vec3 arg2;
cocos2d::Vec3 arg3;
cocos2d::Vec3 arg4;
ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.OBB:set");
ok &= luaval_to_vec3(tolua_S, 3, &arg1, "cc.OBB:set");
ok &= luaval_to_vec3(tolua_S, 4, &arg2, "cc.OBB:set");
ok &= luaval_to_vec3(tolua_S, 5, &arg3, "cc.OBB:set");
ok &= luaval_to_vec3(tolua_S, 6, &arg4, "cc.OBB:set");
if(!ok)
return 0;
cobj->set(arg0, arg1, arg2, arg3, arg4);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:set",argc, 5);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_set'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_OBB_transform(lua_State* tolua_S)
{
int argc = 0;
cocos2d::OBB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_transform'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Mat4 arg0;
ok &= luaval_to_mat4(tolua_S, 2, &arg0, "cc.OBB:transform");
if(!ok)
return 0;
cobj->transform(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:transform",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_transform'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_OBB_getCorners(lua_State* tolua_S)
{
int argc = 0;
cocos2d::OBB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_getCorners'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Vec3* arg0;
ok &= luaval_to_object<cocos2d::Vec3>(tolua_S, 2, "cc.Vec3",&arg0);
if(!ok)
return 0;
cobj->getCorners(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:getCorners",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_getCorners'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_OBB_containPoint(lua_State* tolua_S)
{
int argc = 0;
cocos2d::OBB* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.OBB",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::OBB*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_OBB_containPoint'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Vec3 arg0;
ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.OBB:containPoint");
if(!ok)
return 0;
bool ret = cobj->containPoint(arg0);
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.OBB:containPoint",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_OBB_containPoint'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_3d_OBB_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (OBB)");
return 0;
}
int lua_register_cocos2dx_3d_OBB(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.OBB");
tolua_cclass(tolua_S,"OBB","cc.OBB","",nullptr);
tolua_beginmodule(tolua_S,"OBB");
tolua_function(tolua_S,"reset",lua_cocos2dx_3d_OBB_reset);
tolua_function(tolua_S,"set",lua_cocos2dx_3d_OBB_set);
tolua_function(tolua_S,"transform",lua_cocos2dx_3d_OBB_transform);
tolua_function(tolua_S,"getCorners",lua_cocos2dx_3d_OBB_getCorners);
tolua_function(tolua_S,"containPoint",lua_cocos2dx_3d_OBB_containPoint);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::OBB).name();
g_luaType[typeName] = "cc.OBB";
g_typeCast["OBB"] = "cc.OBB";
return 1;
}
int lua_cocos2dx_3d_Skeleton3D_getBoneByName(lua_State* tolua_S)
{
int argc = 0;
@ -2814,8 +2108,6 @@ TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S)
lua_register_cocos2dx_3d_Animate3D(tolua_S);
lua_register_cocos2dx_3d_Sprite3D(tolua_S);
lua_register_cocos2dx_3d_AttachNode(tolua_S);
lua_register_cocos2dx_3d_AABB(tolua_S);
lua_register_cocos2dx_3d_OBB(tolua_S);
lua_register_cocos2dx_3d_BillBoard(tolua_S);
lua_register_cocos2dx_3d_Animation3D(tolua_S);
lua_register_cocos2dx_3d_Skeleton3D(tolua_S);

View File

@ -43,22 +43,6 @@ int register_all_cocos2dx_3d(lua_State* tolua_S);

View File

@ -186,6 +186,7 @@ bool LuaStack::init(void)
tolua_opengl_open(_state);
register_all_cocos2dx_manual(_state);
register_all_cocos2dx_module_manual(_state);
register_all_cocos2dx_math_manual(_state);
register_all_cocos2dx_experimental(_state);
register_all_cocos2dx_experimental_manual(_state);

View File

@ -371,12 +371,12 @@ bool luaval_to_vec4(lua_State* L,int lo,cocos2d::Vec4* outValue, const char* fun
lua_pushstring(L, "z");
lua_gettable(L, lo);
outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
outValue->z = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "w");
lua_gettable(L, lo);
outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
outValue->w = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
lua_pop(L, 1);
}
return ok;
@ -1997,6 +1997,48 @@ bool luaval_to_std_vector_ushort(lua_State* L, int lo, std::vector<unsigned shor
return ok;
}
bool luaval_to_quaternion(lua_State* L,int lo,cocos2d::Quaternion* outValue, const char* funcName)
{
if (nullptr == L || nullptr == outValue)
return false;
bool ok = true;
tolua_Error tolua_err;
if (!tolua_istable(L, lo, 0, &tolua_err) )
{
#if COCOS2D_DEBUG >=1
luaval_to_native_err(L,"#ferror:",&tolua_err,funcName);
#endif
ok = false;
}
if (ok)
{
lua_pushstring(L, "x");
lua_gettable(L, lo);
outValue->x = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "y");
lua_gettable(L, lo);
outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "z");
lua_gettable(L, lo);
outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "w");
lua_gettable(L, lo);
outValue->y = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1);
lua_pop(L, 1);
}
return ok;
}
void vec2_array_to_luaval(lua_State* L,const cocos2d::Vec2* points, int count)
{
if (NULL == L)
@ -2939,3 +2981,23 @@ void ccvector_ushort_to_luaval(lua_State* L, const std::vector<unsigned short>&
++index;
}
}
void quaternion_to_luaval(lua_State* L,const cocos2d::Quaternion& inValue)
{
if (NULL == L)
return;
lua_newtable(L); /* L: table */
lua_pushstring(L, "x"); /* L: table key */
lua_pushnumber(L, (lua_Number) inValue.x); /* L: table key value*/
lua_rawset(L, -3); /* table[key] = value, L: table */
lua_pushstring(L, "y"); /* L: table key */
lua_pushnumber(L, (lua_Number) inValue.y); /* L: table key value*/
lua_rawset(L, -3);
lua_pushstring(L, "z"); /* L: table key */
lua_pushnumber(L, (lua_Number) inValue.z); /* L: table key value*/
lua_rawset(L, -3);
lua_pushstring(L, "w"); /* L: table key */
lua_pushnumber(L, (lua_Number) inValue.w); /* L: table key value*/
lua_rawset(L, -3);
}

View File

@ -235,6 +235,7 @@ bool luaval_to_object(lua_State* L, int lo, const char* type, T** ret)
extern bool luaval_to_mesh_vertex_attrib(lua_State* L, int lo, cocos2d::MeshVertexAttrib* ret, const char* funcName = "");
extern bool luaval_to_std_vector_float(lua_State* L, int lo, std::vector<float>* ret, const char* funcName = "");
extern bool luaval_to_std_vector_ushort(lua_State* L, int lo, std::vector<unsigned short>* ret, const char* funcName = "");
extern bool luaval_to_quaternion(lua_State* L,int lo,cocos2d::Quaternion* outValue, const char* funcName = "");
// from native
extern void vec2_to_luaval(lua_State* L,const cocos2d::Vec2& vec2);
@ -386,5 +387,6 @@ void ccvector_std_string_to_luaval(lua_State* L, const std::vector<std::string>&
void ccvector_int_to_luaval(lua_State* L, const std::vector<int>& inValue);
void ccvector_float_to_luaval(lua_State* L, const std::vector<float>& inValue);
void ccvector_ushort_to_luaval(lua_State* L, const std::vector<unsigned short>& inValue);
void quaternion_to_luaval(lua_State* L,const cocos2d::Quaternion& inValue);
#endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__

View File

@ -7232,3 +7232,254 @@ int register_all_cocos2dx_module_manual(lua_State* tolua_S)
return 0;
}
static int tolua_cocos2d_Mat4_getInversed(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_istable(tolua_S, 1, 0, &tolua_err))
goto tolua_lerror;
else
#endif
{
cocos2d::Mat4 mat;
bool ok = luaval_to_mat4(tolua_S, 1, &mat);
if (ok)
{
mat4_to_luaval(tolua_S, mat.getInversed());
return 1;
}
}
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'mat4_getInversed'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2d_Mat4_transformVector(lua_State* tolua_S)
{
bool ok = true;
int argc = lua_gettop(tolua_S);
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
if (argc == 3)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
!tolua_istable(tolua_S, 2, 0, &tolua_err) ||
!tolua_istable(tolua_S, 3, 0, &tolua_err))
goto tolua_lerror;
else
#endif
{
cocos2d::Mat4 mat;
cocos2d::Vec4 vector;
cocos2d::Vec4 dst;
ok &= luaval_to_mat4(tolua_S, 1, &mat);
if (!ok)
return 0;
ok &= luaval_to_vec4(tolua_S, 2, &vector);
if (!ok)
return 0;
ok &= luaval_to_vec4(tolua_S, 3, &dst);
if (!ok)
return 0;
mat.transformVector(vector, &dst);
vec4_to_luaval(tolua_S, dst);
return 1;
}
}
else if(argc == 6)
{
/*
float x, float y, float z, float w, Vec3* dst
*/
#if COCOS2D_DEBUG >= 1
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 2, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 4, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 5, 0, &tolua_err) ||
!tolua_isnumber(tolua_S, 6, 0, &tolua_err))
goto tolua_lerror;
else
#endif
{
cocos2d::Mat4 mat;
float x,y,z,w;
cocos2d::Vec3 dst;
ok &= luaval_to_mat4(tolua_S, 1, &mat);
if (!ok)
return 0;
x = tolua_tonumber(tolua_S, 2, 0);
y = tolua_tonumber(tolua_S, 3, 0);
z = tolua_tonumber(tolua_S, 4, 0);
w = tolua_tonumber(tolua_S, 5, 0);
ok &= luaval_to_vec3(tolua_S, 6, &dst);
if (!ok)
return 0;
mat.transformVector(x,y,z,w, &dst);
vec3_to_luaval(tolua_S, dst);
return 1;
}
}
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'mat4_transformVector'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2d_Mat4_decompose(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
!tolua_istable(tolua_S, 2, 0, &tolua_err) ||
!tolua_istable(tolua_S, 3, 0, &tolua_err) ||
!tolua_istable(tolua_S, 4, 0, &tolua_err))
goto tolua_lerror;
else
#endif
{
cocos2d::Mat4 mat;
cocos2d::Vec3 scale;
cocos2d::Quaternion rotation;
cocos2d::Vec3 translation;
bool ok = true;
ok &= luaval_to_mat4(tolua_S, 1, &mat);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 2, &scale);
if (!ok)
return 0;
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 2, &translation);
if (!ok)
return 0;
mat.decompose(&scale, &rotation, &translation);
vec3_to_luaval(tolua_S, scale);
quaternion_to_luaval(tolua_S, rotation);
vec3_to_luaval(tolua_S, translation);
return 3;
}
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'mat4_decompose'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2d_Vec3_cross(lua_State* tolua_S)
{
int argc = lua_gettop(tolua_S);
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
if (1 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
!tolua_istable(tolua_S, 2, 0, &tolua_err) )
goto tolua_lerror;
else
#endif
{
cocos2d::Vec3 cobj;
cocos2d::Vec3 v;
bool ok = true;
ok &= luaval_to_vec3(tolua_S, 1, &cobj);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 2, &v);
if (!ok)
return 0;
cobj.cross(v);
vec3_to_luaval(tolua_S, cobj);
return 1;
}
}
else if (3 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
!tolua_istable(tolua_S, 2, 0, &tolua_err) ||
!tolua_istable(tolua_S, 3, 0, &tolua_err) )
goto tolua_lerror;
else
#endif
{
cocos2d::Vec3 v1;
cocos2d::Vec3 v2;
cocos2d::Vec3 dst;
bool ok = true;
ok &= luaval_to_vec3(tolua_S, 1, &v1);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 2, &v2);
if (!ok)
return 0;
ok &= luaval_to_vec3(tolua_S, 3, &dst);
if (!ok)
return 0;
cocos2d::Vec3::cross(v1, v2, &dst);
vec3_to_luaval(tolua_S, dst);
return 1;
}
}
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'MathUtil_gcrossVec3'.",&tolua_err);
return 0;
#endif
}
int register_all_cocos2dx_math_manual(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
tolua_module(tolua_S, nullptr, 0);
tolua_beginmodule(tolua_S, nullptr);
tolua_function(tolua_S, "mat4_getInversed", tolua_cocos2d_Mat4_getInversed);
tolua_function(tolua_S, "mat4_transformVector", tolua_cocos2d_Mat4_transformVector);
tolua_function(tolua_S, "mat4_decompose", tolua_cocos2d_Mat4_decompose);
tolua_function(tolua_S, "vec3_cross", tolua_cocos2d_Vec3_cross);
tolua_endmodule(tolua_S);
return 0;
}

View File

@ -57,6 +57,8 @@ TOLUA_API int register_cocos2dx_event_releated(lua_State* tolua_S);
TOLUA_API int register_all_cocos2dx_module_manual(lua_State* tolua_S);
TOLUA_API int register_all_cocos2dx_math_manual(lua_State* tolua_S);
struct LuaEventAccelerationData
{
void* acc;

View File

@ -367,6 +367,10 @@ function cc.vec3(_x, _y, _z)
return { x = _x, y = _y, z = _z }
end
function cc.vec4(_x, _y, _z, _w)
return { x = _x, y = _y, z = _z, w = _w }
end
function cc.vec3normalize(vec3)
local n = vec3.x * vec3.x + vec3.y * vec3.y + vec3.z * vec3.z
if n == 1.0 then
@ -382,3 +386,45 @@ function cc.vec3normalize(vec3)
n = 1.0 / n
return {x = vec3.x * n, y = vec3.y * n, z = vec3.z * n}
end
function cc.quaternion(_x, _y ,_z,_w)
return { x = _x, y = _y, z = _z, w = _w }
end
cc.mat4 = cc.mat4 or {}
function cc.mat4.new(...)
local params = {...}
local size = #params
local obj = {}
if 1 == size then
assert(type(params[1]) == "table" , "type of input params are wrong to new a mat4 when num of params is 1")
for i= 1, 16 do
if params[1][i] ~= nil then
obj[i] = params[1][i]
else
obj[i] = 0
end
end
elseif 16 == size then
if params[i] ~= nil then
mat4[i] = params[i]
else
mat4[i] = 0
end
end
setmetatable(obj, {__index = cc.mat4})
return obj
end
function cc.mat4.getInversed(self)
return mat4_getInversed(self)
end
function cc.mat4.transformVector(self, vector, dst)
return mat4_transformVector(self, vector, dst)
end

View File

@ -523,3 +523,30 @@ cc.BillBoard_Mode =
VIEW_POINT_ORIENTED = 0,
VIEW_PLANE_ORIENTED = 1,
}
cc.GLProgram_VERTEX_ATTRIB =
{
POSITION = 0,
COLOR = 1,
TEX_COORD = 2,
TEX_COORD1 = 3,
TEX_COORD2 = 4,
TEX_COORD3 = 5,
TEX_COORD4 = 6,
TEX_COORD5 = 7,
TEX_COORD6 = 8,
TEX_COORD7 = 9,
NORMAL = 10,
BLEND_WEIGHT = 11,
BLEND_INDEX =12,
MAX = 13,
--backward compatibility
TEX_COORDS = 2,
}
cc.MATRIX_STACK_TYPE =
{
MODELVIEW = 0,
PROJECTION = 1,
TEXTURE = 2,
}

View File

@ -822,3 +822,5 @@ gl.WRITEONLY_RENDERING_QCOM = 0x8823
gl.WRITE_ONLY_OES = 0x88b9
gl.Z400_BINARY_AMD = 0x8740
gl.ZERO = 0x0
gl.VERTEX_ATTRIB_POINTER_VEC3 = 0
gl.VERTEX_ATTRIB_POINTER_COLOR4B = 1

View File

@ -374,11 +374,19 @@ void Button::onPressStateChangedToNormal()
}
else
{
_buttonNormalRenderer->stopAllActions();
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize);
_titleRenderer->stopAllActions();
_titleRenderer->setScaleX(_normalTextureScaleXInSize);
_titleRenderer->setScaleY(_normalTextureScaleYInSize);
if (_scale9Enabled)
{
_buttonNormalRenderer->setColor(Color3B::WHITE);
}
else
{
_buttonNormalRenderer->stopAllActions();
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize);
_titleRenderer->stopAllActions();
_titleRenderer->setScaleX(_normalTextureScaleXInSize);
_titleRenderer->setScaleY(_normalTextureScaleYInSize);
}
}
}
@ -630,6 +638,11 @@ void Button::setPressedActionEnabled(bool enabled)
void Button::setTitleText(const std::string& text)
{
_titleRenderer->setString(text);
if (_ignoreSize)
{
Size s = getVirtualRendererSize();
this->setContentSize(s);
}
}
const std::string& Button::getTitleText() const

View File

@ -34,6 +34,60 @@
#define getEditBoxImplMac() ((cocos2d::ui::EditBoxImplMac*)editBox_)
@interface CustomTextFieldFormatter : NSFormatter {
int maxLength;
}
- (void)setMaximumLength:(int)len;
- (int)maximumLength;
@end
@implementation CustomTextFieldFormatter
- (id)init {
if(self = [super init]){
maxLength = INT_MAX;
}
return self;
}
- (void)setMaximumLength:(int)len {
maxLength = len;
}
- (int)maximumLength {
return maxLength;
}
- (NSString *)stringForObjectValue:(id)object {
return (NSString *)object;
}
- (BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error {
*object = string;
return YES;
}
- (BOOL)isPartialStringValid:(NSString **)partialStringPtr
proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
originalString:(NSString *)origString
originalSelectedRange:(NSRange)origSelRange
errorDescription:(NSString **)error {
if ([*partialStringPtr length] > maxLength) {
return NO;
}
return YES;
}
- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes {
return nil;
}
@end
@implementation UIEditBoxImplMac
@ -206,28 +260,6 @@
#endif
}
/**
* Delegate method called before the text has been changed.
* @param textField The text field containing the text.
* @param range The range of characters to be replaced.
* @param string The replacement string.
* @return YES if the specified text range should be replaced; otherwise, NO to keep the old text.
*/
- (BOOL)textField:(NSTextField *) textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (getEditBoxImplMac()->getMaxLength() < 0)
{
return YES;
}
NSUInteger oldLength = [[textField stringValue] length];
NSUInteger replacementLength = [string length];
NSUInteger rangeLength = range.length;
NSUInteger newLength = oldLength - rangeLength + replacementLength;
return newLength <= getEditBoxImplMac()->getMaxLength();
}
/**
* Called each time when the text field's text has changed.
@ -364,6 +396,10 @@ void EditBoxImplMac::setInputMode(EditBox::InputMode inputMode)
void EditBoxImplMac::setMaxLength(int maxLength)
{
_maxTextLength = maxLength;
id formater = [[[CustomTextFieldFormatter alloc]init] autorelease];
[formater setMaximumLength:maxLength];
[_sysEdit.secureTextField setFormatter:formater];
[_sysEdit.textField setFormatter:formater];
}
int EditBoxImplMac::getMaxLength()

View File

@ -4124,7 +4124,6 @@
],
"lua": [
"cocos/scripting/lua-bindings/CMakeLists.txt",
"cocos/scripting/lua-bindings/auto/api/AABB.lua",
"cocos/scripting/lua-bindings/auto/api/Action.lua",
"cocos/scripting/lua-bindings/auto/api/ActionCamera.lua",
"cocos/scripting/lua-bindings/auto/api/ActionEase.lua",
@ -4331,7 +4330,6 @@
"cocos/scripting/lua-bindings/auto/api/Node.lua",
"cocos/scripting/lua-bindings/auto/api/NodeGrid.lua",
"cocos/scripting/lua-bindings/auto/api/NodeReader.lua",
"cocos/scripting/lua-bindings/auto/api/OBB.lua",
"cocos/scripting/lua-bindings/auto/api/OrbitCamera.lua",
"cocos/scripting/lua-bindings/auto/api/PageTurn3D.lua",
"cocos/scripting/lua-bindings/auto/api/PageView.lua",

View File

@ -10,4 +10,4 @@
# Project target.
target=android-10
android.library.reference.1=../../../cocos/platform/android/java
android.library.reference.1=../cocos2d/cocos/platform/android/java

View File

@ -80,7 +80,8 @@ static std::function<Layer*()> createFunctions[] =
CL(LabelIssue4428Test),
CL(LabelIssue4999Test),
CL(LabelLineHeightTest),
CL(LabelAdditionalKerningTest)
CL(LabelAdditionalKerningTest),
CL(LabelIssue8492Test)
};
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
@ -1814,3 +1815,21 @@ std::string LabelAdditionalKerningTest::subtitle() const
{
return "Testing additional kerning of label";
}
LabelIssue8492Test::LabelIssue8492Test()
{
auto label = Label::createWithBMFont("fonts/bitmapFontChinese.fnt", "中国中国中国中国中国");
label->setDimensions(5,100);
label->setPosition(VisibleRect::center());
addChild(label);
}
std::string LabelIssue8492Test::title() const
{
return "Reorder issue #8492";
}
std::string LabelIssue8492Test::subtitle() const
{
return "Work fine when dimensions are not enough to fit one character";
}

View File

@ -509,6 +509,17 @@ private:
Label* label;
};
class LabelIssue8492Test : public AtlasDemoNew
{
public:
CREATE_FUNC(LabelIssue8492Test);
LabelIssue8492Test();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
// we don't support linebreak mode
#endif

View File

@ -37,6 +37,8 @@ bool UIButtonTest::init()
// Create the button
Button* button = Button::create("cocosui/animationbuttonnormal.png");
CCLOG("content size should be greater than 0: width = %f, height = %f", button->getContentSize().width,
button->getContentSize().height);
button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest::touchEvent, this));
button->setZoomScale(0.4f);
@ -632,7 +634,10 @@ bool UIButtonTextOnly::init()
// Create the button
auto button = Button::create();
button->setNormalizedPosition(Vec2(0.5f, 0.5f));
button->setTitleText("PLAY GAME");
CCLOG("content size should be greater than 0: width = %f, height = %f", button->getContentSize().width,
button->getContentSize().height);
button->setZoomScale(0.3f);
button->setPressedActionEnabled(true);
button->addClickEventListener([this](Ref* sender) {

View File

@ -3,6 +3,7 @@ set(APP_NAME lua-tests)
set(SAMPLE_SRC
Classes/AppDelegate.cpp
Classes/lua_assetsmanager_test_sample.cpp
Classes/lua_test_bindings.cpp
)
if(LINUX)

View File

@ -4,6 +4,7 @@
#include "audio/include/SimpleAudioEngine.h"
#include "lua_assetsmanager_test_sample.h"
#include "lua_module_register.h"
#include "lua_test_bindings.h"
using namespace CocosDenshion;
@ -43,6 +44,7 @@ bool AppDelegate::applicationDidFinishLaunching()
if (lua_istable(L,-1))//stack:...,_G,
{
register_assetsmanager_test_sample(L);
register_test_binding(L);
}
lua_pop(L, 1);
#endif

View File

@ -0,0 +1,621 @@
#include "lua_test_bindings.h"
#include "cocos2d.h"
#include "LuaBasicConversions.h"
NS_CC_BEGIN
/**
* Copy DrawNode for 3D geometry drawing.
*/
class DrawNode3D: public Node
{
public:
/** creates and initialize a DrawNode3D node */
static DrawNode3D* create();
/**
* Draw 3D Line
*/
void drawLine(const Vec3 &from, const Vec3 &to, const Color4F &color);
/**
* Draw 3D cube
* @param point to a vertex array who has 8 element.
* vertices[0]:Left-top-front,
* vertices[1]:Left-bottom-front,
* vertices[2]:Right-bottom-front,
* vertices[3]:Right-top-front,
* vertices[4]:Right-top-back,
* vertices[5]:Right-bottom-back,
* vertices[6]:Left-bottom-back,
* vertices[7]:Left-top-back.
* @param color
*/
void drawCube(Vec3* vertices, const Color4F &color);
/** Clear the geometry in the node's buffer. */
void clear();
/**
* @js NA
* @lua NA
*/
const BlendFunc& getBlendFunc() const;
/**
* @code
* When this function bound into js or lua,the parameter will be changed
* In js: var setBlendFunc(var src, var dst)
* @endcode
* @lua NA
*/
void setBlendFunc(const BlendFunc &blendFunc);
void onDraw(const Mat4 &transform, uint32_t flags);
// Overrides
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
CC_CONSTRUCTOR_ACCESS:
DrawNode3D();
virtual ~DrawNode3D();
virtual bool init();
protected:
struct V3F_C4B
{
Vec3 vertices;
Color4B colors;
};
void ensureCapacity(int count);
GLuint _vao;
GLuint _vbo;
int _bufferCapacity;
GLsizei _bufferCount;
V3F_C4B* _buffer;
BlendFunc _blendFunc;
CustomCommand _customCommand;
bool _dirty;
private:
CC_DISALLOW_COPY_AND_ASSIGN(DrawNode3D);
};
DrawNode3D::DrawNode3D()
: _vao(0)
, _vbo(0)
, _bufferCapacity(0)
, _bufferCount(0)
, _buffer(nullptr)
, _dirty(false)
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
}
DrawNode3D::~DrawNode3D()
{
free(_buffer);
_buffer = nullptr;
glDeleteBuffers(1, &_vbo);
_vbo = 0;
if (Configuration::getInstance()->supportsShareableVAO())
{
glDeleteVertexArrays(1, &_vao);
GL::bindVAO(0);
_vao = 0;
}
}
DrawNode3D* DrawNode3D::create()
{
DrawNode3D* ret = new (std::nothrow) DrawNode3D();
if (ret && ret->init())
{
ret->autorelease();
}
else
{
CC_SAFE_DELETE(ret);
}
return ret;
}
void DrawNode3D::ensureCapacity(int count)
{
CCASSERT(count>=0, "capacity must be >= 0");
if(_bufferCount + count > _bufferCapacity)
{
_bufferCapacity += MAX(_bufferCapacity, count);
_buffer = (V3F_C4B*)realloc(_buffer, _bufferCapacity*sizeof(V3F_C4B));
}
}
bool DrawNode3D::init()
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_COLOR));
ensureCapacity(512);
if (Configuration::getInstance()->supportsShareableVAO())
{
glGenVertexArrays(1, &_vao);
GL::bindVAO(_vao);
}
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, vertices));
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, colors));
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(0);
}
CHECK_GL_ERROR_DEBUG();
_dirty = true;
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){
/** listen the event that coming to foreground on Android */
this->init();
});
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
#endif
return true;
}
void DrawNode3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_customCommand.init(_globalZOrder);
_customCommand.func = CC_CALLBACK_0(DrawNode3D::onDraw, this, transform, flags);
renderer->addCommand(&_customCommand);
}
void DrawNode3D::onDraw(const Mat4 &transform, uint32_t flags)
{
auto glProgram = getGLProgram();
glProgram->use();
glProgram->setUniformsForBuiltins(transform);
glEnable(GL_DEPTH_TEST);
GL::blendFunc(_blendFunc.src, _blendFunc.dst);
if (_dirty)
{
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B)*_bufferCapacity, _buffer, GL_STREAM_DRAW);
_dirty = false;
}
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(_vao);
}
else
{
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
// vertex
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, vertices));
// color
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B), (GLvoid *)offsetof(V3F_C4B, colors));
}
glDrawArrays(GL_LINES, 0, _bufferCount);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCount);
glDisable(GL_DEPTH_TEST);
CHECK_GL_ERROR_DEBUG();
}
void DrawNode3D::drawLine(const Vec3 &from, const Vec3 &to, const Color4F &color)
{
unsigned int vertex_count = 2;
ensureCapacity(vertex_count);
Color4B col = Color4B(color);
V3F_C4B a = {Vec3(from.x, from.y, from.z), col};
V3F_C4B b = {Vec3(to.x, to.y, to.z), col, };
V3F_C4B *lines = (V3F_C4B *)(_buffer + _bufferCount);
lines[0] = a;
lines[1] = b;
_bufferCount += vertex_count;
_dirty = true;
}
void DrawNode3D::drawCube(Vec3* vertices, const Color4F &color)
{
// front face
drawLine(vertices[0], vertices[1], color);
drawLine(vertices[1], vertices[2], color);
drawLine(vertices[2], vertices[3], color);
drawLine(vertices[3], vertices[0], color);
// back face
drawLine(vertices[4], vertices[5], color);
drawLine(vertices[5], vertices[6], color);
drawLine(vertices[6], vertices[7], color);
drawLine(vertices[7], vertices[4], color);
// edge
drawLine(vertices[0], vertices[7], color);
drawLine(vertices[1], vertices[6], color);
drawLine(vertices[2], vertices[5], color);
drawLine(vertices[3], vertices[4], color);
}
void DrawNode3D::clear()
{
_bufferCount = 0;
_dirty = true;
}
const BlendFunc& DrawNode3D::getBlendFunc() const
{
return _blendFunc;
}
void DrawNode3D::setBlendFunc(const BlendFunc &blendFunc)
{
_blendFunc = blendFunc;
}
NS_CC_END
int lua_cocos2dx_DrawNode3D_getBlendFunc(lua_State* L)
{
int argc = 0;
cocos2d::DrawNode3D* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_getBlendFunc'", nullptr);
return 0;
}
#endif
argc = lua_gettop(L)-1;
if (argc == 0)
{
if(!ok)
return 0;
const cocos2d::BlendFunc& ret = cobj->getBlendFunc();
blendfunc_to_luaval(L, ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:getBlendFunc",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_getBlendFunc'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_DrawNode3D_setBlendFunc(lua_State* L)
{
int argc = 0;
cocos2d::DrawNode3D* cobj = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_setBlendFunc'", nullptr);
return 0;
}
#endif
argc = lua_gettop(L)-1;
if (argc == 2)
{
GLenum src, dst;
if (!luaval_to_int32(L, 2, (int32_t*)&src, "cc.DrawNode3D:setBlendFunc"))
return 0;
if (!luaval_to_int32(L, 3, (int32_t*)&dst, "cc.DrawNode3D:setBlendFunc"))
return 0;
BlendFunc blendFunc = {src, dst};
cobj->setBlendFunc(blendFunc);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:setBlendFunc",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_setBlendFunc'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_DrawNode3D_drawLine(lua_State* L)
{
int argc = 0;
cocos2d::DrawNode3D* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_drawLine'", nullptr);
return 0;
}
#endif
argc = lua_gettop(L)-1;
if (argc == 3)
{
cocos2d::Vec3 arg0;
cocos2d::Vec3 arg1;
cocos2d::Color4F arg2;
ok &= luaval_to_vec3(L, 2, &arg0, "cc.DrawNode3D:drawLine");
ok &= luaval_to_vec3(L, 3, &arg1, "cc.DrawNode3D:drawLine");
ok &=luaval_to_color4f(L, 4, &arg2, "cc.DrawNode3D:drawLine");
if(!ok)
return 0;
cobj->drawLine(arg0, arg1, arg2);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:drawLine",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_drawLine'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_DrawNode3D_clear(lua_State* L)
{
int argc = 0;
cocos2d::DrawNode3D* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_clear'", nullptr);
return 0;
}
#endif
argc = lua_gettop(L)-1;
if (argc == 0)
{
if(!ok)
return 0;
cobj->clear();
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:clear",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_clear'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_DrawNode3D_drawCube(lua_State* L)
{
int argc = 0;
cocos2d::DrawNode3D* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::DrawNode3D*)tolua_tousertype(L,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(L,"invalid 'cobj' in function 'lua_cocos2dx_DrawNode3D_drawCube'", nullptr);
return 0;
}
#endif
argc = lua_gettop(L)-1;
if (argc == 2)
{
std::vector<cocos2d::Vec3> arg0;
cocos2d::Color4F arg1;
Vec3 vec3;
#if COCOS2D_DEBUG >= 1
if (!tolua_istable(L, 2, 0, &tolua_err))
goto tolua_lerror;
#endif
size_t size = lua_objlen(L, 2);
for (int i = 0; i < size; i++)
{
lua_pushnumber(L, i + 1);
lua_gettable(L, 2);
#ifndef TOLUA_RELEASE
if (!tolua_istable(L, -1, 0, &tolua_err))
{
lua_pop(L, 1);
goto tolua_lerror;
}
#endif
ok &= luaval_to_vec3(L, lua_gettop(L), &vec3);
#ifndef TOLUA_RELEASE
if (!ok)
{
lua_pop(L, 1);
goto tolua_lerror;
}
#endif
//arg0[i] = vec3;
arg0.push_back(vec3);
lua_pop(L, 1);
}
ok &=luaval_to_color4f(L, 3, &arg1, "cc.DrawNode3D:drawCube");
if(!ok)
return 0;
cobj->drawCube(&arg0[0], arg1);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.DrawNode3D:drawCube",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_drawCube'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_DrawNode3D_create(lua_State* L)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(L,1,"cc.DrawNode3D",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(L) - 1;
if (argc == 0)
{
if(!ok)
return 0;
cocos2d::DrawNode3D* ret = cocos2d::DrawNode3D::create();
object_to_luaval<cocos2d::DrawNode3D>(L, "cc.DrawNode3D",(cocos2d::DrawNode3D*)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "cc.DrawNode3D:create",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'lua_cocos2dx_DrawNode3D_create'.",&tolua_err);
#endif
return 0;
}
int lua_register_cocos2dx_DrawNode3D(lua_State* L)
{
tolua_usertype(L,"cc.DrawNode3D");
tolua_cclass(L,"DrawNode3D","cc.DrawNode3D","cc.Node",nullptr);
tolua_beginmodule(L,"DrawNode3D");
tolua_function(L,"getBlendFunc",lua_cocos2dx_DrawNode3D_getBlendFunc);
tolua_function(L,"setBlendFunc",lua_cocos2dx_DrawNode3D_setBlendFunc);
tolua_function(L,"drawLine",lua_cocos2dx_DrawNode3D_drawLine);
tolua_function(L,"clear",lua_cocos2dx_DrawNode3D_clear);
tolua_function(L,"drawCube",lua_cocos2dx_DrawNode3D_drawCube);
tolua_function(L,"create", lua_cocos2dx_DrawNode3D_create);
tolua_endmodule(L);
std::string typeName = typeid(cocos2d::DrawNode3D).name();
g_luaType[typeName] = "cc.DrawNode3D";
g_typeCast["DrawNode3D"] = "cc.DrawNode3D";
return 1;
}
int register_test_binding(lua_State* L)
{
tolua_open(L);
tolua_module(L, "cc", 0);
tolua_beginmodule(L, "cc");
lua_register_cocos2dx_DrawNode3D(L);
tolua_endmodule(L);
return 0;
}

View File

@ -0,0 +1,14 @@
#ifndef COCOS2DX_TEST_LUA_TESTS_PROJECT_CLASSES_LUA_TEST_BINDINGS_H
#define COCOS2DX_TEST_LUA_TESTS_PROJECT_CLASSES_LUA_TEST_BINDINGS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tolua++.h"
#ifdef __cplusplus
}
#endif
TOLUA_API int register_test_binding(lua_State* tolua_S);
#endif // #ifndef COCOS2DX_TEST_LUA_TESTS_PROJECT_CLASSES_LUA_TEST_BINDINGS_H

View File

@ -8,7 +8,8 @@ LOCAL_MODULE_FILENAME := liblua_tests
LOCAL_SRC_FILES += main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/lua_assetsmanager_test_sample.cpp
../../Classes/lua_assetsmanager_test_sample.cpp \
../../Classes/lua_test_bindings.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes

View File

@ -182,12 +182,14 @@ xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(ProjectDir)..\..\res" /e /Y
<ItemGroup>
<ClInclude Include="..\Classes\AppDelegate.h" />
<ClInclude Include="..\Classes\lua_assetsmanager_test_sample.h" />
<ClInclude Include="..\Classes\lua_test_bindings.h" />
<ClInclude Include="..\Classes\lua_module_register.h" />
<ClInclude Include="main.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Classes\AppDelegate.cpp" />
<ClCompile Include="..\Classes\lua_assetsmanager_test_sample.cpp" />
<ClCompile Include="..\Classes\lua_test_bindings.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>

View File

@ -21,6 +21,9 @@
<ClInclude Include="..\Classes\lua_module_register.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="..\Classes\lua_test_bindings.h">
<Filter>Classes</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Classes\AppDelegate.cpp">
@ -32,5 +35,8 @@
<ClCompile Include="..\Classes\lua_assetsmanager_test_sample.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="..\Classes\lua_test_bindings.cpp">
<Filter>Classes</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -413,7 +413,22 @@ function Camera3DTestDemo:onEnter()
self:SwitchViewCallback(self, CameraType.ThirdCamera)
--UNDO DrawLine3D drwaline
local line = cc.DrawNode3D:create()
--draw x
for i = -20 ,20 do
line:drawLine(cc.vec3(-100, 0, 5 * i), cc.vec3(100, 0, 5 * i), cc.c4f(1, 0, 0, 0))
end
--draw z
for i = -20, 20 do
line:drawLine(cc.vec3(5 * i, 0, -100), cc.vec3(5 * i, 0, 100), cc.c4f(0, 0, 1, 1))
end
--draw y
line:drawLine(cc.vec3(0, -50, 0), cc.vec3(0,0,0), cc.c4f(0, 0.5, 0, 1))
line:drawLine(cc.vec3(0, 0, 0), cc.vec3(0,50,0), cc.c4f(0, 1, 0, 1))
self._layer3D:addChild(line)
self._layer3D:setCameraMask(2)
end

View File

@ -629,6 +629,245 @@ function Sprite3DReskinTest.create()
return layer
end
----------------------------------------
----Sprite3DWithOBBPerfromanceTest
----------------------------------------
local Sprite3DWithOBBPerfromanceTest = class("Sprite3DWithOBBPerfromanceTest",function()
return cc.Layer:create()
end)
function Sprite3DWithOBBPerfromanceTest:ctor()
self._obb = {}
local listener = cc.EventListenerTouchAllAtOnce:create()
listener:registerScriptHandler(function (touches, event)
for i,touch in ipairs(touches) do
local location = touch:getLocationInView()
if nil ~= self._obb and #self._obb > 0 then
self._intersetList = {}
local ray = cc.Ray:new()
self:calculateRayByLocationInView(ray, location)
for idx,value in ipairs(self._obb) do
if ray:intersects(value) then
table.insert(self._intersetList, idx)
return
end
end
end
end
end,cc.Handler.EVENT_TOUCHES_BEGAN)
listener:registerScriptHandler(function (touches, event)
end,cc.Handler.EVENT_TOUCHES_ENDED)
listener:registerScriptHandler(function (touches, event)
for i,touch in ipairs(touches) do
local location = touch:getLocation()
for idx,value in ipairs(self._obb) do
for lstIdx,lstValue in ipairs(self._intersetList) do
if idx == lstValue then
self._obb[idx]._center = cc.vec3(location.x,location.y,0)
end
end
end
end
end,cc.Handler.EVENT_TOUCHES_MOVED)
local eventDispatcher = self:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self)
local s = cc.Director:getInstance():getWinSize()
self:initDrawBox()
self:addNewSpriteWithCoords(cc.p(s.width/2, s.height/2))
cc.MenuItemFont:setFontName("fonts/arial.ttf")
cc.MenuItemFont:setFontSize(65)
local decrease = cc.MenuItemFont:create(" - ")
decrease:registerScriptTapHandler(function(tag, sender)
self:delOBBWithCount(10)
end)
decrease:setColor(cc.c3b(0, 200, 20))
local increase = cc.MenuItemFont:create(" + ")
increase:registerScriptTapHandler(function(tag, sender)
self:addOBBWithCount(10)
end)
increase:setColor(cc.c3b(0, 200, 20))
local menu = cc.Menu:create(decrease, increase)
menu:alignItemsHorizontally()
menu:setPosition(cc.p(s.width/2, s.height - 90))
self:addChild(menu, 1)
local ttfConfig = {}
ttfConfig.fontFilePath = "fonts/Marker Felt.ttf"
ttfConfig.fontSize = 30
self._labelCubeCount = cc.Label:createWithTTF(ttfConfig,"0 cubes")
self._labelCubeCount:setColor(cc.c3b(0,200,20))
self._labelCubeCount:setPosition(cc.p(s.width/2, s.height-90))
self:addChild(self._labelCubeCount)
self:addOBBWithCount(10)
self:scheduleUpdateWithPriorityLua(function(dt)
self._labelCubeCount:setString(string.format("%u cubes", #self._obb))
if nil ~= self._drawDebug then
self._drawDebug:clear()
local mat = self._sprite:getNodeToWorldTransform()
self._obbt._xAxis = cc.vec3(mat[1], mat[2], mat[3])
self._obbt._xAxis = cc.vec3normalize(self._obbt._xAxis)
self._obbt._yAxis = cc.vec3(mat[5], mat[6], mat[7])
self._obbt._yAxis = cc.vec3normalize(self._obbt._yAxis)
self._obbt._zAxis = cc.vec3(-mat[9], -mat[10], -mat[11])
self._obbt._zAxis = cc.vec3normalize(self._obbt._zAxis)
self._obbt._center = self._sprite:getPosition3D()
local corners = {}
for i=1,8 do
corners[i] = {}
end
corners = self._obbt:getCorners(corners)
self._drawDebug:drawCube(corners, cc.c4f(0, 0, 1, 1))
end
if #self._obb > 0 then
self._drawOBB:clear()
for i= 1, #self._obb do
local corners = {}
for i=1,8 do
corners[i] = {}
end
corners = self._obb[i]:getCorners(corners)
if self._obbt:intersects(self._obb[i]) then
self._drawOBB:drawCube(corners, cc.c4f(1, 0, 0, 1))
else
self._drawOBB:drawCube(corners, cc.c4f(0, 1, 0, 1))
end
end
end
end, 0)
end
function Sprite3DWithOBBPerfromanceTest:addOBBWithCount( value )
for i=1,value do
local randompos = cc.p(math.random() * cc.Director:getInstance():getWinSize().width, math.random() * cc.Director:getInstance():getWinSize().height)
local extents = cc.vec3(10, 10, 10)
local aabb = cc.AABB:new({x = -10, y = -10, z = -10}, extents)
local obb = cc.OBB:new(aabb)
obb._center = cc.vec3(randompos.x,randompos.y,0)
table.insert(self._obb, obb)
end
end
function Sprite3DWithOBBPerfromanceTest:delOBBWithCount( value )
if #self._obb >= 10 then
for i= 1, 10 do
table.remove(self._obb)
end
self._drawOBB:clear()
end
end
function Sprite3DWithOBBPerfromanceTest:initDrawBox()
self._drawOBB = cc.DrawNode3D:create()
self:addChild(self._drawOBB )
end
function Sprite3DWithOBBPerfromanceTest:unproject( viewProjection, viewport, src, dst)
assert(viewport.width ~= 0.0 and viewport.height ~= 0)
local screen = cc.vec4(src.x / viewport.width, (viewport.height - src.y) / viewport.height, src.z, 1.0)
screen.x = screen.x * 2.0 - 1.0
screen.y = screen.y * 2.0 - 1.0
screen.z = screen.z * 2.0 - 1.0
local inversed = cc.mat4.new(viewProjection:getInversed())
screen = inversed:transformVector(screen, screen)
if screen.w ~= 0.0 then
screen.x = screen.x / screen.w
screen.y = screen.y / screen.w
screen.z = screen.z / screen.w
end
dst.x = screen.x
dst.y = screen.y
dst.z = screen.z
return viewport, src, dst
end
function Sprite3DWithOBBPerfromanceTest:calculateRayByLocationInView(ray, location)
local dir = cc.Director:getInstance()
local view = dir:getWinSize()
local mat = cc.mat4.new(dir:getMatrix(cc.MATRIX_STACK_TYPE.PROJECTION))
local src = cc.vec3(location.x, location.y, -1)
local nearPoint = {}
view, src, nearPoint = self:unproject(mat, view, src, nearPoint)
src = cc.vec3(location.x, location.y, 1)
local farPoint = {}
view, src, farPoint = self:unproject(mat, view, src, farPoint)
local direction = {}
direction.x = farPoint.x - nearPoint.x
direction.y = farPoint.y - nearPoint.y
direction.z = farPoint.z - nearPoint.z
direction = cc.vec3normalize(direction)
ray._origin = nearPoint
ray._direction = direction
end
function Sprite3DWithOBBPerfromanceTest:addNewSpriteWithCoords(vec2)
local fileName = "Sprite3DTest/tortoise.c3b"
local sprite = cc.Sprite3D:create(fileName)
sprite:setScale(0.1)
local s = cc.Director:getInstance():getWinSize()
sprite:setPosition(cc.p(s.width * 4.0 / 5.0, s.height / 2.0))
self:addChild(sprite)
self._sprite = sprite
local animation = cc.Animation3D:create(fileName)
if nil ~= animation then
local animate = cc.Animate3D:create(animation, 0.0, 1.933)
sprite:runAction(cc.RepeatForever:create(animate))
end
self._moveAction = cc.MoveTo:create(4.0, cc.p(s.width / 5.0, s.height / 2.0))
self._moveAction:retain()
local function reachEndCallBack()
self._sprite:stopActionByTag(100)
local inverse = self._moveAction:reverse()
inverse:retain()
self._moveAction:release()
self._moveAction = inverse
local rot = cc.RotateBy:create(1.0, { x = 0.0, y = 180.0, z = 0.0})
local seq = cc.Sequence:create(rot, self._moveAction, cc.CallFunc:create(reachEndCallBack))
seq:setTag(100)
self._sprite:runAction(seq)
end
local seq = cc.Sequence:create(self._moveAction, cc.CallFunc:create(reachEndCallBack))
seq:setTag(100)
sprite:runAction(seq)
local aabb = self._sprite:getAABB()
self._obbt = cc.OBB:new(aabb)
self._drawDebug = cc.DrawNode3D:create()
self:addChild(self._drawDebug)
end
function Sprite3DWithOBBPerfromanceTest.create()
local layer = Sprite3DWithOBBPerfromanceTest.new()
Helper.initWithLayer(layer)
Helper.titleLabel:setString("OBB Collison Perfromance Test")
return layer
end
----------------------------------------
----Sprite3DMirrorTest
----------------------------------------
@ -680,7 +919,6 @@ function Sprite3DMirrorTest.create()
return layer
end
function Sprite3DTest()
local scene = cc.Scene:create()
@ -692,6 +930,7 @@ function Sprite3DTest()
Animate3DTest.create,
AttachmentTest.create,
Sprite3DReskinTest.create,
Sprite3DWithOBBPerfromanceTest.create,
Sprite3DMirrorTest.create,
}

@ -1 +1 @@
Subproject commit 1a71fe7be45db504f3bdc0e24e8d7eca83f2fc1a
Subproject commit b49fad3fb2dbc396e71a5b1178cf2532309cd174

View File

@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.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 AABB OBB BillBoard
classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard
# 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
@ -39,8 +39,6 @@ skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getMeshVertexAttrib
Sprite3D::[getSkin getAABB setBlendFunc],
Skeleton3D::[create],
Animation3D::[getBoneCurveByName],
AABB::[intersects merge],
OBB::[intersects],
BillBoard::[draw]
@ -59,7 +57,7 @@ base_classes_to_skip = Clonable
# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes = OBB
abstract_classes =
# 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