Merge branch 'v3' of github.com:cocos2d/cocos2d-x into framework

This commit is contained in:
Bin Zhang 2015-06-17 18:14:33 +08:00
commit 264a4d104f
161 changed files with 6277 additions and 7296 deletions

View File

@ -818,18 +818,10 @@
15EFA212198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */; }; 15EFA212198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */; };
15EFA213198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; }; 15EFA213198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; };
15EFA214198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; }; 15EFA214198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; };
15FB206A1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20661AE7BE7400C31518 /* SpritePolygon.cpp */; }; 15FB20741AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */; };
15FB206B1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20661AE7BE7400C31518 /* SpritePolygon.cpp */; }; 15FB20751AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */; };
15FB206C1AE7BE7400C31518 /* SpritePolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20671AE7BE7400C31518 /* SpritePolygon.h */; }; 15FB20761AE7BF8600C31518 /* CCAutoPolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */; };
15FB206D1AE7BE7400C31518 /* SpritePolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20671AE7BE7400C31518 /* SpritePolygon.h */; }; 15FB20771AE7BF8600C31518 /* CCAutoPolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */; };
15FB206E1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20681AE7BE7400C31518 /* SpritePolygonCache.cpp */; };
15FB206F1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20681AE7BE7400C31518 /* SpritePolygonCache.cpp */; };
15FB20701AE7BE7400C31518 /* SpritePolygonCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20691AE7BE7400C31518 /* SpritePolygonCache.h */; };
15FB20711AE7BE7400C31518 /* SpritePolygonCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20691AE7BE7400C31518 /* SpritePolygonCache.h */; };
15FB20741AE7BF8600C31518 /* MarchingSquare.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* MarchingSquare.cpp */; };
15FB20751AE7BF8600C31518 /* MarchingSquare.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* MarchingSquare.cpp */; };
15FB20761AE7BF8600C31518 /* MarchingSquare.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* MarchingSquare.h */; };
15FB20771AE7BF8600C31518 /* MarchingSquare.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* MarchingSquare.h */; };
15FB20871AE7C57D00C31518 /* shapes.cc in Sources */ = {isa = PBXBuildFile; fileRef = 15FB207A1AE7C57D00C31518 /* shapes.cc */; }; 15FB20871AE7C57D00C31518 /* shapes.cc in Sources */ = {isa = PBXBuildFile; fileRef = 15FB207A1AE7C57D00C31518 /* shapes.cc */; };
15FB20881AE7C57D00C31518 /* shapes.cc in Sources */ = {isa = PBXBuildFile; fileRef = 15FB207A1AE7C57D00C31518 /* shapes.cc */; }; 15FB20881AE7C57D00C31518 /* shapes.cc in Sources */ = {isa = PBXBuildFile; fileRef = 15FB207A1AE7C57D00C31518 /* shapes.cc */; };
15FB20891AE7C57D00C31518 /* shapes.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB207B1AE7C57D00C31518 /* shapes.h */; }; 15FB20891AE7C57D00C31518 /* shapes.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB207B1AE7C57D00C31518 /* shapes.h */; };
@ -1848,6 +1840,10 @@
826294331AAF001C00CB7CF7 /* HttpAsynConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2A1A5349A3004E4C60 /* HttpAsynConnection.m */; }; 826294331AAF001C00CB7CF7 /* HttpAsynConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2A1A5349A3004E4C60 /* HttpAsynConnection.m */; };
826294341AAF003E00CB7CF7 /* HttpClient-apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2B1A5349A3004E4C60 /* HttpClient-apple.mm */; }; 826294341AAF003E00CB7CF7 /* HttpClient-apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2B1A5349A3004E4C60 /* HttpClient-apple.mm */; };
826294351AAF004C00CB7CF7 /* HttpCookie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2C1A5349A3004E4C60 /* HttpCookie.cpp */; }; 826294351AAF004C00CB7CF7 /* HttpCookie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2C1A5349A3004E4C60 /* HttpCookie.cpp */; };
8525E3A21B291E42008EE815 /* clipper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8525E3A11B291E42008EE815 /* clipper.hpp */; };
8525E3A31B291E42008EE815 /* clipper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8525E3A11B291E42008EE815 /* clipper.hpp */; };
85B3743A1B204B9400C488D6 /* clipper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85B374381B204B9400C488D6 /* clipper.cpp */; };
85B3743B1B204B9400C488D6 /* clipper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85B374381B204B9400C488D6 /* clipper.cpp */; };
A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; }; A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; };
B2165EEA19921124000BE3E6 /* CCPrimitiveCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B257B45E198A353E00D9A687 /* CCPrimitiveCommand.cpp */; }; B2165EEA19921124000BE3E6 /* CCPrimitiveCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B257B45E198A353E00D9A687 /* CCPrimitiveCommand.cpp */; };
B217703C1977ECB4009EE11B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703B1977ECB4009EE11B /* IOKit.framework */; }; B217703C1977ECB4009EE11B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703B1977ECB4009EE11B /* IOKit.framework */; };
@ -3669,12 +3665,8 @@
15B3707719EE414C00ABE682 /* Manifest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Manifest.h; sourceTree = "<group>"; }; 15B3707719EE414C00ABE682 /* Manifest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Manifest.h; sourceTree = "<group>"; };
15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProtectedNode.cpp; sourceTree = "<group>"; }; 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProtectedNode.cpp; sourceTree = "<group>"; };
15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtectedNode.h; sourceTree = "<group>"; }; 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtectedNode.h; sourceTree = "<group>"; };
15FB20661AE7BE7400C31518 /* SpritePolygon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpritePolygon.cpp; sourceTree = "<group>"; }; 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAutoPolygon.cpp; sourceTree = "<group>"; };
15FB20671AE7BE7400C31518 /* SpritePolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpritePolygon.h; sourceTree = "<group>"; }; 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAutoPolygon.h; sourceTree = "<group>"; };
15FB20681AE7BE7400C31518 /* SpritePolygonCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpritePolygonCache.cpp; sourceTree = "<group>"; };
15FB20691AE7BE7400C31518 /* SpritePolygonCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpritePolygonCache.h; sourceTree = "<group>"; };
15FB20721AE7BF8600C31518 /* MarchingSquare.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarchingSquare.cpp; sourceTree = "<group>"; };
15FB20731AE7BF8600C31518 /* MarchingSquare.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarchingSquare.h; sourceTree = "<group>"; };
15FB207A1AE7C57D00C31518 /* shapes.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shapes.cc; sourceTree = "<group>"; }; 15FB207A1AE7C57D00C31518 /* shapes.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shapes.cc; sourceTree = "<group>"; };
15FB207B1AE7C57D00C31518 /* shapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shapes.h; sourceTree = "<group>"; }; 15FB207B1AE7C57D00C31518 /* shapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shapes.h; sourceTree = "<group>"; };
15FB207C1AE7C57D00C31518 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = "<group>"; }; 15FB207C1AE7C57D00C31518 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = "<group>"; };
@ -4601,6 +4593,8 @@
5E9F61231A3FFE3D0038DE01 /* CCFrustum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFrustum.h; sourceTree = "<group>"; }; 5E9F61231A3FFE3D0038DE01 /* CCFrustum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFrustum.h; sourceTree = "<group>"; };
5E9F61241A3FFE3D0038DE01 /* CCPlane.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPlane.cpp; sourceTree = "<group>"; }; 5E9F61241A3FFE3D0038DE01 /* CCPlane.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPlane.cpp; sourceTree = "<group>"; };
5E9F61251A3FFE3D0038DE01 /* CCPlane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPlane.h; sourceTree = "<group>"; }; 5E9F61251A3FFE3D0038DE01 /* CCPlane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPlane.h; sourceTree = "<group>"; };
8525E3A11B291E42008EE815 /* clipper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = clipper.hpp; sourceTree = "<group>"; };
85B374381B204B9400C488D6 /* clipper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clipper.cpp; sourceTree = "<group>"; };
A07A4D641783777C0073F6A7 /* libcocos2d iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2d iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; A07A4D641783777C0073F6A7 /* libcocos2d iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2d iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
B20564AA1A6E5744001C1B6E /* ccShader_PositionColorTextureAsPointsize.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionColorTextureAsPointsize.vert; sourceTree = "<group>"; }; B20564AA1A6E5744001C1B6E /* ccShader_PositionColorTextureAsPointsize.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionColorTextureAsPointsize.vert; sourceTree = "<group>"; };
B217703B1977ECB4009EE11B /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; B217703B1977ECB4009EE11B /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
@ -6023,12 +6017,8 @@
1A570275180BCC840088DEC7 /* sprite-nodes */ = { 1A570275180BCC840088DEC7 /* sprite-nodes */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
15FB20721AE7BF8600C31518 /* MarchingSquare.cpp */, 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */,
15FB20731AE7BF8600C31518 /* MarchingSquare.h */, 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */,
15FB20661AE7BE7400C31518 /* SpritePolygon.cpp */,
15FB20671AE7BE7400C31518 /* SpritePolygon.h */,
15FB20681AE7BE7400C31518 /* SpritePolygonCache.cpp */,
15FB20691AE7BE7400C31518 /* SpritePolygonCache.h */,
1A57028E180BCCAB0088DEC7 /* CCAnimation.cpp */, 1A57028E180BCCAB0088DEC7 /* CCAnimation.cpp */,
1A57028F180BCCAB0088DEC7 /* CCAnimation.h */, 1A57028F180BCCAB0088DEC7 /* CCAnimation.h */,
1A570290180BCCAB0088DEC7 /* CCAnimationCache.cpp */, 1A570290180BCCAB0088DEC7 /* CCAnimationCache.cpp */,
@ -6091,6 +6081,7 @@
1A57033E180BD0490088DEC7 /* external */ = { 1A57033E180BD0490088DEC7 /* external */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
68B39B391B1C5C670084F72C /* clipper */,
B6DD2F731B04820C00E47F5F /* recast */, B6DD2F731B04820C00E47F5F /* recast */,
B6CAB0021AF9A9EE00B9B856 /* bullet */, B6CAB0021AF9A9EE00B9B856 /* bullet */,
15FB20781AE7C57D00C31518 /* poly2tri */, 15FB20781AE7C57D00C31518 /* poly2tri */,
@ -7719,6 +7710,16 @@
path = TextReader; path = TextReader;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
68B39B391B1C5C670084F72C /* clipper */ = {
isa = PBXGroup;
children = (
8525E3A11B291E42008EE815 /* clipper.hpp */,
85B374381B204B9400C488D6 /* clipper.cpp */,
);
name = clipper;
path = ../external/clipper;
sourceTree = "<group>";
};
B29594B81926D61F003EEF37 /* 3d */ = { B29594B81926D61F003EEF37 /* 3d */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -8910,7 +8911,7 @@
3E2F27A719CFBFE400E7C490 /* AudioEngine.h in Headers */, 3E2F27A719CFBFE400E7C490 /* AudioEngine.h in Headers */,
15AE183A19AAD2F700C27E9E /* CCRay.h in Headers */, 15AE183A19AAD2F700C27E9E /* CCRay.h in Headers */,
15AE18A319AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */, 15AE18A319AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */,
15FB20761AE7BF8600C31518 /* MarchingSquare.h in Headers */, 15FB20761AE7BF8600C31518 /* CCAutoPolygon.h in Headers */,
B665E2C41AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.h in Headers */, B665E2C41AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.h in Headers */,
46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */,
15AE199D19AAD39600C27E9E /* ScrollViewReader.h in Headers */, 15AE199D19AAD39600C27E9E /* ScrollViewReader.h in Headers */,
@ -9157,7 +9158,6 @@
15AE1A3319AAD3D500C27E9E /* b2CircleShape.h in Headers */, 15AE1A3319AAD3D500C27E9E /* b2CircleShape.h in Headers */,
1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */,
1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */, 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */,
15FB20701AE7BE7400C31518 /* SpritePolygonCache.h in Headers */,
B6CAB2C11AF9AA1A00B9B856 /* btEmptyShape.h in Headers */, B6CAB2C11AF9AA1A00B9B856 /* btEmptyShape.h in Headers */,
B665E3D81AA80A6600DDB1C5 /* CCPUScriptParser.h in Headers */, B665E3D81AA80A6600DDB1C5 /* CCPUScriptParser.h in Headers */,
382384091A25900F002C4610 /* FlatBuffersSerialize.h in Headers */, 382384091A25900F002C4610 /* FlatBuffersSerialize.h in Headers */,
@ -9512,6 +9512,7 @@
15AE183219AAD2F700C27E9E /* CCOBB.h in Headers */, 15AE183219AAD2F700C27E9E /* CCOBB.h in Headers */,
15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */, 15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */,
B665E2941AA80A6500DDB1C5 /* CCPUEmitter.h in Headers */, B665E2941AA80A6500DDB1C5 /* CCPUEmitter.h in Headers */,
8525E3A21B291E42008EE815 /* clipper.hpp in Headers */,
15FB209D1AE7C57D00C31518 /* sweep_context.h in Headers */, 15FB209D1AE7C57D00C31518 /* sweep_context.h in Headers */,
50CB247519D9C5A100687767 /* AudioCache.h in Headers */, 50CB247519D9C5A100687767 /* AudioCache.h in Headers */,
3823841C1A2590D2002C4610 /* ComAudioReader.h in Headers */, 3823841C1A2590D2002C4610 /* ComAudioReader.h in Headers */,
@ -9667,7 +9668,6 @@
B6CAB2D31AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */, B6CAB2D31AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */,
B665E1F41AA80A6500DDB1C5 /* CCPUAffector.h in Headers */, B665E1F41AA80A6500DDB1C5 /* CCPUAffector.h in Headers */,
1A01C69E18F57BE800EFE3A6 /* CCString.h in Headers */, 1A01C69E18F57BE800EFE3A6 /* CCString.h in Headers */,
15FB206C1AE7BE7400C31518 /* SpritePolygon.h in Headers */,
50ABC00F1926664800A911A9 /* CCFileUtils.h in Headers */, 50ABC00F1926664800A911A9 /* CCFileUtils.h in Headers */,
B665E2981AA80A6500DDB1C5 /* CCPUEmitterManager.h in Headers */, B665E2981AA80A6500DDB1C5 /* CCPUEmitterManager.h in Headers */,
15AE1A3719AAD3D500C27E9E /* b2PolygonShape.h in Headers */, 15AE1A3719AAD3D500C27E9E /* b2PolygonShape.h in Headers */,
@ -9945,7 +9945,6 @@
B665E2451AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffector.h in Headers */, B665E2451AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffector.h in Headers */,
B6CAB3381AF9AA1A00B9B856 /* btQuantization.h in Headers */, B6CAB3381AF9AA1A00B9B856 /* btQuantization.h in Headers */,
50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */, 50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */,
15FB20711AE7BE7400C31518 /* SpritePolygonCache.h in Headers */,
50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */, 50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */,
15AE1AD719AAD40300C27E9E /* b2WheelJoint.h in Headers */, 15AE1AD719AAD40300C27E9E /* b2WheelJoint.h in Headers */,
B665E3311AA80A6500DDB1C5 /* CCPUOnCountObserverTranslator.h in Headers */, B665E3311AA80A6500DDB1C5 /* CCPUOnCountObserverTranslator.h in Headers */,
@ -10143,6 +10142,7 @@
B665E2AD1AA80A6500DDB1C5 /* CCPUFlockCenteringAffector.h in Headers */, B665E2AD1AA80A6500DDB1C5 /* CCPUFlockCenteringAffector.h in Headers */,
15AE196B19AAD35100C27E9E /* DictionaryHelper.h in Headers */, 15AE196B19AAD35100C27E9E /* DictionaryHelper.h in Headers */,
B6CAB4C21AF9AA1A00B9B856 /* SpuLibspe2Support.h in Headers */, B6CAB4C21AF9AA1A00B9B856 /* SpuLibspe2Support.h in Headers */,
8525E3A31B291E42008EE815 /* clipper.hpp in Headers */,
B6CAB5021AF9AA1A00B9B856 /* btConvexHullComputer.h in Headers */, B6CAB5021AF9AA1A00B9B856 /* btConvexHullComputer.h in Headers */,
B665E2411AA80A6500DDB1C5 /* CCPUCircleEmitterTranslator.h in Headers */, B665E2411AA80A6500DDB1C5 /* CCPUCircleEmitterTranslator.h in Headers */,
B6CAB2BA1AF9AA1A00B9B856 /* btConvexTriangleMeshShape.h in Headers */, B6CAB2BA1AF9AA1A00B9B856 /* btConvexTriangleMeshShape.h in Headers */,
@ -10395,13 +10395,12 @@
B6DD2FE01B04825B00E47F5F /* DetourObstacleAvoidance.h in Headers */, B6DD2FE01B04825B00E47F5F /* DetourObstacleAvoidance.h in Headers */,
B6CAB5081AF9AA1A00B9B856 /* btGeometryUtil.h in Headers */, B6CAB5081AF9AA1A00B9B856 /* btGeometryUtil.h in Headers */,
1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */, 1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */,
15FB20771AE7BF8600C31518 /* MarchingSquare.h in Headers */, 15FB20771AE7BF8600C31518 /* CCAutoPolygon.h in Headers */,
B6CAB4F81AF9AA1A00B9B856 /* btAlignedAllocator.h in Headers */, B6CAB4F81AF9AA1A00B9B856 /* btAlignedAllocator.h in Headers */,
15AE18AE19AAD33D00C27E9E /* CCBFileLoader.h in Headers */, 15AE18AE19AAD33D00C27E9E /* CCBFileLoader.h in Headers */,
B6CAB2D41AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */, B6CAB2D41AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */,
15AE197819AAD35700C27E9E /* CCActionTimeline.h in Headers */, 15AE197819AAD35700C27E9E /* CCActionTimeline.h in Headers */,
B6CAAFF11AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h in Headers */, B6CAAFF11AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h in Headers */,
15FB206D1AE7BE7400C31518 /* SpritePolygon.h in Headers */,
15AE1AA019AAD40300C27E9E /* b2Timer.h in Headers */, 15AE1AA019AAD40300C27E9E /* b2Timer.h in Headers */,
5034CA44191D591100CE6051 /* ccShader_Label.vert in Headers */, 5034CA44191D591100CE6051 /* ccShader_Label.vert in Headers */,
1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, 1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */,
@ -11113,6 +11112,7 @@
B6CAB4C51AF9AA1A00B9B856 /* boxBoxDistance.cpp in Sources */, B6CAB4C51AF9AA1A00B9B856 /* boxBoxDistance.cpp in Sources */,
B6CAB29F1AF9AA1A00B9B856 /* btConvex2dShape.cpp in Sources */, B6CAB29F1AF9AA1A00B9B856 /* btConvex2dShape.cpp in Sources */,
B6CAB4331AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */, B6CAB4331AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */,
85B3743A1B204B9400C488D6 /* clipper.cpp in Sources */,
15AE1A8819AAD40300C27E9E /* b2PrismaticJoint.cpp in Sources */, 15AE1A8819AAD40300C27E9E /* b2PrismaticJoint.cpp in Sources */,
182C5CB21A95964700C30D34 /* Node3DReader.cpp in Sources */, 182C5CB21A95964700C30D34 /* Node3DReader.cpp in Sources */,
50ABBE491925AB6F00A911A9 /* CCEventAcceleration.cpp in Sources */, 50ABBE491925AB6F00A911A9 /* CCEventAcceleration.cpp in Sources */,
@ -11250,7 +11250,6 @@
50ABC0191926664800A911A9 /* CCSAXParser.cpp in Sources */, 50ABC0191926664800A911A9 /* CCSAXParser.cpp in Sources */,
15AE189219AAD33D00C27E9E /* CCLayerGradientLoader.cpp in Sources */, 15AE189219AAD33D00C27E9E /* CCLayerGradientLoader.cpp in Sources */,
B6CAB4471AF9AA1A00B9B856 /* btThreadSupportInterface.cpp in Sources */, B6CAB4471AF9AA1A00B9B856 /* btThreadSupportInterface.cpp in Sources */,
15FB206E1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */,
15AE1B6A19AADA9900C27E9E /* UIDeprecated.cpp in Sources */, 15AE1B6A19AADA9900C27E9E /* UIDeprecated.cpp in Sources */,
15AE183C19AAD2F700C27E9E /* CCSkeleton3D.cpp in Sources */, 15AE183C19AAD2F700C27E9E /* CCSkeleton3D.cpp in Sources */,
B6CAB36F1AF9AA1A00B9B856 /* btGjkConvexCast.cpp in Sources */, B6CAB36F1AF9AA1A00B9B856 /* btGjkConvexCast.cpp in Sources */,
@ -11366,7 +11365,7 @@
15AE199A19AAD39600C27E9E /* PageViewReader.cpp in Sources */, 15AE199A19AAD39600C27E9E /* PageViewReader.cpp in Sources */,
1A57030C180BCF190088DEC7 /* CCComponent.cpp in Sources */, 1A57030C180BCF190088DEC7 /* CCComponent.cpp in Sources */,
382383F61A258FA7002C4610 /* idl_gen_fbs.cpp in Sources */, 382383F61A258FA7002C4610 /* idl_gen_fbs.cpp in Sources */,
15FB20741AE7BF8600C31518 /* MarchingSquare.cpp in Sources */, 15FB20741AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */,
B665E2A61AA80A6500DDB1C5 /* CCPUEventHandlerTranslator.cpp in Sources */, B665E2A61AA80A6500DDB1C5 /* CCPUEventHandlerTranslator.cpp in Sources */,
15AE1A5919AAD40300C27E9E /* b2StackAllocator.cpp in Sources */, 15AE1A5919AAD40300C27E9E /* b2StackAllocator.cpp in Sources */,
B6CAB20B1AF9AA1A00B9B856 /* btQuantizedBvh.cpp in Sources */, B6CAB20B1AF9AA1A00B9B856 /* btQuantizedBvh.cpp in Sources */,
@ -11390,7 +11389,6 @@
B665E2721AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.cpp in Sources */, B665E2721AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.cpp in Sources */,
50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */, 50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */,
B6CAB3C31AF9AA1A00B9B856 /* btHingeConstraint.cpp in Sources */, B6CAB3C31AF9AA1A00B9B856 /* btHingeConstraint.cpp in Sources */,
15FB206A1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */,
B29A7DDD19EE1B7700872B35 /* BoneData.c in Sources */, B29A7DDD19EE1B7700872B35 /* BoneData.c in Sources */,
15AE188A19AAD33D00C27E9E /* CCControlLoader.cpp in Sources */, 15AE188A19AAD33D00C27E9E /* CCControlLoader.cpp in Sources */,
5012168E1AC47380009A4BEA /* CCRenderState.cpp in Sources */, 5012168E1AC47380009A4BEA /* CCRenderState.cpp in Sources */,
@ -11990,8 +11988,8 @@
15AE18AB19AAD33D00C27E9E /* CCBAnimationManager.cpp in Sources */, 15AE18AB19AAD33D00C27E9E /* CCBAnimationManager.cpp in Sources */,
15AE1B7219AADA9A00C27E9E /* UIListView.cpp in Sources */, 15AE1B7219AADA9A00C27E9E /* UIListView.cpp in Sources */,
1A5701BE180BCB5A0088DEC7 /* CCLabelAtlas.cpp in Sources */, 1A5701BE180BCB5A0088DEC7 /* CCLabelAtlas.cpp in Sources */,
15FB20751AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */,
B6CAB2021AF9AA1A00B9B856 /* btMultiSapBroadphase.cpp in Sources */, B6CAB2021AF9AA1A00B9B856 /* btMultiSapBroadphase.cpp in Sources */,
15FB20751AE7BF8600C31518 /* MarchingSquare.cpp in Sources */,
15AE1A3D19AAD3D500C27E9E /* b2CollideEdge.cpp in Sources */, 15AE1A3D19AAD3D500C27E9E /* b2CollideEdge.cpp in Sources */,
1A5701C2180BCB5A0088DEC7 /* CCLabelBMFont.cpp in Sources */, 1A5701C2180BCB5A0088DEC7 /* CCLabelBMFont.cpp in Sources */,
1A087AE91860400400196EF5 /* edtaa3func.cpp in Sources */, 1A087AE91860400400196EF5 /* edtaa3func.cpp in Sources */,
@ -12280,7 +12278,6 @@
B6CAB2AC1AF9AA1A00B9B856 /* btConvexPointCloudShape.cpp in Sources */, B6CAB2AC1AF9AA1A00B9B856 /* btConvexPointCloudShape.cpp in Sources */,
B6CAB22C1AF9AA1A00B9B856 /* btCollisionObject.cpp in Sources */, B6CAB22C1AF9AA1A00B9B856 /* btCollisionObject.cpp in Sources */,
15AE183919AAD2F700C27E9E /* CCRay.cpp in Sources */, 15AE183919AAD2F700C27E9E /* CCRay.cpp in Sources */,
15FB206B1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */,
15AE1B8219AADA9A00C27E9E /* UITextBMFont.cpp in Sources */, 15AE1B8219AADA9A00C27E9E /* UITextBMFont.cpp in Sources */,
B6CAB29C1AF9AA1A00B9B856 /* btConeShape.cpp in Sources */, B6CAB29C1AF9AA1A00B9B856 /* btConeShape.cpp in Sources */,
50ABBE6A1925AB6F00A911A9 /* CCEventListenerFocus.cpp in Sources */, 50ABBE6A1925AB6F00A911A9 /* CCEventListenerFocus.cpp in Sources */,
@ -12357,7 +12354,6 @@
B665E29F1AA80A6500DDB1C5 /* CCPUEventHandler.cpp in Sources */, B665E29F1AA80A6500DDB1C5 /* CCPUEventHandler.cpp in Sources */,
15AE195519AAD35100C27E9E /* CCDisplayManager.cpp in Sources */, 15AE195519AAD35100C27E9E /* CCDisplayManager.cpp in Sources */,
B665E43B1AA80A6600DDB1C5 /* CCPUVortexAffectorTranslator.cpp in Sources */, B665E43B1AA80A6600DDB1C5 /* CCPUVortexAffectorTranslator.cpp in Sources */,
15FB206F1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */,
15AE1BA719AADFDF00C27E9E /* UIRelativeBox.cpp in Sources */, 15AE1BA719AADFDF00C27E9E /* UIRelativeBox.cpp in Sources */,
15AE1ACE19AAD40300C27E9E /* b2PulleyJoint.cpp in Sources */, 15AE1ACE19AAD40300C27E9E /* b2PulleyJoint.cpp in Sources */,
B665E2DF1AA80A6500DDB1C5 /* CCPULineAffector.cpp in Sources */, B665E2DF1AA80A6500DDB1C5 /* CCPULineAffector.cpp in Sources */,
@ -12373,6 +12369,7 @@
B665E3131AA80A6500DDB1C5 /* CCPUObserverManager.cpp in Sources */, B665E3131AA80A6500DDB1C5 /* CCPUObserverManager.cpp in Sources */,
50CB248019D9C5A100687767 /* AudioPlayer.mm in Sources */, 50CB248019D9C5A100687767 /* AudioPlayer.mm in Sources */,
50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */, 50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */,
85B3743B1B204B9400C488D6 /* clipper.cpp in Sources */,
15AE18BF19AAD33D00C27E9E /* CCLabelTTFLoader.cpp in Sources */, 15AE18BF19AAD33D00C27E9E /* CCLabelTTFLoader.cpp in Sources */,
B6CAB27E1AF9AA1A00B9B856 /* btBox2dShape.cpp in Sources */, B6CAB27E1AF9AA1A00B9B856 /* btBox2dShape.cpp in Sources */,
15AE1B9519AADA9A00C27E9E /* CocosGUI.cpp in Sources */, 15AE1B9519AADA9A00C27E9E /* CocosGUI.cpp in Sources */,

View File

@ -5925,6 +5925,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "../tests/cpp-tests/proj.ios/Prefix.pch"; GCC_PREFIX_HEADER = "../tests/cpp-tests/proj.ios/Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
@ -5938,6 +5939,7 @@
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../external/curl/prebuilt/ios", "$(SRCROOT)/../external/curl/prebuilt/ios",
); );
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";
@ -5949,6 +5951,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "../tests/cpp-tests/proj.ios/Prefix.pch"; GCC_PREFIX_HEADER = "../tests/cpp-tests/proj.ios/Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
@ -5962,6 +5965,7 @@
"$(inherited)", "$(inherited)",
"$(SRCROOT)/../external/curl/prebuilt/ios", "$(SRCROOT)/../external/curl/prebuilt/ios",
); );
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios";

669
cocos/2d/CCAutoPolygon.cpp Normal file
View File

@ -0,0 +1,669 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCAutoPolygon.h"
#include "poly2tri/poly2tri.h"
#include "base/CCDirector.h"
#include "renderer/CCTextureCache.h"
#include "clipper/clipper.hpp"
#include <algorithm>
#include <math.h>
USING_NS_CC;
static unsigned short quadIndices[]={0,1,2, 3,2,1};
const static float PRECISION = 10.0f;
PolygonInfo::PolygonInfo(const PolygonInfo& other):
triangles(),
isVertsOwner(true),
rect()
{
filename = other.filename;
isVertsOwner = other.isVertsOwner;
rect = other.rect;
triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount];
triangles.indices = new unsigned short[other.triangles.indexCount];
triangles.vertCount = other.triangles.vertCount;
triangles.indexCount = other.triangles.indexCount;
memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F));
memcpy(triangles.indices, other.triangles.indices, other.triangles.indexCount*sizeof(unsigned short));
};
PolygonInfo& PolygonInfo::operator= (const PolygonInfo& other)
{
if(this != &other)
{
releaseVertsAndIndices();
filename = other.filename;
isVertsOwner = other.isVertsOwner;
rect = other.rect;
triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount];
triangles.indices = new unsigned short[other.triangles.indexCount];
triangles.vertCount = other.triangles.vertCount;
triangles.indexCount = other.triangles.indexCount;
memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F));
memcpy(triangles.indices, other.triangles.indices, other.triangles.indexCount*sizeof(unsigned short));
}
return *this;
}
PolygonInfo::~PolygonInfo()
{
releaseVertsAndIndices();
}
void PolygonInfo::setQuad(V3F_C4B_T2F_Quad *quad)
{
releaseVertsAndIndices();
isVertsOwner = false;
triangles.indices = quadIndices;
triangles.vertCount = 4;
triangles.indexCount = 6;
triangles.verts = (V3F_C4B_T2F*)quad;
}
void PolygonInfo::releaseVertsAndIndices()
{
if(isVertsOwner)
{
if(nullptr != triangles.verts)
{
CC_SAFE_DELETE_ARRAY(triangles.verts);
}
if(nullptr != triangles.indices)
{
CC_SAFE_DELETE_ARRAY(triangles.indices);
}
}
}
const unsigned int PolygonInfo::getVertCount() const
{
return (unsigned int)triangles.vertCount;
}
const unsigned int PolygonInfo::getTriaglesCount() const
{
return (unsigned int)triangles.indexCount/3;
}
const float PolygonInfo::getArea() const
{
float area = 0;
V3F_C4B_T2F *verts = triangles.verts;
unsigned short *indices = triangles.indices;
for(int i = 0; i < triangles.indexCount; i+=3)
{
auto A = verts[indices[i]].vertices;
auto B = verts[indices[i+1]].vertices;
auto C = verts[indices[i+2]].vertices;
area += (A.x*(B.y-C.y) + B.x*(C.y-A.y) + C.x*(A.y - B.y))/2;
}
return area;
}
AutoPolygon::AutoPolygon(const std::string &filename)
:_image(nullptr)
,_data(nullptr)
,_filename("")
,_width(0)
,_height(0)
,_scaleFactor(0)
{
_filename = filename;
_image = new Image();
_image->initWithImageFile(filename);
CCASSERT(_image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888, "unsupported format, currently only supports rgba8888");
_data = _image->getData();
_width = _image->getWidth();
_height = _image->getHeight();
_scaleFactor = Director::getInstance()->getContentScaleFactor();
}
AutoPolygon::~AutoPolygon()
{
CC_SAFE_DELETE(_image);
}
std::vector<Vec2> AutoPolygon::trace(const Rect& rect, const float& threshold)
{
Vec2 first = findFirstNoneTransparentPixel(rect, threshold);
return marchSquare(rect, first, threshold);
}
Vec2 AutoPolygon::findFirstNoneTransparentPixel(const Rect& rect, const float& threshold)
{
bool found = false;
Vec2 i;
for(i.y = rect.origin.y; i.y < rect.origin.y+rect.size.height; i.y++)
{
if(found)break;
for(i.x = rect.origin.x; i.x < rect.origin.x+rect.size.width; i.x++)
{
auto alpha = getAlphaByPos(i);
if(alpha>threshold)
{
found = true;
break;
}
}
}
CCASSERT(found, "image is all transparent!");
return i;
}
unsigned char AutoPolygon::getAlphaByIndex(const unsigned int& i)
{
return *(_data+i*4+3);
}
unsigned char AutoPolygon::getAlphaByPos(const Vec2& pos)
{
return *(_data+((int)pos.y*_width+(int)pos.x)*4+3);
}
unsigned int AutoPolygon::getSquareValue(const unsigned int& x, const unsigned int& y, const Rect& rect, const float& threshold)
{
/*
checking the 2x2 pixel grid, assigning these values to each pixel, if not transparent
+---+---+
| 1 | 2 |
+---+---+
| 4 | 8 | <- current pixel (curx,cury)
+---+---+
*/
unsigned int sv = 0;
//NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel
auto fixedRect = Rect(rect.origin, rect.size-Size(2,2));
Vec2 tl = Vec2(x-1, y-1);
sv += (fixedRect.containsPoint(tl) && getAlphaByPos(tl) > threshold)? 1 : 0;
Vec2 tr = Vec2(x, y-1);
sv += (fixedRect.containsPoint(tr) && getAlphaByPos(tr) > threshold)? 2 : 0;
Vec2 bl = Vec2(x-1, y);
sv += (fixedRect.containsPoint(bl) && getAlphaByPos(bl) > threshold)? 4 : 0;
Vec2 br = Vec2(x, y);
sv += (fixedRect.containsPoint(br) && getAlphaByPos(br) > threshold)? 8 : 0;
CCASSERT(sv != 0 && sv != 15, "square value should not be 0, or 15");
return sv;
}
std::vector<cocos2d::Vec2> AutoPolygon::marchSquare(const Rect& rect, const Vec2& start, const float& threshold)
{
int stepx = 0;
int stepy = 0;
int prevx = 0;
int prevy = 0;
int startx = start.x;
int starty = start.y;
int curx = startx;
int cury = starty;
unsigned int count = 0;
unsigned int totalPixel = _width*_height;
bool problem = false;
std::vector<int> case9s;
std::vector<int> case6s;
int i;
std::vector<int>::iterator it;
std::vector<cocos2d::Vec2> _points;
do{
int sv = getSquareValue(curx, cury, rect, threshold);
switch(sv){
case 1:
case 5:
case 13:
/* going UP with these cases:
1 5 13
+---+---+ +---+---+ +---+---+
| 1 | | | 1 | | | 1 | |
+---+---+ +---+---+ +---+---+
| | | | 4 | | | 4 | 8 |
+---+---+ +---+---+ +---+---+
*/
stepx = 0;
stepy = -1;
break;
case 8:
case 10:
case 11:
/* going DOWN with these cases:
8 10 11
+---+---+ +---+---+ +---+---+
| | | | | 2 | | 1 | 2 |
+---+---+ +---+---+ +---+---+
| | 8 | | | 8 | | | 8 |
+---+---+ +---+---+ +---+---+
*/
stepx = 0;
stepy = 1;
break;
case 4:
case 12:
case 14:
/* going LEFT with these cases:
4 12 14
+---+---+ +---+---+ +---+---+
| | | | | | | | 2 |
+---+---+ +---+---+ +---+---+
| 4 | | | 4 | 8 | | 4 | 8 |
+---+---+ +---+---+ +---+---+
*/
stepx = -1;
stepy = 0;
break;
case 2 :
case 3 :
case 7 :
/* going RIGHT with these cases:
2 3 7
+---+---+ +---+---+ +---+---+
| | 2 | | 1 | 2 | | 1 | 2 |
+---+---+ +---+---+ +---+---+
| | | | | | | 4 | |
+---+---+ +---+---+ +---+---+
*/
stepx=1;
stepy=0;
break;
case 9 :
/*
+---+---+
| 1 | |
+---+---+
| | 8 |
+---+---+
this should normaly go UP, but if we already been here, we go down
*/
//find index from xy;
i = getIndexFromPos(curx, cury);
it = find (case9s.begin(), case9s.end(), i);
if (it != case9s.end())
{
//found, so we go down, and delete from case9s;
stepx = 0;
stepy = 1;
case9s.erase(it);
problem = true;
}
else
{
//not found, we go up, and add to case9s;
stepx = 0;
stepy = -1;
case9s.push_back(i);
}
break;
case 6 :
/*
6
+---+---+
| | 2 |
+---+---+
| 4 | |
+---+---+
this normally go RIGHT, but if its coming from UP, it should go LEFT
*/
i = getIndexFromPos(curx, cury);
it = find (case6s.begin(), case6s.end(), i);
if (it != case6s.end())
{
//found, so we go down, and delete from case9s;
stepx = -1;
stepy = 0;
case6s.erase(it);
problem = true;
}
else{
//not found, we go up, and add to case9s;
stepx = 1;
stepy = 0;
case6s.push_back(i);
}
break;
default:
CCLOG("this shouldn't happen.");
}
//little optimization
// if previous direction is same as current direction,
// then we should modify the last vec to current
curx += stepx;
cury += stepy;
if(stepx == prevx && stepy == prevy)
{
_points.back().x = (float)(curx-rect.origin.x) / _scaleFactor;
_points.back().y = (float)(rect.size.height - cury + rect.origin.y) / _scaleFactor;
}
else if(problem)
{
//TODO: we triangulation cannot work collineer points, so we need to modify same point a little
//TODO: maybe we can detect if we go into a hole and coming back the hole, we should extract those points and remove them
_points.push_back(Vec2((float)(curx- rect.origin.x) / _scaleFactor, (float)(rect.size.height - cury + rect.origin.y) / _scaleFactor));
}
else{
_points.push_back(Vec2((float)(curx-rect.origin.x) / _scaleFactor, (float)(rect.size.height - cury + rect.origin.y) / _scaleFactor));
}
count++;
prevx = stepx;
prevy = stepy;
problem = false;
CCASSERT(count <= totalPixel, "oh no, marching square cannot find starting position");
} while(curx != startx || cury != starty);
return _points;
}
float AutoPolygon::perpendicularDistance(const cocos2d::Vec2& i, const cocos2d::Vec2& start, const cocos2d::Vec2& end)
{
float res;
float slope;
float intercept;
if(start.x == end.x)
{
res = fabsf(i.x- end.x);
}
else if (start.y == end.y)
{
res = fabsf(i.y - end.y);
}
else{
slope = (end.y - start.y) / (end.x - start.x);
intercept = start.y - (slope*start.x);
res = fabsf(slope * i.x - i.y + intercept) / sqrtf(powf(slope, 2)+1);
}
return res;
}
std::vector<cocos2d::Vec2> AutoPolygon::rdp(std::vector<cocos2d::Vec2> v, const float& optimization)
{
if(v.size() < 3)
return v;
int index = -1;
float dist = 0;
//not looping first and last point
for(size_t i = 1; i < v.size()-1; i++)
{
float cdist = perpendicularDistance(v[i], v.front(), v.back());
if(cdist > dist)
{
dist = cdist;
index = i;
}
}
if (dist>optimization)
{
std::vector<Vec2>::const_iterator begin = v.begin();
std::vector<Vec2>::const_iterator end = v.end();
std::vector<Vec2> l1(begin, begin+index+1);
std::vector<Vec2> l2(begin+index, end);
std::vector<Vec2> r1 = rdp(l1, optimization);
std::vector<Vec2> r2 = rdp(l2, optimization);
r1.insert(r1.end(), r2.begin()+1, r2.end());
return r1;
}
else {
std::vector<Vec2> ret;
ret.push_back(v.front());
ret.push_back(v.back());
return ret;
}
}
std::vector<Vec2> AutoPolygon::reduce(const std::vector<Vec2>& points, const Rect& rect , const float& epsilon)
{
auto size = points.size();
// if there are less than 3 points, then we have nothing
if(size<3)
{
log("AUTOPOLYGON: cannot reduce points for %s that has less than 3 points in input, e: %f", _filename.c_str(), epsilon);
return std::vector<Vec2>();
}
// if there are less than 9 points (but more than 3), then we don't need to reduce it
else if (size < 9)
{
log("AUTOPOLYGON: cannot reduce points for %s e: %f",_filename.c_str(), epsilon);
return points;
}
float maxEp = MIN(rect.size.width, rect.size.height);
float ep = clampf(epsilon, 0.0, maxEp/_scaleFactor/2);
std::vector<Vec2> result = rdp(points, ep);
auto last = result.back();
if(last.y > result.front().y && last.getDistance(result.front()) < ep*0.5)
{
result.front().y = last.y;
result.pop_back();
}
return result;
}
std::vector<Vec2> AutoPolygon::expand(const std::vector<Vec2>& points, const cocos2d::Rect &rect, const float& epsilon)
{
auto size = points.size();
// if there are less than 3 points, then we have nothig
if(size<3)
{
log("AUTOPOLYGON: cannot expand points for %s with less than 3 points, e: %f", _filename.c_str(), epsilon);
return std::vector<Vec2>();
}
ClipperLib::Path subj;
ClipperLib::PolyTree solution;
ClipperLib::PolyTree out;
for(std::vector<Vec2>::const_iterator it = points.begin(); it<points.end(); it++)
{
subj << ClipperLib::IntPoint(it-> x* PRECISION, it->y * PRECISION);
}
ClipperLib::ClipperOffset co;
co.AddPath(subj, ClipperLib::jtMiter, ClipperLib::etClosedPolygon);
co.Execute(solution, epsilon * PRECISION);
ClipperLib::PolyNode* p = solution.GetFirst();
if(!p)
{
log("AUTOPOLYGON: Clipper failed to expand the points");
return points;
}
while(p->IsHole()){
p = p->GetNext();
}
//turn the result into simply polygon (AKA, fix overlap)
//clamp into the specified rect
ClipperLib::Clipper cl;
cl.StrictlySimple(true);
cl.AddPath(p->Contour, ClipperLib::ptSubject, true);
//create the clipping rect
ClipperLib::Path clamp;
clamp.push_back(ClipperLib::IntPoint(0, 0));
clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, 0));
clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, rect.size.height/_scaleFactor * PRECISION));
clamp.push_back(ClipperLib::IntPoint(0, rect.size.height/_scaleFactor * PRECISION));
cl.AddPath(clamp, ClipperLib::ptClip, true);
cl.Execute(ClipperLib::ctIntersection, out);
std::vector<Vec2> outPoints;
ClipperLib::PolyNode* p2 = out.GetFirst();
while(p2->IsHole()){
p2 = p2->GetNext();
}
auto end = p2->Contour.end();
for(std::vector<ClipperLib::IntPoint>::const_iterator pt = p2->Contour.begin(); pt < end; pt++)
{
outPoints.push_back(Vec2(pt->X/PRECISION, pt->Y/PRECISION));
}
return outPoints;
}
TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& points)
{
// if there are less than 3 points, then we can't triangulate
if(points.size()<3)
{
log("AUTOPOLYGON: cannot triangulate %s with less than 3 points", _filename.c_str());
return TrianglesCommand::Triangles();
}
std::vector<p2t::Point*> p2points;
for(std::vector<Vec2>::const_iterator it = points.begin(); it<points.end(); it++)
{
p2t::Point * p = new p2t::Point(it->x, it->y);
p2points.push_back(p);
}
p2t::CDT cdt(p2points);
cdt.Triangulate();
std::vector<p2t::Triangle*> tris = cdt.GetTriangles();
V3F_C4B_T2F* verts= new V3F_C4B_T2F[points.size()];
unsigned short* indices = new unsigned short[tris.size()*3];
unsigned short idx = 0;
unsigned short vdx = 0;
for(std::vector<p2t::Triangle*>::const_iterator ite = tris.begin(); ite < tris.end(); ite++)
{
for(int i = 0; i < 3; i++)
{
auto p = (*ite)->GetPoint(i);
auto v3 = Vec3(p->x, p->y, 0);
bool found = false;
size_t j;
size_t length = vdx;
for(j = 0; j < length; j++)
{
if(verts[j].vertices == v3)
{
found = true;
break;
}
}
if(found)
{
//if we found the same vertice, don't add to verts, but use the same vert with indices
indices[idx] = j;
idx++;
}
else
{
//vert does not exist yet, so we need to create a new one,
auto c4b = Color4B::WHITE;
auto t2f = Tex2F(0,0); // don't worry about tex coords now, we calculate that later
V3F_C4B_T2F vert = {v3,c4b,t2f};
verts[vdx] = vert;
indices[idx] = vdx;
idx++;
vdx++;
}
}
}
for(auto j : p2points)
{
delete j;
};
TrianglesCommand::Triangles triangles = {verts, indices, vdx, idx};
return triangles;
}
void AutoPolygon::calculateUV(const Rect& rect, V3F_C4B_T2F* verts, const ssize_t& count)
{
/*
whole texture UV coordination
0,0 1,0
+---------------------+
| |0.1
| |0.2
| +--------+ |0.3
| |texRect | |0.4
| | | |0.5
| | | |0.6
| +--------+ |0.7
| |0.8
| |0.9
+---------------------+
0,1 1,1
*/
CCASSERT(_width && _height, "please specify width and height for this AutoPolygon instance");
float texWidth = _width;
float texHeight = _height;
auto end = &verts[count];
for(auto i = verts; i != end; i++)
{
// for every point, offcset with the centerpoint
float u = (i->vertices.x*_scaleFactor + rect.origin.x) / texWidth;
float v = (rect.origin.y+rect.size.height - i->vertices.y*_scaleFactor) / texHeight;
i->texCoords.u = u;
i->texCoords.v = v;
}
}
Rect AutoPolygon::getRealRect(const Rect& rect)
{
Rect realRect = rect;
//check rect to see if its zero
if(realRect.equals(Rect::ZERO))
{
//if the instance doesn't have width and height, then the whole operation is kaput
CCASSERT(_height && _width, "Please specify a width and height for this instance before using its functions");
realRect = Rect(0,0, _width, _height);
}
else{
//rect is specified, so convert to real rect
auto scale = Director::getInstance()->getContentScaleFactor();
realRect = Rect(rect.origin*scale, rect.size*scale);
}
return realRect;
}
PolygonInfo AutoPolygon::generateTriangles(const Rect& rect, const float& epsilon, const float& threshold)
{
Rect realRect = getRealRect(rect);
auto p = trace(realRect, threshold);
p = reduce(p, realRect, epsilon);
p = expand(p, realRect, epsilon);
auto tri = triangulate(p);
calculateUV(realRect, tri.verts, tri.vertCount);
PolygonInfo ret;
ret.triangles = tri;
ret.filename = _filename;
ret.rect = realRect;
return ret;
}
PolygonInfo AutoPolygon::generatePolygon(const std::string& filename, const Rect& rect, const float epsilon, const float threshold)
{
AutoPolygon ap(filename);
auto ret = ap.generateTriangles(rect, epsilon, threshold);
return ret;
}

