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

This commit is contained in:
samuele3hu 2014-06-19 14:37:00 +08:00
commit 46ce1c917d
142 changed files with 26925 additions and 5779 deletions

View File

@ -888,6 +888,10 @@ 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
Retired Core Developers:
WenSheng Yang

View File

@ -1,4 +1,10 @@
cocos2d-x-3.2 ???
cocos2d-x-3.2 ???
[NEW] Node: added getName(), setName(), getChildByName(), enumerateChildren()
[NEW] Label: support setting line height and additional kerning of label that not using system font
[FIX] UIButton: doesn't support TTF font
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 +12,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
@ -26,6 +34,7 @@ cocos2d-x-3.2 ???
[FIX] Node: state of _transformUpdated, _transformDirty and _inverseDirty are wrong in setParent()
[FIX] Node: _orderOfArrival is set to 0 after visit
[FIX] Other: link error with Xcode 6 when building with 32-bit architecture
[FIX] RenderTexture: saveToFile() lost alpha channel
[FIX] Repeat: will run one more over in rare situations
[FIX] Scale9Sprite: support culling
[FIX] Schedule: schedulePerFrame() can not be called twice
@ -36,8 +45,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

View File

@ -1741,10 +1741,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 +1775,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 */; };
@ -2792,8 +2812,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 +2828,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 */
@ -4817,14 +4848,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 +4893,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 */,
@ -4892,6 +4934,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 */,
@ -5183,6 +5226,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;
};
@ -5339,7 +5387,7 @@
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 */,
@ -5375,6 +5423,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 */,
@ -5678,6 +5727,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;
};
@ -6289,7 +6343,7 @@
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 */,
@ -6329,6 +6383,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;
};
@ -6535,7 +6593,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 */,
@ -6770,6 +6828,10 @@
1ABA68AF1888D700007D1BB4 /* CCFontCharMap.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 +7137,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 +7173,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 +7199,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 +7250,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 +7278,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
CC_TARGET_OS_MAC,
@ -7268,6 +7335,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 +7414,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 +7445,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 +7478,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 +7514,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_STANDARD)";
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
CC_TARGET_OS_IPHONE,

63
build/winrt/angle.bat Normal file
View File

@ -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

View File

@ -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);

View File

@ -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)

View File

@ -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;
@ -1163,9 +1175,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 +1288,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;

View File

@ -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;

View File

@ -384,7 +384,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
continue;
}
nextFontPositionX += charAdvance + kernings[i];
nextFontPositionX += charAdvance + kernings[i] + theLabel->_additionalKerning;
if (longestLine < nextFontPositionX)
{

View File

@ -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();
@ -624,6 +628,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 +693,7 @@ GLProgram * Node::getGLProgram() const
return _glProgramState ? _glProgramState->getGLProgram() : nullptr;
}
Scene* Node::getScene()
Scene* Node::getScene() const
{
if(!_parent)
return nullptr;
@ -750,6 +766,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
@ -1050,46 +1219,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 +1241,7 @@ void Node::onEnter()
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeLua)
{
sendNodeEventToLua(this, kNodeOnEnter);
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnEnter);
}
#endif
}
@ -1116,7 +1251,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 +1263,7 @@ void Node::onEnterTransitionDidFinish()
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeLua)
{
sendNodeEventToLua(this, kNodeOnEnterTransitionDidFinish);
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnEnterTransitionDidFinish);
}
#endif
}
@ -1138,7 +1273,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 +1284,7 @@ void Node::onExitTransitionDidStart()
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeLua)
{
sendNodeEventToLua(this, kNodeOnExitTransitionDidStart);
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnExitTransitionDidStart);
}
#endif
}
@ -1159,7 +1294,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 +1309,7 @@ void Node::onExit()
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeLua)
{
sendNodeEventToLua(this, kNodeOnExit);
ScriptEngineManager::sendNodeEventToLua(this, kNodeOnExit);
}
#endif
}

View File

@ -667,6 +667,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 +822,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 +1015,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 +1448,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 +1501,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
@ -1529,7 +1588,7 @@ public:
virtual void setOpacityModifyRGB(bool bValue) override { return Node::setOpacityModifyRGB(bValue); }
virtual bool isOpacityModifyRGB() const override { return Node::isOpacityModifyRGB(); }
protected:
CC_CONSTRUCTOR_ACCESS:
__NodeRGBA();
virtual ~__NodeRGBA() {}

View File

@ -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!

View File

@ -409,29 +409,47 @@ void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, uint3
_orderOfArrival = 0;
}
bool RenderTexture::saveToFile(const std::string& filename)
bool RenderTexture::saveToFile(const std::string& filename, bool isRGBA)
{
return saveToFile(filename,Image::Format::JPG);
std::string basename(filename);
std::transform(basename.begin(), basename.end(), basename.begin(), ::tolower);
if (basename.find(".png") != std::string::npos)
{
return saveToFile(filename, Image::Format::PNG, isRGBA);
}
else if (basename.find(".jpg") != std::string::npos)
{
if (isRGBA) CCLOG("RGBA is not supported for JPG format.");
return saveToFile(filename, Image::Format::JPG, false);
}
else
{
CCLOG("Only PNG and JPG format are supported now!");
}
return saveToFile(filename, Image::Format::JPG, false);
}
bool RenderTexture::saveToFile(const std::string& fileName, Image::Format format)
bool RenderTexture::saveToFile(const std::string& fileName, Image::Format format, bool isRGBA)
{
CCASSERT(format == Image::Format::JPG || format == Image::Format::PNG,
"the image can only be saved as JPG or PNG format");
if (isRGBA && format == Image::Format::JPG) CCLOG("RGBA is not supported for JPG format");
std::string fullpath = FileUtils::getInstance()->getWritablePath() + fileName;
_saveToFileCommand.init(_globalZOrder);
_saveToFileCommand.func = CC_CALLBACK_0(RenderTexture::onSaveToFile,this,fullpath);
_saveToFileCommand.func = CC_CALLBACK_0(RenderTexture::onSaveToFile, this, fullpath, isRGBA);
Director::getInstance()->getRenderer()->addCommand(&_saveToFileCommand);
return true;
}
void RenderTexture::onSaveToFile(const std::string& filename)
void RenderTexture::onSaveToFile(const std::string& filename, bool isRGBA)
{
Image *image = newImage(true);
if (image)
{
image->saveToFile(filename.c_str(), true);
image->saveToFile(filename.c_str(), !isRGBA);
}
CC_SAFE_DELETE(image);

View File

@ -103,12 +103,12 @@ public:
/** saves the texture into a file using JPEG format. The file will be saved in the Documents folder.
Returns true if the operation is successful.
*/
bool saveToFile(const std::string& filename);
bool saveToFile(const std::string& filename, bool isRGBA = true);
/** saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder.
Returns true if the operation is successful.
*/
bool saveToFile(const std::string& filename, Image::Format format);
bool saveToFile(const std::string& filename, Image::Format format, bool isRGBA = true);
/** Listen "come to background" message, and save render texture.
It only has effect on Android.
@ -222,7 +222,7 @@ protected:
void onClear();
void onClearDepth();
void onSaveToFile(const std::string& fileName);
void onSaveToFile(const std::string& fileName, bool isRGBA = true);
Mat4 _oldTransMatrix, _oldProjMatrix;
Mat4 _transformMatrix, _projectionMatrix;

View File

@ -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

View File

@ -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;

View File

@ -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>
@ -175,10 +175,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 +351,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 +547,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" />

View File

@ -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>

View File

@ -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" />

View File

@ -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">

146
cocos/3d/CCAnimate3D.cpp Normal file
View File

@ -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

82
cocos/3d/CCAnimate3D.h Normal file
View File

@ -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__

238
cocos/3d/CCAnimation3D.cpp Normal file
View File

@ -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

105
cocos/3d/CCAnimation3D.h Normal file
View File

@ -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__

View File

@ -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

View File

@ -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

384
cocos/3d/CCBundle3D.cpp Normal file
View File

@ -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

105
cocos/3d/CCBundle3D.h Normal file
View File

@ -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__

187
cocos/3d/CCBundle3DData.h Normal file
View File

@ -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__

View File

@ -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

View File

@ -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_

472
cocos/3d/CCMeshSkin.cpp Normal file
View File

@ -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

226
cocos/3d/CCMeshSkin.h Normal file
View File

@ -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__

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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__

View File

@ -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
)

View File

@ -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 \

View File

@ -45,6 +45,7 @@ public:
KEY_SYSREQ,
KEY_BREAK,
KEY_ESCAPE,
KEY_BACK = KEY_ESCAPE,
KEY_BACKSPACE,
KEY_TAB,
KEY_BACK_TAB,

View File

@ -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

View File

@ -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

View File

@ -31,7 +31,7 @@ NS_CC_BEGIN
const char* cocos2dVersion()
{
return "cocos2d-x 3.1";
return "cocos2d-x 3.2alpha0";
}
NS_CC_END

View File

@ -434,6 +434,14 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t
void Armature::onEnter()
{
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter))
return;
}
#endif
Node::onEnter();
scheduleUpdate();
}

View File

@ -200,9 +200,6 @@ public:
virtual void setArmatureData(ArmatureData *armatureData) { _armatureData = armatureData; }
virtual ArmatureData *getArmatureData() const { return _armatureData; }
virtual void setName(const std::string &name) { _name = name; }
virtual const std::string &getName() const { return _name; }
virtual void setParentBone(Bone *parentBone);
virtual Bone *getParentBone() const;
@ -257,7 +254,6 @@ protected:
BatchNode *_batchNode;
std::string _name;
Bone *_parentBone;
float _version;

View File

@ -207,9 +207,6 @@ public:
virtual FrameData *getTweenData() const { return _tweenData; }
virtual void setName(const std::string &name) { _name = name; }
virtual const std::string getName() const { return _name; }
virtual BaseData *getWorldInfo() const { return _worldInfo; }
protected:
void applyParentTransform(Bone *parent);
@ -242,8 +239,6 @@ protected:
//! Used for making tween effect in every frame
FrameData *_tweenData;
std::string _name;
Bone *_parentBone; //! A weak reference to its parent
bool _boneTransformDirty; //! Whether or not transform dirty

View File

@ -51,7 +51,9 @@ namespace cocostudio
bool fn = DICTOOL->checkObjectExist_json(options, "fontName");
if (fn)
{
label->setFontName(DICTOOL->getStringValue_json(options, "fontName"));
std::string fontName = DICTOOL->getStringValue_json(options, "fontName");
std::string fontFilePath = jsonPath.append(fontName);
label->setFontName(fontFilePath);
}
bool aw = DICTOOL->checkObjectExist_json(options, "areaWidth");
bool ah = DICTOOL->checkObjectExist_json(options, "areaHeight");

View File

@ -134,8 +134,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">
@ -144,8 +144,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>
@ -206,4 +206,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -276,7 +276,15 @@ Rect Skeleton::getBoundingBox () const {
}
void Skeleton::onEnter() {
Node::onEnter();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
if (ScriptEngineManager::sendNodeEventToJSExtended(this, kNodeOnEnter))
return;
}
#endif
Node::onEnter();
scheduleUpdate();
}

View File

@ -42,7 +42,9 @@ bool cocos2d::Image::saveToFile(const std::string& filename, bool isToRGB)
bool saveToPNG = false;
bool needToCopyPixels = false;
if (std::string::npos != filename.find(".png"))
std::string basename(filename);
std::transform(basename.begin(), basename.end(), basename.begin(), ::tolower);
if (std::string::npos != basename.find(".png"))
{
saveToPNG = true;
}

View File

@ -68,12 +68,12 @@
</Link>
<PostBuildEvent>
<Command>echo "Copying WP8-XAML CPP template files"
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq</Command>
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -89,12 +89,12 @@ xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-x
</Link>
<PostBuildEvent>
<Command>echo "Copying WP8-XAML CPP template files"
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq</Command>
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
@ -110,12 +110,12 @@ xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-x
</Link>
<PostBuildEvent>
<Command>echo "Copying WP8-XAML CPP template files"
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq</Command>
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
@ -131,12 +131,12 @@ xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-x
</Link>
<PostBuildEvent>
<Command>echo "Copying WP8-XAML CPP template files"
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\HelloCpp\*" /eiycq</Command>
xcopy "xaml\App.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\App.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\MainPage.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\MainPage.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\EditBox.xaml" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq
xcopy "xaml\EditBox.xaml.cs" "..\..\..\templates\cpp-template-default\proj.wp8-xaml\App\*" /eiycq</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -64,29 +64,29 @@ void Cocos2dRenderer::CreateGLResources()
else
{
cocos2d::GL::invalidateStateCache();
cocos2d::ShaderCache::getInstance()->reloadDefaultShaders();
cocos2d::ShaderCache::getInstance()->reloadDefaultGLPrograms();
cocos2d::DrawPrimitives::init();
cocos2d::VolatileTextureMgr::reloadAllTextures();
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
director->setGLDefaultValues();
director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
cocos2d::Application::getInstance()->applicationWillEnterForeground();
}
director->setGLDefaultValues();
}
m_loadingComplete = true;
}
void Cocos2dRenderer::Connect()
{
}
// purge Cocos2d-x gl GL resourses since the DirectX/Angle Context has been lost
void Cocos2dRenderer::Disconnect()
{
Application::getInstance()->applicationDidEnterBackground();
EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND);
Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent);
Director::getInstance()->purgeCachedData();
cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND);
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent);
CloseAngle();
m_loadingComplete = false;
}

View File

@ -56,14 +56,12 @@ IDrawingSurfaceBackgroundContentProvider^ Direct3DInterop::CreateContentProvider
// Interface With Direct3DContentProvider
HRESULT Direct3DInterop::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device)
{
//m_renderer->SetDevice(device);
return S_OK;
}
void Direct3DInterop::Disconnect()
{
std::lock_guard<std::mutex> guard(mRenderingMutex);
m_renderer->Disconnect();
m_renderer->Disconnect();
}
// IDrawingSurfaceManipulationHandler
@ -143,8 +141,6 @@ HRESULT Direct3DInterop::PrepareResources(_In_ const LARGE_INTEGER* presentTarge
HRESULT Direct3DInterop::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)
{
std::lock_guard<std::mutex> guard(mRenderingMutex);
m_renderer->UpdateDevice(device, context, renderTargetView);
#if 0
if(mCurrentOrientation != WindowOrientation)

View File

@ -87,8 +87,6 @@ private:
Windows::Graphics::Display::DisplayOrientations mCurrentOrientation;
std::mutex mRenderingMutex;
Cocos2dEventDelegate^ m_delegate;
Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
Cocos2dEditBoxDelegate^ m_editBoxDelegate;

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
****************************************************************************/
#include "DirectXBase.h"
#include "DirectXHelper.h"
using namespace DirectX;
using namespace Microsoft::WRL;
@ -167,12 +168,12 @@ void DirectXBase::Render()
void DirectXBase::CloseAngle()
{
eglMakeCurrent(NULL, NULL, NULL, NULL);
if(m_eglDisplay && m_eglSurface)
if(m_eglPhoneWindow != nullptr)
{
eglDestroySurface(m_eglDisplay, m_eglSurface);
m_eglSurface = nullptr;
}
m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
}
if(m_eglDisplay && m_eglContext)
{
@ -180,18 +181,17 @@ void DirectXBase::CloseAngle()
m_eglContext = nullptr;
}
if(m_eglDisplay)
if(m_eglDisplay && m_eglSurface)
{
eglDestroySurface(m_eglDisplay, m_eglSurface);
m_eglSurface = nullptr;
}
if(m_eglDisplay)
{
eglTerminate(m_eglDisplay);
m_eglDisplay = nullptr;
}
if(m_eglPhoneWindow != nullptr)
{
m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
}
eglMakeCurrent(NULL, NULL, NULL, NULL);
}
if(m_device)
{
@ -199,11 +199,8 @@ void DirectXBase::CloseAngle()
m_device = nullptr;
}
#if 0
m_eglPhoneWindow = nullptr;
m_eglWindow = nullptr;
#endif // 0
m_bAngleInitialized = false;
}
@ -262,10 +259,12 @@ bool DirectXBase::InitializeAngle(ID3D11Device1* d3dDevice, ID3D11DeviceContext1
m_eglPhoneWindow->Update(d3dDevice, d3dContext, d3dRenderTargetView);
ComPtr<IUnknown> u;
HRESULT r = m_eglPhoneWindow.As(&u);
if(m_eglWindow == nullptr)
{ DX::ThrowIfFailed(
CreateWinrtEglWindow(m_eglPhoneWindow.Get(), featureLevel, m_eglWindow.GetAddressOf())
CreateWinrtEglWindow(u.Get(), featureLevel, m_eglWindow.GetAddressOf())
);
}

View File

@ -27,8 +27,12 @@ THE SOFTWARE.
#include <d3d11_1.h>
#include <DirectXMath.h>
#include "DirectXHelper.h"
#include "CCGL.h"
#include "EGL/egl.h"
#include "EGL/eglext.h"
#include "EGL/eglplatform.h"
#include "GLES2/gl2.h"
#include "GLES2/gl2ext.h"
#include "winrtangle.h"
// Helper class that initializes DirectX APIs for 3D rendering.
ref class DirectXBase abstract

View File

@ -1,17 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Diagnostics;
using System.Resources;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Markup;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.IO.IsolatedStorage;
using PhoneDirect3DXamlAppInterop.Resources;
namespace PhoneDirect3DXamlAppInterop
{
@ -21,7 +17,28 @@ namespace PhoneDirect3DXamlAppInterop
/// Provides easy access to the root frame of the Phone Application.
/// </summary>
/// <returns>The root frame of the Phone Application.</returns>
public PhoneApplicationFrame RootFrame { get; private set; }
public static PhoneApplicationFrame RootFrame { get; private set; }
enum SessionType
{
None,
Home,
DeepLink
}
// Set to Home when the app is launched from Primary tile.
// Set to DeepLink when the app is launched from Deep Link.
private SessionType sessionType = SessionType.None;
// Set to true when the page navigation is being reset
bool wasRelaunched = false;
// set to true when 5 min passed since the app was relaunched
bool mustClearPagestack = false;
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
/// <summary>
/// Constructor for the Application object.
@ -31,14 +48,14 @@ namespace PhoneDirect3DXamlAppInterop
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
// Standard Silverlight initialization
// Standard XAML initialization
InitializeComponent();
// Phone-specific initialization
InitializePhoneApplication();
// Show graphics profiling information while debugging.
if (System.Diagnostics.Debugger.IsAttached)
// Show graphics profiling information while debugging.
if (Debugger.IsAttached)
{
// Display the current frame rate counters.
Application.Current.Host.Settings.EnableFrameRateCounter = false;
@ -50,8 +67,8 @@ namespace PhoneDirect3DXamlAppInterop
// which shows areas of a page that are handed off to GPU with a colored overlay.
//Application.Current.Host.Settings.EnableCacheVisualization = true;
// Disable the application idle detection by setting the UserIdleDetectionMode property of the
// application's PhoneApplicationService object to Disabled.
// Prevent the screen from turning off while under the debugger by disabling
// the application's idle detection.
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
// and consume battery power when the user is not using the phone.
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
@ -63,43 +80,63 @@ namespace PhoneDirect3DXamlAppInterop
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
// When a new instance of the app is launched, clear all deactivation settings
RemoveCurrentDeactivationSettings();
}
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
// If some interval has passed since the app was deactivated (30 seconds in this example),
// then remember to clear the back stack of pages
mustClearPagestack = CheckDeactivationTimeStamp();
// If IsApplicationInstancePreserved is not true, then set the session type to the value
// saved in isolated storage. This will make sure the session type is correct for an
// app that is being resumed after being tombstoned.
if (!e.IsApplicationInstancePreserved)
{
RestoreSessionType();
}
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
// When the applicaiton is deactivated, save the current deactivation settings to isolated storage
SaveCurrentDeactivationSettings();
}
// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
// When the application closes, delete any deactivation settings from isolated storage
RemoveCurrentDeactivationSettings();
}
// Code to execute if a navigation fails
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
if (Debugger.IsAttached)
{
// A navigation has failed; break into the debugger
System.Diagnostics.Debugger.Break();
Debugger.Break();
}
}
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
Debugger.Break();
}
}
@ -125,10 +162,80 @@ namespace PhoneDirect3DXamlAppInterop
// Handle reset requests for clearing the backstack
RootFrame.Navigated += CheckForResetNavigation;
// Monitor deep link launching
RootFrame.Navigating += RootFrame_Navigating;
// Ensure we don't initialize again
phoneApplicationInitialized = true;
}
// Event handler for the Navigating event of the root frame. Use this handler to modify
// the default navigation behavior.
void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e)
{
// If the session type is None or New, check the navigation Uri to determine if the
// navigation is a deep link or if it points to the app's main page.
if (sessionType == SessionType.None && e.NavigationMode == NavigationMode.New)
{
// This block will run if the current navigation is part of the app's intial launch
// Keep track of Session Type
if (e.Uri.ToString().Contains("DeepLink=true"))
{
sessionType = SessionType.DeepLink;
}
else if (e.Uri.ToString().Contains("/MainPage.xaml"))
{
sessionType = SessionType.Home;
}
}
if (e.NavigationMode == NavigationMode.Reset)
{
// This block will execute if the current navigation is a relaunch.
// If so, another navigation will be coming, so this records that a relaunch just happened
// so that the next navigation can use this info.
wasRelaunched = true;
}
else if (e.NavigationMode == NavigationMode.New && wasRelaunched)
{
// This block will run if the previous navigation was a relaunch
wasRelaunched = false;
if (e.Uri.ToString().Contains("DeepLink=true"))
{
// This block will run if the launch Uri contains "DeepLink=true" which
// was specified when the secondary tile was created in MainPage.xaml.cs
sessionType = SessionType.DeepLink;
// The app was relaunched via a Deep Link.
// The page stack will be cleared.
}
else if (e.Uri.ToString().Contains("/MainPage.xaml"))
{
// This block will run if the navigation Uri is the main page
if (sessionType == SessionType.DeepLink)
{
// When the app was previously launched via Deep Link and relaunched via Main Tile, we need to clear the page stack.
sessionType = SessionType.Home;
}
else
{
if (!mustClearPagestack)
{
//The app was previously launched via Main Tile and relaunched via Main Tile. Cancel the navigation to resume.
e.Cancel = true;
RootFrame.Navigated -= ClearBackStackAfterReset;
}
}
}
mustClearPagestack = false;
}
}
// Do not add any additional code to this method
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
{
@ -153,7 +260,7 @@ namespace PhoneDirect3DXamlAppInterop
// Unregister the event so it doesn't get called again
RootFrame.Navigated -= ClearBackStackAfterReset;
// Only clear the stack for 'new' (forward) navigations
// Only clear the stack for 'new' (forward) and 'refresh' navigations
if (e.NavigationMode != NavigationMode.New)
return;
@ -165,5 +272,92 @@ namespace PhoneDirect3DXamlAppInterop
}
#endregion
// Helper method for adding or updating a key/value pair in isolated storage
public bool AddOrUpdateValue(string Key, Object value)
{
bool valueChanged = false;
// If the key exists
if (settings.Contains(Key))
{
// If the value has changed
if (settings[Key] != value)
{
// Store the new value
settings[Key] = value;
valueChanged = true;
}
}
// Otherwise create the key.
else
{
settings.Add(Key, value);
valueChanged = true;
}
return valueChanged;
}
// Helper method for removing a key/value pair from isolated storage
public void RemoveValue(string Key)
{
// If the key exists
if (settings.Contains(Key))
{
settings.Remove(Key);
}
}
// Called when the app is deactivating. Saves the time of the deactivation and the
// session type of the app instance to isolated storage.
public void SaveCurrentDeactivationSettings()
{
if (AddOrUpdateValue("DeactivateTime", DateTimeOffset.Now))
{
settings.Save();
}
if (AddOrUpdateValue("SessionType", sessionType))
{
settings.Save();
}
}
// Called when the app is launched or closed. Removes all deactivation settings from
// isolated storage
public void RemoveCurrentDeactivationSettings()
{
RemoveValue("DeactivateTime");
RemoveValue("SessionType");
settings.Save();
}
// Helper method to determine if the interval since the app was deactivated is
// greater than 30 seconds
bool CheckDeactivationTimeStamp()
{
DateTimeOffset lastDeactivated;
if (settings.Contains("DeactivateTime"))
{
lastDeactivated = (DateTimeOffset)settings["DeactivateTime"];
}
var currentDuration = DateTimeOffset.Now.Subtract(lastDeactivated);
return TimeSpan.FromSeconds(currentDuration.TotalSeconds) > TimeSpan.FromSeconds(30);
}
// Helper method to restore the session type from isolated storage.
void RestoreSessionType()
{
if (settings.Contains("SessionType"))
{
sessionType = (SessionType)settings["SessionType"];
}
}
}
}
}

