Merge pull request #15853 from ricardoquesada/vr_squashed

Squashed commit of the following:
This commit is contained in:
minggo 2016-06-17 10:15:20 +08:00 committed by GitHub
commit 6778ebf451
44 changed files with 1699 additions and 161 deletions

View File

@ -1426,6 +1426,12 @@
5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; }; 5027253B190BF1B900AAF4ED /* cocos2d.h in Headers */ = {isa = PBXBuildFile; fileRef = 50272538190BF1B900AAF4ED /* cocos2d.h */; };
5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; }; 5027253C190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; };
5027253D190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; }; 5027253D190BF1B900AAF4ED /* cocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50272539190BF1B900AAF4ED /* cocos2d.cpp */; };
502AF9781D0711B8006AF256 /* CCVRGenericHeadTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 502AF9771D0711B8006AF256 /* CCVRGenericHeadTracker.cpp */; };
502AF9791D0711C9006AF256 /* CCVRGenericHeadTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 502AF9771D0711B8006AF256 /* CCVRGenericHeadTracker.cpp */; };
502AF97A1D0711CA006AF256 /* CCVRGenericHeadTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 502AF9771D0711B8006AF256 /* CCVRGenericHeadTracker.cpp */; };
5030C0421CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 5030C03E1CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h */; };
5030C0431CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 5030C03E1CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h */; };
5030C0441CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 5030C03E1CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h */; };
5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */; }; 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */; };
5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */; }; 5034CA22191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */; };
5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */; }; 5034CA2B191D591100CE6051 /* ccShader_PositionTextureA8Color.vert in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */; };
@ -1461,6 +1467,18 @@
5034CA4A191D591100CE6051 /* ccShader_Label_df.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0F191D591000CE6051 /* ccShader_Label_df.frag */; }; 5034CA4A191D591100CE6051 /* ccShader_Label_df.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA0F191D591000CE6051 /* ccShader_Label_df.frag */; };
5034CA4B191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_df_glow.frag */; }; 5034CA4B191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_df_glow.frag */; };
5034CA4C191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_df_glow.frag */; }; 5034CA4C191D591100CE6051 /* ccShader_Label_df_glow.frag in Headers */ = {isa = PBXBuildFile; fileRef = 5034CA10191D591000CE6051 /* ccShader_Label_df_glow.frag */; };
503D4F631CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 503D4F611CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp */; };
503D4F641CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 503D4F611CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp */; };
503D4F651CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 503D4F611CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp */; };
503D4F661CE29D4E0054A2D1 /* CCVRDistortionMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D4F621CE29D4E0054A2D1 /* CCVRDistortionMesh.h */; };
503D4F671CE29D4E0054A2D1 /* CCVRDistortionMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D4F621CE29D4E0054A2D1 /* CCVRDistortionMesh.h */; };
503D4F681CE29D4E0054A2D1 /* CCVRDistortionMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D4F621CE29D4E0054A2D1 /* CCVRDistortionMesh.h */; };
503D4F6B1CE2BDBE0054A2D1 /* CCVRDistortion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 503D4F691CE2BDBE0054A2D1 /* CCVRDistortion.cpp */; };
503D4F6C1CE2BDBE0054A2D1 /* CCVRDistortion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 503D4F691CE2BDBE0054A2D1 /* CCVRDistortion.cpp */; };
503D4F6D1CE2BDBE0054A2D1 /* CCVRDistortion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 503D4F691CE2BDBE0054A2D1 /* CCVRDistortion.cpp */; };
503D4F6E1CE2BDBE0054A2D1 /* CCVRDistortion.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D4F6A1CE2BDBE0054A2D1 /* CCVRDistortion.h */; };
503D4F6F1CE2BDBE0054A2D1 /* CCVRDistortion.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D4F6A1CE2BDBE0054A2D1 /* CCVRDistortion.h */; };
503D4F701CE2BDBE0054A2D1 /* CCVRDistortion.h in Headers */ = {isa = PBXBuildFile; fileRef = 503D4F6A1CE2BDBE0054A2D1 /* CCVRDistortion.h */; };
503DD8E01926736A00CD74DD /* CCApplication-ios.h in Headers */ = {isa = PBXBuildFile; fileRef = 503DD8CE1926736A00CD74DD /* CCApplication-ios.h */; }; 503DD8E01926736A00CD74DD /* CCApplication-ios.h in Headers */ = {isa = PBXBuildFile; fileRef = 503DD8CE1926736A00CD74DD /* CCApplication-ios.h */; };
503DD8E11926736A00CD74DD /* CCApplication-ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = 503DD8CF1926736A00CD74DD /* CCApplication-ios.mm */; }; 503DD8E11926736A00CD74DD /* CCApplication-ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = 503DD8CF1926736A00CD74DD /* CCApplication-ios.mm */; };
503DD8E21926736A00CD74DD /* CCCommon-ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = 503DD8D01926736A00CD74DD /* CCCommon-ios.mm */; }; 503DD8E21926736A00CD74DD /* CCCommon-ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = 503DD8D01926736A00CD74DD /* CCCommon-ios.mm */; };
@ -3811,6 +3829,15 @@
50ED2BE119BEAF7900A0AB90 /* UIEditBoxImpl-win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ED2BDC19BEAF7900A0AB90 /* UIEditBoxImpl-win32.h */; }; 50ED2BE119BEAF7900A0AB90 /* UIEditBoxImpl-win32.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ED2BDC19BEAF7900A0AB90 /* UIEditBoxImpl-win32.h */; };
50ED2BE419BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ED2BDE19BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp */; }; 50ED2BE419BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ED2BDE19BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp */; };
50ED2BE519BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ED2BDE19BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp */; }; 50ED2BE519BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50ED2BDE19BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp */; };
50F965511CD0360000ADE813 /* CCVRGenericRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50F9654E1CD0360000ADE813 /* CCVRGenericRenderer.cpp */; };
50F965521CD0360000ADE813 /* CCVRGenericRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50F9654E1CD0360000ADE813 /* CCVRGenericRenderer.cpp */; };
50F965531CD0360000ADE813 /* CCVRGenericRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 50F9654E1CD0360000ADE813 /* CCVRGenericRenderer.cpp */; };
50F965541CD0360000ADE813 /* CCVRGenericRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F9654F1CD0360000ADE813 /* CCVRGenericRenderer.h */; };
50F965551CD0360000ADE813 /* CCVRGenericRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F9654F1CD0360000ADE813 /* CCVRGenericRenderer.h */; };
50F965561CD0360000ADE813 /* CCVRGenericRenderer.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F9654F1CD0360000ADE813 /* CCVRGenericRenderer.h */; };
50F965571CD0360000ADE813 /* CCVRProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F965501CD0360000ADE813 /* CCVRProtocol.h */; };
50F965581CD0360000ADE813 /* CCVRProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F965501CD0360000ADE813 /* CCVRProtocol.h */; };
50F965591CD0360000ADE813 /* CCVRProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F965501CD0360000ADE813 /* CCVRProtocol.h */; };
52B47A2E1A5349A3004E4C60 /* HttpAsynConnection-apple.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B47A291A5349A3004E4C60 /* HttpAsynConnection-apple.h */; }; 52B47A2E1A5349A3004E4C60 /* HttpAsynConnection-apple.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B47A291A5349A3004E4C60 /* HttpAsynConnection-apple.h */; };
52B47A2F1A5349A3004E4C60 /* HttpAsynConnection-apple.m in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2A1A5349A3004E4C60 /* HttpAsynConnection-apple.m */; }; 52B47A2F1A5349A3004E4C60 /* HttpAsynConnection-apple.m in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2A1A5349A3004E4C60 /* HttpAsynConnection-apple.m */; };
52B47A301A5349A3004E4C60 /* HttpClient-apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2B1A5349A3004E4C60 /* HttpClient-apple.mm */; }; 52B47A301A5349A3004E4C60 /* HttpClient-apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2B1A5349A3004E4C60 /* HttpClient-apple.mm */; };
@ -6403,6 +6430,8 @@
5012169F1AC473AD009A4BEA /* CCMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMaterial.h; sourceTree = "<group>"; }; 5012169F1AC473AD009A4BEA /* CCMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMaterial.h; sourceTree = "<group>"; };
50272538190BF1B900AAF4ED /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocos2d.h; path = ../cocos/cocos2d.h; sourceTree = "<group>"; }; 50272538190BF1B900AAF4ED /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocos2d.h; path = ../cocos/cocos2d.h; sourceTree = "<group>"; };
50272539190BF1B900AAF4ED /* cocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocos2d.cpp; path = ../cocos/cocos2d.cpp; sourceTree = "<group>"; }; 50272539190BF1B900AAF4ED /* cocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cocos2d.cpp; path = ../cocos/cocos2d.cpp; sourceTree = "<group>"; };
502AF9771D0711B8006AF256 /* CCVRGenericHeadTracker.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = CCVRGenericHeadTracker.cpp; sourceTree = "<group>"; };
5030C03E1CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVRGenericHeadTracker.h; sourceTree = "<group>"; };
5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColorAlphaTest.frag; sourceTree = "<group>"; }; 5034C9FB191D591000CE6051 /* ccShader_PositionTextureColorAlphaTest.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColorAlphaTest.frag; sourceTree = "<group>"; };
5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureA8Color.vert; sourceTree = "<group>"; }; 5034CA00191D591000CE6051 /* ccShader_PositionTextureA8Color.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureA8Color.vert; sourceTree = "<group>"; };
5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureA8Color.frag; sourceTree = "<group>"; }; 5034CA01191D591000CE6051 /* ccShader_PositionTextureA8Color.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureA8Color.frag; sourceTree = "<group>"; };
@ -6425,6 +6454,10 @@
5034CA61191D91CF00CE6051 /* ccShader_PositionTextureColor.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor.frag; sourceTree = "<group>"; }; 5034CA61191D91CF00CE6051 /* ccShader_PositionTextureColor.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor.frag; sourceTree = "<group>"; };
5034CA62191D91CF00CE6051 /* ccShader_PositionTextureColor_noMVP.vert */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor_noMVP.vert; sourceTree = "<group>"; }; 5034CA62191D91CF00CE6051 /* ccShader_PositionTextureColor_noMVP.vert */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor_noMVP.vert; sourceTree = "<group>"; };
5034CA63191D91CF00CE6051 /* ccShader_PositionTextureColor_noMVP.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor_noMVP.frag; sourceTree = "<group>"; }; 5034CA63191D91CF00CE6051 /* ccShader_PositionTextureColor_noMVP.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionTextureColor_noMVP.frag; sourceTree = "<group>"; };
503D4F611CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVRDistortionMesh.cpp; sourceTree = "<group>"; };
503D4F621CE29D4E0054A2D1 /* CCVRDistortionMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVRDistortionMesh.h; sourceTree = "<group>"; };
503D4F691CE2BDBE0054A2D1 /* CCVRDistortion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVRDistortion.cpp; sourceTree = "<group>"; };
503D4F6A1CE2BDBE0054A2D1 /* CCVRDistortion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVRDistortion.h; sourceTree = "<group>"; };
503DD8CE1926736A00CD74DD /* CCApplication-ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCApplication-ios.h"; sourceTree = "<group>"; }; 503DD8CE1926736A00CD74DD /* CCApplication-ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCApplication-ios.h"; sourceTree = "<group>"; };
503DD8CF1926736A00CD74DD /* CCApplication-ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "CCApplication-ios.mm"; sourceTree = "<group>"; }; 503DD8CF1926736A00CD74DD /* CCApplication-ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "CCApplication-ios.mm"; sourceTree = "<group>"; };
503DD8D01926736A00CD74DD /* CCCommon-ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "CCCommon-ios.mm"; sourceTree = "<group>"; }; 503DD8D01926736A00CD74DD /* CCCommon-ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "CCCommon-ios.mm"; sourceTree = "<group>"; };
@ -6690,6 +6723,9 @@
50E6D33318E174130051CA34 /* UIVBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVBox.h; sourceTree = "<group>"; }; 50E6D33318E174130051CA34 /* UIVBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVBox.h; sourceTree = "<group>"; };
50ED2BDC19BEAF7900A0AB90 /* UIEditBoxImpl-win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIEditBoxImpl-win32.h"; sourceTree = "<group>"; }; 50ED2BDC19BEAF7900A0AB90 /* UIEditBoxImpl-win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIEditBoxImpl-win32.h"; sourceTree = "<group>"; };
50ED2BDE19BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "UIEditBoxImpl-win32.cpp"; sourceTree = "<group>"; }; 50ED2BDE19BEAF7900A0AB90 /* UIEditBoxImpl-win32.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "UIEditBoxImpl-win32.cpp"; sourceTree = "<group>"; };
50F9654E1CD0360000ADE813 /* CCVRGenericRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVRGenericRenderer.cpp; sourceTree = "<group>"; };
50F9654F1CD0360000ADE813 /* CCVRGenericRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVRGenericRenderer.h; sourceTree = "<group>"; };
50F965501CD0360000ADE813 /* CCVRProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVRProtocol.h; sourceTree = "<group>"; };
50FCEB6A18C72017004AD434 /* ButtonReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ButtonReader.cpp; sourceTree = "<group>"; }; 50FCEB6A18C72017004AD434 /* ButtonReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ButtonReader.cpp; sourceTree = "<group>"; };
50FCEB6B18C72017004AD434 /* ButtonReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonReader.h; sourceTree = "<group>"; }; 50FCEB6B18C72017004AD434 /* ButtonReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ButtonReader.h; sourceTree = "<group>"; };
50FCEB6D18C72017004AD434 /* CheckBoxReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CheckBoxReader.cpp; sourceTree = "<group>"; }; 50FCEB6D18C72017004AD434 /* CheckBoxReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CheckBoxReader.cpp; sourceTree = "<group>"; };
@ -7788,6 +7824,7 @@
1551A340158F2AB200E66CFE /* Products */, 1551A340158F2AB200E66CFE /* Products */,
500DC89819105D41007B91BF /* renderer */, 500DC89819105D41007B91BF /* renderer */,
1AAF5849180E40B8000584C8 /* storage */, 1AAF5849180E40B8000584C8 /* storage */,
50F9654D1CD0360000ADE813 /* vr */,
2905F9E618CF08D000240AA3 /* ui */, 2905F9E618CF08D000240AA3 /* ui */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
@ -9900,6 +9937,23 @@
path = apple; path = apple;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
50F9654D1CD0360000ADE813 /* vr */ = {
isa = PBXGroup;
children = (
502AF9771D0711B8006AF256 /* CCVRGenericHeadTracker.cpp */,
50F9654E1CD0360000ADE813 /* CCVRGenericRenderer.cpp */,
50F9654F1CD0360000ADE813 /* CCVRGenericRenderer.h */,
50F965501CD0360000ADE813 /* CCVRProtocol.h */,
503D4F611CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp */,
503D4F621CE29D4E0054A2D1 /* CCVRDistortionMesh.h */,
503D4F691CE2BDBE0054A2D1 /* CCVRDistortion.cpp */,
503D4F6A1CE2BDBE0054A2D1 /* CCVRDistortion.h */,
5030C03E1CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h */,
);
name = vr;
path = ../cocos/vr;
sourceTree = "<group>";
};
50FCEB6818C72017004AD434 /* WidgetReader */ = { 50FCEB6818C72017004AD434 /* WidgetReader */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@ -11378,6 +11432,7 @@
298C75D71C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */, 298C75D71C0465D1006BAE63 /* CCStencilStateManager.hpp in Headers */,
B6DD2FDB1B04825B00E47F5F /* DetourLocalBoundary.h in Headers */, B6DD2FDB1B04825B00E47F5F /* DetourLocalBoundary.h in Headers */,
B6CAB3491AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */, B6CAB3491AF9AA1A00B9B856 /* gim_clip_polygon.h in Headers */,
503D4F661CE29D4E0054A2D1 /* CCVRDistortionMesh.h in Headers */,
B677B0DB1B18492D006762CB /* CCNavMeshUtils.h in Headers */, B677B0DB1B18492D006762CB /* CCNavMeshUtils.h in Headers */,
B6CAAFE41AF9A9E100B9B856 /* CCPhysics3D.h in Headers */, B6CAAFE41AF9A9E100B9B856 /* CCPhysics3D.h in Headers */,
15AE1A7F19AAD40300C27E9E /* b2DistanceJoint.h in Headers */, 15AE1A7F19AAD40300C27E9E /* b2DistanceJoint.h in Headers */,
@ -11582,6 +11637,7 @@
B6CAB3271AF9AA1A00B9B856 /* btGImpactBvh.h in Headers */, B6CAB3271AF9AA1A00B9B856 /* btGImpactBvh.h in Headers */,
15AE198D19AAD36E00C27E9E /* CheckBoxReader.h in Headers */, 15AE198D19AAD36E00C27E9E /* CheckBoxReader.h in Headers */,
B29A7E0919EE1B7700872B35 /* AttachmentLoader.h in Headers */, B29A7E0919EE1B7700872B35 /* AttachmentLoader.h in Headers */,
50F965541CD0360000ADE813 /* CCVRGenericRenderer.h in Headers */,
1A01C68818F57BE800EFE3A6 /* CCBool.h in Headers */, 1A01C68818F57BE800EFE3A6 /* CCBool.h in Headers */,
B29A7E3319EE1B7700872B35 /* SlotData.h in Headers */, B29A7E3319EE1B7700872B35 /* SlotData.h in Headers */,
B665E2741AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.h in Headers */, B665E2741AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.h in Headers */,
@ -11852,6 +11908,7 @@
B6CAB3A51AF9AA1A00B9B856 /* btConeTwistConstraint.h in Headers */, B6CAB3A51AF9AA1A00B9B856 /* btConeTwistConstraint.h in Headers */,
15AE181E19AAD2F700C27E9E /* CCBundle3DData.h in Headers */, 15AE181E19AAD2F700C27E9E /* CCBundle3DData.h in Headers */,
1A5702F8180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */, 1A5702F8180BCE750088DEC7 /* CCTMXTiledMap.h in Headers */,
503D4F6E1CE2BDBE0054A2D1 /* CCVRDistortion.h in Headers */,
B665E2801AA80A6500DDB1C5 /* CCPUDoScaleEventHandlerTranslator.h in Headers */, B665E2801AA80A6500DDB1C5 /* CCPUDoScaleEventHandlerTranslator.h in Headers */,
5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */, 5034CA21191D591100CE6051 /* ccShader_PositionTextureColorAlphaTest.frag in Headers */,
D0FD03491A3B51AA00825BB5 /* CCAllocatorBase.h in Headers */, D0FD03491A3B51AA00825BB5 /* CCAllocatorBase.h in Headers */,
@ -11869,6 +11926,7 @@
15AE191019AAD35000C27E9E /* CCInputDelegate.h in Headers */, 15AE191019AAD35000C27E9E /* CCInputDelegate.h in Headers */,
B665E4301AA80A6600DDB1C5 /* CCPUVelocityMatchingAffectorTranslator.h in Headers */, B665E4301AA80A6600DDB1C5 /* CCPUVelocityMatchingAffectorTranslator.h in Headers */,
50864CA91C7BC1B000B3BAB1 /* cpDampedRotarySpring.h in Headers */, 50864CA91C7BC1B000B3BAB1 /* cpDampedRotarySpring.h in Headers */,
5030C0421CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h in Headers */,
15AE184C19AAD30800C27E9E /* SimpleAudioEngine.h in Headers */, 15AE184C19AAD30800C27E9E /* SimpleAudioEngine.h in Headers */,
50ABBDA11925AB4100A911A9 /* CCGroupCommand.h in Headers */, 50ABBDA11925AB4100A911A9 /* CCGroupCommand.h in Headers */,
50864C911C7BC1B000B3BAB1 /* chipmunk_private.h in Headers */, 50864C911C7BC1B000B3BAB1 /* chipmunk_private.h in Headers */,
@ -12186,6 +12244,7 @@
50ABBEB11925AB6F00A911A9 /* CCUserDefault.h in Headers */, 50ABBEB11925AB6F00A911A9 /* CCUserDefault.h in Headers */,
B29A7DEF19EE1B7700872B35 /* SkeletonBounds.h in Headers */, B29A7DEF19EE1B7700872B35 /* SkeletonBounds.h in Headers */,
D0FD034D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h in Headers */, D0FD034D1A3B51AA00825BB5 /* CCAllocatorDiagnostics.h in Headers */,
50F965571CD0360000ADE813 /* CCVRProtocol.h in Headers */,
50ABBEC71925AB6F00A911A9 /* etc1.h in Headers */, 50ABBEC71925AB6F00A911A9 /* etc1.h in Headers */,
B6CAB27B1AF9AA1A00B9B856 /* SphereTriangleDetector.h in Headers */, B6CAB27B1AF9AA1A00B9B856 /* SphereTriangleDetector.h in Headers */,
B29A7E3519EE1B7700872B35 /* AnimationStateData.h in Headers */, B29A7E3519EE1B7700872B35 /* AnimationStateData.h in Headers */,
@ -12337,6 +12396,7 @@
507B3D691C31BDD30067B53E /* CCPUDoPlacementParticleEventHandler.h in Headers */, 507B3D691C31BDD30067B53E /* CCPUDoPlacementParticleEventHandler.h in Headers */,
507B3D6A1C31BDD30067B53E /* gim_memory.h in Headers */, 507B3D6A1C31BDD30067B53E /* gim_memory.h in Headers */,
507B3D6B1C31BDD30067B53E /* btGpu3DGridBroadphaseSharedDefs.h in Headers */, 507B3D6B1C31BDD30067B53E /* btGpu3DGridBroadphaseSharedDefs.h in Headers */,
50F965561CD0360000ADE813 /* CCVRGenericRenderer.h in Headers */,
507B3D6C1C31BDD30067B53E /* b2Collision.h in Headers */, 507B3D6C1C31BDD30067B53E /* b2Collision.h in Headers */,
507B3D6D1C31BDD30067B53E /* CCPUOnVelocityObserver.h in Headers */, 507B3D6D1C31BDD30067B53E /* CCPUOnVelocityObserver.h in Headers */,
507B3D6E1C31BDD30067B53E /* btMultiBodyDynamicsWorld.h in Headers */, 507B3D6E1C31BDD30067B53E /* btMultiBodyDynamicsWorld.h in Headers */,
@ -12567,6 +12627,7 @@
507B3E461C31BDD30067B53E /* Bone.h in Headers */, 507B3E461C31BDD30067B53E /* Bone.h in Headers */,
507B3E471C31BDD30067B53E /* CCPUForceFieldAffectorTranslator.h in Headers */, 507B3E471C31BDD30067B53E /* CCPUForceFieldAffectorTranslator.h in Headers */,
507B3E481C31BDD30067B53E /* CCBillBoard.h in Headers */, 507B3E481C31BDD30067B53E /* CCBillBoard.h in Headers */,
5030C0441CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h in Headers */,
507B3E491C31BDD30067B53E /* CCTrianglesCommand.h in Headers */, 507B3E491C31BDD30067B53E /* CCTrianglesCommand.h in Headers */,
507B3E4A1C31BDD30067B53E /* CCPUDynamicAttributeTranslator.h in Headers */, 507B3E4A1C31BDD30067B53E /* CCPUDynamicAttributeTranslator.h in Headers */,
507B3E4B1C31BDD30067B53E /* btSequentialImpulseConstraintSolver.h in Headers */, 507B3E4B1C31BDD30067B53E /* btSequentialImpulseConstraintSolver.h in Headers */,
@ -13052,6 +13113,7 @@
507B401C1C31BDD30067B53E /* CCNinePatchImageParser.h in Headers */, 507B401C1C31BDD30067B53E /* CCNinePatchImageParser.h in Headers */,
507B401D1C31BDD30067B53E /* CCController.h in Headers */, 507B401D1C31BDD30067B53E /* CCController.h in Headers */,
507B401E1C31BDD30067B53E /* btGpuDefines.h in Headers */, 507B401E1C31BDD30067B53E /* btGpuDefines.h in Headers */,
503D4F701CE2BDBE0054A2D1 /* CCVRDistortion.h in Headers */,
507B401F1C31BDD30067B53E /* ComAudioReader.h in Headers */, 507B401F1C31BDD30067B53E /* ComAudioReader.h in Headers */,
507B40201C31BDD30067B53E /* CCGameController.h in Headers */, 507B40201C31BDD30067B53E /* CCGameController.h in Headers */,
507B40211C31BDD30067B53E /* boxBoxDistance.h in Headers */, 507B40211C31BDD30067B53E /* boxBoxDistance.h in Headers */,
@ -13083,6 +13145,7 @@
507B403A1C31BDD30067B53E /* CCTimeLine.h in Headers */, 507B403A1C31BDD30067B53E /* CCTimeLine.h in Headers */,
507B403B1C31BDD30067B53E /* UILayoutComponent.h in Headers */, 507B403B1C31BDD30067B53E /* UILayoutComponent.h in Headers */,
507B403C1C31BDD30067B53E /* btConvexConvexAlgorithm.h in Headers */, 507B403C1C31BDD30067B53E /* btConvexConvexAlgorithm.h in Headers */,
50F965591CD0360000ADE813 /* CCVRProtocol.h in Headers */,
507B403D1C31BDD30067B53E /* CCPUGravityAffectorTranslator.h in Headers */, 507B403D1C31BDD30067B53E /* CCPUGravityAffectorTranslator.h in Headers */,
507B403E1C31BDD30067B53E /* MathUtil.h in Headers */, 507B403E1C31BDD30067B53E /* MathUtil.h in Headers */,
507B403F1C31BDD30067B53E /* CCInteger.h in Headers */, 507B403F1C31BDD30067B53E /* CCInteger.h in Headers */,
@ -13115,6 +13178,7 @@
507B405A1C31BDD30067B53E /* CCPUDoFreezeEventHandler.h in Headers */, 507B405A1C31BDD30067B53E /* CCPUDoFreezeEventHandler.h in Headers */,
507B405B1C31BDD30067B53E /* CCGL.h in Headers */, 507B405B1C31BDD30067B53E /* CCGL.h in Headers */,
507B405C1C31BDD30067B53E /* CCArmatureAnimation.h in Headers */, 507B405C1C31BDD30067B53E /* CCArmatureAnimation.h in Headers */,
503D4F681CE29D4E0054A2D1 /* CCVRDistortionMesh.h in Headers */,
507B405D1C31BDD30067B53E /* b2ContactManager.h in Headers */, 507B405D1C31BDD30067B53E /* b2ContactManager.h in Headers */,
507B405E1C31BDD30067B53E /* CCVertexIndexData.h in Headers */, 507B405E1C31BDD30067B53E /* CCVertexIndexData.h in Headers */,
507B405F1C31BDD30067B53E /* Vec3.h in Headers */, 507B405F1C31BDD30067B53E /* Vec3.h in Headers */,
@ -13378,6 +13442,7 @@
B665E2751AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.h in Headers */, B665E2751AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.h in Headers */,
B6CAB35C1AF9AA1A00B9B856 /* gim_memory.h in Headers */, B6CAB35C1AF9AA1A00B9B856 /* gim_memory.h in Headers */,
B6CAB43A1AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedDefs.h in Headers */, B6CAB43A1AF9AA1A00B9B856 /* btGpu3DGridBroadphaseSharedDefs.h in Headers */,
50F965551CD0360000ADE813 /* CCVRGenericRenderer.h in Headers */,
15AE1A4019AAD3D500C27E9E /* b2Collision.h in Headers */, 15AE1A4019AAD3D500C27E9E /* b2Collision.h in Headers */,
B665E36D1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.h in Headers */, B665E36D1AA80A6500DDB1C5 /* CCPUOnVelocityObserver.h in Headers */,
B6CAB4061AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.h in Headers */, B6CAB4061AF9AA1A00B9B856 /* btMultiBodyDynamicsWorld.h in Headers */,
@ -13608,6 +13673,7 @@
B29A7E0E19EE1B7700872B35 /* Bone.h in Headers */, B29A7E0E19EE1B7700872B35 /* Bone.h in Headers */,
B665E2BD1AA80A6500DDB1C5 /* CCPUForceFieldAffectorTranslator.h in Headers */, B665E2BD1AA80A6500DDB1C5 /* CCPUForceFieldAffectorTranslator.h in Headers */,
B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */, B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */,
5030C0431CE6DF8B00C5D3E7 /* CCVRGenericHeadTracker.h in Headers */,
B230ED7419B417AE00364AA8 /* CCTrianglesCommand.h in Headers */, B230ED7419B417AE00364AA8 /* CCTrianglesCommand.h in Headers */,
B665E2911AA80A6500DDB1C5 /* CCPUDynamicAttributeTranslator.h in Headers */, B665E2911AA80A6500DDB1C5 /* CCPUDynamicAttributeTranslator.h in Headers */,
B6CAB3D01AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.h in Headers */, B6CAB3D01AF9AA1A00B9B856 /* btSequentialImpulseConstraintSolver.h in Headers */,
@ -14094,6 +14160,7 @@
291901441B05895600F8B4BA /* CCNinePatchImageParser.h in Headers */, 291901441B05895600F8B4BA /* CCNinePatchImageParser.h in Headers */,
3E6176691960F89B00DE83F5 /* CCController.h in Headers */, 3E6176691960F89B00DE83F5 /* CCController.h in Headers */,
B6CAB43E1AF9AA1A00B9B856 /* btGpuDefines.h in Headers */, B6CAB43E1AF9AA1A00B9B856 /* btGpuDefines.h in Headers */,
503D4F6F1CE2BDBE0054A2D1 /* CCVRDistortion.h in Headers */,
3823841D1A2590D2002C4610 /* ComAudioReader.h in Headers */, 3823841D1A2590D2002C4610 /* ComAudioReader.h in Headers */,
3E6176781960F89B00DE83F5 /* CCGameController.h in Headers */, 3E6176781960F89B00DE83F5 /* CCGameController.h in Headers */,
B6CAB4C81AF9AA1A00B9B856 /* boxBoxDistance.h in Headers */, B6CAB4C81AF9AA1A00B9B856 /* boxBoxDistance.h in Headers */,
@ -14125,6 +14192,7 @@
15AE198019AAD35700C27E9E /* CCTimeLine.h in Headers */, 15AE198019AAD35700C27E9E /* CCTimeLine.h in Headers */,
38B8E2E419E671D2002D7CE7 /* UILayoutComponent.h in Headers */, 38B8E2E419E671D2002D7CE7 /* UILayoutComponent.h in Headers */,
B6CAB2481AF9AA1A00B9B856 /* btConvexConvexAlgorithm.h in Headers */, B6CAB2481AF9AA1A00B9B856 /* btConvexConvexAlgorithm.h in Headers */,
50F965581CD0360000ADE813 /* CCVRProtocol.h in Headers */,
B665E2CD1AA80A6500DDB1C5 /* CCPUGravityAffectorTranslator.h in Headers */, B665E2CD1AA80A6500DDB1C5 /* CCPUGravityAffectorTranslator.h in Headers */,
50ABBD4F1925AB0000A911A9 /* MathUtil.h in Headers */, 50ABBD4F1925AB0000A911A9 /* MathUtil.h in Headers */,
1A01C69718F57BE800EFE3A6 /* CCInteger.h in Headers */, 1A01C69718F57BE800EFE3A6 /* CCInteger.h in Headers */,
@ -14157,6 +14225,7 @@
B665E26D1AA80A6500DDB1C5 /* CCPUDoFreezeEventHandler.h in Headers */, B665E26D1AA80A6500DDB1C5 /* CCPUDoFreezeEventHandler.h in Headers */,
50643BD519BFAECF00EF68ED /* CCGL.h in Headers */, 50643BD519BFAECF00EF68ED /* CCGL.h in Headers */,
15AE193919AAD35100C27E9E /* CCArmatureAnimation.h in Headers */, 15AE193919AAD35100C27E9E /* CCArmatureAnimation.h in Headers */,
503D4F671CE29D4E0054A2D1 /* CCVRDistortionMesh.h in Headers */,
15AE1AA419AAD40300C27E9E /* b2ContactManager.h in Headers */, 15AE1AA419AAD40300C27E9E /* b2ContactManager.h in Headers */,
B276EF601988D1D500CD400F /* CCVertexIndexData.h in Headers */, B276EF601988D1D500CD400F /* CCVertexIndexData.h in Headers */,
50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */, 50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */,
@ -14429,6 +14498,7 @@
B6CAB2811AF9AA1A00B9B856 /* btBoxShape.cpp in Sources */, B6CAB2811AF9AA1A00B9B856 /* btBoxShape.cpp in Sources */,
50ABBE311925AB6F00A911A9 /* CCConfiguration.cpp in Sources */, 50ABBE311925AB6F00A911A9 /* CCConfiguration.cpp in Sources */,
B665E3821AA80A6500DDB1C5 /* CCPUPathFollower.cpp in Sources */, B665E3821AA80A6500DDB1C5 /* CCPUPathFollower.cpp in Sources */,
502AF9781D0711B8006AF256 /* CCVRGenericHeadTracker.cpp in Sources */,
1A01C6A418F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */, 1A01C6A418F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */,
15AE1A5D19AAD40300C27E9E /* b2Body.cpp in Sources */, 15AE1A5D19AAD40300C27E9E /* b2Body.cpp in Sources */,
15AE1BDA19AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */, 15AE1BDA19AAE01E00C27E9E /* CCControlSwitch.cpp in Sources */,
@ -14562,6 +14632,7 @@
382383F81A258FA7002C4610 /* idl_gen_general.cpp in Sources */, 382383F81A258FA7002C4610 /* idl_gen_general.cpp in Sources */,
15AE1C1319AAE2C600C27E9E /* CCPhysicsSprite.cpp in Sources */, 15AE1C1319AAE2C600C27E9E /* CCPhysicsSprite.cpp in Sources */,
382384131A259092002C4610 /* NodeReaderProtocol.cpp in Sources */, 382384131A259092002C4610 /* NodeReaderProtocol.cpp in Sources */,
503D4F6B1CE2BDBE0054A2D1 /* CCVRDistortion.cpp in Sources */,
B665E2C21AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.cpp in Sources */, B665E2C21AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.cpp in Sources */,
15AE1A5F19AAD40300C27E9E /* b2ContactManager.cpp in Sources */, 15AE1A5F19AAD40300C27E9E /* b2ContactManager.cpp in Sources */,
B6CAB2451AF9AA1A00B9B856 /* btConvexConvexAlgorithm.cpp in Sources */, B6CAB2451AF9AA1A00B9B856 /* btConvexConvexAlgorithm.cpp in Sources */,
@ -14837,6 +14908,7 @@
1A570286180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */, 1A570286180BCC900088DEC7 /* CCSpriteFrame.cpp in Sources */,
B24AA989195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */, B24AA989195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */,
B6CAB4DF1AF9AA1A00B9B856 /* SpuSampleTask.cpp in Sources */, B6CAB4DF1AF9AA1A00B9B856 /* SpuSampleTask.cpp in Sources */,
50F965511CD0360000ADE813 /* CCVRGenericRenderer.cpp in Sources */,
B29A7E2F19EE1B7700872B35 /* SkeletonAnimation.cpp in Sources */, B29A7E2F19EE1B7700872B35 /* SkeletonAnimation.cpp in Sources */,
B60C5BD419AC68B10056FBDE /* CCBillBoard.cpp in Sources */, B60C5BD419AC68B10056FBDE /* CCBillBoard.cpp in Sources */,
15AE199619AAD39600C27E9E /* ListViewReader.cpp in Sources */, 15AE199619AAD39600C27E9E /* ListViewReader.cpp in Sources */,
@ -15107,6 +15179,7 @@
B68778F81A8CA82E00643ABF /* CCParticle3DAffector.cpp in Sources */, B68778F81A8CA82E00643ABF /* CCParticle3DAffector.cpp in Sources */,
15AE19A019AAD39600C27E9E /* TextAtlasReader.cpp in Sources */, 15AE19A019AAD39600C27E9E /* TextAtlasReader.cpp in Sources */,
15AE1A2A19AAD3D500C27E9E /* b2Distance.cpp in Sources */, 15AE1A2A19AAD3D500C27E9E /* b2Distance.cpp in Sources */,
503D4F631CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp in Sources */,
50ABBE6D1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */, 50ABBE6D1925AB6F00A911A9 /* CCEventListenerKeyboard.cpp in Sources */,
15FB20871AE7C57D00C31518 /* shapes.cc in Sources */, 15FB20871AE7C57D00C31518 /* shapes.cc in Sources */,
B665E27A1AA80A6500DDB1C5 /* CCPUDoScaleEventHandler.cpp in Sources */, B665E27A1AA80A6500DDB1C5 /* CCPUDoScaleEventHandler.cpp in Sources */,
@ -15276,6 +15349,7 @@
507B39D01C31BDD30067B53E /* CCSet.cpp in Sources */, 507B39D01C31BDD30067B53E /* CCSet.cpp in Sources */,
507B39D11C31BDD30067B53E /* CCString.cpp in Sources */, 507B39D11C31BDD30067B53E /* CCString.cpp in Sources */,
507B39D21C31BDD30067B53E /* sweep.cc in Sources */, 507B39D21C31BDD30067B53E /* sweep.cc in Sources */,
502AF97A1D0711CA006AF256 /* CCVRGenericHeadTracker.cpp in Sources */,
507B39D31C31BDD30067B53E /* ImageViewReader.cpp in Sources */, 507B39D31C31BDD30067B53E /* ImageViewReader.cpp in Sources */,
507B39D41C31BDD30067B53E /* btGeneric6DofSpringConstraint.cpp in Sources */, 507B39D41C31BDD30067B53E /* btGeneric6DofSpringConstraint.cpp in Sources */,
507B39D51C31BDD30067B53E /* CCPUAffectorManager.cpp in Sources */, 507B39D51C31BDD30067B53E /* CCPUAffectorManager.cpp in Sources */,
@ -15409,6 +15483,7 @@
507B3A551C31BDD30067B53E /* CCArmatureDefine.cpp in Sources */, 507B3A551C31BDD30067B53E /* CCArmatureDefine.cpp in Sources */,
507B3A561C31BDD30067B53E /* CCPUOnRandomObserverTranslator.cpp in Sources */, 507B3A561C31BDD30067B53E /* CCPUOnRandomObserverTranslator.cpp in Sources */,
507B3A571C31BDD30067B53E /* CCMeshCommand.cpp in Sources */, 507B3A571C31BDD30067B53E /* CCMeshCommand.cpp in Sources */,
503D4F6D1CE2BDBE0054A2D1 /* CCVRDistortion.cpp in Sources */,
507B3A581C31BDD30067B53E /* CCStencilStateManager.cpp in Sources */, 507B3A581C31BDD30067B53E /* CCStencilStateManager.cpp in Sources */,
507B3A591C31BDD30067B53E /* CCComRender.cpp in Sources */, 507B3A591C31BDD30067B53E /* CCComRender.cpp in Sources */,
507B3A5A1C31BDD30067B53E /* SpriteReader.cpp in Sources */, 507B3A5A1C31BDD30067B53E /* SpriteReader.cpp in Sources */,
@ -15684,6 +15759,7 @@
507B3B681C31BDD30067B53E /* btGpu3DGridBroadphase.cpp in Sources */, 507B3B681C31BDD30067B53E /* btGpu3DGridBroadphase.cpp in Sources */,
507B3B691C31BDD30067B53E /* CCDecorativeDisplay.cpp in Sources */, 507B3B691C31BDD30067B53E /* CCDecorativeDisplay.cpp in Sources */,
507B3B6A1C31BDD30067B53E /* TextReader.cpp in Sources */, 507B3B6A1C31BDD30067B53E /* TextReader.cpp in Sources */,
50F965531CD0360000ADE813 /* CCVRGenericRenderer.cpp in Sources */,
507B3B6B1C31BDD30067B53E /* Mat4.cpp in Sources */, 507B3B6B1C31BDD30067B53E /* Mat4.cpp in Sources */,
507B3B6C1C31BDD30067B53E /* CCClippingNode.cpp in Sources */, 507B3B6C1C31BDD30067B53E /* CCClippingNode.cpp in Sources */,
507B3B6D1C31BDD30067B53E /* UIButton.cpp in Sources */, 507B3B6D1C31BDD30067B53E /* UIButton.cpp in Sources */,
@ -15953,6 +16029,7 @@
507B3C741C31BDD30067B53E /* CCPUPlaneColliderTranslator.cpp in Sources */, 507B3C741C31BDD30067B53E /* CCPUPlaneColliderTranslator.cpp in Sources */,
507B3C751C31BDD30067B53E /* idl_gen_fbs.cpp in Sources */, 507B3C751C31BDD30067B53E /* idl_gen_fbs.cpp in Sources */,
507B3C761C31BDD30067B53E /* UIPageViewIndicator.cpp in Sources */, 507B3C761C31BDD30067B53E /* UIPageViewIndicator.cpp in Sources */,
503D4F651CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp in Sources */,
507B3C771C31BDD30067B53E /* CCPUColorAffector.cpp in Sources */, 507B3C771C31BDD30067B53E /* CCPUColorAffector.cpp in Sources */,
507B3C781C31BDD30067B53E /* CCPUBaseForceAffector.cpp in Sources */, 507B3C781C31BDD30067B53E /* CCPUBaseForceAffector.cpp in Sources */,
507B3C791C31BDD30067B53E /* UILoadingBar.cpp in Sources */, 507B3C791C31BDD30067B53E /* UILoadingBar.cpp in Sources */,
@ -16122,6 +16199,7 @@
1A01C69918F57BE800EFE3A6 /* CCSet.cpp in Sources */, 1A01C69918F57BE800EFE3A6 /* CCSet.cpp in Sources */,
1A01C69D18F57BE800EFE3A6 /* CCString.cpp in Sources */, 1A01C69D18F57BE800EFE3A6 /* CCString.cpp in Sources */,
15FB20981AE7C57D00C31518 /* sweep.cc in Sources */, 15FB20981AE7C57D00C31518 /* sweep.cc in Sources */,
502AF9791D0711C9006AF256 /* CCVRGenericHeadTracker.cpp in Sources */,
15AE199219AAD37300C27E9E /* ImageViewReader.cpp in Sources */, 15AE199219AAD37300C27E9E /* ImageViewReader.cpp in Sources */,
B6CAB3BC1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.cpp in Sources */, B6CAB3BC1AF9AA1A00B9B856 /* btGeneric6DofSpringConstraint.cpp in Sources */,
B665E1F71AA80A6500DDB1C5 /* CCPUAffectorManager.cpp in Sources */, B665E1F71AA80A6500DDB1C5 /* CCPUAffectorManager.cpp in Sources */,
@ -16255,6 +16333,7 @@
15AE193C19AAD35100C27E9E /* CCArmatureDefine.cpp in Sources */, 15AE193C19AAD35100C27E9E /* CCArmatureDefine.cpp in Sources */,
B665E35F1AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.cpp in Sources */, B665E35F1AA80A6500DDB1C5 /* CCPUOnRandomObserverTranslator.cpp in Sources */,
B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */, B29594B51926D5EC003EEF37 /* CCMeshCommand.cpp in Sources */,
503D4F6C1CE2BDBE0054A2D1 /* CCVRDistortion.cpp in Sources */,
298C75D61C0465D1006BAE63 /* CCStencilStateManager.cpp in Sources */, 298C75D61C0465D1006BAE63 /* CCStencilStateManager.cpp in Sources */,
15AE194B19AAD35100C27E9E /* CCComRender.cpp in Sources */, 15AE194B19AAD35100C27E9E /* CCComRender.cpp in Sources */,
382384451A25915C002C4610 /* SpriteReader.cpp in Sources */, 382384451A25915C002C4610 /* SpriteReader.cpp in Sources */,
@ -16530,6 +16609,7 @@
B6CAB4341AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */, B6CAB4341AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */,
15AE195119AAD35100C27E9E /* CCDecorativeDisplay.cpp in Sources */, 15AE195119AAD35100C27E9E /* CCDecorativeDisplay.cpp in Sources */,
15AE19BA19AAD39700C27E9E /* TextReader.cpp in Sources */, 15AE19BA19AAD39700C27E9E /* TextReader.cpp in Sources */,
50F965521CD0360000ADE813 /* CCVRGenericRenderer.cpp in Sources */,
50ABBD491925AB0000A911A9 /* Mat4.cpp in Sources */, 50ABBD491925AB0000A911A9 /* Mat4.cpp in Sources */,
1A570203180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */, 1A570203180BCBD40088DEC7 /* CCClippingNode.cpp in Sources */,
15AE1B8619AADA9A00C27E9E /* UIButton.cpp in Sources */, 15AE1B8619AADA9A00C27E9E /* UIButton.cpp in Sources */,
@ -16800,6 +16880,7 @@
B665E3931AA80A6500DDB1C5 /* CCPUPlaneColliderTranslator.cpp in Sources */, B665E3931AA80A6500DDB1C5 /* CCPUPlaneColliderTranslator.cpp in Sources */,
382383F71A258FA7002C4610 /* idl_gen_fbs.cpp in Sources */, 382383F71A258FA7002C4610 /* idl_gen_fbs.cpp in Sources */,
B5A738971BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */, B5A738971BB0051F00BAAEF8 /* UIPageViewIndicator.cpp in Sources */,
503D4F641CE29D4E0054A2D1 /* CCVRDistortionMesh.cpp in Sources */,
B665E24B1AA80A6500DDB1C5 /* CCPUColorAffector.cpp in Sources */, B665E24B1AA80A6500DDB1C5 /* CCPUColorAffector.cpp in Sources */,
B665E20F1AA80A6500DDB1C5 /* CCPUBaseForceAffector.cpp in Sources */, B665E20F1AA80A6500DDB1C5 /* CCPUBaseForceAffector.cpp in Sources */,
15AE1B7419AADA9A00C27E9E /* UILoadingBar.cpp in Sources */, 15AE1B7419AADA9A00C27E9E /* UILoadingBar.cpp in Sources */,

View File

@ -41,16 +41,7 @@ NS_CC_BEGIN
Camera* Camera::_visitingCamera = nullptr; Camera* Camera::_visitingCamera = nullptr;
experimental::Viewport Camera::_defaultViewport; experimental::Viewport Camera::_defaultViewport;
Camera* Camera::getDefaultCamera() // start static methods
{
auto scene = Director::getInstance()->getRunningScene();
if(scene)
{
return scene->getDefaultCamera();
}
return nullptr;
}
Camera* Camera::create() Camera* Camera::create()
{ {
@ -88,6 +79,33 @@ Camera* Camera::createOrthographic(float zoomX, float zoomY, float nearPlane, fl
return nullptr; return nullptr;
} }
Camera* Camera::getDefaultCamera()
{
auto scene = Director::getInstance()->getRunningScene();
if(scene)
{
return scene->getDefaultCamera();
}
return nullptr;
}
const experimental::Viewport& Camera::getDefaultViewport()
{
return _defaultViewport;
}
void Camera::setDefaultViewport(const experimental::Viewport& vp)
{
_defaultViewport = vp;
}
const Camera* Camera::getVisitingCamera()
{
return _visitingCamera;
}
// end static methods
Camera::Camera() Camera::Camera()
: _scene(nullptr) : _scene(nullptr)
, _viewProjectionDirty(true) , _viewProjectionDirty(true)
@ -421,11 +439,19 @@ void Camera::setFrameBufferObject(experimental::FrameBuffer *fbo)
} }
} }
void Camera::apply()
{
applyFrameBufferObject();
applyViewport();
}
void Camera::applyFrameBufferObject() void Camera::applyFrameBufferObject()
{ {
if(nullptr == _fbo) if(nullptr == _fbo)
{ {
experimental::FrameBuffer::applyDefaultFBO(); // inherit from context if it doesn't have a FBO
// don't call apply the default one
// experimental::FrameBuffer::applyDefaultFBO();
} }
else else
{ {
@ -433,14 +459,10 @@ void Camera::applyFrameBufferObject()
} }
} }
void Camera::apply()
{
applyFrameBufferObject();
applyViewport();
}
void Camera::applyViewport() void Camera::applyViewport()
{ {
glGetIntegerv(GL_VIEWPORT, _oldViewport);
if(nullptr == _fbo) if(nullptr == _fbo)
{ {
glViewport(getDefaultViewport()._left, getDefaultViewport()._bottom, getDefaultViewport()._width, getDefaultViewport()._height); glViewport(getDefaultViewport()._left, getDefaultViewport()._bottom, getDefaultViewport()._width, getDefaultViewport()._height);
@ -450,7 +472,36 @@ void Camera::applyViewport()
glViewport(_viewport._left * _fbo->getWidth(), _viewport._bottom * _fbo->getHeight(), glViewport(_viewport._left * _fbo->getWidth(), _viewport._bottom * _fbo->getHeight(),
_viewport._width * _fbo->getWidth(), _viewport._height * _fbo->getHeight()); _viewport._width * _fbo->getWidth(), _viewport._height * _fbo->getHeight());
} }
}
void Camera::setViewport(const experimental::Viewport& vp)
{
_viewport = vp;
}
void Camera::restore()
{
restoreFrameBufferObject();
restoreViewport();
}
void Camera::restoreFrameBufferObject()
{
if(nullptr == _fbo)
{
// it was inherited from context if it doesn't have a FBO
// don't call restore the default one... just keep using the previous one
// experimental::FrameBuffer::applyDefaultFBO();
}
else
{
_fbo->restoreFBO();
}
}
void Camera::restoreViewport()
{
glViewport(_oldViewport[0], _oldViewport[1], _oldViewport[2], _oldViewport[3]);
} }
int Camera::getRenderOrder() const int Camera::getRenderOrder() const