269
cocos/2d/CCAutoPolygon.h Normal file
View File

@ -0,0 +1,269 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef COCOS_2D_CCAUTOPOLYGON_H__
#define COCOS_2D_CCAUTOPOLYGON_H__
#include <string>
#include <vector>
#include "platform/CCImage.h"
#include "renderer/CCTrianglesCommand.h"
NS_CC_BEGIN
/**
* @addtogroup _2d
* @{
*/
/**
* PolygonInfo is an object holding the required data to display Sprites
* It can be a simple as a triangle, or as complex as a whole 3D mesh
*/
class CC_DLL PolygonInfo
{
public:
/// @name Creators
/// @{
/**
* Creates an empty Polygon info
* @memberof PolygonInfo
* @return PolygonInfo object
*/
PolygonInfo():
isVertsOwner(true),
rect(cocos2d::Rect::ZERO),
filename("")
{
triangles.verts = nullptr;
triangles.indices = nullptr;
triangles.vertCount = 0;
triangles.indexCount = 0;
};
/**
* Create an polygoninfo from the data of another Polygoninfo
* @param other another PolygonInfo to be copied
* @return duplicate of the other PolygonInfo
*/
PolygonInfo(const PolygonInfo& other);
// end of creators group
/// @}
/**
* Copy the member of the other PolygonInfo
* @param other another PolygonInfo to be copied
*/
PolygonInfo& operator= (const PolygonInfo &other);
~PolygonInfo();
/**
* set the data to be a pointer to a quad
* the member verts will not be released when this PolygonInfo destructs
* as the verts memory are managed by other objects
* @param quad a pointer to the V3F_C4B_T2F_Quad obje
*/
void setQuad(V3F_C4B_T2F_Quad *quad);
/**
* get vertex count
* @return number of vertices
*/
const unsigned int getVertCount() const;
/**
* get triangles count
* @return number of triangles
*/
const unsigned int getTriaglesCount() const;
/**
* get sum of all triangle area size
* @return sum of all triangle area size
*/
const float getArea() const;
Rect rect;
std::string filename;
TrianglesCommand::Triangles triangles;
protected:
bool isVertsOwner;
private:
void releaseVertsAndIndices();
};
/**
* AutoPolygon is a helper Object
* AutoPolygon's purpose is to process an image into 2d polygon mesh in runtime
* It has functions for each step in the process, from tracing all the points, to triangulation
* the result can be then passed to Sprite::create() to create a Polygon Sprite
*/
class CC_DLL AutoPolygon
{
public:
/**
* create an AutoPolygon and initialize it with an image file
* the image must be a 32bit PNG for current version 3.7
* @param filename a path to image file, e.g., "scene1/monster.png".
* @return an AutoPolygon object;
*/
AutoPolygon(const std::string &filename);
/**
* Destructor of AutoPolygon.
*/
~AutoPolygon();
/**
* trace all the points along the outline of the image,
* @warning must create AutoPolygon with filename to use this function
* @param rect a texture rect for specify an area of the image, use Rect::Zero for the size of the image, default to Rect::Zero
* @param threshold the value when alpha is greater than this value will be counted as opaque, default to 0.0
* @return a vector of vec2 of all the points found in clockwise order
* @code
* auto ap = AutoPolygon("grossini.png");
* std::vector<Vec2> points = ap.trace();//default to size of the image and threshold 0.0
* @endcode
*/
std::vector<Vec2> trace(const cocos2d::Rect& rect, const float& threshold = 0.0);
/**
* reduce the ammount of points so its faster for GPU to process and draw
* based on Ramer-Douglas-Puecker algorithm
* @param points a vector of Vec2 points as input
* @param rect a texture rect for specify an area of the image to avoid over reduction
* @param epsilon the perpendicular distance where points smaller than this value will be discarded
* @return a vector of Vec2 of the remaining points in clockwise order
* @code
* auto ap = AutoPolygon();
* std::vector<Vec2> reduced = ap.reduce(inputPoints, rect);//default epsilon is 2
* @endcode
*/
std::vector<Vec2> reduce(const std::vector<Vec2>& points, const Rect& rect, const float& epsilon = 2.0);
/**
* expand the points along their edge, useful after you reduce the points that cuts into the sprite
* using ClipperLib
* @param points a vector of Vec2 points as input
* @param rect a texture rect for specify an area of the image, the expanded points will be clamped in this rect, ultimately resulting in a quad if the expansion is too great
* @param epsilon the distance which the edges will expand
* @return a vector of Vec2 as the result of the expansion
* @code
* auto ap = AutoPolygon();
* std::vector<Vec2> expanded = ap.expand(inputPoints, rect, 2.0);
* @endcode
*/
std::vector<Vec2> expand(const std::vector<Vec2>& points, const Rect& rect, const float& epsilon);
/**
* Triangulate the input points into triangles for rendering
* using poly2tri
* @warning points must be closed loop, cannot have 2 points sharing the same position and cannot intersect itself
* @param points a vector of vec2 points as input
* @return a Triangles object with points and indices
* @code
* auto ap = AutoPolygon();
* TrianglesCommand::Triangles myPolygons = ap.triangulate(myPoints);
* @endcode
*/
TrianglesCommand::Triangles triangulate(const std::vector<Vec2>& points);
/**
* calculate the UV coordinates for each points based on a texture rect
* @warning This method requires the AutoPolygon object to know the texture file dimension
* @param rect a texture rect to specify where to map the UV
* @param verts a pointer to the verts array, served both as input and output verts
* @param count the count for the verts arrac
* @code
* auto ap = AutoPolygon("grossini.png");
* TrianglesCommand::Triangles myPolygons = ap.triangulate(myPoints);
* ap.calculateUV(rect, myPolygons.verts, 20);
* @endcode
*/
void calculateUV(const Rect& rect, V3F_C4B_T2F* verts, const ssize_t& count);
/**
* a helper function, packing trace, reduce, expand, triangulate and calculate uv in one function
* @param rect texture rect, use Rect::ZERO for the size of the texture, default is Rect::ZERO
* @param epsilon the value used to reduce and expand, default to 2.0
* @param threshold the value where bigger than the threshold will be counted as opaque, used in trace
* @return a PolygonInfo, to use with sprite
* @code
* auto ap = AutoPolygon("grossini.png");
* PolygonInfo myInfo = ap.generateTriangles();//use all default values
* auto sp1 = Sprite::create(myInfo);
* polygonInfo myInfo2 = ap.generateTriangles(Rect::ZERO, 5.0, 0.1);//ap can be reused to generate another set of PolygonInfo with different settings
* auto sp2 = Sprite::create(myInfo2);
* @endcode
*/
PolygonInfo generateTriangles(const Rect& rect = Rect::ZERO, const float& epsilon = 2.0, const float& threshold = 0.05);
/**
* a helper function, packing autoPolygon creation, trace, reduce, expand, triangulate and calculate uv in one function
* @warning if you want to repetitively generate polygons, consider create an AutoPolygon object, and use generateTriangles function, as it only reads the file once
* @param filename A path to image file, e.g., "scene1/monster.png".
* @param rect texture rect, use Rect::ZERO for the size of the texture, default is Rect::ZERO
* @param epsilon the value used to reduce and expand, default to 2.0
* @param threshold the value where bigger than the threshold will be counted as opaque, used in trace
* @return a PolygonInfo, to use with sprite
* @code
* auto sp = Sprite::create(AutoPolygon::generatePolygon("grossini.png"));
* @endcode
*/
static PolygonInfo generatePolygon(const std::string& filename, const Rect& rect = Rect::ZERO, const float epsilon = 2.0, const float threshold = 0.05);
protected:
Vec2 findFirstNoneTransparentPixel(const Rect& rect, const float& threshold);
std::vector<cocos2d::Vec2> marchSquare(const Rect& rect, const Vec2& first, const float& threshold);
unsigned int getSquareValue(const unsigned int& x, const unsigned int& y, const Rect& rect, const float& threshold);
unsigned char getAlphaByIndex(const unsigned int& i);
unsigned char getAlphaByPos(const Vec2& pos);
int getIndexFromPos(const unsigned int& x, const unsigned int& y){return y*_width+x;};
cocos2d::Vec2 getPosFromIndex(const unsigned int& i){return cocos2d::Vec2(i%_width, i/_width);};
std::vector<cocos2d::Vec2> rdp(std::vector<cocos2d::Vec2> v, const float& optimization);
float perpendicularDistance(const cocos2d::Vec2& i, const cocos2d::Vec2& start, const cocos2d::Vec2& end);
//real rect is the size that is in scale with the texture file
Rect getRealRect(const Rect& rect);
Image* _image;
unsigned char * _data;
std::string _filename;
unsigned int _width;
unsigned int _height;
float _scaleFactor;
unsigned int _threshold;
};
NS_CC_END
#endif // #ifndef COCOS_2D_CCAUTOPOLYGON_H__