View File

@ -73,6 +73,7 @@ const char* GLProgram::SHADER_NAME_LABEL_OUTLINE = "ShaderLabelOutline";
const char* GLProgram::SHADER_3D_POSITION = "Shader3DPosition";
const char* GLProgram::SHADER_3D_POSITION_TEXTURE = "Shader3DPositionTexture";
const char* GLProgram::SHADER_3D_SKINPOSITION_TEXTURE = "Shader3DSkinPositionTexture";
// uniform names
@ -94,7 +95,8 @@ const char* GLProgram::ATTRIBUTE_NAME_COLOR = "a_color";
const char* GLProgram::ATTRIBUTE_NAME_POSITION = "a_position";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
const char* GLProgram::ATTRIBUTE_NAME_NORMAL = "a_normal";
const char* GLProgram::ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight";
const char* GLProgram::ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex";
GLProgram* GLProgram::createWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray)
{
@ -359,6 +361,12 @@ void GLProgram::parseUniforms()
}
uniform.name = std::string(uniformName);
uniform.location = glGetUniformLocation(_program, uniformName);
GLenum __gl_error_code = glGetError();
if (__gl_error_code != GL_NO_ERROR)
{
CCLOG("error: 0x%x", (int)__gl_error_code);
}
assert(__gl_error_code == GL_NO_ERROR);
_userUniforms[uniform.name] = uniform;
}