View File

@ -99,6 +99,19 @@ public:
/** create default camera, the camera type depends on Director::getProjection, the depth of the default camera is 0 */ /** create default camera, the camera type depends on Director::getProjection, the depth of the default camera is 0 */
static Camera* create(); static Camera* create();
/**
* Get the visiting camera , the visiting camera shall be set on Scene::render
*/
static const Camera* getVisitingCamera();
static const experimental::Viewport& getDefaultViewport();
static void setDefaultViewport(const experimental::Viewport& vp);
/**
* Get the default camera of the current running scene.
*/
static Camera* getDefaultCamera();
/** /**
* Gets the type of camera. * Gets the type of camera.
* *
@ -227,15 +240,6 @@ public:
virtual void onEnter() override; virtual void onEnter() override;
virtual void onExit() override; virtual void onExit() override;
/**
* Get the visiting camera , the visiting camera shall be set on Scene::render
*/
static const Camera* getVisitingCamera() { return _visitingCamera; }
/**
* Get the default camera of the current running scene.
*/
static Camera* getDefaultCamera();
/** /**
Before rendering scene with this camera, the background need to be cleared. It clears the depth buffer with max depth by default. Use setBackgroundBrush to modify the default behavior Before rendering scene with this camera, the background need to be cleared. It clears the depth buffer with max depth by default. Use setBackgroundBrush to modify the default behavior
*/ */
@ -244,6 +248,11 @@ public:
Apply the FBO, RenderTargets and viewport. Apply the FBO, RenderTargets and viewport.
*/ */
void apply(); void apply();
/**
Restor the FBO, RenderTargets and viewport.
*/
void restore();
/** /**
Set FBO, which will attach several render target for the rendered result. Set FBO, which will attach several render target for the rendered result.
*/ */
@ -251,7 +260,7 @@ public:
/** /**
Set Viewport for camera. Set Viewport for camera.
*/ */
void setViewport(const experimental::Viewport& vp) { _viewport = vp; } void setViewport(const experimental::Viewport& vp);
/** /**
* Whether or not the viewprojection matrix was updated since the last frame. * Whether or not the viewprojection matrix was updated since the last frame.
@ -292,13 +301,19 @@ CC_CONSTRUCTOR_ACCESS:
bool initOrthographic(float zoomX, float zoomY, float nearPlane, float farPlane); bool initOrthographic(float zoomX, float zoomY, float nearPlane, float farPlane);
void applyFrameBufferObject(); void applyFrameBufferObject();
void applyViewport(); void applyViewport();
void restoreFrameBufferObject();
void restoreViewport();
protected: protected:
static Camera* _visitingCamera;
static experimental::Viewport _defaultViewport;
Scene* _scene; //Scene camera belongs to Scene* _scene; //Scene camera belongs to
Mat4 _projection; Mat4 _projection;
mutable Mat4 _view; mutable Mat4 _view;
mutable Mat4 _viewInv; mutable Mat4 _viewInv;
mutable Mat4 _viewProjection; mutable Mat4 _viewProjection;
Vec3 _up; Vec3 _up;
Camera::Type _type; Camera::Type _type;
float _fieldOfView; float _fieldOfView;
@ -312,18 +327,12 @@ protected:
mutable Frustum _frustum; // camera frustum mutable Frustum _frustum; // camera frustum
mutable bool _frustumDirty; mutable bool _frustumDirty;
int8_t _depth; //camera depth, the depth of camera with CameraFlag::DEFAULT flag is 0 by default, a camera with larger depth is drawn on top of camera with smaller depth int8_t _depth; //camera depth, the depth of camera with CameraFlag::DEFAULT flag is 0 by default, a camera with larger depth is drawn on top of camera with smaller depth
static Camera* _visitingCamera;
CameraBackgroundBrush* _clearBrush; //brush used to clear the back ground CameraBackgroundBrush* _clearBrush; //brush used to clear the back ground
experimental::Viewport _viewport; experimental::Viewport _viewport;
experimental::FrameBuffer* _fbo; experimental::FrameBuffer* _fbo;
protected: GLint _oldViewport[4];
static experimental::Viewport _defaultViewport;
public:
static const experimental::Viewport& getDefaultViewport() { return _defaultViewport; }
static void setDefaultViewport(const experimental::Viewport& vp) { _defaultViewport = vp; }
}; };
NS_CC_END NS_CC_END

View File

@ -1788,6 +1788,7 @@ void Node::setAdditionalTransform(Mat4* additionalTransform)
if (additionalTransform == nullptr) if (additionalTransform == nullptr)
{ {
_useAdditionalTransform = false; _useAdditionalTransform = false;
_additionalTransform = Mat4::IDENTITY;
} }
else else
{ {
@ -1797,6 +1798,12 @@ void Node::setAdditionalTransform(Mat4* additionalTransform)
_transformUpdated = _transformDirty = _inverseDirty = true; _transformUpdated = _transformDirty = _inverseDirty = true;
} }
void Node::setAdditionalTransform(const Mat4& additionalTransform)
{
_useAdditionalTransform = true;
_additionalTransform = additionalTransform;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
AffineTransform Node::getParentToNodeAffineTransform() const AffineTransform Node::getParentToNodeAffineTransform() const
{ {

View File

@ -1644,6 +1644,7 @@ public:
* @param additionalTransform An additional transform matrix. * @param additionalTransform An additional transform matrix.
*/ */
void setAdditionalTransform(Mat4* additionalTransform); void setAdditionalTransform(Mat4* additionalTransform);
void setAdditionalTransform(const Mat4& additionalTransform);
void setAdditionalTransform(const AffineTransform& additionalTransform); void setAdditionalTransform(const AffineTransform& additionalTransform);
/// @} end of Coordinate Converters /// @} end of Coordinate Converters