View File

@ -343,7 +343,6 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
} }
} }
xAdvance += 2 * _outlineSize;
outRect.size.width = blendWidth; outRect.size.width = blendWidth;
outRect.size.height = blendHeight; outRect.size.height = blendHeight;
outWidth = blendWidth; outWidth = blendWidth;

View File

@ -955,25 +955,42 @@ void Label::onDraw(const Mat4& transform, bool transformUpdated)
} }
} }
if (_currentLabelType == LabelType::TTF)
{
glprogram->setUniformLocationWith4f(_uniformTextColor,
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW)
{
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
}
}
glprogram->setUniformsForBuiltins(transform); glprogram->setUniformsForBuiltins(transform);
for(const auto &child: _children) for(const auto &child: _children)
{ {
child->updateTransform(); child->updateTransform();
} }
if (_currentLabelType == LabelType::TTF)
{
switch (_currLabelEffect) {
case LabelEffect::OUTLINE:
//draw text with outline
glprogram->setUniformLocationWith4f(_uniformTextColor,
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
for (const auto& batchNode:_batchNodes)
{
batchNode->getTextureAtlas()->drawQuads();
}
//draw text without outline
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, 0.f);
break;
case LabelEffect::GLOW:
glprogram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a);
case LabelEffect::NORMAL:
glprogram->setUniformLocationWith4f(_uniformTextColor,
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
break;
default:
break;
}
}
for (const auto& batchNode:_batchNodes) for (const auto& batchNode:_batchNodes)
{ {
batchNode->getTextureAtlas()->drawQuads(); batchNode->getTextureAtlas()->drawQuads();

View File

@ -401,7 +401,7 @@ void Node::updateRotation3D()
float x = _rotationQuat.x, y = _rotationQuat.y, z = _rotationQuat.z, w = _rotationQuat.w; float x = _rotationQuat.x, y = _rotationQuat.y, z = _rotationQuat.z, w = _rotationQuat.w;
_rotationX = atan2f(2.f * (w * x + y * z), 1.f - 2.f * (x * x + y * y)); _rotationX = atan2f(2.f * (w * x + y * z), 1.f - 2.f * (x * x + y * y));
_rotationY = asinf(2.f * (w * y - z * x)); _rotationY = asinf(2.f * (w * y - z * x));
_rotationZ_X = atanf(2.f * (w * z + x * y) / (1.f - 2.f * (y * y + z * z))); _rotationZ_X = atan2f(2.f * (w * z + x * y), 1.f - 2.f * (y * y + z * z));
_rotationX = CC_RADIANS_TO_DEGREES(_rotationX); _rotationX = CC_RADIANS_TO_DEGREES(_rotationX);
_rotationY = CC_RADIANS_TO_DEGREES(_rotationY); _rotationY = CC_RADIANS_TO_DEGREES(_rotationY);

View File

@ -86,6 +86,18 @@ Sprite* Sprite::create(const std::string& filename)
return nullptr; return nullptr;
} }
Sprite* Sprite::create(const PolygonInfo& info)
{
Sprite *sprite = new (std::nothrow) Sprite();
if(sprite && sprite->initWithPolygon(info))
{
sprite->autorelease();
return sprite;
}
CC_SAFE_DELETE(sprite);
return nullptr;
}
Sprite* Sprite::create(const std::string& filename, const Rect& rect) Sprite* Sprite::create(const std::string& filename, const Rect& rect)
{ {
Sprite *sprite = new (std::nothrow) Sprite(); Sprite *sprite = new (std::nothrow) Sprite();
@ -207,6 +219,19 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame)
return bRet; return bRet;
} }
bool Sprite::initWithPolygon(const cocos2d::PolygonInfo &info)
{
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(info.filename);
bool res = false;
if(initWithTexture(texture));
{
_polyInfo = info;
setContentSize(_polyInfo.rect.size/Director::getInstance()->getContentScaleFactor());
res = true;
}
return res;
}
// designated initializer // designated initializer
bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
{ {
@ -246,6 +271,7 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated)
setTexture(texture); setTexture(texture);
setTextureRect(rect, rotated, rect.size); setTextureRect(rect, rotated, rect.size);
_polyInfo.setQuad(&_quad);
// by default use "Self Render". // by default use "Self Render".
// if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render"
setBatchNode(nullptr); setBatchNode(nullptr);
@ -268,8 +294,7 @@ Sprite::Sprite(void)
, _insideBounds(true) , _insideBounds(true)
{ {
#if CC_SPRITE_DEBUG_DRAW #if CC_SPRITE_DEBUG_DRAW
_debugDrawNode = DrawNode::create(); debugDraw(true)
addChild(_debugDrawNode);
#endif //CC_SPRITE_DEBUG_DRAW #endif //CC_SPRITE_DEBUG_DRAW
} }
@ -407,6 +432,47 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme
} }
} }
void Sprite::debugDraw(bool on)
{
DrawNode* draw = getChildByName<DrawNode*>("debugDraw");
if(on)
{
if(!draw)
{
draw = DrawNode::create();
draw->setName("debugDraw");
addChild(draw);
}
draw->setVisible(true);
draw->clear();
//draw lines
auto last = _polyInfo.triangles.indexCount/3;
auto _indices = _polyInfo.triangles.indices;
auto _verts = _polyInfo.triangles.verts;
for(unsigned int i = 0; i < last; i++)
{
//draw 3 lines
Vec3 from =_verts[_indices[i*3]].vertices;
Vec3 to = _verts[_indices[i*3+1]].vertices;
draw->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
from =_verts[_indices[i*3+1]].vertices;
to = _verts[_indices[i*3+2]].vertices;
draw->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
from =_verts[_indices[i*3+2]].vertices;
to = _verts[_indices[i*3]].vertices;
draw->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
}
}
else
{
if(draw)
draw->setVisible(false);
}
}
// override this method to generate "double scale" sprites // override this method to generate "double scale" sprites
void Sprite::setVertexRect(const Rect& rect) void Sprite::setVertexRect(const Rect& rect)
{ {
@ -598,33 +664,11 @@ void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
if(_insideBounds) if(_insideBounds)
#endif #endif
{ {
_trianglesCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, getRenderedTriangles(), transform, flags); _trianglesCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, _polyInfo.triangles, transform, flags);
renderer->addCommand(&_trianglesCommand); renderer->addCommand(&_trianglesCommand);
#if CC_SPRITE_DEBUG_DRAW
_debugDrawNode->clear();
Vec2 vertices[4] = {
Vec2( _quad.bl.vertices.x, _quad.bl.vertices.y ),
Vec2( _quad.br.vertices.x, _quad.br.vertices.y ),
Vec2( _quad.tr.vertices.x, _quad.tr.vertices.y ),
Vec2( _quad.tl.vertices.x, _quad.tl.vertices.y ),
};
_debugDrawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0));
#endif //CC_SPRITE_DEBUG_DRAW
} }
} }
TrianglesCommand::Triangles Sprite::getRenderedTriangles() const
{
static unsigned short indices[6] = {0, 1, 2, 3, 2, 1};
TrianglesCommand::Triangles result;
result.indices = indices;
result.verts = (V3F_C4B_T2F*)&_quad;
result.vertCount = 4;
result.indexCount = 6;
return result;
}
// MARK: visit, draw, transform // MARK: visit, draw, transform
void Sprite::addChild(Node *child, int zOrder, int tag) void Sprite::addChild(Node *child, int zOrder, int tag)
@ -1054,7 +1098,7 @@ void Sprite::updateBlendFunc(void)
{ {
CCASSERT(! _batchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a SpriteBatchNode"); CCASSERT(! _batchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a SpriteBatchNode");
// it is possible to have an untextured sprite // it is possible to have an untextured spritec
if (! _texture || ! _texture->hasPremultipliedAlpha()) if (! _texture || ! _texture->hasPremultipliedAlpha())
{ {
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
@ -1077,4 +1121,14 @@ std::string Sprite::getDescription() const
return StringUtils::format("<Sprite | Tag = %d, TextureID = %d>", _tag, texture_id ); return StringUtils::format("<Sprite | Tag = %d, TextureID = %d>", _tag, texture_id );
} }
PolygonInfo Sprite::getPolygonInfo() const
{
return _polyInfo;
}
void Sprite::setPolygonInfo(const PolygonInfo& info)
{
_polyInfo = info;
}
NS_CC_END NS_CC_END

View File

@ -35,6 +35,7 @@ THE SOFTWARE.
#include "renderer/CCTextureAtlas.h" #include "renderer/CCTextureAtlas.h"
#include "renderer/CCTrianglesCommand.h" #include "renderer/CCTrianglesCommand.h"
#include "renderer/CCCustomCommand.h" #include "renderer/CCCustomCommand.h"
#include "2d/CCAutoPolygon.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -99,6 +100,17 @@ public:
*/ */
static Sprite* create(const std::string& filename); static Sprite* create(const std::string& filename);
/**
* Creates a polygon sprite with a polygon info.
*
* After creation, the rect of sprite will be the size of the image,
* and the offset will be (0,0).
*
* @param polygonInfo A path to image file, e.g., "scene1/monster.png".
* @return An autoreleased sprite object.
*/
static Sprite* create(const PolygonInfo& info);
/** /**
* Creates a sprite with an image filename and a rect. * Creates a sprite with an image filename and a rect.
* *
@ -460,6 +472,17 @@ CC_CONSTRUCTOR_ACCESS:
*/ */
virtual bool initWithTexture(Texture2D *texture); virtual bool initWithTexture(Texture2D *texture);
/**
* Initializes a sprite with a PolygonInfo.
*
* After initialization, the rect used will be the size of the texture, and the offset will be (0,0).
*
* @param PolygonInfo a Polygon info contains the structure of the polygon.
* @return True if the sprite is initialized properly, false otherwise.
*/
virtual bool initWithPolygon(const PolygonInfo& info);
/** /**
* Initializes a sprite with a texture and a rect. * Initializes a sprite with a texture and a rect.
* *
@ -531,6 +554,22 @@ CC_CONSTRUCTOR_ACCESS:
*/ */
virtual bool initWithFile(const std::string& filename, const Rect& rect); virtual bool initWithFile(const std::string& filename, const Rect& rect);
void debugDraw(bool on);
/**
* returns a copy of the polygon information associated with this sprite
* because this is a copy process it is slower than getting the reference, so use wisely
*
* @return a copy of PolygonInfo
*/
PolygonInfo getPolygonInfo() const;
/**
* set the sprite to use this new PolygonInfo
*
* @param PolygonInfo the polygon information object
*/
void setPolygonInfo(const PolygonInfo& info);
protected: protected:
void updateColor() override; void updateColor() override;
@ -539,7 +578,8 @@ protected:
virtual void setReorderChildDirtyRecursively(); virtual void setReorderChildDirtyRecursively();
virtual void setDirtyRecursively(bool value); virtual void setDirtyRecursively(bool value);
TrianglesCommand::Triangles getRenderedTriangles() const;
// //
// Data used when the sprite is rendered using a SpriteSheet // Data used when the sprite is rendered using a SpriteSheet
// //
@ -559,9 +599,8 @@ protected:
Texture2D* _texture; /// Texture2D object that is used to render the sprite Texture2D* _texture; /// Texture2D object that is used to render the sprite
SpriteFrame* _spriteFrame; SpriteFrame* _spriteFrame;
TrianglesCommand _trianglesCommand; /// TrianglesCommand _trianglesCommand; ///
#if CC_SPRITE_DEBUG_DRAW
DrawNode *_debugDrawNode;
#endif //CC_SPRITE_DEBUG_DRAW
// //
// Shared data // Shared data
// //
@ -576,6 +615,7 @@ protected:
// vertex coords, texture coords and color info // vertex coords, texture coords and color info
V3F_C4B_T2F_Quad _quad; V3F_C4B_T2F_Quad _quad;
PolygonInfo _polyInfo;
// opacity and RGB protocol // opacity and RGB protocol
bool _opacityModifyRGB; bool _opacityModifyRGB;

View File

@ -66,9 +66,8 @@ set(COCOS_2D_SRC
2d/CCSprite.cpp 2d/CCSprite.cpp
2d/CCSpriteFrameCache.cpp 2d/CCSpriteFrameCache.cpp
2d/CCSpriteFrame.cpp 2d/CCSpriteFrame.cpp
2d/MarchingSquare.cpp 2d/CCAutoPolygon.cpp
2d/SpritePolygon.cpp ../../external/clipper/clipper.cpp
2d/SpritePolygonCache.cpp
2d/CCTextFieldTTF.cpp 2d/CCTextFieldTTF.cpp
2d/CCTileMapAtlas.cpp 2d/CCTileMapAtlas.cpp
2d/CCTMXLayer.cpp 2d/CCTMXLayer.cpp

View File

@ -1,356 +0,0 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "MarchingSquare.h"
#include "cocos2d.h"
#include <algorithm>
USING_NS_CC;
MarchingSquare::MarchingSquare(const std::string &filename, const unsigned int threshold)
{
_filename = filename;
_threshold = threshold;
Image *image = new Image();
image->initWithImageFile(filename);
CCASSERT(image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888, "unsupported format, currently only supports rgba8888");
data = image->getData();
width = image->getWidth();
height = image->getHeight();
scaleFactor = Director::getInstance()->getContentScaleFactor();
}
void MarchingSquare::trace()
{
unsigned int first = findFirstNoneTransparentPixel();
start = Vec2(first%width, first/width);
marchSquare(start.x, start.y);
}
unsigned int MarchingSquare::findFirstNoneTransparentPixel()
{
for(unsigned int i = 0; i < width*height; i++)
{
if(getAlphaAt(i) > _threshold)
{
// CCLOG("first non transparent is at x:%d, y%d", i%width, i/width);
return i;
}
}
CCASSERT(false, "image is all transparent!");
}
unsigned char MarchingSquare::getAlphaAt(const unsigned int i)
{
return *(data+i*4+3);
}
unsigned char MarchingSquare::getAlphaAt(const int x, const int y)
{
if(x < 0 || y < 0 || x > width-1 || y > height-1)
return 0;
return *(data+(y*width+x)*4+3);
}
unsigned int MarchingSquare::getSquareValue(int x, int y)
{
/*
checking the 2x2 pixel grid, assigning these values to each pixel, if not transparent
+---+---+
| 1 | 2 |
+---+---+
| 4 | 8 | <- current pixel (curx,cury)
+---+---+
*/
unsigned int sv = 0;
if(getAlphaAt(x-1, y-1) > _threshold)
sv += 1;
if(getAlphaAt(x,y-1) > _threshold)
sv += 2;
if(getAlphaAt(x-1, y) > _threshold)
sv += 4;
if(getAlphaAt(x, y) > _threshold)
sv += 8;
return sv;
}
void MarchingSquare::marchSquare(int startx, int starty)
{
int stepx = 0;
int stepy = 0;
int prevx = 0;
int prevy = 0;
int curx = startx;
int cury = starty;
unsigned int count = 0;
unsigned int totalPixel = width*height;
bool problem = false;
std::vector<int> case9s;
std::vector<int> case6s;
int i;
std::vector<int>::iterator it;
do{
int sv = getSquareValue(curx, cury);
switch(sv){
case 1:
case 5:
case 13:
/* going UP with these cases:
1 5 13
+---+---+ +---+---+ +---+---+
| 1 | | | 1 | | | 1 | |
+---+---+ +---+---+ +---+---+
| | | | 4 | | | 4 | 8 |
+---+---+ +---+---+ +---+---+
*/
stepx = 0;
stepy = -1;
break;
case 8:
case 10:
case 11:
/* going DOWN with these cases:
8 10 11
+---+---+ +---+---+ +---+---+
| | | | | 2 | | 1 | 2 |
+---+---+ +---+---+ +---+---+
| | 8 | | | 8 | | | 8 |
+---+---+ +---+---+ +---+---+
*/
stepx = 0;
stepy = 1;
break;
case 4:
case 12:
case 14:
/* going LEFT with these cases:
4 12 14
+---+---+ +---+---+ +---+---+
| | | | | | | | 2 |
+---+---+ +---+---+ +---+---+
| 4 | | | 4 | 8 | | 4 | 8 |
+---+---+ +---+---+ +---+---+
*/
stepx = -1;
stepy = 0;
break;
case 2 :
case 3 :
case 7 :
/* going RIGHT with these cases:
2 3 7
+---+---+ +---+---+ +---+---+
| | 2 | | 1 | 2 | | 1 | 2 |
+---+---+ +---+---+ +---+---+
| | | | | | | 4 | |
+---+---+ +---+---+ +---+---+
*/
stepx=1;
stepy=0;
break;
case 9 :
/*
+---+---+
| 1 | |
+---+---+
| | 8 |
+---+---+
this should normaly go UP, but if we already been here, we go down
*/
//find index from xy;
i = getIndexFromPos(curx, cury);
it = find (case9s.begin(), case9s.end(), i);
if (it != case9s.end())
{
//found, so we go down, and delete from case9s;
stepx = 0;
stepy = 1;
case9s.erase(it);
problem = true;
}
else
{
//not found, we go up, and add to case9s;
stepx = 0;
stepy = -1;
case9s.push_back(i);
}
break;
case 6 :
/*
6
+---+---+
| | 2 |
+---+---+
| 4 | |
+---+---+
this normally go RIGHT, but if its coming from UP, it should go LEFT
*/
i = getIndexFromPos(curx, cury);
it = find (case6s.begin(), case6s.end(), i);
if (it != case6s.end())
{
//found, so we go down, and delete from case9s;
stepx = -1;
stepy = 0;
case6s.erase(it);
problem = true;
}
else{
//not found, we go up, and add to case9s;
stepx = 1;
stepy = 0;
case6s.push_back(i);
}
break;
case 0:
CCLOG("case 0 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy);
CCASSERT(false, "this shoudln't happen");
break;
case 15:
CCLOG("case 15 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy);
CCASSERT(false, "this shoudln't happen");
break;
}
//little optimization
// if previous direction is same as current direction,
// then we should modify the last vec to current
curx += stepx;
cury += stepy;
if(stepx == prevx && stepy == prevy)
{
points.back().x = (float)(curx) / scaleFactor;
points.back().y = (float)(height-cury) / scaleFactor;
}
else if(problem)
{
//TODO: we triangulation cannot work collineer points, so we need to modify same point a little
//TODO: maybe we can detect if we go into a hole and coming back the hole, we should extract those points and remove them
points.back().x -= 0.00001f;
points.back().y -= 0.00001f;
points.push_back(Vec2((float)curx, (float)height-cury)/ scaleFactor);
}
else{
points.push_back(Vec2((float)curx, (float)height-cury)/ scaleFactor);
}
count++;
prevx = stepx;
prevy = stepy;
problem = false;
CCASSERT(count <= totalPixel, "oh no, marching square cannot find starting position");
} while(curx != startx || cury != starty);
}
void MarchingSquare::printPoints()
{
for(auto p : points)
{
CCLOG("%.1f %.1f", p.x, height-p.y);
}
}
float MarchingSquare::perpendicularDistance(cocos2d::Vec2 ii, cocos2d::Vec2 ss, cocos2d::Vec2 ee)
{
float res;
float slope;
float intercept;
if(ss.x == ee.x)
{
res = fabsf(ii.x- ee.x);
}
else if (ss.y == ee.y)
{
res = fabsf(ii.y - ee.y);
}
else{
slope = (ee.y - ss.y) / (ee.x - ss.x);
intercept = ss.y - (slope*ss.x);
res = fabsf(slope * ii.x - ii.y + intercept) / sqrtf(powf(slope, 2)+1);
}
return res;
}
std::vector<cocos2d::Vec2> MarchingSquare::rdp(std::vector<cocos2d::Vec2> v)
{
if(v.size() < 3)
return v;
int index = -1;
float dist = 0;
//not looping first and last point
for(int i = 1; i < v.size()-1; i++)
{
float cdist = perpendicularDistance(v[i], v.front(), v.back());
if(cdist > dist)
{
dist = cdist;
index = i;
}
}
if (dist>epsilon)
{
std::vector<Vec2>::const_iterator begin = v.begin();
std::vector<Vec2>::const_iterator end = v.end();
std::vector<Vec2> l1(begin, begin+index+1);
std::vector<Vec2> l2(begin+index, end);
std::vector<Vec2> r1 = rdp(l1);
std::vector<Vec2> r2 = rdp(l2);
r1.insert(r1.end(), r2.begin()+1, r2.end());
return r1;
}
else {
std::vector<Vec2> ret;
ret.push_back(v.front());
ret.push_back(v.back());
return ret;
}
}
void MarchingSquare::optimize(float level)
{
if(level <= 0 || points.size()<4)
return;
epsilon = level;
points = rdp(points);
auto last = points.back();
if(last.y > points.front().y)
points.front().y = last.y;
points.pop_back();
//delete the last point, because its almost the same as the starting point
// CCLOG("%.1f, %.1f, %.1f, %.1f", points[0].x, points[0].y, points.back().x, points.back().y);
}

View File

@ -1,78 +0,0 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef COCOS_2D_MARCHINGSQUARE_H__
#define COCOS_2D_MARCHINGSQUARE_H__
#include <string>
#include <vector>
#include "base/CCConsole.h"
#include "platform/CCPlatformMacros.h"
#include "math/Vec2.h"
NS_CC_BEGIN
class CC_DLL MarchingSquare
{
public:
MarchingSquare(const std::string &filename, const unsigned int threshold = 0);
//TODO: should return list of vec2s
void trace();
void setThreshold(unsigned int threshold){_threshold = threshold;};
unsigned int getThreshold(){return _threshold;};
ssize_t getVecCount(){return points.size();};
std::vector<cocos2d::Vec2> getPoints(){return points;};
void printPoints();
//using RamerDouglasPeucker algorithm
void optimize(float level = 0);
protected:
unsigned int findFirstNoneTransparentPixel();
void marchSquare(int startx, int starty);
unsigned int getSquareValue(int x, int y);
unsigned char * data;
std::string _filename;
unsigned int width;
unsigned int height;
unsigned int _threshold;
unsigned char getAlphaAt(const unsigned int i);
unsigned char getAlphaAt(const int x, const int y);
cocos2d::Vec2 start;
std::vector<cocos2d::Vec2> points;
int getIndexFromPos(int x, int y){return y*width+x;};
cocos2d::Vec2 getPosFromIndex(int i){return cocos2d::Vec2(i%width, i/width);};
float epsilon;
std::vector<cocos2d::Vec2> rdp(std::vector<cocos2d::Vec2> v);
float perpendicularDistance(cocos2d::Vec2 i, cocos2d::Vec2 start, cocos2d::Vec2 end);
float scaleFactor;
};
NS_CC_END
#endif // #ifndef COCOS_2D_MARCHINGSQUARE_H__

View File

@ -1,506 +0,0 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "SpritePolygon.h"
#include "3d/CCMesh.h"
#include "3d/CCMeshVertexIndexData.h"
#include "MarchingSquare.h"
#include "base/CCDirector.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCTextureCache.h"
#include "renderer/CCGLProgramState.h"
#include "renderer/CCGLProgramCache.h"
#include <vector>
#include "poly2tri/poly2tri.h"
#include "SpritePolygonCache.h"
#include "platform/CCFileUtils.h"
using namespace std;
USING_NS_CC;
using namespace cocos2d::experimental;
SpritePolygon *SpritePolygon::create(const std::string& file, std::vector<cocos2d::V3F_C4B_T2F>& verts, std::vector<unsigned short>& indices)
{
SpritePolygon *ret = new (std::nothrow) SpritePolygon();
if (ret && ret->initWithVerts(file, verts, indices))
{
ret->autorelease();
return ret;
}
else
{
CC_SAFE_DELETE(ret);
return nullptr;
}
}
SpritePolygon *SpritePolygon::create(const std::string& file, std::vector<cocos2d::Vec2>& verts,std::vector<unsigned short>& indices, const cocos2d::Rect& rect)
{
SpritePolygon *ret = new (std::nothrow) SpritePolygon();
if (ret && ret->initWithRect(file, verts, indices, rect))
{
ret->autorelease();
return ret;
}
else
{
CC_SAFE_DELETE(ret);
return nullptr;
}
}
SpritePolygon *SpritePolygon::create(const std::string& file, std::vector<cocos2d::Vec2>& verts, const cocos2d::Rect& rect)
{
SpritePolygon *ret = new (std::nothrow) SpritePolygon();
if (ret && ret->initWithPoly2tri(file, verts, rect))
{
ret->autorelease();
return ret;
}
else
{
CC_SAFE_DELETE(ret);
return nullptr;
}
}
SpritePolygon *SpritePolygon::create(const std::string &file, const cocos2d::Rect &rect, float optimization)
{
SpritePolygon *ret = new (std::nothrow) SpritePolygon();
if (ret)
{
auto info = SpritePolygonCache::getInstance()->getSpritePolygonCache(file, rect);
if(info)
{
// CCLOG("created from cache");
ret->initWithCache(file, info);
}
else{
// CCLOG("created with marching square");
ret->initWithMarching(file, rect, optimization);
}
ret->autorelease();
return ret;
}
else
{
CC_SAFE_DELETE(ret);
return nullptr;
}
}
void SpritePolygon::calculateUVandContentSize()
{
/*
whole texture UV coordination
0,0 1,0
+---------------------+
| |0.1
| |0.2
| +--------+ |0.3
| |texRect | |0.4
| | | |0.5
| | | |0.6
| +--------+ |0.7
| |0.8
| |0.9
+---------------------+
0,1 1,1
because when we scanned the image upside down, our uv is now upside down too
*/
float scaleFactor = Director::getInstance()->getContentScaleFactor();
float texWidth = _texture->getPixelsWide()/scaleFactor;
float texHeight = _texture->getPixelsHigh()/scaleFactor;
// the texture rect in pixels, for example, an image is 32x32 pixels
Rect* textRect = &_polygonInfo->_rect;
bool needDelete = false;
if(textRect->equals(Rect::ZERO))
{
//zero sized rect specified, so it means the whole image, for our calculation, we need actual image rect
textRect = new Rect(0,0, texWidth, texHeight);
needDelete = true;
}
setContentSize(textRect->size);
auto end = &_polygonInfo->_triangles.verts[_polygonInfo->_triangles.vertCount];
for(auto i = _polygonInfo->_triangles.verts; i != end; i++)
{
// for every point, offset with the centerpoint
float u = i->vertices.x / texWidth;
float v = (texHeight - i->vertices.y) / texHeight;
i->texCoords.u = u;
i->texCoords.v = v;
}
if(needDelete)
delete textRect;
}
TrianglesCommand::Triangles SpritePolygon::triangulate(std::vector<cocos2d::Vec2> & verts)
{
std::vector<p2t::Point*> points;
for(std::vector<Vec2>::const_iterator it = verts.begin(); it<verts.end(); it++)
{
p2t::Point * p = new p2t::Point(it->x, it->y);
points.push_back(p);
}
auto cdt = new p2t::CDT(points);
cdt->Triangulate();
std::vector<p2t::Triangle*> tris = cdt->GetTriangles();
vector<V3F_C4B_T2F> *_verts = new vector<V3F_C4B_T2F>();
vector<unsigned short> *_indices = new vector<unsigned short>;
unsigned short idx = 0;
for(std::vector<p2t::Triangle*>::const_iterator ite = tris.begin(); ite < tris.end(); ite++)
{
for(int i = 0; i < 3; i++)
{
auto p = (*ite)->GetPoint(i);
auto v3 = Vec3(p->x, p->y, 0);
bool found = false;
int j;
for(j = 0; j < _verts->size(); j++)
{
if((*_verts)[j].vertices == v3)
{
found = true;
break;
}
}
if(found)
{
//if we found the same vertice, don't add to verts, but use the same vert with indices
_indices->push_back(j);
}
else
{
//vert does not exist yet, so we need to create a new one,
auto c4b = Color4B::WHITE;
auto t2f = Tex2F(0,0); // don't worry about tex coords now, we calculate that later
V3F_C4B_T2F vert = {v3,c4b,t2f};
_verts->push_back(vert);
_indices->push_back(idx);
idx++;
}
}
}
for(auto j : points)
{
delete j;
}
delete cdt;
TrianglesCommand::Triangles triangles = {&(*_verts)[0], &(*_indices)[0], (ssize_t)_verts->size(), (ssize_t)_indices->size()};
return triangles;
}
bool SpritePolygon::initWithCache(const std::string &file, SpritePolygonInfo *info)
{
CCASSERT(file.size()>0, "Invalid filename for sprite");
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file);
CCASSERT(texture, "texture was not loaded properly");
_polygonInfo = info;
initWithTexture(texture);
if(_polygonInfo->_rect.equals(Rect::ZERO))
{
setContentSize(Size(texture->getPixelsWide(), texture->getPixelsHigh())/Director::getInstance()->getContentScaleFactor());
}
else
{
setContentSize(_polygonInfo->_rect.size);
}
setAnchorPoint(Vec2(0.5,0.5));
return true;
}
bool SpritePolygon::initWithMarching(const std::string &file, const cocos2d::Rect &rect, float optimization)
{
CCASSERT(file.size()>0, "Invalid filename for sprite");
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file);
CCASSERT(texture, "texture was not loaded properly");
initWithTexture(texture);
optimization = (optimization < 0)? (float)texture->getPixelsHigh()*(float)texture->getPixelsWide()*0.00015/Director::getInstance()->getContentScaleFactor() : optimization/Director::getInstance()->getContentScaleFactor();
//Marching Square
auto marcher = new MarchingSquare(file);
marcher->trace();
marcher->optimize(optimization);
// marcher->test();
auto p = marcher->getPoints();
auto triangles = triangulate(p);
delete marcher;
//save result to cache
_polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(file, rect, triangles);
setAnchorPoint(Vec2(0.5,0.5));
calculateUVandContentSize();
// SpritePolygonCache::printInfo(*_polygonInfo);
#if CC_SPRITE_DEBUG_DRAW
debugDraw();
#endif
return true;
}
bool SpritePolygon::initWithPoly2tri(const std::string &filename, std::vector<cocos2d::Vec2> & verts, const cocos2d::Rect &Rect)
{
CCASSERT(filename.size()>0, "Invalid filename for sprite");
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);
CCASSERT(texture, "texture was not loaded properly");
initWithTexture(texture);
_polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, Rect, triangulate(verts));
setAnchorPoint(Vec2(0.5,0.5));
calculateUVandContentSize();
#if CC_SPRITE_DEBUG_DRAW
debugDraw();
#endif
return true;
}
Rect SpritePolygon::getTextRectFromTriangles(std::vector<cocos2d::V3F_C4B_T2F>& _verts)
{
// CCASSERT(_polygonInfo, "cannot get texture rect because triangles were not defined");
auto text = getTexture();
int width = text->getPixelsWide();
int height = text->getPixelsHigh();
auto firstV = _verts[0];
auto left = firstV.texCoords.u;
auto right = firstV.texCoords.u;
auto top = firstV.texCoords.v;
auto bot = firstV.texCoords.v;
for(std::vector<V3F_C4B_T2F>::const_iterator v = _verts.begin(); v < _verts.end(); v++)
{
if(v->texCoords.u < left)
{
left = v->texCoords.u;
}
else if (v->texCoords.u > right)
{
right = v->texCoords.u;
}
if(v->texCoords.v < bot)
{
bot = v->texCoords.v;
}
else if (v->texCoords.v > top)
{
top = v->texCoords.v;
}
}
return Rect(left*width, bot*height, right*width, top*height);
}
bool SpritePolygon::initWithVerts(const std::string& filename,std::vector<cocos2d::V3F_C4B_T2F>& verts, std::vector<unsigned short>& indices)
{
CCASSERT(filename.size()>0, "Invalid filename for sprite");
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);
CCASSERT(texture, "texture was not loaded properly");
initWithTexture(texture);
auto _textureRect = getTextRectFromTriangles(verts);
setContentSize(_textureRect.size/Director::getInstance()->getContentScaleFactor());
setAnchorPoint(Vec2(0.5,0.5));
_transformDirty = true;
TrianglesCommand::Triangles triangles = {&verts[0], &indices[0], (ssize_t)verts.size(), (ssize_t)indices.size()};
_polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, _textureRect, triangles);
#if CC_SPRITE_DEBUG_DRAW
debugDraw();
#endif
return true;
}
bool SpritePolygon::initWithRect(const std::string& filename, std::vector<cocos2d::Vec2>& verts, std::vector<unsigned short>& indices, const cocos2d::Rect& rect)
{
CCASSERT(filename.size()>0, "Invalid filename for sprite");
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);
CCASSERT(texture, "texture was not loaded properly");
initWithTexture(texture);
//build v3f_c4b_t2f verts from vec2 vector
vector<V3F_C4B_T2F> _verts;
for(std::vector<Vec2>::const_iterator it = verts.begin(); it<verts.end(); it++)
{
auto v3 = Vec3(it->x, it->y, 0);
auto c4b = Color4B::WHITE;
auto t2f = Tex2F(0,0);
V3F_C4B_T2F vert = {v3,c4b,t2f};
_verts.push_back(vert);
}
TrianglesCommand::Triangles triangles = {&_verts[0], &indices[0], (ssize_t)_verts.size(), (ssize_t)indices.size()};
_polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, rect, triangles);
calculateUVandContentSize();
setAnchorPoint(Vec2(0.5,0.5));
#if CC_SPRITE_DEBUG_DRAW
debugDraw();
#endif
return true;
}
bool SpritePolygon::initWithTexture(Texture2D *texture)
{
Node::init();
//init the triangles command
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setTexture(texture);
return true;
}
void SpritePolygon::setTexture(const std::string &filename)
{
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename);
setTexture(texture);
}
static unsigned char cc_2x2_white_image[] = {
// RGBA8888
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF
};
#define CC_2x2_WHITE_IMAGE_KEY "/cc_2x2_white_image"
void SpritePolygon::setTexture(Texture2D *texture)
{
// accept texture==nil as argument
CCASSERT( !texture || dynamic_cast<Texture2D*>(texture), "setTexture expects a Texture2D. Invalid argument");
if (texture == nullptr)
{
// Gets the texture by key firstly.
texture = Director::getInstance()->getTextureCache()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY);
// If texture wasn't in cache, create it from RAW data.
if (texture == nullptr)
{
Image* image = new (std::nothrow) Image();
bool isOK = image->initWithRawData(cc_2x2_white_image, sizeof(cc_2x2_white_image), 2, 2, 8);
CC_UNUSED_PARAM(isOK);
CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully.");
texture = Director::getInstance()->getTextureCache()->addImage(image, CC_2x2_WHITE_IMAGE_KEY);
CC_SAFE_RELEASE(image);
}
}
if (_texture != texture)
{
CC_SAFE_RETAIN(texture);
CC_SAFE_RELEASE(_texture);
_texture = texture;
}
}
const float SpritePolygon::getArea(){
float area = 0;
V3F_C4B_T2F *verts = _polygonInfo->_triangles.verts;
unsigned short *indices = _polygonInfo->_triangles.indices;
for(int i = 0; i < _polygonInfo->_triangles.indexCount; i=i+3)
{
auto A = verts[indices[i]].vertices;
auto B = verts[indices[i+1]].vertices;
auto C = verts[indices[i+2]].vertices;
area += (A.x*(B.y-C.y) + B.x*(C.y-A.y) + C.x*(A.y - B.y))/2;
}
return area;
}
void SpritePolygon::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
_tcmd.init(0, _texture->getName(), getGLProgramState(), _blendFunc, _polygonInfo->_triangles, transform, flags);
renderer->addCommand(&_tcmd);
}
void SpritePolygon::debugDraw()
{
if(!_debugDrawNode)
{
_debugDrawNode = DrawNode::create();
addChild(_debugDrawNode);
}
else{
_debugDrawNode->clear();
}
//draw all points
auto positions = new (std::nothrow) Vec2[_polygonInfo->_triangles.vertCount];
Vec2 *pos = &positions[0];
auto verts = _polygonInfo->_triangles.verts;
auto end = &verts[_polygonInfo->_triangles.vertCount];
for(V3F_C4B_T2F *v = verts; v != end; pos++, v++)
{
pos->x = v->vertices.x;
pos->y = v->vertices.y;
}
_debugDrawNode->drawPoints(positions, (unsigned int)_polygonInfo->_triangles.vertCount, 8, Color4F(0.0f, 1.0f, 1.0f, 1.0f));
//draw lines
auto last = _polygonInfo->_triangles.indexCount/3;
auto _indices = _polygonInfo->_triangles.indices;
auto _verts = _polygonInfo->_triangles.verts;
for(unsigned int i = 0; i < last; i++)
{
//draw 3 lines
Vec3 from =_verts[_indices[i*3]].vertices;
Vec3 to = _verts[_indices[i*3+1]].vertices;
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
from =_verts[_indices[i*3+1]].vertices;
to = _verts[_indices[i*3+2]].vertices;
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
from =_verts[_indices[i*3+2]].vertices;
to = _verts[_indices[i*3]].vertices;
_debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN);
}
CC_SAFE_DELETE_ARRAY(positions);
}
void SpritePolygon::showDebug(const bool val)
{
if(val)
{
if(!_debugDrawNode)
{
debugDraw();
}
else{
_debugDrawNode->setVisible(val);
}
}
else{
if(_debugDrawNode)
{
_debugDrawNode->setVisible(val);
}
}
}

View File

@ -1,108 +0,0 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef COCOS_2D_SpritePolygon_H__
#define COCOS_2D_SpritePolygon_H__
#include <vector>
#include "platform/CCPlatformMacros.h"
#include "2d/CCNode.h"
#include "renderer/CCTrianglesCommand.h"
#include "CCDrawNode.h"
#include "SpritePolygonCache.h"
NS_CC_BEGIN
namespace experimental{
class CC_DLL SpritePolygon : public cocos2d::Node
{
public:
//create with manually created vertices, color and uv and
static SpritePolygon *create(const std::string&, std::vector<cocos2d::V3F_C4B_T2F>&, std::vector<unsigned short>&);
bool initWithVerts(const std::string&, std::vector<cocos2d::V3F_C4B_T2F>&, std::vector<unsigned short>&);
//create from list of vertices, with texture rect, and triangle indices, UV is calculated from the texture rect
static SpritePolygon *create(const std::string&, std::vector<cocos2d::Vec2>&, std::vector<unsigned short>&, const cocos2d::Rect&rect = cocos2d::Rect::ZERO);
bool initWithRect(const std::string&, std::vector<cocos2d::Vec2>&, std::vector<unsigned short>&, const cocos2d::Rect&rect = cocos2d::Rect::ZERO);
// //create from ordered list of vertices, with texture rect, Triangles and UV is calculated on the fly
static SpritePolygon *create(const std::string&, std::vector<cocos2d::Vec2>&, const cocos2d::Rect& rect = cocos2d::Rect::ZERO);
bool initWithPoly2tri(const std::string&, std::vector<cocos2d::Vec2>&, const cocos2d::Rect&);
//create from a texture (rect), and automatically trace and optimize the points.
//not recommended for production, its better to use the vec2 list for better performance
static SpritePolygon *create(const std::string&, const cocos2d::Rect& rect = cocos2d::Rect::ZERO, float optimization = -1);
bool initWithMarching(const std::string &file, const cocos2d::Rect &rect, float optimization);
bool initWithCache(const std::string &file, SpritePolygonInfo *info);
bool initWithTexture(cocos2d::Texture2D *texture);
virtual void setTexture(const std::string &filename );
virtual void setTexture(cocos2d::Texture2D *texture);
/** returns the Texture2D object used by the sprite */
virtual cocos2d::Texture2D* getTexture(){return _texture;};
const float getArea();
const ssize_t getTrianglesCount(){return _polygonInfo->_triangles.indexCount/3;};
const ssize_t getVertCount(){return _polygonInfo->_triangles.vertCount;};
void showDebug(const bool val);
protected:
SpritePolygon()
: _debugDrawNode(nullptr)
, _texture(nullptr)
, _polygonInfo(nullptr)
{
}
cocos2d::DrawNode *_debugDrawNode;
void debugDraw();
void calculateUVandContentSize();
cocos2d::TrianglesCommand _tcmd;
cocos2d::BlendFunc _blendFunc;
cocos2d::Texture2D *_texture;
SpritePolygonInfo *_polygonInfo;
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags);
cocos2d::Rect getTextRectFromTriangles(std::vector<cocos2d::V3F_C4B_T2F>& verts);
//======Triangulation
cocos2d::TrianglesCommand::Triangles triangulate(std::vector<cocos2d::Vec2> & verts);
//TODO: move those to ccUtils
};
}
NS_CC_END
#endif // #ifndef COCOS_2D_SpritePolygon_H__

View File

@ -1,231 +0,0 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "SpritePolygonCache.h"
#include "3d/CCMesh.h"
#include "3d/CCMeshVertexIndexData.h"
#include "base/CCDirector.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCTextureCache.h"
#include "renderer/CCGLProgramState.h"
#include "renderer/CCGLProgramCache.h"
#include <vector>
#include "poly2tri/poly2tri.h"
#include "platform/CCFileUtils.h"
using namespace std;
USING_NS_CC;
SpritePolygonCache* SpritePolygonCache::_SpritePolygonCache = nullptr;
SpritePolygonCache::SpritePolygonCache()
{
}
SpritePolygonCache::~SpritePolygonCache()
{
}
SpritePolygonCache* SpritePolygonCache::getInstance()
{
if (NULL == _SpritePolygonCache)
{
_SpritePolygonCache = new (std::nothrow) SpritePolygonCache();
_SpritePolygonCache->init();
}
return _SpritePolygonCache;
}
void SpritePolygonCache::destroyInstance()
{
CC_SAFE_DELETE(_SpritePolygonCache);
}
void SpritePolygonCache::init()
{
}
SpritePolygonInfo* SpritePolygonCache::addSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect, const cocos2d::TrianglesCommand::Triangles trianglesCommand)
{
auto fullpath = filePath;
auto it = _SpritePolygonCacheMap.find(fullpath);
if (_SpritePolygonCacheMap.end() != it)
{
VecSpritePolygonInfo vecInfo = it->second;
auto infoIt = vecInfo.begin();
for (; infoIt != vecInfo.end(); infoIt++)
{
if ((*infoIt)->_rect.equals(rect))
{
//Update
CC_SAFE_DELETE((*infoIt)->_triangles.verts);
CC_SAFE_DELETE((*infoIt)->_triangles.indices);
(*infoIt)->_triangles.verts = new V3F_C4B_T2F[trianglesCommand.vertCount];
(*infoIt)->_triangles.indices = new unsigned short[trianglesCommand.indexCount];
(*infoIt)->_triangles.vertCount = trianglesCommand.vertCount;
(*infoIt)->_triangles.indexCount = trianglesCommand.indexCount;
memcpy((*infoIt)->_triangles.verts, trianglesCommand.verts, trianglesCommand.vertCount*sizeof(V3F_C4B_T2F));
memcpy((*infoIt)->_triangles.indices, trianglesCommand.indices, trianglesCommand.indexCount*sizeof(unsigned short));
return *infoIt;
}
}
}
VecSpritePolygonInfo vecInfo;
vecInfo.clear();
if (it != _SpritePolygonCacheMap.end())
{
vecInfo = it->second;
}
SpritePolygonInfo* info = new SpritePolygonInfo;
if (nullptr != info)
{
info->_rect = rect;
info->_triangles.verts = new V3F_C4B_T2F[trianglesCommand.vertCount];
info->_triangles.indices = new unsigned short[trianglesCommand.indexCount];
info->_triangles.vertCount = trianglesCommand.vertCount;
info->_triangles.indexCount = trianglesCommand.indexCount;
memcpy(info->_triangles.verts, trianglesCommand.verts, trianglesCommand.vertCount*sizeof(V3F_C4B_T2F));
memcpy(info->_triangles.indices, trianglesCommand.indices, trianglesCommand.indexCount*sizeof(unsigned short));
vecInfo.push_back(info);
_SpritePolygonCacheMap[filePath] = vecInfo;
}
return info;
}
SpritePolygonInfo* SpritePolygonCache::getSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect)
{
auto fullpath = filePath;
auto it = _SpritePolygonCacheMap.find(fullpath);
if (_SpritePolygonCacheMap.end() == it)
return nullptr;
auto infoIter = it->second.begin();
for (; infoIter != it->second.end(); infoIter++)
{
if ((*infoIter)->_rect.equals(rect))
return *infoIter;
}
return nullptr;
}
void SpritePolygonCache::removeSpritePolygonCache(const std::string& filePath, const cocos2d::Rect* rect)
{
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filePath);
if (fullpath.size() == 0)
return;
auto it = _SpritePolygonCacheMap.find(fullpath);
if (_SpritePolygonCacheMap.end() == it)
return;
if (nullptr == rect)
return;
auto infoIter = it->second.begin();
for (; infoIter != it->second.end(); infoIter++)
{
if((*infoIter)->_rect.equals(*rect))
{
CC_SAFE_DELETE(*infoIter);
it->second.erase(infoIter);
break;
}
}
return;
}
void SpritePolygonCache::removeAllSpritePolygonCache()
{
for (std::unordered_map<std::string, VecSpritePolygonInfo>::iterator it = _SpritePolygonCacheMap.begin(); it != _SpritePolygonCacheMap.end(); ++it)
{
for (auto infoIter = it->second.begin(); infoIter != it->second.end(); infoIter++)
{
CC_SAFE_DELETE(*infoIter);
}
it->second.clear();
}
_SpritePolygonCacheMap.clear();
}
bool SpritePolygonCache::isSpritePolygonCachExist(const std::string& filePath, const cocos2d::Rect& rect)
{
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filePath);
if (fullpath.size() == 0)
return false;
auto it = _SpritePolygonCacheMap.find(fullpath);
if (_SpritePolygonCacheMap.end() == it)
return false;
auto infoIter = it->second.begin();
for (; infoIter != it->second.end(); infoIter++)
{
if ((*infoIter)->_rect.equals(rect))
return true;
}
return false;
}
void SpritePolygonCache::printInfo(SpritePolygonInfo &info){
CCLOG("========================");
CCLOG("%zd, %zd", info._triangles.vertCount, info._triangles.indexCount);
auto vertEnd = &info._triangles.verts[info._triangles.vertCount];
for(auto v = info._triangles.verts; v < vertEnd; v++)
{
CCLOG("%f, %f", v->vertices.x, v->vertices.y);
}
auto indEnd = &info._triangles.indices[info._triangles.indexCount];
for(auto i = info._triangles.indices; i < indEnd; i+=3)
{
CCLOG("%d, %d, %d,", *i,*(i+1), *(i+2));
}
auto uvEnd = &info._triangles.verts[info._triangles.vertCount];
for(auto v = info._triangles.verts; v < uvEnd; v++)
{
CCLOG("%f, %f", v->texCoords.u, v->texCoords.v);
}
}
USING_NS_CC;