View File

@ -85,6 +85,8 @@ public:
VERTEX_ATTRIB_COLOR,
VERTEX_ATTRIB_TEX_COORD,
VERTEX_ATTRIB_NORMAL,
VERTEX_ATTRIB_BLEND_WEIGHT,
VERTEX_ATTRIB_BLEND_INDEX,
VERTEX_ATTRIB_MAX,
@ -130,6 +132,7 @@ public:
//3D
static const char* SHADER_3D_POSITION;
static const char* SHADER_3D_POSITION_TEXTURE;
static const char* SHADER_3D_SKINPOSITION_TEXTURE;
// uniform names
static const char* UNIFORM_NAME_P_MATRIX;
@ -150,6 +153,8 @@ public:
static const char* ATTRIBUTE_NAME_POSITION;
static const char* ATTRIBUTE_NAME_TEX_COORD;
static const char* ATTRIBUTE_NAME_NORMAL;
static const char* ATTRIBUTE_NAME_BLEND_WEIGHT;
static const char* ATTRIBUTE_NAME_BLEND_INDEX;
GLProgram();
virtual ~GLProgram();

View File

@ -51,6 +51,7 @@ enum {
kShaderType_LabelOutline,
kShaderType_3DPosition,
kShaderType_3DPositionTex,
kShaderType_3DSkinPositionTex,
kShaderType_MAX,
};
@ -200,6 +201,9 @@ void GLProgramCache::loadDefaultGLPrograms()
loadDefaultGLProgram(p, kShaderType_3DPositionTex);
_programs.insert( std::make_pair(GLProgram::SHADER_3D_POSITION_TEXTURE, p) );
p = new GLProgram();
loadDefaultGLProgram(p, kShaderType_3DSkinPositionTex);
_programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_TEXTURE, p));
}
void GLProgramCache::reloadDefaultGLPrograms()
@ -297,6 +301,9 @@ void GLProgramCache::reloadDefaultGLPrograms()
p->reset();
loadDefaultGLProgram(p, kShaderType_3DPositionTex);
p = getGLProgram(GLProgram::SHADER_3D_SKINPOSITION_TEXTURE);
p->reset();
loadDefaultGLProgram(p, kShaderType_3DSkinPositionTex);
}
void GLProgramCache::loadDefaultGLProgram(GLProgram *p, int type)
@ -356,6 +363,9 @@ void GLProgramCache::loadDefaultGLProgram(GLProgram *p, int type)
case kShaderType_3DPositionTex:
p->initWithByteArrays(cc3D_PositionTex_vert, cc3D_ColorTex_frag);
break;
case kShaderType_3DSkinPositionTex:
p->initWithByteArrays(cc3D_SkinPositionTex_vert, cc3D_ColorTex_frag);
break;
default:
CCLOG("cocos2d: %s:%d, error shader type", __FUNCTION__, __LINE__);
return;