View File

@ -184,7 +184,7 @@ const std::vector<Camera*>& Scene::getCameras()
return _cameras; return _cameras;
} }
void Scene::render(Renderer* renderer) void Scene::render(Renderer* renderer, const Mat4& eyeTransform, const Mat4* eyeProjection)
{ {
auto director = Director::getInstance(); auto director = Director::getInstance();
Camera* defaultCamera = nullptr; Camera* defaultCamera = nullptr;
@ -201,6 +201,18 @@ void Scene::render(Renderer* renderer)
defaultCamera = Camera::_visitingCamera; defaultCamera = Camera::_visitingCamera;
} }
// There are two ways to modify the "default camera" with the eye Transform:
// a) modify the "nodeToParentTransform" matrix
// b) modify the "additional transform" matrix
// both alternatives are correct, if the user manually modifies the camera with a camera->setPosition()
// then the "nodeToParent transform" will be lost.
// And it is important that the change is "permament", because the matrix might be used for calculate
// culling and other stuff.
if (eyeProjection)
camera->setAdditionalProjection(*eyeProjection * camera->getProjectionMatrix().getInversed());
else
camera->setAdditionalTransform(eyeTransform.getInversed());
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, Camera::_visitingCamera->getViewProjectionMatrix()); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, Camera::_visitingCamera->getViewProjectionMatrix());
camera->apply(); camera->apply();
@ -216,8 +228,13 @@ void Scene::render(Renderer* renderer)
#endif #endif
renderer->render(); renderer->render();
camera->restore();
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
// we shouldn't restore the transform matrix since it could be used
// from "update" or other parts of the game to calculate culling or something else.
// camera->setNodeToParentTransform(eyeCopy);
} }
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
@ -232,7 +249,7 @@ void Scene::render(Renderer* renderer)
#endif #endif
Camera::_visitingCamera = nullptr; Camera::_visitingCamera = nullptr;
experimental::FrameBuffer::applyDefaultFBO(); // experimental::FrameBuffer::applyDefaultFBO();
} }
void Scene::removeAllChildren() void Scene::removeAllChildren()