View File

@ -1,85 +0,0 @@
/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef COCOS_2D_SpritePolygonCACHE_H__
#define COCOS_2D_SpritePolygonCACHE_H__
#include <vector>
#include "platform/CCPlatformMacros.h"
#include "2d/CCNode.h"
#include "renderer/CCTrianglesCommand.h"
#include "CCDrawNode.h"
NS_CC_BEGIN
typedef struct CC_DLL _SpritePolygonInfo
{
cocos2d::Rect _rect;
cocos2d::TrianglesCommand::Triangles _triangles;
~_SpritePolygonInfo()
{
if(nullptr != _triangles.verts)
{
CC_SAFE_DELETE_ARRAY(_triangles.verts);
}
if(nullptr != _triangles.indices)
{
CC_SAFE_DELETE_ARRAY(_triangles.indices);
}
}
} SpritePolygonInfo;
typedef std::vector<SpritePolygonInfo*> VecSpritePolygonInfo;
typedef std::unordered_map<std::string, VecSpritePolygonInfo> MapSpritePolygonInfo;
class CC_DLL SpritePolygonCache: public cocos2d::Ref
{
public:
virtual ~SpritePolygonCache();
static SpritePolygonCache* getInstance();
static void destroyInstance();
SpritePolygonInfo* addSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect, const cocos2d::TrianglesCommand::Triangles trianglesCommand);
SpritePolygonInfo* getSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect);
void removeSpritePolygonCache(const std::string& filePath, const cocos2d::Rect* rect = nullptr);
void removeAllSpritePolygonCache();
bool isSpritePolygonCachExist(const std::string& filePath, const cocos2d::Rect& rect);
static void printInfo(SpritePolygonInfo &info);
protected:
SpritePolygonCache();
private:
void init();
private:
static SpritePolygonCache* _SpritePolygonCache;
MapSpritePolygonInfo _SpritePolygonCacheMap;
};
NS_CC_END
#endif // #ifndef COCOS_2D_SpritePolygonCACHE_H__

View File

@ -355,6 +355,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="..\..\extensions\Particle3D\PU\CCPUVortexAffectorTranslator.cpp" /> <ClCompile Include="..\..\extensions\Particle3D\PU\CCPUVortexAffectorTranslator.cpp" />
<ClCompile Include="..\..\extensions\physics-nodes\CCPhysicsDebugNode.cpp" /> <ClCompile Include="..\..\extensions\physics-nodes\CCPhysicsDebugNode.cpp" />
<ClCompile Include="..\..\extensions\physics-nodes\CCPhysicsSprite.cpp" /> <ClCompile Include="..\..\extensions\physics-nodes\CCPhysicsSprite.cpp" />
<ClCompile Include="..\..\external\clipper\clipper.cpp" />
<ClCompile Include="..\..\external\ConvertUTF\ConvertUTF.c" /> <ClCompile Include="..\..\external\ConvertUTF\ConvertUTF.c" />
<ClCompile Include="..\..\external\ConvertUTF\ConvertUTFWrapper.cpp" /> <ClCompile Include="..\..\external\ConvertUTF\ConvertUTFWrapper.cpp" />
<ClCompile Include="..\..\external\edtaa3func\edtaa3func.cpp" /> <ClCompile Include="..\..\external\edtaa3func\edtaa3func.cpp" />
@ -668,6 +669,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="CCAnimation.cpp" /> <ClCompile Include="CCAnimation.cpp" />
<ClCompile Include="CCAnimationCache.cpp" /> <ClCompile Include="CCAnimationCache.cpp" />
<ClCompile Include="CCAtlasNode.cpp" /> <ClCompile Include="CCAtlasNode.cpp" />
<ClCompile Include="CCAutoPolygon.cpp" />
<ClCompile Include="CCCamera.cpp" /> <ClCompile Include="CCCamera.cpp" />
<ClCompile Include="CCClippingNode.cpp" /> <ClCompile Include="CCClippingNode.cpp" />
<ClCompile Include="CCClippingRectangleNode.cpp" /> <ClCompile Include="CCClippingRectangleNode.cpp" />
@ -721,9 +723,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="CCTransitionPageTurn.cpp" /> <ClCompile Include="CCTransitionPageTurn.cpp" />
<ClCompile Include="CCTransitionProgress.cpp" /> <ClCompile Include="CCTransitionProgress.cpp" />
<ClCompile Include="CCTweenFunction.cpp" /> <ClCompile Include="CCTweenFunction.cpp" />
<ClCompile Include="MarchingSquare.cpp" />
<ClCompile Include="SpritePolygon.cpp" />
<ClCompile Include="SpritePolygonCache.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\extensions\assets-manager\AssetsManager.h" /> <ClInclude Include="..\..\extensions\assets-manager\AssetsManager.h" />
@ -903,6 +902,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\..\extensions\Particle3D\PU\CCPUVortexAffectorTranslator.h" /> <ClInclude Include="..\..\extensions\Particle3D\PU\CCPUVortexAffectorTranslator.h" />
<ClInclude Include="..\..\extensions\physics-nodes\CCPhysicsDebugNode.h" /> <ClInclude Include="..\..\extensions\physics-nodes\CCPhysicsDebugNode.h" />
<ClInclude Include="..\..\extensions\physics-nodes\CCPhysicsSprite.h" /> <ClInclude Include="..\..\extensions\physics-nodes\CCPhysicsSprite.h" />
<ClInclude Include="..\..\external\clipper\clipper.hpp" />
<ClInclude Include="..\..\external\ConvertUTF\ConvertUTF.h" /> <ClInclude Include="..\..\external\ConvertUTF\ConvertUTF.h" />
<ClInclude Include="..\..\external\edtaa3func\edtaa3func.h" /> <ClInclude Include="..\..\external\edtaa3func\edtaa3func.h" />
<ClInclude Include="..\..\external\flatbuffers\flatbuffers.h" /> <ClInclude Include="..\..\external\flatbuffers\flatbuffers.h" />
@ -1275,6 +1275,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="CCAnimation.h" /> <ClInclude Include="CCAnimation.h" />
<ClInclude Include="CCAnimationCache.h" /> <ClInclude Include="CCAnimationCache.h" />
<ClInclude Include="CCAtlasNode.h" /> <ClInclude Include="CCAtlasNode.h" />
<ClInclude Include="CCAutoPolygon.h" />
<ClInclude Include="CCCamera.h" /> <ClInclude Include="CCCamera.h" />
<ClInclude Include="CCClippingNode.h" /> <ClInclude Include="CCClippingNode.h" />
<ClInclude Include="CCClippingRectangleNode.h" /> <ClInclude Include="CCClippingRectangleNode.h" />
@ -1328,9 +1329,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="CCTransitionPageTurn.h" /> <ClInclude Include="CCTransitionPageTurn.h" />
<ClInclude Include="CCTransitionProgress.h" /> <ClInclude Include="CCTransitionProgress.h" />
<ClInclude Include="CCTweenFunction.h" /> <ClInclude Include="CCTweenFunction.h" />
<ClInclude Include="MarchingSquare.h" />
<ClInclude Include="SpritePolygon.h" />
<ClInclude Include="SpritePolygonCache.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\3d\CCAnimationCurve.inl" /> <None Include="..\3d\CCAnimationCurve.inl" />