View File

@ -69,7 +69,7 @@ UniformValue::~UniformValue()
void UniformValue::apply()
{
if(_useCallback) {
(*_value.callback)(_uniform);
(*_value.callback)(_glprogram, _uniform);
}
else
{
@ -110,7 +110,7 @@ void UniformValue::apply()
}
}
void UniformValue::setCallback(const std::function<void(Uniform*)> &callback)
void UniformValue::setCallback(const std::function<void(GLProgram*, Uniform*)> &callback)
{
// delete previously set callback
// XXX TODO: memory will leak if the user does:
@ -119,7 +119,7 @@ void UniformValue::setCallback(const std::function<void(Uniform*)> &callback)
if (_useCallback)
delete _value.callback;
_value.callback = new std::function<void(Uniform*)>();
_value.callback = new std::function<void(GLProgram*, Uniform*)>();
*_value.callback = callback;
_useCallback = true;
@ -422,7 +422,7 @@ void GLProgramState::setVertexAttribPointer(const std::string &name, GLint size,
// Uniform Setters
void GLProgramState::setUniformCallback(const std::string &uniformName, const std::function<void(Uniform*)> &callback)
void GLProgramState::setUniformCallback(const std::string &uniformName, const std::function<void(GLProgram*, Uniform*)> &callback)
{
auto v = getUniformValue(uniformName);
if (v)

View File

@ -62,7 +62,7 @@ public:
void setVec3(const Vec3& value);
void setVec4(const Vec4& value);
void setMat4(const Mat4& value);
void setCallback(const std::function<void(Uniform*)> &callback);
void setCallback(const std::function<void(GLProgram*, Uniform*)> &callback);
void setTexture(GLuint textureId, GLuint activeTexture);
void apply();
@ -83,7 +83,7 @@ protected:
GLuint textureId;
GLuint textureUnit;
} tex;
std::function<void(Uniform*)> *callback;
std::function<void(GLProgram*, Uniform*)> *callback;
U() { memset( this, 0, sizeof(*this) ); }
~U(){}
@ -176,7 +176,7 @@ public:
void setUniformVec3(const std::string &uniformName, const Vec3& value);
void setUniformVec4(const std::string &uniformName, const Vec4& value);
void setUniformMat4(const std::string &uniformName, const Mat4& value);
void setUniformCallback(const std::string &uniformName, const std::function<void(Uniform*)> &callback);
void setUniformCallback(const std::string &uniformName, const std::function<void(GLProgram*, Uniform*)> &callback);
void setUniformTexture(const std::string &uniformName, Texture2D *texture);
void setUniformTexture(const std::string &uniformName, GLuint textureId);

View File

@ -26,10 +26,12 @@
#include "base/CCDirector.h"
#include "renderer/CCMeshCommand.h"
#include "renderer/ccGLStateCache.h"
#include "renderer/CCGLProgram.h"
#include "renderer/CCGLProgramState.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCTextureAtlas.h"
#include "renderer/CCTexture2D.h"
#include "renderer/ccGLStateCache.h"
NS_CC_BEGIN
@ -42,6 +44,8 @@ MeshCommand::MeshCommand()
, _depthTestEnabled(false)
, _depthWriteEnabled(false)
, _displayColor(1.0f, 1.0f, 1.0f, 1.0f)
, _matrixPalette(nullptr)
, _matrixPaletteSize(0)
{
_type = RenderCommand::Type::MESH_COMMAND;
}
@ -134,6 +138,11 @@ void MeshCommand::restoreRenderState()
}
}
void MeshCommand::MatrixPalleteCallBack( GLProgram* glProgram, Uniform* uniform)
{
glProgram->setUniformLocationWith4fv(uniform->location, (const float*)_matrixPalette, _matrixPaletteSize);
}
void MeshCommand::execute()
{
// set render state
@ -145,6 +154,13 @@ void MeshCommand::execute()
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
_glProgramState->setUniformVec4("u_color", _displayColor);
if (_matrixPaletteSize && _matrixPalette)
{
_glProgramState->setUniformCallback("u_matrixPalette", CC_CALLBACK_2(MeshCommand::MatrixPalleteCallBack, this));
}
_glProgramState->apply(_mv);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);

View File

@ -33,6 +33,8 @@
NS_CC_BEGIN
class GLProgramState;
class GLProgram;
class Uniform;
//it is a common mesh
class MeshCommand : public RenderCommand
@ -53,6 +55,10 @@ public:
void setDepthWriteEnabled(bool enable);
void setDisplayColor(const Vec4& color);
void setMatrixPalette(const Vec4* matrixPalette) { _matrixPalette = matrixPalette; }
void setMatrixPaletteSize(int size) { _matrixPaletteSize = size; }
void execute();
@ -62,6 +68,8 @@ protected:
//restore to all false
void restoreRenderState();
void MatrixPalleteCallBack( GLProgram* glProgram, Uniform* uniform);
GLuint _textureID;
GLProgramState* _glProgramState;
@ -71,6 +79,10 @@ protected:
Vec4 _displayColor; // in order to support tint and fade in fade out
// used for skin
const Vec4* _matrixPalette;
int _matrixPaletteSize;
GLuint _vertexBuffer;
GLuint _indexBuffer;
GLenum _primitive;

View File