View File

@ -109,7 +109,7 @@ public:
* @param renderer The renderer use to render the scene. * @param renderer The renderer use to render the scene.
* @js NA * @js NA
*/ */
virtual void render(Renderer* renderer); virtual void render(Renderer* renderer, const Mat4& eyeTransform, const Mat4* eyeProjection = nullptr);
/** override function */ /** override function */
virtual void removeAllChildren() override; virtual void removeAllChildren() override;

View File

@ -463,7 +463,7 @@ void Sprite::setVertexRect(const Rect& rect)
_rect = rect; _rect = rect;
} }
void Sprite::setTextureCoords(Rect rect) void Sprite::setTextureCoords(const Rect& rectInPoint)
{ {
Texture2D *tex = _batchNode ? _textureAtlas->getTexture() : _texture; Texture2D *tex = _batchNode ? _textureAtlas->getTexture() : _texture;
if (tex == nullptr) if (tex == nullptr)
@ -471,7 +471,7 @@ void Sprite::setTextureCoords(Rect rect)
return; return;
} }
rect = CC_RECT_POINTS_TO_PIXELS(rect); auto rectInPixels = CC_RECT_POINTS_TO_PIXELS(rectInPoint);
float atlasWidth = (float)tex->getPixelsWide(); float atlasWidth = (float)tex->getPixelsWide();
float atlasHeight = (float)tex->getPixelsHigh(); float atlasHeight = (float)tex->getPixelsHigh();
@ -481,15 +481,15 @@ void Sprite::setTextureCoords(Rect rect)
if (_rectRotated) if (_rectRotated)
{ {
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
left = (2*rect.origin.x+1)/(2*atlasWidth); left = (2*rectInPixels.origin.x+1)/(2*atlasWidth);
right = left+(rect.size.height*2-2)/(2*atlasWidth); right = left+(rectInPixels.size.height*2-2)/(2*atlasWidth);
top = (2*rect.origin.y+1)/(2*atlasHeight); top = (2*rectInPixels.origin.y+1)/(2*atlasHeight);
bottom = top+(rect.size.width*2-2)/(2*atlasHeight); bottom = top+(rectInPixels.size.width*2-2)/(2*atlasHeight);
#else #else
left = rect.origin.x/atlasWidth; left = rectInPixels.origin.x/atlasWidth;
right = (rect.origin.x+rect.size.height) / atlasWidth; right = (rectInPixels.origin.x+rectInPixels.size.height) / atlasWidth;
top = rect.origin.y/atlasHeight; top = rectInPixels.origin.y/atlasHeight;
bottom = (rect.origin.y+rect.size.width) / atlasHeight; bottom = (rectInPixels.origin.y+rectInPixels.size.width) / atlasHeight;
#endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL #endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
if (_flippedX) if (_flippedX)
@ -514,15 +514,15 @@ void Sprite::setTextureCoords(Rect rect)
else else
{ {
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
left = (2*rect.origin.x+1)/(2*atlasWidth); left = (2*rectInPixels.origin.x+1)/(2*atlasWidth);
right = left + (rect.size.width*2-2)/(2*atlasWidth); right = left + (rectInPixels.size.width*2-2)/(2*atlasWidth);
top = (2*rect.origin.y+1)/(2*atlasHeight); top = (2*rectInPixels.origin.y+1)/(2*atlasHeight);
bottom = top + (rect.size.height*2-2)/(2*atlasHeight); bottom = top + (rectInPixels.size.height*2-2)/(2*atlasHeight);
#else #else
left = rect.origin.x/atlasWidth; left = rectInPixels.origin.x/atlasWidth;
right = (rect.origin.x + rect.size.width) / atlasWidth; right = (rectInPixels.origin.x + rectInPixels.size.width) / atlasWidth;
top = rect.origin.y/atlasHeight; top = rectInPixels.origin.y/atlasHeight;
bottom = (rect.origin.y + rect.size.height) / atlasHeight; bottom = (rectInPixels.origin.y + rectInPixels.size.height) / atlasHeight;
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL #endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
if(_flippedX) if(_flippedX)

View File

@ -585,7 +585,7 @@ CC_CONSTRUCTOR_ACCESS :
protected: protected:
void updateColor() override; void updateColor() override;
virtual void setTextureCoords(Rect rect); virtual void setTextureCoords(const Rect& rect);
virtual void updateBlendFunc(); virtual void updateBlendFunc();
virtual void setReorderChildDirtyRecursively(); virtual void setReorderChildDirtyRecursively();
virtual void setDirtyRecursively(bool value); virtual void setDirtyRecursively(bool value);

View File

@ -670,6 +670,10 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClCompile Include="..\ui\UIVBox.cpp" /> <ClCompile Include="..\ui\UIVBox.cpp" />
<ClCompile Include="..\ui\UIWebView.cpp" /> <ClCompile Include="..\ui\UIWebView.cpp" />
<ClCompile Include="..\ui\UIWidget.cpp" /> <ClCompile Include="..\ui\UIWidget.cpp" />
<ClCompile Include="..\vr\CCVRDistortion.cpp" />
<ClCompile Include="..\vr\CCVRDistortionMesh.cpp" />
<ClCompile Include="..\vr\CCVRGenericHeadTracker.cpp" />
<ClCompile Include="..\vr\CCVRGenericRenderer.cpp" />
<ClCompile Include="CCAction.cpp" /> <ClCompile Include="CCAction.cpp" />
<ClCompile Include="CCActionCamera.cpp" /> <ClCompile Include="CCActionCamera.cpp" />
<ClCompile Include="CCActionCatmullRom.cpp" /> <ClCompile Include="CCActionCatmullRom.cpp" />
@ -1295,6 +1299,11 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
<ClInclude Include="..\ui\UIWebView-inl.h" /> <ClInclude Include="..\ui\UIWebView-inl.h" />
<ClInclude Include="..\ui\UIWebView.h" /> <ClInclude Include="..\ui\UIWebView.h" />
<ClInclude Include="..\ui\UIWidget.h" /> <ClInclude Include="..\ui\UIWidget.h" />
<ClInclude Include="..\vr\CCVRDistortion.h" />
<ClInclude Include="..\vr\CCVRDistortionMesh.h" />
<ClInclude Include="..\vr\CCVRGenericHeadTracker.h" />
<ClInclude Include="..\vr\CCVRGenericRenderer.h" />
<ClInclude Include="..\vr\CCVRProtocol.h" />
<ClInclude Include="CCAction.h" /> <ClInclude Include="CCAction.h" />
<ClInclude Include="CCActionCamera.h" /> <ClInclude Include="CCActionCamera.h" />
<ClInclude Include="CCActionCatmullRom.h" /> <ClInclude Include="CCActionCatmullRom.h" />

View File

@ -286,6 +286,9 @@
<Filter Include="cocostudio\reader\WidgetReader\TabControlReader"> <Filter Include="cocostudio\reader\WidgetReader\TabControlReader">
<UniqueIdentifier>{8686c220-18af-4bea-abce-f4797afd01f1}</UniqueIdentifier> <UniqueIdentifier>{8686c220-18af-4bea-abce-f4797afd01f1}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="vr">
<UniqueIdentifier>{5cbd879f-02ae-4f28-af33-2c4f980dd6f0}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\physics\CCPhysicsBody.cpp"> <ClCompile Include="..\physics\CCPhysicsBody.cpp">
@ -1953,6 +1956,18 @@
<ClCompile Include="..\editor-support\cocostudio\LocalizationManager.cpp"> <ClCompile Include="..\editor-support\cocostudio\LocalizationManager.cpp">
<Filter>cocostudio\json</Filter> <Filter>cocostudio\json</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\vr\CCVRDistortion.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="..\vr\CCVRDistortionMesh.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="..\vr\CCVRGenericHeadTracker.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="..\vr\CCVRGenericRenderer.cpp">
<Filter>vr</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\physics\CCPhysicsBody.h"> <ClInclude Include="..\physics\CCPhysicsBody.h">
@ -3815,6 +3830,21 @@
<ClInclude Include="..\editor-support\cocostudio\LocalizationManager.h"> <ClInclude Include="..\editor-support\cocostudio\LocalizationManager.h">
<Filter>cocostudio\json</Filter> <Filter>cocostudio\json</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\vr\CCVRProtocol.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="..\vr\CCVRDistortion.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="..\vr\CCVRDistortionMesh.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="..\vr\CCVRGenericHeadTracker.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="..\vr\CCVRGenericRenderer.h">
<Filter>vr</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\math\Mat4.inl"> <None Include="..\math\Mat4.inl">

View File

@ -572,6 +572,10 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UITextField.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UITextField.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIVBox.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIVBox.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIWidget.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIWidget.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRDistortion.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRDistortionMesh.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRGenericHeadTracker.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRGenericRenderer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAction.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAction.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCActionCamera.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCActionCamera.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCActionCatmullRom.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCActionCatmullRom.h" />
@ -1175,6 +1179,10 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UITextField.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UITextField.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIVBox.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIVBox.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIWidget.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIWidget.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRDistortion.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRDistortionMesh.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRGenericHeadTracker.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRGenericRenderer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAction.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAction.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCActionCamera.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCActionCamera.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCActionCatmullRom.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCActionCatmullRom.cpp" />

View File

@ -1886,6 +1886,18 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\LocalizationManager.h"> <ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\editor-support\cocostudio\LocalizationManager.h">
<Filter>cocostudio\components</Filter> <Filter>cocostudio\components</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRDistortion.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRDistortionMesh.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRGenericHeadTracker.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRGenericRenderer.h">
<Filter>vr</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos2d.cpp"> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos2d.cpp">
@ -3608,6 +3620,18 @@
<Filter>cocostudio\components</Filter> <Filter>cocostudio\components</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIEditBox\UIEditBoxImpl-common.cpp" /> <ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIEditBox\UIEditBoxImpl-common.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRDistortion.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRDistortionMesh.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRGenericHeadTracker.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\vr\CCVRGenericRenderer.cpp">
<Filter>vr</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="2d"> <Filter Include="2d">
@ -3889,6 +3913,9 @@
<Filter Include="cocostudio\reader\WidgetReader\TabControlReader"> <Filter Include="cocostudio\reader\WidgetReader\TabControlReader">
<UniqueIdentifier>{fe153deb-3cee-416d-bdcb-fa409ae48240}</UniqueIdentifier> <UniqueIdentifier>{fe153deb-3cee-416d-bdcb-fa409ae48240}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="vr">
<UniqueIdentifier>{485c9ff1-3f65-46dc-a4ee-4eeb3f6d31f1}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\..\..\cocos2d.def" /> <None Include="$(MSBuildThisFileDirectory)..\..\..\cocos2d.def" />

View File

@ -671,6 +671,10 @@
<ClCompile Include="..\..\ui\UITextField.cpp" /> <ClCompile Include="..\..\ui\UITextField.cpp" />
<ClCompile Include="..\..\ui\UIVBox.cpp" /> <ClCompile Include="..\..\ui\UIVBox.cpp" />
<ClCompile Include="..\..\ui\UIWidget.cpp" /> <ClCompile Include="..\..\ui\UIWidget.cpp" />
<ClCompile Include="..\..\vr\CCVRDistortion.cpp" />
<ClCompile Include="..\..\vr\CCVRDistortionMesh.cpp" />
<ClCompile Include="..\..\vr\CCVRGenericHeadTracker.cpp" />
<ClCompile Include="..\..\vr\CCVRGenericRenderer.cpp" />
<ClCompile Include="..\CCAction.cpp" /> <ClCompile Include="..\CCAction.cpp" />
<ClCompile Include="..\CCActionCamera.cpp" /> <ClCompile Include="..\CCActionCamera.cpp" />
<ClCompile Include="..\CCActionCatmullRom.cpp" /> <ClCompile Include="..\CCActionCatmullRom.cpp" />
@ -1250,6 +1254,10 @@
<ClInclude Include="..\..\renderer\CCTextureCube.h" /> <ClInclude Include="..\..\renderer\CCTextureCube.h" />
<ClInclude Include="..\..\ui\UIEditBox\UIEditBoxImpl-common.h" /> <ClInclude Include="..\..\ui\UIEditBox\UIEditBoxImpl-common.h" />
<ClInclude Include="..\..\ui\UITabControl.h" /> <ClInclude Include="..\..\ui\UITabControl.h" />
<ClInclude Include="..\..\vr\CCVRDistortion.h" />
<ClInclude Include="..\..\vr\CCVRDistortionMesh.h" />
<ClInclude Include="..\..\vr\CCVRGenericHeadTracker.h" />
<ClInclude Include="..\..\vr\CCVRGenericRenderer.h" />
<ClInclude Include="..\CCAutoPolygon.h" /> <ClInclude Include="..\CCAutoPolygon.h" />
<ClInclude Include="..\CCCameraBackgroundBrush.h" /> <ClInclude Include="..\CCCameraBackgroundBrush.h" />
<ClInclude Include="..\renderer\CCFrameBuffer.h" /> <ClInclude Include="..\renderer\CCFrameBuffer.h" />

View File

@ -269,6 +269,9 @@
<Filter Include="cocostudio\reader\WidgetReader\Particle3DReader\ParticleReader"> <Filter Include="cocostudio\reader\WidgetReader\Particle3DReader\ParticleReader">
<UniqueIdentifier>{2e9af99e-c268-459a-9615-9f3c5b58efdc}</UniqueIdentifier> <UniqueIdentifier>{2e9af99e-c268-459a-9615-9f3c5b58efdc}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="vr">
<UniqueIdentifier>{757d4df8-a9d6-430f-9a7a-80170d9ca6fb}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\cocos2d.cpp" /> <ClCompile Include="..\..\cocos2d.cpp" />
@ -1993,6 +1996,18 @@
<ClCompile Include="..\..\ui\UIEditBox\UIEditBoxImpl-common.cpp"> <ClCompile Include="..\..\ui\UIEditBox\UIEditBoxImpl-common.cpp">
<Filter>ui\UIWidgets\EditBox</Filter> <Filter>ui\UIWidgets\EditBox</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\vr\CCVRDistortion.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="..\..\vr\CCVRDistortionMesh.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="..\..\vr\CCVRGenericHeadTracker.cpp">
<Filter>vr</Filter>
</ClCompile>
<ClCompile Include="..\..\vr\CCVRGenericRenderer.cpp">
<Filter>vr</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\cocos2d.h" /> <ClInclude Include="..\..\cocos2d.h" />
@ -3890,6 +3905,18 @@
<ClInclude Include="..\..\ui\UIEditBox\UIEditBoxImpl-common.h"> <ClInclude Include="..\..\ui\UIEditBox\UIEditBoxImpl-common.h">
<Filter>ui\UIWidgets\EditBox</Filter> <Filter>ui\UIWidgets\EditBox</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\vr\CCVRDistortion.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="..\..\vr\CCVRDistortionMesh.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="..\..\vr\CCVRGenericHeadTracker.h">
<Filter>vr</Filter>
</ClInclude>
<ClInclude Include="..\..\vr\CCVRGenericRenderer.h">
<Filter>vr</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\base\CCController-iOS.mm"> <None Include="..\..\base\CCController-iOS.mm">

View File

@ -190,6 +190,10 @@ renderer/CCVertexIndexData.cpp \
renderer/ccGLStateCache.cpp \ renderer/ccGLStateCache.cpp \
renderer/CCFrameBuffer.cpp \ renderer/CCFrameBuffer.cpp \
renderer/ccShaders.cpp \ renderer/ccShaders.cpp \
vr/CCVRDistortion.cpp \
vr/CCVRDistortionMesh.cpp \
vr/CCVRGenericRenderer.cpp \
vr/CCVRGenericHeadTracker.cpp \
deprecated/CCArray.cpp \ deprecated/CCArray.cpp \
deprecated/CCDeprecated.cpp \ deprecated/CCDeprecated.cpp \
deprecated/CCDictionary.cpp \ deprecated/CCDictionary.cpp \

View File

@ -40,6 +40,7 @@ include(physics3d/CMakeLists.txt)
include(math/CMakeLists.txt) include(math/CMakeLists.txt)
include(navmesh/CMakeLists.txt) include(navmesh/CMakeLists.txt)
include(renderer/CMakeLists.txt) include(renderer/CMakeLists.txt)
include(vr/CMakeLists.txt)
include(base/CMakeLists.txt) include(base/CMakeLists.txt)
include(deprecated/CMakeLists.txt) include(deprecated/CMakeLists.txt)
include(ui/CMakeLists.txt) include(ui/CMakeLists.txt)
@ -73,6 +74,7 @@ set(COCOS_SRC cocos2d.cpp
${COCOS_MATH_SRC} ${COCOS_MATH_SRC}
${COCOS_NAVMESH_SRC} ${COCOS_NAVMESH_SRC}
${COCOS_RENDERER_SRC} ${COCOS_RENDERER_SRC}
${COCOS_VR_SRC}
${COCOS_BASE_SRC} ${COCOS_BASE_SRC}
${COCOS_AUDIO_SRC} ${COCOS_AUDIO_SRC}
${COCOS_UI_SRC} ${COCOS_UI_SRC}

View File

@ -298,7 +298,7 @@ void Director::drawScene()
_renderer->clearDrawStats(); _renderer->clearDrawStats();
//render the scene //render the scene
_runningScene->render(_renderer); _openGLView->renderScene(_runningScene, _renderer);
_eventDispatcher->dispatchEvent(_eventAfterVisit); _eventDispatcher->dispatchEvent(_eventAfterVisit);
} }
@ -604,11 +604,9 @@ void Director::setProjection(Projection projection)
{ {
case Projection::_2D: case Projection::_2D:
{ {
loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
Mat4 orthoMatrix; Mat4 orthoMatrix;
Mat4::createOrthographicOffCenter(0, size.width, 0, size.height, -1024, 1024, &orthoMatrix); Mat4::createOrthographicOffCenter(0, size.width, 0, size.height, -1024, 1024, &orthoMatrix);
multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix); loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, orthoMatrix);
loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
break; break;
} }
@ -619,17 +617,14 @@ void Director::setProjection(Projection projection)
Mat4 matrixPerspective, matrixLookup; Mat4 matrixPerspective, matrixLookup;
loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
// issue #1334 // issue #1334
Mat4::createPerspective(60, (GLfloat)size.width/size.height, 10, zeye+size.height/2, &matrixPerspective); Mat4::createPerspective(60, (GLfloat)size.width/size.height, 10, zeye+size.height/2, &matrixPerspective);
multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, matrixPerspective);
Vec3 eye(size.width/2, size.height/2, zeye), center(size.width/2, size.height/2, 0.0f), up(0.0f, 1.0f, 0.0f); Vec3 eye(size.width/2, size.height/2, zeye), center(size.width/2, size.height/2, 0.0f), up(0.0f, 1.0f, 0.0f);
Mat4::createLookAt(eye, center, up, &matrixLookup); Mat4::createLookAt(eye, center, up, &matrixLookup);
multiplyMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, matrixLookup); Mat4 proj3d = matrixPerspective * matrixLookup;
loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION, proj3d);
loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); loadIdentityMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
break; break;
} }