View File

@ -271,6 +271,8 @@
<Filter Include="physics3d"> <Filter Include="physics3d">
<UniqueIdentifier>{e492faef-2169-4117-8d73-e0c66271fe25}</UniqueIdentifier> <UniqueIdentifier>{e492faef-2169-4117-8d73-e0c66271fe25}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="external\clipper">
<UniqueIdentifier>{ff65e340-b79d-4f87-9b4c-ed46bda5d20f}</UniqueIdentifier>
<Filter Include="navmesh"> <Filter Include="navmesh">
<UniqueIdentifier>{0f3fa25d-9e2b-4a2e-a1df-834b796b3fb3}</UniqueIdentifier> <UniqueIdentifier>{0f3fa25d-9e2b-4a2e-a1df-834b796b3fb3}</UniqueIdentifier>
</Filter> </Filter>
@ -1824,15 +1826,6 @@
<ClCompile Include="..\..\external\poly2tri\sweep\sweep_context.cc"> <ClCompile Include="..\..\external\poly2tri\sweep\sweep_context.cc">
<Filter>external\poly2tri\sweep</Filter> <Filter>external\poly2tri\sweep</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="MarchingSquare.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="SpritePolygon.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="SpritePolygonCache.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\physics3d\CCPhysics3D.cpp"> <ClCompile Include="..\physics3d\CCPhysics3D.cpp">
<Filter>physics3d</Filter> <Filter>physics3d</Filter>
</ClCompile> </ClCompile>
@ -1897,6 +1890,12 @@
<ClCompile Include="..\renderer\CCFrameBuffer.cpp"> <ClCompile Include="..\renderer\CCFrameBuffer.cpp">
<Filter>renderer</Filter> <Filter>renderer</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="CCAutoPolygon.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\..\external\clipper\clipper.cpp">
<Filter>external\clipper</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\physics\CCPhysicsBody.h"> <ClInclude Include="..\physics\CCPhysicsBody.h">
@ -3636,15 +3635,6 @@
<ClInclude Include="..\..\external\poly2tri\sweep\sweep_context.h"> <ClInclude Include="..\..\external\poly2tri\sweep\sweep_context.h">
<Filter>external\poly2tri\sweep</Filter> <Filter>external\poly2tri\sweep</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="MarchingSquare.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="SpritePolygon.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="SpritePolygonCache.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\physics3d\CCPhysics3D.h"> <ClInclude Include="..\physics3d\CCPhysics3D.h">
<Filter>physics3d</Filter> <Filter>physics3d</Filter>
</ClInclude> </ClInclude>
@ -3709,6 +3699,12 @@
<ClInclude Include="..\renderer\CCFrameBuffer.h"> <ClInclude Include="..\renderer\CCFrameBuffer.h">
<Filter>renderer</Filter> <Filter>renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="CCAutoPolygon.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\..\external\clipper\clipper.hpp">
<Filter>external\clipper</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\math\Mat4.inl"> <None Include="..\math\Mat4.inl">

View File

@ -191,6 +191,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\Particle3D\PU\CCPUVortexAffectorTranslator.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\Particle3D\PU\CCPUVortexAffectorTranslator.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\physics-nodes\CCPhysicsDebugNode.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\physics-nodes\CCPhysicsDebugNode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\physics-nodes\CCPhysicsSprite.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\physics-nodes\CCPhysicsSprite.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\clipper\clipper.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\ConvertUTF\ConvertUTF.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\ConvertUTF\ConvertUTF.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\edtaa3func\edtaa3func.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\edtaa3func\edtaa3func.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\flatbuffers\flatbuffers.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\flatbuffers\flatbuffers.h" />
@ -572,6 +573,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimation.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimation.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimationCache.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimationCache.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAtlasNode.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAtlasNode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAutoPolygon.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCCamera.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCCamera.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingNode.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingNode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingRectangleNode.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingRectangleNode.h" />
@ -625,9 +627,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCTransitionPageTurn.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCTransitionPageTurn.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCTransitionProgress.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCTransitionProgress.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCTweenFunction.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCTweenFunction.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\MarchingSquare.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\SpritePolygon.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\SpritePolygonCache.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)targetver.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -804,6 +803,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\Particle3D\PU\CCPUVortexAffectorTranslator.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\Particle3D\PU\CCPUVortexAffectorTranslator.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\physics-nodes\CCPhysicsDebugNode.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\physics-nodes\CCPhysicsDebugNode.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\physics-nodes\CCPhysicsSprite.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\extensions\physics-nodes\CCPhysicsSprite.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\clipper\clipper.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\ConvertUTF\ConvertUTF.c"> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\ConvertUTF\ConvertUTF.c">
<CompileAs>CompileAsCpp</CompileAs> <CompileAs>CompileAsCpp</CompileAs>
</ClCompile> </ClCompile>
@ -1157,6 +1157,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimation.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimation.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimationCache.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimationCache.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAtlasNode.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAtlasNode.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAutoPolygon.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCCamera.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCCamera.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingNode.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingNode.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingRectangleNode.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingRectangleNode.cpp" />
@ -1210,9 +1211,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCTransitionPageTurn.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCTransitionPageTurn.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCTransitionProgress.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCTransitionProgress.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCTweenFunction.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCTweenFunction.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\MarchingSquare.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\SpritePolygon.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\SpritePolygonCache.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectCapability Include="SourceItemsFromImports" /> <ProjectCapability Include="SourceItemsFromImports" />

View File

@ -1743,9 +1743,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\WICImageLoader-winrt.h"> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\WICImageLoader-winrt.h">
<Filter>platform\winrt</Filter> <Filter>platform\winrt</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\MarchingSquare.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\poly2tri\common\shapes.h"> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\poly2tri\common\shapes.h">
<Filter>external\poly2tri\common</Filter> <Filter>external\poly2tri\common</Filter>
</ClInclude> </ClInclude>
@ -1767,12 +1764,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\poly2tri\poly2tri.h"> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\poly2tri\poly2tri.h">
<Filter>external\poly2tri</Filter> <Filter>external\poly2tri</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\SpritePolygon.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\SpritePolygonCache.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\CCRenderState.h"> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\CCRenderState.h">
<Filter>renderer</Filter> <Filter>renderer</Filter>
</ClInclude> </ClInclude>
@ -1845,6 +1836,8 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysicsSprite3D.h"> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics3d\CCPhysicsSprite3D.h">
<Filter>physics3d</Filter> <Filter>physics3d</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\clipper\clipper.hpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAutoPolygon.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos2d.cpp"> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos2d.cpp">
@ -3415,9 +3408,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\WICImageLoader-winrt.cpp"> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\WICImageLoader-winrt.cpp">
<Filter>platform\winrt</Filter> <Filter>platform\winrt</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\MarchingSquare.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\poly2tri\common\shapes.cc"> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\poly2tri\common\shapes.cc">
<Filter>external\poly2tri\common</Filter> <Filter>external\poly2tri\common</Filter>
</ClCompile> </ClCompile>
@ -3433,12 +3423,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\poly2tri\sweep\sweep_context.cc"> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\poly2tri\sweep\sweep_context.cc">
<Filter>external\poly2tri\sweep</Filter> <Filter>external\poly2tri\sweep</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\SpritePolygon.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\SpritePolygonCache.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\CCRenderState.cpp"> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\CCRenderState.cpp">
<Filter>renderer</Filter> <Filter>renderer</Filter>
</ClCompile> </ClCompile>
@ -3517,6 +3501,8 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCUserDefault-winrt.cpp"> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCUserDefault-winrt.cpp">
<Filter>base</Filter> <Filter>base</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\clipper\clipper.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAutoPolygon.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="2d"> <Filter Include="2d">
@ -3774,6 +3760,9 @@
<Filter Include="external\poly2tri\sweep"> <Filter Include="external\poly2tri\sweep">
<UniqueIdentifier>{932c5f6e-07b3-4b34-97ae-2f3d42024149}</UniqueIdentifier> <UniqueIdentifier>{932c5f6e-07b3-4b34-97ae-2f3d42024149}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="external\clipper">
<UniqueIdentifier>{37ad3bdd-733d-46e4-b28d-b350521e6f54}</UniqueIdentifier>
</Filter>
<Filter Include="audio"> <Filter Include="audio">
<UniqueIdentifier>{f1c7e21a-6d78-44ba-9480-d7ba197c7b42}</UniqueIdentifier> <UniqueIdentifier>{f1c7e21a-6d78-44ba-9480-d7ba197c7b42}</UniqueIdentifier>
</Filter> </Filter>

View File

@ -230,7 +230,7 @@ void BillBoard::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{ {
//FIXME: frustum culling here //FIXME: frustum culling here
flags |= Node::FLAGS_RENDER_AS_3D; flags |= Node::FLAGS_RENDER_AS_3D;
_trianglesCommand.init(0, _texture->getName(), getGLProgramState(), _blendFunc, getRenderedTriangles(), _modelViewTransform, flags); _trianglesCommand.init(0, _texture->getName(), getGLProgramState(), _blendFunc, _polyInfo.triangles, _modelViewTransform, flags);
_trianglesCommand.setTransparent(true); _trianglesCommand.setTransparent(true);
_trianglesCommand.set3D(true); _trianglesCommand.set3D(true);
renderer->addCommand(&_trianglesCommand); renderer->addCommand(&_trianglesCommand);

View File

@ -613,9 +613,10 @@ void Mesh::setLightUniforms(Pass* pass, Scene* scene, const Vec4& color, unsigne
if (hasAmbient) if (hasAmbient)
{ {
ambient.x /= 255.f; ambient.y /= 255.f; ambient.z /= 255.f; ambient.x /= 255.f; ambient.y /= 255.f; ambient.z /= 255.f;
} //override the uniform value of u_color using the calculated color
glProgramState->setUniformVec4("u_color", Vec4(color.x * ambient.x, color.y * ambient.y, color.z * ambient.z, color.w)); glProgramState->setUniformVec4("u_color", Vec4(color.x * ambient.x, color.y * ambient.y, color.z * ambient.z, color.w));
} }
}
} }
void Mesh::setBlendFunc(const BlendFunc &blendFunc) void Mesh::setBlendFunc(const BlendFunc &blendFunc)

View File

@ -159,11 +159,9 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
if(_isCameraViewChanged ) if(_isCameraViewChanged )
{ {
auto camPos = camera->getPosition3D(); auto m = camera->getNodeToWorldTransform();
auto camModelMat = camera->getNodeToWorldTransform();
camModelMat.transformPoint(&camPos);
//set lod //set lod
setChunksLOD(camPos); setChunksLOD(Vec3(m.m[12], m.m[13], m.m[14]));
} }
if(_isCameraViewChanged ) if(_isCameraViewChanged )
@ -265,7 +263,7 @@ void Terrain::setChunksLOD(Vec3 cameraPos)
{ {
AABB aabb = _chunkesArray[m][n]->_parent->_worldSpaceAABB; AABB aabb = _chunkesArray[m][n]->_parent->_worldSpaceAABB;
auto center = aabb.getCenter(); auto center = aabb.getCenter();
float dist = Vec3(center.x,0,center.z).distance(Vec3(cameraPos.x,0,cameraPos.z)); float dist = Vec2(center.x, center.z).distance(Vec2(cameraPos.x, cameraPos.z));
_chunkesArray[m][n]->_currentLod = 3; _chunkesArray[m][n]->_currentLod = 3;
for(int i =0;i<3;i++) for(int i =0;i<3;i++)
{ {

View File

@ -83,9 +83,7 @@ cocos2d.cpp \
2d/CCTransitionPageTurn.cpp \ 2d/CCTransitionPageTurn.cpp \
2d/CCTransitionProgress.cpp \ 2d/CCTransitionProgress.cpp \
2d/CCTweenFunction.cpp \ 2d/CCTweenFunction.cpp \
2d/MarchingSquare.cpp \ 2d/CCAutoPolygon.cpp \
2d/SpritePolygon.cpp \
2d/SpritePolygonCache.cpp \
3d/CCFrustum.cpp \ 3d/CCFrustum.cpp \
3d/CCPlane.cpp \ 3d/CCPlane.cpp \
platform/CCFileUtils.cpp \ platform/CCFileUtils.cpp \
@ -221,7 +219,8 @@ navmesh/CCNavMeshUtils.cpp \
../external/poly2tri/sweep/advancing_front.cc \ ../external/poly2tri/sweep/advancing_front.cc \
../external/poly2tri/sweep/cdt.cc \ ../external/poly2tri/sweep/cdt.cc \
../external/poly2tri/sweep/sweep_context.cc \ ../external/poly2tri/sweep/sweep_context.cc \
../external/poly2tri/sweep/sweep.cc ../external/poly2tri/sweep/sweep.cc \
../external/clipper/clipper.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
@ -237,7 +236,8 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../external/nslog \ $(LOCAL_PATH)/../external/nslog \
$(LOCAL_PATH)/../external/poly2tri \ $(LOCAL_PATH)/../external/poly2tri \
$(LOCAL_PATH)/../external/poly2tri/common \ $(LOCAL_PATH)/../external/poly2tri/common \
$(LOCAL_PATH)/../external/poly2tri/sweep $(LOCAL_PATH)/../external/poly2tri/sweep \
$(LOCAL_PATH)/../external/clipper
LOCAL_C_INCLUDES := $(LOCAL_PATH) \ LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/platform \ $(LOCAL_PATH)/platform \
@ -251,7 +251,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../external/nslog \ $(LOCAL_PATH)/../external/nslog \
$(LOCAL_PATH)/../external/poly2tri \ $(LOCAL_PATH)/../external/poly2tri \
$(LOCAL_PATH)/../external/poly2tri/common \ $(LOCAL_PATH)/../external/poly2tri/common \
$(LOCAL_PATH)/../external/poly2tri/sweep $(LOCAL_PATH)/../external/poly2tri/sweep \
$(LOCAL_PATH)/../external/clipper
LOCAL_EXPORT_LDLIBS := -lGLESv2 \ LOCAL_EXPORT_LDLIBS := -lGLESv2 \
-llog \ -llog \

View File

@ -84,6 +84,7 @@ set(COCOS_SRC cocos2d.cpp
#todo: provide prebuild versions of the xx libs for all platforms #todo: provide prebuild versions of the xx libs for all platforms
include_directories(../external/xxtea) include_directories(../external/xxtea)
include_directories(../external/clipper)
add_library(cocos2d ${COCOS_SRC}) add_library(cocos2d ${COCOS_SRC})

View File

@ -254,6 +254,7 @@ THE SOFTWARE.
#include "2d/CCAnimation.h" #include "2d/CCAnimation.h"
#include "2d/CCAnimationCache.h" #include "2d/CCAnimationCache.h"
#include "2d/CCSprite.h" #include "2d/CCSprite.h"
#include "2d/CCAutoPolygon.h"
#include "2d/CCSpriteBatchNode.h" #include "2d/CCSpriteBatchNode.h"
#include "2d/CCSpriteFrame.h" #include "2d/CCSpriteFrame.h"
#include "2d/CCSpriteFrameCache.h" #include "2d/CCSpriteFrameCache.h"

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Copyright (c) 2013-2014 Chukong Technologies

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2015 cocos2d-x.org Copyright (c) 2015 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
#ifndef __CCCOCOSSTUDIO_H__ #ifndef __CCCOCOSSTUDIO_H__
#define __CCCOCOSSTUDIO_H__ #define __CCCOCOSSTUDIO_H__
#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8) #if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8)

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013 cocos2d-x.org Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc. Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2014 cocos2d-x.org Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org http://www.cocos2d-x.org

Some files were not shown because too many files have changed in this diff Show More