@ -455,6 +455,16 @@ Texture2D::~Texture2D()
}
}
void Texture2D::releaseGLTexture()
{
if(_name)
{
GL::deleteTexture(_name);
}
_name = 0;
}
Texture2D::PixelFormat Texture2D::getPixelFormat() const
{
return _pixelFormat;
@ -539,14 +549,7 @@ bool Texture2D::initWithData(const void *data, ssize_t dataLen, Texture2D::Pixel
bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, int pixelsWide, int pixelsHigh)
{
// cocos2d-x is currently calling this multiple times on the same Texture2D
// if the GL texture has already been created,it will be leaked in OpenGL
// For now, call deleteTexture if the texture already exists
if(_name)
{
GL::deleteTexture(_name);
_name = 0;
}
//the pixelFormat must be a certain value
CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!");
@ -601,8 +604,12 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}
if(_name != 0)
{
GL::deleteTexture(_name);
_name = 0;
}
glGenTextures(1, &_name);
GL::bindTexture2D(_name);

View File

@ -203,6 +203,12 @@ public:
*/
virtual std::string getDescription() const;
/** release only the gl texture.
* @js NA
* @lua NA
*/
void releaseGLTexture();
/** Initializes with a texture2d with data
* @js NA
* @lua NA

View File

@ -706,6 +706,12 @@ void VolatileTextureMgr::reloadAllTextures()
{
_isReloading = true;
// we need to release all of the glTextures to avoid collisions of texture id's when reloading the textures onto the GPU
for(auto iter = _textures.begin(); iter != _textures.end(); ++iter)
{
(*iter)->_texture->releaseGLTexture();
}
CCLOG("reload all texture");
auto iter = _textures.begin();

View File

@ -164,22 +164,25 @@ void bindTexture2DN(GLuint textureUnit, GLuint textureId)
void deleteTexture(GLuint textureId)
{
deleteTextureN(0, textureId);
}
void deleteTextureN(GLuint textureUnit, GLuint textureId)
{
#if CC_ENABLE_GL_STATE_CACHE
if (s_currentBoundTexture[textureUnit] == textureId)
for (size_t i = 0; i < MAX_ACTIVE_TEXTURE; ++i)
{
s_currentBoundTexture[textureUnit] = -1;
if (s_currentBoundTexture[i] == textureId)
{
s_currentBoundTexture[i] = -1;
}
}
#endif // CC_ENABLE_GL_STATE_CACHE
glDeleteTextures(1, &textureId);
}
void deleteTextureN(GLuint textureUnit, GLuint textureId)
{
deleteTexture(textureId);
}
void activeTexture(GLenum texture)
{
#if CC_ENABLE_GL_STATE_CACHE

View File

@ -129,7 +129,7 @@ void CC_DLL deleteTexture(GLuint textureId);
If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly.
@since v2.1.0
*/
void CC_DLL deleteTextureN(GLuint textureUnit, GLuint textureId);
CC_DEPRECATED_ATTRIBUTE void CC_DLL deleteTextureN(GLuint textureUnit, GLuint textureId);
/** Select active texture unit.
If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glActiveTexture() directly.

View File

@ -13,3 +13,69 @@ void main(void)
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
}
);
const char* cc3D_SkinPositionTex_vert = STRINGIFY(
attribute vec4 a_position;
attribute vec4 a_blendWeight;
attribute vec4 a_blendIndex;
attribute vec2 a_texCoord;
const int SKINNING_JOINT_COUNT = 60;
// Uniforms
uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];
// Varyings
varying vec2 TextureCoordOut;
vec4 _skinnedPosition;
vec4 getPosition()
{
vec4 matrixPalette1 = vec4(0.0);
vec4 matrixPalette2 = vec4(0.0);
vec4 matrixPalette3 = vec4(0.0);
float blendWeight = a_blendWeight[0];
int matrixIndex = int (a_blendIndex[0]) * 3;
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
blendWeight = a_blendWeight[1];
matrixIndex = int(a_blendIndex[1]) * 3;
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
blendWeight = a_blendWeight[2];
matrixIndex = int(a_blendIndex[2]) * 3;
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
blendWeight = a_blendWeight[3];
matrixIndex = int(a_blendIndex[3]) * 3;
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
_skinnedPosition.x = dot(a_position, matrixPalette1);
_skinnedPosition.y = dot(a_position, matrixPalette2);
_skinnedPosition.z = dot(a_position, matrixPalette3);
_skinnedPosition.w = a_position.w;
return _skinnedPosition;
}
void main()
{
vec4 position = getPosition();
gl_Position = CC_MVPMatrix * position;
TextureCoordOut = a_texCoord;
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
}
);

View File

@ -70,6 +70,7 @@ extern CC_DLL const GLchar * ccLabelOutline_frag;
extern CC_DLL const GLchar * ccLabel_vert;
extern CC_DLL const GLchar * cc3D_PositionTex_vert;
extern CC_DLL const GLchar * cc3D_SkinPositionTex_vert;
extern CC_DLL const GLchar * cc3D_ColorTex_frag;
extern CC_DLL const GLchar * cc3D_Color_frag;
// end of shaders group

View File

@ -46,11 +46,6 @@
-- @param self
-- @return Bone#Bone ret (return value: ccs.Bone)
--------------------------------
-- @function [parent=#Armature] setArmatureData
-- @param self
-- @param #ccs.ArmatureData armaturedata
--------------------------------
-- @function [parent=#Armature] removeBone
-- @param self
@ -62,11 +57,6 @@
-- @param self
-- @return BatchNode#BatchNode ret (return value: ccs.BatchNode)
--------------------------------
-- @function [parent=#Armature] getName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- overload function: init(string)
--
@ -95,9 +85,9 @@
-- @param #ccs.BatchNode batchnode
--------------------------------
-- @function [parent=#Armature] setName
-- @function [parent=#Armature] setArmatureData
-- @param self
-- @param #string str
-- @param #ccs.ArmatureData armaturedata
--------------------------------
-- @function [parent=#Armature] addBone

View File

@ -51,11 +51,6 @@
-- @function [parent=#Bone] updateColor
-- @param self
--------------------------------
-- @function [parent=#Bone] getName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#Bone] setTransformDirty
-- @param self
@ -101,11 +96,6 @@
-- @param #ccs.DisplayData displaydata
-- @param #int int
--------------------------------
-- @function [parent=#Bone] setName
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#Bone] removeFromParent
-- @param self

View File

@ -15,13 +15,6 @@
-- @param #char char
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWithMatrix4fv
-- @param self
-- @param #int int
-- @param #float float
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] initWithFilenames
-- @param self
@ -29,12 +22,6 @@
-- @param #string str
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#GLProgram] getUniformLocationForName
-- @param self
-- @param #char char
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#GLProgram] use
-- @param self
@ -44,12 +31,6 @@
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#GLProgram] getUniform
-- @param self
-- @param #string str
-- @return Uniform#Uniform ret (return value: cc.Uniform)
--------------------------------
-- overload function: setUniformsForBuiltins(mat4_table)
--
@ -59,58 +40,16 @@
-- @param self
-- @param #mat4_table mat4
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith3i
-- @param self
-- @param #int int
-- @param #int int
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith3iv
-- @param self
-- @param #int int
-- @param #int int
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] updateUniforms
-- @param self
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith4iv
-- @param self
-- @param #int int
-- @param #int int
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] getUniformLocation
-- @param self
-- @param #string str
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith1i
-- @param self
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith2iv
-- @param self
-- @param #int int
-- @param #int int
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWithMatrix3fv
-- @param self
-- @param #int int
-- @param #float float
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] reset
-- @param self
@ -127,40 +66,11 @@
-- @param #string str
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#GLProgram] getVertexAttrib
-- @param self
-- @param #string str
-- @return VertexAttrib#VertexAttrib ret (return value: cc.VertexAttrib)
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWithMatrix2fv
-- @param self
-- @param #int int
-- @param #float float
-- @param #unsigned int int
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith4i
-- @param self
-- @param #int int
-- @param #int int
-- @param #int int
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#GLProgram] link
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#GLProgram] setUniformLocationWith2i
-- @param self
-- @param #int int
-- @param #int int
-- @param #int int
--------------------------------
-- @function [parent=#GLProgram] createWithByteArrays
-- @param self

View File

@ -1,122 +0,0 @@
--------------------------------
-- @module LabelBMFont
-- @extend Node,LabelProtocol,BlendProtocol
--------------------------------
-- @function [parent=#LabelBMFont] setLineBreakWithoutSpace
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#LabelBMFont] getBlendFunc
-- @param self
-- @return BlendFunc#BlendFunc ret (return value: cc.BlendFunc)
--------------------------------
-- @function [parent=#LabelBMFont] isOpacityModifyRGB
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#LabelBMFont] getLetter
-- @param self
-- @param #int int
-- @return Sprite#Sprite ret (return value: cc.Sprite)
--------------------------------
-- @function [parent=#LabelBMFont] getString
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#LabelBMFont] setBlendFunc
-- @param self
-- @param #cc.BlendFunc blendfunc
--------------------------------
-- @function [parent=#LabelBMFont] setString
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#LabelBMFont] initWithString
-- @param self
-- @param #string str
-- @param #string str
-- @param #float float
-- @param #cc.TextHAlignment texthalignment
-- @param #vec2_table vec2
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#LabelBMFont] setOpacityModifyRGB
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#LabelBMFont] getFntFile
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#LabelBMFont] setFntFile
-- @param self
-- @param #string str
-- @param #vec2_table vec2
--------------------------------
-- @function [parent=#LabelBMFont] setAlignment
-- @param self
-- @param #cc.TextHAlignment texthalignment
--------------------------------
-- @function [parent=#LabelBMFont] setWidth
-- @param self
-- @param #float float
--------------------------------
-- overload function: create()
--
-- overload function: create(string, string, float, cc.TextHAlignment, vec2_table)
--
-- @function [parent=#LabelBMFont] create
-- @param self
-- @param #string str
-- @param #string str
-- @param #float float
-- @param #cc.TextHAlignment texthalignment
-- @param #vec2_table vec2
-- @return LabelBMFont#LabelBMFont ret (retunr value: cc.LabelBMFont)
--------------------------------
-- @function [parent=#LabelBMFont] getBoundingBox
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
-- @function [parent=#LabelBMFont] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#LabelBMFont] setColor
-- @param self
-- @param #color3b_table color3b
--------------------------------
-- @function [parent=#LabelBMFont] getChildByTag
-- @param self
-- @param #int int
-- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- @function [parent=#LabelBMFont] getContentSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#LabelBMFont] LabelBMFont
-- @param self
return nil

View File

@ -1,191 +0,0 @@
--------------------------------
-- @module LabelTTF
-- @extend Node,LabelProtocol,BlendProtocol
--------------------------------
-- @function [parent=#LabelTTF] enableShadow
-- @param self
-- @param #size_table size
-- @param #float float
-- @param #float float
-- @param #bool bool
--------------------------------
-- @function [parent=#LabelTTF] setDimensions
-- @param self
-- @param #size_table size
--------------------------------
-- @function [parent=#LabelTTF] getFontSize
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#LabelTTF] getString
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#LabelTTF] setFlippedY
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#LabelTTF] setFlippedX
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#LabelTTF] setTextDefinition
-- @param self
-- @param #cc.FontDefinition fontdefinition
--------------------------------
-- @function [parent=#LabelTTF] setFontName
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#LabelTTF] getHorizontalAlignment
-- @param self
-- @return TextHAlignment#TextHAlignment ret (return value: cc.TextHAlignment)
--------------------------------
-- @function [parent=#LabelTTF] initWithStringAndTextDefinition
-- @param self
-- @param #string str
-- @param #cc.FontDefinition fontdefinition
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#LabelTTF] setString
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#LabelTTF] initWithString
-- @param self
-- @param #string str
-- @param #string str
-- @param #float float
-- @param #size_table size
-- @param #cc.TextHAlignment texthalignment
-- @param #cc.TextVAlignment textvalignment
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#LabelTTF] setFontFillColor
-- @param self
-- @param #color3b_table color3b
-- @param #bool bool
--------------------------------
-- @function [parent=#LabelTTF] getBlendFunc
-- @param self
-- @return BlendFunc#BlendFunc ret (return value: cc.BlendFunc)
--------------------------------
-- @function [parent=#LabelTTF] enableStroke
-- @param self
-- @param #color3b_table color3b
-- @param #float float
-- @param #bool bool
--------------------------------
-- @function [parent=#LabelTTF] getDimensions
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#LabelTTF] setVerticalAlignment
-- @param self
-- @param #cc.TextVAlignment textvalignment
--------------------------------
-- @function [parent=#LabelTTF] setFontSize
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#LabelTTF] getVerticalAlignment
-- @param self
-- @return TextVAlignment#TextVAlignment ret (return value: cc.TextVAlignment)
--------------------------------
-- @function [parent=#LabelTTF] getTextDefinition
-- @param self
-- @return FontDefinition#FontDefinition ret (return value: cc.FontDefinition)
--------------------------------
-- @function [parent=#LabelTTF] setBlendFunc
-- @param self
-- @param #cc.BlendFunc blendfunc
--------------------------------
-- @function [parent=#LabelTTF] getFontName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#LabelTTF] setHorizontalAlignment
-- @param self
-- @param #cc.TextHAlignment texthalignment
--------------------------------
-- @function [parent=#LabelTTF] disableShadow
-- @param self
--------------------------------
-- @function [parent=#LabelTTF] disableStroke
-- @param self
--------------------------------
-- overload function: create()
--
-- overload function: create(string, string, float, size_table, cc.TextHAlignment, cc.TextVAlignment)
--
-- @function [parent=#LabelTTF] create
-- @param self
-- @param #string str
-- @param #string str
-- @param #float float
-- @param #size_table size
-- @param #cc.TextHAlignment texthalignment
-- @param #cc.TextVAlignment textvalignment
-- @return LabelTTF#LabelTTF ret (retunr value: cc.LabelTTF)
--------------------------------
-- @function [parent=#LabelTTF] createWithFontDefinition
-- @param self
-- @param #string str
-- @param #cc.FontDefinition fontdefinition
-- @return LabelTTF#LabelTTF ret (return value: cc.LabelTTF)
--------------------------------
-- @function [parent=#LabelTTF] getBoundingBox
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
-- @function [parent=#LabelTTF] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#LabelTTF] getContentSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#LabelTTF] visit
-- @param self
-- @param #cc.Renderer renderer
-- @param #mat4_table mat4
-- @param #unsigned int int
--------------------------------
-- @function [parent=#LabelTTF] LabelTTF
-- @param self
return nil

View File

@ -54,13 +54,4 @@
-- @param #int int
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#Mesh] create
-- @param self
-- @param #array_table array
-- @param #array_table array
-- @param #array_table array
-- @param #array_table vector<short, std::allocator<short> >
-- @return Mesh#Mesh ret (return value: cc.Mesh)
return nil

View File

@ -71,6 +71,12 @@
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#Node] getChildByName
-- @param self
-- @param #string str
-- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- @function [parent=#Node] updateDisplayedOpacity
-- @param self
@ -202,6 +208,11 @@
-- @param self
-- @param #cc.Node node
--------------------------------
-- @function [parent=#Node] getName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#Node] getRotation3D
-- @param self
@ -392,6 +403,11 @@
-- @param #int int
-- @return Action#Action ret (return value: cc.Action)
--------------------------------
-- @function [parent=#Node] setName
-- @param self
-- @param #string str
--------------------------------
-- overload function: setAdditionalTransform(cc.AffineTransform)
--
@ -612,6 +628,12 @@
-- @param self
-- @param #cc.Ref ref
--------------------------------
-- @function [parent=#Node] enumerateChildren
-- @param self
-- @param #string str
-- @param #function func
--------------------------------
-- overload function: removeFromParentAndCleanup(bool)
--

View File

@ -3,13 +3,6 @@
-- @module OrbitCamera
-- @extend ActionCamera
--------------------------------
-- @function [parent=#OrbitCamera] sphericalRadius
-- @param self
-- @param #float float
-- @param #float float
-- @param #float float
--------------------------------
-- @function [parent=#OrbitCamera] create
-- @param self

View File

@ -16,11 +16,6 @@
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#ParallaxNode] setParallaxArray
-- @param self
-- @param #cc._ccArray _ccarray
--------------------------------
-- @function [parent=#ParallaxNode] create
-- @param self

View File

@ -196,12 +196,6 @@
-- @param self
-- @param #color4f_table color4f
--------------------------------
-- @function [parent=#ParticleSystem] updateQuadWithParticle
-- @param self
-- @param #cc.sParticle sparticle
-- @param #vec2_table vec2
--------------------------------
-- @function [parent=#ParticleSystem] getAtlasIndex
-- @param self
@ -276,11 +270,6 @@
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#ParticleSystem] initParticle
-- @param self
-- @param #cc.sParticle sparticle
--------------------------------
-- @function [parent=#ParticleSystem] setEmitterMode
-- @param self

View File

@ -64,14 +64,15 @@
-- @param self
--------------------------------
-- overload function: saveToFile(string, cc.Image::Format)
-- overload function: saveToFile(string, cc.Image::Format, bool)
--
-- overload function: saveToFile(string)
-- overload function: saveToFile(string, bool)
--
-- @function [parent=#RenderTexture] saveToFile
-- @param self
-- @param #string str
-- @param #cc.Image::Format format
-- @param #bool bool
-- @return bool#bool ret (retunr value: bool)
--------------------------------

View File

@ -196,7 +196,7 @@
-- @function [parent=#ScrollView] getChildByName
-- @param self
-- @param #string str
-- @return Widget#Widget ret (return value: ccui.Widget)
-- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- @function [parent=#ScrollView] getDescription

View File

@ -3,18 +3,6 @@
-- @module ShuffleTiles
-- @extend TiledGrid3DAction
--------------------------------
-- @function [parent=#ShuffleTiles] placeTile
-- @param self
-- @param #vec2_table vec2
-- @param #cc.Tile tile
--------------------------------
-- @function [parent=#ShuffleTiles] shuffle
-- @param self
-- @param #unsigned int int
-- @param #unsigned int int
--------------------------------
-- @function [parent=#ShuffleTiles] getDelta
-- @param self

View File

@ -18,12 +18,4 @@
-- @function [parent=#SkeletonAnimation] clearTrack
-- @param self
--------------------------------
-- @function [parent=#SkeletonAnimation] onAnimationStateEvent
-- @param self
-- @param #int int
-- @param #spEventType speventtype
-- @param #spEvent spevent
-- @param #int int
return nil

View File

@ -3,13 +3,6 @@
-- @module TMXLayer
-- @extend SpriteBatchNode
--------------------------------
-- @function [parent=#TMXLayer] getTileGIDAt
-- @param self
-- @param #vec2_table vec2
-- @param #cc.TMXTileFlags_ tmxtileflags_
-- @return unsigned int#unsigned int ret (return value: unsigned int)
--------------------------------
-- @function [parent=#TMXLayer] getPositionAt
-- @param self
@ -25,11 +18,6 @@
-- @function [parent=#TMXLayer] releaseMap
-- @param self
--------------------------------
-- @function [parent=#TMXLayer] setTiles
-- @param self
-- @param #unsigned int int
--------------------------------
-- @function [parent=#TMXLayer] getLayerSize
-- @param self

View File

@ -30,30 +30,14 @@
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#Texture2D] updateWithData
-- @function [parent=#Texture2D] releaseGLTexture
-- @param self
-- @param #void void
-- @param #int int
-- @param #int int
-- @param #int int
-- @param #int int
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#Texture2D] hasPremultipliedAlpha
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#Texture2D] initWithMipmaps
-- @param self
-- @param #cc._MipmapInfo map
-- @param #int int
-- @param #cc.Texture2D::PixelFormat pixelformat
-- @param #int int
-- @param #int int
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#Texture2D] getPixelsHigh
-- @param self

View File

@ -28,11 +28,6 @@
-- @param #color3b_table color3b
-- @param #vec2_table vec2
--------------------------------
-- @function [parent=#TileMapAtlas] setTGAInfo
-- @param self
-- @param #cc.sImageTGA simagetga
--------------------------------
-- @function [parent=#TileMapAtlas] create
-- @param self

View File

@ -13,12 +13,6 @@
-- @param self
-- @param #vec2_table vec2
--------------------------------
-- @function [parent=#TurnOffTiles] shuffle
-- @param self
-- @param #unsigned int int
-- @param #unsigned int int
--------------------------------
-- overload function: create(float, size_table, unsigned int)
--

View File

@ -14,9 +14,9 @@
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#Widget] getLeftBoundary
-- @function [parent=#Widget] setFlippedY
-- @param self
-- @return float#float ret (return value: float)
-- @param #bool bool
--------------------------------
-- @function [parent=#Widget] setFlippedX
@ -53,11 +53,6 @@
-- @param self
-- @param #ccui.Widget::PositionType positiontype
--------------------------------
-- @function [parent=#Widget] getName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#Widget] isIgnoreContentAdaptWithSize
-- @param self
@ -96,10 +91,9 @@
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#Widget] getChildByName
-- @function [parent=#Widget] ignoreContentAdaptWithSize
-- @param self
-- @param #string str
-- @return Widget#Widget ret (return value: ccui.Widget)
-- @param #bool bool
--------------------------------
-- @function [parent=#Widget] isEnabled
@ -147,9 +141,9 @@
-- @param #bool bool
--------------------------------
-- @function [parent=#Widget] setFlippedY
-- @function [parent=#Widget] getLeftBoundary
-- @param self
-- @param #bool bool
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#Widget] setEnabled
@ -166,11 +160,6 @@
-- @param self
-- @param #ccui.Widget::BrightStyle brightstyle
--------------------------------
-- @function [parent=#Widget] setName
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#Widget] setLayoutParameter
-- @param self
@ -229,11 +218,6 @@
-- @param self
-- @return Widget::SizeType#Widget::SizeType ret (return value: ccui.Widget::SizeType)
--------------------------------
-- @function [parent=#Widget] ignoreContentAdaptWithSize
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#Widget] addTouchEventListener
-- @param self

View File

@ -736,11 +736,6 @@
-- @field [parent=#cc] DrawNode#DrawNode DrawNode preloaded module
--------------------------------------------------------
-- the cc LabelTTF
-- @field [parent=#cc] LabelTTF#LabelTTF LabelTTF preloaded module
--------------------------------------------------------
-- the cc GLProgram
-- @field [parent=#cc] GLProgram#GLProgram GLProgram preloaded module
@ -756,11 +751,6 @@
-- @field [parent=#cc] Label#Label Label preloaded module
--------------------------------------------------------
-- the cc LabelBMFont
-- @field [parent=#cc] LabelBMFont#LabelBMFont LabelBMFont preloaded module
--------------------------------------------------------
-- the cc Layer
-- @field [parent=#cc] Layer#Layer Layer preloaded module

File diff suppressed because it is too large Load Diff

View File

@ -1528,72 +1528,6 @@ int register_all_cocos2dx(lua_State* tolua_S);

View File

@ -494,61 +494,6 @@ int lua_cocos2dx_spine_SkeletonAnimation_clearTrack(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(lua_State* tolua_S)
{
int argc = 0;
spine::SkeletonAnimation* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (spine::SkeletonAnimation*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 4)
{
int arg0;
spEventType arg1;
spEvent* arg2;
int arg3;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1);
#pragma warning NO CONVERSION TO NATIVE FOR spEvent*;
ok &= luaval_to_int32(tolua_S, 5,(int *)&arg3);
if(!ok)
return 0;
cobj->onAnimationStateEvent(arg0, arg1, arg2, arg3);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "onAnimationStateEvent",argc, 4);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_spine_SkeletonAnimation_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (SkeletonAnimation)");
@ -564,7 +509,6 @@ int lua_register_cocos2dx_spine_SkeletonAnimation(lua_State* tolua_S)
tolua_function(tolua_S,"setMix",lua_cocos2dx_spine_SkeletonAnimation_setMix);
tolua_function(tolua_S,"clearTracks",lua_cocos2dx_spine_SkeletonAnimation_clearTracks);
tolua_function(tolua_S,"clearTrack",lua_cocos2dx_spine_SkeletonAnimation_clearTrack);
tolua_function(tolua_S,"onAnimationStateEvent",lua_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent);
tolua_endmodule(tolua_S);
std::string typeName = typeid(spine::SkeletonAnimation).name();
g_luaType[typeName] = "sp.SkeletonAnimation";

View File

@ -22,5 +22,4 @@ int register_all_cocos2dx_spine(lua_State* tolua_S);
#endif // __cocos2dx_spine_h__

View File

@ -5130,50 +5130,6 @@ int lua_cocos2dx_studio_Bone_updateColor(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_studio_Bone_getName(lua_State* tolua_S)
{
int argc = 0;
cocostudio::Bone* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_getName'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
const std::string ret = cobj->getName();
tolua_pushcppstring(tolua_S,ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_getName'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_Bone_setTransformDirty(lua_State* tolua_S)
{
int argc = 0;
@ -5514,52 +5470,6 @@ int lua_cocos2dx_studio_Bone_addDisplay(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_studio_Bone_setName(lua_State* tolua_S)
{
int argc = 0;
cocostudio::Bone* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::Bone*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Bone_setName'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if(!ok)
return 0;
cobj->setName(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setName",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Bone_setName'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_Bone_removeFromParent(lua_State* tolua_S)
{
int argc = 0;
@ -6301,7 +6211,6 @@ int lua_register_cocos2dx_studio_Bone(lua_State* tolua_S)
tolua_function(tolua_S,"getTween",lua_cocos2dx_studio_Bone_getTween);
tolua_function(tolua_S,"getParentBone",lua_cocos2dx_studio_Bone_getParentBone);
tolua_function(tolua_S,"updateColor",lua_cocos2dx_studio_Bone_updateColor);
tolua_function(tolua_S,"getName",lua_cocos2dx_studio_Bone_getName);
tolua_function(tolua_S,"setTransformDirty",lua_cocos2dx_studio_Bone_setTransformDirty);
tolua_function(tolua_S,"getDisplayRenderNodeType",lua_cocos2dx_studio_Bone_getDisplayRenderNodeType);
tolua_function(tolua_S,"removeDisplay",lua_cocos2dx_studio_Bone_removeDisplay);
@ -6309,7 +6218,6 @@ int lua_register_cocos2dx_studio_Bone(lua_State* tolua_S)
tolua_function(tolua_S,"init",lua_cocos2dx_studio_Bone_init);
tolua_function(tolua_S,"setParentBone",lua_cocos2dx_studio_Bone_setParentBone);
tolua_function(tolua_S,"addDisplay",lua_cocos2dx_studio_Bone_addDisplay);
tolua_function(tolua_S,"setName",lua_cocos2dx_studio_Bone_setName);
tolua_function(tolua_S,"removeFromParent",lua_cocos2dx_studio_Bone_removeFromParent);
tolua_function(tolua_S,"getColliderDetector",lua_cocos2dx_studio_Bone_getColliderDetector);
tolua_function(tolua_S,"getChildArmature",lua_cocos2dx_studio_Bone_getChildArmature);
@ -8749,52 +8657,6 @@ int lua_cocos2dx_studio_Armature_getParentBone(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_studio_Armature_setArmatureData(lua_State* tolua_S)
{
int argc = 0;
cocostudio::Armature* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setArmatureData'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocostudio::ArmatureData* arg0;
ok &= luaval_to_object<cocostudio::ArmatureData>(tolua_S, 2, "ccs.ArmatureData",&arg0);
if(!ok)
return 0;
cobj->setArmatureData(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setArmatureData",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setArmatureData'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_Armature_removeBone(lua_State* tolua_S)
{
int argc = 0;
@ -8888,50 +8750,6 @@ int lua_cocos2dx_studio_Armature_getBatchNode(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_studio_Armature_getName(lua_State* tolua_S)
{
int argc = 0;
cocostudio::Armature* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::Armature*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_getName'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
const std::string& ret = cobj->getName();
tolua_pushcppstring(tolua_S,ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_getName'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_studio_Armature_init(lua_State* tolua_S)
{
int argc = 0;
@ -9134,7 +8952,7 @@ int lua_cocos2dx_studio_Armature_setBatchNode(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_studio_Armature_setName(lua_State* tolua_S)
int lua_cocos2dx_studio_Armature_setArmatureData(lua_State* tolua_S)
{
int argc = 0;
cocostudio::Armature* cobj = nullptr;
@ -9154,7 +8972,7 @@ int lua_cocos2dx_studio_Armature_setName(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setName'", nullptr);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_studio_Armature_setArmatureData'", nullptr);
return 0;
}
#endif
@ -9162,20 +8980,20 @@ int lua_cocos2dx_studio_Armature_setName(lua_State* tolua_S)
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
cocostudio::ArmatureData* arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
ok &= luaval_to_object<cocostudio::ArmatureData>(tolua_S, 2, "ccs.ArmatureData",&arg0);
if(!ok)
return 0;
cobj->setName(arg0);
cobj->setArmatureData(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setName",argc, 1);
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setArmatureData",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setName'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_studio_Armature_setArmatureData'.",&tolua_err);
#endif
return 0;
@ -9521,15 +9339,13 @@ int lua_register_cocos2dx_studio_Armature(lua_State* tolua_S)
tolua_function(tolua_S,"setVersion",lua_cocos2dx_studio_Armature_setVersion);
tolua_function(tolua_S,"updateOffsetPoint",lua_cocos2dx_studio_Armature_updateOffsetPoint);
tolua_function(tolua_S,"getParentBone",lua_cocos2dx_studio_Armature_getParentBone);
tolua_function(tolua_S,"setArmatureData",lua_cocos2dx_studio_Armature_setArmatureData);
tolua_function(tolua_S,"removeBone",lua_cocos2dx_studio_Armature_removeBone);
tolua_function(tolua_S,"getBatchNode",lua_cocos2dx_studio_Armature_getBatchNode);
tolua_function(tolua_S,"getName",lua_cocos2dx_studio_Armature_getName);
tolua_function(tolua_S,"init",lua_cocos2dx_studio_Armature_init);
tolua_function(tolua_S,"setParentBone",lua_cocos2dx_studio_Armature_setParentBone);
tolua_function(tolua_S,"drawContour",lua_cocos2dx_studio_Armature_drawContour);
tolua_function(tolua_S,"setBatchNode",lua_cocos2dx_studio_Armature_setBatchNode);
tolua_function(tolua_S,"setName",lua_cocos2dx_studio_Armature_setName);
tolua_function(tolua_S,"setArmatureData",lua_cocos2dx_studio_Armature_setArmatureData);
tolua_function(tolua_S,"addBone",lua_cocos2dx_studio_Armature_addBone);
tolua_function(tolua_S,"getArmatureData",lua_cocos2dx_studio_Armature_getArmatureData);
tolua_function(tolua_S,"getVersion",lua_cocos2dx_studio_Armature_getVersion);

View File

@ -299,10 +299,6 @@ int register_all_cocos2dx_studio(lua_State* tolua_S);

View File

@ -903,7 +903,7 @@ int lua_cocos2dx_ui_Widget_getCustomSize(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_getLeftBoundary(lua_State* tolua_S)
int lua_cocos2dx_ui_Widget_setFlippedY(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
@ -923,26 +923,28 @@ int lua_cocos2dx_ui_Widget_getLeftBoundary(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getLeftBoundary'", nullptr);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_setFlippedY'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0);
if(!ok)
return 0;
double ret = cobj->getLeftBoundary();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
cobj->setFlippedY(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLeftBoundary",argc, 0);
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFlippedY",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getLeftBoundary'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_setFlippedY'.",&tolua_err);
#endif
return 0;
@ -1263,50 +1265,6 @@ int lua_cocos2dx_ui_Widget_setPositionType(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_getName(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getName'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
const std::string& ret = cobj->getName();
tolua_pushcppstring(tolua_S,ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getName'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_ui_Widget_isIgnoreContentAdaptWithSize(lua_State* tolua_S)
{
int argc = 0;
@ -1621,7 +1579,7 @@ int lua_cocos2dx_ui_Widget_getTopBoundary(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_getChildByName(lua_State* tolua_S)
int lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
@ -1641,7 +1599,7 @@ int lua_cocos2dx_ui_Widget_getChildByName(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getChildByName'", nullptr);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize'", nullptr);
return 0;
}
#endif
@ -1649,21 +1607,20 @@ int lua_cocos2dx_ui_Widget_getChildByName(lua_State* tolua_S)
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
bool arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
ok &= luaval_to_boolean(tolua_S, 2,&arg0);
if(!ok)
return 0;
cocos2d::ui::Widget* ret = cobj->getChildByName(arg0);
object_to_luaval<cocos2d::ui::Widget>(tolua_S, "ccui.Widget",(cocos2d::ui::Widget*)ret);
return 1;
cobj->ignoreContentAdaptWithSize(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getChildByName",argc, 1);
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ignoreContentAdaptWithSize",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getChildByName'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize'.",&tolua_err);
#endif
return 0;
@ -2070,7 +2027,7 @@ int lua_cocos2dx_ui_Widget_setTouchEnabled(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_setFlippedY(lua_State* tolua_S)
int lua_cocos2dx_ui_Widget_getLeftBoundary(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
@ -2090,28 +2047,26 @@ int lua_cocos2dx_ui_Widget_setFlippedY(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_setFlippedY'", nullptr);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_getLeftBoundary'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
if (argc == 0)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0);
if(!ok)
return 0;
cobj->setFlippedY(arg0);
return 0;
double ret = cobj->getLeftBoundary();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setFlippedY",argc, 1);
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLeftBoundary",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_setFlippedY'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_getLeftBoundary'.",&tolua_err);
#endif
return 0;
@ -2252,52 +2207,6 @@ int lua_cocos2dx_ui_Widget_setBrightStyle(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_setName(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_setName'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
if(!ok)
return 0;
cobj->setName(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setName",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_setName'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_ui_Widget_setLayoutParameter(lua_State* tolua_S)
{
int argc = 0;
@ -2790,52 +2699,6 @@ int lua_cocos2dx_ui_Widget_getSizeType(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize(lua_State* tolua_S)
{
int argc = 0;
cocos2d::ui::Widget* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::ui::Widget*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0);
if(!ok)
return 0;
cobj->ignoreContentAdaptWithSize(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "ignoreContentAdaptWithSize",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_ui_Widget_addTouchEventListener(lua_State* tolua_S)
{
int argc = 0;
@ -3450,7 +3313,7 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
tolua_function(tolua_S,"new",lua_cocos2dx_ui_Widget_constructor);
tolua_function(tolua_S,"setSizePercent",lua_cocos2dx_ui_Widget_setSizePercent);
tolua_function(tolua_S,"getCustomSize",lua_cocos2dx_ui_Widget_getCustomSize);
tolua_function(tolua_S,"getLeftBoundary",lua_cocos2dx_ui_Widget_getLeftBoundary);
tolua_function(tolua_S,"setFlippedY",lua_cocos2dx_ui_Widget_setFlippedY);
tolua_function(tolua_S,"setFlippedX",lua_cocos2dx_ui_Widget_setFlippedX);
tolua_function(tolua_S,"getVirtualRenderer",lua_cocos2dx_ui_Widget_getVirtualRenderer);
tolua_function(tolua_S,"getSize",lua_cocos2dx_ui_Widget_getSize);
@ -3458,7 +3321,6 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
tolua_function(tolua_S,"getLayoutSize",lua_cocos2dx_ui_Widget_getLayoutSize);
tolua_function(tolua_S,"setHighlighted",lua_cocos2dx_ui_Widget_setHighlighted);
tolua_function(tolua_S,"setPositionType",lua_cocos2dx_ui_Widget_setPositionType);
tolua_function(tolua_S,"getName",lua_cocos2dx_ui_Widget_getName);
tolua_function(tolua_S,"isIgnoreContentAdaptWithSize",lua_cocos2dx_ui_Widget_isIgnoreContentAdaptWithSize);
tolua_function(tolua_S,"getVirtualRendererSize",lua_cocos2dx_ui_Widget_getVirtualRendererSize);
tolua_function(tolua_S,"isHighlighted",lua_cocos2dx_ui_Widget_isHighlighted);
@ -3466,7 +3328,7 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
tolua_function(tolua_S,"findNextFocusedWidget",lua_cocos2dx_ui_Widget_findNextFocusedWidget);
tolua_function(tolua_S,"getPositionType",lua_cocos2dx_ui_Widget_getPositionType);
tolua_function(tolua_S,"getTopBoundary",lua_cocos2dx_ui_Widget_getTopBoundary);
tolua_function(tolua_S,"getChildByName",lua_cocos2dx_ui_Widget_getChildByName);
tolua_function(tolua_S,"ignoreContentAdaptWithSize",lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize);
tolua_function(tolua_S,"isEnabled",lua_cocos2dx_ui_Widget_isEnabled);
tolua_function(tolua_S,"isFocused",lua_cocos2dx_ui_Widget_isFocused);
tolua_function(tolua_S,"getTouchBeganPosition",lua_cocos2dx_ui_Widget_getTouchBeganPosition);
@ -3476,11 +3338,10 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
tolua_function(tolua_S,"setFocused",lua_cocos2dx_ui_Widget_setFocused);
tolua_function(tolua_S,"setActionTag",lua_cocos2dx_ui_Widget_setActionTag);
tolua_function(tolua_S,"setTouchEnabled",lua_cocos2dx_ui_Widget_setTouchEnabled);
tolua_function(tolua_S,"setFlippedY",lua_cocos2dx_ui_Widget_setFlippedY);
tolua_function(tolua_S,"getLeftBoundary",lua_cocos2dx_ui_Widget_getLeftBoundary);
tolua_function(tolua_S,"setEnabled",lua_cocos2dx_ui_Widget_setEnabled);
tolua_function(tolua_S,"getRightBoundary",lua_cocos2dx_ui_Widget_getRightBoundary);
tolua_function(tolua_S,"setBrightStyle",lua_cocos2dx_ui_Widget_setBrightStyle);
tolua_function(tolua_S,"setName",lua_cocos2dx_ui_Widget_setName);
tolua_function(tolua_S,"setLayoutParameter",lua_cocos2dx_ui_Widget_setLayoutParameter);
tolua_function(tolua_S,"clone",lua_cocos2dx_ui_Widget_clone);
tolua_function(tolua_S,"setFocusEnabled",lua_cocos2dx_ui_Widget_setFocusEnabled);
@ -3492,7 +3353,6 @@ int lua_register_cocos2dx_ui_Widget(lua_State* tolua_S)
tolua_function(tolua_S,"getSizePercent",lua_cocos2dx_ui_Widget_getSizePercent);
tolua_function(tolua_S,"getTouchMovePosition",lua_cocos2dx_ui_Widget_getTouchMovePosition);
tolua_function(tolua_S,"getSizeType",lua_cocos2dx_ui_Widget_getSizeType);
tolua_function(tolua_S,"ignoreContentAdaptWithSize",lua_cocos2dx_ui_Widget_ignoreContentAdaptWithSize);
tolua_function(tolua_S,"addTouchEventListener",lua_cocos2dx_ui_Widget_addTouchEventListener);
tolua_function(tolua_S,"getTouchEndPosition",lua_cocos2dx_ui_Widget_getTouchEndPosition);
tolua_function(tolua_S,"getPositionPercent",lua_cocos2dx_ui_Widget_getPositionPercent);

View File

@ -385,9 +385,6 @@ int register_all_cocos2dx_ui(lua_State* tolua_S);

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