View File

@ -845,11 +845,8 @@ void EventDispatcher::dispatchTouchEventToListeners(EventListenerVector* listene
// second, for all camera call all listeners // second, for all camera call all listeners
// get a copy of cameras, prevent it's been modified in listener callback // get a copy of cameras, prevent it's been modified in listener callback
// if camera's depth is greater, process it earlier // if camera's depth is greater, process it earlier
auto cameras = scene->getCameras(); for (auto& camera: scene->getCameras())
Camera* camera;
for (int j = int(cameras.size()) - 1; j >= 0; --j)
{ {
camera = cameras[j];
if (camera->isVisible() == false) if (camera->isVisible() == false)
{ {
continue; continue;

View File

@ -301,6 +301,9 @@ THE SOFTWARE.
#include "3d/CCSprite3DMaterial.h" #include "3d/CCSprite3DMaterial.h"
#include "3d/CCTerrain.h" #include "3d/CCTerrain.h"
// vr
#include "vr/CCVRGenericRenderer.h"
// Deprecated // Deprecated
// All deprecated features are include inside deprecated/CCDeprecated.h. // All deprecated features are include inside deprecated/CCDeprecated.h.

View File

@ -29,6 +29,10 @@ THE SOFTWARE.
#include "base/CCDirector.h" #include "base/CCDirector.h"
#include "base/CCEventDispatcher.h" #include "base/CCEventDispatcher.h"
#include "2d/CCCamera.h" #include "2d/CCCamera.h"
#include "2d/CCScene.h"
#include "renderer/CCRenderer.h"
#include "vr/CCVRProtocol.h"
#include "vr/CCVRGenericRenderer.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -103,6 +107,7 @@ GLView::GLView()
: _scaleX(1.0f) : _scaleX(1.0f)
, _scaleY(1.0f) , _scaleY(1.0f)
, _resolutionPolicy(ResolutionPolicy::UNKNOWN) , _resolutionPolicy(ResolutionPolicy::UNKNOWN)
, _vrImpl(nullptr)
{ {
} }
@ -464,4 +469,38 @@ float GLView::getScaleY() const
return _scaleY; return _scaleY;
} }
void GLView::renderScene(Scene* scene, Renderer* renderer)
{
CCASSERT(scene, "Invalid Scene");
CCASSERT(renderer, "Invalid Renderer");
if (_vrImpl)
{
_vrImpl->render(scene, renderer);
}
else
{
scene->render(renderer, Mat4::IDENTITY, nullptr);
}
}
VRIRenderer* GLView::getVR() const
{
return _vrImpl;
}
void GLView::setVR(VRIRenderer* vrRenderer)
{
if (_vrImpl != vrRenderer)
{
if (_vrImpl)
delete _vrImpl;
if (vrRenderer)
vrRenderer->setup(this);
_vrImpl = vrRenderer;
}
}
NS_CC_END NS_CC_END

View File

@ -86,6 +86,10 @@ struct GLContextAttrs
NS_CC_BEGIN NS_CC_BEGIN
class Scene;
class Renderer;
class VRIRenderer;
/** /**
* @addtogroup platform * @addtogroup platform
* @{ * @{
@ -388,6 +392,19 @@ public:
virtual id getCocoaWindow() = 0; virtual id getCocoaWindow() = 0;
#endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) */ #endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) */
/**
* Renders a Scene with a Renderer
* This method is called dirctly by the Director
*/
void renderScene(Scene* scene, Renderer* renderer);
/**
* Sets a VR renderer.
* if `vrrenderer` is `nullptr` VR will be disabled
*/
void setVR(VRIRenderer* vrrenderer);
VRIRenderer* getVR() const;
protected: protected:
void updateDesignResolutionSize(); void updateDesignResolutionSize();
@ -405,6 +422,9 @@ protected:
float _scaleX; float _scaleX;
float _scaleY; float _scaleY;
ResolutionPolicy _resolutionPolicy; ResolutionPolicy _resolutionPolicy;
// VR stuff
VRIRenderer* _vrImpl;
}; };
// end of platform group // end of platform group

View File

@ -47,7 +47,11 @@ public class Cocos2dxAccelerometer implements SensorEventListener {
private final Context mContext; private final Context mContext;
private final SensorManager mSensorManager; private final SensorManager mSensorManager;
private final Sensor mAccelerometer; private final Sensor mAccelerometer;
private final Sensor mCompass;
private final int mNaturalOrientation; private final int mNaturalOrientation;
final float[] accelerometerValues = new float[3];
final float[] compassFieldValues = new float[3];
static final float ALPHA = 0.25f; // if ALPHA = 1 OR 0, no filter applies.
// =========================================================== // ===========================================================
// Constructors // Constructors
@ -58,6 +62,7 @@ public class Cocos2dxAccelerometer implements SensorEventListener {
this.mSensorManager = (SensorManager) this.mContext.getSystemService(Context.SENSOR_SERVICE); this.mSensorManager = (SensorManager) this.mContext.getSystemService(Context.SENSOR_SERVICE);
this.mAccelerometer = this.mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); this.mAccelerometer = this.mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
this.mCompass = this.mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
final Display display = ((WindowManager) this.mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); final Display display = ((WindowManager) this.mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
this.mNaturalOrientation = display.getOrientation(); this.mNaturalOrientation = display.getOrientation();
@ -67,7 +72,11 @@ public class Cocos2dxAccelerometer implements SensorEventListener {
// Getter & Setter // Getter & Setter
// =========================================================== // ===========================================================
public void enable() { public void enableCompass() {
this.mSensorManager.registerListener(this, this.mCompass, SensorManager.SENSOR_DELAY_GAME);
}
public void enableAccel() {
this.mSensorManager.registerListener(this, this.mAccelerometer, SensorManager.SENSOR_DELAY_GAME); this.mSensorManager.registerListener(this, this.mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
} }
@ -88,17 +97,19 @@ public class Cocos2dxAccelerometer implements SensorEventListener {
// =========================================================== // ===========================================================
// Methods for/from SuperClass/Interfaces // Methods for/from SuperClass/Interfaces
// =========================================================== // ===========================================================
@Override @Override
public void onSensorChanged(final SensorEvent sensorEvent) { public void onSensorChanged(final SensorEvent sensorEvent) {
if (sensorEvent.sensor.getType() != Sensor.TYPE_ACCELEROMETER) { if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
return;
}
float x = sensorEvent.values[0]; float x = sensorEvent.values[0];
float y = sensorEvent.values[1]; float y = sensorEvent.values[1];
final float z = sensorEvent.values[2]; final float z = sensorEvent.values[2];
// needed by VR code
this.accelerometerValues[0] = x;
this.accelerometerValues[1] = y;
this.accelerometerValues[2] = z;
/* /*
* Because the axes are not swapped when the device's screen orientation * Because the axes are not swapped when the device's screen orientation
* changes. So we should swap it here. In tablets such as Motorola Xoom, * changes. So we should swap it here. In tablets such as Motorola Xoom,
@ -116,6 +127,7 @@ public class Cocos2dxAccelerometer implements SensorEventListener {
y = -tmp; y = -tmp;
} }
Cocos2dxGLSurfaceView.queueAccelerometer(x,y,z,sensorEvent.timestamp); Cocos2dxGLSurfaceView.queueAccelerometer(x,y,z,sensorEvent.timestamp);
/* /*
@ -124,6 +136,13 @@ public class Cocos2dxAccelerometer implements SensorEventListener {
} }
*/ */
} }
else if (sensorEvent.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
// needed by VR code
this.compassFieldValues[0] = sensorEvent.values[0];
this.compassFieldValues[1] = sensorEvent.values[1];
this.compassFieldValues[2] = sensorEvent.values[2];
}
}
@Override @Override
public void onAccuracyChanged(final Sensor sensor, final int accuracy) { public void onAccuracyChanged(final Sensor sensor, final int accuracy) {

View File

@ -45,6 +45,7 @@ import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.WindowManager; import android.view.WindowManager;
import android.hardware.SensorManager;
import com.android.vending.expansion.zipfile.APKExpansionSupport; import com.android.vending.expansion.zipfile.APKExpansionSupport;
import com.android.vending.expansion.zipfile.ZipResourceFile; import com.android.vending.expansion.zipfile.ZipResourceFile;
@ -61,6 +62,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
public class Cocos2dxHelper { public class Cocos2dxHelper {
// =========================================================== // ===========================================================
// Constants // Constants
@ -78,6 +80,7 @@ public class Cocos2dxHelper {
private static AssetManager sAssetManager; private static AssetManager sAssetManager;
private static Cocos2dxAccelerometer sCocos2dxAccelerometer; private static Cocos2dxAccelerometer sCocos2dxAccelerometer;
private static boolean sAccelerometerEnabled; private static boolean sAccelerometerEnabled;
private static boolean sCompassEnabled;
private static boolean sActivityVisible; private static boolean sActivityVisible;
private static String sPackageName; private static String sPackageName;
private static String sFileDirectory; private static String sFileDirectory;
@ -243,9 +246,13 @@ public class Cocos2dxHelper {
public static void enableAccelerometer() { public static void enableAccelerometer() {
Cocos2dxHelper.sAccelerometerEnabled = true; Cocos2dxHelper.sAccelerometerEnabled = true;
Cocos2dxHelper.sCocos2dxAccelerometer.enable(); Cocos2dxHelper.sCocos2dxAccelerometer.enableAccel();
} }
public static void enableCompass() {
Cocos2dxHelper.sCompassEnabled = true;
Cocos2dxHelper.sCocos2dxAccelerometer.enableCompass();
}
public static void setAccelerometerInterval(float interval) { public static void setAccelerometerInterval(float interval) {
Cocos2dxHelper.sCocos2dxAccelerometer.setInterval(interval); Cocos2dxHelper.sCocos2dxAccelerometer.setInterval(interval);
@ -396,7 +403,10 @@ public class Cocos2dxHelper {
public static void onResume() { public static void onResume() {
sActivityVisible = true; sActivityVisible = true;
if (Cocos2dxHelper.sAccelerometerEnabled) { if (Cocos2dxHelper.sAccelerometerEnabled) {
Cocos2dxHelper.sCocos2dxAccelerometer.enable(); Cocos2dxHelper.sCocos2dxAccelerometer.enableAccel();
}
if (Cocos2dxHelper.sCompassEnabled) {
Cocos2dxHelper.sCocos2dxAccelerometer.enableCompass();
} }
} }
@ -691,5 +701,13 @@ public class Cocos2dxHelper {
return -1; return -1;
} }
} }
//Enhance API modification end //Enhance API modification end
public static float[] getAccelValue() {
return Cocos2dxHelper.sCocos2dxAccelerometer.accelerometerValues;
}
public static float[] getCompassValue() {
return Cocos2dxHelper.sCocos2dxAccelerometer.compassFieldValues;
}
} }

View File

@ -67,6 +67,9 @@ namespace cocos2d {
JavaVM* JniHelper::_psJavaVM = nullptr; JavaVM* JniHelper::_psJavaVM = nullptr;
jmethodID JniHelper::loadclassMethod_methodID = nullptr; jmethodID JniHelper::loadclassMethod_methodID = nullptr;
jobject JniHelper::classloader = nullptr; jobject JniHelper::classloader = nullptr;
std::function<void()> JniHelper::classloaderCallback = nullptr;
jobject JniHelper::_activity = nullptr;
std::unordered_map<JNIEnv*, std::vector<jobject>> JniHelper::localRefs; std::unordered_map<JNIEnv*, std::vector<jobject>> JniHelper::localRefs;
JavaVM* JniHelper::getJavaVM() { JavaVM* JniHelper::getJavaVM() {
@ -123,6 +126,10 @@ namespace cocos2d {
return _env; return _env;
} }
jobject JniHelper::getActivity() {
return _activity;
}
bool JniHelper::setClassLoaderFrom(jobject activityinstance) { bool JniHelper::setClassLoaderFrom(jobject activityinstance) {
JniMethodInfo _getclassloaderMethod; JniMethodInfo _getclassloaderMethod;
if (!JniHelper::getMethodInfo_DefaultClassLoader(_getclassloaderMethod, if (!JniHelper::getMethodInfo_DefaultClassLoader(_getclassloaderMethod,
@ -149,6 +156,10 @@ namespace cocos2d {
JniHelper::classloader = cocos2d::JniHelper::getEnv()->NewGlobalRef(_c); JniHelper::classloader = cocos2d::JniHelper::getEnv()->NewGlobalRef(_c);
JniHelper::loadclassMethod_methodID = _m.methodID; JniHelper::loadclassMethod_methodID = _m.methodID;
JniHelper::_activity = cocos2d::JniHelper::getEnv()->NewGlobalRef(activityinstance);
if (JniHelper::classloaderCallback != nullptr){
JniHelper::classloaderCallback();
}
return true; return true;
} }

View File

@ -29,7 +29,9 @@ THE SOFTWARE.
#include <string> #include <string>
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include <functional>
#include "platform/CCPlatformMacros.h" #include "platform/CCPlatformMacros.h"
#include "math/Vec3.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -46,6 +48,7 @@ public:
static void setJavaVM(JavaVM *javaVM); static void setJavaVM(JavaVM *javaVM);
static JavaVM* getJavaVM(); static JavaVM* getJavaVM();
static JNIEnv* getEnv(); static JNIEnv* getEnv();
static jobject getActivity();
static bool setClassLoaderFrom(jobject activityInstance); static bool setClassLoaderFrom(jobject activityInstance);
static bool getStaticMethodInfo(JniMethodInfo &methodinfo, static bool getStaticMethodInfo(JniMethodInfo &methodinfo,
@ -61,6 +64,7 @@ public:
static jmethodID loadclassMethod_methodID; static jmethodID loadclassMethod_methodID;
static jobject classloader; static jobject classloader;
static std::function<void()> classloaderCallback;
template <typename... Ts> template <typename... Ts>
static void callStaticVoidMethod(const std::string& className, static void callStaticVoidMethod(const std::string& className,
@ -128,6 +132,57 @@ public:
return ret; return ret;
} }
template <typename... Ts>
static float* callStaticFloatArrayMethod(const std::string& className,
const std::string& methodName,
Ts... xs) {
static float ret[32];
cocos2d::JniMethodInfo t;
std::string signature = "(" + std::string(getJNISignature(xs...)) + ")[F";
if (cocos2d::JniHelper::getStaticMethodInfo(t, className.c_str(), methodName.c_str(), signature.c_str())) {
jfloatArray array = (jfloatArray) t.env->CallStaticObjectMethod(t.classID, t.methodID, convert(t, xs)...);
jsize len = t.env->GetArrayLength(array);
if (len <= 32) {
jfloat* elems = t.env->GetFloatArrayElements(array, 0);
if (elems) {
memcpy(ret, elems, sizeof(float) * len);
t.env->ReleaseFloatArrayElements(array, elems, 0);
};
}
t.env->DeleteLocalRef(t.classID);
deleteLocalRefs(t.env);
return &ret[0];
} else {
reportError(className, methodName, signature);
}
return nullptr;
}
template <typename... Ts>
static Vec3 callStaticVec3Method(const std::string& className,
const std::string& methodName,
Ts... xs) {
Vec3 ret;
cocos2d::JniMethodInfo t;
std::string signature = "(" + std::string(getJNISignature(xs...)) + ")[F";
if (cocos2d::JniHelper::getStaticMethodInfo(t, className.c_str(), methodName.c_str(), signature.c_str())) {
jfloatArray array = (jfloatArray) t.env->CallStaticObjectMethod(t.classID, t.methodID, convert(t, xs)...);
jsize len = t.env->GetArrayLength(array);
if (len == 3) {
jfloat* elems = t.env->GetFloatArrayElements(array, 0);
ret.x = elems[0];
ret.y = elems[1];
ret.z = elems[2];
t.env->ReleaseFloatArrayElements(array, elems, 0);
}
t.env->DeleteLocalRef(t.classID);
deleteLocalRefs(t.env);
} else {
reportError(className, methodName, signature);
}
return ret;
}
template <typename... Ts> template <typename... Ts>
static double callStaticDoubleMethod(const std::string& className, static double callStaticDoubleMethod(const std::string& className,
const std::string& methodName, const std::string& methodName,
@ -175,6 +230,8 @@ private:
static JavaVM* _psJavaVM; static JavaVM* _psJavaVM;
static jobject _activity;
static jstring convert(cocos2d::JniMethodInfo& t, const char* x); static jstring convert(cocos2d::JniMethodInfo& t, const char* x);
static jstring convert(cocos2d::JniMethodInfo& t, const std::string& x); static jstring convert(cocos2d::JniMethodInfo& t, const std::string& x);

View File

@ -23,6 +23,7 @@
****************************************************************************/ ****************************************************************************/
#include "renderer/CCFrameBuffer.h" #include "renderer/CCFrameBuffer.h"
#include "renderer/CCRenderer.h"
#include "base/CCDirector.h" #include "base/CCDirector.h"
#include "base/CCEventCustom.h" #include "base/CCEventCustom.h"
#include "base/CCEventListenerCustom.h" #include "base/CCEventListenerCustom.h"
@ -314,6 +315,7 @@ FrameBuffer* FrameBuffer::getOrCreateDefaultFBO(GLView* view)
return _defaultFBO; return _defaultFBO;
} }
void FrameBuffer::applyDefaultFBO() void FrameBuffer::applyDefaultFBO()
{ {
if(_defaultFBO) if(_defaultFBO)
@ -384,6 +386,7 @@ FrameBuffer::FrameBuffer()
, _clearDepth(1.0) , _clearDepth(1.0)
, _clearStencil(0) , _clearStencil(0)
, _fbo(0) , _fbo(0)
, _previousFBO(0)
, _rt(nullptr) , _rt(nullptr)
, _rtDepthStencil(nullptr) , _rtDepthStencil(nullptr)
, _fboBindingDirty(true) , _fboBindingDirty(true)
@ -418,7 +421,7 @@ void FrameBuffer::clearFBO()
glClearDepth(_clearDepth); glClearDepth(_clearDepth);
glClearStencil(_clearStencil); glClearStencil(_clearStencil);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
applyDefaultFBO(); restoreFBO();
} }
void FrameBuffer::attachRenderTarget(RenderTargetBase* rt) void FrameBuffer::attachRenderTarget(RenderTargetBase* rt)
@ -443,7 +446,9 @@ void FrameBuffer::attachRenderTarget(RenderTargetBase* rt)
void FrameBuffer::applyFBO() void FrameBuffer::applyFBO()
{ {
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&_previousFBO);
glBindFramebuffer(GL_FRAMEBUFFER, _fbo); glBindFramebuffer(GL_FRAMEBUFFER, _fbo);
// CCASSERT(_fbo==0 || _fbo != _previousFBO, "calling applyFBO without restoring the previous one");
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
if(_fboBindingDirty && !isDefaultFBO()) if(_fboBindingDirty && !isDefaultFBO())
{ {
@ -467,6 +472,11 @@ void FrameBuffer::applyFBO()
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
} }
void FrameBuffer::restoreFBO()
{
glBindFramebuffer(GL_FRAMEBUFFER, _previousFBO);
}
void FrameBuffer::attachDepthStencilTarget(RenderTargetDepthStencil* rt) void FrameBuffer::attachDepthStencilTarget(RenderTargetDepthStencil* rt)
{ {
if(isDefaultFBO()) if(isDefaultFBO())

View File

@ -157,6 +157,7 @@ public:
//call glclear to clear frame buffer object //call glclear to clear frame buffer object
void clearFBO(); void clearFBO();
void applyFBO(); void applyFBO();
void restoreFBO();
void setClearColor(const Color4F& color) { _clearColor = color;} void setClearColor(const Color4F& color) { _clearColor = color;}
void setClearDepth(float depth) { _clearDepth = depth; } void setClearDepth(float depth) { _clearDepth = depth; }
void setClearStencil(int8_t stencil) { _clearStencil = stencil; } void setClearStencil(int8_t stencil) { _clearStencil = stencil; }
@ -180,6 +181,7 @@ CC_CONSTRUCTOR_ACCESS:
private: private:
//openGL content for FrameBuffer //openGL content for FrameBuffer
GLuint _fbo; GLuint _fbo;
GLuint _previousFBO;
//dirty flag for fbo binding //dirty flag for fbo binding
bool _fboBindingDirty; bool _fboBindingDirty;
// //

View File

@ -404,6 +404,8 @@ void Renderer::processRenderCommand(RenderCommand* command)
{ {
flush3D(); flush3D();
CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_MESH_COMMAND");
if(cmd->isSkipBatching()) if(cmd->isSkipBatching())
{ {
// XXX: execute() will call bind() and unbind() // XXX: execute() will call bind() and unbind()
@ -420,6 +422,7 @@ void Renderer::processRenderCommand(RenderCommand* command)
} }
else else
{ {
CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_MESH_COMMAND");
cmd->batchDraw(); cmd->batchDraw();
} }
} }
@ -427,24 +430,29 @@ void Renderer::processRenderCommand(RenderCommand* command)
{ {
flush(); flush();
int renderQueueID = ((GroupCommand*) command)->getRenderQueueID(); int renderQueueID = ((GroupCommand*) command)->getRenderQueueID();
CCGL_DEBUG_PUSH_GROUP_MARKER("RENDERER_GROUP_COMMAND");
visitRenderQueue(_renderGroups[renderQueueID]); visitRenderQueue(_renderGroups[renderQueueID]);
CCGL_DEBUG_POP_GROUP_MARKER();
} }
else if(RenderCommand::Type::CUSTOM_COMMAND == commandType) else if(RenderCommand::Type::CUSTOM_COMMAND == commandType)
{ {
flush(); flush();
auto cmd = static_cast<CustomCommand*>(command); auto cmd = static_cast<CustomCommand*>(command);
CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_CUSTOM_COMMAND");
cmd->execute(); cmd->execute();
} }
else if(RenderCommand::Type::BATCH_COMMAND == commandType) else if(RenderCommand::Type::BATCH_COMMAND == commandType)
{ {
flush(); flush();
auto cmd = static_cast<BatchCommand*>(command); auto cmd = static_cast<BatchCommand*>(command);
CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_BATCH_COMMAND");
cmd->execute(); cmd->execute();
} }
else if(RenderCommand::Type::PRIMITIVE_COMMAND == commandType) else if(RenderCommand::Type::PRIMITIVE_COMMAND == commandType)
{ {
flush(); flush();
auto cmd = static_cast<PrimitiveCommand*>(command); auto cmd = static_cast<PrimitiveCommand*>(command);
CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_PRIMITIVE_COMMAND");
cmd->execute(); cmd->execute();
} }
else else
@ -718,6 +726,8 @@ void Renderer::drawBatchedTriangles()
if(_queuedTriangleCommands.empty()) if(_queuedTriangleCommands.empty())
return; return;
CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_BATCH_TRIANGLES");
_filledVertex = 0; _filledVertex = 0;
_filledIndex = 0; _filledIndex = 0;
@ -866,6 +876,8 @@ void Renderer::flush3D()
{ {
if (_lastBatchedMeshCommand) if (_lastBatchedMeshCommand)
{ {
CCGL_DEBUG_INSERT_EVENT_MARKER("RENDERER_BATCH_MESH");
_lastBatchedMeshCommand->postBatchDraw(); _lastBatchedMeshCommand->postBatchDraw();
_lastBatchedMeshCommand = nullptr; _lastBatchedMeshCommand = nullptr;
} }

View File

@ -34,6 +34,23 @@
#include "renderer/CCGLProgram.h" #include "renderer/CCGLProgram.h"
#include "platform/CCGL.h" #include "platform/CCGL.h"
#if !defined(NDEBUG) && CC_TARGET_PLATFORM == CC_PLATFORM_IOS
/// Basic wrapper for glInsertEventMarkerEXT() depending on the current build settings and platform.
#define CCGL_DEBUG_INSERT_EVENT_MARKER(__message__) glInsertEventMarkerEXT(0, __message__)
/// Basic wrapper for glPushGroupMarkerEXT() depending on the current build settings and platform.
#define CCGL_DEBUG_PUSH_GROUP_MARKER(__message__) glPushGroupMarkerEXT(0, __message__)
/// Basic wrapper for CCGL_DEBUG_POP_GROUP_MARKER() depending on the current build settings and platform.
#define CCGL_DEBUG_POP_GROUP_MARKER() glPopGroupMarkerEXT()
#else
#define CCGL_DEBUG_INSERT_EVENT_MARKER(__message__)
#define CCGL_DEBUG_PUSH_GROUP_MARKER(__message__)
#define CCGL_DEBUG_POP_GROUP_MARKER()
#endif
/** /**
* @addtogroup renderer * @addtogroup renderer
* @{ * @{

View File

@ -0,0 +1,84 @@
/****************************************************************************
Copyright (c) 2016 Google Inc.
Copyright (c) 2016 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 "vr/CCVRDistortion.h"
#include <math.h>
NS_CC_BEGIN
Distortion::Distortion()
{
_coefficients[0] = 0.441f;
_coefficients[1] = 0.156f;
}
void Distortion::setCoefficients(float *coefficients)
{
for (int i = 0; i < s_numberOfCoefficients; i++)
{
_coefficients[i] = coefficients[i];
}
}
float *Distortion::coefficients()
{
return _coefficients;
}
float Distortion::distortionFactor(float radius)
{
float result = 1.0f;
float rFactor = 1.0f;
float squaredRadius = radius * radius;
for (int i = 0; i < s_numberOfCoefficients; i++)
{
rFactor *= squaredRadius;
result += _coefficients[i] * rFactor;
}
return result;
}
float Distortion::distort(float radius)
{
return radius * distortionFactor(radius);
}
float Distortion::distortInverse(float radius)
{
float r0 = radius / 0.9f;
float r = radius * 0.9f;
float dr0 = radius - distort(r0);
while (fabsf(r - r0) > 0.0001f)
{
float dr = radius - distort(r);
float r2 = r - dr * ((r - r0) / (dr - dr0));
r0 = r;
r = r2;
dr0 = dr;
}
return r;
}
NS_CC_END

53
cocos/vr/CCVRDistortion.h Normal file
View File

@ -0,0 +1,53 @@
/****************************************************************************
Copyright (c) 2016 Google Inc.
Copyright (c) 2016 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 CCVRDistortion_h
#define CCVRDistortion_h
#include "platform/CCPlatformMacros.h"
NS_CC_BEGIN
// Barrel Distortion
class Distortion
{
public:
Distortion();
void setCoefficients(float *coefficients);
float *coefficients();
float distortionFactor(float radius);
float distort(float radius);
float distortInverse(float radius);
private:
static const int s_numberOfCoefficients = 2;
float _coefficients[s_numberOfCoefficients];
};
NS_CC_END
#endif /* CCVRDistortion_h */

View File

@ -0,0 +1,153 @@
/****************************************************************************
Copyright (c) 2016 Google Inc.
Copyright (c) 2016 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 "vr/CCVRDistortionMesh.h"
#include <vector>
#include "vr/CCVRDistortion.h"
#include "math/Vec2.h"
#include "platform/CCGL.h"
NS_CC_BEGIN
DistortionMesh::DistortionMesh(Distortion *distortion,
float screenWidth, float screenHeight,
float xEyeOffsetScreen, float yEyeOffsetScreen,
float textureWidth, float textureHeight,
float xEyeOffsetTexture, float yEyeOffsetTexture,
float viewportXTexture, float viewportYTexture,
float viewportWidthTexture, float viewportHeightTexture,
bool vignetteEnabled)
: _indices(-1)
, _arrayBufferID(-1)
, _elementBufferID(-1)
{
const int rows = 40;
const int cols = 40;
GLfloat vertexData[rows * cols * 5];
int vertexOffset = 0;
const float vignetteSizeTanAngle = 0.05f;
const float maxDistance = sqrtf(textureWidth * textureWidth + textureHeight * textureHeight) / 4;
for (int row = 0; row < rows; row++)
{
for (int col = 0; col < cols; col++)
{
const float uTexture = col / (cols-1.0f) * (viewportWidthTexture / textureWidth) + viewportXTexture / textureWidth;
const float vTexture = row / (rows-1.0f) * (viewportHeightTexture / textureHeight) + viewportYTexture / textureHeight;
const float xTexture = uTexture * textureWidth - xEyeOffsetTexture;
const float yTexture = vTexture * textureHeight - yEyeOffsetTexture;
const float rTexture = sqrtf(xTexture * xTexture + yTexture * yTexture) / maxDistance;
const float textureToScreen = (rTexture > 0.0f) ? distortion->distortInverse(rTexture) / rTexture : 1.0f;
const float xScreen = xTexture * textureToScreen;
const float yScreen = yTexture * textureToScreen;
const float uScreen = (xScreen + xEyeOffsetScreen) / screenWidth;
const float vScreen = (yScreen + yEyeOffsetScreen) / screenHeight;
const float vignetteSizeTexture = vignetteSizeTanAngle / textureToScreen;
const float dxTexture = xTexture + xEyeOffsetTexture - clampf(xTexture + xEyeOffsetTexture,
viewportXTexture + vignetteSizeTexture,
viewportXTexture + viewportWidthTexture - vignetteSizeTexture);
const float dyTexture = yTexture + yEyeOffsetTexture - clampf(yTexture + yEyeOffsetTexture,
viewportYTexture + vignetteSizeTexture,
viewportYTexture + viewportHeightTexture - vignetteSizeTexture);
const float drTexture = sqrtf(dxTexture * dxTexture + dyTexture * dyTexture);
float vignette = 1.0f;
if (vignetteEnabled)
vignette = 1.0f - clampf(drTexture / vignetteSizeTexture, 0.0f, 1.0f);
// position x,y (vertices)
vertexData[(vertexOffset + 0)] = 2.0f * uScreen - 1.0f;
vertexData[(vertexOffset + 1)] = 2.0f * vScreen - 1.0f;
// texture u,v
vertexData[(vertexOffset + 2)] = uTexture;
vertexData[(vertexOffset + 3)] = vTexture;
// vignete
vertexData[(vertexOffset + 4)] = vignette;
vertexOffset += 5;
}
}
_indices = (rows-1)*cols*2+rows-2;
// GLshort indexData[_indices];
std::vector<GLshort> indexData(_indices);
const int indexDataSize = _indices * sizeof(GLshort);
int indexOffset = 0;
vertexOffset = 0;
for (int row = 0; row < rows-1; row++)
{
if (row > 0)
{
indexData[indexOffset] = indexData[(indexOffset - 1)];
indexOffset++;
}
for (int col = 0; col < cols; col++)
{
if (col > 0)
{
if (row % 2 == 0)
vertexOffset++;
else
vertexOffset--;
}
indexData[(indexOffset++)] = vertexOffset;
indexData[(indexOffset++)] = (vertexOffset + cols);
}
vertexOffset += rows;
}
GLuint bufferIDs[2] = { 0, 0 };
glGenBuffers(2, bufferIDs);
_arrayBufferID = bufferIDs[0];
_elementBufferID = bufferIDs[1];
glBindBuffer(GL_ARRAY_BUFFER, _arrayBufferID);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _elementBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexDataSize, &indexData[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
// GLCheckForError();
}
NS_CC_END

View File

@ -0,0 +1,56 @@
/****************************************************************************
Copyright (c) 2016 Google Inc.
Copyright (c) 2016 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 CCVRDistortionMesh_hpp
#define CCVRDistortionMesh_hpp
#include "platform/CCPlatformMacros.h"
NS_CC_BEGIN
class Distortion;
class DistortionMesh
{
public:
DistortionMesh();
DistortionMesh(Distortion *distortion,
float screenWidth, float screenHeight,
float xEyeOffsetScreen, float yEyeOffsetScreen,
float textureWidth, float textureHeight,
float xEyeOffsetTexture, float yEyeOffsetTexture,
float viewportXTexture, float viewportYTexture,
float viewportWidthTexture,
float viewportHeightTexture,
bool vignetteEnabled);
int _indices;
int _arrayBufferID;
int _elementBufferID;
};
NS_CC_END
#endif /* CCVRDistortionMesh_h */

View File

@ -0,0 +1,261 @@
/****************************************************************************
Copyright (c) 2016 Google Inc.
Copyright (c) 2016 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.
****************************************************************************/
// IMPORTANT
// For iOS/Mac, this file is treated as an "Objective-C++" file.
// To change this behvior, use the File Inspector from Xcode
#include "vr/CCVRGenericHeadTracker.h"
#include "platform/CCPlatformMacros.h"
#include "platform/CCDevice.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#import <CoreMotion/CoreMotion.h>
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include <jni.h>
#include "platform/android/jni/JniHelper.h"
#endif
NS_CC_BEGIN
//////
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
static Mat4 matrixFromRotationMatrix(const CMRotationMatrix& rotationMatrix)
{
return Mat4(rotationMatrix.m11,
rotationMatrix.m21,
rotationMatrix.m31,
0.0f,
rotationMatrix.m12,
rotationMatrix.m22,
rotationMatrix.m32,
0.0f,
rotationMatrix.m13,
rotationMatrix.m23,
rotationMatrix.m33,
0.0f,
0.0f,
0.0f,
0.0f,
1.0f);
}
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// getRotationMatrix taken from Android's SensorManager.java
Mat4 getRotationMatrix(const Vec3& gravity, const Vec3& geomagnetic)
{
float Ax = gravity.x;
float Ay = gravity.y;
float Az = gravity.z;
const float normsqA = (Ax*Ax + Ay*Ay + Az*Az);
const float g = 9.81f;
const float freeFallGravitySquared = 0.01f * g * g;
if (normsqA < freeFallGravitySquared) {
// gravity less than 10% of normal value
return Mat4::IDENTITY;
}
const float Ex = geomagnetic.x;
const float Ey = geomagnetic.y;
const float Ez = geomagnetic.z;
float Hx = Ey*Az - Ez*Ay;
float Hy = Ez*Ax - Ex*Az;
float Hz = Ex*Ay - Ey*Ax;
const float normH = std::sqrt(Hx*Hx + Hy*Hy + Hz*Hz);
if (normH < 0.1f) {
// device is close to free fall (or in space?), or close to
// magnetic north pole. Typical values are > 100.
return Mat4::IDENTITY;
}
const float invH = 1.0f / normH;
Hx *= invH;
Hy *= invH;
Hz *= invH;
const float invA = 1.0f / std::sqrt(Ax*Ax + Ay*Ay + Az*Az);
Ax *= invA;
Ay *= invA;
Az *= invA;
const float Mx = Ay*Hz - Az*Hy;
const float My = Az*Hx - Ax*Hz;
const float Mz = Ax*Hy - Ay*Hx;
return Mat4( Hx, Mx, Ax, 0,
Hy, My, Ay, 0,
Hz, Mz, Az, 0,
0, 0, 0, 1);
}
Vec3 lowPass(const Vec3& input, const Vec3& prev)
{
// if ALPHA = 1 OR 0, no filter applies.
static const float ALPHA = 0.12f;
return Vec3(prev.x + ALPHA * (input.x - prev.x),
prev.y + ALPHA * (input.y - prev.y),
prev.z + ALPHA * (input.z - prev.z));
}
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
static Mat4 getRotateEulerMatrix(float x, float y, float z)
{
x *= (float)(M_PI / 180.0f);
y *= (float)(M_PI / 180.0f);
z *= (float)(M_PI / 180.0f);
float cx = (float) cos(x);
float sx = (float) sin(x);
float cy = (float) cos(y);
float sy = (float) sin(y);
float cz = (float) cos(z);
float sz = (float) sin(z);
float cxsy = cx * sy;
float sxsy = sx * sy;
Mat4 matrix;
matrix.m[0] = cy * cz;
matrix.m[1] = -cy * sz;
matrix.m[2] = sy;
matrix.m[3] = 0.0f;
matrix.m[4] = cxsy * cz + cx * sz;
matrix.m[5] = -cxsy * sz + cx * cz;
matrix.m[6] = -sx * cy;
matrix.m[7] = 0.0f;
matrix.m[8] = -sxsy * cz + sx * sz;
matrix.m[9] = sxsy * sz + sx * cz;
matrix.m[10] = cx * cy;
matrix.m[11] = 0.0f;
matrix.m[12] = 0.0f;
matrix.m[13] = 0.0f;
matrix.m[14] = 0.0f;
matrix.m[15] = 1.0f;
return matrix;
}
VRGenericHeadTracker::VRGenericHeadTracker()
: _localPosition(Vec3::ZERO)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
_motionMgr = [[CMMotionManager alloc] init];
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
startTracking();
#endif
}
VRGenericHeadTracker::~VRGenericHeadTracker()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
stopTracking();
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
[(CMMotionManager*)_motionMgr release];
#endif
}
void VRGenericHeadTracker::startTracking()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
CMMotionManager* motionMgr = (CMMotionManager*)_motionMgr;
if (motionMgr.isDeviceMotionAvailable && !motionMgr.isDeviceMotionActive)
{
[motionMgr startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryZVertical];
}
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft)
{
_deviceToDisplay = getRotateEulerMatrix(0.f, 0.f, 90.f);
}
else if (orientation == UIInterfaceOrientationLandscapeRight)
{
_deviceToDisplay = getRotateEulerMatrix(0.f, 0.f, -90.f);
}
// the inertial reference frame has z up and x forward, while the world has z out and x right
_worldToInertialReferenceFrame = getRotateEulerMatrix(-90.f, 0.f, 90.f);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
_deviceToDisplay = getRotateEulerMatrix(0.f, 0.f, -90.f);
_worldToInertialReferenceFrame = getRotateEulerMatrix(-90.f, 0.f, 90.f);
JniHelper::callStaticVoidMethod("org/cocos2dx/lib/Cocos2dxHelper", "enableAccelerometer");
JniHelper::callStaticVoidMethod("org/cocos2dx/lib/Cocos2dxHelper", "enableCompass");
#endif
}
void VRGenericHeadTracker::stopTracking()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
[(CMMotionManager*)_motionMgr stopDeviceMotionUpdates];
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
Device::setAccelerometerEnabled(false);
#endif
}
Vec3 VRGenericHeadTracker::getLocalPosition()
{
return _localPosition;
}
Mat4 VRGenericHeadTracker::getLocalRotation()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
CMMotionManager* motionMgr = (CMMotionManager*)_motionMgr;
CMDeviceMotion *motion = motionMgr.deviceMotion;
CMRotationMatrix rotationMatrix = motion.attitude.rotationMatrix;
Mat4 inertialReferenceFrameToDevice0 = matrixFromRotationMatrix(rotationMatrix); // note the matrix inversion
Mat4 inertialReferenceFrameToDevice = inertialReferenceFrameToDevice0.getTransposed();
Mat4 worldToDevice = inertialReferenceFrameToDevice * _worldToInertialReferenceFrame;
return _deviceToDisplay * worldToDevice;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
static Vec3 prevAccel = Vec3(0,0,0);
static Vec3 prevCompass = Vec3(0,0,0);
Vec3 accel = JniHelper::callStaticVec3Method("org/cocos2dx/lib/Cocos2dxHelper", "getAccelValue");
Vec3 compass = JniHelper::callStaticVec3Method("org/cocos2dx/lib/Cocos2dxHelper", "getCompassValue");
// CCLOG("accel: %f, %f, %f.... compass: %f, %f, %f", accel.x, accel.y, accel.z, compass.x, compass.y, compass.z);
prevAccel = lowPass(accel, prevAccel);
prevCompass = lowPass(compass, prevCompass);
// CCLOG("low pass accel: %f, %f, %f.... compass: %f, %f, %f", prevAccel.x, prevAccel.y, prevAccel.z, prevCompass.x, prevCompass.y, prevCompass.z);
Mat4 rotMatrix = getRotationMatrix(prevAccel, prevCompass);
Mat4 inertialReferenceFrameToDevice(rotMatrix);
Mat4 worldToDevice = inertialReferenceFrameToDevice * _worldToInertialReferenceFrame;
return _deviceToDisplay * worldToDevice;
#else
return Mat4::IDENTITY;
#endif
}
NS_CC_END

View File

@ -0,0 +1,58 @@
/****************************************************************************
Copyright (c) 2016 Google Inc.
Copyright (c) 2016 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 CCVRGenericHeadTracker_hpp
#define CCVRGenericHeadTracker_hpp
#include "vr/CCVRProtocol.h"
#include "math/Vec3.h"
#include "math/Mat4.h"
NS_CC_BEGIN
class CC_DLL VRGenericHeadTracker : public VRIHeadTracker
{
public:
VRGenericHeadTracker();
virtual ~VRGenericHeadTracker();
virtual Vec3 getLocalPosition();
virtual Mat4 getLocalRotation();
protected:
void startTracking();
void stopTracking();
Vec3 _localPosition;
Mat4 _deviceToDisplay;
Mat4 _worldToInertialReferenceFrame;
void* _motionMgr;
};
NS_CC_END
#endif /* CCVRGenericHeadTracker_hpp */

View File

@ -0,0 +1,227 @@
/****************************************************************************
Copyright (c) 2016 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 "platform/CCPlatformMacros.h"
#include "vr/CCVRGenericRenderer.h"
#include "vr/CCVRDistortionMesh.h"
#include "vr/CCVRDistortion.h"
#include "vr/CCVRGenericHeadTracker.h"
#include "renderer/CCRenderer.h"
#include "renderer/CCGLProgramState.h"
#include "renderer/ccGLStateCache.h"
#include "base/CCDirector.h"
#include "2d/CCScene.h"
#include "2d/CCCamera.h"
#include "2d/CCSprite.h"
#include "platform/CCGLView.h"
NS_CC_BEGIN
VRGenericRenderer::VRGenericRenderer()
: _vignetteEnabled(true)
, _distortion(nullptr)
, _leftDistortionMesh(nullptr)
, _rightDistortionMesh(nullptr)
, _glProgramState(nullptr)
{
_headTracker = new VRGenericHeadTracker;
}
VRGenericRenderer::~VRGenericRenderer()
{
CC_SAFE_DELETE(_headTracker);
CC_SAFE_RELEASE(_glProgramState);
CC_SAFE_RELEASE(_fb);
CC_SAFE_DELETE(_distortion);
CC_SAFE_DELETE(_leftDistortionMesh);
CC_SAFE_DELETE(_rightDistortionMesh);
}
void VRGenericRenderer::setup(GLView* glview)
{
// CC_UNUSED(glview);
// set origin to 0,0 in case origin is not 0,0
auto vp = Camera::getDefaultViewport();
_leftEye.viewport._bottom = vp._bottom/2 + vp._height/4;
_leftEye.viewport._left = vp._left/4;
_leftEye.viewport._width = vp._width/2;
_leftEye.viewport._height = vp._height/2;
_rightEye.viewport._bottom = vp._bottom/2 + vp._height/4;
_rightEye.viewport._left = _leftEye.viewport._width + vp._left/2;
_rightEye.viewport._width = vp._width/2;
_rightEye.viewport._height = vp._height/2;
_texSize = Size(vp._width, vp._height);
_fb = experimental::FrameBuffer::create(1, _texSize.width, _texSize.height);
_fb->retain();
auto rt = experimental::RenderTarget::create(_texSize.width, _texSize.height);
auto ds = experimental::RenderTargetDepthStencil::create(_texSize.width, _texSize.height);
_fb->attachRenderTarget(rt);
_fb->attachDepthStencilTarget(ds);
_fb->setClearColor(Color4F(0,0,0,1));
_distortion = new Distortion;
_leftDistortionMesh = createDistortionMesh(VREye::EyeType::LEFT);
_rightDistortionMesh = createDistortionMesh(VREye::EyeType::RIGHT);
setupGLProgram();
}
void VRGenericRenderer::cleanup()
{
}
VRIHeadTracker* VRGenericRenderer::getHeadTracker()
{
return _headTracker;
}
void VRGenericRenderer::render(Scene* scene, Renderer* renderer)
{
// FIXME: Use correct eye displacement
const float eyeOffset = 0.5;
auto headRotation = _headTracker->getLocalRotation();
Mat4 leftTransform;
Mat4::createTranslation(eyeOffset, 0, 0, &leftTransform);
leftTransform *= headRotation;
Mat4 rightTransform;
Mat4::createTranslation(-eyeOffset, 0, 0, &rightTransform);
rightTransform *= headRotation;
_fb->applyFBO();
Camera::setDefaultViewport(_leftEye.viewport);
scene->render(renderer, leftTransform, nullptr);
Camera::setDefaultViewport(_rightEye.viewport);
scene->render(renderer, rightTransform, nullptr);
_fb->restoreFBO();
auto texture = _fb->getRenderTarget()->getTexture();
GL::bindTexture2D(texture->getName());
_glProgramState->apply(Mat4::IDENTITY);
GLint origViewport[4];
glGetIntegerv(GL_VIEWPORT, origViewport);
glViewport(0, 0, _texSize.width, _texSize.height);
renderDistortionMesh(_leftDistortionMesh, texture->getName());
renderDistortionMesh(_rightDistortionMesh, texture->getName());
glViewport(origViewport[0], origViewport[1], origViewport[2], origViewport[3]);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
CHECK_GL_ERROR_DEBUG();
}
void VRGenericRenderer::renderDistortionMesh(DistortionMesh *mesh, GLint textureID)
{
glBindBuffer(GL_ARRAY_BUFFER, mesh->_arrayBufferID);
_glProgramState->setVertexAttribPointer("a_position", 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *)(0 * sizeof(float)));
_glProgramState->setVertexAttribPointer("a_textureCoord", 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *)(2 * sizeof(float)));
_glProgramState->setVertexAttribPointer("a_vignette", 1, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *)(4 * sizeof(float)));
_glProgramState->setUniformTexture("u_textureSampler", textureID);
_glProgramState->apply(Mat4::IDENTITY);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->_elementBufferID);
glDrawElements(GL_TRIANGLE_STRIP, mesh->_indices, GL_UNSIGNED_SHORT, 0);
CHECK_GL_ERROR_DEBUG();
}
DistortionMesh* VRGenericRenderer::createDistortionMesh(VREye::EyeType eyeType)
{
auto vp = Camera::getDefaultViewport();
const float screenWidth = _texSize.width;
const float screenHeight = _texSize.height;
const float xEyeOffsetScreen = (eyeType == VREye::EyeType::LEFT) ? screenWidth/4 + vp._left : screenWidth*3/4 + vp._left;
const float yEyeOffsetScreen = screenHeight/2 + vp._bottom;
const float textureWidth = _texSize.width;
const float textureHeight = _texSize.height;
const float xEyeOffsetTexture = (eyeType == VREye::EyeType::LEFT) ? _texSize.width/4 : _texSize.width*3/4;
const float yEyeOffsetTexture = _texSize.height/2;
const float viewportX = (eyeType == VREye::EyeType::LEFT) ? 0 : textureWidth/2;
const float viewportY = 0;
const float viewportW = textureWidth/2;
const float viewportH = textureHeight;
return new DistortionMesh(_distortion,
screenWidth, screenHeight,
xEyeOffsetScreen, yEyeOffsetScreen,
textureWidth, textureHeight,
xEyeOffsetTexture, yEyeOffsetTexture,
viewportX, viewportY,
viewportW, viewportH,
_vignetteEnabled);
}
void VRGenericRenderer::setupGLProgram()
{
const GLchar *vertexShader =
"\
attribute vec2 a_position;\n\
attribute vec2 a_textureCoord;\n\
attribute float a_vignette;\n\
varying vec2 v_textureCoord;\n\
varying float v_vignette;\n\
void main() {\n\
gl_Position = vec4(a_position, 0.0, 1.0);\n\
v_textureCoord = a_textureCoord.xy;\n\
v_vignette = a_vignette;\n\
}\n";
const GLchar *fragmentShader =
"\
#ifdef GL_ES\n\
precision mediump float;\n\
#endif\n\
varying vec2 v_textureCoord;\n\
varying float v_vignette;\n\
uniform sampler2D u_textureSampler;\n\
void main() {\n\
gl_FragColor = v_vignette * texture2D(u_textureSampler, v_textureCoord);\n\
}\n";
auto program = GLProgram::createWithByteArrays(vertexShader, fragmentShader);
_glProgramState = GLProgramState::getOrCreateWithGLProgram(program);
_glProgramState->retain();
}
NS_CC_END

View File

@ -0,0 +1,84 @@
/****************************************************************************
Copyright (c) 2016 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 CCVRGenericRenderer_hpp
#define CCVRGenericRenderer_hpp
#include "vr/CCVRProtocol.h"
#include "renderer/CCCustomCommand.h"
#include "renderer/CCFrameBuffer.h"
NS_CC_BEGIN
class Camera;
class Sprite;
class DistortionMesh;
class Distortion;
class GLProgramState;
class VRGenericHeadTracker;
struct CC_DLL VREye
{
enum class EyeType {
MONO,
LEFT,
RIGHT,
};
EyeType type;
experimental::Viewport viewport;
};
class CC_DLL VRGenericRenderer : public VRIRenderer
{
public:
VRGenericRenderer();
virtual ~VRGenericRenderer();
virtual void setup(GLView* glview) override;
virtual void cleanup() override;
virtual void render(Scene* scene, Renderer* renderer) override;
virtual VRIHeadTracker* getHeadTracker() override;
protected:
void setupGLProgram();
void renderDistortionMesh(DistortionMesh *mesh, GLint textureID);
DistortionMesh* createDistortionMesh(VREye::EyeType eyeType);
experimental::FrameBuffer* _fb;
Size _texSize;
VREye _leftEye;
VREye _rightEye;
DistortionMesh* _leftDistortionMesh;
DistortionMesh* _rightDistortionMesh;
Distortion* _distortion;
bool _vignetteEnabled;
GLProgramState* _glProgramState;
VRGenericHeadTracker* _headTracker;
};
NS_CC_END
#endif // CCVRGenericRenderer_hpp

64
cocos/vr/CCVRProtocol.h Normal file
View File

@ -0,0 +1,64 @@
/****************************************************************************
Copyright (c) 2016 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_VR_PROTOCOL_H__
#define __CC_VR_PROTOCOL_H__
#include <string>
#include "base/ccTypes.h"
#include "renderer/CCTexture2D.h"
NS_CC_BEGIN
class Scene;
class Renderer;
class GLView;
class CC_DLL VRIHeadTracker
{
public:
virtual ~VRIHeadTracker() {}
// pose
virtual Vec3 getLocalPosition() = 0;
// rotation
virtual Mat4 getLocalRotation() = 0;
};
class CC_DLL VRIRenderer
{
public:
virtual ~VRIRenderer() {}
virtual void setup(GLView* glview) = 0;
virtual void cleanup() = 0;
virtual void render(Scene* scene, Renderer* renderer) = 0;
virtual VRIHeadTracker* getHeadTracker() = 0;
};
NS_CC_END
#endif // __CC_VR_PROTOCOL_H__

7
cocos/vr/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
set(COCOS_VR_SRC
vr/CCVRDistortion.cpp
vr/CCVRDistortionMesh.cpp
vr/CCVRGenericRenderer.cpp
vr/CCVRGenericHeadTracker.cpp
)

View File

@ -573,6 +573,7 @@ void ScrollView::onBeforeDraw()
Rect frame = getViewRect(); Rect frame = getViewRect();
auto glview = Director::getInstance()->getOpenGLView(); auto glview = Director::getInstance()->getOpenGLView();
if (glview->getVR() == nullptr) {
if (glview->isScissorEnabled()) { if (glview->isScissorEnabled()) {
_scissorRestored = true; _scissorRestored = true;
_parentScissorRect = glview->getScissorRect(); _parentScissorRect = glview->getScissorRect();
@ -591,6 +592,7 @@ void ScrollView::onBeforeDraw()
} }
} }
} }
}
void ScrollView::afterDraw() void ScrollView::afterDraw()
{ {
@ -607,9 +609,9 @@ void ScrollView::onAfterDraw()
{ {
if (_clippingToBounds) if (_clippingToBounds)
{ {
if (_scissorRestored) {//restore the parent's scissor rect
auto glview = Director::getInstance()->getOpenGLView(); auto glview = Director::getInstance()->getOpenGLView();
if (glview->getVR() == nullptr) {
if (_scissorRestored) {//restore the parent's scissor rect
glview->setScissorInPoints(_parentScissorRect.origin.x, _parentScissorRect.origin.y, _parentScissorRect.size.width, _parentScissorRect.size.height); glview->setScissorInPoints(_parentScissorRect.origin.x, _parentScissorRect.origin.y, _parentScissorRect.size.width, _parentScissorRect.size.height);
} }
else { else {
@ -617,6 +619,7 @@ void ScrollView::onAfterDraw()
} }
} }
} }
}
void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{ {

View File

@ -92,6 +92,10 @@ bool AppDelegate::applicationDidFinishLaunching()
cocostudio::LocalizationHelper::setCurrentManager(lm, true); cocostudio::LocalizationHelper::setCurrentManager(lm, true);
*/ */
// to enable VR, uncomment the following lines
// auto vrImpl = new VRGenericRenderer;
// glview->setVR(vrImpl);
// turn on display FPS // turn on display FPS
director->setDisplayStats(true); director->setDisplayStats(true);

View File

@ -169,7 +169,6 @@
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array> </array>
</dict> </dict>
</plist> </plist>

View File

@ -105,6 +105,10 @@ bool AppDelegate::applicationDidFinishLaunching()
_testController = TestController::getInstance(); _testController = TestController::getInstance();
// To enable built-in VR, use this line.
// auto vrImpl = new VRGenericRenderer;
// glview->setVR(vrImpl);
return true; return true;
} }