mirror of https://github.com/axmolengine/axmol.git
Merge pull request #40 from chuanweizhang2013/v3luaruntime
modify save file format
This commit is contained in:
commit
b5965c68e4
11
AUTHORS
11
AUTHORS
|
@ -752,7 +752,9 @@ Developers:
|
|||
|
||||
hanjukim
|
||||
Fixed a bug that color and opacity settings were not applied when invoking Label::alignText.
|
||||
|
||||
Fixed the bug that FileUtils:getStringFromFile() may return a unterminated string
|
||||
Skip BOM in DataReaderHelper::addDataFromJsonCache()
|
||||
|
||||
bagobor
|
||||
Fixed a memory leak in AssetsManager::uncompress.
|
||||
Code format fix and small optimizations in cocostudio/CCActionNode.cpp.
|
||||
|
@ -888,6 +890,13 @@ Developers:
|
|||
|
||||
Rumist
|
||||
Fix the bug that the result of Director->convertToUI() is error.
|
||||
|
||||
kyokomi
|
||||
Fix the bug that UIButton doesn't support TTF font
|
||||
Fix a but of TextReader
|
||||
|
||||
gin0606
|
||||
Add a new line at the end of a file
|
||||
|
||||
Retired Core Developers:
|
||||
WenSheng Yang
|
||||
|
|
19
CHANGELOG
19
CHANGELOG
|
@ -1,4 +1,17 @@
|
|||
cocos2d-x-3.2 ???
|
||||
cocos2d-x-3.2 ???
|
||||
[NEW] Label: support setting line height and additional kerning of label that not using system font
|
||||
[NEW] Lua-binding: Animation3D supported
|
||||
[NEW] Node: added getName(), setName(), getChildByName(), enumerateChildren()
|
||||
[NEW] Node: physical body supports rotation
|
||||
|
||||
|
||||
[FIX] FileUtils: getStringFromFile may return a unterminated string
|
||||
[FIX] Lua-binding: Sequence:create will cause drop-dead issue
|
||||
[FIX] Studio support: NodeReader may cause crash
|
||||
[FIX] UIButton: doesn't support TTF font
|
||||
[FIX] UIListView: addEventListener can not work
|
||||
|
||||
cocos2d-x-3.2-alpha0 Jun.17 2014
|
||||
[NEW] Console: add a command to show engine version
|
||||
[NEW] Node: added setter/getter for NormalizedPosition(). Allows to set positions in normalized values (between 0 and 1)
|
||||
[NEW] Scene: Added createWithSize() method
|
||||
|
@ -6,6 +19,8 @@ cocos2d-x-3.2 ???
|
|||
[NEW] TextureCache: added unbindImageAsync() and unbindAllImageAsync()
|
||||
[NEW] utils: added captureScreen()
|
||||
[NEW] UIText: added shadow, outline, glow filter support
|
||||
[NEW] Sprite3D: support 3d animation
|
||||
[NEW] Animation3D: 3d animation
|
||||
|
||||
[FIX] Application.mk: not output debug message in release mode on Android
|
||||
[FIX] Android: 3d model will be black when coming from background
|
||||
|
@ -37,8 +52,10 @@ cocos2d-x-3.2 ???
|
|||
[FIX] WP8: will restart if app goes to background, then touches icon to go to foreground
|
||||
[FIX] WP8: will be black if: 1. 3rd pops up a view; 2. go to background; 3. come to foreground
|
||||
[FIX] WP8: project name of new project created by console is wrong
|
||||
[FIX] WP8: missing texture after app switch
|
||||
|
||||
[3RD] curl: will crash if use https request on iOS simulator
|
||||
[3RD] curl: update OpenSSL to v1.0.1h
|
||||
|
||||
cocos2d-x-3.1.1 May.31 2014
|
||||
[FIX] GLProgramState: restores states after coming from background
|
||||
|
|
|
@ -100,6 +100,8 @@ endif()
|
|||
if(MINGW)
|
||||
add_definitions(-DGLEW_STATIC)
|
||||
add_definitions(-D__SSIZE_T)
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lws2_32")
|
||||
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lws2_32")
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,28 @@
|
|||
/* End PBXAggregateTarget section */
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0634A4D0194B19E400E608AF /* CCActionTimeline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C5194B19E400E608AF /* CCActionTimeline.cpp */; };
|
||||
0634A4D1194B19E400E608AF /* CCActionTimeline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C5194B19E400E608AF /* CCActionTimeline.cpp */; };
|
||||
0634A4D2194B19E400E608AF /* CCActionTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4C6194B19E400E608AF /* CCActionTimeline.h */; };
|
||||
0634A4D3194B19E400E608AF /* CCActionTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4C6194B19E400E608AF /* CCActionTimeline.h */; };
|
||||
0634A4D4194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C7194B19E400E608AF /* CCActionTimelineCache.cpp */; };
|
||||
0634A4D5194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C7194B19E400E608AF /* CCActionTimelineCache.cpp */; };
|
||||
0634A4D6194B19E400E608AF /* CCActionTimelineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4C8194B19E400E608AF /* CCActionTimelineCache.h */; };
|
||||
0634A4D7194B19E400E608AF /* CCActionTimelineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4C8194B19E400E608AF /* CCActionTimelineCache.h */; };
|
||||
0634A4D8194B19E400E608AF /* CCFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C9194B19E400E608AF /* CCFrame.cpp */; };
|
||||
0634A4D9194B19E400E608AF /* CCFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4C9194B19E400E608AF /* CCFrame.cpp */; };
|
||||
0634A4DA194B19E400E608AF /* CCFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CA194B19E400E608AF /* CCFrame.h */; };
|
||||
0634A4DB194B19E400E608AF /* CCFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CA194B19E400E608AF /* CCFrame.h */; };
|
||||
0634A4DC194B19E400E608AF /* CCNodeReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4CB194B19E400E608AF /* CCNodeReader.cpp */; };
|
||||
0634A4DD194B19E400E608AF /* CCNodeReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4CB194B19E400E608AF /* CCNodeReader.cpp */; };
|
||||
0634A4DE194B19E400E608AF /* CCNodeReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CC194B19E400E608AF /* CCNodeReader.h */; };
|
||||
0634A4DF194B19E400E608AF /* CCNodeReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CC194B19E400E608AF /* CCNodeReader.h */; };
|
||||
0634A4E0194B19E400E608AF /* CCTimeLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4CD194B19E400E608AF /* CCTimeLine.cpp */; };
|
||||
0634A4E1194B19E400E608AF /* CCTimeLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0634A4CD194B19E400E608AF /* CCTimeLine.cpp */; };
|
||||
0634A4E2194B19E400E608AF /* CCTimeLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CE194B19E400E608AF /* CCTimeLine.h */; };
|
||||
0634A4E3194B19E400E608AF /* CCTimeLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CE194B19E400E608AF /* CCTimeLine.h */; };
|
||||
0634A4E4194B19E400E608AF /* CCTimelineMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CF194B19E400E608AF /* CCTimelineMacro.h */; };
|
||||
0634A4E5194B19E400E608AF /* CCTimelineMacro.h in Headers */ = {isa = PBXBuildFile; fileRef = 0634A4CF194B19E400E608AF /* CCTimelineMacro.h */; };
|
||||
06CAAAC5186AD7E50012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; };
|
||||
06CAAAC6186AD7E60012A414 /* TriggerObj.h in Headers */ = {isa = PBXBuildFile; fileRef = 06CAAAC1186AD63B0012A414 /* TriggerObj.h */; };
|
||||
06CAAAC7186AD7E90012A414 /* TriggerObj.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 06CAAAC0186AD63B0012A414 /* TriggerObj.cpp */; };
|
||||
|
@ -977,6 +999,10 @@
|
|||
29CB8F4D1929D1BB00C841D6 /* UILayoutManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */; };
|
||||
29CB8F4E1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; };
|
||||
29CB8F4F1929D1BB00C841D6 /* UILayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */; };
|
||||
29E99D1E1957BA7000046604 /* CocoLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29E99D1C1957BA7000046604 /* CocoLoader.cpp */; };
|
||||
29E99D1F1957BA7000046604 /* CocoLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29E99D1C1957BA7000046604 /* CocoLoader.cpp */; };
|
||||
29E99D201957BA7000046604 /* CocoLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E99D1D1957BA7000046604 /* CocoLoader.h */; };
|
||||
29E99D211957BA7000046604 /* CocoLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E99D1D1957BA7000046604 /* CocoLoader.h */; };
|
||||
2AC795DB1862870F005EC8E1 /* SkeletonBounds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D918628689005EC8E1 /* SkeletonBounds.cpp */; };
|
||||
2AC795DC1862870F005EC8E1 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D51862867D005EC8E1 /* Event.cpp */; };
|
||||
2AC795DD1862870F005EC8E1 /* EventData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D71862867D005EC8E1 /* EventData.cpp */; };
|
||||
|
@ -1741,10 +1767,12 @@
|
|||
B29594CB1926D61F003EEF37 /* CCSprite3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BD1926D61F003EEF37 /* CCSprite3D.cpp */; };
|
||||
B29594CC1926D61F003EEF37 /* CCSprite3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594BE1926D61F003EEF37 /* CCSprite3D.h */; };
|
||||
B29594CD1926D61F003EEF37 /* CCSprite3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594BE1926D61F003EEF37 /* CCSprite3D.h */; };
|
||||
B29594CE1926D61F003EEF37 /* CCSprite3DDataCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BF1926D61F003EEF37 /* CCSprite3DDataCache.cpp */; };
|
||||
B29594CF1926D61F003EEF37 /* CCSprite3DDataCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BF1926D61F003EEF37 /* CCSprite3DDataCache.cpp */; };
|
||||
B29594D01926D61F003EEF37 /* CCSprite3DDataCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594C01926D61F003EEF37 /* CCSprite3DDataCache.h */; };
|
||||
B29594D11926D61F003EEF37 /* CCSprite3DDataCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594C01926D61F003EEF37 /* CCSprite3DDataCache.h */; };
|
||||
B29594CE1926D61F003EEF37 /* CCSprite3DMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BF1926D61F003EEF37 /* CCSprite3DMaterial.cpp */; };
|
||||
B29594CF1926D61F003EEF37 /* CCSprite3DMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BF1926D61F003EEF37 /* CCSprite3DMaterial.cpp */; };
|
||||
B29594D01926D61F003EEF37 /* CCSprite3DMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594C01926D61F003EEF37 /* CCSprite3DMaterial.h */; };
|
||||
B29594D11926D61F003EEF37 /* CCSprite3DMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594C01926D61F003EEF37 /* CCSprite3DMaterial.h */; };
|
||||
B2D3D3B91948613300BA4831 /* CCBundle3DData.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3D3B81948613300BA4831 /* CCBundle3DData.h */; };
|
||||
B2D3D3BA1948613300BA4831 /* CCBundle3DData.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3D3B81948613300BA4831 /* CCBundle3DData.h */; };
|
||||
B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */; };
|
||||
B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */; };
|
||||
B37510731823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */; };
|
||||
|
@ -1773,6 +1801,24 @@
|
|||
B3AF01A31842FBA400A98B85 /* b2MotorJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */; };
|
||||
B3B12A5A17E7F44000026B4A /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A03F2CB81780BD04006731B9 /* libchipmunk Mac.a */; };
|
||||
B3B12A5B17E7F45C00026B4A /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A07A4F3B178387670073F6A7 /* libchipmunk iOS.a */; };
|
||||
B6AAF84119404E0D0069DE01 /* CCBundle3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6AAF83F19404E0D0069DE01 /* CCBundle3D.cpp */; };
|
||||
B6AAF84219404E0D0069DE01 /* CCBundle3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6AAF83F19404E0D0069DE01 /* CCBundle3D.cpp */; };
|
||||
B6AAF84319404E0D0069DE01 /* CCBundle3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6AAF84019404E0D0069DE01 /* CCBundle3D.h */; };
|
||||
B6AAF84419404E0D0069DE01 /* CCBundle3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6AAF84019404E0D0069DE01 /* CCBundle3D.h */; };
|
||||
B6ACD897193D6693005E0B8A /* CCMeshSkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6ACD895193D6693005E0B8A /* CCMeshSkin.cpp */; };
|
||||
B6ACD898193D6693005E0B8A /* CCMeshSkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6ACD895193D6693005E0B8A /* CCMeshSkin.cpp */; };
|
||||
B6ACD899193D6693005E0B8A /* CCMeshSkin.h in Headers */ = {isa = PBXBuildFile; fileRef = B6ACD896193D6693005E0B8A /* CCMeshSkin.h */; };
|
||||
B6ACD89A193D6693005E0B8A /* CCMeshSkin.h in Headers */ = {isa = PBXBuildFile; fileRef = B6ACD896193D6693005E0B8A /* CCMeshSkin.h */; };
|
||||
B6ACD89E193DC0CC005E0B8A /* CCAnimate3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6ACD89C193DC0CC005E0B8A /* CCAnimate3D.cpp */; };
|
||||
B6ACD89F193DC0CC005E0B8A /* CCAnimate3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6ACD89C193DC0CC005E0B8A /* CCAnimate3D.cpp */; };
|
||||
B6ACD8A0193DC0CC005E0B8A /* CCAnimate3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6ACD89D193DC0CC005E0B8A /* CCAnimate3D.h */; };
|
||||
B6ACD8A1193DC0CC005E0B8A /* CCAnimate3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6ACD89D193DC0CC005E0B8A /* CCAnimate3D.h */; };
|
||||
B6B2633F19381FBF0088FE25 /* CCAnimationCurve.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B2633C19381FBF0088FE25 /* CCAnimationCurve.h */; };
|
||||
B6B2634019381FBF0088FE25 /* CCAnimationCurve.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B2633C19381FBF0088FE25 /* CCAnimationCurve.h */; };
|
||||
B6B26343193884D60088FE25 /* CCAnimation3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6B26341193884D60088FE25 /* CCAnimation3D.cpp */; };
|
||||
B6B26344193884D60088FE25 /* CCAnimation3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6B26341193884D60088FE25 /* CCAnimation3D.cpp */; };
|
||||
B6B26345193884D60088FE25 /* CCAnimation3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B26342193884D60088FE25 /* CCAnimation3D.h */; };
|
||||
B6B26346193884D60088FE25 /* CCAnimation3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B26342193884D60088FE25 /* CCAnimation3D.h */; };
|
||||
ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; };
|
||||
ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; };
|
||||
ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; };
|
||||
|
@ -1867,6 +1913,17 @@
|
|||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0634A4C5194B19E400E608AF /* CCActionTimeline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTimeline.cpp; sourceTree = "<group>"; };
|
||||
0634A4C6194B19E400E608AF /* CCActionTimeline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTimeline.h; sourceTree = "<group>"; };
|
||||
0634A4C7194B19E400E608AF /* CCActionTimelineCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCActionTimelineCache.cpp; sourceTree = "<group>"; };
|
||||
0634A4C8194B19E400E608AF /* CCActionTimelineCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTimelineCache.h; sourceTree = "<group>"; };
|
||||
0634A4C9194B19E400E608AF /* CCFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCFrame.cpp; sourceTree = "<group>"; };
|
||||
0634A4CA194B19E400E608AF /* CCFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFrame.h; sourceTree = "<group>"; };
|
||||
0634A4CB194B19E400E608AF /* CCNodeReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCNodeReader.cpp; sourceTree = "<group>"; };
|
||||
0634A4CC194B19E400E608AF /* CCNodeReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeReader.h; sourceTree = "<group>"; };
|
||||
0634A4CD194B19E400E608AF /* CCTimeLine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTimeLine.cpp; sourceTree = "<group>"; };
|
||||
0634A4CE194B19E400E608AF /* CCTimeLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTimeLine.h; sourceTree = "<group>"; };
|
||||
0634A4CF194B19E400E608AF /* CCTimelineMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTimelineMacro.h; sourceTree = "<group>"; };
|
||||
06CAAABC186AD63B0012A414 /* TriggerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerBase.cpp; sourceTree = "<group>"; };
|
||||
06CAAABD186AD63B0012A414 /* TriggerBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerBase.h; sourceTree = "<group>"; };
|
||||
06CAAABE186AD63B0012A414 /* TriggerMng.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerMng.cpp; sourceTree = "<group>"; };
|
||||
|
@ -2256,6 +2313,8 @@
|
|||
299754F3193EC95400A54AC3 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjectFactory.h; path = ../base/ObjectFactory.h; sourceTree = "<group>"; };
|
||||
29CB8F4A1929D1BB00C841D6 /* UILayoutManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutManager.cpp; sourceTree = "<group>"; };
|
||||
29CB8F4B1929D1BB00C841D6 /* UILayoutManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutManager.h; sourceTree = "<group>"; };
|
||||
29E99D1C1957BA7000046604 /* CocoLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CocoLoader.cpp; sourceTree = "<group>"; };
|
||||
29E99D1D1957BA7000046604 /* CocoLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoLoader.h; sourceTree = "<group>"; };
|
||||
2AC795D318628672005EC8E1 /* BoundingBoxAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoundingBoxAttachment.cpp; sourceTree = "<group>"; };
|
||||
2AC795D418628672005EC8E1 /* BoundingBoxAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoundingBoxAttachment.h; sourceTree = "<group>"; };
|
||||
2AC795D51862867D005EC8E1 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = "<group>"; };
|
||||
|
@ -2792,8 +2851,9 @@
|
|||
B29594BC1926D61F003EEF37 /* CCObjLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCObjLoader.h; sourceTree = "<group>"; };
|
||||
B29594BD1926D61F003EEF37 /* CCSprite3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSprite3D.cpp; sourceTree = "<group>"; };
|
||||
B29594BE1926D61F003EEF37 /* CCSprite3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSprite3D.h; sourceTree = "<group>"; };
|
||||
B29594BF1926D61F003EEF37 /* CCSprite3DDataCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSprite3DDataCache.cpp; sourceTree = "<group>"; };
|
||||
B29594C01926D61F003EEF37 /* CCSprite3DDataCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSprite3DDataCache.h; sourceTree = "<group>"; };
|
||||
B29594BF1926D61F003EEF37 /* CCSprite3DMaterial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSprite3DMaterial.cpp; sourceTree = "<group>"; };
|
||||
B29594C01926D61F003EEF37 /* CCSprite3DMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSprite3DMaterial.h; sourceTree = "<group>"; };
|
||||
B2D3D3B81948613300BA4831 /* CCBundle3DData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBundle3DData.h; sourceTree = "<group>"; };
|
||||
B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsBodyInfo_chipmunk.cpp; sourceTree = "<group>"; };
|
||||
B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsBodyInfo_chipmunk.h; sourceTree = "<group>"; };
|
||||
B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsContactInfo_chipmunk.cpp; sourceTree = "<group>"; };
|
||||
|
@ -2807,6 +2867,16 @@
|
|||
B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsWorldInfo_chipmunk.h; sourceTree = "<group>"; };
|
||||
B3AF019E1842FBA400A98B85 /* b2MotorJoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = b2MotorJoint.cpp; sourceTree = "<group>"; };
|
||||
B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = "<group>"; };
|
||||
B6AAF83F19404E0D0069DE01 /* CCBundle3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBundle3D.cpp; sourceTree = "<group>"; };
|
||||
B6AAF84019404E0D0069DE01 /* CCBundle3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBundle3D.h; sourceTree = "<group>"; };
|
||||
B6ACD895193D6693005E0B8A /* CCMeshSkin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMeshSkin.cpp; sourceTree = "<group>"; };
|
||||
B6ACD896193D6693005E0B8A /* CCMeshSkin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMeshSkin.h; sourceTree = "<group>"; };
|
||||
B6ACD89C193DC0CC005E0B8A /* CCAnimate3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAnimate3D.cpp; sourceTree = "<group>"; };
|
||||
B6ACD89D193DC0CC005E0B8A /* CCAnimate3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAnimate3D.h; sourceTree = "<group>"; };
|
||||
B6B2633B19381FBF0088FE25 /* CCAnimationCurve.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CCAnimationCurve.inl; sourceTree = "<group>"; };
|
||||
B6B2633C19381FBF0088FE25 /* CCAnimationCurve.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAnimationCurve.h; sourceTree = "<group>"; };
|
||||
B6B26341193884D60088FE25 /* CCAnimation3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAnimation3D.cpp; sourceTree = "<group>"; };
|
||||
B6B26342193884D60088FE25 /* CCAnimation3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAnimation3D.h; sourceTree = "<group>"; };
|
||||
ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCNodeGrid.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeGrid.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -2903,6 +2973,24 @@
|
|||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0634A4C4194B19E400E608AF /* ActionTimeline */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0634A4C5194B19E400E608AF /* CCActionTimeline.cpp */,
|
||||
0634A4C6194B19E400E608AF /* CCActionTimeline.h */,
|
||||
0634A4C7194B19E400E608AF /* CCActionTimelineCache.cpp */,
|
||||
0634A4C8194B19E400E608AF /* CCActionTimelineCache.h */,
|
||||
0634A4C9194B19E400E608AF /* CCFrame.cpp */,
|
||||
0634A4CA194B19E400E608AF /* CCFrame.h */,
|
||||
0634A4CB194B19E400E608AF /* CCNodeReader.cpp */,
|
||||
0634A4CC194B19E400E608AF /* CCNodeReader.h */,
|
||||
0634A4CD194B19E400E608AF /* CCTimeLine.cpp */,
|
||||
0634A4CE194B19E400E608AF /* CCTimeLine.h */,
|
||||
0634A4CF194B19E400E608AF /* CCTimelineMacro.h */,
|
||||
);
|
||||
path = ActionTimeline;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1551A334158F2AB200E66CFE = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -3559,6 +3647,9 @@
|
|||
1A8C5946180E930E00EF57C3 /* cocostudio */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
29E99D1C1957BA7000046604 /* CocoLoader.cpp */,
|
||||
29E99D1D1957BA7000046604 /* CocoLoader.h */,
|
||||
0634A4C4194B19E400E608AF /* ActionTimeline */,
|
||||
50FCEB6818C72017004AD434 /* WidgetReader */,
|
||||
06CAAAC1186AD63B0012A414 /* TriggerObj.h */,
|
||||
06CAAABC186AD63B0012A414 /* TriggerBase.cpp */,
|
||||
|
@ -4817,14 +4908,25 @@
|
|||
B29594B81926D61F003EEF37 /* 3d */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B6AAF83F19404E0D0069DE01 /* CCBundle3D.cpp */,
|
||||
B6AAF84019404E0D0069DE01 /* CCBundle3D.h */,
|
||||
B6ACD89C193DC0CC005E0B8A /* CCAnimate3D.cpp */,
|
||||
B6ACD89D193DC0CC005E0B8A /* CCAnimate3D.h */,
|
||||
B6ACD895193D6693005E0B8A /* CCMeshSkin.cpp */,
|
||||
B6ACD896193D6693005E0B8A /* CCMeshSkin.h */,
|
||||
B6B26341193884D60088FE25 /* CCAnimation3D.cpp */,
|
||||
B6B26342193884D60088FE25 /* CCAnimation3D.h */,
|
||||
B6B2633B19381FBF0088FE25 /* CCAnimationCurve.inl */,
|
||||
B6B2633C19381FBF0088FE25 /* CCAnimationCurve.h */,
|
||||
B29594B91926D61F003EEF37 /* CCMesh.cpp */,
|
||||
B29594BA1926D61F003EEF37 /* CCMesh.h */,
|
||||
B29594BB1926D61F003EEF37 /* CCObjLoader.cpp */,
|
||||
B29594BC1926D61F003EEF37 /* CCObjLoader.h */,
|
||||
B29594BD1926D61F003EEF37 /* CCSprite3D.cpp */,
|
||||
B29594BE1926D61F003EEF37 /* CCSprite3D.h */,
|
||||
B29594BF1926D61F003EEF37 /* CCSprite3DDataCache.cpp */,
|
||||
B29594C01926D61F003EEF37 /* CCSprite3DDataCache.h */,
|
||||
B29594BF1926D61F003EEF37 /* CCSprite3DMaterial.cpp */,
|
||||
B29594C01926D61F003EEF37 /* CCSprite3DMaterial.h */,
|
||||
B2D3D3B81948613300BA4831 /* CCBundle3DData.h */,
|
||||
);
|
||||
name = 3d;
|
||||
path = ../cocos/3d;
|
||||
|
@ -4851,7 +4953,7 @@
|
|||
06CAAAC9186AD7EE0012A414 /* TriggerMng.h in Headers */,
|
||||
2905FA6018CF08D100240AA3 /* UILayoutParameter.h in Headers */,
|
||||
50ABBEA51925AB6F00A911A9 /* CCScriptSupport.h in Headers */,
|
||||
B29594D01926D61F003EEF37 /* CCSprite3DDataCache.h in Headers */,
|
||||
B29594D01926D61F003EEF37 /* CCSprite3DMaterial.h in Headers */,
|
||||
1ABA68B01888D700007D1BB4 /* CCFontCharMap.h in Headers */,
|
||||
5034CA3F191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */,
|
||||
50ABBD461925AB0000A911A9 /* CCVertex.h in Headers */,
|
||||
|
@ -4874,6 +4976,7 @@
|
|||
50ABBE731925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */,
|
||||
1A570063180BC5A10088DEC7 /* CCAction.h in Headers */,
|
||||
1A570067180BC5A10088DEC7 /* CCActionCamera.h in Headers */,
|
||||
0634A4DA194B19E400E608AF /* CCFrame.h in Headers */,
|
||||
1A57006B180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */,
|
||||
1A57006F180BC5A10088DEC7 /* CCActionEase.h in Headers */,
|
||||
1A570073180BC5A10088DEC7 /* CCActionGrid.h in Headers */,
|
||||
|
@ -4892,6 +4995,7 @@
|
|||
50ABBD8D1925AB4100A911A9 /* CCGLProgram.h in Headers */,
|
||||
50ABBEA11925AB6F00A911A9 /* CCScheduler.h in Headers */,
|
||||
50ABBDB71925AB4100A911A9 /* CCTexture2D.h in Headers */,
|
||||
B2D3D3B91948613300BA4831 /* CCBundle3DData.h in Headers */,
|
||||
2905FA6C18CF08D100240AA3 /* UIPageView.h in Headers */,
|
||||
50FCEB9518C72017004AD434 /* ButtonReader.h in Headers */,
|
||||
50ABBE811925AB6F00A911A9 /* CCEventType.h in Headers */,
|
||||
|
@ -4977,6 +5081,7 @@
|
|||
1A570294180BCCAB0088DEC7 /* CCAnimation.h in Headers */,
|
||||
50ABBD421925AB0000A911A9 /* CCMathBase.h in Headers */,
|
||||
1A570298180BCCAB0088DEC7 /* CCAnimationCache.h in Headers */,
|
||||
0634A4DE194B19E400E608AF /* CCNodeReader.h in Headers */,
|
||||
50FCEB9D18C72017004AD434 /* ImageViewReader.h in Headers */,
|
||||
B29594C81926D61F003EEF37 /* CCObjLoader.h in Headers */,
|
||||
50ABBE911925AB6F00A911A9 /* CCPlatformMacros.h in Headers */,
|
||||
|
@ -5037,6 +5142,7 @@
|
|||
1AD71DCF180E26E600808F54 /* CCControlLoader.h in Headers */,
|
||||
50ABBE7B1925AB6F00A911A9 /* CCEventMouse.h in Headers */,
|
||||
1AD71DD3180E26E600808F54 /* CCLabelBMFontLoader.h in Headers */,
|
||||
0634A4D6194B19E400E608AF /* CCActionTimelineCache.h in Headers */,
|
||||
1AD71DD7180E26E600808F54 /* CCLabelTTFLoader.h in Headers */,
|
||||
1AD71DDB180E26E600808F54 /* CCLayerColorLoader.h in Headers */,
|
||||
503DD8F91926B0DB00CD74DD /* CCIMEDispatcher.h in Headers */,
|
||||
|
@ -5064,6 +5170,7 @@
|
|||
1AD71E0D180E26E600808F54 /* CocosBuilder.h in Headers */,
|
||||
1AD71E97180E26E600808F54 /* Animation.h in Headers */,
|
||||
1AD71E9B180E26E600808F54 /* AnimationState.h in Headers */,
|
||||
29E99D201957BA7000046604 /* CocoLoader.h in Headers */,
|
||||
1A01C69218F57BE800EFE3A6 /* CCDouble.h in Headers */,
|
||||
50ABBE251925AB6F00A911A9 /* base64.h in Headers */,
|
||||
50ABBEC91925AB6F00A911A9 /* firePngData.h in Headers */,
|
||||
|
@ -5105,6 +5212,7 @@
|
|||
50ABBE3F1925AB6F00A911A9 /* CCDataVisitor.h in Headers */,
|
||||
1AD71EDF180E26E600808F54 /* Slot.h in Headers */,
|
||||
1AD71EE3180E26E600808F54 /* SlotData.h in Headers */,
|
||||
0634A4E2194B19E400E608AF /* CCTimeLine.h in Headers */,
|
||||
1AD71EE7180E26E600808F54 /* spine-cocos2dx.h in Headers */,
|
||||
1AD71EE9180E26E600808F54 /* spine.h in Headers */,
|
||||
1AAF536C180E3374000584C8 /* HttpClient.h in Headers */,
|
||||
|
@ -5136,6 +5244,7 @@
|
|||
50ABBE371925AB6F00A911A9 /* CCConsole.h in Headers */,
|
||||
1A8C59A1180E930E00EF57C3 /* CCArmature.h in Headers */,
|
||||
1A8C59A5180E930E00EF57C3 /* CCArmatureAnimation.h in Headers */,
|
||||
0634A4D2194B19E400E608AF /* CCActionTimeline.h in Headers */,
|
||||
1A8C59A9180E930E00EF57C3 /* CCArmatureDataManager.h in Headers */,
|
||||
50ABC00B1926664800A911A9 /* CCDevice.h in Headers */,
|
||||
2905FA7A18CF08D100240AA3 /* UISlider.h in Headers */,
|
||||
|
@ -5174,6 +5283,7 @@
|
|||
50ABBD951925AB4100A911A9 /* CCGLProgramState.h in Headers */,
|
||||
1A8C59F1180E930E00EF57C3 /* CCSpriteFrameCacheHelper.h in Headers */,
|
||||
1A8C59F5180E930E00EF57C3 /* CCSSceneReader.h in Headers */,
|
||||
0634A4E4194B19E400E608AF /* CCTimelineMacro.h in Headers */,
|
||||
1A8C59F9180E930E00EF57C3 /* CCTransformHelp.h in Headers */,
|
||||
1A8C59FD180E930E00EF57C3 /* CCTween.h in Headers */,
|
||||
1A8C5A05180E930E00EF57C3 /* CCUtilMath.h in Headers */,
|
||||
|
@ -5183,6 +5293,11 @@
|
|||
1A8C5A0F180E930E00EF57C3 /* DictionaryHelper.h in Headers */,
|
||||
50FCEBBD18C72017004AD434 /* TextBMFontReader.h in Headers */,
|
||||
50FCEBCB18C72017004AD434 /* WidgetReaderProtocol.h in Headers */,
|
||||
B6B2633F19381FBF0088FE25 /* CCAnimationCurve.h in Headers */,
|
||||
B6B26345193884D60088FE25 /* CCAnimation3D.h in Headers */,
|
||||
B6ACD899193D6693005E0B8A /* CCMeshSkin.h in Headers */,
|
||||
B6ACD8A0193DC0CC005E0B8A /* CCAnimate3D.h in Headers */,
|
||||
B6AAF84319404E0D0069DE01 /* CCBundle3D.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -5332,6 +5447,7 @@
|
|||
2AC795EA1862875D005EC8E1 /* BoundingBoxAttachment.h in Headers */,
|
||||
503DD8F01926736A00CD74DD /* CCStdC.h in Headers */,
|
||||
46A170FF1807CECB005B8026 /* CCPhysicsContact.h in Headers */,
|
||||
0634A4D3194B19E400E608AF /* CCActionTimeline.h in Headers */,
|
||||
50ABBDA21925AB4100A911A9 /* CCGroupCommand.h in Headers */,
|
||||
503DD8EF1926736A00CD74DD /* CCPlatformDefine.h in Headers */,
|
||||
46A171041807CECB005B8026 /* CCPhysicsShape.h in Headers */,
|
||||
|
@ -5339,11 +5455,12 @@
|
|||
50ABBD3B1925AB0000A911A9 /* CCAffineTransform.h in Headers */,
|
||||
5034CA38191D591100CE6051 /* ccShader_PositionColorLengthTexture.vert in Headers */,
|
||||
50ABBE7C1925AB6F00A911A9 /* CCEventMouse.h in Headers */,
|
||||
B29594D11926D61F003EEF37 /* CCSprite3DDataCache.h in Headers */,
|
||||
B29594D11926D61F003EEF37 /* CCSprite3DMaterial.h in Headers */,
|
||||
46A171011807CECB005B8026 /* CCPhysicsJoint.h in Headers */,
|
||||
46A170FD1807CECB005B8026 /* CCPhysicsBody.h in Headers */,
|
||||
2905FA6118CF08D100240AA3 /* UILayoutParameter.h in Headers */,
|
||||
B29594C51926D61F003EEF37 /* CCMesh.h in Headers */,
|
||||
0634A4DB194B19E400E608AF /* CCFrame.h in Headers */,
|
||||
50ABBE9C1925AB6F00A911A9 /* CCRef.h in Headers */,
|
||||
50ABBD961925AB4100A911A9 /* CCGLProgramState.h in Headers */,
|
||||
46A171061807CECB005B8026 /* CCPhysicsWorld.h in Headers */,
|
||||
|
@ -5355,11 +5472,13 @@
|
|||
50ABBEC21925AB6F00A911A9 /* CCValue.h in Headers */,
|
||||
2905FA5518CF08D100240AA3 /* UIImageView.h in Headers */,
|
||||
50ABBECA1925AB6F00A911A9 /* firePngData.h in Headers */,
|
||||
0634A4E3194B19E400E608AF /* CCTimeLine.h in Headers */,
|
||||
50ABBE401925AB6F00A911A9 /* CCDataVisitor.h in Headers */,
|
||||
1A570064180BC5A10088DEC7 /* CCAction.h in Headers */,
|
||||
06CAAACE186AD7FA0012A414 /* TriggerBase.h in Headers */,
|
||||
503DD8EC1926736A00CD74DD /* CCGLView.h in Headers */,
|
||||
50FCEBC218C72017004AD434 /* TextFieldReader.h in Headers */,
|
||||
29E99D211957BA7000046604 /* CocoLoader.h in Headers */,
|
||||
50ABBEBA1925AB6F00A911A9 /* ccUTF8.h in Headers */,
|
||||
1A570068180BC5A10088DEC7 /* CCActionCamera.h in Headers */,
|
||||
1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */,
|
||||
|
@ -5375,6 +5494,7 @@
|
|||
1A01C68918F57BE800EFE3A6 /* CCBool.h in Headers */,
|
||||
1A57007C180BC5A10088DEC7 /* CCActionInstant.h in Headers */,
|
||||
50ABBE781925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */,
|
||||
B2D3D3BA1948613300BA4831 /* CCBundle3DData.h in Headers */,
|
||||
B37510861823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */,
|
||||
1A570080180BC5A10088DEC7 /* CCActionInterval.h in Headers */,
|
||||
1A570084180BC5A10088DEC7 /* CCActionManager.h in Headers */,
|
||||
|
@ -5411,6 +5531,7 @@
|
|||
1A57011E180BC90D0088DEC7 /* CCGrabber.h in Headers */,
|
||||
1A570122180BC90D0088DEC7 /* CCGrid.h in Headers */,
|
||||
50FCEBBA18C72017004AD434 /* TextAtlasReader.h in Headers */,
|
||||
0634A4D7194B19E400E608AF /* CCActionTimelineCache.h in Headers */,
|
||||
5034CA2E191D591100CE6051 /* ccShader_PositionTextureA8Color.frag in Headers */,
|
||||
50ABBD5B1925AB0000A911A9 /* Vec2.h in Headers */,
|
||||
50ABBD411925AB0000A911A9 /* CCMath.h in Headers */,
|
||||
|
@ -5494,6 +5615,7 @@
|
|||
50ABBE2A1925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */,
|
||||
1A57030F180BCF190088DEC7 /* CCComponent.h in Headers */,
|
||||
1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */,
|
||||
0634A4DF194B19E400E608AF /* CCNodeReader.h in Headers */,
|
||||
1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */,
|
||||
2905FA6518CF08D100240AA3 /* UIListView.h in Headers */,
|
||||
50FCEBAA18C72017004AD434 /* LoadingBarReader.h in Headers */,
|
||||
|
@ -5615,6 +5737,7 @@
|
|||
1A9DCA2A180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */,
|
||||
1A01C69F18F57BE800EFE3A6 /* CCString.h in Headers */,
|
||||
1A01C69118F57BE800EFE3A6 /* CCDictionary.h in Headers */,
|
||||
0634A4E5194B19E400E608AF /* CCTimelineMacro.h in Headers */,
|
||||
1A8C598E180E930E00EF57C3 /* CCActionFrame.h in Headers */,
|
||||
1A8C5992180E930E00EF57C3 /* CCActionFrameEasing.h in Headers */,
|
||||
5034CA36191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */,
|
||||
|
@ -5678,6 +5801,11 @@
|
|||
1A8C5A08180E930E00EF57C3 /* CocoStudio.h in Headers */,
|
||||
1A8C5A10180E930E00EF57C3 /* DictionaryHelper.h in Headers */,
|
||||
50ABBEB21925AB6F00A911A9 /* CCUserDefault.h in Headers */,
|
||||
B6B2634019381FBF0088FE25 /* CCAnimationCurve.h in Headers */,
|
||||
B6B26346193884D60088FE25 /* CCAnimation3D.h in Headers */,
|
||||
B6ACD89A193D6693005E0B8A /* CCMeshSkin.h in Headers */,
|
||||
B6ACD8A1193DC0CC005E0B8A /* CCAnimate3D.h in Headers */,
|
||||
B6AAF84419404E0D0069DE01 /* CCBundle3D.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -6046,6 +6174,7 @@
|
|||
1A01C6A418F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */,
|
||||
46A170EA1807CECA005B8026 /* CCPhysicsJoint.cpp in Sources */,
|
||||
5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */,
|
||||
0634A4D4194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */,
|
||||
50ABC0611926664800A911A9 /* CCCommon.mm in Sources */,
|
||||
50ABBDB11925AB4100A911A9 /* ccShaders.cpp in Sources */,
|
||||
46A170EF1807CECA005B8026 /* CCPhysicsWorld.cpp in Sources */,
|
||||
|
@ -6054,6 +6183,7 @@
|
|||
ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */,
|
||||
06CAAACB186AD7F20012A414 /* TriggerMng.cpp in Sources */,
|
||||
46A170E61807CECA005B8026 /* CCPhysicsBody.cpp in Sources */,
|
||||
29E99D1E1957BA7000046604 /* CocoLoader.cpp in Sources */,
|
||||
50ABBDA71925AB4100A911A9 /* CCRenderCommand.cpp in Sources */,
|
||||
50ABBD501925AB0000A911A9 /* Quaternion.cpp in Sources */,
|
||||
50ABBEBB1925AB6F00A911A9 /* ccUtils.cpp in Sources */,
|
||||
|
@ -6164,6 +6294,7 @@
|
|||
1A5702EE180BCE750088DEC7 /* CCTMXLayer.cpp in Sources */,
|
||||
50ABBE691925AB6F00A911A9 /* CCEventListenerFocus.cpp in Sources */,
|
||||
1A5702F2180BCE750088DEC7 /* CCTMXObjectGroup.cpp in Sources */,
|
||||
0634A4DC194B19E400E608AF /* CCNodeReader.cpp in Sources */,
|
||||
1A5702F6180BCE750088DEC7 /* CCTMXTiledMap.cpp in Sources */,
|
||||
1A5702FA180BCE750088DEC7 /* CCTMXXMLParser.cpp in Sources */,
|
||||
50ABBD5C1925AB0000A911A9 /* Vec3.cpp in Sources */,
|
||||
|
@ -6252,6 +6383,7 @@
|
|||
1AD71EE5180E26E600808F54 /* spine-cocos2dx.cpp in Sources */,
|
||||
1AAF536A180E3374000584C8 /* HttpClient.cpp in Sources */,
|
||||
50ABC0631926664800A911A9 /* CCDevice.mm in Sources */,
|
||||
0634A4E0194B19E400E608AF /* CCTimeLine.cpp in Sources */,
|
||||
1AAF5372180E3374000584C8 /* SocketIO.cpp in Sources */,
|
||||
50ABBE1F1925AB6F00A911A9 /* atitc.cpp in Sources */,
|
||||
1AAF5376180E3374000584C8 /* WebSocket.cpp in Sources */,
|
||||
|
@ -6289,11 +6421,12 @@
|
|||
1A8C59C3180E930E00EF57C3 /* CCComController.cpp in Sources */,
|
||||
2905FA5218CF08D100240AA3 /* UIImageView.cpp in Sources */,
|
||||
50ABBDBD1925AB4100A911A9 /* CCTextureCache.cpp in Sources */,
|
||||
B29594CE1926D61F003EEF37 /* CCSprite3DDataCache.cpp in Sources */,
|
||||
B29594CE1926D61F003EEF37 /* CCSprite3DMaterial.cpp in Sources */,
|
||||
299754F4193EC95400A54AC3 /* ObjectFactory.cpp in Sources */,
|
||||
2905FA7C18CF08D100240AA3 /* UIText.cpp in Sources */,
|
||||
50FCEB9F18C72017004AD434 /* LayoutReader.cpp in Sources */,
|
||||
50ABC0211926664800A911A9 /* CCGLView.cpp in Sources */,
|
||||
0634A4D8194B19E400E608AF /* CCFrame.cpp in Sources */,
|
||||
1A8C59C7180E930E00EF57C3 /* CCComRender.cpp in Sources */,
|
||||
50ABC00D1926664800A911A9 /* CCFileUtils.cpp in Sources */,
|
||||
1A8C59CB180E930E00EF57C3 /* CCDataReaderHelper.cpp in Sources */,
|
||||
|
@ -6308,6 +6441,7 @@
|
|||
1A8C59D7180E930E00EF57C3 /* CCDisplayFactory.cpp in Sources */,
|
||||
50ABBD601925AB0000A911A9 /* Vec4.cpp in Sources */,
|
||||
1A8C59DB180E930E00EF57C3 /* CCDisplayManager.cpp in Sources */,
|
||||
0634A4D0194B19E400E608AF /* CCActionTimeline.cpp in Sources */,
|
||||
2905FA6218CF08D100240AA3 /* UIListView.cpp in Sources */,
|
||||
1A8C59DF180E930E00EF57C3 /* CCInputDelegate.cpp in Sources */,
|
||||
1A8C59E3180E930E00EF57C3 /* CCProcessBase.cpp in Sources */,
|
||||
|
@ -6329,6 +6463,10 @@
|
|||
50ABBE931925AB6F00A911A9 /* CCProfiling.cpp in Sources */,
|
||||
1ABA68AE1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */,
|
||||
2905FA4618CF08D100240AA3 /* UIButton.cpp in Sources */,
|
||||
B6B26343193884D60088FE25 /* CCAnimation3D.cpp in Sources */,
|
||||
B6ACD897193D6693005E0B8A /* CCMeshSkin.cpp in Sources */,
|
||||
B6ACD89E193DC0CC005E0B8A /* CCAnimate3D.cpp in Sources */,
|
||||
B6AAF84119404E0D0069DE01 /* CCBundle3D.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -6498,6 +6636,7 @@
|
|||
3EA0FB6C191C841D00B170C8 /* UIVideoPlayerIOS.mm in Sources */,
|
||||
1A570062180BC5A10088DEC7 /* CCAction.cpp in Sources */,
|
||||
1A570066180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */,
|
||||
0634A4D9194B19E400E608AF /* CCFrame.cpp in Sources */,
|
||||
1A57006A180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */,
|
||||
1A57006E180BC5A10088DEC7 /* CCActionEase.cpp in Sources */,
|
||||
50ABBD8C1925AB4100A911A9 /* CCGLProgram.cpp in Sources */,
|
||||
|
@ -6505,7 +6644,9 @@
|
|||
50ABBE621925AB6F00A911A9 /* CCEventListenerAcceleration.cpp in Sources */,
|
||||
B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
|
||||
2905FA8D18CF08D100240AA3 /* UIWidget.cpp in Sources */,
|
||||
29E99D1F1957BA7000046604 /* CocoLoader.cpp in Sources */,
|
||||
B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */,
|
||||
0634A4D5194B19E400E608AF /* CCActionTimelineCache.cpp in Sources */,
|
||||
50ABBE7E1925AB6F00A911A9 /* CCEventTouch.cpp in Sources */,
|
||||
50FCEB9818C72017004AD434 /* CheckBoxReader.cpp in Sources */,
|
||||
50ABBE6E1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */,
|
||||
|
@ -6535,7 +6676,7 @@
|
|||
50ABBE3E1925AB6F00A911A9 /* CCDataVisitor.cpp in Sources */,
|
||||
1A57009F180BC5D20088DEC7 /* CCNode.cpp in Sources */,
|
||||
B37510831823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */,
|
||||
B29594CF1926D61F003EEF37 /* CCSprite3DDataCache.cpp in Sources */,
|
||||
B29594CF1926D61F003EEF37 /* CCSprite3DMaterial.cpp in Sources */,
|
||||
1A57010F180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */,
|
||||
1A570113180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */,
|
||||
1A57011C180BC90D0088DEC7 /* CCGrabber.cpp in Sources */,
|
||||
|
@ -6565,6 +6706,7 @@
|
|||
50ABBD9C1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */,
|
||||
1A5701E7180BCB8C0088DEC7 /* CCTransition.cpp in Sources */,
|
||||
50ABC01E1926664800A911A9 /* CCThread.cpp in Sources */,
|
||||
0634A4D1194B19E400E608AF /* CCActionTimeline.cpp in Sources */,
|
||||
1A5701EB180BCB8C0088DEC7 /* CCTransitionPageTurn.cpp in Sources */,
|
||||
1A5701EF180BCB8C0088DEC7 /* CCTransitionProgress.cpp in Sources */,
|
||||
1A5701F8180BCBAD0088DEC7 /* CCMenu.cpp in Sources */,
|
||||
|
@ -6622,6 +6764,7 @@
|
|||
50ABBDB61925AB4100A911A9 /* CCTexture2D.cpp in Sources */,
|
||||
1A570355180BD0B00088DEC7 /* ioapi.cpp in Sources */,
|
||||
1A570359180BD0B00088DEC7 /* unzip.cpp in Sources */,
|
||||
0634A4E1194B19E400E608AF /* CCTimeLine.cpp in Sources */,
|
||||
1AD71DAA180E26E600808F54 /* CCBAnimationManager.cpp in Sources */,
|
||||
50ABBD881925AB4100A911A9 /* CCCustomCommand.cpp in Sources */,
|
||||
50ABBE941925AB6F00A911A9 /* CCProfiling.cpp in Sources */,
|
||||
|
@ -6768,8 +6911,13 @@
|
|||
2905FA7518CF08D100240AA3 /* UIScrollView.cpp in Sources */,
|
||||
1A8C5A0E180E930E00EF57C3 /* DictionaryHelper.cpp in Sources */,
|
||||
1ABA68AF1888D700007D1BB4 /* CCFontCharMap.cpp in Sources */,
|
||||
0634A4DD194B19E400E608AF /* CCNodeReader.cpp in Sources */,
|
||||
50ABBE7A1925AB6F00A911A9 /* CCEventMouse.cpp in Sources */,
|
||||
50ABBD981925AB4100A911A9 /* CCGLProgramStateCache.cpp in Sources */,
|
||||
B6B26344193884D60088FE25 /* CCAnimation3D.cpp in Sources */,
|
||||
B6ACD898193D6693005E0B8A /* CCMeshSkin.cpp in Sources */,
|
||||
B6ACD89F193DC0CC005E0B8A /* CCAnimate3D.cpp in Sources */,
|
||||
B6AAF84219404E0D0069DE01 /* CCBundle3D.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -7075,6 +7223,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "../cocos/cocos2d-prefix.pch";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
|
@ -7110,6 +7259,7 @@
|
|||
A03F2CB71780BD04006731B9 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../external/chipmunk/include/chipmunk/";
|
||||
|
@ -7135,6 +7285,7 @@
|
|||
buildSettings = {
|
||||
CLANG_WARN_BOOL_CONVERSION = NO;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = NO;
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
|
||||
GCC_WARN_SHADOW = NO;
|
||||
GCC_WARN_UNUSED_VALUE = NO;
|
||||
|
@ -7185,6 +7336,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = CC_TARGET_OS_MAC;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
|
@ -7212,6 +7364,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_MAC,
|
||||
|
@ -7268,6 +7421,7 @@
|
|||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "../cocos/cocos2d-prefix.pch";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
|
@ -7346,6 +7500,7 @@
|
|||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
|
@ -7376,6 +7531,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
SDKROOT = iphoneos;
|
||||
|
@ -7408,6 +7564,7 @@
|
|||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
CLANG_WARN_BOOL_CONVERSION = NO;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = NO;
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
|
||||
GCC_WARN_SHADOW = NO;
|
||||
GCC_WARN_UNUSED_VALUE = NO;
|
||||
|
@ -7443,6 +7600,7 @@
|
|||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
|
|
|
@ -804,6 +804,10 @@
|
|||
29080DE4191B595E0066F8DF /* UIWidgetAddNodeTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29080D89191B595E0066F8DF /* UIWidgetAddNodeTest.cpp */; };
|
||||
29080DE5191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29080D8B191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp */; };
|
||||
29080DE6191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29080D8B191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp */; };
|
||||
38FA2E73194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */; };
|
||||
38FA2E74194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */; };
|
||||
38FA2E76194AECF800FF2BE4 /* ActionTimeline in Resources */ = {isa = PBXBuildFile; fileRef = 38FA2E75194AECF800FF2BE4 /* ActionTimeline */; };
|
||||
38FA2E77194AECF800FF2BE4 /* ActionTimeline in Resources */ = {isa = PBXBuildFile; fileRef = 38FA2E75194AECF800FF2BE4 /* ActionTimeline */; };
|
||||
3E92EA821921A1400094CD21 /* Sprite3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E92EA801921A1400094CD21 /* Sprite3DTest.cpp */; };
|
||||
3E92EA831921A1400094CD21 /* Sprite3DTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E92EA801921A1400094CD21 /* Sprite3DTest.cpp */; };
|
||||
3E92EA851921A7720094CD21 /* Sprite3DTest in Resources */ = {isa = PBXBuildFile; fileRef = 3E92EA841921A7720094CD21 /* Sprite3DTest */; };
|
||||
|
@ -1840,6 +1844,9 @@
|
|||
29080D8A191B595E0066F8DF /* UIWidgetAddNodeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidgetAddNodeTest.h; sourceTree = "<group>"; };
|
||||
29080D8B191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIWidgetAddNodeTest_Editor.cpp; sourceTree = "<group>"; };
|
||||
29080D8C191B595E0066F8DF /* UIWidgetAddNodeTest_Editor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIWidgetAddNodeTest_Editor.h; sourceTree = "<group>"; };
|
||||
38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActionTimelineTestScene.cpp; sourceTree = "<group>"; };
|
||||
38FA2E72194AEBE100FF2BE4 /* ActionTimelineTestScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionTimelineTestScene.h; sourceTree = "<group>"; };
|
||||
38FA2E75194AECF800FF2BE4 /* ActionTimeline */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ActionTimeline; path = "../tests/cpp-tests/Resources/ActionTimeline"; sourceTree = "<group>"; };
|
||||
3E92EA801921A1400094CD21 /* Sprite3DTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sprite3DTest.cpp; path = Sprite3DTest/Sprite3DTest.cpp; sourceTree = "<group>"; };
|
||||
3E92EA811921A1400094CD21 /* Sprite3DTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sprite3DTest.h; path = Sprite3DTest/Sprite3DTest.h; sourceTree = "<group>"; };
|
||||
3E92EA841921A7720094CD21 /* Sprite3DTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Sprite3DTest; path = "../tests/cpp-tests/Resources/Sprite3DTest"; sourceTree = "<group>"; };
|
||||
|
@ -2541,6 +2548,7 @@
|
|||
1AC359B418CECF0B00F37B72 /* ExtensionsTest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
38FA2E70194AEBE100FF2BE4 /* CocoStudioActionTimelineTest */,
|
||||
1AC359B518CECF0B00F37B72 /* CocosBuilderTest */,
|
||||
1AC359DC18CECF0B00F37B72 /* CocoStudioArmatureTest */,
|
||||
1AC359DF18CECF0B00F37B72 /* CocoStudioComponentsTest */,
|
||||
|
@ -3240,6 +3248,7 @@
|
|||
1AC35CA818CED83500F37B72 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
38FA2E75194AECF800FF2BE4 /* ActionTimeline */,
|
||||
B2507B6A192589AF00FA4972 /* Shaders3D */,
|
||||
3E92EA841921A7720094CD21 /* Sprite3DTest */,
|
||||
3EA0FB5D191B92F100B170C8 /* cocosvideo.mp4 */,
|
||||
|
@ -3757,6 +3766,15 @@
|
|||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
38FA2E70194AEBE100FF2BE4 /* CocoStudioActionTimelineTest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
38FA2E71194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp */,
|
||||
38FA2E72194AEBE100FF2BE4 /* ActionTimelineTestScene.h */,
|
||||
);
|
||||
path = CocoStudioActionTimelineTest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3E92EA7D1921A0C60094CD21 /* Sprite3DTest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -4383,6 +4401,7 @@
|
|||
1AC35CE018CED84500F37B72 /* configs in Resources */,
|
||||
1AC35CE618CED84500F37B72 /* effect2.ogg in Resources */,
|
||||
1AC35CFA18CED84500F37B72 /* Misc in Resources */,
|
||||
38FA2E76194AECF800FF2BE4 /* ActionTimeline in Resources */,
|
||||
1AC35D0418CED84500F37B72 /* Shaders in Resources */,
|
||||
1AC35CD818CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */,
|
||||
B2507B6B192589AF00FA4972 /* Shaders3D in Resources */,
|
||||
|
@ -4451,6 +4470,7 @@
|
|||
1AC35CF318CED84500F37B72 /* Hello.png in Resources */,
|
||||
1AC35C8F18CECF1400F37B72 /* Icon-152.png in Resources */,
|
||||
1AC35CE718CED84500F37B72 /* effect2.ogg in Resources */,
|
||||
38FA2E77194AECF800FF2BE4 /* ActionTimeline in Resources */,
|
||||
1AC35C9718CECF1400F37B72 /* Icon-80.png in Resources */,
|
||||
1AC35CEB18CED84500F37B72 /* fileLookup.plist in Resources */,
|
||||
1AC35CFD18CED84500F37B72 /* music.mid in Resources */,
|
||||
|
@ -4686,6 +4706,7 @@
|
|||
1AC35C2B18CECF0C00F37B72 /* PerformanceLabelTest.cpp in Sources */,
|
||||
1AC35C0118CECF0C00F37B72 /* TableViewTestScene.cpp in Sources */,
|
||||
1AC35C4B18CECF0C00F37B72 /* ShaderTest2.cpp in Sources */,
|
||||
38FA2E73194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */,
|
||||
1AC35C6518CECF0C00F37B72 /* UnitTest.cpp in Sources */,
|
||||
29080DC9191B595E0066F8DF /* UISceneManager_Editor.cpp in Sources */,
|
||||
1AC35B3F18CECF0C00F37B72 /* Bug-458.cpp in Sources */,
|
||||
|
@ -4729,6 +4750,7 @@
|
|||
29080D8E191B595E0066F8DF /* CocosGUIScene.cpp in Sources */,
|
||||
1AC35BFA18CECF0C00F37B72 /* WebSocketTest.cpp in Sources */,
|
||||
1AC35BF218CECF0C00F37B72 /* EditBoxTest.cpp in Sources */,
|
||||
38FA2E74194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */,
|
||||
1AC35B3A18CECF0C00F37B72 /* Bug-1174.cpp in Sources */,
|
||||
1AC35BE418CECF0C00F37B72 /* CCControlColourPickerTest.cpp in Sources */,
|
||||
29080DD4191B595E0066F8DF /* UITextAtlasTest.cpp in Sources */,
|
||||
|
@ -5454,6 +5476,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
|
@ -5470,6 +5493,7 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
|
|
|
@ -9,14 +9,15 @@
|
|||
|
||||
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<StackPanel Orientation="Horizontal" Margin="40,100,0,0" Height="50" VerticalAlignment="Top">
|
||||
<TextBlock Text="Memory: " FontSize="36"/>
|
||||
<TextBlock x:Name="MemoryTextBlock" FontSize="36"/>
|
||||
<TextBlock Text=" MB" FontSize="36"/>
|
||||
<TextBlock Text=" Peak: " FontSize="36"/>
|
||||
<TextBlock x:Name="PeakMemoryTextBlock" FontSize="36"/>
|
||||
<TextBlock Text=" MB" FontSize="36"/>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal" Margin="40,100,0,0" Height="50" VerticalAlignment="Top">
|
||||
<TextBlock Text="Save file to cocos\platform\wp8\shaders\precompiledshaders.h" FontSize="36"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="40,100,0,0" Height="50" VerticalAlignment="Top">
|
||||
<TextBlock Text="Result: " FontSize="36"/>
|
||||
<TextBlock Text="" FontSize="36" x:Name="ResultText" />
|
||||
</StackPanel>
|
||||
<Button Margin="40,100,0,0" x:Name="compileButton" Content="Compile" Width="150" Click="OnCompile" />
|
||||
</StackPanel>
|
||||
<Button Margin="40,10,0,0" x:Name="compileButton" Content="Compile" Width="150" Click="OnCompile" />
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -60,7 +60,7 @@ DirectXPage::~DirectXPage()
|
|||
|
||||
void DirectXPage::OnCompile(Object^ sender, RoutedEventArgs^ args)
|
||||
{
|
||||
compiler.Compile();
|
||||
compiler.Compile(ResultText);
|
||||
}
|
||||
|
||||
// Saves the current state of the app for suspend and terminate events.
|
||||
|
|
|
@ -35,7 +35,11 @@ using namespace Windows::UI::Core;
|
|||
|
||||
USING_NS_CC;
|
||||
|
||||
ShaderCompiler::ShaderCompiler() : m_display(nullptr), m_context(nullptr), m_initialized(false)
|
||||
ShaderCompiler::ShaderCompiler()
|
||||
: m_display(nullptr),
|
||||
m_context(nullptr),
|
||||
m_initialized(false),
|
||||
m_resultText(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -64,14 +68,22 @@ void ShaderCompiler::applicationWillEnterForeground()
|
|||
}
|
||||
|
||||
|
||||
bool ShaderCompiler::Compile()
|
||||
bool ShaderCompiler::Compile(Windows::UI::Xaml::Controls::TextBlock^ resultText)
|
||||
{
|
||||
m_resultText = resultText;
|
||||
resultText->Text = "Compiling shaders...";
|
||||
|
||||
if (!InitializeAngle(ANGLE_D3D_FEATURE_LEVEL::ANGLE_D3D_FEATURE_LEVEL_9_3))
|
||||
{
|
||||
resultText->Text = "Unable to initialize Angle";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = InitializeAngle(ANGLE_D3D_FEATURE_LEVEL::ANGLE_D3D_FEATURE_LEVEL_9_3);
|
||||
Director::getInstance()->setAnimationInterval(1.0 / 60.0);
|
||||
CCShaderCache::getInstance()->loadDefaultShaders();
|
||||
CCPrecompiledShaders::getInstance()->savePrecompiledShaders();
|
||||
return result;
|
||||
resultText->Text = "Complete";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,10 +34,12 @@ class ShaderCompiler : private cocos2d::Application
|
|||
public:
|
||||
ShaderCompiler();
|
||||
~ShaderCompiler();
|
||||
bool Compile();
|
||||
bool Compile(Windows::UI::Xaml::Controls::TextBlock^ resultText);
|
||||
|
||||
private:
|
||||
|
||||
Windows::UI::Xaml::Controls::TextBlock^ m_resultText;
|
||||
|
||||
virtual bool applicationDidFinishLaunching();
|
||||
virtual void applicationDidEnterBackground();
|
||||
virtual void applicationWillEnterForeground();
|
||||
|
|
|
@ -13,4 +13,4 @@
|
|||
#include <agile.h>
|
||||
#include <concrt.h>
|
||||
#include <collection.h>
|
||||
#include "App.xaml.h"
|
||||
#include "App.xaml.h"
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
set IN_DIR=.\..\..\..\angle\src\WP8\redist\vs2012\ARM\Release
|
||||
|
||||
set OUT_DIR=.\..\..\external\wp8-specific\angle\prebuilt\ARM\
|
||||
xcopy "%IN_DIR%\libGLESv2_phone\libGLESv2_phone.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_phone\libGLESv2_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_phone\libEGL_phone.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_phone\libEGL_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\esUtil_phone\esUtil_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
|
||||
|
||||
set IN_DIR=.\..\..\..\angle\src\WP8\redist\vs2012\Win32\Release
|
||||
|
||||
set OUT_DIR=.\..\..\external\wp8-specific\angle\prebuilt\Win32\
|
||||
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_phone\libGLESv2_phone.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_phone\libGLESv2_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_phone\libEGL_phone.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_phone\libEGL_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\esUtil_phone\esUtil_phone.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
|
||||
|
||||
set IN_DIR=.\..\..\..\angle\src\WinRT\redist\vs2013\ARM\Release\
|
||||
set OUT_DIR=.\..\..\external\winrt-specific\angle\prebuilt\ARM\
|
||||
xcopy "%IN_DIR%\libGLESv2_winrt_2013\libGLESv2.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_winrt_2013\libGLESv2.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_winrt_2013\libEGL.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_winrt_2013\libEGL.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\esUtil_winrt_2013\esUtil.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
|
||||
set IN_DIR=.\..\..\..\angle\src\WinRT\redist\vs2013\Win32\Release\
|
||||
set OUT_DIR=.\..\..\external\winrt-specific\angle\prebuilt\Win32\
|
||||
xcopy "%IN_DIR%\libGLESv2_winrt_2013\libGLESv2.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libGLESv2_winrt_2013\libGLESv2.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_winrt_2013\libEGL.dll" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\libEGL_winrt_2013\libEGL.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
xcopy "%IN_DIR%\esUtil_winrt_2013\esUtil.lib" "%OUT_DIR%" /iycq
|
||||
|
||||
|
||||
set OUT_DIR=.\..\..\external\winrt-specific\angle\include
|
||||
xcopy ".\..\..\..\angle\include" "%OUT_DIR%" /eiycq
|
||||
xcopy ".\..\..\..\angle\src\common\winrtangle.h" "%OUT_DIR%" /iycq
|
||||
xcopy ".\..\..\..\angle\samples\gles2_book\Common\esUtil.h" "%OUT_DIR%" /iycq
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
How to compile precompiled shaders for Windows Phone 8.0 (WP8)
|
||||
|
||||
1. Open the VS project Cocos2dShaderCompiler\Cocos2dShaderCompiler.sln
|
||||
2. Build and run the project
|
||||
3. Click the Compile button
|
||||
4. Select the file cocos\platform\wp8\shaders\precompiledshaders.h in the file dialog box
|
||||
5. Program will precompile all of the cached cocos2d-x shaders.
|
|
@ -138,4 +138,4 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CCCAMERA_ACTION_H__
|
||||
#endif //__CCCAMERA_ACTION_H__
|
||||
|
|
|
@ -528,6 +528,8 @@ void RepeatForever::step(float dt)
|
|||
if (_innerAction->isDone())
|
||||
{
|
||||
float diff = _innerAction->getElapsed() - _innerAction->getDuration();
|
||||
if (diff > _innerAction->getDuration())
|
||||
diff = fmodf(diff, _innerAction->getDuration());
|
||||
_innerAction->startWithTarget(_target);
|
||||
// to prevent jerk. issue #390, 1247
|
||||
_innerAction->step(0.0f);
|
||||
|
@ -826,8 +828,26 @@ void RotateTo::update(float time)
|
|||
{
|
||||
if (_target)
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
if (_target->getPhysicsBody() != nullptr && _startAngleX == _startAngleY && _diffAngleX == _diffAngleY)
|
||||
{
|
||||
_target->setRotation(_startAngleX + _diffAngleX * time);
|
||||
}
|
||||
else
|
||||
{
|
||||
// _startAngleX != _startAngleY || _diffAngleX != _diffAngleY
|
||||
if (_target->getPhysicsBody() != nullptr)
|
||||
{
|
||||
CCLOG("RotateTo WARNING: PhysicsBody doesn't support skew rotation");
|
||||
}
|
||||
|
||||
_target->setRotationSkewX(_startAngleX + _diffAngleX * time);
|
||||
_target->setRotationSkewY(_startAngleY + _diffAngleY * time);
|
||||
}
|
||||
#else
|
||||
_target->setRotationSkewX(_startAngleX + _diffAngleX * time);
|
||||
_target->setRotationSkewY(_startAngleY + _diffAngleY * time);
|
||||
#endif // CC_USE_PHYSICS
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,8 +970,26 @@ void RotateBy::update(float time)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
if (_target->getPhysicsBody() != nullptr && _startAngleZ_X == _startAngleZ_Y && _angleZ_X == _angleZ_Y)
|
||||
{
|
||||
_target->setRotation(_startAngleZ_X + _angleZ_X * time);
|
||||
}
|
||||
else
|
||||
{
|
||||
// _startAngleZ_X != _startAngleZ_Y || _angleZ_X != _angleZ_Y
|
||||
if (_target->getPhysicsBody() != nullptr)
|
||||
{
|
||||
CCLOG("RotateBy WARNING: PhysicsBody doesn't support skew rotation");
|
||||
}
|
||||
|
||||
_target->setRotationSkewX(_startAngleZ_X + _angleZ_X * time);
|
||||
_target->setRotationSkewY(_startAngleZ_Y + _angleZ_Y * time);
|
||||
}
|
||||
#else
|
||||
_target->setRotationSkewX(_startAngleZ_X + _angleZ_X * time);
|
||||
_target->setRotationSkewY(_startAngleZ_Y + _angleZ_Y * time);
|
||||
#endif // CC_USE_PHYSICS
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,6 +370,7 @@ class CC_DLL RotateBy : public ActionInterval
|
|||
public:
|
||||
/** creates the action */
|
||||
static RotateBy* create(float duration, float deltaAngle);
|
||||
/** @warning The physics body contained in Node doesn't support rotate with different x and y angle. */
|
||||
static RotateBy* create(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
|
||||
static RotateBy* create(float duration, const Vec3& deltaAngle3D);
|
||||
|
||||
|
@ -387,6 +388,7 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
|
||||
/** initializes the action */
|
||||
bool initWithDuration(float duration, float deltaAngle);
|
||||
/** @warning The physics body contained in Node doesn't support rotate with different x and y angle. */
|
||||
bool initWithDuration(float duration, float deltaAngleZ_X, float deltaAngleZ_Y);
|
||||
bool initWithDuration(float duration, const Vec3& deltaAngle3D);
|
||||
|
||||
|
@ -675,6 +677,7 @@ private:
|
|||
|
||||
/** @brief Scales a Node object to a zoom factor by modifying it's scale attribute.
|
||||
@warning This action doesn't support "reverse"
|
||||
@warning The physics body contained in Node doesn't support this action.
|
||||
*/
|
||||
class CC_DLL ScaleTo : public ActionInterval
|
||||
{
|
||||
|
@ -726,6 +729,7 @@ private:
|
|||
};
|
||||
|
||||
/** @brief Scales a Node object a zoom factor by modifying it's scale attribute.
|
||||
@warning The physics body contained in Node doesn't support this action.
|
||||
*/
|
||||
class CC_DLL ScaleBy : public ScaleTo
|
||||
{
|
||||
|
|
|
@ -201,4 +201,4 @@ Animation* Animation::clone() const
|
|||
return a;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -237,4 +237,4 @@ void AnimationCache::addAnimationsWithFile(const std::string& plist)
|
|||
}
|
||||
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -142,6 +142,14 @@ bool ClippingNode::init(Node *stencil)
|
|||
|
||||
void ClippingNode::onEnter()
|
||||
{
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Node::onEnter();
|
||||
|
||||
if (_stencil != nullptr)
|
||||
|
|
|
@ -160,4 +160,4 @@ FontAtlas * FontCharMap::createFontAtlas()
|
|||
return tempAtlas;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -240,6 +240,7 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
|
|||
TextVAlignment vAlignment /* = TextVAlignment::TOP */,bool useDistanceField /* = false */,bool useA8Shader /* = false */)
|
||||
: _reusedLetter(nullptr)
|
||||
, _commonLineHeight(0.0f)
|
||||
, _additionalKerning(0.0f)
|
||||
, _lineBreakWithoutSpaces(false)
|
||||
, _maxLineWidth(0)
|
||||
, _labelWidth(0)
|
||||
|
@ -719,19 +720,30 @@ void Label::sortAllChildren()
|
|||
|
||||
void Label::enableGlow(const Color4B& glowColor)
|
||||
{
|
||||
if(! _useDistanceField)
|
||||
return;
|
||||
_currLabelEffect = LabelEffect::GLOW;
|
||||
_effectColor = glowColor;
|
||||
_effectColorF.r = _effectColor.r / 255.0f;
|
||||
_effectColorF.g = _effectColor.g / 255.0f;
|
||||
_effectColorF.b = _effectColor.b / 255.0f;
|
||||
_effectColorF.a = _effectColor.a / 255.0f;
|
||||
updateShaderProgram();
|
||||
if (_currentLabelType == LabelType::TTF)
|
||||
{
|
||||
if (_fontConfig.distanceFieldEnabled == false)
|
||||
{
|
||||
auto config = _fontConfig;
|
||||
config.outlineSize = 0;
|
||||
config.distanceFieldEnabled = true;
|
||||
setTTFConfig(config);
|
||||
_contentDirty = true;
|
||||
}
|
||||
_currLabelEffect = LabelEffect::GLOW;
|
||||
_effectColor = glowColor;
|
||||
_effectColorF.r = _effectColor.r / 255.0f;
|
||||
_effectColorF.g = _effectColor.g / 255.0f;
|
||||
_effectColorF.b = _effectColor.b / 255.0f;
|
||||
_effectColorF.a = _effectColor.a / 255.0f;
|
||||
updateShaderProgram();
|
||||
}
|
||||
}
|
||||
|
||||
void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */)
|
||||
{
|
||||
CCASSERT(_currentLabelType == LabelType::STRING_TEXTURE || _currentLabelType == LabelType::TTF, "Only supported system font and TTF!");
|
||||
|
||||
_effectColor = outlineColor;
|
||||
_effectColorF.r = _effectColor.r / 255.0f;
|
||||
_effectColorF.g = _effectColor.g / 255.0f;
|
||||
|
@ -1098,7 +1110,9 @@ void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t pare
|
|||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
setOrderOfArrival(0);
|
||||
// FIX ME: Why need to set _orderOfArrival to 0??
|
||||
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
|
||||
// setOrderOfArrival(0);
|
||||
}
|
||||
|
||||
void Label::setSystemFontName(const std::string& systemFont)
|
||||
|
@ -1163,9 +1177,38 @@ Sprite * Label::getLetter(int letterIndex)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int Label::getCommonLineHeight() const
|
||||
void Label::setLineHeight(float height)
|
||||
{
|
||||
return _textSprite ? 0 : _commonLineHeight;
|
||||
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
|
||||
|
||||
if (_commonLineHeight != height)
|
||||
{
|
||||
_commonLineHeight = height;
|
||||
_contentDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
float Label::getLineHeight() const
|
||||
{
|
||||
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
|
||||
return _textSprite ? 0.0f : _commonLineHeight;
|
||||
}
|
||||
|
||||
void Label::setAdditionalKerning(float space)
|
||||
{
|
||||
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
|
||||
if (_additionalKerning != space)
|
||||
{
|
||||
_additionalKerning = space;
|
||||
_contentDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
float Label::getAdditionalKerning() const
|
||||
{
|
||||
CCASSERT(_currentLabelType != LabelType::STRING_TEXTURE, "Not supported system font!");
|
||||
|
||||
return _additionalKerning;
|
||||
}
|
||||
|
||||
void Label::computeStringNumLines()
|
||||
|
@ -1247,6 +1290,8 @@ void Label::updateDisplayedOpacity(GLubyte parentOpacity)
|
|||
|
||||
void Label::setTextColor(const Color4B &color)
|
||||
{
|
||||
CCASSERT(_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::STRING_TEXTURE, "Only supported system font and ttf!");
|
||||
|
||||
_textColor = color;
|
||||
_textColorF.r = _textColor.r / 255.0f;
|
||||
_textColorF.g = _textColor.g / 255.0f;
|
||||
|
|
|
@ -91,6 +91,7 @@ public:
|
|||
|
||||
/** Creates a label with an initial string,font file,font size, dimension in points, horizontal alignment and vertical alignment.
|
||||
* @warning Not support font name.
|
||||
* @warning Cache textures for each different font size or font file.
|
||||
*/
|
||||
static Label * createWithTTF(const std::string& text, const std::string& fontFile, float fontSize,
|
||||
const Size& dimensions = Size::ZERO, TextHAlignment hAlignment = TextHAlignment::LEFT,
|
||||
|
@ -98,6 +99,8 @@ public:
|
|||
|
||||
/** Create a label with TTF configuration
|
||||
* @warning Not support font name.
|
||||
* @warning Cache textures for each different font file when enable distance field.
|
||||
* @warning Cache textures for each different font size or font file when disable distance field.
|
||||
*/
|
||||
static Label* createWithTTF(const TTFConfig& ttfConfig, const std::string& text, TextHAlignment alignment = TextHAlignment::LEFT, int maxLineWidth = 0);
|
||||
|
||||
|
@ -136,6 +139,17 @@ public:
|
|||
|
||||
virtual const std::string& getString() const override { return _originalUTF8String; }
|
||||
|
||||
/** Sets the text color of the label
|
||||
* Only support for TTF and system font
|
||||
* @warning Different from the color of Node.
|
||||
*/
|
||||
virtual void setTextColor(const Color4B &color);
|
||||
/** Returns the text color of this label
|
||||
* Only support for TTF and system font
|
||||
* @warning Different from the color of Node.
|
||||
*/
|
||||
const Color4B& getTextColor() const { return _textColor;}
|
||||
|
||||
/**
|
||||
* Enable shadow for the label
|
||||
*
|
||||
|
@ -193,22 +207,34 @@ public:
|
|||
/** update content immediately.*/
|
||||
virtual void updateContent();
|
||||
|
||||
/** Sets the text color
|
||||
*
|
||||
*/
|
||||
virtual void setTextColor(const Color4B &color);
|
||||
|
||||
const Color4B& getTextColor() const { return _textColor;}
|
||||
|
||||
virtual Sprite * getLetter(int lettetIndex);
|
||||
|
||||
/** clip upper and lower margin for reduce height of label.
|
||||
*/
|
||||
void setClipMarginEnabled(bool clipEnabled) { _clipEnabled = clipEnabled; }
|
||||
bool isClipMarginEnabled() const { return _clipEnabled; }
|
||||
// font related stuff
|
||||
int getCommonLineHeight() const;
|
||||
|
||||
|
||||
/** Sets the line height of the label
|
||||
@warning Not support system font
|
||||
@since v3.2.0
|
||||
*/
|
||||
void setLineHeight(float height);
|
||||
/** Returns the line height of this label
|
||||
@warning Not support system font
|
||||
*/
|
||||
float getLineHeight() const;
|
||||
|
||||
/** Sets the additional kerning of the label
|
||||
@warning Not support system font
|
||||
@since v3.2.0
|
||||
*/
|
||||
void setAdditionalKerning(float space);
|
||||
/** Returns the additional kerning of this label
|
||||
@warning Not support system font
|
||||
@since v3.2.0
|
||||
*/
|
||||
float getAdditionalKerning() const;
|
||||
|
||||
// string related stuff
|
||||
int getStringNumLines() const { return _currNumLines;}
|
||||
int getStringLength() const;
|
||||
|
@ -247,6 +273,8 @@ public:
|
|||
CC_DEPRECATED_ATTRIBUTE virtual void setFontDefinition(const FontDefinition& textDefinition);
|
||||
CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; }
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE int getCommonLineHeight() const { return getLineHeight();}
|
||||
|
||||
protected:
|
||||
void onDraw(const Mat4& transform, bool transformUpdated);
|
||||
|
||||
|
@ -331,6 +359,7 @@ protected:
|
|||
Rect _reusedRect;
|
||||
int _limitShowCount;
|
||||
|
||||
float _additionalKerning;
|
||||
float _commonLineHeight;
|
||||
bool _lineBreakWithoutSpaces;
|
||||
int * _horizontalKernings;
|
||||
|
|
|
@ -384,7 +384,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
|
|||
continue;
|
||||
}
|
||||
|
||||
nextFontPositionX += charAdvance + kernings[i];
|
||||
nextFontPositionX += charAdvance + kernings[i] + theLabel->_additionalKerning;
|
||||
|
||||
if (longestLine < nextFontPositionX)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,8 @@ THE SOFTWARE.
|
|||
#include "2d/CCNode.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCScheduler.h"
|
||||
|
@ -122,6 +124,8 @@ Node::Node(void)
|
|||
, _cascadeColorEnabled(false)
|
||||
, _cascadeOpacityEnabled(false)
|
||||
, _usingNormalizedPosition(false)
|
||||
, _name("")
|
||||
, _hashOfName(0)
|
||||
{
|
||||
// set default scheduler and actionManager
|
||||
Director *director = Director::getInstance();
|
||||
|
@ -199,6 +203,13 @@ void Node::setSkewX(float skewX)
|
|||
if (_skewX == skewX)
|
||||
return;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setSkewX");
|
||||
}
|
||||
#endif
|
||||
|
||||
_skewX = skewX;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
@ -213,6 +224,13 @@ void Node::setSkewY(float skewY)
|
|||
if (_skewY == skewY)
|
||||
return;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setSkewY");
|
||||
}
|
||||
#endif
|
||||
|
||||
_skewY = skewY;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
@ -294,10 +312,9 @@ void Node::setRotation3D(const Vec3& rotation)
|
|||
_rotationZ_Y = _rotationZ_X = rotation.z;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody)
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
Scene* scene = _physicsBody->getWorld() != nullptr ? &_physicsBody->getWorld()->getScene() : nullptr;
|
||||
updatePhysicsBodyRotation(scene);
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setRotation3D");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -315,6 +332,13 @@ void Node::setRotationSkewX(float rotationX)
|
|||
if (_rotationZ_X == rotationX)
|
||||
return;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setRotationSkewX");
|
||||
}
|
||||
#endif
|
||||
|
||||
_rotationZ_X = rotationX;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
@ -329,6 +353,13 @@ void Node::setRotationSkewY(float rotationY)
|
|||
if (_rotationZ_Y == rotationY)
|
||||
return;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setRotationSkewY");
|
||||
}
|
||||
#endif
|
||||
|
||||
_rotationZ_Y = rotationY;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
@ -345,7 +376,14 @@ void Node::setScale(float scale)
|
|||
{
|
||||
if (_scaleX == scale)
|
||||
return;
|
||||
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setScale");
|
||||
}
|
||||
#endif
|
||||
|
||||
_scaleX = _scaleY = _scaleZ = scale;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
@ -362,6 +400,13 @@ void Node::setScale(float scaleX,float scaleY)
|
|||
if (_scaleX == scaleX && _scaleY == scaleY)
|
||||
return;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setScale");
|
||||
}
|
||||
#endif
|
||||
|
||||
_scaleX = scaleX;
|
||||
_scaleY = scaleY;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
@ -373,6 +418,13 @@ void Node::setScaleX(float scaleX)
|
|||
if (_scaleX == scaleX)
|
||||
return;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setScaleX");
|
||||
}
|
||||
#endif
|
||||
|
||||
_scaleX = scaleX;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
@ -389,6 +441,13 @@ void Node::setScaleZ(float scaleZ)
|
|||
if (_scaleZ == scaleZ)
|
||||
return;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setScaleZ");
|
||||
}
|
||||
#endif
|
||||
|
||||
_scaleZ = scaleZ;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
@ -405,6 +464,13 @@ void Node::setScaleY(float scaleY)
|
|||
if (_scaleY == scaleY)
|
||||
return;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
CCLOG("Node WARNING: PhysicsBody doesn't support setScaleY");
|
||||
}
|
||||
#endif
|
||||
|
||||
_scaleY = scaleY;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
|
@ -624,6 +690,18 @@ void Node::setTag(int tag)
|
|||
_tag = tag ;
|
||||
}
|
||||
|
||||
std::string Node::getName() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void Node::setName(const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
std::hash<std::string> h;
|
||||
_hashOfName = h(name);
|
||||
}
|
||||
|
||||
/// userData setter
|
||||
void Node::setUserData(void *userData)
|
||||
{
|
||||
|
@ -677,7 +755,7 @@ GLProgram * Node::getGLProgram() const
|
|||
return _glProgramState ? _glProgramState->getGLProgram() : nullptr;
|
||||
}
|
||||
|
||||
Scene* Node::getScene()
|
||||
Scene* Node::getScene() const
|
||||
{
|
||||
if(!_parent)
|
||||
return nullptr;
|
||||
|
@ -750,6 +828,159 @@ Node* Node::getChildByTag(int tag) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Node* Node::getChildByName(const std::string& name) const
|
||||
{
|
||||
CCASSERT(name.length() != 0, "Invalid name");
|
||||
|
||||
std::hash<std::string> h;
|
||||
size_t hash = h(name);
|
||||
|
||||
for (const auto& child : _children)
|
||||
{
|
||||
// Different strings may have the same hash code, but can use it to compare first for speed
|
||||
if(child->_hashOfName == hash && child->_name.compare(name) == 0)
|
||||
return child;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Node::enumerateChildren(const std::string &name, std::function<bool (Node *)> callback) const
|
||||
{
|
||||
CCASSERT(name.length() != 0, "Invalid name");
|
||||
CCASSERT(callback != nullptr, "Invalid callback function");
|
||||
|
||||
size_t length = name.length();
|
||||
|
||||
size_t subStrStartPos = 0; // sub string start index
|
||||
size_t subStrlength = length; // sub string length
|
||||
|
||||
// Starts with '/' or '//'?
|
||||
bool searchFromRoot = false;
|
||||
bool searchFromRootRecursive = false;
|
||||
if (name[0] == '/')
|
||||
{
|
||||
if (length > 2 && name[1] == '/')
|
||||
{
|
||||
searchFromRootRecursive = true;
|
||||
subStrStartPos = 2;
|
||||
subStrlength -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
searchFromRoot = true;
|
||||
subStrStartPos = 1;
|
||||
subStrlength -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// End with '/..'?
|
||||
bool searchFromParent = false;
|
||||
if (length > 3 &&
|
||||
name[length-3] == '/' &&
|
||||
name[length-2] == '.' &&
|
||||
name[length-1] == '.')
|
||||
{
|
||||
searchFromParent = true;
|
||||
subStrlength -= 3;
|
||||
}
|
||||
|
||||
// Remove '/', '//' and '/..' if exist
|
||||
std::string newName = name.substr(subStrStartPos, subStrlength);
|
||||
// If search from parent, then add * at first to make it match its children, which will do make
|
||||
if (searchFromParent)
|
||||
{
|
||||
newName.insert(0, "[[:alnum:]]+/");
|
||||
}
|
||||
|
||||
if (searchFromRoot)
|
||||
{
|
||||
// name is '/xxx'
|
||||
auto root = getScene();
|
||||
if (root)
|
||||
{
|
||||
root->doEnumerate(newName, callback);
|
||||
}
|
||||
}
|
||||
else if (searchFromRootRecursive)
|
||||
{
|
||||
// name is '//xxx'
|
||||
auto root = getScene();
|
||||
if (root)
|
||||
{
|
||||
doEnumerateRecursive(root, newName, callback);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// name is xxx
|
||||
doEnumerate(newName, callback);
|
||||
}
|
||||
}
|
||||
|
||||
bool Node::doEnumerateRecursive(const Node* node, const std::string &name, std::function<bool (Node *)> callback) const
|
||||
{
|
||||
bool ret =false;
|
||||
|
||||
if (node->doEnumerate(name, callback))
|
||||
{
|
||||
// search itself
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// search its children
|
||||
for (const auto& child : node->getChildren())
|
||||
{
|
||||
if (doEnumerateRecursive(child, name, callback))
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Node::doEnumerate(std::string name, std::function<bool (Node *)> callback) const
|
||||
{
|
||||
// name may be xxx/yyy, should find its parent
|
||||
size_t pos = name.find('/');
|
||||
std::string searchName = name;
|
||||
bool needRecursive = false;
|
||||
if (pos != name.npos)
|
||||
{
|
||||
searchName = name.substr(0, pos);
|
||||
name.erase(0, pos+1);
|
||||
needRecursive = true;
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
for (const auto& child : _children)
|
||||
{
|
||||
if(std::regex_match(child->_name, std::regex(searchName)))
|
||||
{
|
||||
if (!needRecursive)
|
||||
{
|
||||
// terminate enumeration if callback return true
|
||||
if (callback(child))
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = child->doEnumerate(name, callback);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* "add" logic MUST only be on this method
|
||||
* If a class want's to extend the 'addChild' behavior it only needs
|
||||
* to override this method
|
||||
|
@ -1041,6 +1272,11 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t paren
|
|||
}
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
||||
// FIX ME: Why need to set _orderOfArrival to 0??
|
||||
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
|
||||
// reset for next frame
|
||||
// _orderOfArrival = 0;
|
||||
}
|
||||
|
||||
Mat4 Node::transform(const Mat4& parentTransform)
|
||||
|
@ -1050,46 +1286,12 @@ Mat4 Node::transform(const Mat4& parentTransform)
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
|
||||
static bool sendNodeEventToJS(Node* node, int action)
|
||||
{
|
||||
auto scriptEngine = ScriptEngineManager::getInstance()->getScriptEngine();
|
||||
|
||||
if (scriptEngine->isCalledFromScript())
|
||||
{
|
||||
scriptEngine->setCalledFromScript(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
BasicScriptData data(node,(void*)&action);
|
||||
ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
|
||||
if (scriptEngine->sendEvent(&scriptEvent))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void sendNodeEventToLua(Node* node, int action)
|
||||
{
|
||||
auto scriptEngine = ScriptEngineManager::getInstance()->getScriptEngine();
|
||||
|
||||
BasicScriptData data(node,(void*)&action);
|
||||
ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
|
||||
|
||||
scriptEngine->sendEvent(&scriptEvent);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Node::onEnter()
|
||||
{
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnter))
|
||||
if (ScriptEngineManager::sendNodeEventToJS(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -1106,7 +1308,7 @@ void Node::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnter);
|
||||
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1116,7 +1318,7 @@ void Node::onEnterTransitionDidFinish()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnEnterTransitionDidFinish))
|
||||
if (ScriptEngineManager::sendNodeEventToJS(this, kNodeOnEnterTransitionDidFinish))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -1128,7 +1330,7 @@ void Node::onEnterTransitionDidFinish()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnEnterTransitionDidFinish);
|
||||
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnEnterTransitionDidFinish);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1138,7 +1340,7 @@ void Node::onExitTransitionDidStart()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnExitTransitionDidStart))
|
||||
if (ScriptEngineManager::sendNodeEventToJS(this, kNodeOnExitTransitionDidStart))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -1149,7 +1351,7 @@ void Node::onExitTransitionDidStart()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnExitTransitionDidStart);
|
||||
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnExitTransitionDidStart);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1159,7 +1361,7 @@ void Node::onExit()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendNodeEventToJS(this, kNodeOnExit))
|
||||
if (ScriptEngineManager::sendNodeEventToJS(this, kNodeOnExit))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -1174,7 +1376,7 @@ void Node::onExit()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeLua)
|
||||
{
|
||||
sendNodeEventToLua(this, kNodeOnExit);
|
||||
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnExit);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -201,6 +201,8 @@ public:
|
|||
* It is a scaling factor that multiplies the width of the node and its children.
|
||||
*
|
||||
* @param scaleX The scale factor on X axis.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setScaleX(float scaleX);
|
||||
/**
|
||||
|
@ -219,6 +221,8 @@ public:
|
|||
* It is a scaling factor that multiplies the height of the node and its children.
|
||||
*
|
||||
* @param scaleY The scale factor on Y axis.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setScaleY(float scaleY);
|
||||
/**
|
||||
|
@ -236,6 +240,8 @@ public:
|
|||
* The Default value is 1.0 if you haven't changed it before.
|
||||
*
|
||||
* @param scaleY The scale factor on Y axis.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setScaleZ(float scaleZ);
|
||||
/**
|
||||
|
@ -254,6 +260,8 @@ public:
|
|||
* It is a scaling factor that multiplies the width, height and depth of the node and its children.
|
||||
*
|
||||
* @param scale The scale factor for both X and Y axis.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setScale(float scale);
|
||||
/**
|
||||
|
@ -273,6 +281,8 @@ public:
|
|||
*
|
||||
* @param scaleX The scale factor on X axis.
|
||||
* @param scaleY The scale factor on Y axis.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setScale(float scaleX, float scaleY);
|
||||
|
||||
|
@ -395,6 +405,8 @@ public:
|
|||
* The default skewX angle is 0. Positive values distort the node in a CW direction.
|
||||
*
|
||||
* @param skewX The X skew angle of the node in degrees.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setSkewX(float skewX);
|
||||
/**
|
||||
|
@ -418,6 +430,8 @@ public:
|
|||
* The default skewY angle is 0. Positive values distort the node in a CCW direction.
|
||||
*
|
||||
* @param skewY The Y skew angle of the node in degrees.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setSkewY(float skewY);
|
||||
/**
|
||||
|
@ -520,6 +534,8 @@ public:
|
|||
/**
|
||||
* Sets the rotation (X,Y,Z) in degrees.
|
||||
* Useful for 3d rotations
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setRotation3D(const Vec3& rotation);
|
||||
/**
|
||||
|
@ -537,6 +553,8 @@ public:
|
|||
* Positive values rotate node clockwise, and negative values for anti-clockwise.
|
||||
*
|
||||
* @param rotationX The X rotation in degrees which performs a horizontal rotational skew.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setRotationSkewX(float rotationX);
|
||||
CC_DEPRECATED_ATTRIBUTE virtual void setRotationX(float rotationX) { return setRotationSkewX(rotationX); }
|
||||
|
@ -561,6 +579,8 @@ public:
|
|||
* Positive values rotate node clockwise, and negative values for anti-clockwise.
|
||||
*
|
||||
* @param rotationY The Y rotation in degrees.
|
||||
*
|
||||
* @warning The physics body doesn't support this.
|
||||
*/
|
||||
virtual void setRotationSkewY(float rotationY);
|
||||
CC_DEPRECATED_ATTRIBUTE virtual void setRotationY(float rotationY) { return setRotationSkewY(rotationY); }
|
||||
|
@ -667,6 +687,48 @@ public:
|
|||
* @return a Node object whose tag equals to the input parameter
|
||||
*/
|
||||
virtual Node * getChildByTag(int tag) const;
|
||||
/**
|
||||
* Gets a child from the container with its name
|
||||
*
|
||||
* @param name An identifier to find the child node.
|
||||
*
|
||||
* @return a Node object whose name equals to the input parameter
|
||||
*
|
||||
* @since v3.2
|
||||
*/
|
||||
virtual Node* getChildByName(const std::string& name) const;
|
||||
/** Search the children of the receiving node to perform processing for nodes which share a name.
|
||||
*
|
||||
* @param name The name to search for, support c++11 regular expression
|
||||
* Search syntax options:
|
||||
* `/` : When placed at the start of the search string, this indicates that the search should be performed on the tree's node.
|
||||
* `//`: Can only be placed at the begin of the search string. This indicates that the search should be performed on the tree's node
|
||||
* and be performed recursively across the entire node tree.
|
||||
* `..`: The search should move up to the node's parent. Can only be placed at the end of string
|
||||
* `/` : When placed anywhere but the start of the search string, this indicates that the search should move to the node's children
|
||||
*
|
||||
* @code
|
||||
* enumerateChildren("/MyName", ...): This searches the root's children and matches any node with the name `MyName`.
|
||||
* enumerateChildren("//MyName", ...): This searches the root's children recursively and matches any node with the name `MyName`.
|
||||
* enumerateChildren("[[:alnum:]]+", ...): This search string matches every node of its children.
|
||||
* enumerateChildren("/MyName", ...): This searches the node tree and matches the parent node of every node named `MyName`.
|
||||
* enumerateChildren("A[[:digit:]]", ...): This searches the node's children and returns any child named `A0`, `A1`, ..., `A9`
|
||||
* enumerateChildren("Abby/Normal", ...): This searches the node's grandchildren and returns any node whose name is `Normal`
|
||||
* and whose parent is named `Abby`.
|
||||
* enumerateChildren("//Abby/Normal", ...): This searches the node tree and returns any node whose name is `Normal` and whose
|
||||
* parent is named `Abby`.
|
||||
* @endcode
|
||||
*
|
||||
* @warning Only support alpha or number for name, and not support unicode
|
||||
*
|
||||
* @param callback A callback function to execute on nodes that match the `name` parameter. The function takes the following arguments:
|
||||
* `node`
|
||||
* A node that matches the name
|
||||
* And returns a boolean result. Your callback can return `true` to terminate the enumeration.
|
||||
*
|
||||
* @since v3.2
|
||||
*/
|
||||
virtual void enumerateChildren(const std::string &name, std::function<bool(Node* node)> callback) const;
|
||||
/**
|
||||
* Returns the array of the node's children
|
||||
*
|
||||
|
@ -780,6 +842,19 @@ public:
|
|||
* @param tag A integer that identifies the node.
|
||||
*/
|
||||
virtual void setTag(int tag);
|
||||
|
||||
/** Returns a string that is used to identify the node.
|
||||
* @return A string that identifies the node.
|
||||
*
|
||||
* @since v3.2
|
||||
*/
|
||||
virtual std::string getName() const;
|
||||
/** Changes the name that is used to identify the node easily.
|
||||
* @param name A string that identifies the node.
|
||||
*
|
||||
* @since v3.2
|
||||
*/
|
||||
virtual void setName(const std::string& name);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -960,7 +1035,7 @@ public:
|
|||
It returns `nullptr` if the node doesn't belong to any Scene.
|
||||
This function recursively calls parent->getScene() until parent is a Scene object. The results are not cached. It is that the user caches the results in case this functions is being used inside a loop.
|
||||
*/
|
||||
virtual Scene* getScene();
|
||||
virtual Scene* getScene() const;
|
||||
|
||||
/**
|
||||
* Returns an AABB (axis-aligned bounding-box) in its parent's coordinate system.
|
||||
|
@ -1393,6 +1468,9 @@ protected:
|
|||
virtual void disableCascadeColor();
|
||||
virtual void updateColor() {}
|
||||
|
||||
bool doEnumerate(std::string name, std::function<bool (Node *)> callback) const;
|
||||
bool doEnumerateRecursive(const Node* node, const std::string &name, std::function<bool (Node *)> callback) const;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
virtual void updatePhysicsBodyPosition(Scene* layer);
|
||||
virtual void updatePhysicsBodyRotation(Scene* layer);
|
||||
|
@ -1443,6 +1521,7 @@ protected:
|
|||
int _tag; ///< a tag. Can be any number you assigned just to identify this node
|
||||
|
||||
std::string _name; ///<a string label, an user defined string to identify this node
|
||||
size_t _hashOfName; ///<hash value of _name, used for speed in getChildByName
|
||||
|
||||
void *_userData; ///< A user assingned void pointer, Can be point to any cpp object
|
||||
Ref *_userObject; ///< A user assigned Object
|
||||
|
|
|
@ -74,4 +74,4 @@ private:
|
|||
};
|
||||
NS_CC_END
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -616,6 +616,14 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
|
||||
void ParticleSystem::onEnter()
|
||||
{
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Node::onEnter();
|
||||
|
||||
// update after action in run!
|
||||
|
|
|
@ -98,9 +98,10 @@ std::string Scene::getDescription() const
|
|||
return StringUtils::format("<Scene | tag = %d>", _tag);
|
||||
}
|
||||
|
||||
Scene* Scene::getScene()
|
||||
Scene* Scene::getScene() const
|
||||
{
|
||||
return this;
|
||||
// FIX ME: should use const_case<> to fix compiling error
|
||||
return const_cast<Scene*>(this);
|
||||
}
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
static Scene *createWithSize(const Size& size);
|
||||
|
||||
// Overrides
|
||||
virtual Scene *getScene() override;
|
||||
virtual Scene *getScene() const override;
|
||||
|
||||
using Node::addChild;
|
||||
virtual std::string getDescription() const override;
|
||||
|
|
|
@ -521,8 +521,8 @@ void Sprite::updateTransform(void)
|
|||
else
|
||||
{
|
||||
CCASSERT( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
|
||||
Mat4 nodeToParent = getNodeToParentTransform();
|
||||
Mat4 parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch;
|
||||
const Mat4 &nodeToParent = getNodeToParentTransform();
|
||||
Mat4 &parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch;
|
||||
_transformToBatch = parentTransform * nodeToParent;
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ void Sprite::updateTransform(void)
|
|||
// calculate the Quad based on the Affine Matrix
|
||||
//
|
||||
|
||||
Size size = _rect.size;
|
||||
Size &size = _rect.size;
|
||||
|
||||
float x1 = _offsetPosition.x;
|
||||
float y1 = _offsetPosition.y;
|
||||
|
|
|
@ -162,7 +162,9 @@ void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uin
|
|||
draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
setOrderOfArrival(0);
|
||||
// FIX ME: Why need to set _orderOfArrival to 0??
|
||||
// Please refer to https://github.com/cocos2d/cocos2d-x/pull/6920
|
||||
// setOrderOfArrival(0);
|
||||
|
||||
CC_PROFILER_STOP_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit");
|
||||
}
|
||||
|
|
|
@ -110,4 +110,4 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CCTMX_OBJECT_GROUP_H__
|
||||
#endif //__CCTMX_OBJECT_GROUP_H__
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;$(EngineRoot)external\ConvertUTF;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;$(EngineRoot)external\ConvertUTF;$(EngineRoot)external;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
|
@ -99,6 +99,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\jpeg\prebuilt\win32\*.*" "$(OutDir)"
|
|||
xcopy /Y /Q "$(ProjectDir)..\..\external\png\prebuilt\win32\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\tiff\prebuilt\win32\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\webp\prebuilt\win32\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\zlib\prebuilt\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\icon\prebuilt\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(OutDir)"
|
||||
|
@ -125,16 +126,18 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
</Command>
|
||||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;$(EngineRoot)external\ConvertUTF;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\win32;$(EngineRoot)external\jpeg\include\win32;$(EngineRoot)external\tiff\include\win32;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\win32;$(EngineRoot)external\win32-specific\icon\include;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;$(EngineRoot)external\ConvertUTF;$(EngineRoot)external;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
</ClCompile>
|
||||
<PreLinkEvent>
|
||||
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
|
||||
|
@ -145,6 +148,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\jpeg\prebuilt\win32\*.*" "$(OutDir)"
|
|||
xcopy /Y /Q "$(ProjectDir)..\..\external\png\prebuilt\win32\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\tiff\prebuilt\win32\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\webp\prebuilt\win32\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\zlib\prebuilt\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\icon\prebuilt\*.*" "$(OutDir)"
|
||||
xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(OutDir)"
|
||||
|
@ -175,10 +179,14 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClCompile Include="..\..\external\unzip\ioapi.cpp" />
|
||||
<ClCompile Include="..\..\external\unzip\unzip.cpp" />
|
||||
<ClCompile Include="..\..\external\xxhash\xxhash.c" />
|
||||
<ClCompile Include="..\3d\CCAnimate3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCAnimation3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCBundle3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCMesh.cpp" />
|
||||
<ClCompile Include="..\3d\CCMeshSkin.cpp" />
|
||||
<ClCompile Include="..\3d\CCObjLoader.cpp" />
|
||||
<ClCompile Include="..\3d\CCSprite3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCSprite3DDataCache.cpp" />
|
||||
<ClCompile Include="..\3d\CCSprite3DMaterial.cpp" />
|
||||
<ClCompile Include="..\base\atitc.cpp" />
|
||||
<ClCompile Include="..\base\base64.cpp" />
|
||||
<ClCompile Include="..\base\CCAutoreleasePool.cpp" />
|
||||
|
@ -347,10 +355,16 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClInclude Include="..\..\external\unzip\ioapi.h" />
|
||||
<ClInclude Include="..\..\external\unzip\unzip.h" />
|
||||
<ClInclude Include="..\..\external\xxhash\xxhash.h" />
|
||||
<ClInclude Include="..\3d\CCAnimate3D.h" />
|
||||
<ClInclude Include="..\3d\CCAnimation3D.h" />
|
||||
<ClInclude Include="..\3d\CCAnimationCurve.h" />
|
||||
<ClInclude Include="..\3d\CCBundle3D.h" />
|
||||
<ClInclude Include="..\3d\CCBundle3DData.h" />
|
||||
<ClInclude Include="..\3d\CCMesh.h" />
|
||||
<ClInclude Include="..\3d\CCMeshSkin.h" />
|
||||
<ClInclude Include="..\3d\CCObjLoader.h" />
|
||||
<ClInclude Include="..\3d\CCSprite3D.h" />
|
||||
<ClInclude Include="..\3d\CCSprite3DDataCache.h" />
|
||||
<ClInclude Include="..\3d\CCSprite3DMaterial.h" />
|
||||
<ClInclude Include="..\base\atitc.h" />
|
||||
<ClInclude Include="..\base\base64.h" />
|
||||
<ClInclude Include="..\base\CCAutoreleasePool.h" />
|
||||
|
@ -537,6 +551,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClInclude Include="CCTweenFunction.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\3d\CCAnimationCurve.inl" />
|
||||
<None Include="..\math\Mat4.inl" />
|
||||
<None Include="..\math\MathUtil.inl" />
|
||||
<None Include="..\math\MathUtilNeon.inl" />
|
||||
|
|
|
@ -562,12 +562,24 @@
|
|||
<ClCompile Include="..\3d\CCSprite3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCSprite3DDataCache.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\ObjectFactory.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCBundle3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCAnimate3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCMeshSkin.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCAnimation3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCSprite3DMaterial.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||
|
@ -1144,12 +1156,30 @@
|
|||
<ClInclude Include="..\3d\CCSprite3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCSprite3DDataCache.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\ObjectFactory.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCBundle3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCAnimate3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCAnimationCurve.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCMeshSkin.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCAnimation3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCBundle3DData.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCSprite3DMaterial.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\math\Mat4.inl">
|
||||
|
@ -1173,5 +1203,8 @@
|
|||
<None Include="..\math\Vec4.inl">
|
||||
<Filter>math</Filter>
|
||||
</None>
|
||||
<None Include="..\3d\CCAnimationCurve.inl">
|
||||
<Filter>3d</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -139,7 +139,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WINRT;_DEBUG;_LIB;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -160,7 +160,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WINRT;NDEBUG;_LIB;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -181,7 +181,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WINRT;_DEBUG;_LIB;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -202,7 +202,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WINRT;NDEBUG;_LIB;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -223,7 +223,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WINRT;_DEBUG;_LIB;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -244,7 +244,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external;$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\winrt;$(EngineRoot)external\jpeg\include\winrt;$(EngineRoot)external\tiff\include\winrt;$(EngineRoot)external\webp\include\win32;$(EngineRoot)external\freetype2\include\winrt;$(EngineRoot)external\winrt-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WINRT;NDEBUG;_LIB;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -312,7 +312,6 @@
|
|||
<ClCompile Include="..\3d\CCMesh.cpp" />
|
||||
<ClCompile Include="..\3d\CCObjLoader.cpp" />
|
||||
<ClCompile Include="..\3d\CCSprite3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCSprite3DDataCache.cpp" />
|
||||
<ClCompile Include="..\base\atitc.cpp" />
|
||||
<ClCompile Include="..\base\base64.cpp" />
|
||||
<ClCompile Include="..\base\CCAutoreleasePool.cpp" />
|
||||
|
@ -505,7 +504,6 @@
|
|||
<ClInclude Include="..\3d\CCMesh.h" />
|
||||
<ClInclude Include="..\3d\CCObjLoader.h" />
|
||||
<ClInclude Include="..\3d\CCSprite3D.h" />
|
||||
<ClInclude Include="..\3d\CCSprite3DDataCache.h" />
|
||||
<ClInclude Include="..\base\atitc.h" />
|
||||
<ClInclude Include="..\base\base64.h" />
|
||||
<ClInclude Include="..\base\CCAutoreleasePool.h" />
|
||||
|
|
|
@ -308,9 +308,6 @@
|
|||
<ClCompile Include="..\3d\CCSprite3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCSprite3DDataCache.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\atitc.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
@ -858,9 +855,6 @@
|
|||
<ClInclude Include="..\3d\CCSprite3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCSprite3DDataCache.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\atitc.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -222,10 +222,14 @@
|
|||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCAnimate3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCAnimation3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCBundle3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCMesh.cpp" />
|
||||
<ClCompile Include="..\3d\CCMeshSkin.cpp" />
|
||||
<ClCompile Include="..\3d\CCObjLoader.cpp" />
|
||||
<ClCompile Include="..\3d\CCSprite3D.cpp" />
|
||||
<ClCompile Include="..\3d\CCSprite3DDataCache.cpp" />
|
||||
<ClCompile Include="..\3d\CCSprite3DMaterial.cpp" />
|
||||
<ClCompile Include="..\base\atitc.cpp" />
|
||||
<ClCompile Include="..\base\base64.cpp" />
|
||||
<ClCompile Include="..\base\CCAutoreleasePool.cpp" />
|
||||
|
@ -424,10 +428,16 @@
|
|||
<ClInclude Include="..\..\external\unzip\ioapi.h" />
|
||||
<ClInclude Include="..\..\external\unzip\unzip.h" />
|
||||
<ClInclude Include="..\..\external\xxhash\xxhash.h" />
|
||||
<ClInclude Include="..\3d\CCAnimate3D.h" />
|
||||
<ClInclude Include="..\3d\CCAnimation3D.h" />
|
||||
<ClInclude Include="..\3d\CCAnimationCurve.h" />
|
||||
<ClInclude Include="..\3d\CCBundle3D.h" />
|
||||
<ClInclude Include="..\3d\CCBundle3DData.h" />
|
||||
<ClInclude Include="..\3d\CCMesh.h" />
|
||||
<ClInclude Include="..\3d\CCMeshSkin.h" />
|
||||
<ClInclude Include="..\3d\CCObjLoader.h" />
|
||||
<ClInclude Include="..\3d\CCSprite3D.h" />
|
||||
<ClInclude Include="..\3d\CCSprite3DDataCache.h" />
|
||||
<ClInclude Include="..\3d\CCSprite3DMaterial.h" />
|
||||
<ClInclude Include="..\base\atitc.h" />
|
||||
<ClInclude Include="..\base\base64.h" />
|
||||
<ClInclude Include="..\base\CCAutoreleasePool.h" />
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
<Filter Include="deprecated">
|
||||
<UniqueIdentifier>{5598fb0c-c012-45b6-8e43-447e7891b61d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="2d">
|
||||
<UniqueIdentifier>{fdee8fd3-05f9-46a1-aa15-6ceb16358145}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="3d">
|
||||
<UniqueIdentifier>{f3673af7-9bbd-463b-a3a9-a081e67248d8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -55,6 +52,9 @@
|
|||
<Filter Include="external\xxhash">
|
||||
<UniqueIdentifier>{a36c6808-a8d6-43f4-bfb0-e08ee2747a21}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="2d">
|
||||
<UniqueIdentifier>{fdee8fd3-05f9-46a1-aa15-6ceb16358145}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\physics\CCPhysicsBody.cpp">
|
||||
|
@ -586,9 +586,6 @@
|
|||
<ClCompile Include="..\3d\CCSprite3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCSprite3DDataCache.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\renderer\CCMeshCommand.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
|
@ -596,6 +593,21 @@
|
|||
<ClCompile Include="..\base\ObjectFactory.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCAnimate3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCAnimation3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCBundle3D.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCMeshSkin.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\3d\CCSprite3DMaterial.cpp">
|
||||
<Filter>3d</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||
|
@ -1201,9 +1213,6 @@
|
|||
<ClInclude Include="..\3d\CCSprite3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCSprite3DDataCache.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\renderer\CCMeshCommand.h">
|
||||
<Filter>renderer</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1211,6 +1220,27 @@
|
|||
<ClInclude Include="..\base\ObjectFactory.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCAnimate3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCAnimation3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCAnimationCurve.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCBundle3D.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCBundle3DData.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCMeshSkin.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCSprite3DMaterial.h">
|
||||
<Filter>3d</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\math\Mat4.inl">
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "3d/CCAnimate3D.h"
|
||||
#include "3d/CCAnimation3D.h"
|
||||
#include "3d/CCSprite3D.h"
|
||||
#include "3d/CCMeshSkin.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
//create Animate3D using Animation.
|
||||
Animate3D* Animate3D::create(Animation3D* animation)
|
||||
{
|
||||
auto animate = new Animate3D();
|
||||
animate->_animation = animation;
|
||||
animation->retain();
|
||||
|
||||
animate->autorelease();
|
||||
animate->setDuration(animation->getDuration());
|
||||
|
||||
return animate;
|
||||
}
|
||||
|
||||
/** returns a clone of action */
|
||||
Animate3D* Animate3D::clone() const
|
||||
{
|
||||
|
||||
auto animate = const_cast<Animate3D*>(this);
|
||||
auto copy = Animate3D::create(animate->_animation);
|
||||
|
||||
copy->_speed = _speed;
|
||||
copy->_elapsed = _elapsed;
|
||||
copy->_playBack = _playBack;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
/** returns a new action that performs the exactly the reverse action */
|
||||
Animate3D* Animate3D::reverse() const
|
||||
{
|
||||
auto animate = clone();
|
||||
animate->_playBack = !animate->_playBack;
|
||||
return animate;
|
||||
}
|
||||
|
||||
//! called before the action start. It will also set the target.
|
||||
void Animate3D::startWithTarget(Node *target)
|
||||
{
|
||||
Sprite3D* sprite = dynamic_cast<Sprite3D*>(target);
|
||||
CCASSERT(sprite && sprite->getSkin() && _animation, "Animate3D apply to Sprite3D only");
|
||||
|
||||
ActionInterval::startWithTarget(target);
|
||||
|
||||
_boneCurves.clear();
|
||||
auto skin = sprite->getSkin();
|
||||
for (unsigned int i = 0; i < skin->getBoneCount(); i++) {
|
||||
auto bone = skin->getBoneByIndex(i);
|
||||
auto curve = _animation->getBoneCurveByName(bone->getName());
|
||||
if (curve)
|
||||
{
|
||||
_boneCurves[bone] = curve;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("warning: bone %s not find in animation", bone->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! called every frame with it's delta time. DON'T override unless you know what you are doing.
|
||||
void Animate3D::step(float dt)
|
||||
{
|
||||
ActionInterval::step(dt * _speed);
|
||||
}
|
||||
|
||||
void Animate3D::update(float t)
|
||||
{
|
||||
if (_target)
|
||||
{
|
||||
float transDst[3], rotDst[4], scaleDst[3];
|
||||
float* trans = nullptr, *rot = nullptr, *scale = nullptr;
|
||||
if (_playBack)
|
||||
t = 1 - t;
|
||||
|
||||
for (const auto& it : _boneCurves) {
|
||||
auto bone = it.first;
|
||||
auto curve = it.second;
|
||||
if (curve->translateCurve)
|
||||
{
|
||||
curve->translateCurve->evaluate(t, transDst, EvaluateType::INT_LINEAR);
|
||||
trans = &transDst[0];
|
||||
}
|
||||
if (curve->rotCurve)
|
||||
{
|
||||
curve->rotCurve->evaluate(t, rotDst, EvaluateType::INT_QUAT_SLERP);
|
||||
rot = &rotDst[0];
|
||||
}
|
||||
if (curve->scaleCurve)
|
||||
{
|
||||
curve->scaleCurve->evaluate(t, scaleDst, EvaluateType::INT_LINEAR);
|
||||
scale = &scaleDst[0];
|
||||
}
|
||||
bone->setAnimationValue(trans, rot, scale, _weight);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Animate3D::Animate3D()
|
||||
: _speed(1)
|
||||
, _weight(1.f)
|
||||
, _animation(nullptr)
|
||||
, _playBack(false)
|
||||
{
|
||||
|
||||
}
|
||||
Animate3D::~Animate3D()
|
||||
{
|
||||
CC_SAFE_RELEASE(_animation);
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,82 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCANIMATE3D_H__
|
||||
#define __CCANIMATE3D_H__
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "3d/CCAnimation3D.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "2d/CCActionInterval.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Animation3D;
|
||||
class Bone;
|
||||
/**
|
||||
* Animate3D
|
||||
*/
|
||||
class Animate3D: public ActionInterval
|
||||
{
|
||||
public:
|
||||
|
||||
//create Animate3D using Animation.
|
||||
static Animate3D* create(Animation3D* animation);
|
||||
|
||||
//
|
||||
// Overrides
|
||||
//
|
||||
virtual void step(float dt) override;
|
||||
virtual void startWithTarget(Node *target) override;
|
||||
virtual Animate3D* reverse() const override;
|
||||
virtual Animate3D *clone() const override;
|
||||
|
||||
virtual void update(float t) override;
|
||||
|
||||
float getSpeed() const { return _speed; }
|
||||
void setSpeed(float speed) { _speed = speed; }
|
||||
|
||||
bool getPlayBack() const { return _playBack; }
|
||||
void setPlayBack(bool playBack) { _playBack = playBack; }
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
Animate3D();
|
||||
virtual ~Animate3D();
|
||||
|
||||
Animation3D* _animation;
|
||||
|
||||
float _speed;
|
||||
float _weight;
|
||||
bool _playBack;
|
||||
std::map<Bone*, Animation3D::Curve*> _boneCurves; //weak ref
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCANIMATE3D_H__
|
|
@ -0,0 +1,238 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "3d/CCAnimation3D.h"
|
||||
#include "3d/CCBundle3D.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Animation3D* Animation3D::getOrCreate(const std::string& fileName, const std::string& animationName)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
std::string key = fullPath + "#" + animationName;
|
||||
auto animation = Animation3DCache::getInstance()->getAnimation(key);
|
||||
if (animation != nullptr)
|
||||
return animation;
|
||||
|
||||
//load animation here
|
||||
animation = new Animation3D();
|
||||
auto bundle = Bundle3D::getInstance();
|
||||
Animation3DData animationdata;
|
||||
if (bundle->load(fullPath) && bundle->loadAnimationData(animationName, &animationdata) && animation->init(animationdata))
|
||||
{
|
||||
Animation3DCache::getInstance()->addAnimation(key, animation);
|
||||
animation->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(animation);
|
||||
animation = nullptr;
|
||||
}
|
||||
|
||||
return animation;
|
||||
}
|
||||
|
||||
Animation3D::Curve* Animation3D::getBoneCurveByName(const std::string& name) const
|
||||
{
|
||||
auto it = _boneCurves.find(name);
|
||||
if (it != _boneCurves.end())
|
||||
return it->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Animation3D::Animation3D()
|
||||
: _duration(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Animation3D::~Animation3D()
|
||||
{
|
||||
for (auto itor : _boneCurves) {
|
||||
CC_SAFE_DELETE(itor.second);
|
||||
}
|
||||
}
|
||||
|
||||
Animation3D::Curve::Curve()
|
||||
: translateCurve(nullptr)
|
||||
, rotCurve(nullptr)
|
||||
, scaleCurve(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
Animation3D::Curve::~Curve()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(translateCurve);
|
||||
CC_SAFE_RELEASE_NULL(rotCurve);
|
||||
CC_SAFE_RELEASE_NULL(scaleCurve);
|
||||
}
|
||||
|
||||
bool Animation3D::init(const Animation3DData &data)
|
||||
{
|
||||
_duration = data._totalTime;
|
||||
|
||||
for(const auto& iter : data._translationKeys)
|
||||
{
|
||||
Curve* curve = _boneCurves[iter.first];
|
||||
if( curve == nullptr)
|
||||
{
|
||||
curve = new Curve();
|
||||
_boneCurves[iter.first] = curve;
|
||||
}
|
||||
|
||||
if(iter.second.size() == 0) continue;
|
||||
std::vector<float> keys;
|
||||
std::vector<float> values;
|
||||
for(const auto& keyIter : iter.second)
|
||||
{
|
||||
keys.push_back(keyIter._time);
|
||||
values.push_back(keyIter._key.x);
|
||||
values.push_back(keyIter._key.y);
|
||||
values.push_back(keyIter._key.z);
|
||||
}
|
||||
|
||||
curve->translateCurve = Curve::AnimationCurveVec3::create(&keys[0], &values[0], (int)keys.size());
|
||||
if(curve->translateCurve) curve->translateCurve->retain();
|
||||
}
|
||||
|
||||
for(const auto& iter : data._rotationKeys)
|
||||
{
|
||||
Curve* curve = _boneCurves[iter.first];
|
||||
if( curve == nullptr)
|
||||
{
|
||||
curve = new Curve();
|
||||
_boneCurves[iter.first] = curve;
|
||||
}
|
||||
|
||||
if(iter.second.size() == 0) continue;
|
||||
std::vector<float> keys;
|
||||
std::vector<float> values;
|
||||
for(const auto& keyIter : iter.second)
|
||||
{
|
||||
keys.push_back(keyIter._time);
|
||||
values.push_back(keyIter._key.x);
|
||||
values.push_back(keyIter._key.y);
|
||||
values.push_back(keyIter._key.z);
|
||||
values.push_back(keyIter._key.w);
|
||||
}
|
||||
|
||||
curve->rotCurve = Curve::AnimationCurveQuat::create(&keys[0], &values[0], (int)keys.size());
|
||||
if(curve->rotCurve) curve->rotCurve->retain();
|
||||
}
|
||||
|
||||
for(const auto& iter : data._scaleKeys)
|
||||
{
|
||||
Curve* curve = _boneCurves[iter.first];
|
||||
if( curve == nullptr)
|
||||
{
|
||||
curve = new Curve();
|
||||
_boneCurves[iter.first] = curve;
|
||||
}
|
||||
|
||||
if(iter.second.size() == 0) continue;
|
||||
std::vector<float> keys;
|
||||
std::vector<float> values;
|
||||
for(const auto& keyIter : iter.second)
|
||||
{
|
||||
keys.push_back(keyIter._time);
|
||||
values.push_back(keyIter._key.x);
|
||||
values.push_back(keyIter._key.y);
|
||||
values.push_back(keyIter._key.z);
|
||||
}
|
||||
|
||||
curve->scaleCurve = Curve::AnimationCurveVec3::create(&keys[0], &values[0], (int)keys.size());
|
||||
if(curve->scaleCurve) curve->scaleCurve->retain();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
Animation3DCache* Animation3DCache::_cacheInstance = nullptr;
|
||||
|
||||
Animation3DCache* Animation3DCache::getInstance()
|
||||
{
|
||||
if (_cacheInstance == nullptr)
|
||||
_cacheInstance = new Animation3DCache();
|
||||
|
||||
return _cacheInstance;
|
||||
}
|
||||
void Animation3DCache::destroyInstance()
|
||||
{
|
||||
CC_SAFE_DELETE(_cacheInstance);
|
||||
}
|
||||
|
||||
Animation3D* Animation3DCache::getAnimation(const std::string& key)
|
||||
{
|
||||
auto it = _animations.find(key);
|
||||
if (it != _animations.end())
|
||||
return it->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Animation3DCache::addAnimation(const std::string& key, Animation3D* animation)
|
||||
{
|
||||
const auto& it = _animations.find(key);
|
||||
if (it != _animations.end())
|
||||
{
|
||||
return; // already have this key
|
||||
}
|
||||
_animations[key] = animation;
|
||||
animation->retain();
|
||||
}
|
||||
|
||||
void Animation3DCache::removeAllAnimations()
|
||||
{
|
||||
for (auto itor : _animations) {
|
||||
CC_SAFE_RELEASE(itor.second);
|
||||
}
|
||||
_animations.clear();
|
||||
}
|
||||
void Animation3DCache::removeUnusedAnimation()
|
||||
{
|
||||
for (auto itor = _animations.begin(); itor != _animations.end(); ) {
|
||||
if (itor->second->getReferenceCount() == 1)
|
||||
{
|
||||
itor->second->release();
|
||||
_animations.erase(itor++);
|
||||
}
|
||||
else
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
Animation3DCache::Animation3DCache()
|
||||
{
|
||||
|
||||
}
|
||||
Animation3DCache::~Animation3DCache()
|
||||
{
|
||||
removeAllAnimations();
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,105 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCANIMATION3D_H__
|
||||
#define __CCANIMATION3D_H__
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "3d/CCAnimationCurve.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "CCBundle3DData.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* static animation data, shared
|
||||
*/
|
||||
class Animation3D: public Ref
|
||||
{
|
||||
friend class Bundle3D;
|
||||
public:
|
||||
class Curve
|
||||
{
|
||||
public:
|
||||
typedef AnimationCurve<3> AnimationCurveVec3;
|
||||
typedef AnimationCurve<4> AnimationCurveQuat;
|
||||
AnimationCurveVec3* translateCurve;
|
||||
AnimationCurveQuat* rotCurve;
|
||||
AnimationCurveVec3* scaleCurve;
|
||||
|
||||
Curve();
|
||||
~Curve();
|
||||
};
|
||||
|
||||
//read all animation or only the animation with given animationName? animationName == "" read all.
|
||||
static Animation3D* getOrCreate(const std::string& filename, const std::string& animationName = "");
|
||||
|
||||
float getDuration() const { return _duration; }
|
||||
|
||||
Curve* getBoneCurveByName(const std::string& name) const;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
Animation3D();
|
||||
virtual ~Animation3D();
|
||||
|
||||
bool init(const Animation3DData& data);
|
||||
|
||||
protected:
|
||||
|
||||
std::unordered_map<std::string, Curve*> _boneCurves;//bone curves map, key bone name, value AnimationCurve
|
||||
|
||||
|
||||
float _duration; //animation duration
|
||||
};
|
||||
|
||||
class Animation3DCache
|
||||
{
|
||||
public:
|
||||
static Animation3DCache* getInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
Animation3D* getAnimation(const std::string& key);
|
||||
|
||||
void addAnimation(const std::string& key, Animation3D* animation);
|
||||
|
||||
void removeAllAnimations();
|
||||
void removeUnusedAnimation();
|
||||
|
||||
protected:
|
||||
Animation3DCache();
|
||||
~Animation3DCache();
|
||||
|
||||
static Animation3DCache* _cacheInstance;
|
||||
|
||||
std::unordered_map<std::string, Animation3D*> _animations;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCANIMATION3D_H__
|
|
@ -0,0 +1,92 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#ifndef __CCANIMATIONCURVE_H__
|
||||
#define __CCANIMATIONCURVE_H__
|
||||
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
|
||||
#include "base/ccTypes.h"
|
||||
#include "base/CCPlatformMacros.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "math/CCMath.h"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
#undef NEAR
|
||||
#endif
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
enum class EvaluateType
|
||||
{
|
||||
INT_LINEAR,
|
||||
INT_NEAR,
|
||||
INT_QUAT_SLERP,
|
||||
INT_USER_FUNCTION,
|
||||
};
|
||||
|
||||
/**
|
||||
* curve of bone's position, rotation or scale
|
||||
*/
|
||||
template <int componentSize>
|
||||
class AnimationCurve: public Ref
|
||||
{
|
||||
public:
|
||||
|
||||
//create animation curve
|
||||
static AnimationCurve* create(float* keytime, float* value, int count);
|
||||
|
||||
void evaluate(float time, float* dst, EvaluateType type) const;
|
||||
|
||||
void setEvaluateFun(std::function<void(float time, float* dst)> fun);
|
||||
|
||||
float getStartTime() const;
|
||||
|
||||
float getEndTime() const;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
AnimationCurve();
|
||||
virtual ~AnimationCurve();
|
||||
|
||||
/**
|
||||
* Determine index by time.
|
||||
*/
|
||||
int determineIndex(float time) const;
|
||||
|
||||
protected:
|
||||
|
||||
float* _value; //
|
||||
float* _keytime; //key time(0 - 1), start time _keytime[0], end time _keytime[_count - 1]
|
||||
int _count;
|
||||
int _componentSizeByte; //component size in byte, position and scale 3 * sizeof(float), rotation 4 * sizeof(float)
|
||||
|
||||
std::function<void(float time, float* dst)> _evaluateFun;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#include "CCAnimationCurve.inl"
|
||||
|
||||
#endif
|
|
@ -0,0 +1,145 @@
|
|||
#include "3d/CCAnimationCurve.h"
|
||||
NS_CC_BEGIN
|
||||
|
||||
template <int componentSize>
|
||||
void AnimationCurve<componentSize>::evaluate(float time, float* dst, EvaluateType type) const
|
||||
{
|
||||
int floatSize = sizeof(float);
|
||||
if (_count == 1 || time <= _keytime[0])
|
||||
{
|
||||
memcpy(dst, _value, _componentSizeByte);
|
||||
return;
|
||||
}
|
||||
else if (time >= _keytime[_count - 1])
|
||||
{
|
||||
memcpy(dst, &_value[(_count - 1) * componentSize], _componentSizeByte);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int index = determineIndex(time);
|
||||
|
||||
float scale = (_keytime[index + 1] - _keytime[index]);
|
||||
float t = (time - _keytime[index]) / scale;
|
||||
|
||||
float* fromValue = &_value[index * componentSize];
|
||||
float* toValue = fromValue + componentSize;
|
||||
|
||||
switch (type) {
|
||||
case EvaluateType::INT_LINEAR:
|
||||
{
|
||||
for (auto i = 0; i < componentSize; i++) {
|
||||
dst[i] = fromValue[i] + (toValue[i] - fromValue[i]) * t;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EvaluateType::INT_NEAR:
|
||||
{
|
||||
float* src = t > 0.5f ? toValue : fromValue;
|
||||
memcpy(dst, src, _componentSizeByte);
|
||||
}
|
||||
break;
|
||||
case EvaluateType::INT_QUAT_SLERP:
|
||||
{
|
||||
// Evaluate.
|
||||
Quaternion quat;
|
||||
if (t >= 0)
|
||||
Quaternion::slerp(Quaternion(fromValue), Quaternion(toValue), t, &quat);
|
||||
else
|
||||
Quaternion::slerp(Quaternion(toValue), Quaternion(fromValue), t, &quat);
|
||||
|
||||
dst[0] = quat.x, dst[1] = quat.y, dst[2] = quat.z, dst[3] = quat.w;
|
||||
}
|
||||
break;
|
||||
case EvaluateType::INT_USER_FUNCTION:
|
||||
{
|
||||
if (_evaluateFun)
|
||||
_evaluateFun(time, dst);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template <int componentSize>
|
||||
void AnimationCurve<componentSize>::setEvaluateFun(std::function<void(float time, float* dst)> fun)
|
||||
{
|
||||
_evaluateFun = fun;
|
||||
}
|
||||
|
||||
//create animation curve
|
||||
template <int componentSize>
|
||||
AnimationCurve<componentSize>* AnimationCurve<componentSize>::create(float* keytime, float* value, int count)
|
||||
{
|
||||
int floatSize = sizeof(float);
|
||||
AnimationCurve* curve = new AnimationCurve();
|
||||
curve->_keytime = new float[count];
|
||||
memcpy(curve->_keytime, keytime, count * floatSize);
|
||||
|
||||
int compoentSizeByte = componentSize * floatSize;
|
||||
int totalByte = count * compoentSizeByte;
|
||||
curve->_value = new float[totalByte / floatSize];
|
||||
memcpy(curve->_value, value, totalByte);
|
||||
|
||||
curve->_count = count;
|
||||
curve->_componentSizeByte = compoentSizeByte;
|
||||
|
||||
curve->autorelease();
|
||||
return curve;
|
||||
}
|
||||
|
||||
template <int componentSize>
|
||||
float AnimationCurve<componentSize>::getStartTime() const
|
||||
{
|
||||
return _keytime[0];
|
||||
}
|
||||
|
||||
template <int componentSize>
|
||||
float AnimationCurve<componentSize>::getEndTime() const
|
||||
{
|
||||
return _keytime[_count - 1];
|
||||
}
|
||||
|
||||
|
||||
template <int componentSize>
|
||||
AnimationCurve<componentSize>::AnimationCurve()
|
||||
: _keytime(nullptr)
|
||||
, _value(nullptr)
|
||||
, _count(0)
|
||||
, _componentSizeByte(0)
|
||||
, _evaluateFun(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
template <int componentSize>
|
||||
AnimationCurve<componentSize>::~AnimationCurve()
|
||||
{
|
||||
CC_SAFE_DELETE(_keytime);
|
||||
CC_SAFE_DELETE(_value);
|
||||
}
|
||||
|
||||
template <int componentSize>
|
||||
int AnimationCurve<componentSize>::determineIndex(float time) const
|
||||
{
|
||||
unsigned int min = 0;
|
||||
unsigned int max = _count - 1;
|
||||
unsigned int mid = 0;
|
||||
|
||||
do
|
||||
{
|
||||
mid = (min + max) >> 1;
|
||||
|
||||
if (time >= _keytime[mid] && time <= _keytime[mid + 1])
|
||||
return mid;
|
||||
else if (time < _keytime[mid])
|
||||
max = mid - 1;
|
||||
else
|
||||
min = mid + 1;
|
||||
} while (min <= max);
|
||||
|
||||
// We should never hit this!
|
||||
return -1;
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,384 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "3d/CCBundle3D.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
void getChildMap(std::map<int, std::vector<int> >& map, SkinData* skinData, const rapidjson::Value& val)
|
||||
{
|
||||
if (!skinData)
|
||||
return;
|
||||
|
||||
if (!val.HasMember("children"))
|
||||
return;
|
||||
|
||||
std::string parent_name = val["id"].GetString();
|
||||
int parent_name_index = skinData->getBoneNameIndex(parent_name);
|
||||
|
||||
const rapidjson::Value& children = val["children"];
|
||||
for (rapidjson::SizeType i = 0; i < children.Size(); i++)
|
||||
{
|
||||
const rapidjson::Value& child = children[i];
|
||||
std::string child_name = child["id"].GetString();
|
||||
|
||||
int child_name_index = skinData->getBoneNameIndex(child_name);
|
||||
if (child_name_index >= 0)
|
||||
{
|
||||
map[parent_name_index].push_back(child_name_index);
|
||||
|
||||
getChildMap(map, skinData, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void getChildMapT(std::map<std::string, std::vector<std::string> >& map, const SkinData* skinData, const rapidjson::Value& val)
|
||||
{
|
||||
if (!skinData)
|
||||
return;
|
||||
|
||||
if (!val.HasMember("children"))
|
||||
return;
|
||||
|
||||
std::string parent_name = val["id"].GetString();
|
||||
const rapidjson::Value& children = val["children"];
|
||||
for (rapidjson::SizeType i = 0; i < children.Size(); i++)
|
||||
{
|
||||
const rapidjson::Value& child = children[i];
|
||||
std::string child_name = child["id"].GetString();
|
||||
|
||||
map[parent_name].push_back(child_name);
|
||||
|
||||
getChildMapT(map, skinData, child);
|
||||
}
|
||||
}
|
||||
|
||||
Bundle3D* Bundle3D::_instance = nullptr;
|
||||
|
||||
Bundle3D* Bundle3D::getInstance()
|
||||
{
|
||||
if (_instance == nullptr)
|
||||
_instance = new Bundle3D();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void Bundle3D::destroyInstance()
|
||||
{
|
||||
CC_SAFE_DELETE(_instance);
|
||||
}
|
||||
|
||||
bool Bundle3D::load(const std::string& path)
|
||||
{
|
||||
if (_path == path)
|
||||
return true;
|
||||
|
||||
getModelPath(path);
|
||||
std::string strFileString = FileUtils::getInstance()->getStringFromFile(path);
|
||||
ssize_t size = strFileString.length();
|
||||
CC_SAFE_DELETE_ARRAY(_documentBuffer);
|
||||
_documentBuffer = new char[size + 1];
|
||||
memcpy(_documentBuffer, strFileString.c_str(), size);
|
||||
_documentBuffer[size] = '\0';
|
||||
if (_document.ParseInsitu<0>(_documentBuffer).HasParseError())
|
||||
{
|
||||
assert(0);
|
||||
CC_SAFE_DELETE_ARRAY(_documentBuffer);
|
||||
_path = "";
|
||||
return false;
|
||||
}
|
||||
_path = path;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bundle3D::loadMeshData(const std::string& id, MeshData* meshdata)
|
||||
{
|
||||
meshdata->resetData();
|
||||
|
||||
assert(_document.HasMember("mesh"));
|
||||
const rapidjson::Value& mash_data_array = _document["mesh"];
|
||||
|
||||
assert(mash_data_array.IsArray());
|
||||
const rapidjson::Value& mash_data_val = mash_data_array[(rapidjson::SizeType)0];
|
||||
|
||||
assert(mash_data_val.HasMember("body"));
|
||||
const rapidjson::Value& mesh_data_body_array = mash_data_val["body"];
|
||||
|
||||
assert(mesh_data_body_array.IsArray());
|
||||
const rapidjson::Value& mesh_data_body_array_0 = mesh_data_body_array[(rapidjson::SizeType)0];
|
||||
|
||||
// vertex_size
|
||||
assert(mesh_data_body_array_0.HasMember("vertexsize"));
|
||||
meshdata->vertexSizeInFloat = mesh_data_body_array_0["vertexsize"].GetInt();
|
||||
|
||||
// vertices
|
||||
meshdata->vertex.resize(meshdata->vertexSizeInFloat);
|
||||
const rapidjson::Value& mesh_data_body_vertices = mesh_data_body_array_0["vertices"];
|
||||
for (rapidjson::SizeType i = 0; i < mesh_data_body_vertices.Size(); i++)
|
||||
meshdata->vertex[i] = mesh_data_body_vertices[i].GetDouble();
|
||||
|
||||
// index_number
|
||||
meshdata->numIndex = mesh_data_body_array_0["indexnum"].GetUint();
|
||||
|
||||
// indices
|
||||
meshdata->indices.resize(meshdata->numIndex);
|
||||
const rapidjson::Value& mesh_data_body_indices_val = mesh_data_body_array_0["indices"];
|
||||
for (rapidjson::SizeType i = 0; i < mesh_data_body_indices_val.Size(); i++)
|
||||
meshdata->indices[i] = (unsigned short)mesh_data_body_indices_val[i].GetUint();
|
||||
|
||||
// mesh_vertex_attribute
|
||||
const rapidjson::Value& mesh_vertex_attribute = mash_data_val["attributes"];
|
||||
meshdata->attribCount = mesh_vertex_attribute.Size();
|
||||
meshdata->attribs.resize(meshdata->attribCount);
|
||||
for (rapidjson::SizeType i = 0; i < mesh_vertex_attribute.Size(); i++)
|
||||
{
|
||||
const rapidjson::Value& mesh_vertex_attribute_val = mesh_vertex_attribute[i];
|
||||
|
||||
meshdata->attribs[i].size = mesh_vertex_attribute_val["size"].GetUint();
|
||||
meshdata->attribs[i].attribSizeBytes = meshdata->attribs[i].size * parseGLTypeSize(mesh_vertex_attribute_val["type"].GetString());
|
||||
meshdata->attribs[i].type = parseGLType(mesh_vertex_attribute_val["type"].GetString());
|
||||
meshdata->attribs[i].vertexAttrib = parseGLProgramAttribute(mesh_vertex_attribute_val["attribute"].GetString());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bundle3D::loadSkinData(const std::string& id, SkinData* skindata)
|
||||
{
|
||||
if (!_document.HasMember("skin")) return false;
|
||||
|
||||
skindata->resetData();
|
||||
|
||||
const rapidjson::Value& skin_data_array = _document["skin"];
|
||||
|
||||
assert(skin_data_array.IsArray());
|
||||
const rapidjson::Value& skin_data_array_val_0 = skin_data_array[(rapidjson::SizeType)0];
|
||||
|
||||
if (!skin_data_array_val_0.HasMember("bones"))
|
||||
return false;
|
||||
|
||||
const rapidjson::Value& skin_data_bones = skin_data_array_val_0["bones"];
|
||||
for (rapidjson::SizeType i = 0; i < skin_data_bones.Size(); i++)
|
||||
{
|
||||
const rapidjson::Value& skin_data_bone = skin_data_bones[i];
|
||||
std::string name = skin_data_bone["node"].GetString();
|
||||
skindata->boneNames.push_back(name);
|
||||
|
||||
Mat4 mat_bind_pos;
|
||||
const rapidjson::Value& bind_pos = skin_data_bone["bindshape"];
|
||||
for (rapidjson::SizeType j = 0; j < bind_pos.Size(); j++)
|
||||
{
|
||||
mat_bind_pos.m[j] = bind_pos[j].GetDouble();
|
||||
}
|
||||
skindata->inverseBindPoseMatrices.push_back(mat_bind_pos);
|
||||
}
|
||||
|
||||
const rapidjson::Value& skin_data_1 = skin_data_array[1];
|
||||
const rapidjson::Value& bone_array_0 = skin_data_1["children"][(rapidjson::SizeType)0];
|
||||
skindata->rootBoneIndex = skindata->getBoneNameIndex(bone_array_0["id"].GetString());
|
||||
getChildMap(skindata->boneChild, skindata, bone_array_0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bundle3D::loadMaterialData(const std::string& id, MaterialData* materialdata)
|
||||
{
|
||||
if (!_document.HasMember("material"))
|
||||
return false;
|
||||
|
||||
const rapidjson::Value& material_data_array = _document["material"];
|
||||
|
||||
const rapidjson::Value& material_data_array_0 = material_data_array[(rapidjson::SizeType)0];
|
||||
|
||||
const rapidjson::Value& material_data_base_array = material_data_array_0["base"];
|
||||
|
||||
const rapidjson::Value& material_data_base_array_0 = material_data_base_array[(rapidjson::SizeType)0];
|
||||
|
||||
materialdata->texturePath = _modelRelativePath + material_data_base_array_0["filename"].GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Bundle3D::loadAnimationData(const std::string& id, Animation3DData* animationdata)
|
||||
{
|
||||
if (!_document.HasMember("animation")) return false;
|
||||
|
||||
animationdata->_rotationKeys.clear();
|
||||
animationdata->_scaleKeys.clear();
|
||||
animationdata->_translationKeys.clear();
|
||||
|
||||
const rapidjson::Value& animation_data_array = _document["animation"];
|
||||
if (animation_data_array.Size()==0) return false;
|
||||
|
||||
const rapidjson::Value& animation_data_array_val_0 = animation_data_array[(rapidjson::SizeType)0];
|
||||
|
||||
animationdata->_totalTime = animation_data_array_val_0["length"].GetDouble();
|
||||
|
||||
const rapidjson::Value& bones = animation_data_array_val_0["bones"];
|
||||
for (rapidjson::SizeType i = 0; i < bones.Size(); i++)
|
||||
{
|
||||
const rapidjson::Value& bone = bones[i];
|
||||
std::string bone_name = bone["boneId"].GetString();
|
||||
|
||||
if ( bone.HasMember("keyframes"))
|
||||
{
|
||||
const rapidjson::Value& bone_keyframes = bone["keyframes"];
|
||||
rapidjson::SizeType keyframe_size = bone_keyframes.Size();
|
||||
for (rapidjson::SizeType j = 0; j < bone_keyframes.Size(); j++)
|
||||
{
|
||||
const rapidjson::Value& bone_keyframe = bone_keyframes[j];
|
||||
|
||||
if ( bone_keyframe.HasMember("translation"))
|
||||
{
|
||||
const rapidjson::Value& bone_keyframe_translation = bone_keyframe["translation"];
|
||||
float keytime = bone_keyframe["keytime"].GetDouble();
|
||||
Vec3 val = Vec3(bone_keyframe_translation[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_translation[1].GetDouble(), bone_keyframe_translation[2].GetDouble());
|
||||
animationdata->_translationKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime,val));
|
||||
}
|
||||
|
||||
if ( bone_keyframe.HasMember("rotation"))
|
||||
{
|
||||
const rapidjson::Value& bone_keyframe_rotation = bone_keyframe["rotation"];
|
||||
float keytime = bone_keyframe["keytime"].GetDouble();
|
||||
Quaternion val = Quaternion(bone_keyframe_rotation[(rapidjson::SizeType)0].GetDouble(),bone_keyframe_rotation[1].GetDouble(),bone_keyframe_rotation[2].GetDouble(),bone_keyframe_rotation[3].GetDouble());
|
||||
animationdata->_rotationKeys[bone_name].push_back(Animation3DData::QuatKey(keytime,val));
|
||||
}
|
||||
|
||||
if ( bone_keyframe.HasMember("scale"))
|
||||
{
|
||||
const rapidjson::Value& bone_keyframe_scale = bone_keyframe["scale"];
|
||||
float keytime = bone_keyframe["keytime"].GetDouble();
|
||||
Vec3 val = Vec3(bone_keyframe_scale[(rapidjson::SizeType)0].GetDouble(), bone_keyframe_scale[1].GetDouble(), bone_keyframe_scale[2].GetDouble());
|
||||
animationdata->_scaleKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime,val));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GLenum Bundle3D::parseGLType(const std::string& str)
|
||||
{
|
||||
if (str == "GL_FLOAT")
|
||||
{
|
||||
return GL_FLOAT;
|
||||
}
|
||||
else if (str == "GL_UNSIGNED_INT")
|
||||
{
|
||||
return GL_UNSIGNED_INT;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Bundle3D::parseGLTypeSize(const std::string& str)
|
||||
{
|
||||
if (str == "GL_FLOAT")
|
||||
{
|
||||
return sizeof(float);
|
||||
}
|
||||
else if (str == "GL_UNSIGNED_INT")
|
||||
{
|
||||
return sizeof(unsigned int);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Bundle3D::parseGLProgramAttribute(const std::string& str)
|
||||
{
|
||||
if (str == "VERTEX_ATTRIB_POSITION")
|
||||
{
|
||||
return GLProgram::VERTEX_ATTRIB_POSITION;
|
||||
}
|
||||
else if (str == "VERTEX_ATTRIB_COLOR")
|
||||
{
|
||||
return GLProgram::VERTEX_ATTRIB_COLOR;
|
||||
}
|
||||
else if (str == "VERTEX_ATTRIB_TEX_COORD")
|
||||
{
|
||||
return GLProgram::VERTEX_ATTRIB_TEX_COORD;
|
||||
}
|
||||
else if (str == "VERTEX_ATTRIB_NORMAL")
|
||||
{
|
||||
return GLProgram::VERTEX_ATTRIB_NORMAL;
|
||||
}
|
||||
else if (str == "VERTEX_ATTRIB_BLEND_WEIGHT")
|
||||
{
|
||||
return GLProgram::VERTEX_ATTRIB_BLEND_WEIGHT;
|
||||
}
|
||||
else if (str == "VERTEX_ATTRIB_BLEND_INDEX")
|
||||
{
|
||||
return GLProgram::VERTEX_ATTRIB_BLEND_INDEX;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Bundle3D::getModelPath(const std::string& path)
|
||||
{
|
||||
int index = path.find_last_of('/');
|
||||
std::string fullModelPath;
|
||||
fullModelPath = path.substr(0, index + 1);
|
||||
|
||||
auto list = FileUtils::getInstance()->getSearchPaths();
|
||||
for( const auto &item : list )
|
||||
{
|
||||
if ( fullModelPath.find(item) != std::string::npos )
|
||||
{
|
||||
_modelRelativePath = fullModelPath.substr(item.length(), fullModelPath.length() + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bundle3D::Bundle3D()
|
||||
:_isBinary(false)
|
||||
,_modelRelativePath("")
|
||||
,_documentBuffer(nullptr)
|
||||
,_path("")
|
||||
{
|
||||
|
||||
}
|
||||
Bundle3D::~Bundle3D()
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(_documentBuffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,105 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCBUNDLE3D_H__
|
||||
#define __CCBUNDLE3D_H__
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "3d/CCBundle3DData.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "base/ccTypes.h"
|
||||
|
||||
#include "json/document.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Animation3D;
|
||||
class Bundle3D
|
||||
{
|
||||
public:
|
||||
|
||||
static Bundle3D* getInstance();
|
||||
|
||||
static void destroyInstance();
|
||||
|
||||
bool load(const std::string& path);
|
||||
|
||||
/**
|
||||
* load mesh data from bundle
|
||||
* @param id The ID of the mesh, load the first Mesh in the bundle if it is empty
|
||||
*/
|
||||
bool loadMeshData(const std::string& id, MeshData* meshdata);
|
||||
|
||||
/**
|
||||
* load skin data from bundle
|
||||
* @param id The ID of the skin, load the first Skin in the bundle if it is empty
|
||||
*/
|
||||
bool loadSkinData(const std::string& id, SkinData* skindata);
|
||||
|
||||
/**
|
||||
* load material data from bundle
|
||||
* @param id The ID of the material, load the first Material in the bundle if it is empty
|
||||
*/
|
||||
bool loadMaterialData(const std::string& id, MaterialData* materialdata);
|
||||
|
||||
/**
|
||||
* load material data from bundle
|
||||
* @param id The ID of the animation, load the first animation in the bundle if it is empty
|
||||
*/
|
||||
bool loadAnimationData(const std::string& id, Animation3DData* animationdata);
|
||||
|
||||
protected:
|
||||
GLenum parseGLType(const std::string& str);
|
||||
|
||||
unsigned int parseGLTypeSize(const std::string& str);
|
||||
|
||||
unsigned int parseGLProgramAttribute(const std::string& str);
|
||||
|
||||
// get model path
|
||||
void getModelPath(const std::string& path);
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
Bundle3D();
|
||||
~Bundle3D();
|
||||
|
||||
protected:
|
||||
|
||||
static Bundle3D* _instance;
|
||||
|
||||
std::string _modelRelativePath;
|
||||
|
||||
char* _documentBuffer;
|
||||
std::string _path;
|
||||
|
||||
rapidjson::Document _document;
|
||||
|
||||
bool _isBinary;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCANIMATE3D_H__
|
|
@ -0,0 +1,187 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CC_BUNDLE_3D_DATA_H__
|
||||
#define __CC_BUNDLE_3D_DATA_H__
|
||||
|
||||
#include "base/CCRef.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "math/CCMath.h"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
//mesh vertex attribute
|
||||
struct MeshVertexAttrib
|
||||
{
|
||||
//attribute size
|
||||
GLint size;
|
||||
//GL_FLOAT
|
||||
GLenum type;
|
||||
//VERTEX_ATTRIB_POSITION,VERTEX_ATTRIB_COLOR,VERTEX_ATTRIB_TEX_COORD,VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_BLEND_INDEX, GLProgram for detail
|
||||
int vertexAttrib;
|
||||
//size in bytes
|
||||
int attribSizeBytes;
|
||||
};
|
||||
|
||||
struct MeshData
|
||||
{
|
||||
std::vector<float> vertex;
|
||||
int vertexSizeInFloat;
|
||||
std::vector<unsigned short> indices;
|
||||
int numIndex;
|
||||
std::vector<MeshVertexAttrib> attribs;
|
||||
int attribCount;
|
||||
|
||||
public:
|
||||
void resetData()
|
||||
{
|
||||
vertex.clear();
|
||||
indices.clear();
|
||||
attribs.clear();
|
||||
vertexSizeInFloat = 0;
|
||||
numIndex = 0;
|
||||
attribCount = 0;
|
||||
}
|
||||
MeshData()
|
||||
: vertexSizeInFloat(0)
|
||||
, numIndex(0)
|
||||
, attribCount(0)
|
||||
{
|
||||
}
|
||||
~MeshData()
|
||||
{
|
||||
resetData();
|
||||
}
|
||||
};
|
||||
|
||||
struct SkinData
|
||||
{
|
||||
std::vector<std::string> boneNames;
|
||||
std::vector<Mat4> inverseBindPoseMatrices; //bind pose of bone
|
||||
|
||||
std::map<int, std::vector<int> > boneChild;//key parent, value child
|
||||
int rootBoneIndex;
|
||||
void resetData()
|
||||
{
|
||||
boneNames.clear();
|
||||
inverseBindPoseMatrices.clear();
|
||||
boneChild.clear();
|
||||
rootBoneIndex = -1;
|
||||
}
|
||||
|
||||
int getBoneNameIndex(const std::string& name)const
|
||||
{
|
||||
std::vector<std::string>::const_iterator iter = boneNames.begin();
|
||||
for (int i = 0; iter != boneNames.end(); ++iter, ++i)
|
||||
{
|
||||
if ((*iter) == name)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct MaterialData
|
||||
{
|
||||
std::string texturePath;
|
||||
};
|
||||
|
||||
struct Animation3DData
|
||||
{
|
||||
public:
|
||||
struct Vec3Key
|
||||
{
|
||||
Vec3Key()
|
||||
: _time(0)
|
||||
, _key(Vec3::ZERO)
|
||||
{
|
||||
}
|
||||
|
||||
Vec3Key(float time, const Vec3& v)
|
||||
: _time(time)
|
||||
, _key(v)
|
||||
{
|
||||
}
|
||||
|
||||
float _time;
|
||||
Vec3 _key;
|
||||
};
|
||||
|
||||
struct QuatKey
|
||||
{
|
||||
QuatKey()
|
||||
: _time(0)
|
||||
, _key(Quaternion::identity())
|
||||
{
|
||||
}
|
||||
|
||||
QuatKey(float time, const Quaternion& quat)
|
||||
: _time(time)
|
||||
, _key(quat)
|
||||
{
|
||||
}
|
||||
|
||||
float _time;
|
||||
Quaternion _key;
|
||||
};
|
||||
|
||||
public:
|
||||
std::map<std::string, std::vector<Vec3Key>> _translationKeys;
|
||||
std::map<std::string, std::vector<QuatKey>> _rotationKeys;
|
||||
std::map<std::string, std::vector<Vec3Key>> _scaleKeys;
|
||||
|
||||
float _totalTime;
|
||||
|
||||
public:
|
||||
Animation3DData()
|
||||
:_totalTime(0)
|
||||
{
|
||||
}
|
||||
|
||||
Animation3DData(const Animation3DData& other)
|
||||
: _totalTime(other._totalTime)
|
||||
, _translationKeys(other._translationKeys)
|
||||
, _rotationKeys(other._rotationKeys)
|
||||
, _scaleKeys(other._scaleKeys)
|
||||
{
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
_totalTime = 0;
|
||||
_translationKeys.clear();
|
||||
_rotationKeys.clear();
|
||||
_scaleKeys.clear();
|
||||
}
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CC_BUNDLE_3D_DATA_H__
|
|
@ -29,10 +29,17 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "3d/CCObjLoader.h"
|
||||
#include "3d/CCSprite3DMaterial.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
#include "base/CCEventListenerCustom.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
#include "base/CCEventType.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "CCObjLoader.h"
|
||||
#include "CCSprite3DDataCache.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -48,7 +55,7 @@ bool RenderMeshData::hasVertexAttrib(int attrib)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool RenderMeshData::initFrom(const std::vector<float>& positions,
|
||||
bool RenderMeshData::init(const std::vector<float>& positions,
|
||||
const std::vector<float>& normals,
|
||||
const std::vector<float>& texs,
|
||||
const std::vector<unsigned short>& indices)
|
||||
|
@ -56,7 +63,6 @@ bool RenderMeshData::initFrom(const std::vector<float>& positions,
|
|||
CC_ASSERT(positions.size()<65536 * 3 && "index may out of bound");
|
||||
|
||||
_vertexAttribs.clear();
|
||||
_vertexsizeBytes = 0;
|
||||
|
||||
_vertexNum = positions.size() / 3; //number of vertex
|
||||
if (_vertexNum == 0)
|
||||
|
@ -65,7 +71,6 @@ bool RenderMeshData::initFrom(const std::vector<float>& positions,
|
|||
if ((normals.size() != 0 && _vertexNum * 3 != normals.size()) || (texs.size() != 0 && _vertexNum * 2 != texs.size()))
|
||||
return false;
|
||||
|
||||
_vertexsizeBytes += 3;
|
||||
MeshVertexAttrib meshvertexattrib;
|
||||
meshvertexattrib.size = 3;
|
||||
meshvertexattrib.type = GL_FLOAT;
|
||||
|
@ -77,14 +82,12 @@ bool RenderMeshData::initFrom(const std::vector<float>& positions,
|
|||
if (normals.size())
|
||||
{
|
||||
//add normal flag
|
||||
_vertexsizeBytes += 3;
|
||||
meshvertexattrib.vertexAttrib = GLProgram::VERTEX_ATTRIB_NORMAL;
|
||||
_vertexAttribs.push_back(meshvertexattrib);
|
||||
}
|
||||
//
|
||||
if (texs.size())
|
||||
{
|
||||
_vertexsizeBytes += 2;
|
||||
meshvertexattrib.size = 2;
|
||||
meshvertexattrib.vertexAttrib = GLProgram::VERTEX_ATTRIB_TEX_COORD;
|
||||
meshvertexattrib.attribSizeBytes = meshvertexattrib.size * sizeof(float);
|
||||
|
@ -92,8 +95,8 @@ bool RenderMeshData::initFrom(const std::vector<float>& positions,
|
|||
}
|
||||
|
||||
_vertexs.clear();
|
||||
_vertexs.reserve(_vertexNum * _vertexsizeBytes);
|
||||
_vertexsizeBytes *= sizeof(float);
|
||||
_vertexsizeBytes = calVertexSizeBytes();
|
||||
_vertexs.reserve(_vertexNum * _vertexsizeBytes / sizeof(float));
|
||||
|
||||
bool hasNormal = hasVertexAttrib(GLProgram::VERTEX_ATTRIB_NORMAL);
|
||||
bool hasTexCoord = hasVertexAttrib(GLProgram::VERTEX_ATTRIB_TEX_COORD);
|
||||
|
@ -122,6 +125,29 @@ bool RenderMeshData::initFrom(const std::vector<float>& positions,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RenderMeshData::init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount)
|
||||
{
|
||||
_vertexs = vertices;
|
||||
_indices = indices;
|
||||
_vertexAttribs = attribs;
|
||||
|
||||
_vertexsizeBytes = calVertexSizeBytes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int RenderMeshData::calVertexSizeBytes()
|
||||
{
|
||||
int sizeBytes = 0;
|
||||
for (auto it = _vertexAttribs.begin(); it != _vertexAttribs.end(); it++) {
|
||||
sizeBytes += (*it).size;
|
||||
CCASSERT((*it).type == GL_FLOAT, "use float");
|
||||
}
|
||||
sizeBytes *= sizeof(float);
|
||||
|
||||
return sizeBytes;
|
||||
}
|
||||
|
||||
Mesh::Mesh()
|
||||
:_vertexBuffer(0)
|
||||
, _indexBuffer(0)
|
||||
|
@ -148,9 +174,31 @@ Mesh* Mesh::create(const std::vector<float>& positions, const std::vector<float>
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Mesh* Mesh::create(const std::vector<float> &vertices, int vertexSizeInFloat, const std::vector<unsigned short> &indices, int numIndex, const std::vector<MeshVertexAttrib> &attribs, int attribCount)
|
||||
{
|
||||
auto mesh = new Mesh();
|
||||
if (mesh && mesh->init(vertices, vertexSizeInFloat, indices, numIndex, attribs, attribCount))
|
||||
{
|
||||
mesh->autorelease();
|
||||
return mesh;
|
||||
}
|
||||
CC_SAFE_DELETE(mesh);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Mesh::init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices)
|
||||
{
|
||||
bool bRet = _renderdata.initFrom(positions, normals, texs, indices);
|
||||
bool bRet = _renderdata.init(positions, normals, texs, indices);
|
||||
if (!bRet)
|
||||
return false;
|
||||
|
||||
restore();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Mesh::init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount)
|
||||
{
|
||||
bool bRet = _renderdata.init(vertices, vertexSizeInFloat, indices, numIndex, attribs, attribCount);
|
||||
if (!bRet)
|
||||
return false;
|
||||
|
||||
|
@ -211,4 +259,92 @@ void Mesh::restore()
|
|||
buildBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* MeshCache
|
||||
*/
|
||||
MeshCache* MeshCache::_cacheInstance = nullptr;
|
||||
|
||||
MeshCache* MeshCache::getInstance()
|
||||
{
|
||||
if (_cacheInstance == nullptr)
|
||||
_cacheInstance = new MeshCache();
|
||||
|
||||
return _cacheInstance;
|
||||
}
|
||||
void MeshCache::destroyInstance()
|
||||
{
|
||||
if (_cacheInstance)
|
||||
CC_SAFE_DELETE(_cacheInstance);
|
||||
}
|
||||
|
||||
Mesh* MeshCache::getMesh(const std::string& key) const
|
||||
{
|
||||
auto it = _meshes.find(key);
|
||||
if (it != _meshes.end())
|
||||
return it->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool MeshCache::addMesh(const std::string& key, Mesh* mesh)
|
||||
{
|
||||
auto it = _meshes.find(key);
|
||||
if (it == _meshes.end())
|
||||
{
|
||||
mesh->retain();
|
||||
_meshes[key] = mesh;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MeshCache::removeAllMeshes()
|
||||
{
|
||||
for (auto it : _meshes) {
|
||||
CC_SAFE_RELEASE(it.second);
|
||||
}
|
||||
_meshes.clear();
|
||||
}
|
||||
|
||||
void MeshCache::removeUnusedMesh()
|
||||
{
|
||||
for( auto it=_meshes.cbegin(); it!=_meshes.cend(); /* nothing */) {
|
||||
if(it->second->getReferenceCount() == 1)
|
||||
{
|
||||
it->second->release();
|
||||
_meshes.erase(it++);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
MeshCache::MeshCache()
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// listen the event when app go to foreground
|
||||
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(MeshCache::listenBackToForeground, this));
|
||||
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
|
||||
#endif
|
||||
}
|
||||
MeshCache::~MeshCache()
|
||||
{
|
||||
removeAllMeshes();
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
void MeshCache::listenBackToForeground(EventCustom* event)
|
||||
{
|
||||
for (auto iter = _meshes.begin(); iter != _meshes.end(); ++iter)
|
||||
{
|
||||
auto mesh = iter->second;
|
||||
mesh->restore();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "3d/CCBundle3DData.h"
|
||||
|
||||
#include "base/CCRef.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "math/CCMath.h"
|
||||
|
@ -35,18 +37,8 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
//mesh vertex attribute
|
||||
struct MeshVertexAttrib
|
||||
{
|
||||
//attribute size
|
||||
GLint size;
|
||||
//GL_FLOAT
|
||||
GLenum type;
|
||||
//VERTEX_ATTRIB_POSITION,VERTEX_ATTRIB_COLOR,VERTEX_ATTRIB_TEX_COORD,VERTEX_ATTRIB_NORMAL, GLProgram for detail
|
||||
int vertexAttrib;
|
||||
//size in bytes
|
||||
int attribSizeBytes;
|
||||
};
|
||||
class EventListenerCustom;
|
||||
class EventCustom;
|
||||
|
||||
class RenderMeshData
|
||||
{
|
||||
|
@ -56,9 +48,13 @@ public:
|
|||
{
|
||||
}
|
||||
bool hasVertexAttrib(int attrib);
|
||||
bool initFrom(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices);
|
||||
bool init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices);
|
||||
bool init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount);
|
||||
|
||||
protected:
|
||||
|
||||
int calVertexSizeBytes();
|
||||
|
||||
int _vertexsizeBytes;
|
||||
ssize_t _vertexNum;
|
||||
std::vector<float> _vertexs;
|
||||
|
@ -89,6 +85,8 @@ public:
|
|||
|
||||
//create
|
||||
static Mesh* create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices);
|
||||
|
||||
static Mesh* create(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount);
|
||||
|
||||
//get vertex buffer
|
||||
inline GLuint getVertexBuffer() const { return _vertexBuffer; }
|
||||
|
@ -110,15 +108,19 @@ public:
|
|||
//build vertex buffer from renderdata
|
||||
void restore();
|
||||
|
||||
protected:
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
Mesh();
|
||||
virtual ~Mesh();
|
||||
bool init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<unsigned short>& indices);
|
||||
|
||||
bool init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<unsigned short>& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount);
|
||||
|
||||
//build buffer
|
||||
void buildBuffer();
|
||||
void cleanAndFreeBuffers();
|
||||
|
||||
protected:
|
||||
PrimitiveType _primitiveType;
|
||||
IndexFormat _indexFormat;
|
||||
GLuint _vertexBuffer;
|
||||
|
@ -128,6 +130,43 @@ protected:
|
|||
RenderMeshData _renderdata;
|
||||
};
|
||||
|
||||
/**
|
||||
* MeshCache
|
||||
*/
|
||||
class MeshCache
|
||||
{
|
||||
public:
|
||||
static MeshCache* getInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
Mesh* getMesh(const std::string& key) const;
|
||||
|
||||
bool addMesh(const std::string& key, Mesh* mesh);
|
||||
|
||||
void removeAllMeshes();
|
||||
|
||||
void removeUnusedMesh();
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
void listenBackToForeground(EventCustom* event);
|
||||
#endif
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
MeshCache();
|
||||
~MeshCache();
|
||||
|
||||
protected:
|
||||
|
||||
static MeshCache* _cacheInstance;
|
||||
|
||||
std::unordered_map<std::string, Mesh*> _meshes;
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
EventListenerCustom* _backToForegroundlistener;
|
||||
#endif
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCMESH_H_
|
||||
|
|
|
@ -0,0 +1,472 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "3d/CCMeshSkin.h"
|
||||
#include "3d/CCBundle3D.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCPlatformMacros.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* Sets the inverse bind pose matrix.
|
||||
*
|
||||
* @param m C3DMatrix representing the inverse bind pose for this Bone.
|
||||
*/
|
||||
void Bone::setInverseBindPose(const Mat4& m)
|
||||
{
|
||||
_invBindPose = m;
|
||||
}
|
||||
|
||||
const Mat4& Bone::getInverseBindPose()
|
||||
{
|
||||
return _invBindPose;
|
||||
}
|
||||
|
||||
void Bone::setWorldMatDirty(bool dirty)
|
||||
{
|
||||
_worldDirty = dirty;
|
||||
for (auto it : _children) {
|
||||
it->setWorldMatDirty(dirty);
|
||||
}
|
||||
}
|
||||
|
||||
//update own world matrix and children's
|
||||
void Bone::updateWorldMat()
|
||||
{
|
||||
getWorldMat();
|
||||
for (auto itor : _children) {
|
||||
itor->updateWorldMat();
|
||||
}
|
||||
}
|
||||
|
||||
const Mat4& Bone::getWorldMat()
|
||||
{
|
||||
if (_worldDirty)
|
||||
{
|
||||
updateLocalMat();
|
||||
if (_parent)
|
||||
{
|
||||
_world = _parent->getWorldMat() * _local;
|
||||
}
|
||||
else
|
||||
_world = _local;
|
||||
|
||||
_worldDirty = false;
|
||||
}
|
||||
|
||||
return _world;
|
||||
}
|
||||
|
||||
void Bone::setAnimationValue(float* trans, float* rot, float* scale, float weight)
|
||||
{
|
||||
BoneBlendState state;
|
||||
if (trans)
|
||||
state.localTranslate.set(trans);
|
||||
if (rot)
|
||||
state.localRot.set(rot);
|
||||
if (scale)
|
||||
state.localScale.set(scale);
|
||||
|
||||
state.weight = weight;
|
||||
|
||||
_blendStates.push_back(state);
|
||||
_localDirty = true;
|
||||
}
|
||||
|
||||
void Bone::clearBoneBlendState()
|
||||
{
|
||||
_blendStates.clear();
|
||||
for (auto it : _children) {
|
||||
it->clearBoneBlendState();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates C3DBone.
|
||||
*/
|
||||
Bone* Bone::create(const std::string& id)
|
||||
{
|
||||
auto bone = new Bone(id);
|
||||
bone->autorelease();
|
||||
return bone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates the joint matrix.
|
||||
*
|
||||
* @param matrixPalette The matrix palette to update.
|
||||
*/
|
||||
void Bone::updateJointMatrix(Vec4* matrixPalette)
|
||||
{
|
||||
{
|
||||
static Mat4 t;
|
||||
Mat4::multiply(_world, getInverseBindPose(), &t);
|
||||
|
||||
matrixPalette[0].set(t.m[0], t.m[4], t.m[8], t.m[12]);
|
||||
matrixPalette[1].set(t.m[1], t.m[5], t.m[9], t.m[13]);
|
||||
matrixPalette[2].set(t.m[2], t.m[6], t.m[10], t.m[14]);
|
||||
}
|
||||
}
|
||||
|
||||
//bone tree, we do not inherit from Node, Node has too many properties that we do not need. A clean Node is needed.
|
||||
Bone* Bone::getParentBone()
|
||||
{
|
||||
return _parent;
|
||||
}
|
||||
int Bone::getChildBoneCount() const
|
||||
{
|
||||
return _children.size();
|
||||
}
|
||||
Bone* Bone::getChildBoneByIndex(int index)
|
||||
{
|
||||
return _children.at(index);
|
||||
}
|
||||
void Bone::addChildBone(Bone* bone)
|
||||
{
|
||||
if (_children.find(bone) == _children.end())
|
||||
_children.pushBack(bone);
|
||||
}
|
||||
void Bone::removeChildBoneByIndex(int index)
|
||||
{
|
||||
_children.erase(index);
|
||||
}
|
||||
void Bone::removeChildBone(Bone* bone)
|
||||
{
|
||||
_children.eraseObject(bone);
|
||||
}
|
||||
void Bone::removeAllChildBone()
|
||||
{
|
||||
_children.clear();
|
||||
}
|
||||
|
||||
Bone::Bone(const std::string& id)
|
||||
: _name(id)
|
||||
, _parent(nullptr)
|
||||
, _localDirty(true)
|
||||
, _worldDirty(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
Bone::~Bone()
|
||||
{
|
||||
removeAllChildBone();
|
||||
}
|
||||
|
||||
void Bone::updateLocalMat()
|
||||
{
|
||||
if (_blendStates.size())
|
||||
{
|
||||
Vec3 translate(Vec3::ZERO), scale(Vec3::ONE);
|
||||
Quaternion quat(Quaternion::identity());
|
||||
|
||||
float total = 0.f;
|
||||
for (auto it: _blendStates) {
|
||||
total += it.weight;
|
||||
}
|
||||
if (total)
|
||||
{
|
||||
//if (_blendStates.size() == 1)
|
||||
if (true)
|
||||
{
|
||||
int cnt = _blendStates.size();
|
||||
translate = _blendStates[cnt - 1].localTranslate;
|
||||
scale = _blendStates[cnt - 1].localScale;
|
||||
quat = _blendStates[cnt - 1].localRot;
|
||||
}
|
||||
else
|
||||
{
|
||||
float invTotal = 1.f / total;
|
||||
for (auto it : _blendStates) {
|
||||
float weight = (it.weight * invTotal);
|
||||
translate += it.localTranslate * weight;
|
||||
if (!it.localScale.isZero())
|
||||
{
|
||||
scale.x *= it.localScale.x * weight;
|
||||
scale.y *= it.localScale.y * weight;
|
||||
scale.z *= it.localScale.z * weight;
|
||||
}
|
||||
if (!it.localRot.isZero())
|
||||
{
|
||||
if (!quat.isZero())
|
||||
{
|
||||
Quaternion& q = _blendStates[0].localRot;
|
||||
if (q.x * quat.x + q.y * quat.y + q.z * quat.z + q.w * quat.w < 0)
|
||||
weight = -weight;
|
||||
}
|
||||
quat = Quaternion(it.localRot.x * weight + quat.x, it.localRot.y * weight + quat.y, it.localRot.z * weight + quat.z, it.localRot.w * weight + quat.w);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mat4::createTranslation(translate, &_local);
|
||||
_local.rotate(quat);
|
||||
_local.scale(scale);
|
||||
|
||||
_blendStates.clear();
|
||||
_localDirty = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("use cached local");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static int PALETTE_ROWS = 3;
|
||||
|
||||
MeshSkin::MeshSkin()
|
||||
: _rootBone(nullptr)
|
||||
, _matrixPalette(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MeshSkin::~MeshSkin()
|
||||
{
|
||||
removeAllBones();
|
||||
}
|
||||
|
||||
//create a new meshskin if do not want to share meshskin
|
||||
MeshSkin* MeshSkin::create(const std::string& filename, const std::string& name)
|
||||
{
|
||||
//load skin here;
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename);
|
||||
std::string key = fullPath + "#" + name;
|
||||
const auto skindata = MeshSkinDataCache::getInstance()->getMeshSkinData(key);
|
||||
if (skindata)
|
||||
{
|
||||
auto skin = new MeshSkin();
|
||||
skin->initFromSkinData(*skindata);
|
||||
skin->autorelease();
|
||||
return skin;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto instance = Bundle3D::getInstance();
|
||||
bool ret = instance->load(fullPath);
|
||||
if (ret)
|
||||
{
|
||||
SkinData data;
|
||||
if (instance->loadSkinData(name, &data))
|
||||
{
|
||||
auto skin = new MeshSkin();
|
||||
skin->initFromSkinData(data);
|
||||
skin->autorelease();
|
||||
MeshSkinDataCache::getInstance()->addMeshSkinData(key, data);
|
||||
return skin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool MeshSkin::initFromSkinData(const SkinData& skindata)
|
||||
{
|
||||
setBoneCount((int)skindata.boneNames.size());
|
||||
for (size_t i = 0; i < skindata.boneNames.size(); i++) {
|
||||
auto bone = Bone::create(skindata.boneNames[i]);
|
||||
bone->_invBindPose = skindata.inverseBindPoseMatrices[i];
|
||||
addBone(bone);
|
||||
}
|
||||
for (auto it : skindata.boneChild) {
|
||||
auto parent = getBoneByIndex(it.first);
|
||||
for (auto childIt : it.second) {
|
||||
auto child = getBoneByIndex(childIt);
|
||||
child->_parent = parent;
|
||||
parent->_children.pushBack(child);
|
||||
}
|
||||
}
|
||||
|
||||
setRootBone(getBoneByIndex(skindata.rootBoneIndex));
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int MeshSkin::getBoneCount() const
|
||||
{
|
||||
return _bones.size();
|
||||
}
|
||||
|
||||
//get bone
|
||||
Bone* MeshSkin::getBoneByIndex(unsigned int index) const
|
||||
{
|
||||
return _bones.at(index);
|
||||
}
|
||||
Bone* MeshSkin::getBoneByName(const std::string& id) const
|
||||
{
|
||||
for (auto it : _bones) {
|
||||
if (it->getName() == id )
|
||||
return it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//get & set root bone
|
||||
Bone* MeshSkin::getRootBone() const
|
||||
{
|
||||
return _rootBone;
|
||||
}
|
||||
void MeshSkin::setRootBone(Bone* joint)
|
||||
{
|
||||
CC_SAFE_RETAIN(joint);
|
||||
CC_SAFE_RELEASE(_rootBone);
|
||||
_rootBone = joint;
|
||||
}
|
||||
|
||||
void MeshSkin::setBoneCount(int boneCount)
|
||||
{
|
||||
removeAllBones();
|
||||
|
||||
// Resize the joints vector and initialize to NULL
|
||||
_bones.reserve(boneCount);
|
||||
// for (auto i = 0; i < boneCount; i++)
|
||||
// {
|
||||
// _bones.pushBack(nullptr);
|
||||
// }
|
||||
|
||||
// Rebuild the matrix palette. Each matrix is 3 rows of Vec4.
|
||||
CC_SAFE_DELETE_ARRAY(_matrixPalette);
|
||||
|
||||
if (boneCount > 0)
|
||||
{
|
||||
_matrixPalette = new Vec4[boneCount * PALETTE_ROWS];
|
||||
for (unsigned int i = 0; i < boneCount * PALETTE_ROWS; i+=PALETTE_ROWS)
|
||||
{
|
||||
_matrixPalette[i+0].set(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
_matrixPalette[i+1].set(0.0f, 1.0f, 0.0f, 0.0f);
|
||||
_matrixPalette[i+2].set(0.0f, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MeshSkin::getBoneIndex(Bone* joint) const
|
||||
{
|
||||
for (auto i = 0; i < _bones.size(); i++) {
|
||||
if (_bones.at(i) == joint)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//compute matrix palette used by gpu skin
|
||||
Vec4* MeshSkin::getMatrixPalette()
|
||||
{
|
||||
updateBoneMatrix();
|
||||
|
||||
int i = 0;
|
||||
for (auto it : _bones )
|
||||
{
|
||||
it->updateJointMatrix(&_matrixPalette[i++ * PALETTE_ROWS]);
|
||||
}
|
||||
|
||||
return _matrixPalette;
|
||||
}
|
||||
|
||||
//getBoneCount() * 3
|
||||
unsigned int MeshSkin::getMatrixPaletteSize() const
|
||||
{
|
||||
return _bones.size() * PALETTE_ROWS;
|
||||
}
|
||||
|
||||
//refresh bone world matrix
|
||||
void MeshSkin::updateBoneMatrix()
|
||||
{
|
||||
_rootBone->setWorldMatDirty(true);
|
||||
_rootBone->updateWorldMat();
|
||||
}
|
||||
|
||||
void MeshSkin::removeAllBones()
|
||||
{
|
||||
_bones.clear();
|
||||
CC_SAFE_DELETE_ARRAY(_matrixPalette);
|
||||
CC_SAFE_RELEASE(_rootBone);
|
||||
}
|
||||
|
||||
void MeshSkin::addBone(Bone* bone)
|
||||
{
|
||||
_bones.pushBack(bone);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
MeshSkinDataCache* MeshSkinDataCache::_cacheInstance = nullptr;
|
||||
|
||||
MeshSkinDataCache* MeshSkinDataCache::getInstance()
|
||||
{
|
||||
if (_cacheInstance == nullptr)
|
||||
_cacheInstance = new MeshSkinDataCache();
|
||||
return _cacheInstance;
|
||||
}
|
||||
void MeshSkinDataCache::destroyInstance()
|
||||
{
|
||||
if (_cacheInstance)
|
||||
{
|
||||
CC_SAFE_DELETE(_cacheInstance);
|
||||
}
|
||||
}
|
||||
|
||||
const SkinData* MeshSkinDataCache::getMeshSkinData(const std::string& key) const
|
||||
{
|
||||
auto it = _skinDatas.find(key);
|
||||
if (it != _skinDatas.end())
|
||||
return &it->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool MeshSkinDataCache::addMeshSkinData(const std::string& key, const SkinData& skin)
|
||||
{
|
||||
if (_skinDatas.find(key) != _skinDatas.end())
|
||||
return false; // already have this key
|
||||
|
||||
_skinDatas[key] = skin;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MeshSkinDataCache::removeAllMeshSkinData()
|
||||
{
|
||||
_skinDatas.clear();
|
||||
}
|
||||
|
||||
MeshSkinDataCache::MeshSkinDataCache()
|
||||
{
|
||||
|
||||
}
|
||||
MeshSkinDataCache::~MeshSkinDataCache()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,226 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCMESHSKIN_H__
|
||||
#define __CCMESHSKIN_H__
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "3d/CCBundle3DData.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "base/CCVector.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "math/CCMath.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* Defines a basic hierachial structure of transformation spaces.
|
||||
*/
|
||||
class Bone : public Ref
|
||||
{
|
||||
friend class MeshSkin;
|
||||
public:
|
||||
|
||||
/**
|
||||
* Returns the inverse bind pose matrix for this joint.
|
||||
*
|
||||
* @return Inverse bind pose matrix.
|
||||
*/
|
||||
const Mat4& getInverseBindPose();
|
||||
|
||||
//update own world matrix and children's
|
||||
void updateWorldMat();
|
||||
|
||||
void setWorldMatDirty(bool dirty = true);
|
||||
|
||||
const Mat4& getWorldMat();
|
||||
|
||||
const std::string& getName() const { return _name; }
|
||||
|
||||
void setAnimationValue(float* trans, float* rot, float* scale, float weight = 1.0f);
|
||||
|
||||
void clearBoneBlendState();
|
||||
/**
|
||||
* Creates C3DBone.
|
||||
*/
|
||||
static Bone* create(const std::string& id);
|
||||
|
||||
/**
|
||||
* Sets the inverse bind pose matrix.
|
||||
*
|
||||
* @param m C3DMatrix representing the inverse bind pose for this Bone.
|
||||
*/
|
||||
void setInverseBindPose(const Mat4& m);
|
||||
|
||||
/**
|
||||
* Updates the joint matrix.
|
||||
*
|
||||
* @param matrixPalette The matrix palette to update.
|
||||
*/
|
||||
void updateJointMatrix(Vec4* matrixPalette);
|
||||
|
||||
//bone tree, we do not inherit from Node, Node has too many properties that we do not need. A clean Node is needed.
|
||||
Bone* getParentBone();
|
||||
int getChildBoneCount() const;
|
||||
Bone* getChildBoneByIndex(int index);
|
||||
void addChildBone(Bone* bone);
|
||||
void removeChildBoneByIndex(int index);
|
||||
void removeChildBone(Bone* bone);
|
||||
void removeAllChildBone();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
struct BoneBlendState
|
||||
{
|
||||
Vec3 localTranslate;
|
||||
Quaternion localRot;
|
||||
Vec3 localScale;
|
||||
float weight;
|
||||
BoneBlendState()
|
||||
: localTranslate(Vec3::ZERO)
|
||||
, localRot(Quaternion::identity())
|
||||
, localScale(Vec3::ONE)
|
||||
, weight(1.f)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Bone(const std::string& id);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Bone();
|
||||
|
||||
/**
|
||||
* Update local matrix
|
||||
*/
|
||||
void updateLocalMat();
|
||||
|
||||
std::string _name;
|
||||
/**
|
||||
* The Mat4 representation of the Joint's bind pose.
|
||||
*/
|
||||
Mat4 _invBindPose;
|
||||
|
||||
Bone* _parent;
|
||||
|
||||
Vector<Bone*> _children;
|
||||
|
||||
bool _localDirty;
|
||||
bool _worldDirty;
|
||||
Mat4 _world;
|
||||
Mat4 _local;
|
||||
|
||||
std::vector<BoneBlendState> _blendStates;
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
class MeshSkin: public Ref
|
||||
{
|
||||
public:
|
||||
|
||||
//create a new meshskin if do not want to share meshskin
|
||||
static MeshSkin* create(const std::string& filename, const std::string& name);
|
||||
|
||||
unsigned int getBoneCount() const;
|
||||
|
||||
void setBoneCount(int boneCount);
|
||||
|
||||
//get bone
|
||||
Bone* getBoneByIndex(unsigned int index) const;
|
||||
Bone* getBoneByName(const std::string& id) const;
|
||||
|
||||
//get & set root bone
|
||||
Bone* getRootBone() const;
|
||||
void setRootBone(Bone* joint);
|
||||
|
||||
int getBoneIndex(Bone* joint) const;
|
||||
|
||||
//compute matrix palette used by gpu skin
|
||||
Vec4* getMatrixPalette();
|
||||
|
||||
//getBoneCount() * 3
|
||||
unsigned int getMatrixPaletteSize() const;
|
||||
|
||||
//refresh bone world matrix
|
||||
void updateBoneMatrix();
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
MeshSkin();
|
||||
|
||||
~MeshSkin();
|
||||
|
||||
bool initFromSkinData(const SkinData& skindata);
|
||||
|
||||
void removeAllBones();
|
||||
|
||||
void addBone(Bone* bone);
|
||||
|
||||
protected:
|
||||
|
||||
Vector<Bone*> _bones;
|
||||
Bone* _rootBone;
|
||||
|
||||
// Pointer to the array of palette matrices.
|
||||
// This array is passed to the vertex shader as a uniform.
|
||||
// Each 4x3 row-wise matrix is represented as 3 Vec4's.
|
||||
// The number of Vec4's is (_joints.size() * 3).
|
||||
Vec4* _matrixPalette;
|
||||
};
|
||||
|
||||
class MeshSkinDataCache
|
||||
{
|
||||
public:
|
||||
static MeshSkinDataCache* getInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
const SkinData* getMeshSkinData(const std::string& key) const;
|
||||
|
||||
bool addMeshSkinData(const std::string& key, const SkinData& skinData);
|
||||
|
||||
void removeAllMeshSkinData();
|
||||
|
||||
protected:
|
||||
MeshSkinDataCache();
|
||||
~MeshSkinDataCache();
|
||||
|
||||
static MeshSkinDataCache* _cacheInstance;
|
||||
|
||||
std::unordered_map<std::string, SkinData> _skinDatas;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCSKIN_H__
|
|
@ -23,9 +23,11 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "3d/CCSprite3D.h"
|
||||
#include "3d/CCSprite3DDataCache.h"
|
||||
#include "3d/CCMesh.h"
|
||||
#include "3d/CCObjLoader.h"
|
||||
#include "3d/CCMeshSkin.h"
|
||||
#include "3d/CCBundle3D.h"
|
||||
#include "3d/CCSprite3DMaterial.h"
|
||||
|
||||
#include "base/CCDirector.h"
|
||||
#include "base/CCPlatformMacros.h"
|
||||
|
@ -40,7 +42,7 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
std::string s_attributeNames[] = {GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::ATTRIBUTE_NAME_NORMAL};
|
||||
std::string s_attributeNames[] = {GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::ATTRIBUTE_NAME_NORMAL, GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT, GLProgram::ATTRIBUTE_NAME_BLEND_INDEX};
|
||||
|
||||
Sprite3D* Sprite3D::create(const std::string &modelPath)
|
||||
{
|
||||
|
@ -89,6 +91,22 @@ bool Sprite3D::loadFromObj(const std::string& path)
|
|||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path);
|
||||
|
||||
//find from the cache
|
||||
std::string key = fullPath + "#";
|
||||
auto mesh = MeshCache::getInstance()->getMesh(key);
|
||||
if (mesh)
|
||||
{
|
||||
_mesh = mesh;
|
||||
_mesh->retain();
|
||||
|
||||
auto tex = Sprite3DMaterialCache::getInstance()->getSprite3DMaterial(key);
|
||||
setTexture(tex);
|
||||
|
||||
genGLProgramState();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//.mtl file directory
|
||||
std::string dir = "";
|
||||
auto last = fullPath.rfind("/");
|
||||
|
@ -130,13 +148,80 @@ bool Sprite3D::loadFromObj(const std::string& path)
|
|||
genGLProgramState();
|
||||
|
||||
//add to cache
|
||||
Sprite3DDataCache::getInstance()->addSprite3D(fullPath, _mesh, matnames.size() > 0 ? matnames[0] : "");
|
||||
|
||||
if (_texture)
|
||||
{
|
||||
Sprite3DMaterialCache::getInstance()->addSprite3DMaterial(key, _texture);
|
||||
}
|
||||
|
||||
MeshCache::getInstance()->addMesh(key, _mesh);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Sprite3D::loadFromC3x(const std::string& path)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path);
|
||||
//find from the cache
|
||||
std::string key = fullPath + "#";
|
||||
auto mesh = MeshCache::getInstance()->getMesh(key);
|
||||
if (mesh)
|
||||
{
|
||||
_mesh = mesh;
|
||||
_mesh->retain();
|
||||
|
||||
auto tex = Sprite3DMaterialCache::getInstance()->getSprite3DMaterial(key);
|
||||
setTexture(tex);
|
||||
|
||||
_skin = MeshSkin::create(fullPath, "");
|
||||
CC_SAFE_RETAIN(_skin);
|
||||
|
||||
genGLProgramState();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//load from .c3b or .c3t
|
||||
auto bundle = Bundle3D::getInstance();
|
||||
if (!bundle->load(fullPath))
|
||||
return false;
|
||||
|
||||
MeshData meshdata;
|
||||
bool ret = bundle->loadMeshData("", &meshdata);
|
||||
if (!ret)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_mesh = Mesh::create(meshdata.vertex, meshdata.vertexSizeInFloat, meshdata.indices, meshdata.numIndex, meshdata.attribs, meshdata.attribCount);
|
||||
CC_SAFE_RETAIN(_mesh);
|
||||
|
||||
_skin = MeshSkin::create(fullPath, "");
|
||||
CC_SAFE_RETAIN(_skin);
|
||||
|
||||
MaterialData materialdata;
|
||||
ret = bundle->loadMaterialData("", &materialdata);
|
||||
if (ret)
|
||||
{
|
||||
setTexture(materialdata.texturePath);
|
||||
}
|
||||
|
||||
genGLProgramState();
|
||||
|
||||
//add to cache
|
||||
auto cache = Director::getInstance()->getTextureCache();
|
||||
auto tex = cache->addImage(materialdata.texturePath);
|
||||
if (tex)
|
||||
Sprite3DMaterialCache::getInstance()->addSprite3DMaterial(key, tex);
|
||||
|
||||
MeshCache::getInstance()->addMesh(key, _mesh);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Sprite3D::Sprite3D()
|
||||
: _mesh(nullptr)
|
||||
, _skin(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _blend(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||
{
|
||||
|
@ -146,38 +231,29 @@ Sprite3D::~Sprite3D()
|
|||
{
|
||||
CC_SAFE_RELEASE_NULL(_texture);
|
||||
CC_SAFE_RELEASE_NULL(_mesh);
|
||||
CC_SAFE_RELEASE_NULL(_skin);
|
||||
}
|
||||
|
||||
bool Sprite3D::initWithFile(const std::string &path)
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(_mesh);
|
||||
|
||||
CC_SAFE_RELEASE_NULL(_skin);
|
||||
CC_SAFE_RELEASE_NULL(_texture);
|
||||
|
||||
//find from the cache
|
||||
Mesh* mesh = Sprite3DDataCache::getInstance()->getSprite3DMesh(path);
|
||||
if (mesh)
|
||||
//load from file
|
||||
std::string ext = path.substr(path.length() - 4, 4);
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
|
||||
|
||||
if (ext == ".obj")
|
||||
{
|
||||
_mesh = mesh;
|
||||
_mesh->retain();
|
||||
|
||||
auto tex = Sprite3DDataCache::getInstance()->getSprite3DTexture(path);
|
||||
setTexture(tex);
|
||||
|
||||
genGLProgramState();
|
||||
|
||||
return true;
|
||||
return loadFromObj(path);
|
||||
}
|
||||
else
|
||||
else if (ext == ".c3b" || ext == ".c3t")
|
||||
{
|
||||
//load from file
|
||||
std::string ext = path.substr(path.length() - 4, 4);
|
||||
if (ext != ".obj" || !loadFromObj(path))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return loadFromC3x(path);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Sprite3D::genGLProgramState()
|
||||
|
@ -201,8 +277,14 @@ void Sprite3D::genGLProgramState()
|
|||
|
||||
GLProgram* Sprite3D::getDefaultGLProgram(bool textured)
|
||||
{
|
||||
bool hasSkin = _skin && _mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_BLEND_INDEX)
|
||||
&& _mesh->hasVertexAttrib(GLProgram::VERTEX_ATTRIB_BLEND_WEIGHT);
|
||||
|
||||
if(textured)
|
||||
{
|
||||
if (hasSkin)
|
||||
return GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_SKINPOSITION_TEXTURE);
|
||||
|
||||
return GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_POSITION_TEXTURE);
|
||||
}
|
||||
else
|
||||
|
@ -250,6 +332,11 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
|
||||
_meshCommand.setCullFaceEnabled(true);
|
||||
_meshCommand.setDepthTestEnabled(true);
|
||||
if (_skin)
|
||||
{
|
||||
_meshCommand.setMatrixPaletteSize(_skin->getMatrixPaletteSize());
|
||||
_meshCommand.setMatrixPalette(_skin->getMatrixPalette());
|
||||
}
|
||||
//support tint and fade
|
||||
_meshCommand.setDisplayColor(Vec4(color.r, color.g, color.b, color.a));
|
||||
Director::getInstance()->getRenderer()->addCommand(&_meshCommand);
|
||||
|
|
|
@ -38,6 +38,7 @@ NS_CC_BEGIN
|
|||
class GLProgramState;
|
||||
class Mesh;
|
||||
class Texture2D;
|
||||
class MeshSkin;
|
||||
|
||||
/** Sprite3D: TODO add description */
|
||||
class Sprite3D : public Node, public BlendProtocol
|
||||
|
@ -54,18 +55,24 @@ public:
|
|||
void setTexture(Texture2D* texture);
|
||||
|
||||
Mesh* getMesh() const { return _mesh; }
|
||||
|
||||
MeshSkin* getSkin() const { return _skin; }
|
||||
|
||||
// overrides
|
||||
virtual void setBlendFunc(const BlendFunc &blendFunc) override;
|
||||
virtual const BlendFunc &getBlendFunc() const override;
|
||||
|
||||
protected:
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
Sprite3D();
|
||||
virtual ~Sprite3D();
|
||||
bool initWithFile(const std::string &path);
|
||||
|
||||
//.mtl file should at the same directory with the same name if exist
|
||||
bool loadFromObj(const std::string& path);
|
||||
|
||||
//load from .c3b or .c3t
|
||||
bool loadFromC3x(const std::string& path);
|
||||
|
||||
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
||||
|
||||
|
@ -73,7 +80,10 @@ protected:
|
|||
|
||||
void genGLProgramState();
|
||||
|
||||
protected:
|
||||
Mesh *_mesh;
|
||||
MeshSkin *_skin;
|
||||
|
||||
MeshCommand _meshCommand;
|
||||
Texture2D* _texture;
|
||||
BlendFunc _blend;
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "3d/CCSprite3DDataCache.h"
|
||||
|
||||
#include "3d/CCMesh.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
#include "base/CCEventListenerCustom.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
#include "base/CCEventType.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Sprite3DDataCache* Sprite3DDataCache::_cacheInstance = nullptr;
|
||||
|
||||
Sprite3DDataCache::Sprite3DDataCache()
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
// listen the event when app go to foreground
|
||||
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(Sprite3DDataCache::listenBackToForeground, this));
|
||||
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
Sprite3DDataCache::~Sprite3DDataCache()
|
||||
{
|
||||
removeAllSprite3DData();
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
|
||||
#endif
|
||||
}
|
||||
|
||||
Sprite3DDataCache* Sprite3DDataCache::getInstance()
|
||||
{
|
||||
if (! _cacheInstance)
|
||||
{
|
||||
_cacheInstance = new Sprite3DDataCache();
|
||||
}
|
||||
|
||||
return _cacheInstance;
|
||||
}
|
||||
|
||||
void Sprite3DDataCache::purgeMeshCache()
|
||||
{
|
||||
if (_cacheInstance)
|
||||
{
|
||||
CC_SAFE_DELETE(_cacheInstance);
|
||||
}
|
||||
}
|
||||
|
||||
bool Sprite3DDataCache::addSprite3D(const std::string& fileName, Mesh* mesh, const std::string& texture)
|
||||
{
|
||||
const std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
auto itr = _sprite3DDatas.find(fullPath);
|
||||
if (itr == _sprite3DDatas.end())
|
||||
{
|
||||
Sprite3DData data;
|
||||
data.mesh = mesh;
|
||||
CC_SAFE_RETAIN(mesh);
|
||||
data.texture = texture;
|
||||
_sprite3DDatas[fullPath] = data;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Mesh* Sprite3DDataCache::getSprite3DMesh(const std::string& fileName)
|
||||
{
|
||||
const std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
auto itr = _sprite3DDatas.find(fullPath);
|
||||
if (itr != _sprite3DDatas.end())
|
||||
return itr->second.mesh;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Texture2D* Sprite3DDataCache::getSprite3DTexture(const std::string& fileName)
|
||||
{
|
||||
const std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
auto itr = _sprite3DDatas.find(fullPath);
|
||||
if (itr != _sprite3DDatas.end())
|
||||
{
|
||||
auto cache = Director::getInstance()->getTextureCache();
|
||||
return cache->addImage(itr->second.texture);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Sprite3DDataCache::removeAllSprite3DData()
|
||||
{
|
||||
for (auto itr = _sprite3DDatas.begin(); itr != _sprite3DDatas.end(); itr++) {
|
||||
CC_SAFE_RELEASE_NULL(itr->second.mesh);
|
||||
}
|
||||
_sprite3DDatas.clear();
|
||||
}
|
||||
void Sprite3DDataCache::removeUnusedSprite3DData()
|
||||
{
|
||||
for( auto it=_sprite3DDatas.cbegin(); it!=_sprite3DDatas.cend(); /* nothing */) {
|
||||
auto value = it->second;
|
||||
if( value.mesh->getReferenceCount() == 1 ) {
|
||||
CCLOG("cocos2d: GLProgramStateCache: removing unused GLProgramState");
|
||||
|
||||
value.mesh->release();
|
||||
_sprite3DDatas.erase(it++);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
void Sprite3DDataCache::listenBackToForeground(EventCustom* event)
|
||||
{
|
||||
for (auto iter = _sprite3DDatas.begin(); iter != _sprite3DDatas.end(); ++iter)
|
||||
{
|
||||
auto mesh = iter->second.mesh;
|
||||
mesh->restore();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,111 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "3d/CCSprite3DMaterial.h"
|
||||
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
#include "base/CCEventListenerCustom.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
#include "base/CCEventType.h"
|
||||
#include "base/CCDirector.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Sprite3DMaterialCache* Sprite3DMaterialCache::_cacheInstance = nullptr;
|
||||
|
||||
Sprite3DMaterialCache::Sprite3DMaterialCache()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Sprite3DMaterialCache::~Sprite3DMaterialCache()
|
||||
{
|
||||
removeAllSprite3DMaterial();
|
||||
}
|
||||
|
||||
Sprite3DMaterialCache* Sprite3DMaterialCache::getInstance()
|
||||
{
|
||||
if (! _cacheInstance)
|
||||
{
|
||||
_cacheInstance = new Sprite3DMaterialCache();
|
||||
}
|
||||
|
||||
return _cacheInstance;
|
||||
}
|
||||
|
||||
void Sprite3DMaterialCache::destroyInstance()
|
||||
{
|
||||
if (_cacheInstance)
|
||||
{
|
||||
CC_SAFE_DELETE(_cacheInstance);
|
||||
}
|
||||
}
|
||||
|
||||
bool Sprite3DMaterialCache::addSprite3DMaterial(const std::string& key, Texture2D* texture)
|
||||
{
|
||||
auto itr = _materials.find(key);
|
||||
if (itr == _materials.end())
|
||||
{
|
||||
CC_SAFE_RETAIN(texture);
|
||||
_materials[key] = texture;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Texture2D* Sprite3DMaterialCache::getSprite3DMaterial(const std::string& key)
|
||||
{
|
||||
auto itr = _materials.find(key);
|
||||
if (itr != _materials.end())
|
||||
{
|
||||
return itr->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Sprite3DMaterialCache::removeAllSprite3DMaterial()
|
||||
{
|
||||
for (auto itr = _materials.begin(); itr != _materials.end(); itr++) {
|
||||
CC_SAFE_RELEASE_NULL(itr->second);
|
||||
}
|
||||
_materials.clear();
|
||||
}
|
||||
void Sprite3DMaterialCache::removeUnusedSprite3DMaterial()
|
||||
{
|
||||
for( auto it=_materials.cbegin(); it!=_materials.cend(); /* nothing */) {
|
||||
auto value = it->second;
|
||||
if( value->getReferenceCount() == 1 ) {
|
||||
CCLOG("cocos2d: GLProgramStateCache: removing unused GLProgramState");
|
||||
|
||||
value->release();
|
||||
_materials.erase(it++);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -22,8 +22,8 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCSPRIT3DDATA_CACHE_H__
|
||||
#define __CCSPRIT3DDATA_CACHE_H__
|
||||
#ifndef __CCSPRIT3DMATERIAL_H__
|
||||
#define __CCSPRIT3DMATERIAL_H__
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
@ -38,46 +38,34 @@ class EventListenerCustom;
|
|||
class EventCustom;
|
||||
class Texture2D;
|
||||
|
||||
class Sprite3DDataCache
|
||||
/**
|
||||
* the sprite3D material is only texture for now
|
||||
*/
|
||||
class Sprite3DMaterialCache
|
||||
{
|
||||
public:
|
||||
struct Sprite3DData
|
||||
{
|
||||
Mesh* mesh;
|
||||
std::string texture;
|
||||
};
|
||||
|
||||
static Sprite3DDataCache* getInstance();
|
||||
static void purgeMeshCache();
|
||||
static Sprite3DMaterialCache* getInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
bool addSprite3D(const std::string& fileName, Mesh* mesh, const std::string& texture);
|
||||
bool addSprite3DMaterial(const std::string& key, Texture2D* tex);
|
||||
|
||||
Mesh* getSprite3DMesh(const std::string& fileName);
|
||||
Texture2D* getSprite3DMaterial(const std::string& key);
|
||||
|
||||
Texture2D* getSprite3DTexture(const std::string& fileName);
|
||||
void removeAllSprite3DMaterial();
|
||||
void removeUnusedSprite3DMaterial();
|
||||
|
||||
void removeAllSprite3DData();
|
||||
void removeUnusedSprite3DData();
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
void listenBackToForeground(EventCustom* event);
|
||||
#endif
|
||||
Sprite3DMaterialCache();
|
||||
~Sprite3DMaterialCache();
|
||||
|
||||
protected:
|
||||
Sprite3DDataCache();
|
||||
static Sprite3DMaterialCache* _cacheInstance;
|
||||
std::unordered_map<std::string, Texture2D*> _materials; //
|
||||
|
||||
~Sprite3DDataCache();
|
||||
|
||||
static Sprite3DDataCache* _cacheInstance;
|
||||
|
||||
std::unordered_map<std::string, Sprite3DData> _sprite3DDatas; //sprites
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
EventListenerCustom* _backToForegroundlistener;
|
||||
#endif
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCSPRIT3DDATA_CACHE_H__
|
||||
#endif // __CCSPRIT3DMATERIAL_H__
|
|
@ -2,6 +2,10 @@ set(COCOS_3D_SRC
|
|||
3d/CCMesh.cpp
|
||||
3d/CCObjLoader.cpp
|
||||
3d/CCSprite3D.cpp
|
||||
3d/CCSprite3DDataCache.cpp
|
||||
3d/CCSprite3DMaterial.cpp
|
||||
3d/CCAnimate3D.cpp
|
||||
3d/CCAnimation3D.cpp
|
||||
3d/CCBundle3D.cpp
|
||||
3d/CCMeshSkin.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -71,8 +71,12 @@ cocos2d.cpp \
|
|||
2d/CCTransitionPageTurn.cpp \
|
||||
2d/CCTransitionProgress.cpp \
|
||||
2d/CCTweenFunction.cpp \
|
||||
3d/CCAnimate3D.cpp \
|
||||
3d/CCAnimation3D.cpp \
|
||||
3d/CCBundle3D.cpp \
|
||||
3d/CCMesh.cpp \
|
||||
3d/CCSprite3DDataCache.cpp \
|
||||
3d/CCMeshSkin.cpp \
|
||||
3d/CCSprite3DMaterial.cpp \
|
||||
3d/CCObjLoader.cpp \
|
||||
3d/CCSprite3D.cpp \
|
||||
platform/CCGLViewProtocol.cpp \
|
||||
|
@ -185,12 +189,13 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
|
|||
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
|
||||
$(LOCAL_PATH)/. \
|
||||
$(LOCAL_PATH)/platform/android \
|
||||
$(LOCAL_PATH)/../external \
|
||||
$(LOCAL_PATH)/../external/tinyxml2 \
|
||||
$(LOCAL_PATH)/../external/unzip \
|
||||
$(LOCAL_PATH)/../external/chipmunk/include/chipmunk \
|
||||
$(LOCAL_PATH)/../external/edtaa3func \
|
||||
$(LOCAL_PATH)/../external/xxhash \
|
||||
$(LOCAL_PATH)/../external/ConvertUTF
|
||||
$(LOCAL_PATH)/../external/ConvertUTF
|
||||
|
||||
|
||||
LOCAL_LDLIBS := -lGLESv2 \
|
||||
|
|
|
@ -179,4 +179,4 @@ OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *outData)
|
|||
- (BOOL)setPreferredIOBufferDuration:(NSTimeInterval)duration error:(NSError**)outError {return YES;}
|
||||
|
||||
@end
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
|
@ -32,8 +32,8 @@
|
|||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
@ -103,9 +103,11 @@
|
|||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4251</DisableSpecificWarnings>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>winmm.lib;libcocos2d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
|
|
@ -212,4 +212,4 @@ void MediaStreamer::Restart()
|
|||
ThrowIfFailed(
|
||||
m_reader->SetCurrentPosition(GUID_NULL, var)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,4 @@ public:
|
|||
bool GetNextBuffer(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength);
|
||||
void ReadAll(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength);
|
||||
void Restart();
|
||||
};
|
||||
};
|
||||
|
|
|
@ -213,4 +213,4 @@ void MediaStreamer::ReadAll(uint8* buffer, uint32 maxBufferSize, uint32* bufferL
|
|||
void MediaStreamer::Restart()
|
||||
{
|
||||
m_offset = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,4 +55,4 @@ internal:
|
|||
void Initialize(_In_ const WCHAR* url);
|
||||
void ReadAll(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength);
|
||||
void Restart();
|
||||
};
|
||||
};
|
||||
|
|
|
@ -39,4 +39,4 @@ _widgetGetFocus(widgetGetFocus)
|
|||
|
||||
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
KEY_SYSREQ,
|
||||
KEY_BREAK,
|
||||
KEY_ESCAPE,
|
||||
KEY_BACK = KEY_ESCAPE,
|
||||
KEY_BACKSPACE,
|
||||
KEY_TAB,
|
||||
KEY_BACK_TAB,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/CCConsole.h"
|
||||
#include "base/CCEventListener.h"
|
||||
#include "platform/CCCommon.h"
|
||||
|
||||
|
|
|
@ -95,4 +95,4 @@ bool EventListenerFocus::checkAvailable()
|
|||
|
||||
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -109,4 +109,4 @@ bool EventListenerMouse::init()
|
|||
return false;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -187,4 +187,4 @@ EventListenerTouchAllAtOnce* EventListenerTouchAllAtOnce::clone()
|
|||
return ret;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -38,4 +38,4 @@ EventMouse::EventMouse(MouseEventType mouseEventCode)
|
|||
{
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
|
||||
#include "base/CCScheduler.h"
|
||||
#include "2d/CCNode.h"
|
||||
|
||||
bool CC_DLL cc_assert_script_compatible(const char *msg)
|
||||
{
|
||||
|
@ -162,6 +163,51 @@ void ScriptEngineManager::destroyInstance()
|
|||
}
|
||||
}
|
||||
|
||||
bool ScriptEngineManager::sendNodeEventToJS(Node* node, int action)
|
||||
{
|
||||
auto scriptEngine = getInstance()->getScriptEngine();
|
||||
|
||||
if (scriptEngine->isCalledFromScript())
|
||||
{
|
||||
// Should only be invoked at root class Node
|
||||
scriptEngine->setCalledFromScript(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
BasicScriptData data(node,(void*)&action);
|
||||
ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
|
||||
if (scriptEngine->sendEvent(&scriptEvent))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ScriptEngineManager::sendNodeEventToJSExtended(Node* node, int action)
|
||||
{
|
||||
auto scriptEngine = getInstance()->getScriptEngine();
|
||||
|
||||
if (!scriptEngine->isCalledFromScript())
|
||||
{
|
||||
BasicScriptData data(node,(void*)&action);
|
||||
ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
|
||||
if (scriptEngine->sendEvent(&scriptEvent))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScriptEngineManager::sendNodeEventToLua(Node* node, int action)
|
||||
{
|
||||
auto scriptEngine = getInstance()->getScriptEngine();
|
||||
|
||||
BasicScriptData data(node,(void*)&action);
|
||||
ScriptEvent scriptEvent(kNodeEvent,(void*)&data);
|
||||
|
||||
scriptEngine->sendEvent(&scriptEvent);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // #if CC_ENABLE_SCRIPT_BINDING
|
||||
|
|
|
@ -450,6 +450,7 @@ public:
|
|||
virtual bool parseConfig(ConfigType type, const std::string& str) = 0;
|
||||
};
|
||||
|
||||
class Node;
|
||||
/**
|
||||
ScriptEngineManager is a singleton which holds an object instance of ScriptEngineProtocl
|
||||
It helps cocos2d-x and the user code to find back LuaEngine object
|
||||
|
@ -490,6 +491,21 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
static void destroyInstance();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static bool sendNodeEventToJS(Node* node, int action);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static bool sendNodeEventToJSExtended(Node* node, int action);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
static void sendNodeEventToLua(Node* node, int action);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
|
|
@ -70,4 +70,4 @@ Vec2 Touch::getDelta() const
|
|||
return getLocation() - getPreviousLocation();
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -31,7 +31,7 @@ NS_CC_BEGIN
|
|||
|
||||
const char* cocos2dVersion()
|
||||
{
|
||||
return "cocos2d-x 3.1";
|
||||
return "cocos2d-x 3.2alpha0";
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define __CCINTEGER_H__
|
||||
|
||||
#include "base/CCRef.h"
|
||||
#include "base/CCConsole.h"
|
||||
#include "base/CCDataVisitor.h"
|
||||
#include "platform/CCCommon.h"
|
||||
|
||||
|
|
|
@ -86,4 +86,4 @@ void CCBSequence::setChainedSequenceId(int nChainedSequenceId)
|
|||
mChainedSequenceId = nChainedSequenceId;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,4 +114,4 @@ void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, c
|
|||
}
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
@ -27,4 +27,4 @@ void ControlLoader::onHandlePropTypeBlockControl(Node * pNode, Node * pParent, c
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,4 @@ void LabelBMFontLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,4 +80,4 @@ void LabelTTFLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const ch
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,4 +32,4 @@ void LayerColorLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, c
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,4 +42,4 @@ void LayerLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char
|
|||
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
||||
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -27,4 +27,4 @@ void MenuItemLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const c
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,4 +102,4 @@ NodeLoaderLibrary * NodeLoaderLibrary::newDefaultNodeLoaderLibrary() {
|
|||
return ccNodeLoaderLibrary;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,4 +137,4 @@ void ParticleSystemQuadLoader::onHandlePropTypeTexture(Node * pNode, Node * pPar
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,4 +54,4 @@ void ScrollViewLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pPare
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
|
@ -31,8 +31,8 @@
|
|||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '10.0'">v100</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0'">v110</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '11.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v110_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0' and exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A')">v120_xp</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
@ -76,13 +76,15 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)extensions;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
|
|
@ -0,0 +1,278 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCActionTimeline.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
// ActionTimelineData
|
||||
ActionTimelineData* ActionTimelineData::create(int actionTag)
|
||||
{
|
||||
ActionTimelineData * ret = new ActionTimelineData();
|
||||
if (ret && ret->init(actionTag))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ActionTimelineData::ActionTimelineData()
|
||||
: _actionTag(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool ActionTimelineData::init(int actionTag)
|
||||
{
|
||||
_actionTag = actionTag;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ActionTimeline
|
||||
ActionTimeline* ActionTimeline::create()
|
||||
{
|
||||
ActionTimeline* object = new ActionTimeline();
|
||||
if (object && object->init())
|
||||
{
|
||||
object->autorelease();
|
||||
return object;
|
||||
}
|
||||
CC_SAFE_DELETE(object);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ActionTimeline::ActionTimeline()
|
||||
: _duration(0)
|
||||
, _time(0)
|
||||
, _timeSpeed(1)
|
||||
, _frameInternal(1/60.0f)
|
||||
, _playing(false)
|
||||
, _currentFrame(0)
|
||||
, _startFrame(0)
|
||||
, _endFrame(0)
|
||||
, _frameEventListener(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ActionTimeline::~ActionTimeline()
|
||||
{
|
||||
}
|
||||
|
||||
bool ActionTimeline::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ActionTimeline::gotoFrameAndPlay(int startIndex)
|
||||
{
|
||||
gotoFrameAndPlay(startIndex, true);
|
||||
}
|
||||
|
||||
void ActionTimeline::gotoFrameAndPlay(int startIndex, bool loop)
|
||||
{
|
||||
gotoFrameAndPlay(startIndex, _duration, loop);
|
||||
}
|
||||
|
||||
void ActionTimeline::gotoFrameAndPlay(int startIndex, int endIndex, bool loop)
|
||||
{
|
||||
_startFrame = _currentFrame = startIndex;
|
||||
_endFrame = endIndex;
|
||||
_loop = loop;
|
||||
_time = _currentFrame * _frameInternal;
|
||||
|
||||
resume();
|
||||
gotoFrame(_currentFrame);
|
||||
}
|
||||
|
||||
void ActionTimeline::gotoFrameAndPause(int startIndex)
|
||||
{
|
||||
_startFrame = _currentFrame = startIndex;
|
||||
_time = _currentFrame * _frameInternal;
|
||||
|
||||
pause();
|
||||
gotoFrame(_currentFrame);
|
||||
}
|
||||
|
||||
void ActionTimeline::pause()
|
||||
{
|
||||
_playing = false;
|
||||
}
|
||||
|
||||
void ActionTimeline::resume()
|
||||
{
|
||||
_playing = true;
|
||||
}
|
||||
|
||||
bool ActionTimeline::isPlaying() const
|
||||
{
|
||||
return _playing;
|
||||
}
|
||||
|
||||
ActionTimeline* ActionTimeline::clone() const
|
||||
{
|
||||
ActionTimeline* newAction = ActionTimeline::create();
|
||||
newAction->setDuration(_duration);
|
||||
newAction->setTimeSpeed(_timeSpeed);
|
||||
|
||||
for (auto timelines : _timelineMap)
|
||||
{
|
||||
for(auto timeline : timelines.second)
|
||||
{
|
||||
Timeline* newTimeline = timeline->clone();
|
||||
newAction->addTimeline(newTimeline);
|
||||
}
|
||||
}
|
||||
|
||||
return newAction;
|
||||
}
|
||||
|
||||
void ActionTimeline::step(float delta)
|
||||
{
|
||||
if (!_playing || _timelineMap.size() == 0 || _duration == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_time += delta * _timeSpeed;
|
||||
_currentFrame = (int)(_time / _frameInternal);
|
||||
|
||||
stepToFrame(_currentFrame);
|
||||
|
||||
if(_time > _endFrame * _frameInternal)
|
||||
{
|
||||
_playing = _loop;
|
||||
if(!_playing)
|
||||
_time = _endFrame * _frameInternal;
|
||||
else
|
||||
gotoFrameAndPlay(_startFrame, _endFrame, _loop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
typedef std::function<void(Node*)> tCallBack;
|
||||
void foreachNodeDescendant(Node* parent, tCallBack callback)
|
||||
{
|
||||
callback(parent);
|
||||
|
||||
auto children = parent->getChildren();
|
||||
for (auto child : children)
|
||||
{
|
||||
foreachNodeDescendant(child, callback);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionTimeline::startWithTarget(Node *target)
|
||||
{
|
||||
Action::startWithTarget(target);
|
||||
|
||||
foreachNodeDescendant(target,
|
||||
[this, target](Node* child)
|
||||
{
|
||||
ActionTimelineData* data = dynamic_cast<ActionTimelineData*>(child->getUserObject());
|
||||
int actionTag = data->getActionTag();
|
||||
if(_timelineMap.find(actionTag) != _timelineMap.end())
|
||||
{
|
||||
auto timelines = this->_timelineMap[actionTag];
|
||||
for (auto timeline : timelines)
|
||||
{
|
||||
timeline->setNode(child);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ActionTimeline::addTimeline(Timeline* timeline)
|
||||
{
|
||||
int tag = timeline->getActionTag();
|
||||
if (_timelineMap.find(tag) == _timelineMap.end())
|
||||
{
|
||||
_timelineMap[tag] = Vector<Timeline*>();
|
||||
}
|
||||
|
||||
if (!_timelineMap[tag].contains(timeline))
|
||||
{
|
||||
_timelineList.pushBack(timeline);
|
||||
_timelineMap[tag].pushBack(timeline);
|
||||
timeline->setActionTimeline(this);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionTimeline::removeTimeline(Timeline* timeline)
|
||||
{
|
||||
int tag = timeline->getActionTag();
|
||||
if (_timelineMap.find(tag) != _timelineMap.end())
|
||||
{
|
||||
if(_timelineMap[tag].contains(timeline))
|
||||
{
|
||||
_timelineMap[tag].eraseObject(timeline);
|
||||
_timelineList.eraseObject(timeline);
|
||||
timeline->setActionTimeline(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActionTimeline::setFrameEventCallFunc(std::function<void(Frame *)> listener)
|
||||
{
|
||||
_frameEventListener = listener;
|
||||
}
|
||||
|
||||
void ActionTimeline::clearFrameEventCallFunc()
|
||||
{
|
||||
_frameEventListener = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void ActionTimeline::emitFrameEvent(Frame* frame)
|
||||
{
|
||||
if(_frameEventListener)
|
||||
{
|
||||
_frameEventListener(frame);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionTimeline::gotoFrame(int frameIndex)
|
||||
{
|
||||
int size = _timelineList.size();
|
||||
for(int i = 0; i<size; i++)
|
||||
{
|
||||
_timelineList.at(i)->gotoFrame(frameIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void ActionTimeline::stepToFrame(int frameIndex)
|
||||
{
|
||||
int size = _timelineList.size();
|
||||
for(int i = 0; i<size; i++)
|
||||
{
|
||||
_timelineList.at(i)->stepToFrame(frameIndex);
|
||||
}
|
||||
}
|
||||
|
||||
NS_TIMELINE_END
|
|
@ -0,0 +1,160 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCTIMELINE_ACTION_H__
|
||||
#define __CCTIMELINE_ACTION_H__
|
||||
|
||||
#include "CCTimeLine.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
class ActionTimelineData : public cocos2d::Ref
|
||||
{
|
||||
public:
|
||||
static ActionTimelineData* create(int actionTag);
|
||||
|
||||
virtual void setActionTag(int actionTag) { _actionTag = actionTag; }
|
||||
virtual int getActionTag() const { return _actionTag; }
|
||||
protected:
|
||||
ActionTimelineData();
|
||||
virtual bool init(int actionTag);
|
||||
|
||||
int _actionTag;
|
||||
};
|
||||
|
||||
|
||||
class ActionTimeline : public cocos2d::Action
|
||||
{
|
||||
public:
|
||||
friend class Frame;
|
||||
|
||||
static ActionTimeline* create();
|
||||
|
||||
ActionTimeline();
|
||||
virtual ~ActionTimeline();
|
||||
|
||||
virtual bool init();
|
||||
|
||||
/** Goto the specified frame index, and start playing from this index.
|
||||
* @param startIndex The animation will play from this index.
|
||||
*/
|
||||
virtual void gotoFrameAndPlay(int startIndex);
|
||||
|
||||
/** Goto the specified frame index, and start playing from this index.
|
||||
* @param startIndex The animation will play from this index.
|
||||
* @param loop Whether or not the animation need loop.
|
||||
*/
|
||||
virtual void gotoFrameAndPlay(int startIndex, bool loop);
|
||||
|
||||
/** Goto the specified frame index, and start playing from start index, end at end index.
|
||||
* @param startIndex The animation will play from this index.
|
||||
* @param endIndex The animation will end at this index.
|
||||
* @param loop Whether or not the animation need loop.
|
||||
*/
|
||||
virtual void gotoFrameAndPlay(int startIndex, int endIndex, bool loop);
|
||||
|
||||
/** Goto the specified frame index, and pause at this index.
|
||||
* @param startIndex The animation will pause at this index.
|
||||
*/
|
||||
virtual void gotoFrameAndPause(int startIndex);
|
||||
|
||||
/** Pause the animation. */
|
||||
virtual void pause();
|
||||
/** Resume the animation. */
|
||||
virtual void resume();
|
||||
|
||||
/** Whether or not Action is playing. */
|
||||
virtual bool isPlaying() const;
|
||||
|
||||
/** Set the animation speed, this will speed up or slow down the speed. */
|
||||
virtual void setTimeSpeed(float speed) { _timeSpeed = speed; }
|
||||
/** Get current animation speed. */
|
||||
virtual float getTimeSpeed() const { return _timeSpeed; }
|
||||
|
||||
/** duration of the whole action*/
|
||||
virtual void setDuration(int duration) { _duration = duration; }
|
||||
virtual int getDuration() const { return _duration; }
|
||||
|
||||
/** Start frame index of this action*/
|
||||
virtual int getStartFrame() const { return _startFrame; }
|
||||
|
||||
/** End frame of this action.
|
||||
* When action play to this frame, if action is not loop, then it will stop,
|
||||
* or it will play from start frame again. */
|
||||
virtual int getEndFrame() const { return _endFrame; }
|
||||
|
||||
/** Get current frame. */
|
||||
virtual int getCurrentFrame() const { return _currentFrame; }
|
||||
|
||||
/** add Timeline to ActionTimeline */
|
||||
virtual void addTimeline(Timeline* timeline);
|
||||
virtual void removeTimeline(Timeline* timeline);
|
||||
|
||||
virtual const cocos2d::Vector<Timeline*>& getTimelines() const { return _timelineList; }
|
||||
|
||||
/** Set ActionTimeline's frame event callback function */
|
||||
void setFrameEventCallFunc(std::function<void(Frame *)> listener);
|
||||
void clearFrameEventCallFunc();
|
||||
|
||||
/** Inherit from Action. */
|
||||
|
||||
/** Returns a clone of ActionTimeline */
|
||||
virtual ActionTimeline* clone() const override;
|
||||
|
||||
/** Returns a reverse of ActionTimeline.
|
||||
* Not implement yet.
|
||||
*/
|
||||
virtual ActionTimeline* reverse() const override { return nullptr; }
|
||||
|
||||
virtual void step(float delta) override;
|
||||
virtual void startWithTarget(cocos2d::Node *target) override;
|
||||
virtual bool isDone() const override { return false; }
|
||||
protected:
|
||||
virtual void gotoFrame(int frameIndex);
|
||||
virtual void stepToFrame(int frameIndex);
|
||||
|
||||
/** emit frame event, call it when enter a frame*/
|
||||
virtual void emitFrameEvent(Frame* frame);
|
||||
|
||||
std::map<int, cocos2d::Vector<Timeline*>> _timelineMap;
|
||||
cocos2d::Vector<Timeline*> _timelineList;
|
||||
|
||||
int _duration;
|
||||
double _time;
|
||||
float _timeSpeed;
|
||||
float _frameInternal;
|
||||
bool _playing;
|
||||
int _currentFrame;
|
||||
int _startFrame;
|
||||
int _endFrame;
|
||||
bool _loop;
|
||||
|
||||
std::function<void(Frame*)> _frameEventListener;
|
||||
};
|
||||
|
||||
NS_TIMELINE_END
|
||||
|
||||
|
||||
#endif /*__CCTIMELINE_ACTION_H__*/
|
|
@ -0,0 +1,374 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCActionTimelineCache.h"
|
||||
#include "CCNodeReader.h"
|
||||
#include "CCFrame.h"
|
||||
#include "CCTimeLine.h"
|
||||
#include "CCActionTimeline.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
|
||||
static const char* FrameType_VisibleFrame = "VisibleFrame";
|
||||
static const char* FrameType_PositionFrame = "PositionFrame";
|
||||
static const char* FrameType_ScaleFrame = "ScaleFrame";
|
||||
static const char* FrameType_RotationFrame = "RotationFrame";
|
||||
static const char* FrameType_SkewFrame = "SkewFrame";
|
||||
static const char* FrameType_RotationSkewFrame = "RotationSkewFrame";
|
||||
static const char* FrameType_AnchorFrame = "AnchorFrame";
|
||||
static const char* FrameType_InnerActionFrame = "InnerActionFrame";
|
||||
static const char* FrameType_ColorFrame = "ColorFrame";
|
||||
static const char* FrameType_TextureFrame = "TextureFrame";
|
||||
static const char* FrameType_EventFrame = "EventFrame";
|
||||
static const char* FrameType_ZOrderFrame = "ZOrderFrame";
|
||||
|
||||
static const char* ACTION = "action";
|
||||
static const char* DURATION = "duration";
|
||||
static const char* TIMELINES = "timelines";
|
||||
static const char* FRAME_TYPE = "frameType";
|
||||
static const char* FRAMES = "frames";
|
||||
static const char* FRAME_INDEX = "frameIndex";
|
||||
static const char* TWEEN = "tween";
|
||||
static const char* TIME_SPEED = "speed";
|
||||
static const char* ACTION_TAG = "actionTag";
|
||||
static const char* INNER_ACTION = "innerActionType";
|
||||
static const char* START_FRAME = "startFrame";
|
||||
|
||||
static const char* X = "x";
|
||||
static const char* Y = "y";
|
||||
static const char* ROTATION = "rotation";
|
||||
static const char* ALPHA = "alpha";
|
||||
static const char* RED = "red";
|
||||
static const char* GREEN = "green";
|
||||
static const char* BLUE = "blue";
|
||||
static const char* Value = "value";
|
||||
|
||||
|
||||
static ActionTimelineCache* _sharedActionCache = nullptr;
|
||||
|
||||
ActionTimelineCache* ActionTimelineCache::getInstance()
|
||||
{
|
||||
if (! _sharedActionCache)
|
||||
{
|
||||
_sharedActionCache = new ActionTimelineCache();
|
||||
_sharedActionCache->init();
|
||||
}
|
||||
|
||||
return _sharedActionCache;
|
||||
}
|
||||
|
||||
void ActionTimelineCache::destroyInstance()
|
||||
{
|
||||
CC_SAFE_DELETE(_sharedActionCache);
|
||||
}
|
||||
|
||||
void ActionTimelineCache::purge()
|
||||
{
|
||||
_animationActions.clear();
|
||||
}
|
||||
|
||||
void ActionTimelineCache::init()
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
_funcs.insert(Pair(FrameType_VisibleFrame, std::bind(&ActionTimelineCache::loadVisibleFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_PositionFrame, std::bind(&ActionTimelineCache::loadPositionFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_ScaleFrame, std::bind(&ActionTimelineCache::loadScaleFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_RotationFrame, std::bind(&ActionTimelineCache::loadRotationFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_SkewFrame, std::bind(&ActionTimelineCache::loadSkewFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_RotationSkewFrame, std::bind(&ActionTimelineCache::loadRotationSkewFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_AnchorFrame, std::bind(&ActionTimelineCache::loadAnchorPointFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_InnerActionFrame, std::bind(&ActionTimelineCache::loadInnerActionFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_ColorFrame, std::bind(&ActionTimelineCache::loadColorFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_TextureFrame, std::bind(&ActionTimelineCache::loadTextureFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_EventFrame, std::bind(&ActionTimelineCache::loadEventFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_ZOrderFrame, std::bind(&ActionTimelineCache::loadZOrderFrame, this, _1)));
|
||||
|
||||
}
|
||||
|
||||
void ActionTimelineCache::removeAction(const std::string& fileName)
|
||||
{
|
||||
if (_animationActions.find(fileName) != _animationActions.end())
|
||||
{
|
||||
_animationActions.erase(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
ActionTimeline* ActionTimelineCache::createAction(const std::string& fileName)
|
||||
{
|
||||
ActionTimeline* action = _animationActions.at(fileName);
|
||||
if (action == nullptr)
|
||||
{
|
||||
action = loadAnimationActionWithFile(fileName);
|
||||
}
|
||||
return action->clone();
|
||||
}
|
||||
|
||||
ActionTimeline* ActionTimelineCache::loadAnimationActionWithFile(const std::string& fileName)
|
||||
{
|
||||
// Read content from file
|
||||
std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
std::string contentStr = FileUtils::getInstance()->getStringFromFile(fullPath);
|
||||
|
||||
return loadAnimationActionWithContent(fileName, contentStr);
|
||||
}
|
||||
|
||||
ActionTimeline* ActionTimelineCache::loadAnimationActionWithContent(const std::string&fileName, const std::string& content)
|
||||
{
|
||||
// if already exists an action with filename, then return this action
|
||||
ActionTimeline* action = _animationActions.at(fileName);
|
||||
if(action)
|
||||
return action;
|
||||
|
||||
rapidjson::Document doc;
|
||||
doc.Parse<0>(content.c_str());
|
||||
if (doc.HasParseError())
|
||||
{
|
||||
CCLOG("GetParseError %s\n", doc.GetParseError());
|
||||
}
|
||||
|
||||
const rapidjson::Value& json = DICTOOL->getSubDictionary_json(doc, ACTION);
|
||||
|
||||
action = ActionTimeline::create();
|
||||
|
||||
action->setDuration(DICTOOL->getIntValue_json(json, DURATION));
|
||||
action->setTimeSpeed(DICTOOL->getFloatValue_json(json, TIME_SPEED, 1.0f));
|
||||
|
||||
int timelineLength = DICTOOL->getArrayCount_json(json, TIMELINES);
|
||||
for (int i = 0; i<timelineLength; i++)
|
||||
{
|
||||
const rapidjson::Value& dic = DICTOOL->getSubDictionary_json(json, TIMELINES, i);
|
||||
Timeline* timeline = loadTimeline(dic);
|
||||
|
||||
if(timeline)
|
||||
action->addTimeline(timeline);
|
||||
}
|
||||
|
||||
_animationActions.insert(fileName, action);
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
Timeline* ActionTimelineCache::loadTimeline(const rapidjson::Value& json)
|
||||
{
|
||||
Timeline* timeline = nullptr;
|
||||
|
||||
// get frame type
|
||||
const char* frameType = DICTOOL->getStringValue_json(json, FRAME_TYPE);
|
||||
if(frameType == nullptr)
|
||||
return nullptr;
|
||||
|
||||
if(frameType && _funcs.find(frameType) != _funcs.end())
|
||||
{
|
||||
timeline = Timeline::create();
|
||||
|
||||
int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG);
|
||||
timeline->setActionTag(actionTag);
|
||||
|
||||
FrameCreateFunc func = _funcs.at(frameType);
|
||||
|
||||
int length = DICTOOL->getArrayCount_json(json, FRAMES);
|
||||
for (int i = 0; i<length; i++)
|
||||
{
|
||||
const rapidjson::Value& dic = DICTOOL->getSubDictionary_json(json, FRAMES, i);
|
||||
|
||||
Frame* frame = nullptr;
|
||||
|
||||
if (func != nullptr)
|
||||
{
|
||||
frame = func(dic);
|
||||
|
||||
int frameIndex = DICTOOL->getIntValue_json(dic, FRAME_INDEX);
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = DICTOOL->getBooleanValue_json(dic, TWEEN, false);
|
||||
frame->setTween(tween);
|
||||
}
|
||||
|
||||
timeline->addFrame(frame);
|
||||
}
|
||||
}
|
||||
|
||||
return timeline;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadVisibleFrame(const rapidjson::Value& json)
|
||||
{
|
||||
VisibleFrame* frame = VisibleFrame::create();
|
||||
|
||||
bool visible = DICTOOL->getBooleanValue_json(json, Value);
|
||||
frame->setVisible(visible);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadPositionFrame(const rapidjson::Value& json)
|
||||
{
|
||||
PositionFrame* frame = PositionFrame::create();
|
||||
|
||||
float x = DICTOOL->getFloatValue_json(json, X);
|
||||
float y = DICTOOL->getFloatValue_json(json, Y);
|
||||
frame->setPosition(Point(x,y));
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadScaleFrame(const rapidjson::Value& json)
|
||||
{
|
||||
ScaleFrame* frame = ScaleFrame::create();
|
||||
|
||||
float scalex = DICTOOL->getFloatValue_json(json, X);
|
||||
float scaley = DICTOOL->getFloatValue_json(json, Y);
|
||||
|
||||
frame->setScaleX(scalex);
|
||||
frame->setScaleY(scaley);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadSkewFrame(const rapidjson::Value& json)
|
||||
{
|
||||
SkewFrame* frame = SkewFrame::create();
|
||||
|
||||
float skewx = DICTOOL->getFloatValue_json(json, X);
|
||||
float skewy = DICTOOL->getFloatValue_json(json, Y);
|
||||
|
||||
frame->setSkewX(skewx);
|
||||
frame->setSkewY(skewy);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadRotationSkewFrame(const rapidjson::Value& json)
|
||||
{
|
||||
RotationSkewFrame* frame = RotationSkewFrame::create();
|
||||
|
||||
float skewx = DICTOOL->getFloatValue_json(json, X);
|
||||
float skewy = DICTOOL->getFloatValue_json(json, Y);
|
||||
|
||||
frame->setSkewX(skewx);
|
||||
frame->setSkewY(skewy);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadRotationFrame(const rapidjson::Value& json)
|
||||
{
|
||||
RotationFrame* frame = RotationFrame::create();
|
||||
|
||||
float rotation = DICTOOL->getFloatValue_json(json, ROTATION);
|
||||
frame->setRotation(rotation);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadAnchorPointFrame (const rapidjson::Value& json)
|
||||
{
|
||||
AnchorPointFrame* frame = AnchorPointFrame::create();
|
||||
|
||||
float anchorx = DICTOOL->getFloatValue_json(json, X);
|
||||
float anchory = DICTOOL->getFloatValue_json(json, Y);
|
||||
|
||||
frame->setAnchorPoint(Point(anchorx, anchory));
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadInnerActionFrame(const rapidjson::Value& json)
|
||||
{
|
||||
InnerActionFrame* frame = InnerActionFrame::create();
|
||||
|
||||
InnerActionType type = (InnerActionType)DICTOOL->getIntValue_json(json, INNER_ACTION);
|
||||
int startFrame = DICTOOL->getIntValue_json(json, START_FRAME);
|
||||
|
||||
frame->setInnerActionType(type);
|
||||
frame->setStartFrameIndex(startFrame);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadColorFrame(const rapidjson::Value& json)
|
||||
{
|
||||
ColorFrame* frame = ColorFrame::create();
|
||||
|
||||
GLubyte alpha = (GLubyte)DICTOOL->getIntValue_json(json, ALPHA);
|
||||
GLubyte red = (GLubyte)DICTOOL->getIntValue_json(json, RED);
|
||||
GLubyte green = (GLubyte)DICTOOL->getIntValue_json(json, GREEN);
|
||||
GLubyte blue = (GLubyte)DICTOOL->getIntValue_json(json, BLUE);
|
||||
|
||||
frame->setAlpha(alpha);
|
||||
frame->setColor(Color3B(red, green, blue));
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadTextureFrame(const rapidjson::Value& json)
|
||||
{
|
||||
TextureFrame* frame = TextureFrame::create();
|
||||
|
||||
const char* texture = DICTOOL->getStringValue_json(json, Value);
|
||||
|
||||
if(texture != nullptr)
|
||||
{
|
||||
std::string path = texture;
|
||||
|
||||
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path);
|
||||
if(spriteFrame == nullptr)
|
||||
{
|
||||
std::string jsonPath = NodeReader::getInstance()->getJsonPath();
|
||||
path = jsonPath + texture;
|
||||
}
|
||||
|
||||
frame->setTextureName(path);
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadEventFrame(const rapidjson::Value& json)
|
||||
{
|
||||
EventFrame* frame = EventFrame::create();
|
||||
|
||||
const char* evnt = DICTOOL->getStringValue_json(json, Value);
|
||||
|
||||
if(evnt != nullptr)
|
||||
frame->setEvent(evnt);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadZOrderFrame(const rapidjson::Value& json)
|
||||
{
|
||||
ZOrderFrame* frame = ZOrderFrame::create();
|
||||
|
||||
int zorder = DICTOOL->getIntValue_json(json, Value);
|
||||
frame->setZOrder(zorder);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCTIMELINE_ACTION_CACHE_H__
|
||||
#define __CCTIMELINE_ACTION_CACHE_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "cocostudio/DictionaryHelper.h"
|
||||
#include "CCTimelineMacro.h"
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
class ActionTimeline;
|
||||
class Timeline;
|
||||
class Frame;
|
||||
|
||||
class ActionTimelineCache
|
||||
{
|
||||
public:
|
||||
/** Gets the singleton */
|
||||
static ActionTimelineCache* getInstance();
|
||||
|
||||
/** Destroys the singleton */
|
||||
static void destroyInstance();
|
||||
|
||||
void purge();
|
||||
|
||||
void init();
|
||||
|
||||
/** Remove action with filename, and also remove other resource relate with this file */
|
||||
void removeAction(const std::string& fileName);
|
||||
|
||||
/** Clone a action with the specified name from the container. */
|
||||
ActionTimeline* createAction(const std::string& fileName);
|
||||
|
||||
ActionTimeline* loadAnimationActionWithFile(const std::string& fileName);
|
||||
ActionTimeline* loadAnimationActionWithContent(const std::string&fileName, const std::string& content);
|
||||
protected:
|
||||
|
||||
Timeline* loadTimeline(const rapidjson::Value& json);
|
||||
|
||||
Frame* loadVisibleFrame (const rapidjson::Value& json);
|
||||
Frame* loadPositionFrame (const rapidjson::Value& json);
|
||||
Frame* loadScaleFrame (const rapidjson::Value& json);
|
||||
Frame* loadSkewFrame (const rapidjson::Value& json);
|
||||
Frame* loadRotationSkewFrame(const rapidjson::Value& json);
|
||||
Frame* loadRotationFrame (const rapidjson::Value& json);
|
||||
Frame* loadAnchorPointFrame (const rapidjson::Value& json);
|
||||
Frame* loadInnerActionFrame (const rapidjson::Value& json);
|
||||
Frame* loadColorFrame (const rapidjson::Value& json);
|
||||
Frame* loadTextureFrame (const rapidjson::Value& json);
|
||||
Frame* loadEventFrame (const rapidjson::Value& json);
|
||||
Frame* loadZOrderFrame (const rapidjson::Value& json);
|
||||
|
||||
protected:
|
||||
|
||||
typedef std::function<Frame*(const rapidjson::Value& json)> FrameCreateFunc;
|
||||
typedef std::pair<std::string, FrameCreateFunc> Pair;
|
||||
|
||||
std::unordered_map<std::string, FrameCreateFunc> _funcs;
|
||||
cocos2d::Map<std::string, ActionTimeline*> _animationActions;
|
||||
};
|
||||
|
||||
NS_TIMELINE_END
|
||||
|
||||
#endif /*__CCTIMELINE_ACTION_CACHE_H__*/
|
|
@ -0,0 +1,622 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCFrame.h"
|
||||
#include "CCTimeLine.h"
|
||||
#include "CCActionTimeline.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
// Frame
|
||||
Frame::Frame()
|
||||
: _frameIndex(0)
|
||||
, _tween(true)
|
||||
, _timeline(nullptr)
|
||||
, _node(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Frame::~Frame()
|
||||
{
|
||||
}
|
||||
|
||||
void Frame::emitEvent()
|
||||
{
|
||||
if (_timeline)
|
||||
{
|
||||
_timeline->getActionTimeline()->emitFrameEvent(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Frame::cloneProperty(Frame* frame)
|
||||
{
|
||||
_frameIndex = frame->getFrameIndex();
|
||||
_tween = frame->isTween();
|
||||
}
|
||||
|
||||
|
||||
// VisibleFrame
|
||||
VisibleFrame* VisibleFrame::create()
|
||||
{
|
||||
VisibleFrame* frame = new VisibleFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VisibleFrame::VisibleFrame()
|
||||
: _visible(true)
|
||||
{
|
||||
}
|
||||
|
||||
void VisibleFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
_node->setVisible(_visible);
|
||||
}
|
||||
|
||||
|
||||
Frame* VisibleFrame::clone()
|
||||
{
|
||||
VisibleFrame* frame = VisibleFrame::create();
|
||||
frame->setVisible(_visible);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TextureFrame
|
||||
TextureFrame* TextureFrame::create()
|
||||
{
|
||||
TextureFrame* frame = new TextureFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TextureFrame::TextureFrame()
|
||||
: _textureName("")
|
||||
{
|
||||
}
|
||||
|
||||
void TextureFrame::setNode(Node* node)
|
||||
{
|
||||
Frame::setNode(node);
|
||||
|
||||
_sprite = dynamic_cast<Sprite*>(node);
|
||||
}
|
||||
|
||||
void TextureFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
if(_sprite)
|
||||
{
|
||||
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(_textureName);
|
||||
|
||||
if(spriteFrame != nullptr)
|
||||
_sprite->setSpriteFrame(spriteFrame);
|
||||
else
|
||||
_sprite->setTexture(_textureName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Frame* TextureFrame::clone()
|
||||
{
|
||||
TextureFrame* frame = TextureFrame::create();
|
||||
frame->setTextureName(_textureName);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// RotationFrame
|
||||
RotationFrame* RotationFrame::create()
|
||||
{
|
||||
RotationFrame* frame = new RotationFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RotationFrame::RotationFrame()
|
||||
: _rotation(0)
|
||||
{
|
||||
}
|
||||
|
||||
void RotationFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
_node->setRotation(_rotation);
|
||||
|
||||
if(_tween)
|
||||
{
|
||||
_betwennRotation = static_cast<RotationFrame*>(nextFrame)->_rotation - _rotation;
|
||||
}
|
||||
}
|
||||
|
||||
void RotationFrame::apply(float percent)
|
||||
{
|
||||
if (_tween && percent != 0 && _betwennRotation != 0)
|
||||
{
|
||||
float rotation = _rotation + percent * _betwennRotation;
|
||||
_node->setRotation(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
Frame* RotationFrame::clone()
|
||||
{
|
||||
RotationFrame* frame = RotationFrame::create();
|
||||
frame->setRotation(_rotation);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// SkewFrame
|
||||
SkewFrame* SkewFrame::create()
|
||||
{
|
||||
SkewFrame* frame = new SkewFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkewFrame::SkewFrame()
|
||||
: _skewX(0)
|
||||
, _skewY(0)
|
||||
{
|
||||
}
|
||||
|
||||
void SkewFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
_node->setSkewX(_skewX);
|
||||
_node->setSkewY(_skewY);
|
||||
|
||||
if(_tween)
|
||||
{
|
||||
_betweenSkewX = static_cast<SkewFrame*>(nextFrame)->_skewX - _skewX;
|
||||
_betweenSkewY = static_cast<SkewFrame*>(nextFrame)->_skewY - _skewY;
|
||||
}
|
||||
}
|
||||
|
||||
void SkewFrame::apply(float percent)
|
||||
{
|
||||
if (_tween && percent != 0 && (_betweenSkewX != 0 || _betweenSkewY != 0))
|
||||
{
|
||||
float skewx = _skewX + percent * _betweenSkewX;
|
||||
float skewy = _skewY + percent * _betweenSkewY;
|
||||
|
||||
_node->setSkewX(skewx);
|
||||
_node->setSkewY(skewy);
|
||||
}
|
||||
}
|
||||
|
||||
Frame* SkewFrame::clone()
|
||||
{
|
||||
SkewFrame* frame = SkewFrame::create();
|
||||
frame->setSkewX(_skewX);
|
||||
frame->setSkewY(_skewY);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// RotationSkewFrame
|
||||
RotationSkewFrame* RotationSkewFrame::create()
|
||||
{
|
||||
RotationSkewFrame* frame = new RotationSkewFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RotationSkewFrame::RotationSkewFrame()
|
||||
{
|
||||
}
|
||||
|
||||
void RotationSkewFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
_node->setRotationSkewX(_skewX);
|
||||
_node->setRotationSkewY(_skewY);
|
||||
|
||||
if (_tween)
|
||||
{
|
||||
_betweenSkewX = static_cast<RotationSkewFrame*>(nextFrame)->_skewX - _skewX;
|
||||
_betweenSkewY = static_cast<RotationSkewFrame*>(nextFrame)->_skewY - _skewY;
|
||||
}
|
||||
}
|
||||
|
||||
void RotationSkewFrame::apply(float percent)
|
||||
{
|
||||
if (_tween && percent != 0 && (_betweenSkewX != 0 || _betweenSkewY != 0))
|
||||
{
|
||||
float skewx = _skewX + percent * _betweenSkewX;
|
||||
float skewy = _skewY + percent * _betweenSkewY;
|
||||
|
||||
_node->setRotationSkewX(skewx);
|
||||
_node->setRotationSkewY(skewy);
|
||||
}
|
||||
}
|
||||
|
||||
Frame* RotationSkewFrame::clone()
|
||||
{
|
||||
RotationSkewFrame* frame = RotationSkewFrame::create();
|
||||
frame->setSkewX(_skewX);
|
||||
frame->setSkewY(_skewY);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
// PositionFrame
|
||||
PositionFrame* PositionFrame::create()
|
||||
{
|
||||
PositionFrame* frame = new PositionFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PositionFrame::PositionFrame()
|
||||
: _position(0,0)
|
||||
{
|
||||
}
|
||||
|
||||
void PositionFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
_node->setPosition(_position);
|
||||
|
||||
if(_tween)
|
||||
{
|
||||
_betweenX = static_cast<PositionFrame*>(nextFrame)->_position.x - _position.x;
|
||||
_betweenY = static_cast<PositionFrame*>(nextFrame)->_position.y - _position.y;
|
||||
}
|
||||
}
|
||||
|
||||
void PositionFrame::apply(float percent)
|
||||
{
|
||||
if (_tween && percent != 0 && (_betweenX != 0 || _betweenY != 0))
|
||||
{
|
||||
Point p;
|
||||
p.x = _position.x + _betweenX * percent;
|
||||
p.y = _position.y + _betweenY * percent;
|
||||
|
||||
_node->setPosition(p);
|
||||
}
|
||||
}
|
||||
|
||||
Frame* PositionFrame::clone()
|
||||
{
|
||||
PositionFrame* frame = PositionFrame::create();
|
||||
frame->setPosition(_position);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
// ScaleFrame
|
||||
ScaleFrame* ScaleFrame::create()
|
||||
{
|
||||
ScaleFrame* frame = new ScaleFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ScaleFrame::ScaleFrame()
|
||||
: _scaleX(1)
|
||||
, _scaleY(1)
|
||||
{
|
||||
}
|
||||
|
||||
void ScaleFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
_node->setScaleX(_scaleX);
|
||||
_node->setScaleY(_scaleY);
|
||||
|
||||
if(_tween)
|
||||
{
|
||||
_betweenScaleX = static_cast<ScaleFrame*>(nextFrame)->_scaleX - _scaleX;
|
||||
_betweenScaleY = static_cast<ScaleFrame*>(nextFrame)->_scaleY - _scaleY;
|
||||
}
|
||||
}
|
||||
|
||||
void ScaleFrame::apply(float percent)
|
||||
{
|
||||
if (_tween && percent != 0 && (_betweenScaleX != 0 || _betweenScaleY != 0))
|
||||
{
|
||||
float scaleX = _scaleX + _betweenScaleX * percent;
|
||||
float scaleY = _scaleY + _betweenScaleY * percent;
|
||||
|
||||
_node->setScaleX(scaleX);
|
||||
_node->setScaleY(scaleY);
|
||||
}
|
||||
}
|
||||
|
||||
Frame* ScaleFrame::clone()
|
||||
{
|
||||
ScaleFrame* frame = ScaleFrame::create();
|
||||
frame->setScaleX(_scaleX);
|
||||
frame->setScaleY(_scaleY);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
// AnchorPointFrame
|
||||
AnchorPointFrame* AnchorPointFrame::create()
|
||||
{
|
||||
AnchorPointFrame* frame = new AnchorPointFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AnchorPointFrame::AnchorPointFrame()
|
||||
: _anchorPoint(0.5f,0.5f)
|
||||
{
|
||||
}
|
||||
|
||||
void AnchorPointFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
_node->setAnchorPoint(_anchorPoint);
|
||||
}
|
||||
|
||||
|
||||
Frame* AnchorPointFrame::clone()
|
||||
{
|
||||
AnchorPointFrame* frame = AnchorPointFrame::create();
|
||||
frame->setAnchorPoint(_anchorPoint);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// InnerActionFrame
|
||||
InnerActionFrame* InnerActionFrame::create()
|
||||
{
|
||||
InnerActionFrame* frame = new InnerActionFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
InnerActionFrame::InnerActionFrame()
|
||||
: _innerActionType(LoopAction)
|
||||
, _startFrameIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
void InnerActionFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Frame* InnerActionFrame::clone()
|
||||
{
|
||||
InnerActionFrame* frame = InnerActionFrame::create();
|
||||
frame->setInnerActionType(_innerActionType);
|
||||
frame->setStartFrameIndex(_startFrameIndex);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
// ColorFrame
|
||||
ColorFrame* ColorFrame::create()
|
||||
{
|
||||
ColorFrame* frame = new ColorFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ColorFrame::ColorFrame()
|
||||
: _alpha(255)
|
||||
, _color(Color3B(255, 255, 255))
|
||||
{
|
||||
}
|
||||
|
||||
void ColorFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
_node->setOpacity(_alpha);
|
||||
_node->setColor(_color);
|
||||
|
||||
if(_tween)
|
||||
{
|
||||
_betweenAlpha = static_cast<ColorFrame*>(nextFrame)->_alpha - _alpha;
|
||||
|
||||
const Color3B& color = static_cast<ColorFrame*>(nextFrame)->_color;
|
||||
_betweenRed = color.r - _color.r;
|
||||
_betweenGreen = color.g - _color.g;
|
||||
_betweenBlue = color.b - _color.b;
|
||||
}
|
||||
|
||||
_node->setCascadeColorEnabled(true);
|
||||
_node->setCascadeOpacityEnabled(true);
|
||||
}
|
||||
|
||||
void ColorFrame::apply(float percent)
|
||||
{
|
||||
if (_tween && percent != 0 && (_betweenAlpha !=0 || _betweenRed != 0 || _betweenGreen != 0 || _betweenBlue != 0))
|
||||
{
|
||||
GLubyte alpha = _alpha + _betweenAlpha * percent;
|
||||
|
||||
Color3B color;
|
||||
color.r = _color.r+ _betweenRed * percent;
|
||||
color.g = _color.g+ _betweenGreen * percent;
|
||||
color.b = _color.b+ _betweenBlue * percent;
|
||||
|
||||
_node->setOpacity(alpha);
|
||||
_node->setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
Frame* ColorFrame::clone()
|
||||
{
|
||||
ColorFrame* frame = ColorFrame::create();
|
||||
frame->setAlpha(_alpha);
|
||||
frame->setColor(_color);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
// EventFrame
|
||||
EventFrame* EventFrame::create()
|
||||
{
|
||||
EventFrame* frame = new EventFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EventFrame::EventFrame()
|
||||
: _event("")
|
||||
{
|
||||
}
|
||||
|
||||
void EventFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
emitEvent();
|
||||
}
|
||||
|
||||
|
||||
Frame* EventFrame::clone()
|
||||
{
|
||||
EventFrame* frame = EventFrame::create();
|
||||
frame->setEvent(_event);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
// ZOrderFrame
|
||||
ZOrderFrame* ZOrderFrame::create()
|
||||
{
|
||||
ZOrderFrame* frame = new ZOrderFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZOrderFrame::ZOrderFrame()
|
||||
: _zorder(0)
|
||||
{
|
||||
}
|
||||
|
||||
void ZOrderFrame::onEnter(Frame *nextFrame)
|
||||
{
|
||||
if(_node)
|
||||
_node->setZOrder(_zorder);
|
||||
}
|
||||
|
||||
|
||||
Frame* ZOrderFrame::clone()
|
||||
{
|
||||
ZOrderFrame* frame = ZOrderFrame::create();
|
||||
frame->setZOrder(_zorder);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
NS_TIMELINE_END
|
|
@ -0,0 +1,330 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCFRAME_H__
|
||||
#define __CCFRAME_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "CCTimelineMacro.h"
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
class Timeline;
|
||||
|
||||
class Frame : public cocos2d::Ref
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void setFrameIndex(unsigned int frameIndex) { _frameIndex = frameIndex; }
|
||||
virtual unsigned int getFrameIndex() const { return _frameIndex; }
|
||||
|
||||
virtual void setTimeline(Timeline* timeline) { _timeline = timeline; }
|
||||
virtual Timeline* getTimeline() const { return _timeline; }
|
||||
|
||||
virtual void setNode(cocos2d::Node* node) { _node = node; }
|
||||
virtual cocos2d::Node* getNode() const { return _node; }
|
||||
|
||||
virtual void setTween(bool tween) { _tween = tween; }
|
||||
virtual bool isTween() const { return _tween; }
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) = 0;
|
||||
virtual void apply(float percent) {}
|
||||
|
||||
virtual Frame* clone() = 0;
|
||||
protected:
|
||||
Frame();
|
||||
virtual ~Frame();
|
||||
|
||||
virtual void emitEvent();
|
||||
virtual void cloneProperty(Frame* frame);
|
||||
protected:
|
||||
|
||||
unsigned int _frameIndex;
|
||||
bool _tween;
|
||||
|
||||
Timeline* _timeline;
|
||||
cocos2d::Node* _node;
|
||||
};
|
||||
|
||||
|
||||
class VisibleFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static VisibleFrame* create();
|
||||
|
||||
VisibleFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setVisible(bool visible) { _visible = visible;}
|
||||
inline bool isVisible() const { return _visible; }
|
||||
|
||||
protected:
|
||||
bool _visible;
|
||||
};
|
||||
|
||||
|
||||
class TextureFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static TextureFrame* create();
|
||||
|
||||
TextureFrame();
|
||||
|
||||
virtual void setNode(cocos2d::Node* node);
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setTextureName(std::string textureName) { _textureName = textureName;}
|
||||
inline std::string getTextureName() const { return _textureName; }
|
||||
|
||||
protected:
|
||||
cocos2d::Sprite* _sprite;
|
||||
std::string _textureName;
|
||||
};
|
||||
|
||||
class RotationFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static RotationFrame* create();
|
||||
|
||||
RotationFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setRotation(float rotation) { _rotation = rotation; }
|
||||
inline float getRotation() const { return _rotation; }
|
||||
|
||||
protected:
|
||||
float _rotation;
|
||||
float _betwennRotation;
|
||||
};
|
||||
|
||||
class SkewFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static SkewFrame* create();
|
||||
|
||||
SkewFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setSkewX(float skewx) { _skewX = skewx; }
|
||||
inline float getSkewX() const { return _skewX; }
|
||||
|
||||
inline void setSkewY(float skewy) { _skewY = skewy; }
|
||||
inline float getSkewY() const { return _skewY; }
|
||||
|
||||
protected:
|
||||
float _skewX;
|
||||
float _skewY;
|
||||
float _betweenSkewX;
|
||||
float _betweenSkewY;
|
||||
};
|
||||
|
||||
|
||||
class RotationSkewFrame : public SkewFrame
|
||||
{
|
||||
public:
|
||||
static RotationSkewFrame* create();
|
||||
|
||||
RotationSkewFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
};
|
||||
|
||||
|
||||
class PositionFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static PositionFrame* create();
|
||||
|
||||
PositionFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setPosition(const cocos2d::Point& position) { _position = position; }
|
||||
inline cocos2d::Point getPosition() const { return _position; }
|
||||
|
||||
inline void setX(float x) { _position.x = x; }
|
||||
inline void setY(float y) { _position.y = y; }
|
||||
|
||||
inline float getX() const { return _position.x; }
|
||||
inline float getY() const { return _position.y; }
|
||||
protected:
|
||||
cocos2d::Point _position;
|
||||
float _betweenX;
|
||||
float _betweenY;
|
||||
};
|
||||
|
||||
|
||||
class ScaleFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static ScaleFrame* create();
|
||||
|
||||
ScaleFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setScale(float scale) { _scaleX = scale; _scaleY = scale; }
|
||||
|
||||
inline void setScaleX(float scaleX) { _scaleX = scaleX; }
|
||||
inline float getScaleX() const { return _scaleX; }
|
||||
|
||||
inline void setScaleY(float scaleY) { _scaleY = scaleY;}
|
||||
inline float getScaleY() const { return _scaleY; }
|
||||
|
||||
protected:
|
||||
float _scaleX;
|
||||
float _scaleY;
|
||||
float _betweenScaleX;
|
||||
float _betweenScaleY;
|
||||
};
|
||||
|
||||
|
||||
class AnchorPointFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static AnchorPointFrame* create();
|
||||
|
||||
AnchorPointFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setAnchorPoint(const cocos2d::Point& point) { _anchorPoint = point; }
|
||||
inline cocos2d::Point getAnchorPoint() const { return _anchorPoint; }
|
||||
|
||||
protected:
|
||||
cocos2d::Point _anchorPoint;
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum InnerActionType
|
||||
{
|
||||
LoopAction,
|
||||
NoLoopAction,
|
||||
SingleFrame
|
||||
};
|
||||
|
||||
class InnerActionFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static InnerActionFrame* create();
|
||||
InnerActionFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setInnerActionType(InnerActionType type) { _innerActionType = type; }
|
||||
inline InnerActionType getInnerActionType() const { return _innerActionType; }
|
||||
|
||||
inline void setStartFrameIndex(int frameIndex) { _startFrameIndex = frameIndex; }
|
||||
inline int getStartFrameIndex() const { return _startFrameIndex; }
|
||||
|
||||
protected:
|
||||
InnerActionType _innerActionType;
|
||||
int _startFrameIndex;
|
||||
};
|
||||
|
||||
|
||||
class ColorFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static ColorFrame* create();
|
||||
ColorFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
|
||||
inline GLubyte getAlpha() const { return _alpha; }
|
||||
|
||||
inline void setColor(const cocos2d::Color3B& color) { _color = color; }
|
||||
inline cocos2d::Color3B getColor() const { return _color; }
|
||||
|
||||
protected:
|
||||
GLubyte _alpha;
|
||||
cocos2d::Color3B _color;
|
||||
|
||||
int _betweenAlpha;
|
||||
int _betweenRed;
|
||||
int _betweenGreen;
|
||||
int _betweenBlue;
|
||||
};
|
||||
|
||||
|
||||
class EventFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static EventFrame* create();
|
||||
|
||||
EventFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setEvent(std::string event) { _event = event;}
|
||||
inline std::string getEvent() const { return _event; }
|
||||
|
||||
protected:
|
||||
std::string _event;
|
||||
};
|
||||
|
||||
class ZOrderFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static ZOrderFrame* create();
|
||||
|
||||
ZOrderFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setZOrder(int zorder) { _zorder = zorder;}
|
||||
inline int getZOrder() const { return _zorder; }
|
||||
|
||||
protected:
|
||||
int _zorder;
|
||||
};
|
||||
|
||||
NS_TIMELINE_END
|
||||
|
||||
|
||||
#endif /*__CCFRAME_H__*/
|
|
@ -0,0 +1,458 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCNodeReader.h"
|
||||
#include "CCActionTimelineCache.h"
|
||||
#include "CCActionTimeline.h"
|
||||
|
||||
#include "cocostudio/CCSGUIReader.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
using namespace ui;
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
|
||||
|
||||
static const char* ClassName_Node = "Node";
|
||||
static const char* ClassName_SubGraph = "SubGraph";
|
||||
static const char* ClassName_Sprite = "Sprite";
|
||||
static const char* ClassName_Particle = "Particle";
|
||||
|
||||
static const char* ClassName_Panel = "Panel";
|
||||
static const char* ClassName_Button = "Button";
|
||||
static const char* ClassName_CheckBox = "CheckBox";
|
||||
static const char* ClassName_ImageView = "ImageView";
|
||||
static const char* ClassName_TextAtlas = "TextAtlas";
|
||||
static const char* ClassName_TextBMFont = "TextBMFont";
|
||||
static const char* ClassName_Text = "Text";
|
||||
static const char* ClassName_LoadingBar = "LoadingBar";
|
||||
static const char* ClassName_TextField = "TextField";
|
||||
static const char* ClassName_Slider = "Slider";
|
||||
static const char* ClassName_Layout = "Layout";
|
||||
static const char* ClassName_ScrollView = "ScrollView";
|
||||
static const char* ClassName_ListView = "ListView";
|
||||
static const char* ClassName_PageView = "PageView";
|
||||
static const char* ClassName_Widget = "Widget";
|
||||
static const char* ClassName_Label = "Label";
|
||||
|
||||
|
||||
static const char* NODE = "nodeTree";
|
||||
static const char* CHILDREN = "children";
|
||||
static const char* CLASSNAME = "classname";
|
||||
static const char* FILE_PATH = "fileName";
|
||||
static const char* PLIST_FILE = "plistFile";
|
||||
static const char* TAG = "tag";
|
||||
static const char* ACTION_TAG = "actionTag";
|
||||
|
||||
static const char* OPTIONS = "options";
|
||||
|
||||
static const char* WIDTH = "width";
|
||||
static const char* HEIGHT = "height";
|
||||
static const char* X = "x";
|
||||
static const char* Y = "y";
|
||||
static const char* SCALE_X = "scaleX";
|
||||
static const char* SCALE_Y = "scaleY";
|
||||
static const char* SKEW_X = "skewX";
|
||||
static const char* SKEW_Y = "skewY";
|
||||
static const char* ROTATION = "rotation";
|
||||
static const char* ROTATION_SKEW_X = "rotationSkewX";
|
||||
static const char* ROTATION_SKEW_Y = "rotationSkewY";
|
||||
static const char* ANCHOR_X = "anchorPointX";
|
||||
static const char* ANCHOR_Y = "anchorPointY";
|
||||
static const char* ALPHA = "opacity";
|
||||
static const char* RED = "colorR";
|
||||
static const char* GREEN = "colorG";
|
||||
static const char* BLUE = "colorB";
|
||||
static const char* ZORDER = "ZOrder";
|
||||
static const char* PARTICLE_NUM = "particleNum";
|
||||
static const char* FLIPX = "flipX";
|
||||
static const char* FLIPY = "flipY";
|
||||
static const char* VISIBLE = "visible";
|
||||
|
||||
static const char* TEXTURES = "textures";
|
||||
static const char* TEXTURES_PNG = "texturesPng";
|
||||
|
||||
|
||||
// NodeReader
|
||||
static NodeReader* _sharedNodeReader = nullptr;
|
||||
|
||||
NodeReader* NodeReader::getInstance()
|
||||
{
|
||||
if (! _sharedNodeReader)
|
||||
{
|
||||
_sharedNodeReader = new NodeReader();
|
||||
_sharedNodeReader->init();
|
||||
}
|
||||
|
||||
return _sharedNodeReader;
|
||||
}
|
||||
|
||||
void NodeReader::destroyInstance()
|
||||
{
|
||||
CC_SAFE_DELETE(_sharedNodeReader);
|
||||
}
|
||||
|
||||
NodeReader::NodeReader()
|
||||
: _recordJsonPath(true)
|
||||
, _jsonPath("")
|
||||
{
|
||||
}
|
||||
|
||||
void NodeReader::purge()
|
||||
{
|
||||
}
|
||||
|
||||
void NodeReader::init()
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
|
||||
_funcs.insert(Pair(ClassName_Node, std::bind(&NodeReader::loadSimpleNode, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_SubGraph, std::bind(&NodeReader::loadSubGraph, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Sprite, std::bind(&NodeReader::loadSprite, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Particle, std::bind(&NodeReader::loadParticle, this, _1)));
|
||||
|
||||
_funcs.insert(Pair(ClassName_Panel, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Button, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_CheckBox, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_ImageView, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_TextAtlas, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_TextBMFont,std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Text, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_LoadingBar,std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_TextField, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Slider, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Layout, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_ScrollView,std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_ListView, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_PageView, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Widget, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Label, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
|
||||
}
|
||||
|
||||
Node* NodeReader::createNode(const std::string& filename)
|
||||
{
|
||||
if(_recordJsonPath)
|
||||
{
|
||||
std::string jsonPath = filename.substr(0, filename.find_last_of('/') + 1);
|
||||
GUIReader::getInstance()->setFilePath(jsonPath);
|
||||
|
||||
_jsonPath = jsonPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIReader::getInstance()->setFilePath("");
|
||||
_jsonPath = "";
|
||||
}
|
||||
|
||||
Node* node = loadNodeWithFile(filename);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
Node* NodeReader::loadNodeWithFile(const std::string& fileName)
|
||||
{
|
||||
// Read content from file
|
||||
std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName);
|
||||
|
||||
Node* node = loadNodeWithContent(contentStr);
|
||||
|
||||
// Load animation data from file
|
||||
ActionTimelineCache::getInstance()->loadAnimationActionWithContent(fileName, contentStr);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
Node* NodeReader::loadNodeWithContent(const std::string& content)
|
||||
{
|
||||
rapidjson::Document doc;
|
||||
doc.Parse<0>(content.c_str());
|
||||
if (doc.HasParseError())
|
||||
{
|
||||
CCLOG("GetParseError %s\n", doc.GetParseError());
|
||||
}
|
||||
|
||||
// decode plist
|
||||
int length = DICTOOL->getArrayCount_json(doc, TEXTURES);
|
||||
|
||||
for(int i=0; i<length; i++)
|
||||
{
|
||||
std::string plist = DICTOOL->getStringValueFromArray_json(doc, TEXTURES, i);
|
||||
std::string png = DICTOOL->getStringValueFromArray_json(doc, TEXTURES_PNG, i);
|
||||
plist = _jsonPath + plist;
|
||||
png = _jsonPath + png;
|
||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plist, png);
|
||||
}
|
||||
|
||||
// decode node tree
|
||||
const rapidjson::Value& subJson = DICTOOL->getSubDictionary_json(doc, NODE);
|
||||
Node* root = loadNode(subJson);
|
||||
root->release();
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Node* NodeReader::loadNode(const rapidjson::Value& json)
|
||||
{
|
||||
Node* node = nullptr;
|
||||
std::string nodeType = DICTOOL->getStringValue_json(json, CLASSNAME);
|
||||
|
||||
NodeCreateFunc func = _funcs[nodeType];
|
||||
if (func != nullptr)
|
||||
{
|
||||
const rapidjson::Value& options = DICTOOL->getSubDictionary_json(json, OPTIONS);
|
||||
node = func(options);
|
||||
}
|
||||
|
||||
if(node)
|
||||
{
|
||||
int length = DICTOOL->getArrayCount_json(json, CHILDREN, 0);
|
||||
for (int i = 0; i<length; i++)
|
||||
{
|
||||
const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, CHILDREN, i);
|
||||
Node* child = loadNode(dic);
|
||||
if (child)
|
||||
{
|
||||
node->addChild(child);
|
||||
child->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Not supported NodeType: %s", nodeType.c_str());
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void NodeReader::initNode(Node* node, const rapidjson::Value& json)
|
||||
{
|
||||
float width = DICTOOL->getFloatValue_json(json, WIDTH);
|
||||
float height = DICTOOL->getFloatValue_json(json, HEIGHT);
|
||||
float x = DICTOOL->getFloatValue_json(json, X);
|
||||
float y = DICTOOL->getFloatValue_json(json, Y);
|
||||
float scalex = DICTOOL->getFloatValue_json(json, SCALE_X, 1);
|
||||
float scaley = DICTOOL->getFloatValue_json(json, SCALE_Y, 1);
|
||||
float rotation = DICTOOL->getFloatValue_json(json, ROTATION);
|
||||
float rotationSkewX = DICTOOL->getFloatValue_json(json, ROTATION_SKEW_X);
|
||||
float rotationSkewY = DICTOOL->getFloatValue_json(json, ROTATION_SKEW_Y);
|
||||
float skewx = DICTOOL->getFloatValue_json(json, SKEW_X);
|
||||
float skewy = DICTOOL->getFloatValue_json(json, SKEW_Y);
|
||||
float anchorx = DICTOOL->getFloatValue_json(json, ANCHOR_X, 0.5f);
|
||||
float anchory = DICTOOL->getFloatValue_json(json, ANCHOR_Y, 0.5f);
|
||||
GLubyte alpha = (GLubyte)DICTOOL->getIntValue_json(json, ALPHA, 255);
|
||||
GLubyte red = (GLubyte)DICTOOL->getIntValue_json(json, RED, 255);
|
||||
GLubyte green = (GLubyte)DICTOOL->getIntValue_json(json, GREEN, 255);
|
||||
GLubyte blue = (GLubyte)DICTOOL->getIntValue_json(json, BLUE, 255);
|
||||
int zorder = DICTOOL->getIntValue_json(json, ZORDER);
|
||||
int tag = DICTOOL->getIntValue_json(json, TAG);
|
||||
int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG);
|
||||
bool visible = DICTOOL->getBooleanValue_json(json, VISIBLE);
|
||||
|
||||
if(x != 0 || y != 0)
|
||||
node->setPosition(Point(x, y));
|
||||
if(scalex != 1)
|
||||
node->setScaleX(scalex);
|
||||
if(scaley != 1)
|
||||
node->setScaleY(scaley);
|
||||
if (rotation != 0)
|
||||
node->setRotation(rotation);
|
||||
if(rotationSkewX != 0)
|
||||
node->setRotationX(rotationSkewX);
|
||||
if(rotationSkewY != 0)
|
||||
node->setRotationY(rotationSkewY);
|
||||
if(skewx != 0)
|
||||
node->setSkewX(skewx);
|
||||
if(skewy != 0)
|
||||
node->setSkewY(skewy);
|
||||
if(anchorx != 0.5f || anchory != 0.5f)
|
||||
node->setAnchorPoint(Point(anchorx, anchory));
|
||||
if(width != 0 || height != 0)
|
||||
node->setContentSize(Size(width, height));
|
||||
if(zorder != 0)
|
||||
node->setZOrder(zorder);
|
||||
if(visible != true)
|
||||
node->setVisible(visible);
|
||||
|
||||
if(alpha != 255)
|
||||
{
|
||||
node->setOpacity(alpha);
|
||||
node->setCascadeOpacityEnabled(true);
|
||||
}
|
||||
if(red != 255 || green != 255 || blue != 255)
|
||||
{
|
||||
node->setColor(Color3B(red, green, blue));
|
||||
node->setCascadeColorEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
node->setTag(tag);
|
||||
node->setUserObject(ActionTimelineData::create(actionTag));
|
||||
}
|
||||
|
||||
Node* NodeReader::loadSimpleNode(const rapidjson::Value& json)
|
||||
{
|
||||
Node* node = Node::create();
|
||||
node->retain();
|
||||
initNode(node, json);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
Node* NodeReader::loadSubGraph(const rapidjson::Value& json)
|
||||
{
|
||||
const char* filePath = DICTOOL->getStringValue_json(json, FILE_PATH);
|
||||
|
||||
Node* node = nullptr;
|
||||
if (filePath && strcmp("", filePath) != 0)
|
||||
{
|
||||
node = createNode(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = Node::create();
|
||||
}
|
||||
|
||||
node->retain();
|
||||
|
||||
initNode(node, json);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
Node* NodeReader::loadSprite(const rapidjson::Value& json)
|
||||
{
|
||||
const char* filePath = DICTOOL->getStringValue_json(json, FILE_PATH);
|
||||
Sprite *sprite = nullptr;
|
||||
|
||||
if(filePath != nullptr)
|
||||
{
|
||||
std::string path = filePath;
|
||||
|
||||
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path);
|
||||
if(!spriteFrame)
|
||||
{
|
||||
path = _jsonPath + path;
|
||||
sprite = Sprite::create(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite = Sprite::createWithSpriteFrame(spriteFrame);
|
||||
}
|
||||
|
||||
if(!sprite)
|
||||
{
|
||||
sprite = CCSprite::create();
|
||||
CCLOG("filePath is empty. Create a sprite with no texture");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite = Sprite::create();
|
||||
}
|
||||
|
||||
sprite->retain();
|
||||
|
||||
initNode(sprite, json);
|
||||
|
||||
bool flipX = DICTOOL->getBooleanValue_json(json, FLIPX);
|
||||
bool flipY = DICTOOL->getBooleanValue_json(json, FLIPY);
|
||||
|
||||
if(flipX != false)
|
||||
sprite->setFlippedX(flipX);
|
||||
if(flipY != false)
|
||||
sprite->setFlippedY(flipY);
|
||||
|
||||
return sprite;
|
||||
}
|
||||
|
||||
Node* NodeReader::loadParticle(const rapidjson::Value& json)
|
||||
{
|
||||
const char* filePath = DICTOOL->getStringValue_json(json, PLIST_FILE);
|
||||
int num = DICTOOL->getIntValue_json(json, PARTICLE_NUM);
|
||||
|
||||
ParticleSystemQuad* particle = ParticleSystemQuad::create(filePath);
|
||||
particle->setTotalParticles(num);
|
||||
particle->retain();
|
||||
|
||||
initNode(particle, json);
|
||||
|
||||
return particle;
|
||||
}
|
||||
|
||||
Node* NodeReader::loadWidget(const rapidjson::Value& json)
|
||||
{
|
||||
const char* str = DICTOOL->getStringValue_json(json, CLASSNAME);
|
||||
if(str == nullptr)
|
||||
return nullptr;
|
||||
|
||||
std::string classname = str;
|
||||
|
||||
if (classname == "Panel")
|
||||
{
|
||||
classname = "Layout";
|
||||
}
|
||||
else if (classname == "TextArea")
|
||||
{
|
||||
classname = "Text";
|
||||
}
|
||||
else if (classname == "TextButton")
|
||||
{
|
||||
classname = "Button";
|
||||
}
|
||||
else if (classname == "Label")
|
||||
{
|
||||
classname = "Text";
|
||||
}
|
||||
else if (classname == "LabelAtlas")
|
||||
{
|
||||
classname = "TextAtlas";
|
||||
}
|
||||
else if (classname == "LabelBMFont")
|
||||
{
|
||||
classname = "TextBMFont";
|
||||
}
|
||||
|
||||
std::string readerName = classname;
|
||||
readerName.append("Reader");
|
||||
|
||||
Widget* widget = dynamic_cast<Widget*>(ObjectFactory::getInstance()->createObject(classname));
|
||||
widget->retain();
|
||||
|
||||
WidgetReaderProtocol* reader = dynamic_cast<WidgetReaderProtocol*>(ObjectFactory::getInstance()->createObject(readerName));
|
||||
|
||||
WidgetPropertiesReader0300* guiReader = new WidgetPropertiesReader0300();
|
||||
guiReader->setPropsForAllWidgetFromJsonDictionary(reader, widget, json);
|
||||
CC_SAFE_DELETE(guiReader);
|
||||
|
||||
int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG);
|
||||
widget->setUserObject(ActionTimelineData::create(actionTag));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CC_NODE_CACHE_H__
|
||||
#define __CC_NODE_CACHE_H__
|
||||
|
||||
#include "cocostudio/DictionaryHelper.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
||||
namespace timeline{
|
||||
|
||||
class NodeReader
|
||||
{
|
||||
public:
|
||||
static NodeReader* getInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
NodeReader();
|
||||
void purge();
|
||||
|
||||
void init();
|
||||
|
||||
cocos2d::Node* createNode(const std::string& filename);
|
||||
|
||||
cocos2d::Node* loadNodeWithFile(const std::string& fileName);
|
||||
cocos2d::Node* loadNodeWithContent(const std::string& content);
|
||||
|
||||
void setRecordJsonPath(bool record) { _recordJsonPath = record; }
|
||||
bool isRecordJsonPath() const { return _recordJsonPath; }
|
||||
|
||||
void setJsonPath(std::string jsonPath) { _jsonPath = jsonPath; }
|
||||
std::string getJsonPath() const { return _jsonPath; }
|
||||
|
||||
protected:
|
||||
|
||||
cocos2d::Node* loadNode(const rapidjson::Value& json);
|
||||
|
||||
void locateNodeWithMulresPosition(cocos2d::Node* node, const rapidjson::Value& json);
|
||||
|
||||
void initNode(cocos2d::Node* node, const rapidjson::Value& json);
|
||||
|
||||
// load nodes
|
||||
cocos2d::Node* loadSimpleNode(const rapidjson::Value& json);
|
||||
cocos2d::Node* loadSubGraph (const rapidjson::Value& json);
|
||||
cocos2d::Node* loadSprite (const rapidjson::Value& json);
|
||||
cocos2d::Node* loadParticle (const rapidjson::Value& json);
|
||||
|
||||
// load gui
|
||||
cocos2d::Node* loadWidget(const rapidjson::Value& json);
|
||||
|
||||
typedef std::function<cocos2d::Node*(const rapidjson::Value& json)> NodeCreateFunc;
|
||||
typedef std::pair<std::string, NodeCreateFunc> Pair;
|
||||
|
||||
std::unordered_map<std::string, NodeCreateFunc> _funcs;
|
||||
|
||||
bool _recordJsonPath;
|
||||
|
||||
std::string _jsonPath;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /*__CC_NODE_CACHE_H__*/
|
|
@ -0,0 +1,249 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCTimeLine.h"
|
||||
#include "CCActionTimeline.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
Timeline* Timeline::create()
|
||||
{
|
||||
Timeline* object = new Timeline();
|
||||
if (object)
|
||||
{
|
||||
object->autorelease();
|
||||
return object;
|
||||
}
|
||||
CC_SAFE_DELETE(object);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Timeline::Timeline()
|
||||
: _currentKeyFrame(nullptr)
|
||||
, _currentKeyFrameIndex(0)
|
||||
, _fromIndex(0)
|
||||
, _toIndex(0)
|
||||
, _betweenDuration(0)
|
||||
, _actionTag(0)
|
||||
, _ActionTimeline(nullptr)
|
||||
, _node(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Timeline::~Timeline()
|
||||
{
|
||||
}
|
||||
|
||||
void Timeline::gotoFrame(int frameIndex)
|
||||
{
|
||||
if(_frames.size() == 0)
|
||||
return;
|
||||
|
||||
binarySearchKeyFrame(frameIndex);
|
||||
apply(frameIndex);
|
||||
}
|
||||
|
||||
void Timeline::stepToFrame(int frameIndex)
|
||||
{
|
||||
if(_frames.size() == 0)
|
||||
return;
|
||||
|
||||
updateCurrentKeyFrame(frameIndex);
|
||||
apply(frameIndex);
|
||||
}
|
||||
|
||||
Timeline* Timeline::clone()
|
||||
{
|
||||
Timeline* timeline = Timeline::create();
|
||||
timeline->_actionTag = _actionTag;
|
||||
|
||||
for (auto frame : _frames)
|
||||
{
|
||||
Frame* newFrame = frame->clone();
|
||||
timeline->addFrame(newFrame);
|
||||
}
|
||||
|
||||
return timeline;
|
||||
}
|
||||
|
||||
void Timeline::addFrame(Frame* frame)
|
||||
{
|
||||
_frames.pushBack(frame);
|
||||
frame->setTimeline(this);
|
||||
}
|
||||
|
||||
void Timeline::insertFrame(Frame* frame, int index)
|
||||
{
|
||||
_frames.insert(index, frame);
|
||||
frame->setTimeline(this);
|
||||
}
|
||||
|
||||
void Timeline::removeFrame(Frame* frame)
|
||||
{
|
||||
_frames.eraseObject(frame);
|
||||
frame->setTimeline(NULL);
|
||||
}
|
||||
|
||||
void Timeline::setNode(Node* node)
|
||||
{
|
||||
for (auto frame : _frames)
|
||||
{
|
||||
frame->setNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
Node* Timeline::getNode() const
|
||||
{
|
||||
return _node;
|
||||
}
|
||||
|
||||
void Timeline::apply(int frameIndex)
|
||||
{
|
||||
if (_currentKeyFrame)
|
||||
{
|
||||
float currentPercent = _betweenDuration == 0 ? 0 : (frameIndex - _currentKeyFrameIndex) / (float)_betweenDuration;
|
||||
_currentKeyFrame->apply(currentPercent);
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::binarySearchKeyFrame(int frameIndex)
|
||||
{
|
||||
Frame *from = NULL;
|
||||
Frame *to = NULL;
|
||||
|
||||
long length = _frames.size();
|
||||
bool needEnterFrame = false;
|
||||
|
||||
do
|
||||
{
|
||||
if (frameIndex < _frames.at(0)->getFrameIndex())
|
||||
{
|
||||
if(_currentKeyFrameIndex >= _frames.at(0)->getFrameIndex())
|
||||
needEnterFrame = true;
|
||||
|
||||
from = to = _frames.at(0);
|
||||
_currentKeyFrameIndex = 0;
|
||||
_betweenDuration = _frames.at(0)->getFrameIndex();
|
||||
break;
|
||||
}
|
||||
else if(frameIndex >= _frames.at(length - 1)->getFrameIndex())
|
||||
{
|
||||
from = to = _frames.at(length - 1);
|
||||
_currentKeyFrameIndex = _frames.at(length - 1)->getFrameIndex();
|
||||
_betweenDuration = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
int target = -1;
|
||||
int low=0,high=length-1,mid;
|
||||
while(low<=high){
|
||||
mid=(low+high)/2;
|
||||
if(frameIndex >= _frames.at(mid)->getFrameIndex() && frameIndex < _frames.at(mid+1)->getFrameIndex())
|
||||
{
|
||||
target = mid;
|
||||
break;
|
||||
}
|
||||
if(_frames.at(mid)->getFrameIndex()>frameIndex)
|
||||
high=mid-1;
|
||||
else
|
||||
low=mid+1;
|
||||
}
|
||||
|
||||
from = _frames.at(target);
|
||||
to = _frames.at(target+1);
|
||||
|
||||
if(target == 0 && _currentKeyFrameIndex<from->getFrameIndex())
|
||||
needEnterFrame = true;
|
||||
|
||||
_currentKeyFrameIndex = from->getFrameIndex();
|
||||
_betweenDuration = to->getFrameIndex() - from->getFrameIndex();
|
||||
} while (0);
|
||||
|
||||
if(needEnterFrame || _currentKeyFrame != from)
|
||||
{
|
||||
_currentKeyFrame = from;
|
||||
_currentKeyFrame->onEnter(to);
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::updateCurrentKeyFrame(int frameIndex)
|
||||
{
|
||||
//! If play to current frame's front or back, then find current frame again
|
||||
if (frameIndex < _currentKeyFrameIndex || frameIndex >= _currentKeyFrameIndex + _betweenDuration)
|
||||
{
|
||||
Frame *from = nullptr;
|
||||
Frame *to = nullptr;
|
||||
|
||||
do
|
||||
{
|
||||
long length = _frames.size();
|
||||
|
||||
if (frameIndex < _frames.at(0)->getFrameIndex())
|
||||
{
|
||||
from = to = _frames.at(0);
|
||||
_currentKeyFrameIndex = 0;
|
||||
_betweenDuration = _frames.at(0)->getFrameIndex();
|
||||
break;
|
||||
}
|
||||
else if(frameIndex >= _frames.at(length - 1)->getFrameIndex())
|
||||
{
|
||||
from = to = _frames.at(length - 1);
|
||||
_currentKeyFrameIndex = _frames.at(length - 1)->getFrameIndex();
|
||||
_betweenDuration = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
_fromIndex = _toIndex;
|
||||
from = _frames.at(_fromIndex);
|
||||
_currentKeyFrameIndex = from->getFrameIndex();
|
||||
|
||||
_toIndex = _fromIndex + 1;
|
||||
if (_toIndex >= length)
|
||||
{
|
||||
_toIndex = 0;
|
||||
}
|
||||
|
||||
to = _frames.at(_toIndex);
|
||||
|
||||
if (frameIndex == from->getFrameIndex())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (frameIndex < from->getFrameIndex() || frameIndex >= to->getFrameIndex());
|
||||
|
||||
_betweenDuration = to->getFrameIndex() - from->getFrameIndex();
|
||||
|
||||
} while (0);
|
||||
|
||||
_currentKeyFrame = from;
|
||||
_currentKeyFrame->onEnter(to);
|
||||
}
|
||||
}
|
||||
|
||||
NS_TIMELINE_END
|
|
@ -0,0 +1,85 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCTIMELINE_H__
|
||||
#define __CCTIMELINE_H__
|
||||
|
||||
#include "CCFrame.h"
|
||||
#include "CCTimelineMacro.h"
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
class ActionTimeline;
|
||||
|
||||
class Timeline : public cocos2d::Ref
|
||||
{
|
||||
public:
|
||||
static Timeline* create();
|
||||
|
||||
Timeline();
|
||||
virtual ~Timeline();
|
||||
|
||||
virtual void gotoFrame(int frameIndex);
|
||||
virtual void stepToFrame(int frameIndex);
|
||||
|
||||
virtual const cocos2d::Vector<Frame*>& getFrames() const { return _frames; }
|
||||
|
||||
virtual void addFrame(Frame* frame);
|
||||
virtual void insertFrame(Frame* frame, int index);
|
||||
virtual void removeFrame(Frame* frame);
|
||||
|
||||
virtual void setActionTag(int tag) { _actionTag = tag; }
|
||||
virtual int getActionTag() const { return _actionTag; }
|
||||
|
||||
virtual void setNode(cocos2d::Node* node);
|
||||
virtual cocos2d::Node* getNode() const;
|
||||
|
||||
virtual void setActionTimeline(ActionTimeline* action) { _ActionTimeline = action; }
|
||||
virtual ActionTimeline* getActionTimeline() const { return _ActionTimeline; }
|
||||
|
||||
virtual Timeline* clone();
|
||||
|
||||
protected:
|
||||
virtual void apply(int frameIndex);
|
||||
|
||||
virtual void binarySearchKeyFrame (int frameIndex);
|
||||
virtual void updateCurrentKeyFrame(int frameIndex);
|
||||
|
||||
cocos2d::Vector<Frame*> _frames;
|
||||
Frame* _currentKeyFrame;
|
||||
int _currentKeyFrameIndex;
|
||||
|
||||
int _fromIndex;
|
||||
int _toIndex;
|
||||
int _betweenDuration;
|
||||
int _actionTag;
|
||||
|
||||
ActionTimeline* _ActionTimeline;
|
||||
cocos2d::Node* _node;
|
||||
};
|
||||
|
||||
NS_TIMELINE_END
|
||||
|
||||
|
||||
#endif /*__CCTIMELINE_H__*/
|
|
@ -0,0 +1,38 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2013-2014 Chukong Technologies
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#ifndef __CC_TIMELINE_MACROS_H__
|
||||
#define __CC_TIMELINE_MACROS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define NS_TIMELINE_BEGIN namespace cocostudio { namespace timeline{
|
||||
#define NS_TIMELINE_END }}
|
||||
#define USING_NS_TIMELINE using namespace cocostudio::timeline;
|
||||
#else
|
||||
#define NS_TIMELINE_BEGIN
|
||||
#define NS_TIMELINE_END
|
||||
#define USING_NS_TIMELINE
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -39,6 +39,7 @@ CCSSceneReader.cpp \
|
|||
TriggerBase.cpp \
|
||||
TriggerMng.cpp \
|
||||
TriggerObj.cpp \
|
||||
CocoLoader.cpp \
|
||||
WidgetReader/WidgetReader.cpp \
|
||||
WidgetReader/ButtonReader/ButtonReader.cpp \
|
||||
WidgetReader/CheckBoxReader/CheckBoxReader.cpp \
|
||||
|
@ -53,6 +54,11 @@ WidgetReader/TextAtlasReader/TextAtlasReader.cpp \
|
|||
WidgetReader/TextBMFontReader/TextBMFontReader.cpp \
|
||||
WidgetReader/TextFieldReader/TextFieldReader.cpp \
|
||||
WidgetReader/TextReader/TextReader.cpp \
|
||||
ActionTimeline/CCNodeReader.cpp \
|
||||
ActionTimeline/CCActionTimelineCache.cpp \
|
||||
ActionTimeline/CCFrame.cpp \
|
||||
ActionTimeline/CCTimeline.cpp \
|
||||
ActionTimeline/CCActionTimeline.cpp \
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \
|
||||
$(LOCAL_PATH)/../../../external
|
||||
|
|
|
@ -373,4 +373,4 @@ ActionInterval* ActionTintFrame::getAction(float fDuration)
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue