From 813e954f4e0d482222d975fa29d83715ec04ecf9 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 8 Aug 2014 00:00:58 +0800 Subject: [PATCH 01/42] aabb, obb --- build/cocos2d_libs.xcodeproj/project.pbxproj | 24 + cocos/3d/CCAABB.cpp | 186 ++++++++ cocos/3d/CCAABB.h | 114 +++++ cocos/3d/CCOBB.cpp | 439 +++++++++++++++++++ cocos/3d/CCOBB.h | 117 +++++ cocos/3d/CMakeLists.txt | 2 + cocos/Android.mk | 2 + templates/cocos2dx_files.json | 4 + 8 files changed, 888 insertions(+) create mode 100755 cocos/3d/CCAABB.cpp create mode 100755 cocos/3d/CCAABB.h create mode 100755 cocos/3d/CCOBB.cpp create mode 100755 cocos/3d/CCOBB.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index f6336e4b6a..c9cb06ded3 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -584,6 +584,14 @@ 3E6176771960F89B00DE83F5 /* CCEventListenerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */; }; 3E6176781960F89B00DE83F5 /* CCGameController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E6176651960F89B00DE83F5 /* CCGameController.h */; }; 3E61781D1966A5A300DE83F5 /* CCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E61781C1966A5A300DE83F5 /* CCController.cpp */; }; + 3E9E75E41993D8E4005B7047 /* CCAABB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E75E01993D8E4005B7047 /* CCAABB.cpp */; }; + 3E9E75E51993D8E4005B7047 /* CCAABB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E75E01993D8E4005B7047 /* CCAABB.cpp */; }; + 3E9E75E61993D8E4005B7047 /* CCAABB.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E75E11993D8E4005B7047 /* CCAABB.h */; }; + 3E9E75E71993D8E4005B7047 /* CCAABB.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E75E11993D8E4005B7047 /* CCAABB.h */; }; + 3E9E75E81993D8E4005B7047 /* CCOBB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E75E21993D8E4005B7047 /* CCOBB.cpp */; }; + 3E9E75E91993D8E4005B7047 /* CCOBB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E75E21993D8E4005B7047 /* CCOBB.cpp */; }; + 3E9E75EA1993D8E4005B7047 /* CCOBB.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E75E31993D8E4005B7047 /* CCOBB.h */; }; + 3E9E75EB1993D8E4005B7047 /* CCOBB.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E75E31993D8E4005B7047 /* CCOBB.h */; }; 3E9E80E9198639EF00FA95D0 /* CCAttachNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E3198639EF00FA95D0 /* CCAttachNode.cpp */; }; 3E9E80EA198639EF00FA95D0 /* CCAttachNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E3198639EF00FA95D0 /* CCAttachNode.cpp */; }; 3E9E80EB198639EF00FA95D0 /* CCAttachNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E4198639EF00FA95D0 /* CCAttachNode.h */; }; @@ -2477,6 +2485,10 @@ 3E6176641960F89B00DE83F5 /* CCEventListenerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCEventListenerController.h; path = ../base/CCEventListenerController.h; sourceTree = ""; }; 3E6176651960F89B00DE83F5 /* CCGameController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCGameController.h; path = ../base/CCGameController.h; sourceTree = ""; }; 3E61781C1966A5A300DE83F5 /* CCController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCController.cpp; path = ../base/CCController.cpp; sourceTree = ""; }; + 3E9E75E01993D8E4005B7047 /* CCAABB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAABB.cpp; sourceTree = ""; }; + 3E9E75E11993D8E4005B7047 /* CCAABB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAABB.h; sourceTree = ""; }; + 3E9E75E21993D8E4005B7047 /* CCOBB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCOBB.cpp; sourceTree = ""; }; + 3E9E75E31993D8E4005B7047 /* CCOBB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCOBB.h; sourceTree = ""; }; 3E9E80E3198639EF00FA95D0 /* CCAttachNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAttachNode.cpp; sourceTree = ""; }; 3E9E80E4198639EF00FA95D0 /* CCAttachNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAttachNode.h; sourceTree = ""; }; 3E9E80E5198639EF00FA95D0 /* CCSubMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSubMesh.cpp; sourceTree = ""; }; @@ -5202,6 +5214,10 @@ B29594B81926D61F003EEF37 /* 3d */ = { isa = PBXGroup; children = ( + 3E9E75E01993D8E4005B7047 /* CCAABB.cpp */, + 3E9E75E11993D8E4005B7047 /* CCAABB.h */, + 3E9E75E21993D8E4005B7047 /* CCOBB.cpp */, + 3E9E75E31993D8E4005B7047 /* CCOBB.h */, 3EA3EDCA199234B500645534 /* CCDrawNode3D.cpp */, 3EA3EDCB199234B500645534 /* CCDrawNode3D.h */, 3EA2A83E1987A6810077B3D4 /* CCSkeleton3D.cpp */, @@ -5339,6 +5355,7 @@ 1A570216180BCBF40088DEC7 /* CCRenderTexture.h in Headers */, 1A01C69618F57BE800EFE3A6 /* CCInteger.h in Headers */, 3EA3EDCE199234B500645534 /* CCDrawNode3D.h in Headers */, + 3E9E75EA1993D8E4005B7047 /* CCOBB.h in Headers */, 1A570223180BCC1A0088DEC7 /* CCParticleBatchNode.h in Headers */, 50ABBD891925AB4100A911A9 /* CCCustomCommand.h in Headers */, 5034CA43191D591100CE6051 /* ccShader_Label.vert in Headers */, @@ -5387,6 +5404,7 @@ 50ABBDBB1925AB4100A911A9 /* CCTextureAtlas.h in Headers */, 1A570302180BCE890088DEC7 /* CCParallaxNode.h in Headers */, 50ABBE4B1925AB6F00A911A9 /* CCEventAcceleration.h in Headers */, + 3E9E75E61993D8E4005B7047 /* CCAABB.h in Headers */, 1A57030E180BCF190088DEC7 /* CCComponent.h in Headers */, 3E9E80EF198639EF00FA95D0 /* CCSubMesh.h in Headers */, 1A570312180BCF190088DEC7 /* CCComponentContainer.h in Headers */, @@ -5621,6 +5639,7 @@ 503DD8EF1926736A00CD74DD /* CCPlatformDefine.h in Headers */, 46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */, 50ABBD3B1925AB0000A911A9 /* CCAffineTransform.h in Headers */, + 3E9E75EB1993D8E4005B7047 /* CCOBB.h in Headers */, 5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture.vert in Headers */, 50ABBE7C1925AB6F00A911A9 /* CCEventMouse.h in Headers */, B29594D11926D61F003EEF37 /* CCSprite3DMaterial.h in Headers */, @@ -5851,6 +5870,7 @@ B6B2634019381FBF0088FE25 /* CCAnimationCurve.h in Headers */, B6B26346193884D60088FE25 /* CCAnimation3D.h in Headers */, B6ACD89A193D6693005E0B8A /* CCMeshSkin.h in Headers */, + 3E9E75E71993D8E4005B7047 /* CCAABB.h in Headers */, B6ACD8A1193DC0CC005E0B8A /* CCAnimate3D.h in Headers */, B6AAF84419404E0D0069DE01 /* CCBundle3D.h in Headers */, ); @@ -6885,6 +6905,7 @@ 50ABBD481925AB0000A911A9 /* Mat4.cpp in Sources */, 50ABBD8F1925AB4100A911A9 /* CCGLProgramCache.cpp in Sources */, 50ABBD441925AB0000A911A9 /* CCVertex.cpp in Sources */, + 3E9E75E81993D8E4005B7047 /* CCOBB.cpp in Sources */, 503DD8F71926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */, 50ABBE751925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */, 50ABBE511925AB6F00A911A9 /* CCEventDispatcher.cpp in Sources */, @@ -6904,6 +6925,7 @@ 50ABBECF1925AB6F00A911A9 /* TGAlib.cpp in Sources */, 50ABBE451925AB6F00A911A9 /* CCEvent.cpp in Sources */, 50ABBE611925AB6F00A911A9 /* CCEventListenerAcceleration.cpp in Sources */, + 3E9E75E41993D8E4005B7047 /* CCAABB.cpp in Sources */, 50ABBD9F1925AB4100A911A9 /* CCGroupCommand.cpp in Sources */, 50ABBD871925AB4100A911A9 /* CCCustomCommand.cpp in Sources */, 50ABBDBD1925AB4100A911A9 /* CCTextureCache.cpp in Sources */, @@ -7099,6 +7121,7 @@ 50ABBE6E1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */, 50ABBE461925AB6F00A911A9 /* CCEvent.cpp in Sources */, 50ABBEA01925AB6F00A911A9 /* CCScheduler.cpp in Sources */, + 3E9E75E91993D8E4005B7047 /* CCOBB.cpp in Sources */, 3E9E80EA198639EF00FA95D0 /* CCAttachNode.cpp in Sources */, 3EA3EDCD199234B500645534 /* CCDrawNode3D.cpp in Sources */, 50ABBE4E1925AB6F00A911A9 /* CCEventCustom.cpp in Sources */, @@ -7107,6 +7130,7 @@ 1A570076180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */, B37510851823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */, 50ABBD551925AB0000A911A9 /* TransformUtils.cpp in Sources */, + 3E9E75E51993D8E4005B7047 /* CCAABB.cpp in Sources */, 1A57007A180BC5A10088DEC7 /* CCActionInstant.cpp in Sources */, 50ABBEC01925AB6F00A911A9 /* CCValue.cpp in Sources */, 50ABBD591925AB0000A911A9 /* Vec2.cpp in Sources */, diff --git a/cocos/3d/CCAABB.cpp b/cocos/3d/CCAABB.cpp new file mode 100755 index 0000000000..0cc13f2e46 --- /dev/null +++ b/cocos/3d/CCAABB.cpp @@ -0,0 +1,186 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "3d/CCAABB.h" + +NS_CC_BEGIN + +AABB::AABB() +{ + reset(); +} + +AABB::AABB(const Vec3& min, const Vec3& max) +{ + set(min, max); +} + +AABB::AABB(const AABB& box) +{ + set(box._min,box._max); +} + +Vec3 AABB::getCenter() +{ + Vec3 center; + center.x = 0.5f*(_min.x+_max.x); + center.y = 0.5f*(_min.y+_max.y); + center.z = 0.5f*(_min.z+_max.z); + + return center; +} + +void AABB::getCorners(Vec3 *dst) const +{ + assert(dst); + + // Near face, specified counter-clockwise looking towards the origin from the positive z-axis. + // Left-top-front. + dst[0].set(_min.x, _max.y, _max.z); + // Left-bottom-front. + dst[1].set(_min.x, _min.y, _max.z); + // Right-bottom-front. + dst[2].set(_max.x, _min.y, _max.z); + // Right-top-front. + dst[3].set(_max.x, _max.y, _max.z); + + // Far face, specified counter-clockwise looking towards the origin from the negative z-axis. + // Right-top-back. + dst[4].set(_max.x, _max.y, _min.z); + // Right-bottom-back. + dst[5].set(_max.x, _min.y, _min.z); + // Left-bottom-back. + dst[6].set(_min.x, _min.y, _min.z); + // Left-top-back. + dst[7].set(_min.x, _max.y, _min.z); +} + +bool AABB::intersects(const AABB& aabb) const +{ + return ((_min.x >= aabb._min.x && _min.x <= aabb._max.x) || (aabb._min.x >= _min.x && aabb._min.x <= _max.x)) && + ((_min.y >= aabb._min.y && _min.y <= aabb._max.y) || (aabb._min.y >= _min.y && aabb._min.y <= _max.y)) && + ((_min.z >= aabb._min.z && _min.z <= aabb._max.z) || (aabb._min.z >= _min.z && aabb._min.z <= _max.z)); +} + +bool AABB::containPoint(const Vec3& point) const +{ + if (point.x < _min.x) return false; + if (point.y < _min.y) return false; + if (point.z < _min.z) return false; + if (point.x > _max.x) return false; + if (point.y > _max.y) return false; + if (point.z > _max.z) return false; + return true; +} + +void AABB::merge(const AABB& box) +{ + // Calculate the new minimum point. + _min.x = std::min(_min.x, box._min.x); + _min.y = std::min(_min.y, box._min.y); + _min.z = std::min(_min.z, box._min.z); + + // Calculate the new maximum point. + _max.x = std::max(_max.x, box._max.x); + _max.y = std::max(_max.y, box._max.y); + _max.z = std::max(_max.z, box._max.z); +} + +void AABB::set(const Vec3& min, const Vec3& max) +{ + this->_min = min; + this->_max = max; +} + +void AABB::reset() +{ + _min.set(99999.0f, 99999.0f, 99999.0f); + _max.set(-99999.0f, -99999.0f, -99999.0f); +} + +void AABB::updateMinMax(const Vec3* point, ssize_t num) +{ + for (ssize_t i = 0; i < num; i++) + { + // Leftmost point. + if (point[i].x < _min.x) + _min.x = point[i].x; + + // Lowest point. + if (point[i].y < _min.y) + _min.y = point[i].y; + + // Farthest point. + if (point[i].z < _min.z) + _min.z = point[i].z; + + // Rightmost point. + if (point[i].x > _max.x) + _max.x = point[i].x; + + // Highest point. + if (point[i].y > _max.y) + _max.y = point[i].y; + + // Nearest point. + if (point[i].z > _max.z) + _max.z = point[i].z; + } +} + +void AABB::transform(const Mat4& matrix) +{ + Vec3 corners[8]; + // Near face, specified counter-clockwise + // Left-top-front. + corners[0].set(_min.x, _max.y, _max.z); + // Left-bottom-front. + corners[1].set(_min.x, _min.y, _max.z); + // Right-bottom-front. + corners[2].set(_max.x, _min.y, _max.z); + // Right-top-front. + corners[3].set(_max.x, _max.y, _max.z); + + // Far face, specified clockwise + // Right-top-back. + corners[4].set(_max.x, _max.y, _min.z); + // Right-bottom-back. + corners[5].set(_max.x, _min.y, _min.z); + // Left-bottom-back. + corners[6].set(_min.x, _min.y, _min.z); + // Left-top-back. + corners[7].set(_min.x, _max.y, _min.z); + + // Transform the corners, recalculating the min and max points along the way. + //matrix.transformPoint(&corners[0]); + + for (int i = 0; i < 8; i++) + matrix.transformPoint(&corners[i]); + + reset(); + + updateMinMax(corners, 8); +} + +NS_CC_END diff --git a/cocos/3d/CCAABB.h b/cocos/3d/CCAABB.h new file mode 100755 index 0000000000..97d25a09fe --- /dev/null +++ b/cocos/3d/CCAABB.h @@ -0,0 +1,114 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __CC_AABB_H__ +#define __CC_AABB_H__ + +#include "base/ccMacros.h" +#include "math/CCMath.h" + +NS_CC_BEGIN + +class CC_DLL AABB +{ + +public: + /** + * Constructor. + */ + AABB(); + + /** + * Constructor. + */ + AABB(const Vec3& min, const Vec3& max); + + /** + * Constructor. + */ + AABB(const AABB& box); + + /** + * Gets the center point of the bounding box. + */ + Vec3 getCenter(); + + /* Near face, specified counter-clockwise looking towards the origin from the positive z-axis. + * verts[0] : left top front + * verts[1] : left bottom front + * verts[2] : right bottom front + * verts[3] : right top front + * + * Far face, specified counter-clockwise looking towards the origin from the negative z-axis. + * verts[4] : right top back + * verts[5] : right bottom back + * verts[6] : left bottom back + * verts[7] : left top back + */ + void getCorners(Vec3 *dst) const; + + /** + * Tests whether this bounding box intersects the specified bounding object. + */ + bool intersects(const AABB& aabb) const; + + /** + * check whether the point is in. + */ + bool containPoint(const Vec3& point) const; + + /** + * Sets this bounding box to the smallest bounding box + * that contains both this bounding object and the specified bounding box. + */ + void merge(const AABB& box); + + /** + * Sets this bounding box to the specified values. + */ + void set(const Vec3& min, const Vec3& max); + + /** + * reset min and max value. + */ + void reset(); + + /** + * update the _min and _max from the given point. + */ + void updateMinMax(const Vec3* point, ssize_t num); + + /** + * Transforms the bounding box by the given transformation matrix. + */ + void transform(const Mat4& matrix); + +public: + Vec3 _min; + Vec3 _max; +}; + +NS_CC_END + +#endif diff --git a/cocos/3d/CCOBB.cpp b/cocos/3d/CCOBB.cpp new file mode 100755 index 0000000000..65a7e2b733 --- /dev/null +++ b/cocos/3d/CCOBB.cpp @@ -0,0 +1,439 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "3d/CCOBB.h" + +NS_CC_BEGIN + +#define ROTATE(a,i,j,k,l) g=a.m[i + 4 * j]; h=a.m[k + 4 * l]; a.m[i + 4 * j]=(float)(g-s*(h+g*tau)); a.m[k + 4 * l]=(float)(h+s*(g-h*tau)); + +static Mat4 _convarianceMatrix(const Vec3* aVertPos, int nVertCount) +{ + int i; + Mat4 Cov; + + double S1[3]; + double S2[3][3]; + + S1[0] = S1[1] = S1[2] = 0.0; + S2[0][0] = S2[1][0] = S2[2][0] = 0.0; + S2[0][1] = S2[1][1] = S2[2][1] = 0.0; + S2[0][2] = S2[1][2] = S2[2][2] = 0.0; + + // get center of mass + for(i=0; i3 && fabs(dmip)+g==fabs(dmip) && fabs(dmiq)+g==fabs(dmiq) ) + a.m[ip + 4 * iq]=0.0; + else if (fabs(a.m[ip + 4 * iq])>tresh) + { + h = dmiq-dmip; + if (fabs(h)+g == fabs(h)) + t=(a.m[ip + 4 * iq])/h; + else + { + theta=0.5*h/(a.m[ip + 4 * iq]); + t=1.0/(fabs(theta)+sqrt(1.0+theta*theta)); + if (theta < 0.0) t = -t; + } + c=1.0/sqrt(1+t*t); + s=t*c; + tau=s/(1.0+c); + h=t*a.m[ip + 4 * iq]; + _getElement(z, ip) -= (float)h; + _getElement(z, iq) += (float)h; + _getElement(d, ip) -= (float)h; + _getElement(d, iq) += (float)h; + a.m[ip + 4 * iq]=0.0; + for(j=0;j vect.x ? vecMax.x : vect.x; + vecMax.y = vecMax.y > vect.y ? vecMax.y : vect.y; + vecMax.z = vecMax.z > vect.z ? vecMax.z : vect.z; + + vecMin.x = vecMin.x < vect.x ? vecMin.x : vect.x; + vecMin.y = vecMin.y < vect.y ? vecMin.y : vect.y; + vecMin.z = vecMin.z < vect.z ? vecMin.z : vect.z; + } + + matTransform.transpose(); + + _xAxis = Vec3(matTransform.m[0], matTransform.m[1], matTransform.m[2]); + _yAxis = Vec3(matTransform.m[4], matTransform.m[5], matTransform.m[6]); + _zAxis = Vec3(matTransform.m[8], matTransform.m[9], matTransform.m[10]); + + _center = 0.5f * (vecMax + vecMin); + _center *= matTransform; + + _xAxis.normalize(); + _yAxis.normalize(); + _zAxis.normalize(); + + _extents = 0.5f * (vecMax - vecMin); +} + +bool OBB::containPoint(const Vec3& point) const +{ + Vec3 vd = point - _center; + + float d = vd.dot(_xAxis); + if (d > _extents.x || d < -_extents.x) + return false; + + d = vd.dot(_yAxis); + if (d > _extents.y || d < -_extents.y) + return false; + + d = vd.dot(_zAxis); + if (d > _extents.z || d < -_extents.z) + return false; + + return true; +} + +void OBB::set(const Vec3& center, const Vec3& xAxis, const Vec3& yAxis, const Vec3& zAxis, const Vec3& extents) +{ + _center = center; + _xAxis = xAxis; + _yAxis = yAxis; + _zAxis = zAxis; + _extents = extents; +} + +void OBB::reset() +{ + memset(this, 0, sizeof(OBB)); +} + +void OBB::getCorners(Vec3* verts) const +{ + Vec3 extX = _xAxis * _extents.x; + Vec3 extY = _yAxis * _extents.y; + Vec3 extZ = _zAxis * _extents.z; + + verts[0] = _center - extX + extY + extZ; // left top front + verts[1] = _center - extX - extY + extZ; // left bottom front + verts[2] = _center + extX - extY + extZ; // right bottom front + verts[3] = _center + extX + extY + extZ; // right top front + + verts[4] = _center + extX + extY - extZ; // right top back + verts[5] = _center + extX - extY - extZ; // right bottom back + verts[6] = _center - extX - extY - extZ; // left bottom back + verts[7] = _center - extX + extY - extZ; // left top back +} + +float OBB::projectPoint(const Vec3& point, const Vec3& axis)const +{ + float dot = axis.dot(point); + float ret = dot * point.length(); + return ret; +} + +void OBB::getInterval(const OBB& box, const Vec3& axis, float &min, float &max)const +{ + Vec3 corners[8]; + box.getCorners(corners); + float value; + min = max = projectPoint(axis, corners[0]); + for(int i = 1; i < 8; i++) + { + value = projectPoint(axis, corners[i]); + min = MIN(min, value); + max = MAX(max, value); + } +} + +Vec3 OBB::getEdgeDir(int index)const +{ + Vec3 corners[8]; + getCorners(corners); + + Vec3 tmpLine; + switch(index) + { + case 0:// edge with x axis + tmpLine = corners[5] - corners[6]; + tmpLine.normalize(); + break; + case 1:// edge with y axis + tmpLine = corners[7] - corners[6]; + tmpLine.normalize(); + break; + case 2:// edge with z axis + tmpLine = corners[1] - corners[6]; + tmpLine.normalize(); + break; + } + return tmpLine; +} + +Vec3 OBB::getFaceDir(int index) const +{ + Vec3 corners[8]; + getCorners(corners); + + Vec3 faceDir, v0, v1; + switch(index) + { + case 0:// front and back + v0 = corners[2] - corners[1]; + v1 = corners[0] - corners[1]; + Vec3::cross(v0, v1, &faceDir); + faceDir.normalize(); + break; + case 1:// left and right + v0 = corners[5] - corners[2]; + v1 = corners[3] - corners[2]; + Vec3::cross(v0, v1, &faceDir); + faceDir.normalize(); + break; + case 2:// top and bottom + v0 = corners[1] - corners[2]; + v1 = corners[5] - corners[2]; + Vec3::cross(v0, v1, &faceDir); + faceDir.normalize(); + break; + } + return faceDir; +} + +bool OBB::intersects(const OBB& box) const +{ + float min1, max1, min2, max2; + for (int i = 0; i < 3; i++) + { + getInterval(*this, getFaceDir(i), min1, max1); + getInterval(box, getFaceDir(i), min2, max2); + if (max1 < min2 || max2 < min1) return false; + } + + for (int i = 0; i < 3; i++) + { + getInterval(*this, box.getFaceDir(i), min1, max1); + getInterval(box, box.getFaceDir(i), min2, max2); + if (max1 < min2 || max2 < min1) return false; + } + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + Vec3 axis; + Vec3::cross(getEdgeDir(i), box.getEdgeDir(j), &axis); + getInterval(*this, axis, min1, max1); + getInterval(box, axis, min2, max2); + if (max1 < min2 || max2 < min1) return false; + } + } + + return true; +} + + +void OBB::transform(const Mat4& mat) +{ + Vec4 newcenter = mat * Vec4(_center.x, _center.y, _center.z, 1.0f);// center; + _center.x = newcenter.x; + _center.y = newcenter.y; + _center.z = newcenter.z; + + _xAxis = mat * _xAxis; + _yAxis = mat * _yAxis; + _zAxis = mat * _zAxis; + + _xAxis.normalize(); + _yAxis.normalize(); + _zAxis.normalize(); + + Vec3 scale, trans; + Quaternion quat; + mat.decompose(&scale, &quat, &trans); + + _extents.x *= scale.x; + _extents.y *= scale.y; + _extents.z *= scale.z; +} + +NS_CC_END diff --git a/cocos/3d/CCOBB.h b/cocos/3d/CCOBB.h new file mode 100755 index 0000000000..ed691d9f79 --- /dev/null +++ b/cocos/3d/CCOBB.h @@ -0,0 +1,117 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __CC_OBB_H__ +#define __CC_OBB_H__ + +#include "CCAABB.h" + +NS_CC_BEGIN + +class CC_DLL OBB +{ +public: + OBB(); + + /* + * Construct obb from oriented bounding box + */ + OBB(const AABB& aabb); + + /* + * Construct obb from points + */ + OBB(const Vec3* verts, int nVerts); + + /* + * Check point in + */ + bool containPoint(const Vec3& point) const; + + /* + * Specify obb values + */ + void set(const Vec3& center, const Vec3& _xAxis, const Vec3& _yAxis, const Vec3& _zAxis, const Vec3& _extents); + + /* + * Clear obb + */ + void reset(); + + /* face to the obb's -z direction + * verts[0] : left top front + * verts[1] : left bottom front + * verts[2] : right bottom front + * verts[3] : right top front + * + * face to the obb's z direction + * verts[4] : right top back + * verts[5] : right bottom back + * verts[6] : left bottom back + * verts[7] : left top back + */ + void getCorners(Vec3* verts) const; + + /* + * Check intersect with other + */ + bool intersects(const OBB& box) const; + + /** + * Transforms the obb by the given transformation matrix. + */ + void transform(const Mat4& mat); + +protected: + /* + * Project point to the target axis + */ + float projectPoint(const Vec3& point, const Vec3& axis) const; + + /* + * Calculate the min and max project value of through the box's corners + */ + void getInterval(const OBB& box, const Vec3& axis, float &min, float &max) const; + + /* + * Get the edege of x y z axis direction + */ + Vec3 getEdgeDir(int index) const; + + /* + * Get the face of x y z axis direction + */ + Vec3 getFaceDir(int index) const; + +public: + Vec3 _center; // obb center + Vec3 _xAxis; // x axis of obb, unit vector + Vec3 _yAxis; // y axis of obb, unit vecotr + Vec3 _zAxis; // z axis of obb, unit vector + Vec3 _extents; // obb length along each axis +}; + +NS_CC_END + +#endif diff --git a/cocos/3d/CMakeLists.txt b/cocos/3d/CMakeLists.txt index 19b90ab82e..bebc7af70b 100644 --- a/cocos/3d/CMakeLists.txt +++ b/cocos/3d/CMakeLists.txt @@ -1,4 +1,6 @@ set(COCOS_3D_SRC + 3d/CCAABB.cpp + 3d/CCOBB.cpp 3d/CCDrawNode3D.cpp 3d/CCSkeleton3D.cpp 3d/CCAttachNode.cpp diff --git a/cocos/Android.mk b/cocos/Android.mk index 479b3a3988..dd3ddc8a1e 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -74,6 +74,8 @@ cocos2d.cpp \ 2d/CCTransitionPageTurn.cpp \ 2d/CCTransitionProgress.cpp \ 2d/CCTweenFunction.cpp \ +3d/CCAABB.cpp \ +3d/CCOBB.cpp \ 3d/CCAnimate3D.cpp \ 3d/CCAnimation3D.cpp \ 3d/CCAttachNode.cpp \ diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 799c5e127a..4fd30579a1 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -192,6 +192,10 @@ "cocos/2d/cocos2dx.props", "cocos/2d/libcocos2d.vcxproj", "cocos/2d/libcocos2d.vcxproj.filters", + "cocos/3d/CCAABB.cpp", + "cocos/3d/CCAABB.h”, + "cocos/3d/CCOBB.cpp", + "cocos/3d/CCOBB.h”, "cocos/3d/CCAnimate3D.cpp", "cocos/3d/CCAnimate3D.h", "cocos/3d/CCAnimation3D.cpp", From 9471b572f7683dc655e6b92ecea4c7ba87598866 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 8 Aug 2014 00:05:02 +0800 Subject: [PATCH 02/42] add to cocos2d.h --- cocos/cocos2d.h | 2 ++ tools/tolua/cocos2dx.ini | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index afdb4cfa13..9ffea8f200 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -262,6 +262,8 @@ THE SOFTWARE. #include "2d/CCComponentContainer.h" //3d +#include "3d/CCAABB.h" +#include "3d/CCOBB.h" #include "3d/CCSprite3D.h" #include "3d/CCMesh.h" #include "3d/CCMeshSkin.h" diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 525d31fc6b..6626ccf4c5 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.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 = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console Mesh GLProgramCache GLProgramState SubMeshState AttachNode Camera DrawNode3D +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console Mesh GLProgramCache GLProgramState SubMeshState AttachNode Camera DrawNode3D AABB OBB # 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 From 28769c9b1512072400d95a06b7d16465d3be89ed Mon Sep 17 00:00:00 2001 From: lvlong Date: Fri, 8 Aug 2014 11:16:33 +0800 Subject: [PATCH 03/42] add obb sample --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 + cocos/3d/CCRay.cpp | 176 ++++++++++++ cocos/3d/CCRay.h | 97 +++++++ cocos/Android.mk | 1 + .../Classes/Sprite3DTest/Sprite3DTest.cpp | 261 +++++++++++++++++- .../Classes/Sprite3DTest/Sprite3DTest.h | 35 +++ 6 files changed, 581 insertions(+), 1 deletion(-) create mode 100755 cocos/3d/CCRay.cpp create mode 100755 cocos/3d/CCRay.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index c9cb06ded3..2b8e040b16 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1264,6 +1264,10 @@ 50ABC0651926664800A911A9 /* CCGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF531926664700A911A9 /* CCGL.h */; }; 50ABC0671926664800A911A9 /* CCPlatformDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF541926664700A911A9 /* CCPlatformDefine.h */; }; 50ABC0691926664800A911A9 /* CCStdC.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF551926664700A911A9 /* CCStdC.h */; }; + 5E7EAC03199469D200CCFA35 /* CCRay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E7EAC01199469D200CCFA35 /* CCRay.cpp */; }; + 5E7EAC04199469D200CCFA35 /* CCRay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E7EAC01199469D200CCFA35 /* CCRay.cpp */; }; + 5E7EAC05199469D200CCFA35 /* CCRay.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E7EAC02199469D200CCFA35 /* CCRay.h */; }; + 5E7EAC06199469D200CCFA35 /* CCRay.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E7EAC02199469D200CCFA35 /* CCRay.h */; }; A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; }; B217703C1977ECB4009EE11B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703B1977ECB4009EE11B /* IOKit.framework */; }; B21770401977ECE6009EE11B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703F1977ECE6009EE11B /* OpenGL.framework */; }; @@ -2998,6 +3002,8 @@ 50FCEB9018C72017004AD434 /* WidgetReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetReader.cpp; sourceTree = ""; }; 50FCEB9118C72017004AD434 /* WidgetReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetReader.h; sourceTree = ""; }; 50FCEB9218C72017004AD434 /* WidgetReaderProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetReaderProtocol.h; sourceTree = ""; }; + 5E7EAC01199469D200CCFA35 /* CCRay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCRay.cpp; sourceTree = ""; }; + 5E7EAC02199469D200CCFA35 /* CCRay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCRay.h; sourceTree = ""; }; A03F2CB81780BD04006731B9 /* libchipmunk Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libchipmunk Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2D9B1780BDF7006731B9 /* libbox2d Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libbox2d Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A03F2ED617814268006731B9 /* libcocosdenshion Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocosdenshion Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -5214,6 +5220,8 @@ B29594B81926D61F003EEF37 /* 3d */ = { isa = PBXGroup; children = ( + 5E7EAC01199469D200CCFA35 /* CCRay.cpp */, + 5E7EAC02199469D200CCFA35 /* CCRay.h */, 3E9E75E01993D8E4005B7047 /* CCAABB.cpp */, 3E9E75E11993D8E4005B7047 /* CCAABB.h */, 3E9E75E21993D8E4005B7047 /* CCOBB.cpp */, @@ -5318,6 +5326,7 @@ 1A570114180BC8EE0088DEC7 /* CCDrawNode.h in Headers */, 1A57011D180BC90D0088DEC7 /* CCGrabber.h in Headers */, 1A570121180BC90D0088DEC7 /* CCGrid.h in Headers */, + 5E7EAC05199469D200CCFA35 /* CCRay.h in Headers */, 5034CA2D191D591100CE6051 /* ccShader_PositionTextureA8Color.frag in Headers */, 1AC0269C1914068200FA920D /* ConvertUTF.h in Headers */, 50ABBED11925AB6F00A911A9 /* TGAlib.h in Headers */, @@ -5637,6 +5646,7 @@ 46A170FF1807CECB005B8026 /* CCPhysicsContact.h in Headers */, 50ABBDA21925AB4100A911A9 /* CCGroupCommand.h in Headers */, 503DD8EF1926736A00CD74DD /* CCPlatformDefine.h in Headers */, + 5E7EAC06199469D200CCFA35 /* CCRay.h in Headers */, 46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */, 50ABBD3B1925AB0000A911A9 /* CCAffineTransform.h in Headers */, 3E9E75EB1993D8E4005B7047 /* CCOBB.h in Headers */, @@ -6855,6 +6865,7 @@ 1A570225180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */, 1A570229180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */, 1A57022D180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */, + 5E7EAC03199469D200CCFA35 /* CCRay.cpp in Sources */, 1A57027E180BCC900088DEC7 /* CCSprite.cpp in Sources */, 3EA3EDCC199234B500645534 /* CCDrawNode3D.cpp in Sources */, 1A570282180BCC900088DEC7 /* CCSpriteBatchNode.cpp in Sources */, @@ -7143,6 +7154,7 @@ 50ABBED81925AB6F00A911A9 /* ZipUtils.cpp in Sources */, 1A57008E180BC5A10088DEC7 /* CCActionTiledGrid.cpp in Sources */, 1A570092180BC5A10088DEC7 /* CCActionTween.cpp in Sources */, + 5E7EAC04199469D200CCFA35 /* CCRay.cpp in Sources */, 1A570099180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */, 50ABBD4D1925AB0000A911A9 /* MathUtil.cpp in Sources */, 50ABBE3E1925AB6F00A911A9 /* CCDataVisitor.cpp in Sources */, diff --git a/cocos/3d/CCRay.cpp b/cocos/3d/CCRay.cpp new file mode 100755 index 0000000000..8d8275af18 --- /dev/null +++ b/cocos/3d/CCRay.cpp @@ -0,0 +1,176 @@ +/**************************************************************************** +Copyright (c) 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 "CCRay.h" +#include "CCAABB.h" +#include "CCOBB.h" + +NS_CC_BEGIN + +Ray::Ray() + : _direction(0, 0, 1) +{ +} + +Ray::Ray(const Vec3& origin, const Vec3& direction) +{ + set(origin, direction); +} + +Ray::~Ray() +{ +} + +bool Ray::intersects(const AABB& aabb) const +{ + Vec3 ptOnPlane; + Vec3 min = aabb._min; + Vec3 max = aabb._max; + + const Vec3& origin = _origin; + const Vec3& dir = _direction; + + float t; + + if (dir.x != 0.f) + { + if (dir.x > 0) + t = (min.x - origin.x) / dir.x; + else + t = (max.x - origin.x) / dir.x; + + if (t > 0.f) + { + ptOnPlane = origin + t * dir; + + if (min.y < ptOnPlane.y && ptOnPlane.y < max.y && min.z < ptOnPlane.z && ptOnPlane.z < max.z) + { + return true; + } + } + } + + if (dir.y != 0.f) + { + if (dir.y > 0) + t = (min.y - origin.y) / dir.y; + else + t = (max.y - origin.y) / dir.y; + + if (t > 0.f) + { + ptOnPlane = origin + t * dir; + + if (min.z < ptOnPlane.z && ptOnPlane.z < max.z && min.x < ptOnPlane.x && ptOnPlane.x < max.x) + { + return true; + } + } + } + + if (dir.z != 0.f) + { + if (dir.z > 0) + t = (min.z - origin.z) / dir.z; + else + t = (max.z - origin.z) / dir.z; + + if (t > 0.f) + { + ptOnPlane = origin + t * dir; + + if (min.x < ptOnPlane.x && ptOnPlane.x < max.x && min.y < ptOnPlane.y && ptOnPlane.y < max.y) + { + return true; + } + } + } + + return false; +} + +bool Ray::intersects(const OBB& obb) const +{ + AABB aabb; + aabb._min = - obb._extents; + aabb._max = obb._extents; + + Ray ray; + ray._direction = _direction; + ray._origin = _origin; + + Mat4 mat = Mat4::IDENTITY; + mat.m[0] = obb._xAxis.x; + mat.m[1] = obb._xAxis.y; + mat.m[2] = obb._xAxis.z; + + mat.m[4] = obb._yAxis.x; + mat.m[5] = obb._yAxis.y; + mat.m[6] = obb._yAxis.z; + + mat.m[8] = obb._zAxis.x; + mat.m[9] = obb._zAxis.y; + mat.m[10] = obb._zAxis.z; + + mat.m[12] = obb._center.x; + mat.m[13] = obb._center.y; + mat.m[14] = obb._center.z; + + mat = mat.getInversed(); + + ray.transform(mat); + + return ray.intersects(aabb); +} + +void Ray::set(const Vec3& origin, const Vec3& direction) +{ + _origin = origin; + _direction = direction; + normalize(); +} + +void Ray::transform(const Mat4& matrix) +{ + matrix.transformPoint(&_origin); + matrix.transformVector(&_direction); + _direction.normalize(); +} + +void Ray::normalize() +{ + if (_direction.isZero()) + { + return; + } + + // Normalize the ray's direction vector. + float normalizeFactor = 1.0f / sqrt(_direction.x * _direction.x + _direction.y * _direction.y + _direction.z * _direction.z); + if (normalizeFactor != 1.0f) + { + _direction.x *= normalizeFactor; + _direction.y *= normalizeFactor; + _direction.z *= normalizeFactor; + } +} + +NS_CC_END diff --git a/cocos/3d/CCRay.h b/cocos/3d/CCRay.h new file mode 100755 index 0000000000..7c60c35635 --- /dev/null +++ b/cocos/3d/CCRay.h @@ -0,0 +1,97 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __CC_RAY_H_ +#define __CC_RAY_H_ + +#include "base/ccMacros.h" +#include "math/CCMath.h" +#include "CCAABB.h" +#include "CCOBB.h" + +NS_CC_BEGIN + +class CC_DLL Ray +{ +public: + /** + * Constructor. + */ + Ray(); + + /** + * Constructor. + */ + Ray(const Ray& ray); + + /** + * Constructs a new ray initialized to the specified values. + * + * @param origin The ray's origin. + * @param direction The ray's direction. + */ + Ray(const Vec3& origin, const Vec3& direction); + + /** + * Destructor. + */ + ~Ray(); + + /** + * Check whether this ray intersects the specified bounding box. + */ + bool intersects(const AABB& aabb) const; + + /** + * Check whether this ray intersects the specified obb. + */ + bool intersects(const OBB& obb) const; + + /** + * Sets this ray to the specified values. + * + * @param origin The ray's origin. + * @param direction The ray's direction. + */ + void set(const Vec3& origin, const Vec3& direction); + + /** + * Transforms this ray by the given transformation matrix. + * + * @param matrix The transformation matrix to transform by. + */ + void transform(const Mat4& matrix); + + /** + * Normalizes the ray. + */ + void normalize(); + + Vec3 _origin; // The ray origin position. + Vec3 _direction; // The ray direction vector. +}; + +NS_CC_END + +#endif diff --git a/cocos/Android.mk b/cocos/Android.mk index dd3ddc8a1e..ece0054f1d 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -74,6 +74,7 @@ cocos2d.cpp \ 2d/CCTransitionPageTurn.cpp \ 2d/CCTransitionProgress.cpp \ 2d/CCTweenFunction.cpp \ +3d/CCRay.cpp\ 3d/CCAABB.cpp \ 3d/CCOBB.cpp \ 3d/CCAnimate3D.cpp \ diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 2c9c540c72..2ce7ce40e0 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -28,6 +28,7 @@ #include "3d/CCAnimate3D.h" #include "3d/CCSubMesh.h" #include "3d/CCAttachNode.h" +#include "3d/CCRay.h" #include #include "../testResource.h" @@ -52,7 +53,8 @@ static std::function createFunctions[] = #endif CL(Sprite3DWithSkinTest), CL(Animate3DTest), - CL(AttachmentTest) + CL(AttachmentTest), + CL(Sprite3DWithOBBPerfromanceTest) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -867,3 +869,260 @@ void AttachmentTest::onTouchesEnded(const std::vector& touches, Event* e } _hasWeapon = !_hasWeapon; } + +Sprite3DWithOBBPerfromanceTest::Sprite3DWithOBBPerfromanceTest() +{ + auto listener = EventListenerTouchAllAtOnce::create(); + listener->onTouchesBegan = CC_CALLBACK_2(Sprite3DWithOBBPerfromanceTest::onTouchesBegan, this); + listener->onTouchesEnded = CC_CALLBACK_2(Sprite3DWithOBBPerfromanceTest::onTouchesEnded, this); + listener->onTouchesMoved = CC_CALLBACK_2(Sprite3DWithOBBPerfromanceTest::onTouchesMoved, this); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); + auto s = Director::getInstance()->getWinSize(); + initDrawBox(); + + addNewSpriteWithCoords(Vec2(s.width/2, s.height/2)); + MenuItemFont::setFontName("fonts/arial.ttf"); + MenuItemFont::setFontSize(65); + auto decrease = MenuItemFont::create(" - ", CC_CALLBACK_1(Sprite3DWithOBBPerfromanceTest::delOBBCallback, this)); + decrease->setColor(Color3B(0,200,20)); + auto increase = MenuItemFont::create(" + ", CC_CALLBACK_1(Sprite3DWithOBBPerfromanceTest::addOBBCallback, this)); + increase->setColor(Color3B(0,200,20)); + + auto menu = Menu::create(decrease, increase, nullptr); + menu->alignItemsHorizontally(); + menu->setPosition(Vec2(s.width/2, s.height-65)); + addChild(menu, 1); + + TTFConfig ttfCount("fonts/Marker Felt.ttf", 30); + _labelCubeCount = Label::createWithTTF(ttfCount,"0 cubes"); + _labelCubeCount->setColor(Color3B(0,200,20)); + _labelCubeCount->setPosition(Vec2(s.width/2, s.height-90)); + addChild(_labelCubeCount); + _hasCollider = false; + scheduleUpdate(); +} +std::string Sprite3DWithOBBPerfromanceTest::title() const +{ + return "OBB Collison Perfromance Test"; +} +std::string Sprite3DWithOBBPerfromanceTest::subtitle() const +{ + return ""; +} +void Sprite3DWithOBBPerfromanceTest::addNewOBBWithCoords(Vec2 p) +{ + Vec3 extents = Vec3(10, 10, 10); + AABB aabb(-extents, extents); + auto obb = OBB(aabb); + obb._center = Vec3(p.x,p.y,0); + _obb.push_back(obb); +} + +void Sprite3DWithOBBPerfromanceTest::onTouchesBegan(const std::vector& touches, Event* event) +{ + for (auto touch: touches) + { + auto location = touch->getLocationInView(); + + if(_obb.size() > 0) + { + _intersetList.clear(); + Ray ray; + calculateRayByLocationInView(&ray,location); + for(int i = 0; i < _obb.size(); i++) + { + if(ray.intersects(_obb[i])) + { + _intersetList.insert(i); + return; + } + } + } + } +} + +void Sprite3DWithOBBPerfromanceTest::onTouchesEnded(const std::vector& touches, Event* event) +{ + +} + +void Sprite3DWithOBBPerfromanceTest::onTouchesMoved(const std::vector& touches, Event* event) +{ + for (auto touch: touches) + { + auto location = touch->getLocation(); + + for(int i = 0; i < _obb.size(); i++) + { + if(_intersetList.find(i) != _intersetList.end()) + _obb[i]._center = Vec3(location.x,location.y,0); + } + } +} + +void Sprite3DWithOBBPerfromanceTest::update(float dt) +{ + char szText[16]; + sprintf(szText,"%lu cubes",_obb.size()); + _labelCubeCount->setString(szText); + + if (_drawDebug) + { + _drawDebug->clear(); + + Mat4 mat = _sprite->getNodeToWorldTransform(); + mat.getRightVector(&_obbt._xAxis); + _obbt._xAxis.normalize(); + + mat.getUpVector(&_obbt._yAxis); + _obbt._yAxis.normalize(); + + mat.getForwardVector(&_obbt._zAxis); + _obbt._zAxis.normalize(); + + _obbt._center = _sprite->getPosition3D(); + + Vec3 corners[8] = {}; + _obbt.getCorners(corners); + _drawDebug->drawCube(corners, Color4F(0,0,1,1)); + } + if(_obb.size() > 0) + { + _drawOBB->clear(); + for(int i =0; i < _obb.size(); i++) + { + Vec3 corners[8] = {}; + _obb[i].getCorners(corners); + _drawOBB->drawCube(corners, _obbt.intersects(_obb[i])?Color4F(1,0,0,1):Color4F(0,1,0,1)); + } + } +} + +void Sprite3DWithOBBPerfromanceTest::initDrawBox() +{ + _drawOBB = DrawNode3D::create(); + addChild(_drawOBB); +} + +void Sprite3DWithOBBPerfromanceTest::addNewSpriteWithCoords(Vec2 p) +{ + std::string fileName = "Sprite3DTest/tortoise.c3b"; + auto sprite = Sprite3D::create(fileName); + sprite->setScale(0.1f); + auto s = Director::getInstance()->getWinSize(); + sprite->setPosition(Vec2(s.width * 4.f / 5.f, s.height / 2.f)); + addChild(sprite); + _sprite = sprite; + auto animation = Animation3D::create(fileName); + if (animation) + { + auto animate = Animate3D::create(animation, 0.f, 1.933f); + sprite->runAction(RepeatForever::create(animate)); + } + + _moveAction = MoveTo::create(4.f, Vec2(s.width / 5.f, s.height / 2.f)); + _moveAction->retain(); + auto seq = Sequence::create(_moveAction, CallFunc::create(CC_CALLBACK_0(Sprite3DWithOBBPerfromanceTest::reachEndCallBack, this)), nullptr); + seq->setTag(100); + sprite->runAction(seq); + + //Generate OBB by AABB + Vec3 extents = Vec3(50, 25, 25); + AABB aabb(-extents, extents); + _obbt = OBB(aabb); + + _drawDebug = DrawNode3D::create(); + addChild(_drawDebug); +} + +void Sprite3DWithOBBPerfromanceTest::reachEndCallBack() +{ + _sprite->stopActionByTag(100); + auto inverse = (MoveTo*)_moveAction->reverse(); + inverse->retain(); + _moveAction->release(); + _moveAction = inverse; + auto rot = RotateBy::create(1.0f, Vec3(0.f, 180.f, 0.f)); + auto seq = Sequence::create(rot, _moveAction, CallFunc::create(CC_CALLBACK_0(Sprite3DWithOBBPerfromanceTest::reachEndCallBack, this)), nullptr); + seq->setTag(100); + _sprite->runAction(seq); +} + +void Sprite3DWithOBBPerfromanceTest::addOBBCallback(Ref* sender) +{ + addOBBWithCount(10); +} + +void Sprite3DWithOBBPerfromanceTest::addOBBWithCount(float value) +{ + for(int i = 0; i < value; i++) + { + Vec2 randompos = Vec2(CCRANDOM_0_1() * Director::getInstance()->getWinSize().width,CCRANDOM_0_1() * Director::getInstance()->getWinSize().height); + Vec3 extents = Vec3(10, 10, 10); + AABB aabb(-extents, extents); + auto obb = OBB(aabb); + obb._center = Vec3(randompos.x,randompos.y,0); + _obb.push_back(obb); + } +} + +void Sprite3DWithOBBPerfromanceTest::delOBBCallback(Ref* sender) +{ + delOBBWithCount(10); +} + +void Sprite3DWithOBBPerfromanceTest::delOBBWithCount(float value) +{ + if(_obb.size() >= 10) + { + _obb.erase(_obb.begin(),_obb.begin() + value); + _drawOBB->clear(); + } + else + return; +} +void Sprite3DWithOBBPerfromanceTest::unproject(const Mat4& viewProjection, const Size* viewport, Vec3* src, Vec3* dst) +{ + assert(dst); + + assert(viewport->width != 0.0f && viewport->height != 0.0f); + Vec4 screen(src->x / viewport->width, ((viewport->height - src->y)) / viewport->height, src->z, 1.0f); + + screen.x = screen.x * 2.0f - 1.0f; + screen.y = screen.y * 2.0f - 1.0f; + screen.z = screen.z * 2.0f - 1.0f; + + viewProjection.getInversed().transformVector(screen, &screen); + + if (screen.w != 0.0f) + { + screen.x /= screen.w; + screen.y /= screen.w; + screen.z /= screen.w; + } + + dst->set(screen.x, screen.y, screen.z); +} + +void Sprite3DWithOBBPerfromanceTest::calculateRayByLocationInView(Ray* ray, const Vec2& location) +{ + auto dir = Director::getInstance(); + auto view = dir->getWinSize(); + Mat4 mat = dir->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + mat = dir->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); + + Vec3 src = Vec3(location.x, location.y, -1); + Vec3 nearPoint; + unproject(mat, &view, &src, &nearPoint); + + src = Vec3(location.x, location.y, 1); + Vec3 farPoint; + unproject(mat, &view, &src, &farPoint); + + Vec3 direction; + Vec3::subtract(farPoint, nearPoint, &direction); + direction.normalize(); + + ray->_origin = nearPoint; + ray->_direction = direction; +} diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index a9f774d368..6b97aac4d6 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -33,6 +33,7 @@ namespace cocos2d { class Animate3D; class Sprite3D; class Delay; + class Ray; } class Sprite3DTestDemo : public BaseTest @@ -224,6 +225,40 @@ protected: cocos2d::Sprite3D* _sprite; }; +class Sprite3DWithOBBPerfromanceTest : public Sprite3DTestDemo +{ +public: + CREATE_FUNC(Sprite3DWithOBBPerfromanceTest); + Sprite3DWithOBBPerfromanceTest(); + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual void update(float dt) override; + void addNewOBBWithCoords(Vec2 p); + void addNewSpriteWithCoords(Vec2 p); + void onTouchesBegan(const std::vector& touches, Event* event); + void onTouchesEnded(const std::vector& touches, Event* event); + void onTouchesMoved(const std::vector& touches, Event* event); + void addOBBCallback(Ref* sender); + void delOBBCallback(Ref* sender); + void addOBBWithCount(float value); + void delOBBWithCount(float value); +protected: + cocos2d::Sprite3D* _sprite; + std::vector _obb; + DrawNode3D* _drawOBB; + Label* _labelCubeCount; + MoveTo* _moveAction; + OBB _obbt; + DrawNode3D* _drawDebug; + bool _hasCollider; + std::set _intersetList; + void initDrawBox(); + void reachEndCallBack(); + + void unproject(const Mat4& viewProjection, const Size* viewport, Vec3* src, Vec3* dst); + void calculateRayByLocationInView(Ray* ray, const Vec2& location); +}; + class Sprite3DTestScene : public TestScene { public: From fe58c43b2d2c8605c0692029111a7dbe57932147 Mon Sep 17 00:00:00 2001 From: lvlong Date: Fri, 8 Aug 2014 14:06:54 +0800 Subject: [PATCH 04/42] add abb and obb to vc2012-project --- cocos/2d/libcocos2d.vcxproj | 6 ++++++ cocos/2d/libcocos2d.vcxproj.filters | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index f935648fa7..c6396c878d 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -183,6 +183,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + @@ -191,7 +192,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + + @@ -370,6 +373,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + @@ -380,7 +384,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index b20b7f8bc3..dbbb942f17 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -616,6 +616,15 @@ base + + 3d + + + 3d + + + 3d + @@ -1252,6 +1261,15 @@ base + + 3d + + + 3d + + + 3d + From c71df09072b3840a2f5f8b72579b20f4e45cedff Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 8 Aug 2014 16:30:17 +0800 Subject: [PATCH 05/42] not export getCameras --- tools/tolua/cocos2dx.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index f067e48d6f..b89d890a58 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -132,7 +132,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Animation3D::[getBoneCurveByName], Animation3DCache::[*], Sprite3DMaterialCache::[*], - Bone3D::[*] + Bone3D::[*], + Scene::[getCameras] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], From 8101e2ff1adf3a0b5a12a180f1c4822f5a5b01bd Mon Sep 17 00:00:00 2001 From: lvlong Date: Fri, 8 Aug 2014 17:54:39 +0800 Subject: [PATCH 06/42] 1. move drawnode3d to Sprite3DTest 2. add getAABB to sprite3D and mesh --- build/cocos2d_libs.xcodeproj/project.pbxproj | 46 ---- build/cocos2d_tests.xcodeproj/project.pbxproj | 8 + cocos/3d/CCMesh.cpp | 22 ++ cocos/3d/CCMesh.h | 15 ++ cocos/3d/CCSprite3D.cpp | 25 ++ cocos/3d/CCSprite3D.h | 15 ++ tests/cpp-tests/Android.mk | 1 + .../Classes/Sprite3DTest/DrawNode3D.cpp | 240 ++++++++++++++++++ .../Classes/Sprite3DTest/DrawNode3D.h | 117 +++++++++ .../Classes/Sprite3DTest/Sprite3DTest.cpp | 5 +- .../Classes/Sprite3DTest/Sprite3DTest.h | 1 + 11 files changed, 446 insertions(+), 49 deletions(-) create mode 100644 tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp create mode 100644 tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index e5b3dbac4b..12a9dde1f8 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -7867,7 +7867,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_BOOL_CONVERSION = YES; @@ -7905,7 +7904,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_BOOL_CONVERSION = YES; @@ -7940,7 +7938,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_EXTENSION = a; EXECUTABLE_PREFIX = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -7973,7 +7970,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_EXTENSION = a; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; @@ -8006,7 +8002,6 @@ A03F2CB61780BD04006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; HEADER_SEARCH_PATHS = ""; @@ -8017,7 +8012,6 @@ A03F2CB71780BD04006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; @@ -8029,7 +8023,6 @@ A03F2D991780BDF7006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; CLANG_WARN_BOOL_CONVERSION = NO; CLANG_WARN_CONSTANT_CONVERSION = NO; EXECUTABLE_PREFIX = ""; @@ -8045,7 +8038,6 @@ A03F2D9A1780BDF7006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; CLANG_WARN_BOOL_CONVERSION = NO; CLANG_WARN_CONSTANT_CONVERSION = NO; EXECUTABLE_PREFIX = ""; @@ -8062,7 +8054,6 @@ A03F2E90178141C1006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "COCOS2D_DEBUG=1", @@ -8079,7 +8070,6 @@ A03F2E91178141C1006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; HEADER_SEARCH_PATHS = ( "$(inherited)", "/Applications/Xcode\\ 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", @@ -8091,7 +8081,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; GCC_TREAT_WARNINGS_AS_ERRORS = NO; @@ -8104,7 +8093,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; @@ -8118,7 +8106,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = ""; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8137,7 +8124,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = ""; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; @@ -8157,7 +8143,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/cocos2d-prefix.pch"; @@ -8187,7 +8172,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -8217,7 +8201,6 @@ A07A4E0D178386390073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -8227,7 +8210,6 @@ A07A4E0E178386390073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -8238,7 +8220,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8258,7 +8239,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8278,7 +8258,6 @@ A07A4F39178387670073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; @@ -8291,7 +8270,6 @@ A07A4F3A178387670073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; HEADER_SEARCH_PATHS = ""; @@ -8305,7 +8283,6 @@ A07A4F9C1783876B0073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; CLANG_WARN_BOOL_CONVERSION = NO; CLANG_WARN_CONSTANT_CONVERSION = NO; EXECUTABLE_PREFIX = ""; @@ -8324,7 +8301,6 @@ A07A4F9D1783876B0073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD)"; CLANG_WARN_BOOL_CONVERSION = NO; CLANG_WARN_CONSTANT_CONVERSION = NO; EXECUTABLE_PREFIX = ""; @@ -8345,7 +8321,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8364,7 +8339,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8384,7 +8358,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8403,7 +8376,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8423,7 +8395,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8444,7 +8415,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8466,7 +8436,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8487,7 +8456,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8509,7 +8477,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8530,7 +8497,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8552,7 +8518,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8573,7 +8538,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8595,7 +8559,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8619,7 +8582,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8644,7 +8606,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8663,7 +8624,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8683,7 +8643,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8702,7 +8661,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8722,7 +8680,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8741,7 +8698,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8761,7 +8717,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8783,7 +8738,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index b71dae873f..6613a084c1 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -969,6 +969,8 @@ 3EA0FB72191C844400B170C8 /* UIVideoPlayerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA0FB70191C844400B170C8 /* UIVideoPlayerTest.cpp */; }; 59620E8F1921E5CF002021B6 /* Bug-Child.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59620E8D1921E5CF002021B6 /* Bug-Child.cpp */; }; 59620E901921E5CF002021B6 /* Bug-Child.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59620E8D1921E5CF002021B6 /* Bug-Child.cpp */; }; + 5EBEECB01995247000429821 /* DrawNode3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EBEECAE1995247000429821 /* DrawNode3D.cpp */; }; + 5EBEECB11995247000429821 /* DrawNode3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EBEECAE1995247000429821 /* DrawNode3D.cpp */; }; A05FCACA177C124500BE600E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64822165F391E007D4F18 /* Cocoa.framework */; }; A07A521E1783A1D20073F6A7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C6482E165F399D007D4F18 /* libz.dylib */; }; A07A521F1783A1D20073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64832165F3AFD007D4F18 /* Foundation.framework */; }; @@ -3659,6 +3661,8 @@ 46A15F9C1807A4F8005B8026 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = cocos2d_libs.xcodeproj; sourceTree = ""; }; 59620E8D1921E5CF002021B6 /* Bug-Child.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "Bug-Child.cpp"; sourceTree = ""; }; 59620E8E1921E5CF002021B6 /* Bug-Child.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bug-Child.h"; sourceTree = ""; }; + 5EBEECAE1995247000429821 /* DrawNode3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DrawNode3D.cpp; path = Sprite3DTest/DrawNode3D.cpp; sourceTree = ""; }; + 5EBEECAF1995247000429821 /* DrawNode3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DrawNode3D.h; path = Sprite3DTest/DrawNode3D.h; sourceTree = ""; }; 70A7F72D191D3E4900F0F206 /* shaderTest.psh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = shaderTest.psh.h; sourceTree = ""; }; 70A7F730191D421B00F0F206 /* ShaderTest.vsh.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ShaderTest.vsh.h; sourceTree = ""; }; A035A71117822E9E00987F6C /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; @@ -7891,6 +7895,8 @@ 3E92EA7D1921A0C60094CD21 /* Sprite3DTest */ = { isa = PBXGroup; children = ( + 5EBEECAE1995247000429821 /* DrawNode3D.cpp */, + 5EBEECAF1995247000429821 /* DrawNode3D.h */, 3E92EA801921A1400094CD21 /* Sprite3DTest.cpp */, 3E92EA811921A1400094CD21 /* Sprite3DTest.h */, ); @@ -9154,6 +9160,7 @@ 29080DC3191B595E0066F8DF /* UIScene.cpp in Sources */, 29080D9B191B595E0066F8DF /* CustomParticleWidget.cpp in Sources */, 29080D8D191B595E0066F8DF /* CocosGUIScene.cpp in Sources */, + 5EBEECB01995247000429821 /* DrawNode3D.cpp in Sources */, 1AC35BED18CECF0C00F37B72 /* CCControlStepperTest.cpp in Sources */, 1AC35C3318CECF0C00F37B72 /* PerformanceScenarioTest.cpp in Sources */, 1AC35C5918CECF0C00F37B72 /* TextureAtlasEncryptionTest.cpp in Sources */, @@ -9248,6 +9255,7 @@ 29080DB4191B595E0066F8DF /* UILayoutTest_Editor.cpp in Sources */, 1AC35C4E18CECF0C00F37B72 /* SpineTest.cpp in Sources */, 1AC35C1E18CECF0C00F37B72 /* NewRendererTest.cpp in Sources */, + 5EBEECB11995247000429821 /* DrawNode3D.cpp in Sources */, 1AC35B6818CECF0C00F37B72 /* AnimationsTestLayer.cpp in Sources */, 29080D8E191B595E0066F8DF /* CocosGUIScene.cpp in Sources */, 1AC35BFA18CECF0C00F37B72 /* WebSocketTest.cpp in Sources */, diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 76438101b1..5cc5fe475a 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -207,6 +207,9 @@ bool Mesh::init(const std::vector& positions, const std::vector& n buildSubMeshes(); buildBuffer(); + + calcuOriginAABB(positions, 3); + return true; } @@ -220,6 +223,10 @@ bool Mesh::init(const std::vector& vertices, int vertexSizeInFloat, const buildSubMeshes(); buildBuffer(); + + unsigned int perVertexSize = _renderdata.calVertexSizeBytes() / sizeof(float); + calcuOriginAABB(vertices, perVertexSize); + return true; } @@ -245,6 +252,16 @@ void Mesh::cleanAndFreeBuffers() } } +void Mesh::calcuOriginAABB(const std::vector& vertices, unsigned int stride) +{ + ssize_t vertexNum = vertices.size() / stride; + for(unsigned int i = 0; i < vertexNum; i++) + { + Vec3 point = Vec3(vertices[i * stride], vertices[i * stride + 1], vertices[i * stride + 2]); + _originAABB.updateMinMax(&point, 1); + } +} + void Mesh::buildBuffer() { cleanAndFreeBuffers(); @@ -273,6 +290,11 @@ void Mesh::restore() buildBuffer(); } +const AABB& Mesh::getOriginAABB() const +{ + return _originAABB; +} + /** * MeshCache */ diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index 2cea95b189..d88f30d7ea 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -37,6 +37,9 @@ #include "math/CCMath.h" #include "renderer/CCGLProgram.h" +#include "CCAABB.h" + + NS_CC_BEGIN class EventListenerCustom; @@ -121,6 +124,9 @@ public: /**build vertex buffer from renderdata*/ void restore(); + /** get origin aabb that calculate from vertices*/ + const AABB& getOriginAABB() const; + /**to be deprecated, those functions have been moved to SubMesh*/ /** get primitive type*/ CC_DEPRECATED_ATTRIBUTE PrimitiveType getPrimitiveType() const { return _subMeshes.at(0)->getPrimitiveType(); } @@ -147,12 +153,21 @@ CC_CONSTRUCTOR_ACCESS: void buildBuffer(); /**free buffer*/ void cleanAndFreeBuffers(); + + /* + * calculate AABB by origin vertices + * @param the vertices list + * @param stride the stride between two vertex's position data. + */ + void calcuOriginAABB(const std::vector& vertices, unsigned int stride); protected: GLuint _vertexBuffer; Vector _subMeshes; RenderMeshData _renderdata; + + AABB _originAABB; }; /** diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 0bbc9ccd58..629c141c30 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -399,4 +399,29 @@ const BlendFunc& Sprite3D::getBlendFunc() const return _blend; } +AABB Sprite3D::getAABB() const +{ + AABB aabb = _mesh->getOriginAABB(); + Mat4 transform; + + if (getSkin() && getSkin()->getRootBone()) + { + transform = getNodeToWorldTransform() * getSkin()->getRootBone()->getWorldMat(); + } + else + { + transform = getNodeToWorldTransform(); + } + + aabb.transform(transform); + return aabb; +} + +Rect Sprite3D::getBoundingBox() const +{ + AABB aabb = getAABB(); + Rect ret(aabb._min.x, aabb._min.y, (aabb._max.x - aabb._min.x), (aabb._max.y - aabb._min.y)); + return ret; +} + NS_CC_END diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 734f52c675..340a6ca9c2 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -33,6 +33,7 @@ #include "base/CCProtocols.h" #include "2d/CCNode.h" #include "renderer/CCMeshCommand.h" +#include "CCAABB.h" NS_CC_BEGIN @@ -79,6 +80,20 @@ public: // overrides virtual void setBlendFunc(const BlendFunc &blendFunc) override; virtual const BlendFunc &getBlendFunc() const override; + + /* + * Get AABB + * If the sprite has animation, it can't be calculated accuratly, + * because bone can drive the vertices, we just use the origin vertices + * to calculate the AABB. + */ + AABB getAABB() const; + + /** + * Returns 2d bounding-box + * Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate. + */ + virtual Rect getBoundingBox() const override; CC_CONSTRUCTOR_ACCESS: diff --git a/tests/cpp-tests/Android.mk b/tests/cpp-tests/Android.mk index 994ba9f81d..9b69186e42 100644 --- a/tests/cpp-tests/Android.mk +++ b/tests/cpp-tests/Android.mk @@ -168,6 +168,7 @@ Classes/ShaderTest/ShaderTest.cpp \ Classes/ShaderTest/ShaderTest2.cpp \ Classes/SpineTest/SpineTest.cpp \ Classes/SpriteTest/SpriteTest.cpp \ +Classes/Sprite3DTest/DrawNode3D.cpp \ Classes/Sprite3DTest/Sprite3DTest.cpp \ Classes/TextInputTest/TextInputTest.cpp \ Classes/Texture2dTest/Texture2dTest.cpp \ diff --git a/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp b/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp new file mode 100644 index 0000000000..acb88b95e9 --- /dev/null +++ b/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.cpp @@ -0,0 +1,240 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "DrawNode3D.h" +#include "CCGL.h" +#include "base/CCEventType.h" +#include "base/CCConfiguration.h" +#include "renderer/CCCustomCommand.h" +#include "renderer/CCRenderer.h" +#include "renderer/CCGLProgramState.h" +#include "base/CCDirector.h" +#include "base/CCEventListenerCustom.h" +#include "base/CCEventDispatcher.h" + +NS_CC_BEGIN + + +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 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 diff --git a/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.h b/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.h new file mode 100644 index 0000000000..240bb025ee --- /dev/null +++ b/tests/cpp-tests/Classes/Sprite3DTest/DrawNode3D.h @@ -0,0 +1,117 @@ +/**************************************************************************** + Copyright (c) 2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __DRAW_NODE_3D_H__ +#define __DRAW_NODE_3D_H__ + +#include "2d/CCNode.h" +#include "base/ccTypes.h" +#include "renderer/CCCustomCommand.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); +}; + +NS_CC_END + +#endif // __DRAW_NODE_3D_H__ diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 2ce7ce40e0..54100ba464 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -29,6 +29,7 @@ #include "3d/CCSubMesh.h" #include "3d/CCAttachNode.h" #include "3d/CCRay.h" +#include "DrawNode3D.h" #include #include "../testResource.h" @@ -1026,9 +1027,7 @@ void Sprite3DWithOBBPerfromanceTest::addNewSpriteWithCoords(Vec2 p) seq->setTag(100); sprite->runAction(seq); - //Generate OBB by AABB - Vec3 extents = Vec3(50, 25, 25); - AABB aabb(-extents, extents); + AABB aabb = _sprite->getAABB(); _obbt = OBB(aabb); _drawDebug = DrawNode3D::create(); diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 6b97aac4d6..e82f5491e9 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -34,6 +34,7 @@ namespace cocos2d { class Sprite3D; class Delay; class Ray; + class DrawNode3D; } class Sprite3DTestDemo : public BaseTest From 504ef32b97c6417f61531853cb40f33cb5991168 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 8 Aug 2014 18:14:41 +0800 Subject: [PATCH 07/42] linux --- tests/cpp-tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 439db8020c..ac88ce2b90 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -162,6 +162,7 @@ set(SAMPLE_SRC Classes/ShaderTest/ShaderTest2.cpp Classes/SpriteTest/SpriteTest.cpp Classes/Sprite3DTest/Sprite3DTest.cpp + Classes/Sprite3DTest/CCDrawNode3D.cpp Classes/TextInputTest/TextInputTest.cpp Classes/Texture2dTest/Texture2dTest.cpp Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp From e904ee646a3f96914fe0657960980dbebf27df86 Mon Sep 17 00:00:00 2001 From: yangxiao1 Date: Fri, 8 Aug 2014 18:25:36 +0800 Subject: [PATCH 08/42] windows work --- tests/cpp-tests/proj.win32/cpp-tests.vcxproj | 2 ++ tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj index 394aa71ab2..27cc2c0735 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj @@ -183,6 +183,7 @@ + @@ -370,6 +371,7 @@ + diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters index eee082ff8a..e815660d53 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters @@ -864,6 +864,9 @@ Classes\Camera3DTest + + Classes\Sprite3DTest + @@ -1595,5 +1598,8 @@ Classes\Camera3DTest + + Classes\Sprite3DTest + \ No newline at end of file From 73a0b7701d6315581942be062d302a89ec127ce4 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Sat, 9 Aug 2014 00:02:19 +0800 Subject: [PATCH 09/42] remove normalize --- cocos/3d/CCRay.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/cocos/3d/CCRay.cpp b/cocos/3d/CCRay.cpp index 8d8275af18..b49fd17343 100755 --- a/cocos/3d/CCRay.cpp +++ b/cocos/3d/CCRay.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. NS_CC_BEGIN Ray::Ray() - : _direction(0, 0, 1) +: _direction(0, 0, 1) { } @@ -146,7 +146,6 @@ void Ray::set(const Vec3& origin, const Vec3& direction) { _origin = origin; _direction = direction; - normalize(); } void Ray::transform(const Mat4& matrix) @@ -156,21 +155,4 @@ void Ray::transform(const Mat4& matrix) _direction.normalize(); } -void Ray::normalize() -{ - if (_direction.isZero()) - { - return; - } - - // Normalize the ray's direction vector. - float normalizeFactor = 1.0f / sqrt(_direction.x * _direction.x + _direction.y * _direction.y + _direction.z * _direction.z); - if (normalizeFactor != 1.0f) - { - _direction.x *= normalizeFactor; - _direction.y *= normalizeFactor; - _direction.z *= normalizeFactor; - } -} - NS_CC_END From 53c143c67936c2a138af1754f4af9b8a7ba2629a Mon Sep 17 00:00:00 2001 From: yangxiao Date: Sat, 9 Aug 2014 00:02:40 +0800 Subject: [PATCH 10/42] remove normalize --- cocos/3d/CCRay.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cocos/3d/CCRay.h b/cocos/3d/CCRay.h index 7c60c35635..0deab2a68a 100755 --- a/cocos/3d/CCRay.h +++ b/cocos/3d/CCRay.h @@ -83,11 +83,6 @@ public: */ void transform(const Mat4& matrix); - /** - * Normalizes the ray. - */ - void normalize(); - Vec3 _origin; // The ray origin position. Vec3 _direction; // The ray direction vector. }; From 754a78bd26a2f78c6aad17fc34fcf30682d24606 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Sat, 9 Aug 2014 00:03:11 +0800 Subject: [PATCH 11/42] can not export aabb obb ray --- tools/tolua/cocos2dx.ini | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index b89d890a58..146766e652 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -126,14 +126,17 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS TurnOffTiles::[shuffle], LabelTTF::[*], LabelBMFont::[*], - Mesh::[create], + Mesh::[create getOriginAABB], SubMeshState::[getSkin setSkin create], - Sprite3D::[getSkin getSubMeshState], + Sprite3D::[getSkin getSubMeshState getAABB], Animation3D::[getBoneCurveByName], Animation3DCache::[*], Sprite3DMaterialCache::[*], Bone3D::[*], - Scene::[getCameras] + Scene::[getCameras], + Ray::[*], + AABB::[*], + OBB::[*] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], From 933439c6ca5ff588fe8757413051b0b84b186625 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Sat, 9 Aug 2014 09:27:48 +0800 Subject: [PATCH 12/42] fix linux --- tests/cpp-tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index ac88ce2b90..e457e435f2 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -162,7 +162,7 @@ set(SAMPLE_SRC Classes/ShaderTest/ShaderTest2.cpp Classes/SpriteTest/SpriteTest.cpp Classes/Sprite3DTest/Sprite3DTest.cpp - Classes/Sprite3DTest/CCDrawNode3D.cpp + Classes/Sprite3DTest/DrawNode3D.cpp Classes/TextInputTest/TextInputTest.cpp Classes/Texture2dTest/Texture2dTest.cpp Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp From 2576622778a9773ab7ca7e4dc654fa62ccc086db Mon Sep 17 00:00:00 2001 From: yangxiao Date: Mon, 11 Aug 2014 10:07:23 +0800 Subject: [PATCH 13/42] move create camera to Scene::initWithSize --- cocos/2d/CCScene.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 5fc4c3bd14..f373ec8017 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -54,16 +54,16 @@ Scene::~Scene() bool Scene::init() { - //create default camera - auto camera = Camera::create(); - addChild(camera); - auto size = Director::getInstance()->getWinSize(); return initWithSize(size); } bool Scene::initWithSize(const Size& size) { + //create default camera + auto camera = Camera::create(); + addChild(camera); + setContentSize(size); return true; } From c592ac4248392571afa6603d7863656295eaa1ac Mon Sep 17 00:00:00 2001 From: lvlong Date: Mon, 11 Aug 2014 10:40:34 +0800 Subject: [PATCH 14/42] for pull request modify!! --- cocos/3d/CCAABB.cpp | 13 ++++-- cocos/3d/CCAABB.h | 5 +- cocos/3d/CCMesh.cpp | 6 +-- cocos/3d/CCMesh.h | 2 +- cocos/3d/CCOBB.cpp | 109 ++++++++++++++++++++++++-------------------- cocos/3d/CCOBB.h | 7 ++- cocos/3d/CCRay.cpp | 76 +++++++++++++++--------------- 7 files changed, 119 insertions(+), 99 deletions(-) diff --git a/cocos/3d/CCAABB.cpp b/cocos/3d/CCAABB.cpp index 0cc13f2e46..f56c06f12e 100755 --- a/cocos/3d/CCAABB.cpp +++ b/cocos/3d/CCAABB.cpp @@ -149,8 +149,13 @@ void AABB::updateMinMax(const Vec3* point, ssize_t num) } } -void AABB::transform(const Mat4& matrix) +void AABB::transform(const Mat4& mat) { + // if _transform matrix isn't changed, just return. + int size = sizeof(Mat4); + if (memcmp(&_transform, &mat, size) == 0) + return; + Vec3 corners[8]; // Near face, specified counter-clockwise // Left-top-front. @@ -172,11 +177,9 @@ void AABB::transform(const Mat4& matrix) // Left-top-back. corners[7].set(_min.x, _max.y, _min.z); - // Transform the corners, recalculating the min and max points along the way. - //matrix.transformPoint(&corners[0]); - + // Transform the corners, recalculate the min and max points along the way. for (int i = 0; i < 8; i++) - matrix.transformPoint(&corners[i]); + mat.transformPoint(&corners[i]); reset(); diff --git a/cocos/3d/CCAABB.h b/cocos/3d/CCAABB.h index 97d25a09fe..e560f3456c 100755 --- a/cocos/3d/CCAABB.h +++ b/cocos/3d/CCAABB.h @@ -102,7 +102,10 @@ public: /** * Transforms the bounding box by the given transformation matrix. */ - void transform(const Mat4& matrix); + void transform(const Mat4& mat); + +private: + Mat4 _transform; public: Vec3 _min; diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 5cc5fe475a..16007b1588 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -208,7 +208,7 @@ bool Mesh::init(const std::vector& positions, const std::vector& n buildBuffer(); - calcuOriginAABB(positions, 3); + calOriginAABB(positions, 3); return true; } @@ -225,7 +225,7 @@ bool Mesh::init(const std::vector& vertices, int vertexSizeInFloat, const buildBuffer(); unsigned int perVertexSize = _renderdata.calVertexSizeBytes() / sizeof(float); - calcuOriginAABB(vertices, perVertexSize); + calOriginAABB(vertices, perVertexSize); return true; } @@ -252,7 +252,7 @@ void Mesh::cleanAndFreeBuffers() } } -void Mesh::calcuOriginAABB(const std::vector& vertices, unsigned int stride) +void Mesh::calOriginAABB(const std::vector& vertices, unsigned int stride) { ssize_t vertexNum = vertices.size() / stride; for(unsigned int i = 0; i < vertexNum; i++) diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index d88f30d7ea..304a09f207 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -159,7 +159,7 @@ CC_CONSTRUCTOR_ACCESS: * @param the vertices list * @param stride the stride between two vertex's position data. */ - void calcuOriginAABB(const std::vector& vertices, unsigned int stride); + void calOriginAABB(const std::vector& vertices, unsigned int stride); protected: GLuint _vertexBuffer; diff --git a/cocos/3d/CCOBB.cpp b/cocos/3d/CCOBB.cpp index 65a7e2b733..c191fee9fc 100755 --- a/cocos/3d/CCOBB.cpp +++ b/cocos/3d/CCOBB.cpp @@ -28,7 +28,7 @@ NS_CC_BEGIN #define ROTATE(a,i,j,k,l) g=a.m[i + 4 * j]; h=a.m[k + 4 * l]; a.m[i + 4 * j]=(float)(g-s*(h+g*tau)); a.m[k + 4 * l]=(float)(h+s*(g-h*tau)); -static Mat4 _convarianceMatrix(const Vec3* aVertPos, int nVertCount) +static Mat4 _getConvarianceMatrix(const Vec3* vertPos, int vertCount) { int i; Mat4 Cov; @@ -42,21 +42,21 @@ static Mat4 _convarianceMatrix(const Vec3* aVertPos, int nVertCount) S2[0][2] = S2[1][2] = S2[2][2] = 0.0; // get center of mass - for(i=0; i3 && fabs(dmip)+g==fabs(dmip) && fabs(dmiq)+g==fabs(dmiq) ) - a.m[ip + 4 * iq]=0.0; - else if (fabs(a.m[ip + 4 * iq])>tresh) + + if( i>3 && fabs(dmip) + g == fabs(dmip) && fabs(dmiq) + g == fabs(dmiq) ) { - h = dmiq-dmip; - if (fabs(h)+g == fabs(h)) + a.m[ip + 4 * iq] = 0.0; + } + else if (fabs(a.m[ip + 4 * iq]) > tresh) + { + h = dmiq - dmip; + if (fabs(h) + g == fabs(h)) + { t=(a.m[ip + 4 * iq])/h; + } else { - theta=0.5*h/(a.m[ip + 4 * iq]); - t=1.0/(fabs(theta)+sqrt(1.0+theta*theta)); + theta = 0.5 * h / (a.m[ip + 4 * iq]); + t=1.0 / (fabs(theta) + sqrt(1.0 + theta * theta)); if (theta < 0.0) t = -t; } - c=1.0/sqrt(1+t*t); - s=t*c; - tau=s/(1.0+c); - h=t*a.m[ip + 4 * iq]; + c = 1.0 / sqrt(1+t*t); + s = t*c; + tau = s / (1.0+c); + h = t * a.m[ip + 4 * iq]; _getElement(z, ip) -= (float)h; _getElement(z, iq) += (float)h; _getElement(d, ip) -= (float)h; _getElement(d, iq) += (float)h; a.m[ip + 4 * iq]=0.0; - for(j=0;j 0) t = (min.x - origin.x) / dir.x; else t = (max.x - origin.x) / dir.x; - if (t > 0.f) - { - ptOnPlane = origin + t * dir; - - if (min.y < ptOnPlane.y && ptOnPlane.y < max.y && min.z < ptOnPlane.z && ptOnPlane.z < max.z) - { - return true; - } - } - } + if (t > 0.f) + { + ptOnPlane = origin + t * dir; + + if (min.y < ptOnPlane.y && ptOnPlane.y < max.y && min.z < ptOnPlane.z && ptOnPlane.z < max.z) + { + return true; + } + } + } - if (dir.y != 0.f) - { + if (dir.y != 0.f) + { if (dir.y > 0) t = (min.y - origin.y) / dir.y; else t = (max.y - origin.y) / dir.y; - if (t > 0.f) - { - ptOnPlane = origin + t * dir; - - if (min.z < ptOnPlane.z && ptOnPlane.z < max.z && min.x < ptOnPlane.x && ptOnPlane.x < max.x) - { - return true; - } - } - } + if (t > 0.f) + { + ptOnPlane = origin + t * dir; + + if (min.z < ptOnPlane.z && ptOnPlane.z < max.z && min.x < ptOnPlane.x && ptOnPlane.x < max.x) + { + return true; + } + } + } if (dir.z != 0.f) { @@ -94,18 +94,18 @@ bool Ray::intersects(const AABB& aabb) const else t = (max.z - origin.z) / dir.z; - if (t > 0.f) - { - ptOnPlane = origin + t * dir; + if (t > 0.f) + { + ptOnPlane = origin + t * dir; - if (min.x < ptOnPlane.x && ptOnPlane.x < max.x && min.y < ptOnPlane.y && ptOnPlane.y < max.y) - { - return true; - } - } - } + if (min.x < ptOnPlane.x && ptOnPlane.x < max.x && min.y < ptOnPlane.y && ptOnPlane.y < max.y) + { + return true; + } + } + } - return false; + return false; } bool Ray::intersects(const OBB& obb) const From f191bebe7224fd24234c49ffdc53e1a5b0d3d05a Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 12 Aug 2014 13:45:06 +0800 Subject: [PATCH 15/42] optimize Sprite3D get aabb. --- cocos/3d/CCAABB.cpp | 5 ----- cocos/3d/CCAABB.h | 3 --- cocos/3d/CCOBB.cpp | 4 ---- cocos/3d/CCOBB.h | 3 --- cocos/3d/CCSprite3D.cpp | 22 +++++++++++++++------- cocos/3d/CCSprite3D.h | 3 +++ 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/cocos/3d/CCAABB.cpp b/cocos/3d/CCAABB.cpp index f56c06f12e..4c159ae8b8 100755 --- a/cocos/3d/CCAABB.cpp +++ b/cocos/3d/CCAABB.cpp @@ -151,11 +151,6 @@ void AABB::updateMinMax(const Vec3* point, ssize_t num) void AABB::transform(const Mat4& mat) { - // if _transform matrix isn't changed, just return. - int size = sizeof(Mat4); - if (memcmp(&_transform, &mat, size) == 0) - return; - Vec3 corners[8]; // Near face, specified counter-clockwise // Left-top-front. diff --git a/cocos/3d/CCAABB.h b/cocos/3d/CCAABB.h index e560f3456c..8894aa0098 100755 --- a/cocos/3d/CCAABB.h +++ b/cocos/3d/CCAABB.h @@ -104,9 +104,6 @@ public: */ void transform(const Mat4& mat); -private: - Mat4 _transform; - public: Vec3 _min; Vec3 _max; diff --git a/cocos/3d/CCOBB.cpp b/cocos/3d/CCOBB.cpp index c191fee9fc..f74bf96a47 100755 --- a/cocos/3d/CCOBB.cpp +++ b/cocos/3d/CCOBB.cpp @@ -421,10 +421,6 @@ bool OBB::intersects(const OBB& box) const void OBB::transform(const Mat4& mat) { - int size = sizeof(Mat4); - if (memcmp(&_transform, &mat, size) == 0) - return; - Vec4 newcenter = mat * Vec4(_center.x, _center.y, _center.z, 1.0f);// center; _center.x = newcenter.x; _center.y = newcenter.y; diff --git a/cocos/3d/CCOBB.h b/cocos/3d/CCOBB.h index 9b797c9746..95776bd5f5 100755 --- a/cocos/3d/CCOBB.h +++ b/cocos/3d/CCOBB.h @@ -104,9 +104,6 @@ protected: */ Vec3 getFaceDir(int index) const; -private: - Mat4 _transform; - public: Vec3 _center; // obb center Vec3 _xAxis; // x axis of obb, unit vector diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index 629c141c30..acc03c1d18 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -401,20 +401,28 @@ const BlendFunc& Sprite3D::getBlendFunc() const AABB Sprite3D::getAABB() const { - AABB aabb = _mesh->getOriginAABB(); - Mat4 transform; + Mat4 nodeToWorldTransform(getNodeToWorldTransform()); - if (getSkin() && getSkin()->getRootBone()) + // If nodeToWorldTransform matrix isn't changed, we don't need to transform aabb. + if (memcmp(_nodeToWorldTransform.m, nodeToWorldTransform.m, sizeof(Mat4)) == 0) { - transform = getNodeToWorldTransform() * getSkin()->getRootBone()->getWorldMat(); + return _aabb; } else { - transform = getNodeToWorldTransform(); + Mat4 transform(nodeToWorldTransform); + _aabb = _mesh->getOriginAABB(); + + if (getSkin() && getSkin()->getRootBone()) + { + transform = nodeToWorldTransform * getSkin()->getRootBone()->getWorldMat(); + } + + _aabb.transform(transform); + _nodeToWorldTransform = nodeToWorldTransform; } - aabb.transform(transform); - return aabb; + return _aabb; } Rect Sprite3D::getBoundingBox() const diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 340a6ca9c2..49a1282e89 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -134,6 +134,9 @@ protected: std::unordered_map _attachments; BlendFunc _blend; + + mutable AABB _aabb; // cache current aabb + mutable Mat4 _nodeToWorldTransform; // cache the matrix }; extern std::string CC_DLL s_attributeNames[];//attribute names array From 510b72d7c8f10d7f6257c936069a148b219a22ba Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 12 Aug 2014 15:21:21 +0800 Subject: [PATCH 16/42] reset cocos2d project --- build/cocos2d_libs.xcodeproj/project.pbxproj | 46 ++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 12a9dde1f8..e5b3dbac4b 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -7867,6 +7867,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_BOOL_CONVERSION = YES; @@ -7904,6 +7905,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_BOOL_CONVERSION = YES; @@ -7938,6 +7940,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_EXTENSION = a; EXECUTABLE_PREFIX = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -7970,6 +7973,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_EXTENSION = a; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; @@ -8002,6 +8006,7 @@ A03F2CB61780BD04006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; HEADER_SEARCH_PATHS = ""; @@ -8012,6 +8017,7 @@ A03F2CB71780BD04006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; @@ -8023,6 +8029,7 @@ A03F2D991780BDF7006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; CLANG_WARN_BOOL_CONVERSION = NO; CLANG_WARN_CONSTANT_CONVERSION = NO; EXECUTABLE_PREFIX = ""; @@ -8038,6 +8045,7 @@ A03F2D9A1780BDF7006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; CLANG_WARN_BOOL_CONVERSION = NO; CLANG_WARN_CONSTANT_CONVERSION = NO; EXECUTABLE_PREFIX = ""; @@ -8054,6 +8062,7 @@ A03F2E90178141C1006731B9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "COCOS2D_DEBUG=1", @@ -8070,6 +8079,7 @@ A03F2E91178141C1006731B9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; HEADER_SEARCH_PATHS = ( "$(inherited)", "/Applications/Xcode\\ 2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", @@ -8081,6 +8091,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; GCC_TREAT_WARNINGS_AS_ERRORS = NO; @@ -8093,6 +8104,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC; @@ -8106,6 +8118,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = ""; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8124,6 +8137,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; CODE_SIGN_IDENTITY = ""; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; @@ -8143,6 +8157,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../cocos/cocos2d-prefix.pch"; @@ -8172,6 +8187,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -8201,6 +8217,7 @@ A07A4E0D178386390073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -8210,6 +8227,7 @@ A07A4E0E178386390073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -8220,6 +8238,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8239,6 +8258,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8258,6 +8278,7 @@ A07A4F39178387670073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; HEADER_SEARCH_PATHS = ""; IPHONEOS_DEPLOYMENT_TARGET = 5.1.1; @@ -8270,6 +8291,7 @@ A07A4F3A178387670073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; HEADER_SEARCH_PATHS = ""; @@ -8283,6 +8305,7 @@ A07A4F9C1783876B0073F6A7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; CLANG_WARN_BOOL_CONVERSION = NO; CLANG_WARN_CONSTANT_CONVERSION = NO; EXECUTABLE_PREFIX = ""; @@ -8301,6 +8324,7 @@ A07A4F9D1783876B0073F6A7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; CLANG_WARN_BOOL_CONVERSION = NO; CLANG_WARN_CONSTANT_CONVERSION = NO; EXECUTABLE_PREFIX = ""; @@ -8321,6 +8345,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8339,6 +8364,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8358,6 +8384,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8376,6 +8403,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8395,6 +8423,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8415,6 +8444,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8436,6 +8466,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8456,6 +8487,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8477,6 +8509,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8497,6 +8530,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8518,6 +8552,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8538,6 +8573,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8559,6 +8595,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8582,6 +8619,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8606,6 +8644,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8624,6 +8663,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8643,6 +8683,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8661,6 +8702,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8680,6 +8722,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8698,6 +8741,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -8717,6 +8761,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", @@ -8738,6 +8783,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = YES; + ARCHS = "$(ARCHS_STANDARD)"; EXECUTABLE_PREFIX = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( From cfafeb1e87d2dbfa48d08f6143f4f837b7508b06 Mon Sep 17 00:00:00 2001 From: Mircea Rila Date: Tue, 12 Aug 2014 22:22:47 +0300 Subject: [PATCH 17/42] add minimize / restore for win32 --- cocos/platform/desktop/CCGLViewImpl.cpp | 22 ++++++++++++++++++++++ cocos/platform/desktop/CCGLViewImpl.h | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cocos/platform/desktop/CCGLViewImpl.cpp b/cocos/platform/desktop/CCGLViewImpl.cpp index 515e1272cf..cb8976fa92 100644 --- a/cocos/platform/desktop/CCGLViewImpl.cpp +++ b/cocos/platform/desktop/CCGLViewImpl.cpp @@ -24,6 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCGLViewImpl.h" +#include "CCApplication.h" #include "base/CCDirector.h" #include "base/CCTouch.h" #include "base/CCEventDispatcher.h" @@ -101,6 +102,14 @@ public: _view = view; } + static void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified) + { + if (_view) + { + _view->onGLFWWindowIconifyCallback(window, iconified); + } + } + private: static GLViewImpl* _view; }; @@ -352,6 +361,7 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback); glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWframebuffersize); glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeFunCallback); + glfwSetWindowIconifyCallback(_mainWindow, GLFWEventHandler::onGLFWWindowIconifyCallback); setFrameSize(rect.size.width, rect.size.height); @@ -709,6 +719,18 @@ void GLViewImpl::onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int } } +void GLViewImpl::onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified) +{ + if (iconified == GL_TRUE) + { + Application::getInstance()->applicationDidEnterBackground(); + } + else + { + Application::getInstance()->applicationWillEnterForeground(); + } +} + #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) static bool glew_dynamic_binding() { diff --git a/cocos/platform/desktop/CCGLViewImpl.h b/cocos/platform/desktop/CCGLViewImpl.h index a9befbbd51..0bd3fd0373 100644 --- a/cocos/platform/desktop/CCGLViewImpl.h +++ b/cocos/platform/desktop/CCGLViewImpl.h @@ -130,8 +130,9 @@ protected: void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y); void onGLFWframebuffersize(GLFWwindow* window, int w, int h); void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height); + void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified); - bool _captured; + bool _captured; bool _supportTouch; bool _isInRetinaMonitor; bool _isRetinaEnabled; From 5a42a94d21268b5d681e472af7f172de2f9421a6 Mon Sep 17 00:00:00 2001 From: Mircea Rila Date: Tue, 12 Aug 2014 22:31:28 +0300 Subject: [PATCH 18/42] update AUTHORS --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 6ab981b04e..40ef469e80 100644 --- a/AUTHORS +++ b/AUTHORS @@ -974,6 +974,9 @@ Developers: DavidPartouche Fixed the bug that video player not showing on iOS if it's not in FullScreen mode + + zaWasp + Added support for applicationDidEnterBackground / applicationWillEnterForeground on win32 Retired Core Developers: WenSheng Yang From 18851d3e815622be9933b19a9ddee6e21af7d587 Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 14 Aug 2014 11:14:24 +0800 Subject: [PATCH 19/42] add customization to UIButton and UIPageView --- cocos/ui/UIButton.cpp | 17 ++- cocos/ui/UIButton.h | 11 +- cocos/ui/UIPageView.cpp | 31 +++++- cocos/ui/UIPageView.h | 21 +++- .../CocoStudioGUITest/CocosGUIScene.cpp | 4 +- .../UIButtonTest/UIButtonTest.cpp | 68 ++++++++++++ .../UIButtonTest/UIButtonTest.h | 13 +++ .../UIPageViewTest/UIPageViewTest.cpp | 100 ++++++++++++++++++ .../UIPageViewTest/UIPageViewTest.h | 15 +++ .../CocoStudioGUITest/UISceneManager.cpp | 5 + .../UITest/CocoStudioGUITest/UISceneManager.h | 2 + 11 files changed, 278 insertions(+), 9 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 25bc9dcd50..468103761a 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -64,6 +64,7 @@ _normalTextureScaleXInSize(1.0f), _normalTextureScaleYInSize(1.0f), _pressedTextureScaleXInSize(1.0f), _pressedTextureScaleYInSize(1.0f), +_zoomScale(0.1f), _normalTextureLoaded(false), _pressedTextureLoaded(false), _disabledTextureLoaded(false), @@ -386,9 +387,9 @@ void Button::onPressStateChangedToPressed() { _buttonNormalRenderer->stopAllActions(); _buttonClickedRenderer->stopAllActions(); - Action *zoomAction = ScaleTo::create(0.05f, _pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f); + Action *zoomAction = ScaleTo::create(0.05f, _pressedTextureScaleXInSize + _zoomScale, _pressedTextureScaleYInSize + _zoomScale); _buttonClickedRenderer->runAction(zoomAction); - _buttonNormalRenderer->setScale(_pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f); + _buttonNormalRenderer->setScale(_pressedTextureScaleXInSize + _zoomScale, _pressedTextureScaleYInSize + _zoomScale); } } else @@ -403,7 +404,7 @@ void Button::onPressStateChangedToPressed() else { _buttonNormalRenderer->stopAllActions(); - _buttonNormalRenderer->setScale(_normalTextureScaleXInSize + 0.1f, _normalTextureScaleYInSize + 0.1f); + _buttonNormalRenderer->setScale(_normalTextureScaleXInSize +_zoomScale, _normalTextureScaleYInSize + _zoomScale); } } } @@ -643,6 +644,16 @@ float Button::getTitleFontSize() const { return _fontSize; } + +void Button::setZoomScale(float scale) +{ + _zoomScale = scale; +} + +float Button::getZoomScale()const +{ + return _zoomScale; +} void Button::setTitleFontName(const std::string& fontName) { diff --git a/cocos/ui/UIButton.h b/cocos/ui/UIButton.h index e44e148024..6d33e19770 100644 --- a/cocos/ui/UIButton.h +++ b/cocos/ui/UIButton.h @@ -188,6 +188,14 @@ public: float getTitleFontSize() const; void setTitleFontName(const std::string& fontName); const std::string& getTitleFontName() const; + /** When user pressed the button, the button will zoom to a scale. + * The final scale of the button equals (button original scale + _zoomScale) + */ + void setZoomScale(float scale); + /** + * @brief Return a zoom scale + */ + float getZoomScale()const; CC_CONSTRUCTOR_ACCESS: virtual bool init() override; @@ -222,7 +230,8 @@ protected: Scale9Sprite* _buttonClickedRenderer; Scale9Sprite* _buttonDisableRenderer; Label* _titleRenderer; - + + float _zoomScale; std::string _normalFileName; std::string _clickedFileName; std::string _disabledFileName; diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index c884be87e4..c4222959bd 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -44,7 +44,9 @@ _autoScrollDirection(AutoScrollDirection::LEFT), _childFocusCancelOffset(5.0f), _pageViewEventListener(nullptr), _pageViewEventSelector(nullptr), -_eventCallback(nullptr) +_eventCallback(nullptr), +_customScrollThreshold(0.0), +_usingCustomCrollThreshold(false) { this->setTouchEnabled(true); } @@ -447,6 +449,28 @@ void PageView::handleMoveLogic(Touch *touch) } scrollPages(offset); } + +void PageView::setCustomScrollThreshold(float threshold) +{ + CCASSERT(threshold > 0, "Invalid threshold!"); + _customScrollThreshold = threshold; + this->setUsingCustomScrollThreshold(true); +} + +float PageView::getCustomScrollThreshold()const +{ + return _customScrollThreshold; +} + +void PageView::setUsingCustomScrollThreshold(bool flag) +{ + _usingCustomCrollThreshold = flag; +} + +bool PageView::isUsingCustomScrollThreshold()const +{ + return _usingCustomCrollThreshold; +} void PageView::handleReleaseLogic(Touch *touch) { @@ -461,7 +485,10 @@ void PageView::handleReleaseLogic(Touch *touch) ssize_t pageCount = this->getPageCount(); float curPageLocation = curPagePos.x; float pageWidth = getContentSize().width; - float boundary = pageWidth/2.0f; + if (!_usingCustomCrollThreshold) { + _customScrollThreshold = pageWidth / 2.0; + } + float boundary = _customScrollThreshold; if (curPageLocation <= -boundary) { if (_curPageIdx >= pageCount-1) diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 96d01c98df..2065f2fb73 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -168,6 +168,23 @@ public: virtual std::string getDescription() const override; virtual void onEnter() override; + /** + * @brief If you don't specify the value, the pageView will scroll when half pageview width reached + */ + void setCustomScrollThreshold(float threshold); + /** + *@brief Return user defined scroll page threshold + */ + float getCustomScrollThreshold()const; + /** + *@brief Set using user defined scroll page threshold or not + * If you set it to false, then the default scroll threshold is pageView.width / 2 + */ + void setUsingCustomScrollThreshold(bool flag); + /** + *@brief Query whether we are using user defined scroll page threshold or not + */ + bool isUsingCustomScrollThreshold()const; CC_CONSTRUCTOR_ACCESS: virtual bool init() override; @@ -219,7 +236,9 @@ protected: float _leftBoundary; float _rightBoundary; - + float _customScrollThreshold; + bool _usingCustomCrollThreshold; + float _childFocusCancelOffset; Ref* _pageViewEventListener; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp index 003a4e1f61..ab7dc67667 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/CocosGUIScene.cpp @@ -63,7 +63,7 @@ g_guisTests[] = UISceneManager* sceneManager = UISceneManager::sharedUISceneManager(); sceneManager->setCurrentUISceneId(kUIButtonTest); sceneManager->setMinUISceneId(kUIButtonTest); - sceneManager->setMaxUISceneId(kUIButtonTestSwitchScale9); + sceneManager->setMaxUISceneId(kUIButtonTestZoomScale); Scene* scene = sceneManager->currentUIScene(); Director::getInstance()->replaceScene(scene); } @@ -195,7 +195,7 @@ g_guisTests[] = UISceneManager* sceneManager = UISceneManager::sharedUISceneManager(); sceneManager->setCurrentUISceneId(kUIPageViewTest); sceneManager->setMinUISceneId(kUIPageViewTest); - sceneManager->setMaxUISceneId(kUIPageViewButtonTest); + sceneManager->setMaxUISceneId(kUIPageViewCustomScrollThreshold); Scene* scene = sceneManager->currentUIScene(); Director::getInstance()->replaceScene(scene); } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 68307eed18..9c1016f681 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -520,3 +520,71 @@ void UIButtonTestSwitchScale9::touchEvent(Ref *pSender, Widget::TouchEventType t break; } } + + +// UIButtonTestZoomScale +UIButtonTestZoomScale::UIButtonTestZoomScale() +: _displayValueLabel(nullptr) +{ + +} + +UIButtonTestZoomScale::~UIButtonTestZoomScale() +{ +} + +bool UIButtonTestZoomScale::init() +{ + if (UIScene::init()) + { + Size widgetSize = _widget->getContentSize(); + + // Add a label in which the button events will be displayed + _displayValueLabel = Text::create("Zoom Scale: 0.1", "fonts/Marker Felt.ttf",32); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 20)); + _uiLayer->addChild(_displayValueLabel); + + // Add the alert + Text* alert = Text::create("Button","fonts/Marker Felt.ttf",30); + alert->setColor(Color3B(159, 168, 176)); + + alert->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f)); + + _uiLayer->addChild(alert); + + // Create the button + Button* button = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); + button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 20)); + button->setPressedActionEnabled(true); + button->setName("button"); + _uiLayer->addChild(button); + button->setZoomScale(-0.5); + + Slider* slider = Slider::create(); + slider->loadBarTexture("cocosui/sliderTrack.png"); + slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); + slider->loadProgressBarTexture("cocosui/sliderProgress.png"); + slider->setPosition(Vec2(widgetSize.width / 2.0f , widgetSize.height / 2.0f - 20)); + slider->addEventListener(CC_CALLBACK_2(UIButtonTestZoomScale::sliderEvent, this)); + slider->setPercent(button->getZoomScale()*100); + _uiLayer->addChild(slider); + return true; + } + return false; +} + +void UIButtonTestZoomScale::sliderEvent(Ref *pSender, Slider::EventType type) +{ + if (type == Slider::EventType::ON_PERCENTAGE_CHANGED) + { + Slider* slider = dynamic_cast(pSender); + int percent = slider->getPercent(); + Button* btn = (Button*)_uiLayer->getChildByName("button"); + float zoomScale = percent * 0.01; + btn->setZoomScale(zoomScale); + _displayValueLabel->setString(String::createWithFormat("Zoom Scale: %f", zoomScale)->getCString()); + } +} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h index c9f7be36f7..668789066a 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h @@ -105,4 +105,17 @@ protected: Text* _displayValueLabel; }; +class UIButtonTestZoomScale : public UIScene +{ +public: + UIButtonTestZoomScale(); + ~UIButtonTestZoomScale(); + bool init(); + void sliderEvent(Ref* pSender, Slider::EventType type); + +protected: + UI_SCENE_CREATE_FUNC(UIButtonTestZoomScale) + Text* _displayValueLabel; +}; + #endif /* defined(__TestCpp__UIButtonTest__) */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index 973d6ba1ef..8419708306 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -208,3 +208,103 @@ void UIPageViewButtonTest::pageViewEvent(Ref *pSender, PageView::EventType type) break; } } + + +// UIPageViewCustomScrollThreshold +UIPageViewCustomScrollThreshold::UIPageViewCustomScrollThreshold() +: _displayValueLabel(nullptr) +{ + +} + +UIPageViewCustomScrollThreshold::~UIPageViewCustomScrollThreshold() +{ +} + +bool UIPageViewCustomScrollThreshold::init() +{ + if (UIScene::init()) + { + Size widgetSize = _widget->getContentSize(); + + // Add a label in which the dragpanel events will be displayed + _displayValueLabel = Text::create("Scroll Threshold", "fonts/Marker Felt.ttf", 32); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f + + _displayValueLabel->getContentSize().height * 1.5)); + _uiLayer->addChild(_displayValueLabel); + + // Add the black background + Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); + alert->setColor(Color3B(159, 168, 176)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); + _uiLayer->addChild(alert); + + Layout* root = static_cast(_uiLayer->getChildByTag(81)); + + Layout* background = dynamic_cast(root->getChildByName("background_Panel")); + + // Create the page view + PageView* pageView = PageView::create(); + pageView->setContentSize(Size(240.0f, 100.0f)); + Size backgroundSize = background->getContentSize(); + pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + + (backgroundSize.width - pageView->getContentSize().width) / 2.0f, + (widgetSize.height - backgroundSize.height) / 2.0f + + (backgroundSize.height - pageView->getContentSize().height) / 2.0f + 20)); + + int pageCount = 4; + for (int i = 0; i < pageCount; ++i) + { + Layout* layout = Layout::create(); + layout->setContentSize(Size(240.0f, 130.0f)); + + ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); + imageView->setScale9Enabled(true); + imageView->setContentSize(Size(240, 130)); + imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); + layout->addChild(imageView); + + Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30); + label->setColor(Color3B(192, 192, 192)); + label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f)); + layout->addChild(label); + + pageView->insertPage(layout,i); + } + + _uiLayer->addChild(pageView); + pageView->setName("pageView"); + + Slider* slider = Slider::create(); + slider->loadBarTexture("cocosui/sliderTrack.png"); + slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); + slider->loadProgressBarTexture("cocosui/sliderProgress.png"); + slider->setPosition(Vec2(widgetSize.width / 2.0f , widgetSize.height / 2.0f - 40)); + slider->addEventListener(CC_CALLBACK_2(UIPageViewCustomScrollThreshold::sliderEvent, this)); + slider->setPercent(50); + _uiLayer->addChild(slider); + + + return true; + } + return false; +} + + +void UIPageViewCustomScrollThreshold::sliderEvent(Ref *pSender, Slider::EventType type) +{ + if (type == Slider::EventType::ON_PERCENTAGE_CHANGED) + { + Slider* slider = dynamic_cast(pSender); + int percent = slider->getPercent(); + PageView* pageView = (PageView*)_uiLayer->getChildByName("pageView"); + if (percent == 0) { + percent = 1; + } + pageView->setCustomScrollThreshold(percent * 0.01 * pageView->getContentSize().width); + + _displayValueLabel->setString(String::createWithFormat("Scroll Threshold: %f", pageView->getCustomScrollThreshold())->getCString()); + } +} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index 114737a291..0892b3e936 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -55,4 +55,19 @@ protected: Text* _displayValueLabel; }; +class UIPageViewCustomScrollThreshold : public UIScene +{ +public: + UIPageViewCustomScrollThreshold(); + ~UIPageViewCustomScrollThreshold(); + bool init(); + + void sliderEvent(Ref* pSender, Slider::EventType type); + + void pageViewEvent(Ref* pSender, PageView::EventType type); +protected: + UI_SCENE_CREATE_FUNC(UIPageViewCustomScrollThreshold) + Text* _displayValueLabel; +}; + #endif /* defined(__TestCpp__UIPageViewTest__) */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp index 37031bf8af..59cec14db4 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.cpp @@ -34,6 +34,7 @@ static const char* s_testArray[] = "UIButtonTest_Title", "UIButtonTest_RemoveSelf", "UIButtonTestSwitchScale9", + "UIButtonTestZoomScale", "UICheckBoxTest", "UISliderTest", "UISliderTest_Scale9", @@ -180,6 +181,8 @@ Scene *UISceneManager::currentUIScene() return UIButtonTestRemoveSelf::sceneWithTitle(s_testArray[_currentUISceneId]); case kUIButtonTestSwitchScale9: return UIButtonTestSwitchScale9::sceneWithTitle(s_testArray[_currentUISceneId]); + case kUIButtonTestZoomScale: + return UIButtonTestZoomScale::sceneWithTitle(s_testArray[_currentUISceneId]); case kUICheckBoxTest: return UICheckBoxTest::sceneWithTitle(s_testArray[_currentUISceneId]); @@ -288,6 +291,8 @@ Scene *UISceneManager::currentUIScene() return UIPageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]); case kUIPageViewButtonTest: return UIPageViewButtonTest::sceneWithTitle(s_testArray[_currentUISceneId]); + case kUIPageViewCustomScrollThreshold: + return UIPageViewCustomScrollThreshold::sceneWithTitle(s_testArray[_currentUISceneId]); case kUIListViewTest_Vertical: return UIListViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h index a730422203..9d49b61b89 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISceneManager.h @@ -37,6 +37,7 @@ enum kUIButtonTest_Title, kUIButtonTest_RemoveSelf, kUIButtonTestSwitchScale9, + kUIButtonTestZoomScale, kUICheckBoxTest, kUISliderTest, kUISliderTest_Scale9, @@ -75,6 +76,7 @@ enum kUIScrollViewTest_ScrollToPercentBothDirection_Bounce, kUIPageViewTest, kUIPageViewButtonTest, + kUIPageViewCustomScrollThreshold, kUIListViewTest_Vertical, kUIListViewTest_Horizontal, kUIWidgetAddNodeTest, From dbf58b8873331f9da1fe6a57d6f2f76fcbad003f Mon Sep 17 00:00:00 2001 From: lvlong Date: Thu, 14 Aug 2014 13:15:37 +0800 Subject: [PATCH 20/42] modify function name and add default to switch block. --- cocos/3d/CCOBB.cpp | 36 +++++++++++++++++++++--------------- cocos/3d/CCOBB.h | 4 ++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/cocos/3d/CCOBB.cpp b/cocos/3d/CCOBB.cpp index f74bf96a47..a9e3235c31 100755 --- a/cocos/3d/CCOBB.cpp +++ b/cocos/3d/CCOBB.cpp @@ -332,7 +332,7 @@ void OBB::getInterval(const OBB& box, const Vec3& axis, float &min, float &max)c } } -Vec3 OBB::getEdgeDir(int index)const +Vec3 OBB::getEdgeDirection(int index)const { Vec3 corners[8]; getCorners(corners); @@ -352,38 +352,44 @@ Vec3 OBB::getEdgeDir(int index)const tmpLine = corners[1] - corners[6]; tmpLine.normalize(); break; + default: + CCASSERT(0, "Invalid index!"); + break; } return tmpLine; } -Vec3 OBB::getFaceDir(int index) const +Vec3 OBB::getFaceDirection(int index) const { Vec3 corners[8]; getCorners(corners); - Vec3 faceDir, v0, v1; + Vec3 faceDirection, v0, v1; switch(index) { case 0:// front and back v0 = corners[2] - corners[1]; v1 = corners[0] - corners[1]; - Vec3::cross(v0, v1, &faceDir); - faceDir.normalize(); + Vec3::cross(v0, v1, &faceDirection); + faceDirection.normalize(); break; case 1:// left and right v0 = corners[5] - corners[2]; v1 = corners[3] - corners[2]; - Vec3::cross(v0, v1, &faceDir); - faceDir.normalize(); + Vec3::cross(v0, v1, &faceDirection); + faceDirection.normalize(); break; case 2:// top and bottom v0 = corners[1] - corners[2]; v1 = corners[5] - corners[2]; - Vec3::cross(v0, v1, &faceDir); - faceDir.normalize(); + Vec3::cross(v0, v1, &faceDirection); + faceDirection.normalize(); + break; + default: + CCASSERT(0, "Invalid index!"); break; } - return faceDir; + return faceDirection; } bool OBB::intersects(const OBB& box) const @@ -391,15 +397,15 @@ bool OBB::intersects(const OBB& box) const float min1, max1, min2, max2; for (int i = 0; i < 3; i++) { - getInterval(*this, getFaceDir(i), min1, max1); - getInterval(box, getFaceDir(i), min2, max2); + getInterval(*this, getFaceDirection(i), min1, max1); + getInterval(box, getFaceDirection(i), min2, max2); if (max1 < min2 || max2 < min1) return false; } for (int i = 0; i < 3; i++) { - getInterval(*this, box.getFaceDir(i), min1, max1); - getInterval(box, box.getFaceDir(i), min2, max2); + getInterval(*this, box.getFaceDirection(i), min1, max1); + getInterval(box, box.getFaceDirection(i), min2, max2); if (max1 < min2 || max2 < min1) return false; } @@ -408,7 +414,7 @@ bool OBB::intersects(const OBB& box) const for (int j = 0; j < 3; j++) { Vec3 axis; - Vec3::cross(getEdgeDir(i), box.getEdgeDir(j), &axis); + Vec3::cross(getFaceDirection(i), box.getFaceDirection(j), &axis); getInterval(*this, axis, min1, max1); getInterval(box, axis, min2, max2); if (max1 < min2 || max2 < min1) return false; diff --git a/cocos/3d/CCOBB.h b/cocos/3d/CCOBB.h index 95776bd5f5..0fd8c1eea1 100755 --- a/cocos/3d/CCOBB.h +++ b/cocos/3d/CCOBB.h @@ -97,12 +97,12 @@ protected: /* * Get the edege of x y z axis direction */ - Vec3 getEdgeDir(int index) const; + Vec3 getEdgeDirection(int index) const; /* * Get the face of x y z axis direction */ - Vec3 getFaceDir(int index) const; + Vec3 getFaceDirection(int index) const; public: Vec3 _center; // obb center From e27a2aee91613699b0771965ab265b8d39e28feb Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 14 Aug 2014 14:36:30 +0800 Subject: [PATCH 21/42] fix typo --- cocos/ui/UIPageView.cpp | 8 ++++---- cocos/ui/UIPageView.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index c4222959bd..b6f702ede2 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -46,7 +46,7 @@ _pageViewEventListener(nullptr), _pageViewEventSelector(nullptr), _eventCallback(nullptr), _customScrollThreshold(0.0), -_usingCustomCrollThreshold(false) +_usingCustomScrollThreshold(false) { this->setTouchEnabled(true); } @@ -464,12 +464,12 @@ float PageView::getCustomScrollThreshold()const void PageView::setUsingCustomScrollThreshold(bool flag) { - _usingCustomCrollThreshold = flag; + _usingCustomScrollThreshold = flag; } bool PageView::isUsingCustomScrollThreshold()const { - return _usingCustomCrollThreshold; + return _usingCustomScrollThreshold; } void PageView::handleReleaseLogic(Touch *touch) @@ -485,7 +485,7 @@ void PageView::handleReleaseLogic(Touch *touch) ssize_t pageCount = this->getPageCount(); float curPageLocation = curPagePos.x; float pageWidth = getContentSize().width; - if (!_usingCustomCrollThreshold) { + if (!_usingCustomScrollThreshold) { _customScrollThreshold = pageWidth / 2.0; } float boundary = _customScrollThreshold; diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 2065f2fb73..65078870e9 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -237,7 +237,7 @@ protected: float _leftBoundary; float _rightBoundary; float _customScrollThreshold; - bool _usingCustomCrollThreshold; + bool _usingCustomScrollThreshold; float _childFocusCancelOffset; From d9a0c6a2ad7658e48bcde8a7b4c95304db453cff Mon Sep 17 00:00:00 2001 From: Mircea Rila Date: Thu, 14 Aug 2014 10:48:09 +0300 Subject: [PATCH 22/42] replace tabs with spaces --- AUTHORS | 6 ++--- cocos/platform/desktop/CCGLViewImpl.cpp | 32 ++++++++++++------------- cocos/platform/desktop/CCGLViewImpl.h | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/AUTHORS b/AUTHORS index 40ef469e80..b85103502b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -974,9 +974,9 @@ Developers: DavidPartouche Fixed the bug that video player not showing on iOS if it's not in FullScreen mode - - zaWasp - Added support for applicationDidEnterBackground / applicationWillEnterForeground on win32 + + zaWasp + Added support for applicationDidEnterBackground / applicationWillEnterForeground on win32 Retired Core Developers: WenSheng Yang diff --git a/cocos/platform/desktop/CCGLViewImpl.cpp b/cocos/platform/desktop/CCGLViewImpl.cpp index cb8976fa92..210e6f12be 100644 --- a/cocos/platform/desktop/CCGLViewImpl.cpp +++ b/cocos/platform/desktop/CCGLViewImpl.cpp @@ -102,13 +102,13 @@ public: _view = view; } - static void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified) - { - if (_view) - { - _view->onGLFWWindowIconifyCallback(window, iconified); - } - } + static void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified) + { + if (_view) + { + _view->onGLFWWindowIconifyCallback(window, iconified); + } + } private: static GLViewImpl* _view; @@ -361,7 +361,7 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback); glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWframebuffersize); glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeFunCallback); - glfwSetWindowIconifyCallback(_mainWindow, GLFWEventHandler::onGLFWWindowIconifyCallback); + glfwSetWindowIconifyCallback(_mainWindow, GLFWEventHandler::onGLFWWindowIconifyCallback); setFrameSize(rect.size.width, rect.size.height); @@ -721,14 +721,14 @@ void GLViewImpl::onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int void GLViewImpl::onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified) { - if (iconified == GL_TRUE) - { - Application::getInstance()->applicationDidEnterBackground(); - } - else - { - Application::getInstance()->applicationWillEnterForeground(); - } + if (iconified == GL_TRUE) + { + Application::getInstance()->applicationDidEnterBackground(); + } + else + { + Application::getInstance()->applicationWillEnterForeground(); + } } #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/cocos/platform/desktop/CCGLViewImpl.h b/cocos/platform/desktop/CCGLViewImpl.h index 0bd3fd0373..368e6d97a2 100644 --- a/cocos/platform/desktop/CCGLViewImpl.h +++ b/cocos/platform/desktop/CCGLViewImpl.h @@ -130,9 +130,9 @@ protected: void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y); void onGLFWframebuffersize(GLFWwindow* window, int w, int h); void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height); - void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified); + void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified); - bool _captured; + bool _captured; bool _supportTouch; bool _isInRetinaMonitor; bool _isRetinaEnabled; From e8a5147b92225bd3661fb8602c69e4dc80e7ab5e Mon Sep 17 00:00:00 2001 From: andyque Date: Thu, 14 Aug 2014 16:56:15 +0800 Subject: [PATCH 23/42] copy new added widget property to clone method --- cocos/ui/UIButton.cpp | 1 + cocos/ui/UIPageView.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index 468103761a..aebfd113d0 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -704,6 +704,7 @@ void Button::copySpecialProperties(Widget *widget) setTitleFontSize(button->getTitleFontSize()); setTitleColor(button->getTitleColor()); setPressedActionEnabled(button->_pressedActionEnabled); + setZoomScale(button->_zoomScale); } } diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index b6f702ede2..3931192a83 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -617,6 +617,8 @@ void PageView::copySpecialProperties(Widget *widget) _eventCallback = pageView->_eventCallback; _pageViewEventListener = pageView->_pageViewEventListener; _pageViewEventSelector = pageView->_pageViewEventSelector; + _usingCustomScrollThreshold = pageView->_usingCustomScrollThreshold; + _customScrollThreshold = pageView->_customScrollThreshold; } } From a508477eda1042cd884a17c00549ab23fe20886f Mon Sep 17 00:00:00 2001 From: yangxiao Date: Thu, 14 Aug 2014 19:07:40 +0800 Subject: [PATCH 24/42] remove unused code --- cocos/2d/CCScene.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 93a644a2f6..9d5fa4cfdc 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -71,10 +71,6 @@ bool Scene::init() bool Scene::initWithSize(const Size& size) { - //create default camera - auto camera = Camera::create(); - addChild(camera); - setContentSize(size); return true; } From e9563696db57ba2ce8ede61666c9e6be05e86795 Mon Sep 17 00:00:00 2001 From: teivaz Date: Thu, 14 Aug 2014 15:14:25 +0300 Subject: [PATCH 25/42] * Fixed WP8 compilation errors (added path to CCGLView.h) - Modified filters for CCCamera.h/cpp --- cocos/2d/cocos2d_wp8.vcxproj.filters | 6 ++++++ cocos/2d/cocos2d_wp8_headers.props | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index 787f62f854..b8660f1d4b 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -632,6 +632,9 @@ 3d + + base + @@ -1292,6 +1295,9 @@ 3d + + base + diff --git a/cocos/2d/cocos2d_wp8_headers.props b/cocos/2d/cocos2d_wp8_headers.props index ca110ab470..b5f55539b7 100644 --- a/cocos/2d/cocos2d_wp8_headers.props +++ b/cocos/2d/cocos2d_wp8_headers.props @@ -7,7 +7,7 @@ - $(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\wp8-specific\zlib\include;$(GeneratedFilesDir) + $(EngineRoot)cocos\platform;$(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\wp8-specific\zlib\include;$(GeneratedFilesDir) _VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true true From 885fd16b9e56f74163407dd7d742ddaa780c48f5 Mon Sep 17 00:00:00 2001 From: teivaz Date: Thu, 14 Aug 2014 15:20:48 +0300 Subject: [PATCH 26/42] * Fixed WP8 compilation error (Added missing files CCCamera.h/cpp to the project) --- cocos/2d/cocos2d_wp8.vcxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index c81fef6b22..4b4908198e 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -238,6 +238,7 @@ + @@ -454,6 +455,7 @@ + From 90e5870499cc89a323cf3942ed357113461c50b0 Mon Sep 17 00:00:00 2001 From: teivaz Date: Thu, 14 Aug 2014 15:35:36 +0300 Subject: [PATCH 27/42] * Fixed WP compilation errors (added CCPrimitive, CCPrimitiveCommand, CCVertexIndexBuffer and CCVertexIndexData to the project) --- cocos/2d/cocos2d_wp8.vcxproj | 8 ++++++++ cocos/2d/cocos2d_wp8.vcxproj.filters | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index 4b4908198e..950d79440a 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -356,6 +356,8 @@ + + @@ -363,6 +365,8 @@ + + @@ -578,6 +582,8 @@ + + @@ -586,6 +592,8 @@ + + diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index b8660f1d4b..9db875128a 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -635,6 +635,18 @@ base + + renderer + + + renderer + + + renderer + + + renderer + @@ -1298,6 +1310,18 @@ base + + renderer + + + renderer + + + renderer + + + renderer + From 97d8d27eec3a7d4b504cd00b25e81a13f55d1266 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 14 Aug 2014 21:58:40 +0800 Subject: [PATCH 28/42] Add LOCAL_WHOLE_STATIC_LIBRARIES for lua-template-runtime on android --- .../frameworks/runtime-src/proj.android/jni/Android.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk index e6225d828d..f007cdfe62 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk @@ -43,6 +43,11 @@ $(LOCAL_PATH)/../../../cocos2d-x/external LOCAL_WHOLE_STATIC_LIBRARIES := cocos2d_lua_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_lua_static LOCAL_WHOLE_STATIC_LIBRARIES += network_lua_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_lua_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_lua_static +LOCAL_WHOLE_STATIC_LIBRARIES += spine_lua_static +LOCAL_WHOLE_STATIC_LIBRARIES += extension_lua_static +LOCAL_WHOLE_STATIC_LIBRARIES += ui_lua_static include $(BUILD_SHARED_LIBRARY) From 55180c63e49271ae413328a0e8b7e503a2b132c4 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 14 Aug 2014 23:22:24 +0800 Subject: [PATCH 29/42] Add modules register functions for lua-template-runtime on android --- .../runtime-src/Classes/lua_module_register.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/lua_module_register.h b/templates/lua-template-runtime/frameworks/runtime-src/Classes/lua_module_register.h index 1ce4720324..43a2c175b2 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/lua_module_register.h +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/lua_module_register.h @@ -3,12 +3,22 @@ #include "network/lua_cocos2dx_network_manual.h" #include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h" +#include "cocosbuilder/lua_cocos2dx_cocosbuilder_manual.h" +#include "cocostudio/lua_cocos2dx_coco_studio_manual.hpp" +#include "extension/lua_cocos2dx_extension_manual.h" +#include "ui/lua_cocos2dx_ui_manual.hpp" +#include "spine/lua_cocos2dx_spine_manual.hpp" int lua_module_register(lua_State* L) { register_network_module(L); register_cocosdenshion_module(L); + register_cocosbuilder_module(L); + register_cocostudio_module(L); + register_extension_module(L); + register_ui_moudle(L); + register_spine_module(L); return 1; } From 76a9382a91c32fdf5e1bc822a58e779c43942121 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Fri, 15 Aug 2014 00:08:15 +0800 Subject: [PATCH 30/42] =?UTF-8?q?Rename=20folder=20names=20of=20cpp-templa?= =?UTF-8?q?te:=20=E2=80=98Classes=E2=80=99=E2=80=94>=E2=80=99src=E2=80=99?= =?UTF-8?q?=20,=E2=80=99Resource=E2=80=99=E2=80=94>=E2=80=99res=E2=80=99?= =?UTF-8?q?=20and=20adjust=20the=20template=20project=20except=20wp8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/cpp-template-default/CMakeLists.txt | 12 +- .../proj.android/build-cfg.json | 2 +- .../proj.android/build_native.py | 2 +- .../proj.android/jni/Android.mk | 6 +- .../HelloCpp.xcodeproj/project.pbxproj | 362 +++++++++++------- .../cpp-template-default/proj.linux/main.cpp | 2 +- .../proj.win32/HelloCpp.vcxproj | 12 +- .../proj.win32/HelloCpp.vcxproj.filters | 22 +- .../proj.win32/HelloCpp.vcxproj.user | 4 +- .../{Resources => res}/CloseNormal.png | Bin .../{Resources => res}/CloseSelected.png | Bin .../{Resources => res}/HelloWorld.png | Bin .../{Resources => res}/fonts/Marker Felt.ttf | Bin .../{Classes => src}/AppDelegate.cpp | 0 .../{Classes => src}/AppDelegate.h | 0 .../{Classes => src}/HelloWorldScene.cpp | 0 .../{Classes => src}/HelloWorldScene.h | 0 17 files changed, 256 insertions(+), 168 deletions(-) rename templates/cpp-template-default/{Resources => res}/CloseNormal.png (100%) rename templates/cpp-template-default/{Resources => res}/CloseSelected.png (100%) rename templates/cpp-template-default/{Resources => res}/HelloWorld.png (100%) rename templates/cpp-template-default/{Resources => res}/fonts/Marker Felt.ttf (100%) rename templates/cpp-template-default/{Classes => src}/AppDelegate.cpp (100%) rename templates/cpp-template-default/{Classes => src}/AppDelegate.h (100%) rename templates/cpp-template-default/{Classes => src}/HelloWorldScene.cpp (100%) rename templates/cpp-template-default/{Classes => src}/HelloWorldScene.h (100%) diff --git a/templates/cpp-template-default/CMakeLists.txt b/templates/cpp-template-default/CMakeLists.txt index 97c0813e94..afee5d541d 100644 --- a/templates/cpp-template-default/CMakeLists.txt +++ b/templates/cpp-template-default/CMakeLists.txt @@ -57,16 +57,16 @@ endif() if( UNIX ) #assume linux set(GAME_SRC proj.linux/main.cpp - Classes/AppDelegate.cpp - Classes/HelloWorldScene.cpp + src/AppDelegate.cpp + src/HelloWorldScene.cpp ) elseif ( WIN32 ) set(GAME_SRC proj.win32/main.cpp proj.win32/main.h proj.win32/resource.h - Classes/AppDelegate.cpp - Classes/HelloWorldScene.cpp + src/AppDelegate.cpp + src/HelloWorldScene.cpp ) endif() @@ -244,14 +244,14 @@ if ( WIN32 ) #also copying dlls to binary directory for the executable to run pre_build(${APP_NAME} COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/res ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt/glew32.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE} COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt/zlib1.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE} ) else() pre_build(${APP_NAME} COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/res ${APP_BIN_DIR}/Resources ) endif() diff --git a/templates/cpp-template-default/proj.android/build-cfg.json b/templates/cpp-template-default/proj.android/build-cfg.json index 611f232c30..c719dc3cf2 100644 --- a/templates/cpp-template-default/proj.android/build-cfg.json +++ b/templates/cpp-template-default/proj.android/build-cfg.json @@ -6,7 +6,7 @@ ], "copy_resources": [ { - "from": "../Resources", + "from": "../res", "to": "" } ] diff --git a/templates/cpp-template-default/proj.android/build_native.py b/templates/cpp-template-default/proj.android/build_native.py index 97c9f89991..8f231b2478 100755 --- a/templates/cpp-template-default/proj.android/build_native.py +++ b/templates/cpp-template-default/proj.android/build_native.py @@ -114,7 +114,7 @@ def copy_resources(app_android_root): # copy resources os.mkdir(assets_dir) - resources_dir = os.path.join(app_android_root, "../Resources") + resources_dir = os.path.join(app_android_root, "../res") if os.path.isdir(resources_dir): copy_files(resources_dir, assets_dir) diff --git a/templates/cpp-template-default/proj.android/jni/Android.mk b/templates/cpp-template-default/proj.android/jni/Android.mk index cddef45aa8..55e22ede0b 100644 --- a/templates/cpp-template-default/proj.android/jni/Android.mk +++ b/templates/cpp-template-default/proj.android/jni/Android.mk @@ -11,10 +11,10 @@ LOCAL_MODULE := cocos2dcpp_shared LOCAL_MODULE_FILENAME := libcocos2dcpp LOCAL_SRC_FILES := hellocpp/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../Classes/HelloWorldScene.cpp + ../../src/AppDelegate.cpp \ + ../../src/HelloWorldScene.cpp -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../src LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static diff --git a/templates/cpp-template-default/proj.ios_mac/HelloCpp.xcodeproj/project.pbxproj b/templates/cpp-template-default/proj.ios_mac/HelloCpp.xcodeproj/project.pbxproj index 15fe6d6f6b..8f4d492fbf 100644 --- a/templates/cpp-template-default/proj.ios_mac/HelloCpp.xcodeproj/project.pbxproj +++ b/templates/cpp-template-default/proj.ios_mac/HelloCpp.xcodeproj/project.pbxproj @@ -7,21 +7,26 @@ objects = { /* Begin PBXBuildFile section */ + 15A6DA93199CFB1100B56DBF /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15A6DA8F199CFB1100B56DBF /* AppDelegate.cpp */; }; + 15A6DA94199CFB1100B56DBF /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15A6DA8F199CFB1100B56DBF /* AppDelegate.cpp */; }; + 15A6DA95199CFB1100B56DBF /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15A6DA91199CFB1100B56DBF /* HelloWorldScene.cpp */; }; + 15A6DA96199CFB1100B56DBF /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15A6DA91199CFB1100B56DBF /* HelloWorldScene.cpp */; }; + 15A6DA9B199CFB9800B56DBF /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = 15A6DA98199CFB9800B56DBF /* CloseNormal.png */; }; + 15A6DA9C199CFB9800B56DBF /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = 15A6DA98199CFB9800B56DBF /* CloseNormal.png */; }; + 15A6DA9D199CFB9800B56DBF /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 15A6DA99199CFB9800B56DBF /* CloseSelected.png */; }; + 15A6DA9E199CFB9800B56DBF /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 15A6DA99199CFB9800B56DBF /* CloseSelected.png */; }; + 15A6DA9F199CFB9800B56DBF /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = 15A6DA9A199CFB9800B56DBF /* HelloWorld.png */; }; + 15A6DAA0199CFB9800B56DBF /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = 15A6DA9A199CFB9800B56DBF /* HelloWorld.png */; }; 1AC6FB1F180E996B004C840B /* libbox2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FAFF180E9839004C840B /* libbox2d Mac.a */; }; 1AC6FB20180E996B004C840B /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FAFD180E9839004C840B /* libchipmunk Mac.a */; }; - 1AC6FB21180E996B004C840B /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FAF9180E9839004C840B /* libcocos2dx Mac.a */; }; - 1AC6FB22180E996B004C840B /* libcocos2dx-extensions Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FAFB180E9839004C840B /* libcocos2dx-extensions Mac.a */; }; - 1AC6FB23180E996B004C840B /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB01180E9839004C840B /* libCocosDenshion Mac.a */; }; + 1AC6FB21180E996B004C840B /* libcocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FAF9180E9839004C840B /* libcocos2d Mac.a */; }; + 1AC6FB22180E996B004C840B /* libextension Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FAFB180E9839004C840B /* libextension Mac.a */; }; + 1AC6FB23180E996B004C840B /* libcocosdenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB01180E9839004C840B /* libcocosdenshion Mac.a */; }; 1AC6FB2E180E99EB004C840B /* libbox2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB0D180E9839004C840B /* libbox2d iOS.a */; }; 1AC6FB2F180E99EB004C840B /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB0B180E9839004C840B /* libchipmunk iOS.a */; }; - 1AC6FB30180E99EB004C840B /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB07180E9839004C840B /* libcocos2dx iOS.a */; }; - 1AC6FB31180E99EB004C840B /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB09180E9839004C840B /* libcocos2dx-extensions iOS.a */; }; - 1AC6FB32180E99EB004C840B /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB0F180E9839004C840B /* libCocosDenshion iOS.a */; }; - 1AFAF8B716D35DE700DB1158 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B316D35DE700DB1158 /* AppDelegate.cpp */; }; - 1AFAF8B816D35DE700DB1158 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B516D35DE700DB1158 /* HelloWorldScene.cpp */; }; - 1AFAF8BC16D35E4900DB1158 /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B916D35E4900DB1158 /* CloseNormal.png */; }; - 1AFAF8BD16D35E4900DB1158 /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAF8BA16D35E4900DB1158 /* CloseSelected.png */; }; - 1AFAF8BE16D35E4900DB1158 /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAF8BB16D35E4900DB1158 /* HelloWorld.png */; }; + 1AC6FB30180E99EB004C840B /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB07180E9839004C840B /* libcocos2d iOS.a */; }; + 1AC6FB31180E99EB004C840B /* libextension iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB09180E9839004C840B /* libextension iOS.a */; }; + 1AC6FB32180E99EB004C840B /* libcocosdenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB0F180E9839004C840B /* libcocosdenshion iOS.a */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; @@ -32,11 +37,6 @@ 503AE10517EB98FF00D1A890 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 503AE10317EB98FF00D1A890 /* main.cpp */; }; 503AE11217EB99EE00D1A890 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 503AE11117EB99EE00D1A890 /* libcurl.dylib */; }; 503AE11B17EB9C5A00D1A890 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 503AE11A17EB9C5A00D1A890 /* IOKit.framework */; }; - 5087E75317EB910900C73F5D /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B916D35E4900DB1158 /* CloseNormal.png */; }; - 5087E75417EB910900C73F5D /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAF8BA16D35E4900DB1158 /* CloseSelected.png */; }; - 5087E75517EB910900C73F5D /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = 1AFAF8BB16D35E4900DB1158 /* HelloWorld.png */; }; - 5087E75717EB910900C73F5D /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B316D35DE700DB1158 /* AppDelegate.cpp */; }; - 5087E75817EB910900C73F5D /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFAF8B516D35DE700DB1158 /* HelloWorldScene.cpp */; }; 5087E76317EB910900C73F5D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 5087E76517EB910900C73F5D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 5087E76717EB910900C73F5D /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF170DB412928DE900B8313A /* libz.dylib */; }; @@ -72,6 +72,76 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 15A6DA7A199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B245F13A19766132001920FD; + remoteInfo = "libui Mac"; + }; + 15A6DA7C199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B2DB484D1976716E00411E16; + remoteInfo = "libcocostudio Mac"; + }; + 15A6DA7E199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B2DB47D2197669A100411E16; + remoteInfo = "libcocosbuilder Mac"; + }; + 15A6DA80199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B2DB490119767F1F00411E16; + remoteInfo = "libspine Mac"; + }; + 15A6DA82199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B2DB49C4197686CB00411E16; + remoteInfo = "libnetwork Mac"; + }; + 15A6DA84199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B24EEA6619775E92004493CC; + remoteInfo = "libui iOS"; + }; + 15A6DA86199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B24EEA6E19775EBB004493CC; + remoteInfo = "libcocostudio iOS"; + }; + 15A6DA88199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B24EEA7619775ECE004493CC; + remoteInfo = "libcocosbuilder iOS"; + }; + 15A6DA8A199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B24EEA7E19775EE1004493CC; + remoteInfo = "libspine iOS"; + }; + 15A6DA8C199CFAFD00B56DBF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B24EEA8619775EF3004493CC; + remoteInfo = "libnetwork iOS"; + }; 1AC6FAF8180E9839004C840B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; @@ -107,20 +177,6 @@ remoteGlobalIDString = A03F2ED617814268006731B9; remoteInfo = "CocosDenshion Mac"; }; - 1AC6FB02180E9839004C840B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = A03F31FD1781479B006731B9; - remoteInfo = "jsbindings Mac"; - }; - 1AC6FB04180E9839004C840B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 1A6FB53017854BC300CDF010; - remoteInfo = "luabindings Mac"; - }; 1AC6FB06180E9839004C840B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; @@ -156,20 +212,6 @@ remoteGlobalIDString = A07A4FB4178387730073F6A7; remoteInfo = "CocosDenshion iOS"; }; - 1AC6FB10180E9839004C840B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = A07A5030178387750073F6A7; - remoteInfo = "jsbindings iOS"; - }; - 1AC6FB12180E9839004C840B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 1A119791178526AA00D62A44; - remoteInfo = "luabindings iOS"; - }; 1AC6FB15180E9959004C840B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */; @@ -243,15 +285,15 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 15A6DA8F199CFB1100B56DBF /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppDelegate.cpp; path = ../src/AppDelegate.cpp; sourceTree = ""; }; + 15A6DA90199CFB1100B56DBF /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ../src/AppDelegate.h; sourceTree = ""; }; + 15A6DA91199CFB1100B56DBF /* HelloWorldScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HelloWorldScene.cpp; path = ../src/HelloWorldScene.cpp; sourceTree = ""; }; + 15A6DA92199CFB1100B56DBF /* HelloWorldScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HelloWorldScene.h; path = ../src/HelloWorldScene.h; sourceTree = ""; }; + 15A6DA98199CFB9800B56DBF /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = CloseNormal.png; path = ../res/CloseNormal.png; sourceTree = ""; }; + 15A6DA99199CFB9800B56DBF /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = CloseSelected.png; path = ../res/CloseSelected.png; sourceTree = ""; }; + 15A6DA9A199CFB9800B56DBF /* HelloWorld.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HelloWorld.png; path = ../res/HelloWorld.png; sourceTree = ""; }; 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../cocos2d/build/cocos2d_libs.xcodeproj; sourceTree = ""; }; 1ACB3243164770DE00914215 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../../cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; - 1AFAF8B316D35DE700DB1158 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppDelegate.cpp; path = ../Classes/AppDelegate.cpp; sourceTree = ""; }; - 1AFAF8B416D35DE700DB1158 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ../Classes/AppDelegate.h; sourceTree = ""; }; - 1AFAF8B516D35DE700DB1158 /* HelloWorldScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HelloWorldScene.cpp; path = ../Classes/HelloWorldScene.cpp; sourceTree = ""; }; - 1AFAF8B616D35DE700DB1158 /* HelloWorldScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HelloWorldScene.h; path = ../Classes/HelloWorldScene.h; sourceTree = ""; }; - 1AFAF8B916D35E4900DB1158 /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = ""; }; - 1AFAF8BA16D35E4900DB1158 /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = ""; }; - 1AFAF8BB16D35E4900DB1158 /* HelloWorld.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HelloWorld.png; sourceTree = ""; }; 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 1D6058910D05DD3D006BFB54 /* HelloCpp iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HelloCpp iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; @@ -304,9 +346,9 @@ files = ( 1AC6FB2E180E99EB004C840B /* libbox2d iOS.a in Frameworks */, 1AC6FB2F180E99EB004C840B /* libchipmunk iOS.a in Frameworks */, - 1AC6FB30180E99EB004C840B /* libcocos2dx iOS.a in Frameworks */, - 1AC6FB31180E99EB004C840B /* libcocos2dx-extensions iOS.a in Frameworks */, - 1AC6FB32180E99EB004C840B /* libCocosDenshion iOS.a in Frameworks */, + 1AC6FB30180E99EB004C840B /* libcocos2d iOS.a in Frameworks */, + 1AC6FB31180E99EB004C840B /* libextension iOS.a in Frameworks */, + 1AC6FB32180E99EB004C840B /* libcocosdenshion iOS.a in Frameworks */, D6B0611B1803AB670077942B /* CoreMotion.framework in Frameworks */, 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, @@ -326,9 +368,9 @@ files = ( 1AC6FB1F180E996B004C840B /* libbox2d Mac.a in Frameworks */, 1AC6FB20180E996B004C840B /* libchipmunk Mac.a in Frameworks */, - 1AC6FB21180E996B004C840B /* libcocos2dx Mac.a in Frameworks */, - 1AC6FB22180E996B004C840B /* libcocos2dx-extensions Mac.a in Frameworks */, - 1AC6FB23180E996B004C840B /* libCocosDenshion Mac.a in Frameworks */, + 1AC6FB21180E996B004C840B /* libcocos2d Mac.a in Frameworks */, + 1AC6FB22180E996B004C840B /* libextension Mac.a in Frameworks */, + 1AC6FB23180E996B004C840B /* libcocosdenshion Mac.a in Frameworks */, 503AE11217EB99EE00D1A890 /* libcurl.dylib in Frameworks */, 5087E76717EB910900C73F5D /* libz.dylib in Frameworks */, 503AE11B17EB9C5A00D1A890 /* IOKit.framework in Frameworks */, @@ -361,16 +403,25 @@ path = Classes; sourceTree = ""; }; - 15AA9C4015B7EC450033D6C2 /* Classes */ = { + 15A6DA8E199CFB0100B56DBF /* src */ = { isa = PBXGroup; children = ( - 1AFAF8B316D35DE700DB1158 /* AppDelegate.cpp */, - 1AFAF8B416D35DE700DB1158 /* AppDelegate.h */, - 1AFAF8B516D35DE700DB1158 /* HelloWorldScene.cpp */, - 1AFAF8B616D35DE700DB1158 /* HelloWorldScene.h */, + 15A6DA8F199CFB1100B56DBF /* AppDelegate.cpp */, + 15A6DA90199CFB1100B56DBF /* AppDelegate.h */, + 15A6DA91199CFB1100B56DBF /* HelloWorldScene.cpp */, + 15A6DA92199CFB1100B56DBF /* HelloWorldScene.h */, ); - name = Classes; - path = ../classes; + name = src; + sourceTree = ""; + }; + 15A6DA97199CFB8700B56DBF /* res */ = { + isa = PBXGroup; + children = ( + 15A6DA98199CFB9800B56DBF /* CloseNormal.png */, + 15A6DA99199CFB9800B56DBF /* CloseSelected.png */, + 15A6DA9A199CFB9800B56DBF /* HelloWorld.png */, + ); + name = res; sourceTree = ""; }; 19C28FACFE9D520D11CA2CBB /* Products */ = { @@ -385,20 +436,26 @@ 1AC6FAE6180E9839004C840B /* Products */ = { isa = PBXGroup; children = ( - 1AC6FAF9180E9839004C840B /* libcocos2dx Mac.a */, - 1AC6FAFB180E9839004C840B /* libcocos2dx-extensions Mac.a */, + 1AC6FAF9180E9839004C840B /* libcocos2d Mac.a */, + 1AC6FAFB180E9839004C840B /* libextension Mac.a */, + 15A6DA7B199CFAFD00B56DBF /* libui Mac.a */, + 15A6DA7D199CFAFD00B56DBF /* libcocostudio Mac.a */, + 15A6DA7F199CFAFD00B56DBF /* libcocosbuilder Mac.a */, + 15A6DA81199CFAFD00B56DBF /* libspine Mac.a */, + 15A6DA83199CFAFD00B56DBF /* libnetwork Mac.a */, 1AC6FAFD180E9839004C840B /* libchipmunk Mac.a */, 1AC6FAFF180E9839004C840B /* libbox2d Mac.a */, - 1AC6FB01180E9839004C840B /* libCocosDenshion Mac.a */, - 1AC6FB03180E9839004C840B /* libjsbindings Mac.a */, - 1AC6FB05180E9839004C840B /* libluabindings Mac.a */, - 1AC6FB07180E9839004C840B /* libcocos2dx iOS.a */, - 1AC6FB09180E9839004C840B /* libcocos2dx-extensions iOS.a */, + 1AC6FB01180E9839004C840B /* libcocosdenshion Mac.a */, + 1AC6FB07180E9839004C840B /* libcocos2d iOS.a */, + 1AC6FB09180E9839004C840B /* libextension iOS.a */, 1AC6FB0B180E9839004C840B /* libchipmunk iOS.a */, 1AC6FB0D180E9839004C840B /* libbox2d iOS.a */, - 1AC6FB0F180E9839004C840B /* libCocosDenshion iOS.a */, - 1AC6FB11180E9839004C840B /* libjsbindings iOS.a */, - 1AC6FB13180E9839004C840B /* libluabindings iOS.a */, + 1AC6FB0F180E9839004C840B /* libcocosdenshion iOS.a */, + 15A6DA85199CFAFD00B56DBF /* libui iOS.a */, + 15A6DA87199CFAFD00B56DBF /* libcocostudio iOS.a */, + 15A6DA89199CFAFD00B56DBF /* libcocosbuilder iOS.a */, + 15A6DA8B199CFAFD00B56DBF /* libspine iOS.a */, + 15A6DA8D199CFAFD00B56DBF /* libnetwork iOS.a */, ); name = Products; sourceTree = ""; @@ -407,12 +464,12 @@ isa = PBXGroup; children = ( 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */, - 15AA9C4015B7EC450033D6C2 /* Classes */, + 15A6DA8E199CFB0100B56DBF /* src */, 29B97323FDCFA39411CA2CEA /* Frameworks */, 080E96DDFE201D6D7F000001 /* ios */, 503AE10617EB990700D1A890 /* mac */, 19C28FACFE9D520D11CA2CBB /* Products */, - 78C7DDAA14EBA5050085D0C2 /* Resources */, + 15A6DA97199CFB8700B56DBF /* res */, ); name = CustomTemplate; sourceTree = ""; @@ -484,17 +541,6 @@ path = ios; sourceTree = SOURCE_ROOT; }; - 78C7DDAA14EBA5050085D0C2 /* Resources */ = { - isa = PBXGroup; - children = ( - 1AFAF8B916D35E4900DB1158 /* CloseNormal.png */, - 1AFAF8BA16D35E4900DB1158 /* CloseSelected.png */, - 1AFAF8BB16D35E4900DB1158 /* HelloWorld.png */, - ); - name = Resources; - path = ../Resources; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -582,17 +628,87 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 1AC6FAF9180E9839004C840B /* libcocos2dx Mac.a */ = { + 15A6DA7B199CFAFD00B56DBF /* libui Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = "libcocos2dx Mac.a"; + path = "libui Mac.a"; + remoteRef = 15A6DA7A199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA7D199CFAFD00B56DBF /* libcocostudio Mac.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libcocostudio Mac.a"; + remoteRef = 15A6DA7C199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA7F199CFAFD00B56DBF /* libcocosbuilder Mac.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libcocosbuilder Mac.a"; + remoteRef = 15A6DA7E199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA81199CFAFD00B56DBF /* libspine Mac.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libspine Mac.a"; + remoteRef = 15A6DA80199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA83199CFAFD00B56DBF /* libnetwork Mac.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libnetwork Mac.a"; + remoteRef = 15A6DA82199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA85199CFAFD00B56DBF /* libui iOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libui iOS.a"; + remoteRef = 15A6DA84199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA87199CFAFD00B56DBF /* libcocostudio iOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libcocostudio iOS.a"; + remoteRef = 15A6DA86199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA89199CFAFD00B56DBF /* libcocosbuilder iOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libcocosbuilder iOS.a"; + remoteRef = 15A6DA88199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA8B199CFAFD00B56DBF /* libspine iOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libspine iOS.a"; + remoteRef = 15A6DA8A199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 15A6DA8D199CFAFD00B56DBF /* libnetwork iOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libnetwork iOS.a"; + remoteRef = 15A6DA8C199CFAFD00B56DBF /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 1AC6FAF9180E9839004C840B /* libcocos2d Mac.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libcocos2d Mac.a"; remoteRef = 1AC6FAF8180E9839004C840B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AC6FAFB180E9839004C840B /* libcocos2dx-extensions Mac.a */ = { + 1AC6FAFB180E9839004C840B /* libextension Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = "libcocos2dx-extensions Mac.a"; + path = "libextension Mac.a"; remoteRef = 1AC6FAFA180E9839004C840B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -610,38 +726,24 @@ remoteRef = 1AC6FAFE180E9839004C840B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AC6FB01180E9839004C840B /* libCocosDenshion Mac.a */ = { + 1AC6FB01180E9839004C840B /* libcocosdenshion Mac.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = "libCocosDenshion Mac.a"; + path = "libcocosdenshion Mac.a"; remoteRef = 1AC6FB00180E9839004C840B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AC6FB03180E9839004C840B /* libjsbindings Mac.a */ = { + 1AC6FB07180E9839004C840B /* libcocos2d iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = "libjsbindings Mac.a"; - remoteRef = 1AC6FB02180E9839004C840B /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 1AC6FB05180E9839004C840B /* libluabindings Mac.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libluabindings Mac.a"; - remoteRef = 1AC6FB04180E9839004C840B /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 1AC6FB07180E9839004C840B /* libcocos2dx iOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libcocos2dx iOS.a"; + path = "libcocos2d iOS.a"; remoteRef = 1AC6FB06180E9839004C840B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AC6FB09180E9839004C840B /* libcocos2dx-extensions iOS.a */ = { + 1AC6FB09180E9839004C840B /* libextension iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = "libcocos2dx-extensions iOS.a"; + path = "libextension iOS.a"; remoteRef = 1AC6FB08180E9839004C840B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -659,27 +761,13 @@ remoteRef = 1AC6FB0C180E9839004C840B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AC6FB0F180E9839004C840B /* libCocosDenshion iOS.a */ = { + 1AC6FB0F180E9839004C840B /* libcocosdenshion iOS.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = "libCocosDenshion iOS.a"; + path = "libcocosdenshion iOS.a"; remoteRef = 1AC6FB0E180E9839004C840B /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 1AC6FB11180E9839004C840B /* libjsbindings iOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libjsbindings iOS.a"; - remoteRef = 1AC6FB10180E9839004C840B /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 1AC6FB13180E9839004C840B /* libluabindings iOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libluabindings iOS.a"; - remoteRef = 1AC6FB12180E9839004C840B /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -688,23 +776,23 @@ buildActionMask = 2147483647; files = ( 5087E78117EB970100C73F5D /* Icon-120.png in Resources */, + 15A6DA9F199CFB9800B56DBF /* HelloWorld.png in Resources */, 5087E78617EB970100C73F5D /* Icon-76.png in Resources */, 5087E77F17EB970100C73F5D /* Default@2x.png in Resources */, 50EF629917ECD46A001EB2F8 /* Icon-100.png in Resources */, - 1AFAF8BC16D35E4900DB1158 /* CloseNormal.png in Resources */, 5087E78317EB970100C73F5D /* Icon-152.png in Resources */, + 15A6DA9D199CFB9800B56DBF /* CloseSelected.png in Resources */, 5087E77D17EB970100C73F5D /* Default-568h@2x.png in Resources */, 5087E78517EB970100C73F5D /* Icon-72.png in Resources */, - 1AFAF8BD16D35E4900DB1158 /* CloseSelected.png in Resources */, 50EF62A317ECD613001EB2F8 /* Icon-50.png in Resources */, 5087E78017EB970100C73F5D /* Icon-114.png in Resources */, - 1AFAF8BE16D35E4900DB1158 /* HelloWorld.png in Resources */, 50EF62A217ECD613001EB2F8 /* Icon-29.png in Resources */, 50EF629617ECD46A001EB2F8 /* Icon-40.png in Resources */, 5087E78217EB970100C73F5D /* Icon-144.png in Resources */, 50EF629817ECD46A001EB2F8 /* Icon-80.png in Resources */, 5087E78417EB970100C73F5D /* Icon-57.png in Resources */, 5087E77E17EB970100C73F5D /* Default.png in Resources */, + 15A6DA9B199CFB9800B56DBF /* CloseNormal.png in Resources */, 50EF629717ECD46A001EB2F8 /* Icon-58.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -713,10 +801,10 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5087E75317EB910900C73F5D /* CloseNormal.png in Resources */, 503AE0F817EB97AB00D1A890 /* Icon.icns in Resources */, - 5087E75417EB910900C73F5D /* CloseSelected.png in Resources */, - 5087E75517EB910900C73F5D /* HelloWorld.png in Resources */, + 15A6DAA0199CFB9800B56DBF /* HelloWorld.png in Resources */, + 15A6DA9C199CFB9800B56DBF /* CloseNormal.png in Resources */, + 15A6DA9E199CFB9800B56DBF /* CloseSelected.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -727,11 +815,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15A6DA93199CFB1100B56DBF /* AppDelegate.cpp in Sources */, + 15A6DA95199CFB1100B56DBF /* HelloWorldScene.cpp in Sources */, 503AE10017EB989F00D1A890 /* AppController.mm in Sources */, 503AE10217EB989F00D1A890 /* RootViewController.mm in Sources */, - 1AFAF8B716D35DE700DB1158 /* AppDelegate.cpp in Sources */, 503AE10117EB989F00D1A890 /* main.m in Sources */, - 1AFAF8B816D35DE700DB1158 /* HelloWorldScene.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -739,9 +827,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5087E75717EB910900C73F5D /* AppDelegate.cpp in Sources */, - 5087E75817EB910900C73F5D /* HelloWorldScene.cpp in Sources */, + 15A6DA94199CFB1100B56DBF /* AppDelegate.cpp in Sources */, 503AE10517EB98FF00D1A890 /* main.cpp in Sources */, + 15A6DA96199CFB1100B56DBF /* HelloWorldScene.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/templates/cpp-template-default/proj.linux/main.cpp b/templates/cpp-template-default/proj.linux/main.cpp index c5b735da78..529445638b 100644 --- a/templates/cpp-template-default/proj.linux/main.cpp +++ b/templates/cpp-template-default/proj.linux/main.cpp @@ -1,4 +1,4 @@ -#include "../Classes/AppDelegate.h" +#include "../src/AppDelegate.h" #include #include diff --git a/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj b/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj index 022025afc8..a2eb592205 100644 --- a/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj +++ b/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj @@ -73,7 +73,7 @@ Disabled - $(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;..\Classes;..;%(AdditionalIncludeDirectories) + $(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;..\src;..;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -106,7 +106,7 @@ xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)" MaxSpeed true - $(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;..\Classes;..;%(AdditionalIncludeDirectories) + $(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;..\src;..;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -137,13 +137,13 @@ xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)" - - + + - - + + diff --git a/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj.filters b/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj.filters index 0afd6b671a..4b0292cd30 100644 --- a/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj.filters +++ b/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj.filters @@ -4,33 +4,33 @@ {84a8ebd7-7cf0-47f6-b75e-d441df67da40} - - {bb6c862e-70e9-49d9-81b7-3829a6f50471} - {715254bc-d70b-4ec5-bf29-467dd3ace079} + + {bb6c862e-70e9-49d9-81b7-3829a6f50471} + win32 - - Classes + + src - - Classes + + src win32 - - Classes + + src - - Classes + + src diff --git a/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj.user b/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj.user index 32a6296820..57d3d8f797 100644 --- a/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj.user +++ b/templates/cpp-template-default/proj.win32/HelloCpp.vcxproj.user @@ -1,11 +1,11 @@  - $(ProjectDir)..\Resources + $(ProjectDir)..\res WindowsLocalDebugger - $(ProjectDir)..\Resources + $(ProjectDir)..\res WindowsLocalDebugger \ No newline at end of file diff --git a/templates/cpp-template-default/Resources/CloseNormal.png b/templates/cpp-template-default/res/CloseNormal.png similarity index 100% rename from templates/cpp-template-default/Resources/CloseNormal.png rename to templates/cpp-template-default/res/CloseNormal.png diff --git a/templates/cpp-template-default/Resources/CloseSelected.png b/templates/cpp-template-default/res/CloseSelected.png similarity index 100% rename from templates/cpp-template-default/Resources/CloseSelected.png rename to templates/cpp-template-default/res/CloseSelected.png diff --git a/templates/cpp-template-default/Resources/HelloWorld.png b/templates/cpp-template-default/res/HelloWorld.png similarity index 100% rename from templates/cpp-template-default/Resources/HelloWorld.png rename to templates/cpp-template-default/res/HelloWorld.png diff --git a/templates/cpp-template-default/Resources/fonts/Marker Felt.ttf b/templates/cpp-template-default/res/fonts/Marker Felt.ttf similarity index 100% rename from templates/cpp-template-default/Resources/fonts/Marker Felt.ttf rename to templates/cpp-template-default/res/fonts/Marker Felt.ttf diff --git a/templates/cpp-template-default/Classes/AppDelegate.cpp b/templates/cpp-template-default/src/AppDelegate.cpp similarity index 100% rename from templates/cpp-template-default/Classes/AppDelegate.cpp rename to templates/cpp-template-default/src/AppDelegate.cpp diff --git a/templates/cpp-template-default/Classes/AppDelegate.h b/templates/cpp-template-default/src/AppDelegate.h similarity index 100% rename from templates/cpp-template-default/Classes/AppDelegate.h rename to templates/cpp-template-default/src/AppDelegate.h diff --git a/templates/cpp-template-default/Classes/HelloWorldScene.cpp b/templates/cpp-template-default/src/HelloWorldScene.cpp similarity index 100% rename from templates/cpp-template-default/Classes/HelloWorldScene.cpp rename to templates/cpp-template-default/src/HelloWorldScene.cpp diff --git a/templates/cpp-template-default/Classes/HelloWorldScene.h b/templates/cpp-template-default/src/HelloWorldScene.h similarity index 100% rename from templates/cpp-template-default/Classes/HelloWorldScene.h rename to templates/cpp-template-default/src/HelloWorldScene.h From 8b83419a32febbca01cd8217b889a03178454b1c Mon Sep 17 00:00:00 2001 From: xiangxw Date: Fri, 15 Aug 2014 11:48:33 +0800 Subject: [PATCH 31/42] fix replaceAll() This function will never return if new_value contains old_value. For example, old_value = "'", new_value = "''". --- .../frameworks/runtime-src/Classes/runtime/Runtime.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp index 94c78e7e56..065219dd92 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp @@ -72,11 +72,14 @@ const char* getRuntimeVersion() static string& replaceAll(string& str,const string& old_value,const string& new_value) { + int start = 0; while(true) { int pos=0; - if((pos=str.find(old_value,0))!=string::npos) + if((pos=str.find(old_value,start))!=string::npos) { str.replace(pos,old_value.length(),new_value); + start = pos + new_value.length(); + } else break; } return str; From db17084b6d4bbaba5cc5e4e0c9317d1cbaadee63 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Aug 2014 12:06:16 +0800 Subject: [PATCH 32/42] fix warnings --- cocos/base/CCDirector.cpp | 2 +- extensions/GUI/CCScrollView/CCScrollView.h | 2 ++ tests/cpp-tests/Classes/ActionsTest/ActionsTest.h | 2 ++ .../Classes/PerformanceTest/PerformanceAllocTest.cpp | 10 +++++----- .../PerformanceTest/PerformanceContainerTest.cpp | 2 +- tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h | 5 +++++ 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index b942e24a95..30518792db 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -232,7 +232,7 @@ void Director::setDefaultValues(void) // PVR v2 has alpha premultiplied ? bool pvr_alpha_premultipled = conf->getValue("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", Value(false)).asBool(); - Texture2D::PVRImagesHavePremultipliedAlpha(pvr_alpha_premultipled); + Image::setPVRImagesHavePremultipliedAlpha(pvr_alpha_premultipled); } void Director::setGLDefaultValues() diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index a7939ee433..72695df5c7 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -181,10 +181,12 @@ public: /** * Provided to make scroll view compatible with SWLayer's pause method */ + using Layer::pause; // fix warning void pause(Ref* sender); /** * Provided to make scroll view compatible with SWLayer's resume method */ + using Layer::resume; // fix warning void resume(Ref* sender); void setTouchEnabled(bool enabled); diff --git a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h index 8d281e237e..a596e23cb0 100644 --- a/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h +++ b/tests/cpp-tests/Classes/ActionsTest/ActionsTest.h @@ -630,7 +630,9 @@ public: virtual std::string subtitle() const override; virtual std::string title() const override; + using Layer::pause; void pause(float dt); + using Layer::resume; void resume(float dt); private: Vector _pausedTargets; diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp index 7aee682d4f..fec47cbdea 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -230,7 +230,7 @@ void NodeCreateTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - log("Size of Node: %u\n", sizeof(Node)); + log("Size of Node: %lu\n", sizeof(Node)); scheduleUpdate(); } @@ -278,7 +278,7 @@ void NodeDeallocTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - log("Size of Node: %u\n", sizeof(Node)); + log("Size of Node: %lu\n", sizeof(Node)); scheduleUpdate(); } @@ -331,7 +331,7 @@ void SpriteCreateEmptyTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - log("Size of Sprite: %u\n", sizeof(Sprite)); + log("Size of Sprite: %lu\n", sizeof(Sprite)); scheduleUpdate(); } @@ -381,7 +381,7 @@ void SpriteCreateTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - log("Size of Sprite: %u\n", sizeof(Sprite)); + log("Size of Sprite: %lu\n", sizeof(Sprite)); scheduleUpdate(); } @@ -431,7 +431,7 @@ void SpriteDeallocTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - log("Size of sprite: %u\n", sizeof(Sprite)); + log("Size of sprite: %lu\n", sizeof(Sprite)); scheduleUpdate(); } diff --git a/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp b/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp index 2ebe66e483..2ad8bea2d9 100644 --- a/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp +++ b/tests/cpp-tests/Classes/PerformanceTest/PerformanceContainerTest.cpp @@ -156,7 +156,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes) addChild(menuLayer); menuLayer->release(); - log("Size of Node: %u\n", sizeof(Node)); + log("Size of Node: %d\n", (int)sizeof(Node)); int oldFontSize = MenuItemFont::getFontSize(); MenuItemFont::setFontSize(24); diff --git a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h index 5728f46a3a..09e6534bf2 100644 --- a/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h +++ b/tests/cpp-tests/Classes/SchedulerTest/SchedulerTest.h @@ -47,6 +47,7 @@ public: void tick1(float dt); void tick2(float dt); + using SchedulerTestLayer::pause; void pause(float dt); }; @@ -65,7 +66,9 @@ public: void tick1(float dt); void tick2(float dt); + using SchedulerTestLayer::pause; void pause(float dt); + using SchedulerTestLayer::resume; void resume(float dt); private: std::set _pausedTargets; @@ -85,7 +88,9 @@ public: void tick1(float dt); void tick2(float dt); + using SchedulerTestLayer::pause; void pause(float dt); + using SchedulerTestLayer::resume; void resume(float dt); private: std::set _pausedTargets; From 34ac767dc126d382c7b7d737aaa707b61c0223f1 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Aug 2014 13:41:11 +0800 Subject: [PATCH 33/42] [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 6ab981b04e..75b7360c1c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -920,6 +920,7 @@ Developers: Teivaz Custom uniform search optimization + Fixed compiling error on WP8. chareice Make `setup.py` work on zsh From 5e7b75c5c7881333a92a2fea76b795a99dfb49f6 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 15 Aug 2014 14:05:17 +0800 Subject: [PATCH 34/42] fix android background and foreground crash for primitive --- cocos/renderer/CCVertexIndexBuffer.cpp | 56 +++++++++++--------------- cocos/renderer/CCVertexIndexBuffer.h | 11 ++--- 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/cocos/renderer/CCVertexIndexBuffer.cpp b/cocos/renderer/CCVertexIndexBuffer.cpp index 5fdd9f31b6..44c1a70de9 100644 --- a/cocos/renderer/CCVertexIndexBuffer.cpp +++ b/cocos/renderer/CCVertexIndexBuffer.cpp @@ -57,11 +57,17 @@ VertexBuffer::VertexBuffer() : _vbo(0) , _vertexNumber(0) , _sizePerVertex(0) +, _recreateVBOEventListener(nullptr) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(VertexBuffer::listenToBackground, this)); - + auto callBack = [this](EventCustom* event) + { + this->recreateVBO(); + }; + + _recreateVBOEventListener = Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_RENDERER_RECREATED, callBack); + #endif } @@ -72,6 +78,9 @@ VertexBuffer::~VertexBuffer() glDeleteBuffers(1, &_vbo); _vbo = 0; } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Director::getInstance()->getEventDispatcher()->removeEventListener(_recreateVBOEventListener); +#endif } bool VertexBuffer::init(int sizePerVertex, int vertexNumber) @@ -131,21 +140,8 @@ bool VertexBuffer::updateVertices(const void* verts, int count, int begin) return true; } -void VertexBuffer::listenToBackground(EventCustom *event) -{ - if(glIsBuffer(_vbo)) - { - glDeleteBuffers(1, &_vbo); - _vbo = 0; - } -} - GLuint VertexBuffer::getVBO() const { - if(0 == _vbo) - { - recreateVBO(); - } return _vbo; } @@ -159,7 +155,7 @@ void VertexBuffer::recreateVBO() const { buffer = &_shadowCopy[0]; } - + CCLOG("recreate IndexBuffer with size %d %d", getSizePerVertex(), _vertexNumber); glBufferData(GL_ARRAY_BUFFER, _sizePerVertex * _vertexNumber, buffer, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); if(!glIsBuffer(_vbo)) @@ -189,10 +185,15 @@ IndexBuffer::IndexBuffer() : _vbo(0) , _type(IndexType::INDEX_TYPE_SHORT_16) , _indexNumber(0) +, _recreateVBOEventListener(nullptr) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(IndexBuffer::listenToBackground, this)); - + auto callBack = [this](EventCustom* event) + { + this->recreateVBO(); + }; + + _recreateVBOEventListener = Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_RENDERER_RECREATED, callBack); #endif } @@ -203,6 +204,9 @@ IndexBuffer::~IndexBuffer() glDeleteBuffers(1, &_vbo); _vbo = 0; } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Director::getInstance()->getEventDispatcher()->removeEventListener(_recreateVBOEventListener); +#endif } bool IndexBuffer::init(IndexBuffer::IndexType type, int number) @@ -273,22 +277,8 @@ int IndexBuffer::getSize() const return getSizePerIndex() * _indexNumber; } -void IndexBuffer::listenToBackground(EventCustom *event) -{ - if(glIsBuffer(_vbo)) - { - glDeleteBuffers(1, &_vbo); - _vbo = 0; - } -} - GLuint IndexBuffer::getVBO() const { - if(0 == _vbo) - { - recreateVBO(); - } - return _vbo; } @@ -302,7 +292,7 @@ void IndexBuffer::recreateVBO() const { buffer = &_shadowCopy[0]; } - + CCLOG("recreate IndexBuffer with size %d %d ", getSizePerIndex(), _indexNumber); glBufferData(GL_ARRAY_BUFFER, getSize(), buffer, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); if(!glIsBuffer(_vbo)) diff --git a/cocos/renderer/CCVertexIndexBuffer.h b/cocos/renderer/CCVertexIndexBuffer.h index 3c38af4422..ebc21b1537 100644 --- a/cocos/renderer/CCVertexIndexBuffer.h +++ b/cocos/renderer/CCVertexIndexBuffer.h @@ -30,6 +30,8 @@ NS_CC_BEGIN +class EventListenerCustom; + class CC_DLL VertexBuffer : public Ref { public: @@ -49,9 +51,9 @@ protected: bool init(int sizePerVertex, int vertexNumber); protected: - //event listener for foreground and background - void listenToBackground(EventCustom *event); + //event listener for foreground void recreateVBO() const; + EventListenerCustom* _recreateVBOEventListener; protected: mutable GLuint _vbo; int _sizePerVertex; @@ -98,10 +100,9 @@ protected: int _indexNumber; protected: - //event listener for foreground and background - void listenToBackground(EventCustom *event); + //event listener for foreground void recreateVBO() const; - + EventListenerCustom* _recreateVBOEventListener; //buffer used for shadow copy std::vector _shadowCopy; protected: From bf75e9996a423904aedb1743d26d315fc16bc2b0 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Aug 2014 14:29:10 +0800 Subject: [PATCH 35/42] separate jpeg, tiff and webp --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 + cocos/Android.mk | 7 +- cocos/base/CCModuleManager.cpp | 71 +++ cocos/base/CCModuleManager.h | 50 ++ cocos/platform/CCImage.cpp | 502 +++---------------- cocos/platform/CCImage.h | 32 ++ 6 files changed, 235 insertions(+), 439 deletions(-) create mode 100644 cocos/base/CCModuleManager.cpp create mode 100644 cocos/base/CCModuleManager.h diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 138951d22f..e4555d5cbe 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -690,6 +690,10 @@ 464AD6E6197EBB1400E502D8 /* pvr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 464AD6E3197EBB1400E502D8 /* pvr.cpp */; }; 464AD6E7197EBB1400E502D8 /* pvr.h in Headers */ = {isa = PBXBuildFile; fileRef = 464AD6E4197EBB1400E502D8 /* pvr.h */; }; 464AD6E8197EBB1400E502D8 /* pvr.h in Headers */ = {isa = PBXBuildFile; fileRef = 464AD6E4197EBB1400E502D8 /* pvr.h */; }; + 46633BC4199DDB2F00F6E838 /* CCModuleManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46633BC2199DDB2F00F6E838 /* CCModuleManager.cpp */; }; + 46633BC5199DDB2F00F6E838 /* CCModuleManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46633BC2199DDB2F00F6E838 /* CCModuleManager.cpp */; }; + 46633BC6199DDB2F00F6E838 /* CCModuleManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46633BC3199DDB2F00F6E838 /* CCModuleManager.h */; }; + 46633BC7199DDB2F00F6E838 /* CCModuleManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46633BC3199DDB2F00F6E838 /* CCModuleManager.h */; }; 46A160421807A5D4005B8026 /* Export.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE11807A56F005B8026 /* Export.h */; }; 46A160431807A5D4005B8026 /* SimpleAudioEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FE21807A56F005B8026 /* SimpleAudioEngine.h */; }; 46A160441807A5D4005B8026 /* CDAudioManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A15FF41807A56F005B8026 /* CDAudioManager.h */; }; @@ -2505,6 +2509,8 @@ 3EA4786F195478E00068D9D1 /* CCBundleReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBundleReader.h; sourceTree = ""; }; 464AD6E3197EBB1400E502D8 /* pvr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pvr.cpp; path = ../base/pvr.cpp; sourceTree = ""; }; 464AD6E4197EBB1400E502D8 /* pvr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = pvr.h; path = ../base/pvr.h; sourceTree = ""; }; + 46633BC2199DDB2F00F6E838 /* CCModuleManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCModuleManager.cpp; path = ../base/CCModuleManager.cpp; sourceTree = ""; }; + 46633BC3199DDB2F00F6E838 /* CCModuleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCModuleManager.h; path = ../base/CCModuleManager.h; sourceTree = ""; }; 46A15FCC1807A544005B8026 /* AUTHORS */ = {isa = PBXFileReference; lastKnownFileType = text; name = AUTHORS; path = ../AUTHORS; sourceTree = ""; }; 46A15FCE1807A544005B8026 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = ""; }; 46A15FE11807A56F005B8026 /* Export.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; @@ -3411,6 +3417,8 @@ 1A570095180BC5B00088DEC7 /* base-nodes */ = { isa = PBXGroup; children = ( + 46633BC2199DDB2F00F6E838 /* CCModuleManager.cpp */, + 46633BC3199DDB2F00F6E838 /* CCModuleManager.h */, 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */, 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */, 1A57009C180BC5D20088DEC7 /* CCNode.cpp */, @@ -5280,6 +5288,7 @@ 1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */, 5034CA3F191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */, 50ABBD461925AB0000A911A9 /* CCVertex.h in Headers */, + 46633BC6199DDB2F00F6E838 /* CCModuleManager.h in Headers */, 46A170E71807CECA005B8026 /* CCPhysicsBody.h in Headers */, 46A170EB1807CECA005B8026 /* CCPhysicsJoint.h in Headers */, 50ABBD3E1925AB0000A911A9 /* CCGeometry.h in Headers */, @@ -5664,6 +5673,7 @@ 50ABC0041926664800A911A9 /* CCLock.h in Headers */, 5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */, 50ABBEC21925AB6F00A911A9 /* CCValue.h in Headers */, + 46633BC7199DDB2F00F6E838 /* CCModuleManager.h in Headers */, 50ABBECA1925AB6F00A911A9 /* firePngData.h in Headers */, B257B4511989D5E800D9A687 /* CCPrimitive.h in Headers */, 50ABBE401925AB6F00A911A9 /* CCDataVisitor.h in Headers */, @@ -6821,6 +6831,7 @@ 50ABBE651925AB6F00A911A9 /* CCEventListenerCustom.cpp in Sources */, B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */, 50ABBE391925AB6F00A911A9 /* CCData.cpp in Sources */, + 46633BC4199DDB2F00F6E838 /* CCModuleManager.cpp in Sources */, 1A57010E180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */, 50ABBED71925AB6F00A911A9 /* ZipUtils.cpp in Sources */, 1A01C68418F57BE800EFE3A6 /* CCArray.cpp in Sources */, @@ -7228,6 +7239,7 @@ 50ABBE8C1925AB6F00A911A9 /* CCNS.cpp in Sources */, 50ABBDAE1925AB4100A911A9 /* CCRenderer.cpp in Sources */, 50ABBDBA1925AB4100A911A9 /* CCTextureAtlas.cpp in Sources */, + 46633BC5199DDB2F00F6E838 /* CCModuleManager.cpp in Sources */, 1A5702FB180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */, 1A570301180BCE890088DEC7 /* CCParallaxNode.cpp in Sources */, 1A57030D180BCF190088DEC7 /* CCComponent.cpp in Sources */, diff --git a/cocos/Android.mk b/cocos/Android.mk index 471ef20ff7..32b0039a16 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -127,6 +127,7 @@ base/CCEventListenerTouch.cpp \ base/CCEventMouse.cpp \ base/CCEventTouch.cpp \ base/CCIMEDispatcher.cpp \ +base/CCModuleManager.cpp \ base/CCNS.cpp \ base/CCProfiling.cpp \ base/CCRef.cpp \ @@ -226,9 +227,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_freetype2_static LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_png_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_tiff_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_webp_static # define the macro to compile through support/zip_support/ioapi.c LOCAL_CFLAGS := -DUSE_FILE32API @@ -241,7 +239,4 @@ include $(BUILD_STATIC_LIBRARY) $(call import-module,freetype2/prebuilt/android) $(call import-module,chipmunk) $(call import-module,platform/android) -$(call import-module,jpeg/prebuilt/android) $(call import-module,png/prebuilt/android) -$(call import-module,tiff/prebuilt/android) -$(call import-module,webp/prebuilt/android) diff --git a/cocos/base/CCModuleManager.cpp b/cocos/base/CCModuleManager.cpp new file mode 100644 index 0000000000..d6a8d9b681 --- /dev/null +++ b/cocos/base/CCModuleManager.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** + Copyright (c) 2014 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "base/CCModuleManager.h" +#include +#include "base/CCConsole.h" + +using namespace std; + +//RegisterJPEG *temp = new RegisterJPEG(); + +NS_CC_BEGIN + +void ModuleManager::registerModule(const string &moduleName, void* module) +{ + auto &moduleMap = createMap(); + if (moduleMap.find(moduleName) != moduleMap.end()) + { + CCLOG("module: %s exists", moduleName.c_str()); + return; + } + + moduleMap[moduleName] = module; +} + +void ModuleManager::unRegisterModule(const string &moduleName) +{ + auto &moduleMap = createMap(); + moduleMap.erase(moduleName); +} + +void* ModuleManager::getModule(const string &moduleName) +{ + auto &moduleMap = createMap(); + auto result = moduleMap.find(moduleName); + if (result != moduleMap.end()) + { + return result->second; + } + else + return nullptr; +} + +unordered_map& ModuleManager::createMap() +{ + static unordered_map map; + return map; +} + +NS_CC_END diff --git a/cocos/base/CCModuleManager.h b/cocos/base/CCModuleManager.h new file mode 100644 index 0000000000..c6ec6f1268 --- /dev/null +++ b/cocos/base/CCModuleManager.h @@ -0,0 +1,50 @@ +/**************************************************************************** + Copyright (c) 2014 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __BASE_CC_MODULE_MANAGER__ +#define __BASE_CC_MODULE_MANAGER__ + +#include +#include + +#include "base/CCPlatformMacros.h" + + +NS_CC_BEGIN + +class CC_DLL ModuleManager +{ +public: + static void registerModule(const std::string &moduleName, void* module); + static void unRegisterModule(const std::string &moduleName); + static void* getModule(const std::string &moduleName); + +private: + static std::unordered_map& createMap(); +}; + +NS_CC_END + +#endif + diff --git a/cocos/platform/CCImage.cpp b/cocos/platform/CCImage.cpp index 08cd3e5f10..80ba8e672b 100644 --- a/cocos/platform/CCImage.cpp +++ b/cocos/platform/CCImage.cpp @@ -31,12 +31,6 @@ THE SOFTWARE. #include "base/CCData.h" - -#ifdef EMSCRIPTEN -#include -#include -#endif // EMSCRIPTEN - extern "C" { // To resolve link error when building 32bits with Xcode 6. @@ -57,22 +51,21 @@ extern "C" { return strerror(errnum); } + // int fputs(const char * __restrict, FILE * __restrict) __DARWIN_ALIAS(fputs); + int fputs$UNIX2003(const char *str, FILE *stream) + { + return fputs(str, stream); + } #endif #endif #include "png.h" -#include "tiffio.h" #include "base/etc1.h" -#include "jpeglib.h" } #include "base/s3tc.h" #include "base/atitc.h" #include "base/pvr.h" #include "base/TGAlib.h" -#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) -#include "decode.h" -#endif - #include "base/ccMacros.h" #include "CCCommon.h" #include "CCStdC.h" @@ -80,6 +73,7 @@ extern "C" #include "base/CCConfiguration.h" #include "base/ccUtils.h" #include "base/ZipUtils.h" +#include "base/CCModuleManager.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "android/CCFileUtilsAndroid.h" #endif @@ -96,7 +90,6 @@ NS_CC_BEGIN namespace { static const int PVR_TEXTURE_FLAG_TYPE_MASK = 0xff; - static bool _PVRHaveAlphaPremultiplied = false; // Values taken from PVRTexture.h from http://www.imgtec.com @@ -759,158 +752,28 @@ bool Image::isCompressed() return Texture2D::getPixelFormatInfoMap().at(_renderFormat).compressed; } -namespace -{ -/* - * ERROR HANDLING: - * - * The JPEG library's standard error handler (jerror.c) is divided into - * several "methods" which you can override individually. This lets you - * adjust the behavior without duplicating a lot of code, which you might - * have to update with each future release. - * - * We override the "error_exit" method so that control is returned to the - * library's caller when a fatal error occurs, rather than calling exit() - * as the standard error_exit method does. - * - * We use C's setjmp/longjmp facility to return control. This means that the - * routine which calls the JPEG library must first execute a setjmp() call to - * establish the return point. We want the replacement error_exit to do a - * longjmp(). But we need to make the setjmp buffer accessible to the - * error_exit routine. To do this, we make a private extension of the - * standard JPEG error handler object. (If we were using C++, we'd say we - * were making a subclass of the regular error handler.) - * - * Here's the extended error handler struct: - */ - struct MyErrorMgr - { - struct jpeg_error_mgr pub; /* "public" fields */ - jmp_buf setjmp_buffer; /* for return to caller */ - }; - - typedef struct MyErrorMgr * MyErrorPtr; - - /* - * Here's the routine that will replace the standard error_exit method: - */ - - METHODDEF(void) - myErrorExit(j_common_ptr cinfo) - { - /* cinfo->err really points to a MyErrorMgr struct, so coerce pointer */ - MyErrorPtr myerr = (MyErrorPtr) cinfo->err; - - /* Always display the message. */ - /* We could postpone this until after returning, if we chose. */ - /* internal message function cann't show error message in some platforms, so we rewrite it here. - * edit it if has version confilict. - */ - //(*cinfo->err->output_message) (cinfo); - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message) (cinfo, buffer); - CCLOG("jpeg error: %s", buffer); - - /* Return control to the setjmp point */ - longjmp(myerr->setjmp_buffer, 1); - } -} - bool Image::initWithJpgData(const unsigned char * data, ssize_t dataLen) { - /* these are standard libjpeg structures for reading(decompression) */ - struct jpeg_decompress_struct cinfo; - /* We use our private extension JPEG error handler. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct MyErrorMgr jerr; - /* libjpeg data structure for storing one row, that is, scanline of an image */ - JSAMPROW row_pointer[1] = {0}; - unsigned long location = 0; - unsigned int i = 0; - - bool bRet = false; - do + _hasPremultipliedAlpha = false; + + JPEGModule *jpegModule = static_cast(ModuleManager::getModule("jpeg")); + if (jpegModule) { - /* We set up the normal JPEG error routines, then override error_exit. */ - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = myErrorExit; - /* Establish the setjmp return context for MyErrorExit to use. */ - if (setjmp(jerr.setjmp_buffer)) { - /* If we get here, the JPEG code has signaled an error. - * We need to clean up the JPEG object, close the input file, and return. - */ - jpeg_destroy_decompress(&cinfo); - break; - } - - /* setup decompression process and source, then read JPEG header */ - jpeg_create_decompress( &cinfo ); - -#ifndef CC_TARGET_QT5 - jpeg_mem_src( &cinfo, const_cast(data), dataLen ); -#endif /* CC_TARGET_QT5 */ - - /* reading the image header which contains image information */ -#if (JPEG_LIB_VERSION >= 90) - // libjpeg 0.9 adds stricter types. - jpeg_read_header( &cinfo, TRUE ); -#else - jpeg_read_header( &cinfo, true ); -#endif - - // we only support RGB or grayscale - if (cinfo.jpeg_color_space == JCS_GRAYSCALE) - { - _renderFormat = Texture2D::PixelFormat::I8; - }else - { - cinfo.out_color_space = JCS_RGB; - _renderFormat = Texture2D::PixelFormat::RGB888; - } - - /* Start decompression jpeg here */ - jpeg_start_decompress( &cinfo ); - - /* init image info */ - _width = cinfo.output_width; - _height = cinfo.output_height; - _hasPremultipliedAlpha = false; - row_pointer[0] = static_cast(malloc(cinfo.output_width*cinfo.output_components * sizeof(unsigned char))); - CC_BREAK_IF(! row_pointer[0]); - - _dataLen = cinfo.output_width*cinfo.output_height*cinfo.output_components; - _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); - CC_BREAK_IF(! _data); - - /* now actually read the jpeg into the raw buffer */ - /* read one scan line at a time */ - while( cinfo.output_scanline < cinfo.output_height ) - { - jpeg_read_scanlines( &cinfo, row_pointer, 1 ); - for( i=0; iinitWithJPEGData(data, dataLen, dataFromJPEGInit); + _width = dataFromJPEGInit.width; + _height = dataFromJPEGInit.height; + _renderFormat = dataFromJPEGInit.renderFormat; + _dataLen = dataFromJPEGInit.dataLength; + _data = dataFromJPEGInit.data; + + return result; + } + else { - free(row_pointer[0]); - }; - return bRet; + CCLOG("jpeg module is not enabled"); + return false; + } } bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen) @@ -1062,175 +925,28 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen) return bRet; } -namespace -{ - static tmsize_t tiffReadProc(thandle_t fd, void* buf, tmsize_t size) - { - tImageSource* isource = (tImageSource*)fd; - uint8* ma; - uint64 mb; - unsigned long n; - unsigned long o; - tmsize_t p; - ma=(uint8*)buf; - mb=size; - p=0; - while (mb>0) - { - n=0x80000000UL; - if ((uint64)n>mb) - n=(unsigned long)mb; - - - if((int)(isource->offset + n) <= isource->size) - { - memcpy(ma, isource->data+isource->offset, n); - isource->offset += n; - o = n; - } - else - { - return 0; - } - - ma+=o; - mb-=o; - p+=o; - if (o!=n) - { - break; - } - } - return p; - } - - static tmsize_t tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) - { - CC_UNUSED_PARAM(fd); - CC_UNUSED_PARAM(buf); - CC_UNUSED_PARAM(size); - return 0; - } - - - static uint64 tiffSeekProc(thandle_t fd, uint64 off, int whence) - { - tImageSource* isource = (tImageSource*)fd; - uint64 ret = -1; - do - { - if (whence == SEEK_SET) - { - CC_BREAK_IF(off >= (uint64)isource->size); - ret = isource->offset = (uint32)off; - } - else if (whence == SEEK_CUR) - { - CC_BREAK_IF(isource->offset + off >= (uint64)isource->size); - ret = isource->offset += (uint32)off; - } - else if (whence == SEEK_END) - { - CC_BREAK_IF(off >= (uint64)isource->size); - ret = isource->offset = (uint32)(isource->size-1 - off); - } - else - { - CC_BREAK_IF(off >= (uint64)isource->size); - ret = isource->offset = (uint32)off; - } - } while (0); - - return ret; - } - - static uint64 tiffSizeProc(thandle_t fd) - { - tImageSource* pImageSrc = (tImageSource*)fd; - return pImageSrc->size; - } - - static int tiffCloseProc(thandle_t fd) - { - CC_UNUSED_PARAM(fd); - return 0; - } - - static int tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) - { - CC_UNUSED_PARAM(fd); - CC_UNUSED_PARAM(pbase); - CC_UNUSED_PARAM(psize); - return 0; - } - - static void tiffUnmapProc(thandle_t fd, void* base, toff_t size) - { - CC_UNUSED_PARAM(fd); - CC_UNUSED_PARAM(base); - CC_UNUSED_PARAM(size); - } -} - bool Image::initWithTiffData(const unsigned char * data, ssize_t dataLen) { - bool bRet = false; - do + _hasPremultipliedAlpha = true; + + TIFFModule *tiffModule = static_cast(ModuleManager::getModule("tiff")); + if (tiffModule) { - // set the read call back function - tImageSource imageSource; - imageSource.data = data; - imageSource.size = dataLen; - imageSource.offset = 0; - - TIFF* tif = TIFFClientOpen("file.tif", "r", (thandle_t)&imageSource, - tiffReadProc, tiffWriteProc, - tiffSeekProc, tiffCloseProc, tiffSizeProc, - tiffMapProc, - tiffUnmapProc); - - CC_BREAK_IF(nullptr == tif); - - uint32 w = 0, h = 0; - uint16 bitsPerSample = 0, samplePerPixel = 0, planarConfig = 0; - size_t npixels = 0; + DataFromModule dataFromTIFFInit; + bool result = tiffModule->initWithTIFFData(data, dataLen, dataFromTIFFInit); + _width = dataFromTIFFInit.width; + _height = dataFromTIFFInit.height; + _renderFormat = dataFromTIFFInit.renderFormat; + _dataLen = dataFromTIFFInit.dataLength; + _data = dataFromTIFFInit.data; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); - TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplePerPixel); - TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarConfig); - - npixels = w * h; - - _renderFormat = Texture2D::PixelFormat::RGBA8888; - _width = w; - _height = h; - - _dataLen = npixels * sizeof (uint32); - _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); - - uint32* raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); - if (raster != nullptr) - { - if (TIFFReadRGBAImageOriented(tif, w, h, raster, ORIENTATION_TOPLEFT, 0)) - { - /* the raster data is pre-multiplied by the alpha component - after invoking TIFFReadRGBAImageOriented*/ - _hasPremultipliedAlpha = true; - - memcpy(_data, raster, npixels*sizeof (uint32)); - } - - _TIFFfree(raster); - } - - - TIFFClose(tif); - - bRet = true; - } while (0); - return bRet; + return result; + } + else + { + CCLOG("tiff module is not enabled"); + return false; + } } namespace @@ -2011,42 +1727,29 @@ bool Image::initWithPVRData(const unsigned char * data, ssize_t dataLen) bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen) { - bool bRet = false; - #if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) CCLOG("WEBP image format not supported on WinRT or WP8"); + return false; #else - do - { - WebPDecoderConfig config; - if (WebPInitDecoderConfig(&config) == 0) break; - if (WebPGetFeatures(static_cast(data), dataLen, &config.input) != VP8_STATUS_OK) break; - if (config.input.width == 0 || config.input.height == 0) break; + WEBPModule *webpModule = static_cast(ModuleManager::getModule("webp")); + if (webpModule) + { + DataFromModule dataFromWEBPInit; + bool result = webpModule->initWithWEBPData(data, dataLen, dataFromWEBPInit); + _width = dataFromWEBPInit.width; + _height = dataFromWEBPInit.height; + _renderFormat = dataFromWEBPInit.renderFormat; + _dataLen = dataFromWEBPInit.dataLength; + _data = dataFromWEBPInit.data; - config.output.colorspace = MODE_RGBA; - _renderFormat = Texture2D::PixelFormat::RGBA8888; - _width = config.input.width; - _height = config.input.height; - - _dataLen = _width * _height * 4; - _data = static_cast(malloc(_dataLen * sizeof(unsigned char))); - - config.output.u.RGBA.rgba = static_cast(_data); - config.output.u.RGBA.stride = _width * 4; - config.output.u.RGBA.size = _dataLen; - config.output.is_external_memory = 1; - - if (WebPDecode(static_cast(data), dataLen, &config) != VP8_STATUS_OK) - { - free(_data); - _data = nullptr; - break; - } - - bRet = true; - } while (0); + return result; + } + else + { + CCLOG("webp module is not enabled"); + return false; + } #endif - return bRet; } @@ -2265,82 +1968,16 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB) } bool Image::saveImageToJPG(const std::string& filePath) { - bool bRet = false; - do + JPEGModule *jpegModule = static_cast(ModuleManager::getModule("jpeg")); + if (jpegModule) { - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - FILE * outfile; /* target file */ - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - int row_stride; /* physical row width in image buffer */ - - cinfo.err = jpeg_std_error(&jerr); - /* Now we can initialize the JPEG compression object. */ - jpeg_create_compress(&cinfo); - - CC_BREAK_IF((outfile = fopen(filePath.c_str(), "wb")) == nullptr); - - jpeg_stdio_dest(&cinfo, outfile); - - cinfo.image_width = _width; /* image width and height, in pixels */ - cinfo.image_height = _height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, 90, TRUE); - - jpeg_start_compress(&cinfo, TRUE); - - row_stride = _width * 3; /* JSAMPLEs per row in image_buffer */ - - if (hasAlpha()) - { - unsigned char *pTempData = static_cast(malloc(_width * _height * 3 * sizeof(unsigned char))); - if (nullptr == pTempData) - { - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - fclose(outfile); - break; - } - - for (int i = 0; i < _height; ++i) - { - for (int j = 0; j < _width; ++j) - - { - pTempData[(i * _width + j) * 3] = _data[(i * _width + j) * 4]; - pTempData[(i * _width + j) * 3 + 1] = _data[(i * _width + j) * 4 + 1]; - pTempData[(i * _width + j) * 3 + 2] = _data[(i * _width + j) * 4 + 2]; - } - } - - while (cinfo.next_scanline < cinfo.image_height) { - row_pointer[0] = & pTempData[cinfo.next_scanline * row_stride]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - if (pTempData != nullptr) - { - free(pTempData); - } - } - else - { - while (cinfo.next_scanline < cinfo.image_height) { - row_pointer[0] = & _data[cinfo.next_scanline * row_stride]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - } - - jpeg_finish_compress(&cinfo); - fclose(outfile); - jpeg_destroy_compress(&cinfo); - - bRet = true; - } while (0); - return bRet; + return jpegModule->saveImage(filePath, this); + } + else + { + CCLOG("jpeg module is not enabled"); + return false; + } } void Image::premultipliedAlpha() @@ -2357,7 +1994,6 @@ void Image::premultipliedAlpha() _hasPremultipliedAlpha = true; } - void Image::setPVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied) { _PVRHaveAlphaPremultiplied = haveAlphaPremultiplied; diff --git a/cocos/platform/CCImage.h b/cocos/platform/CCImage.h index 483ea686ff..bb9e8d0014 100644 --- a/cocos/platform/CCImage.h +++ b/cocos/platform/CCImage.h @@ -26,6 +26,8 @@ THE SOFTWARE. #ifndef __CC_IMAGE_H__ #define __CC_IMAGE_H__ +#include +#include #include "base/CCRef.h" #include "renderer/CCTexture2D.h" @@ -167,6 +169,7 @@ protected: void premultipliedAlpha(); + protected: /** @brief Determine how many mipmaps can we have. @@ -212,6 +215,35 @@ protected: bool isATITC(const unsigned char *data, ssize_t dataLen); }; +/* Data returned from jpeg/tiff/webp module initialization + */ +typedef struct DataFromModule +{ + Texture2D::PixelFormat renderFormat; + int width; + int height; + ssize_t dataLength; + unsigned char* data; + bool hasPremultiAlpha; +} DataFromModule; + +struct JPEGModule +{ + std::function saveImage; + std::function initWithJPEGData; +}; + +struct TIFFModule +{ + std::function initWithTIFFData; +}; + +struct WEBPModule +{ + std::function initWithWEBPData; +}; + + // end of platform group /// @} From aa052eb1c1d78680f6bcee59811d12bb55ae8c4c Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Aug 2014 14:39:15 +0800 Subject: [PATCH 36/42] add CCModuleManager into vs project --- cocos/2d/libcocos2d.vcxproj | 2 ++ cocos/2d/libcocos2d.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index b2a8130617..8e9bfae113 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -223,6 +223,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + @@ -420,6 +421,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 6597d36e2e..4a44e2d359 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -625,6 +625,9 @@ renderer + + base + @@ -1270,6 +1273,9 @@ renderer + + base + From 408472625c7ddb9141d27f816ec23ffbe1a63ca2 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Aug 2014 14:46:21 +0800 Subject: [PATCH 37/42] add CCModuleManager into CMakeLists.txt --- cocos/base/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/base/CMakeLists.txt b/cocos/base/CMakeLists.txt index 197e6bb7d4..a9b1f51ad9 100644 --- a/cocos/base/CMakeLists.txt +++ b/cocos/base/CMakeLists.txt @@ -22,6 +22,7 @@ set(COCOS_BASE_SRC base/CCEventMouse.cpp base/CCEventTouch.cpp base/CCIMEDispatcher.cpp + base/CCModuleManager.cpp base/CCNS.cpp base/CCProfiling.cpp base/CCRef.cpp From 64f6b9a8cc7edd7219ff0034c7aa5be5c1cbcffc Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Aug 2014 15:02:09 +0800 Subject: [PATCH 38/42] [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 9e4b52c463..ea4ffee5aa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ cocos2d-x-3.3 ?? [NEW] Added UIScale9Sprite [NEW] Added Camera [NEW] Added render primitive and render primitive command, support passing point, line and triangle data + [NEW] Added support for applicationDidEnterBackground / applicationWillEnterForeground on desktop [NEW] EventMouse: support getDelta, getDeltaX, getDeltaY functions [NEW] FileUtils: add isDirectoryExist(), createDirectory(), removeDirectory(), removeFile(), renameFile() getFileSize() From 8d69d4b05ca6ff6af8e1c03dfa32c0c1985e0551 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Aug 2014 15:20:05 +0800 Subject: [PATCH 39/42] [ci skip] --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index ea4ffee5aa..cb3e5c2993 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,8 @@ cocos2d-x-3.3 ?? [NEW] Sprite3D: added setCullFace() and setCullFaceEnabled() [NEW] SpriteFrameCache: load from plist file content data [NEW] utils: added gettime() + [NEW] ui::Button: support customize how much zoom scale is when pressing a button + [NEW] ui::PageView: added `customScrollThreshold`, could determine the swipe distance to trigger a PageView scroll event [NEW] ui::TextField: support utf8 [NEW] ui::TextField: support set color and placehold color [NEW] Text: added getter and setter for TextColor From 24f0e8aada4c140da5e9b43de84b0273ebd377e2 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 15 Aug 2014 07:23:17 +0000 Subject: [PATCH 40/42] [AUTO]: updating luabinding automatically --- .../lua-bindings/auto/api/Button.lua | 10 + .../lua-bindings/auto/api/PageView.lua | 20 ++ .../auto/lua_cocos2dx_ui_auto.cpp | 276 ++++++++++++++++++ .../auto/lua_cocos2dx_ui_auto.hpp | 6 + 4 files changed, 312 insertions(+) diff --git a/cocos/scripting/lua-bindings/auto/api/Button.lua b/cocos/scripting/lua-bindings/auto/api/Button.lua index 01e2a2990d..b0212c1988 100644 --- a/cocos/scripting/lua-bindings/auto/api/Button.lua +++ b/cocos/scripting/lua-bindings/auto/api/Button.lua @@ -19,6 +19,11 @@ -- @param self -- @param #bool bool +-------------------------------- +-- @function [parent=#Button] getZoomScale +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- @function [parent=#Button] getCapInsetsDisabledRenderer -- @param self @@ -120,6 +125,11 @@ -- @param self -- @param #bool bool +-------------------------------- +-- @function [parent=#Button] setZoomScale +-- @param self +-- @param #float float + -------------------------------- -- @overload self, string, string, string, int -- @overload self diff --git a/cocos/scripting/lua-bindings/auto/api/PageView.lua b/cocos/scripting/lua-bindings/auto/api/PageView.lua index 2e660a0635..f68253b507 100644 --- a/cocos/scripting/lua-bindings/auto/api/PageView.lua +++ b/cocos/scripting/lua-bindings/auto/api/PageView.lua @@ -4,6 +4,11 @@ -- @extend Layout -- @parent_module ccui +-------------------------------- +-- @function [parent=#PageView] getCustomScrollThreshold +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- @function [parent=#PageView] getCurPageIndex -- @param self @@ -16,6 +21,11 @@ -- @param #long long -- @param #bool bool +-------------------------------- +-- @function [parent=#PageView] isUsingCustomScrollThreshold +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- @function [parent=#PageView] getPage -- @param self @@ -32,6 +42,16 @@ -- @param self -- @param #function func +-------------------------------- +-- @function [parent=#PageView] setUsingCustomScrollThreshold +-- @param self +-- @param #bool bool + +-------------------------------- +-- @function [parent=#PageView] setCustomScrollThreshold +-- @param self +-- @param #float float + -------------------------------- -- @function [parent=#PageView] insertPage -- @param self diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index c4c11ce464..6774030a18 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -5069,6 +5069,50 @@ int lua_cocos2dx_ui_Button_setScale9Enabled(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Button_getZoomScale(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Button* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Button*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Button_getZoomScale'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + double ret = cobj->getZoomScale(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Button:getZoomScale",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Button_getZoomScale'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Button_getCapInsetsDisabledRenderer(lua_State* tolua_S) { int argc = 0; @@ -6006,6 +6050,52 @@ int lua_cocos2dx_ui_Button_setPressedActionEnabled(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Button_setZoomScale(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Button* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Button",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Button*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Button_setZoomScale'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "ccui.Button:setZoomScale"); + if(!ok) + return 0; + cobj->setZoomScale(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Button:setZoomScale",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Button_setZoomScale'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Button_create(lua_State* tolua_S) { int argc = 0; @@ -6189,6 +6279,7 @@ int lua_register_cocos2dx_ui_Button(lua_State* tolua_S) tolua_function(tolua_S,"getTitleText",lua_cocos2dx_ui_Button_getTitleText); tolua_function(tolua_S,"setTitleFontSize",lua_cocos2dx_ui_Button_setTitleFontSize); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_ui_Button_setScale9Enabled); + tolua_function(tolua_S,"getZoomScale",lua_cocos2dx_ui_Button_getZoomScale); tolua_function(tolua_S,"getCapInsetsDisabledRenderer",lua_cocos2dx_ui_Button_getCapInsetsDisabledRenderer); tolua_function(tolua_S,"setTitleColor",lua_cocos2dx_ui_Button_setTitleColor); tolua_function(tolua_S,"setCapInsetsDisabledRenderer",lua_cocos2dx_ui_Button_setCapInsetsDisabledRenderer); @@ -6208,6 +6299,7 @@ int lua_register_cocos2dx_ui_Button(lua_State* tolua_S) tolua_function(tolua_S,"getTitleFontName",lua_cocos2dx_ui_Button_getTitleFontName); tolua_function(tolua_S,"getTitleColor",lua_cocos2dx_ui_Button_getTitleColor); tolua_function(tolua_S,"setPressedActionEnabled",lua_cocos2dx_ui_Button_setPressedActionEnabled); + tolua_function(tolua_S,"setZoomScale",lua_cocos2dx_ui_Button_setZoomScale); tolua_function(tolua_S,"create", lua_cocos2dx_ui_Button_create); tolua_function(tolua_S,"createInstance", lua_cocos2dx_ui_Button_createInstance); tolua_endmodule(tolua_S); @@ -15318,6 +15410,50 @@ int lua_register_cocos2dx_ui_TextBMFont(lua_State* tolua_S) return 1; } +int lua_cocos2dx_ui_PageView_getCustomScrollThreshold(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_getCustomScrollThreshold'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + double ret = cobj->getCustomScrollThreshold(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:getCustomScrollThreshold",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_getCustomScrollThreshold'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_PageView_getCurPageIndex(lua_State* tolua_S) { int argc = 0; @@ -15414,6 +15550,50 @@ int lua_cocos2dx_ui_PageView_addWidgetToPage(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + bool ret = cobj->isUsingCustomScrollThreshold(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:isUsingCustomScrollThreshold",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_PageView_getPage(lua_State* tolua_S) { int argc = 0; @@ -15557,6 +15737,98 @@ int lua_cocos2dx_ui_PageView_addEventListener(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccui.PageView:setUsingCustomScrollThreshold"); + if(!ok) + return 0; + cobj->setUsingCustomScrollThreshold(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setUsingCustomScrollThreshold",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_ui_PageView_setCustomScrollThreshold(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::PageView* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::PageView*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_PageView_setCustomScrollThreshold'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + double arg0; + + ok &= luaval_to_number(tolua_S, 2,&arg0, "ccui.PageView:setCustomScrollThreshold"); + if(!ok) + return 0; + cobj->setCustomScrollThreshold(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ccui.PageView:setCustomScrollThreshold",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_PageView_setCustomScrollThreshold'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_PageView_insertPage(lua_State* tolua_S) { int argc = 0; @@ -15940,11 +16212,15 @@ int lua_register_cocos2dx_ui_PageView(lua_State* tolua_S) tolua_beginmodule(tolua_S,"PageView"); tolua_function(tolua_S,"new",lua_cocos2dx_ui_PageView_constructor); + tolua_function(tolua_S,"getCustomScrollThreshold",lua_cocos2dx_ui_PageView_getCustomScrollThreshold); tolua_function(tolua_S,"getCurPageIndex",lua_cocos2dx_ui_PageView_getCurPageIndex); tolua_function(tolua_S,"addWidgetToPage",lua_cocos2dx_ui_PageView_addWidgetToPage); + tolua_function(tolua_S,"isUsingCustomScrollThreshold",lua_cocos2dx_ui_PageView_isUsingCustomScrollThreshold); tolua_function(tolua_S,"getPage",lua_cocos2dx_ui_PageView_getPage); tolua_function(tolua_S,"removePage",lua_cocos2dx_ui_PageView_removePage); tolua_function(tolua_S,"addEventListener",lua_cocos2dx_ui_PageView_addEventListener); + tolua_function(tolua_S,"setUsingCustomScrollThreshold",lua_cocos2dx_ui_PageView_setUsingCustomScrollThreshold); + tolua_function(tolua_S,"setCustomScrollThreshold",lua_cocos2dx_ui_PageView_setCustomScrollThreshold); tolua_function(tolua_S,"insertPage",lua_cocos2dx_ui_PageView_insertPage); tolua_function(tolua_S,"scrollToPage",lua_cocos2dx_ui_PageView_scrollToPage); tolua_function(tolua_S,"removePageAtIndex",lua_cocos2dx_ui_PageView_removePageAtIndex); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index e733905e27..fa92d1bdaa 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -398,6 +398,12 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + + + + + From 128d06076a02b8aa4bbde8fa01df3b64acfba2b9 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 15 Aug 2014 07:41:13 +0000 Subject: [PATCH 41/42] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 304345daca..1652b0fb8f 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -192,10 +192,8 @@ "cocos/2d/cocos2dx.props", "cocos/2d/libcocos2d.vcxproj", "cocos/2d/libcocos2d.vcxproj.filters", - "cocos/3d/CCAABB.cpp", - "cocos/3d/CCAABB.h”, - "cocos/3d/CCOBB.cpp", - "cocos/3d/CCOBB.h”, + "cocos/3d/CCAABB.cpp", + "cocos/3d/CCAABB.h", "cocos/3d/CCAnimate3D.cpp", "cocos/3d/CCAnimate3D.h", "cocos/3d/CCAnimation3D.cpp", @@ -213,8 +211,12 @@ "cocos/3d/CCMesh.h", "cocos/3d/CCMeshSkin.cpp", "cocos/3d/CCMeshSkin.h", + "cocos/3d/CCOBB.cpp", + "cocos/3d/CCOBB.h", "cocos/3d/CCObjLoader.cpp", "cocos/3d/CCObjLoader.h", + "cocos/3d/CCRay.cpp", + "cocos/3d/CCRay.h", "cocos/3d/CCSkeleton3D.cpp", "cocos/3d/CCSkeleton3D.h", "cocos/3d/CCSprite3D.cpp", @@ -343,6 +345,8 @@ "cocos/base/CCIMEDispatcher.cpp", "cocos/base/CCIMEDispatcher.h", "cocos/base/CCMap.h", + "cocos/base/CCModuleManager.cpp", + "cocos/base/CCModuleManager.h", "cocos/base/CCNS.cpp", "cocos/base/CCNS.h", "cocos/base/CCPlatformConfig.h", From 6d214207553b41898d7a15198752062daa9e5664 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Aug 2014 16:05:12 +0800 Subject: [PATCH 42/42] [ci skip] --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index cb3e5c2993..c7a4200e53 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ cocos2d-x-3.3 ?? [NEW] Added submesh support, and support attaching a Sprite3D object to a bone [NEW] Added UIScale9Sprite - [NEW] Added Camera + [NEW] Added Camera, AABB, OBB and Ray [NEW] Added render primitive and render primitive command, support passing point, line and triangle data [NEW] Added support for applicationDidEnterBackground / applicationWillEnterForeground on desktop [NEW] EventMouse: support getDelta, getDeltaX, getDeltaY functions @@ -15,6 +15,7 @@ cocos2d-x-3.3 ?? [NEW] RotateTo: added 3D rotation support [NEW] ScrollView: added `setMinScale()` and `setMaxScale()` [NEW] Sprite3D: added setCullFace() and setCullFaceEnabled() + [NEW] Sprite3D: added getBoundingBox() and getAABB() [NEW] SpriteFrameCache: load from plist file content data [NEW] utils: added gettime() [NEW] ui::Button: support customize how much zoom scale is when pressing a button