mirror of https://github.com/axmolengine/axmol.git
engine refactor hide concept of submesh
This commit is contained in:
parent
7818b28ee3
commit
d90572fc10
|
@ -57,14 +57,13 @@
|
|||
1516200E199E75C2006099B8 /* CCRay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6105179199CB1A600DC41CE /* CCRay.cpp */; };
|
||||
1516200F199E75C2006099B8 /* CCSkeleton3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA2A83E1987A6810077B3D4 /* CCSkeleton3D.cpp */; };
|
||||
15162010199E75C2006099B8 /* CCAttachNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E3198639EF00FA95D0 /* CCAttachNode.cpp */; };
|
||||
15162011199E75C2006099B8 /* CCSubMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E5198639EF00FA95D0 /* CCSubMesh.cpp */; };
|
||||
15162012199E75C2006099B8 /* CCSubMeshState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E7198639EF00FA95D0 /* CCSubMeshState.cpp */; };
|
||||
15162011199E75C2006099B8 /* CCMeshVertexIndexData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E5198639EF00FA95D0 /* CCMeshVertexIndexData.cpp */; };
|
||||
15162012199E75C2006099B8 /* CCMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E7198639EF00FA95D0 /* CCMesh.cpp */; };
|
||||
15162013199E75C2006099B8 /* CCBundleReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */; };
|
||||
15162014199E75C2006099B8 /* CCBundle3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6AAF83F19404E0D0069DE01 /* CCBundle3D.cpp */; };
|
||||
15162015199E75C2006099B8 /* CCAnimate3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6ACD89C193DC0CC005E0B8A /* CCAnimate3D.cpp */; };
|
||||
15162016199E75C2006099B8 /* CCMeshSkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6ACD895193D6693005E0B8A /* CCMeshSkin.cpp */; };
|
||||
15162017199E75C2006099B8 /* CCAnimation3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6B26341193884D60088FE25 /* CCAnimation3D.cpp */; };
|
||||
15162018199E75C2006099B8 /* CCMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594B91926D61F003EEF37 /* CCMesh.cpp */; };
|
||||
15162019199E75C2006099B8 /* CCObjLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BB1926D61F003EEF37 /* CCObjLoader.cpp */; };
|
||||
1516201A199E75C2006099B8 /* CCSprite3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BD1926D61F003EEF37 /* CCSprite3D.cpp */; };
|
||||
1516201B199E75C2006099B8 /* CCSprite3DMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BF1926D61F003EEF37 /* CCSprite3DMaterial.cpp */; };
|
||||
|
@ -73,15 +72,14 @@
|
|||
1516201E199E75FE006099B8 /* CCRay.h in Headers */ = {isa = PBXBuildFile; fileRef = B610517A199CB1A600DC41CE /* CCRay.h */; };
|
||||
1516201F199E75FE006099B8 /* CCSkeleton3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA2A83F1987A6810077B3D4 /* CCSkeleton3D.h */; };
|
||||
15162020199E75FE006099B8 /* CCAttachNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E4198639EF00FA95D0 /* CCAttachNode.h */; };
|
||||
15162021199E75FE006099B8 /* CCSubMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E6198639EF00FA95D0 /* CCSubMesh.h */; };
|
||||
15162022199E75FF006099B8 /* CCSubMeshState.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E8198639EF00FA95D0 /* CCSubMeshState.h */; };
|
||||
15162021199E75FE006099B8 /* CCMeshVertexIndexData.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E6198639EF00FA95D0 /* CCMeshVertexIndexData.h */; };
|
||||
15162022199E75FF006099B8 /* CCMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E8198639EF00FA95D0 /* CCMesh.h */; };
|
||||
15162023199E75FF006099B8 /* CCBundleReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA4786F195478E00068D9D1 /* CCBundleReader.h */; };
|
||||
15162024199E75FF006099B8 /* CCBundle3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6AAF84019404E0D0069DE01 /* CCBundle3D.h */; };
|
||||
15162025199E75FF006099B8 /* CCAnimate3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6ACD89D193DC0CC005E0B8A /* CCAnimate3D.h */; };
|
||||
15162026199E75FF006099B8 /* CCMeshSkin.h in Headers */ = {isa = PBXBuildFile; fileRef = B6ACD896193D6693005E0B8A /* CCMeshSkin.h */; };
|
||||
15162027199E75FF006099B8 /* CCAnimation3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B26342193884D60088FE25 /* CCAnimation3D.h */; };
|
||||
15162028199E75FF006099B8 /* CCAnimationCurve.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B2633C19381FBF0088FE25 /* CCAnimationCurve.h */; };
|
||||
15162029199E75FF006099B8 /* CCMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594BA1926D61F003EEF37 /* CCMesh.h */; };
|
||||
1516202A199E75FF006099B8 /* CCObjLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594BC1926D61F003EEF37 /* CCObjLoader.h */; };
|
||||
1516202B199E75FF006099B8 /* CCSprite3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594BE1926D61F003EEF37 /* CCSprite3D.h */; };
|
||||
1516202C199E75FF006099B8 /* CCSprite3DMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594C01926D61F003EEF37 /* CCSprite3DMaterial.h */; };
|
||||
|
@ -91,14 +89,13 @@
|
|||
15162204199E7874006099B8 /* CCRay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6105179199CB1A600DC41CE /* CCRay.cpp */; };
|
||||
15162205199E7874006099B8 /* CCSkeleton3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA2A83E1987A6810077B3D4 /* CCSkeleton3D.cpp */; };
|
||||
15162206199E7874006099B8 /* CCAttachNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E3198639EF00FA95D0 /* CCAttachNode.cpp */; };
|
||||
15162207199E7874006099B8 /* CCSubMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E5198639EF00FA95D0 /* CCSubMesh.cpp */; };
|
||||
15162208199E7874006099B8 /* CCSubMeshState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E7198639EF00FA95D0 /* CCSubMeshState.cpp */; };
|
||||
15162207199E7874006099B8 /* CCMeshVertexIndexData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E5198639EF00FA95D0 /* CCMeshVertexIndexData.cpp */; };
|
||||
15162208199E7874006099B8 /* CCMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3E9E80E7198639EF00FA95D0 /* CCMesh.cpp */; };
|
||||
15162209199E7874006099B8 /* CCBundleReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */; };
|
||||
1516220A199E7874006099B8 /* CCBundle3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6AAF83F19404E0D0069DE01 /* CCBundle3D.cpp */; };
|
||||
1516220B199E7874006099B8 /* CCAnimate3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6ACD89C193DC0CC005E0B8A /* CCAnimate3D.cpp */; };
|
||||
1516220C199E7874006099B8 /* CCMeshSkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6ACD895193D6693005E0B8A /* CCMeshSkin.cpp */; };
|
||||
1516220D199E7874006099B8 /* CCAnimation3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B6B26341193884D60088FE25 /* CCAnimation3D.cpp */; };
|
||||
1516220E199E7874006099B8 /* CCMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594B91926D61F003EEF37 /* CCMesh.cpp */; };
|
||||
1516220F199E7874006099B8 /* CCObjLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BB1926D61F003EEF37 /* CCObjLoader.cpp */; };
|
||||
15162210199E7874006099B8 /* CCSprite3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BD1926D61F003EEF37 /* CCSprite3D.cpp */; };
|
||||
15162211199E7874006099B8 /* CCSprite3DMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B29594BF1926D61F003EEF37 /* CCSprite3DMaterial.cpp */; };
|
||||
|
@ -107,15 +104,14 @@
|
|||
15162214199E7A32006099B8 /* CCRay.h in Headers */ = {isa = PBXBuildFile; fileRef = B610517A199CB1A600DC41CE /* CCRay.h */; };
|
||||
15162215199E7A32006099B8 /* CCSkeleton3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA2A83F1987A6810077B3D4 /* CCSkeleton3D.h */; };
|
||||
15162216199E7A32006099B8 /* CCAttachNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E4198639EF00FA95D0 /* CCAttachNode.h */; };
|
||||
15162217199E7A32006099B8 /* CCSubMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E6198639EF00FA95D0 /* CCSubMesh.h */; };
|
||||
15162218199E7A32006099B8 /* CCSubMeshState.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E8198639EF00FA95D0 /* CCSubMeshState.h */; };
|
||||
15162217199E7A32006099B8 /* CCMeshVertexIndexData.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E6198639EF00FA95D0 /* CCMeshVertexIndexData.h */; };
|
||||
15162218199E7A32006099B8 /* CCMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E9E80E8198639EF00FA95D0 /* CCMesh.h */; };
|
||||
15162219199E7A32006099B8 /* CCBundleReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 3EA4786F195478E00068D9D1 /* CCBundleReader.h */; };
|
||||
1516221A199E7A32006099B8 /* CCBundle3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6AAF84019404E0D0069DE01 /* CCBundle3D.h */; };
|
||||
1516221B199E7A32006099B8 /* CCAnimate3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6ACD89D193DC0CC005E0B8A /* CCAnimate3D.h */; };
|
||||
1516221C199E7A32006099B8 /* CCMeshSkin.h in Headers */ = {isa = PBXBuildFile; fileRef = B6ACD896193D6693005E0B8A /* CCMeshSkin.h */; };
|
||||
1516221D199E7A32006099B8 /* CCAnimation3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B26342193884D60088FE25 /* CCAnimation3D.h */; };
|
||||
1516221E199E7A32006099B8 /* CCAnimationCurve.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B2633C19381FBF0088FE25 /* CCAnimationCurve.h */; };
|
||||
1516221F199E7A32006099B8 /* CCMesh.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594BA1926D61F003EEF37 /* CCMesh.h */; };
|
||||
15162220199E7A32006099B8 /* CCObjLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594BC1926D61F003EEF37 /* CCObjLoader.h */; };
|
||||
15162221199E7A32006099B8 /* CCSprite3D.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594BE1926D61F003EEF37 /* CCSprite3D.h */; };
|
||||
15162222199E7A32006099B8 /* CCSprite3DMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = B29594C01926D61F003EEF37 /* CCSprite3DMaterial.h */; };
|
||||
|
@ -2534,10 +2530,10 @@
|
|||
3E61781C1966A5A300DE83F5 /* CCController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCController.cpp; path = ../base/CCController.cpp; sourceTree = "<group>"; };
|
||||
3E9E80E3198639EF00FA95D0 /* CCAttachNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAttachNode.cpp; sourceTree = "<group>"; };
|
||||
3E9E80E4198639EF00FA95D0 /* CCAttachNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAttachNode.h; sourceTree = "<group>"; };
|
||||
3E9E80E5198639EF00FA95D0 /* CCSubMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSubMesh.cpp; sourceTree = "<group>"; };
|
||||
3E9E80E6198639EF00FA95D0 /* CCSubMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSubMesh.h; sourceTree = "<group>"; };
|
||||
3E9E80E7198639EF00FA95D0 /* CCSubMeshState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSubMeshState.cpp; sourceTree = "<group>"; };
|
||||
3E9E80E8198639EF00FA95D0 /* CCSubMeshState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSubMeshState.h; sourceTree = "<group>"; };
|
||||
3E9E80E5198639EF00FA95D0 /* CCMeshVertexIndexData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMeshVertexIndexData.cpp; sourceTree = "<group>"; };
|
||||
3E9E80E6198639EF00FA95D0 /* CCMeshVertexIndexData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMeshVertexIndexData.h; sourceTree = "<group>"; };
|
||||
3E9E80E7198639EF00FA95D0 /* CCMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMesh.cpp; sourceTree = "<group>"; };
|
||||
3E9E80E8198639EF00FA95D0 /* CCMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMesh.h; sourceTree = "<group>"; };
|
||||
3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIVideoPlayer.h; sourceTree = "<group>"; };
|
||||
3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIVideoPlayerIOS.mm; sourceTree = "<group>"; };
|
||||
3EA2A83E1987A6810077B3D4 /* CCSkeleton3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSkeleton3D.cpp; sourceTree = "<group>"; };
|
||||
|
@ -3084,8 +3080,6 @@
|
|||
B29594B11926D5D9003EEF37 /* ccShader_3D_PositionTex.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_PositionTex.vert; sourceTree = "<group>"; };
|
||||
B29594B21926D5EC003EEF37 /* CCMeshCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMeshCommand.cpp; sourceTree = "<group>"; };
|
||||
B29594B31926D5EC003EEF37 /* CCMeshCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMeshCommand.h; sourceTree = "<group>"; };
|
||||
B29594B91926D61F003EEF37 /* CCMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCMesh.cpp; sourceTree = "<group>"; };
|
||||
B29594BA1926D61F003EEF37 /* CCMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCMesh.h; sourceTree = "<group>"; };
|
||||
B29594BB1926D61F003EEF37 /* CCObjLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCObjLoader.cpp; sourceTree = "<group>"; };
|
||||
B29594BC1926D61F003EEF37 /* CCObjLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCObjLoader.h; sourceTree = "<group>"; };
|
||||
B29594BD1926D61F003EEF37 /* CCSprite3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSprite3D.cpp; sourceTree = "<group>"; };
|
||||
|
@ -5311,10 +5305,10 @@
|
|||
3EA2A83F1987A6810077B3D4 /* CCSkeleton3D.h */,
|
||||
3E9E80E3198639EF00FA95D0 /* CCAttachNode.cpp */,
|
||||
3E9E80E4198639EF00FA95D0 /* CCAttachNode.h */,
|
||||
3E9E80E5198639EF00FA95D0 /* CCSubMesh.cpp */,
|
||||
3E9E80E6198639EF00FA95D0 /* CCSubMesh.h */,
|
||||
3E9E80E7198639EF00FA95D0 /* CCSubMeshState.cpp */,
|
||||
3E9E80E8198639EF00FA95D0 /* CCSubMeshState.h */,
|
||||
3E9E80E5198639EF00FA95D0 /* CCMeshVertexIndexData.cpp */,
|
||||
3E9E80E6198639EF00FA95D0 /* CCMeshVertexIndexData.h */,
|
||||
3E9E80E7198639EF00FA95D0 /* CCMesh.cpp */,
|
||||
3E9E80E8198639EF00FA95D0 /* CCMesh.h */,
|
||||
3EA4786E195478E00068D9D1 /* CCBundleReader.cpp */,
|
||||
3EA4786F195478E00068D9D1 /* CCBundleReader.h */,
|
||||
B6AAF83F19404E0D0069DE01 /* CCBundle3D.cpp */,
|
||||
|
@ -5327,8 +5321,6 @@
|
|||
B6B26342193884D60088FE25 /* CCAnimation3D.h */,
|
||||
B6B2633B19381FBF0088FE25 /* CCAnimationCurve.inl */,
|
||||
B6B2633C19381FBF0088FE25 /* CCAnimationCurve.h */,
|
||||
B29594B91926D61F003EEF37 /* CCMesh.cpp */,
|
||||
B29594BA1926D61F003EEF37 /* CCMesh.h */,
|
||||
B29594BB1926D61F003EEF37 /* CCObjLoader.cpp */,
|
||||
B29594BC1926D61F003EEF37 /* CCObjLoader.h */,
|
||||
B29594BD1926D61F003EEF37 /* CCSprite3D.cpp */,
|
||||
|
@ -5353,8 +5345,8 @@
|
|||
1516201E199E75FE006099B8 /* CCRay.h in Headers */,
|
||||
1516201F199E75FE006099B8 /* CCSkeleton3D.h in Headers */,
|
||||
15162020199E75FE006099B8 /* CCAttachNode.h in Headers */,
|
||||
15162021199E75FE006099B8 /* CCSubMesh.h in Headers */,
|
||||
15162022199E75FF006099B8 /* CCSubMeshState.h in Headers */,
|
||||
15162021199E75FE006099B8 /* CCMeshVertexIndexData.h in Headers */,
|
||||
15162022199E75FF006099B8 /* CCMesh.h in Headers */,
|
||||
15162023199E75FF006099B8 /* CCBundleReader.h in Headers */,
|
||||
15162024199E75FF006099B8 /* CCBundle3D.h in Headers */,
|
||||
15162025199E75FF006099B8 /* CCAnimate3D.h in Headers */,
|
||||
|
@ -5362,7 +5354,6 @@
|
|||
15162026199E75FF006099B8 /* CCMeshSkin.h in Headers */,
|
||||
15162027199E75FF006099B8 /* CCAnimation3D.h in Headers */,
|
||||
15162028199E75FF006099B8 /* CCAnimationCurve.h in Headers */,
|
||||
15162029199E75FF006099B8 /* CCMesh.h in Headers */,
|
||||
1516202A199E75FF006099B8 /* CCObjLoader.h in Headers */,
|
||||
1516202B199E75FF006099B8 /* CCSprite3D.h in Headers */,
|
||||
1516202C199E75FF006099B8 /* CCSprite3DMaterial.h in Headers */,
|
||||
|
@ -5379,8 +5370,8 @@
|
|||
15162214199E7A32006099B8 /* CCRay.h in Headers */,
|
||||
15162215199E7A32006099B8 /* CCSkeleton3D.h in Headers */,
|
||||
15162216199E7A32006099B8 /* CCAttachNode.h in Headers */,
|
||||
15162217199E7A32006099B8 /* CCSubMesh.h in Headers */,
|
||||
15162218199E7A32006099B8 /* CCSubMeshState.h in Headers */,
|
||||
15162217199E7A32006099B8 /* CCMeshVertexIndexData.h in Headers */,
|
||||
15162218199E7A32006099B8 /* CCMesh.h in Headers */,
|
||||
15162219199E7A32006099B8 /* CCBundleReader.h in Headers */,
|
||||
1516221A199E7A32006099B8 /* CCBundle3D.h in Headers */,
|
||||
1516221B199E7A32006099B8 /* CCAnimate3D.h in Headers */,
|
||||
|
@ -5388,7 +5379,6 @@
|
|||
1516221C199E7A32006099B8 /* CCMeshSkin.h in Headers */,
|
||||
1516221D199E7A32006099B8 /* CCAnimation3D.h in Headers */,
|
||||
1516221E199E7A32006099B8 /* CCAnimationCurve.h in Headers */,
|
||||
1516221F199E7A32006099B8 /* CCMesh.h in Headers */,
|
||||
15162220199E7A32006099B8 /* CCObjLoader.h in Headers */,
|
||||
15162221199E7A32006099B8 /* CCSprite3D.h in Headers */,
|
||||
15162222199E7A32006099B8 /* CCSprite3DMaterial.h in Headers */,
|
||||
|
@ -6913,14 +6903,13 @@
|
|||
1516200E199E75C2006099B8 /* CCRay.cpp in Sources */,
|
||||
1516200F199E75C2006099B8 /* CCSkeleton3D.cpp in Sources */,
|
||||
15162010199E75C2006099B8 /* CCAttachNode.cpp in Sources */,
|
||||
15162011199E75C2006099B8 /* CCSubMesh.cpp in Sources */,
|
||||
15162012199E75C2006099B8 /* CCSubMeshState.cpp in Sources */,
|
||||
15162011199E75C2006099B8 /* CCMeshVertexIndexData.cpp in Sources */,
|
||||
15162012199E75C2006099B8 /* CCMesh.cpp in Sources */,
|
||||
15162013199E75C2006099B8 /* CCBundleReader.cpp in Sources */,
|
||||
15162014199E75C2006099B8 /* CCBundle3D.cpp in Sources */,
|
||||
15162015199E75C2006099B8 /* CCAnimate3D.cpp in Sources */,
|
||||
15162016199E75C2006099B8 /* CCMeshSkin.cpp in Sources */,
|
||||
15162017199E75C2006099B8 /* CCAnimation3D.cpp in Sources */,
|
||||
15162018199E75C2006099B8 /* CCMesh.cpp in Sources */,
|
||||
15162019199E75C2006099B8 /* CCObjLoader.cpp in Sources */,
|
||||
1516201A199E75C2006099B8 /* CCSprite3D.cpp in Sources */,
|
||||
1516201B199E75C2006099B8 /* CCSprite3DMaterial.cpp in Sources */,
|
||||
|
@ -6936,14 +6925,13 @@
|
|||
15162204199E7874006099B8 /* CCRay.cpp in Sources */,
|
||||
15162205199E7874006099B8 /* CCSkeleton3D.cpp in Sources */,
|
||||
15162206199E7874006099B8 /* CCAttachNode.cpp in Sources */,
|
||||
15162207199E7874006099B8 /* CCSubMesh.cpp in Sources */,
|
||||
15162208199E7874006099B8 /* CCSubMeshState.cpp in Sources */,
|
||||
15162207199E7874006099B8 /* CCMeshVertexIndexData.cpp in Sources */,
|
||||
15162208199E7874006099B8 /* CCMesh.cpp in Sources */,
|
||||
15162209199E7874006099B8 /* CCBundleReader.cpp in Sources */,
|
||||
1516220A199E7874006099B8 /* CCBundle3D.cpp in Sources */,
|
||||
1516220B199E7874006099B8 /* CCAnimate3D.cpp in Sources */,
|
||||
1516220C199E7874006099B8 /* CCMeshSkin.cpp in Sources */,
|
||||
1516220D199E7874006099B8 /* CCAnimation3D.cpp in Sources */,
|
||||
1516220E199E7874006099B8 /* CCMesh.cpp in Sources */,
|
||||
1516220F199E7874006099B8 /* CCObjLoader.cpp in Sources */,
|
||||
15162210199E7874006099B8 /* CCSprite3D.cpp in Sources */,
|
||||
15162211199E7874006099B8 /* CCSprite3DMaterial.cpp in Sources */,
|
||||
|
|
|
@ -22,17 +22,14 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCMesh.h"
|
||||
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "3d/CCSubMesh.h"
|
||||
#include "3d/CCObjLoader.h"
|
||||
#include "3d/CCSprite3DMaterial.h"
|
||||
#include "3d/CCSubMesh.h"
|
||||
#include "3d/CCMesh.h"
|
||||
#include "3d/CCMeshSkin.h"
|
||||
#include "3d/CCMeshVertexIndexData.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
|
@ -41,362 +38,263 @@
|
|||
#include "base/CCEventType.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "renderer/CCTexture2D.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCGLProgramCache.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
//bool RenderMeshData::hasVertexAttrib(int attrib)
|
||||
//{
|
||||
// for (auto itr = _vertexAttribs.begin(); itr != _vertexAttribs.end(); itr++)
|
||||
// {
|
||||
// if ((*itr).vertexAttrib == attrib)
|
||||
// return true; //already has
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
//
|
||||
//bool RenderMeshData::init(const std::vector<float>& positions,
|
||||
// const std::vector<float>& normals,
|
||||
// const std::vector<float>& texs,
|
||||
// const std::vector<IndexArray>& indices)
|
||||
//{
|
||||
// CC_ASSERT(positions.size()<65536 * 3 && "index may out of bound");
|
||||
//
|
||||
// _vertexAttribs.clear();
|
||||
//
|
||||
// _vertexNum = positions.size() / 3; //number of vertex
|
||||
// if (_vertexNum == 0)
|
||||
// return false;
|
||||
//
|
||||
// if ((normals.size() != 0 && _vertexNum * 3 != normals.size()) || (texs.size() != 0 && _vertexNum * 2 != texs.size()))
|
||||
// return false;
|
||||
//
|
||||
// MeshVertexAttrib meshvertexattrib;
|
||||
// meshvertexattrib.size = 3;
|
||||
// meshvertexattrib.type = GL_FLOAT;
|
||||
// meshvertexattrib.attribSizeBytes = meshvertexattrib.size * sizeof(float);
|
||||
// meshvertexattrib.vertexAttrib = GLProgram::VERTEX_ATTRIB_POSITION;
|
||||
// _vertexAttribs.push_back(meshvertexattrib);
|
||||
//
|
||||
// //normal
|
||||
// if (normals.size())
|
||||
// {
|
||||
// //add normal flag
|
||||
// meshvertexattrib.vertexAttrib = GLProgram::VERTEX_ATTRIB_NORMAL;
|
||||
// _vertexAttribs.push_back(meshvertexattrib);
|
||||
// }
|
||||
// //
|
||||
// if (texs.size())
|
||||
// {
|
||||
// meshvertexattrib.size = 2;
|
||||
// meshvertexattrib.vertexAttrib = GLProgram::VERTEX_ATTRIB_TEX_COORD;
|
||||
// meshvertexattrib.attribSizeBytes = meshvertexattrib.size * sizeof(float);
|
||||
// _vertexAttribs.push_back(meshvertexattrib);
|
||||
// }
|
||||
//
|
||||
// _vertexs.clear();
|
||||
// _vertexsizeBytes = calVertexSizeBytes();
|
||||
// _vertexs.reserve(_vertexNum * _vertexsizeBytes / sizeof(float));
|
||||
//
|
||||
// bool hasNormal = hasVertexAttrib(GLProgram::VERTEX_ATTRIB_NORMAL);
|
||||
// bool hasTexCoord = hasVertexAttrib(GLProgram::VERTEX_ATTRIB_TEX_COORD);
|
||||
// //position, normal, texCoordinate into _vertexs
|
||||
// for(int i = 0; i < _vertexNum; i++)
|
||||
// {
|
||||
// _vertexs.push_back(positions[i * 3]);
|
||||
// _vertexs.push_back(positions[i * 3 + 1]);
|
||||
// _vertexs.push_back(positions[i * 3 + 2]);
|
||||
//
|
||||
// if (hasNormal)
|
||||
// {
|
||||
// _vertexs.push_back(normals[i * 3]);
|
||||
// _vertexs.push_back(normals[i * 3 + 1]);
|
||||
// _vertexs.push_back(normals[i * 3 + 2]);
|
||||
// }
|
||||
//
|
||||
// if (hasTexCoord)
|
||||
// {
|
||||
// _vertexs.push_back(texs[i * 2]);
|
||||
// _vertexs.push_back(texs[i * 2 + 1]);
|
||||
// }
|
||||
// }
|
||||
// _subMeshIndices = indices;
|
||||
//
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//bool RenderMeshData::init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<IndexArray>& indices, const std::vector<MeshVertexAttrib>& attribs)
|
||||
//{
|
||||
// _vertexs = vertices;
|
||||
// _subMeshIndices = indices;
|
||||
// _vertexAttribs = attribs;
|
||||
//
|
||||
// _vertexsizeBytes = calVertexSizeBytes();
|
||||
//
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//int RenderMeshData::calVertexSizeBytes()
|
||||
//{
|
||||
// int sizeBytes = 0;
|
||||
// for (auto it = _vertexAttribs.begin(); it != _vertexAttribs.end(); it++) {
|
||||
// sizeBytes += (*it).size;
|
||||
// CCASSERT((*it).type == GL_FLOAT, "use float");
|
||||
// }
|
||||
// sizeBytes *= sizeof(float);
|
||||
//
|
||||
// return sizeBytes;
|
||||
//}
|
||||
//
|
||||
//Mesh::Mesh()
|
||||
//:_vertexBuffer(0)
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//Mesh::~Mesh()
|
||||
//{
|
||||
// _subMeshes.clear();
|
||||
// cleanAndFreeBuffers();
|
||||
//}
|
||||
//
|
||||
//Mesh* Mesh::create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const IndexArray& indices)
|
||||
//{
|
||||
// std::vector<IndexArray> submeshIndices;
|
||||
// submeshIndices.push_back(indices);
|
||||
// return create(positions, normals, texs, submeshIndices);
|
||||
//}
|
||||
//
|
||||
//Mesh* Mesh::create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<IndexArray>& indices)
|
||||
//{
|
||||
// auto mesh = new Mesh();
|
||||
// if(mesh && mesh->init(positions, normals, texs, indices))
|
||||
// {
|
||||
// mesh->autorelease();
|
||||
// return mesh;
|
||||
// }
|
||||
// CC_SAFE_DELETE(mesh);
|
||||
// return nullptr;
|
||||
//}
|
||||
//
|
||||
//Mesh* Mesh::create(const std::vector<float>& vertices, int vertexSizeInFloat, const IndexArray& indices, const std::vector<MeshVertexAttrib>& attribs)
|
||||
//{
|
||||
// std::vector<IndexArray> submeshIndices;
|
||||
// submeshIndices.push_back(indices);
|
||||
// return create(vertices, vertexSizeInFloat, submeshIndices, attribs);
|
||||
//}
|
||||
//
|
||||
//Mesh* Mesh::create(const std::vector<float> &vertices, int vertexSizeInFloat, const std::vector<IndexArray> &indices, const std::vector<MeshVertexAttrib> &attribs)
|
||||
//{
|
||||
// auto mesh = new Mesh();
|
||||
// if (mesh && mesh->init(vertices, vertexSizeInFloat, indices, attribs))
|
||||
// {
|
||||
// mesh->autorelease();
|
||||
// return mesh;
|
||||
// }
|
||||
// CC_SAFE_DELETE(mesh);
|
||||
// return nullptr;
|
||||
//}
|
||||
//
|
||||
//Mesh* Mesh::create(const MeshData& meshdata)
|
||||
//{
|
||||
// auto mesh = new Mesh();
|
||||
// if (mesh && mesh->init(meshdata.vertex, meshdata.vertexSizeInFloat, meshdata.subMeshIndices, meshdata.attribs))
|
||||
// {
|
||||
// for (int i = 0; i < (int)mesh->getSubMeshCount(); i++) {
|
||||
// auto submesh = mesh->getSubMesh(i);
|
||||
// if (meshdata.subMeshIds.size())
|
||||
// submesh->_id = meshdata.subMeshIds[i];
|
||||
// submesh->_mesh = mesh;
|
||||
// }
|
||||
// }
|
||||
// mesh->autorelease();
|
||||
// return mesh;
|
||||
//}
|
||||
//
|
||||
//bool Mesh::init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<IndexArray>& indices)
|
||||
//{
|
||||
// bool bRet = _renderdata.init(positions, normals, texs, indices);
|
||||
// if (!bRet)
|
||||
// return false;
|
||||
//
|
||||
// buildSubMeshes();
|
||||
//
|
||||
// buildBuffer();
|
||||
//
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//bool Mesh::init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<IndexArray>& indices, const std::vector<MeshVertexAttrib>& attribs)
|
||||
//{
|
||||
// bool bRet = _renderdata.init(vertices, vertexSizeInFloat, indices, attribs);
|
||||
// if (!bRet)
|
||||
// return false;
|
||||
//
|
||||
// buildSubMeshes();
|
||||
//
|
||||
// buildBuffer();
|
||||
//
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//void Mesh::buildSubMeshes()
|
||||
//{
|
||||
// _subMeshes.clear();
|
||||
// for (auto& it : _renderdata._subMeshIndices) {
|
||||
// auto subMesh = SubMesh::create(PrimitiveType::TRIANGLES, IndexFormat::INDEX16, it);
|
||||
// _subMeshes.pushBack(subMesh);
|
||||
//
|
||||
// //calculate aabb for sub mesh
|
||||
// AABB aabb;
|
||||
// int stride = _renderdata._vertexsizeBytes / sizeof(float);
|
||||
// for(const auto& index : it)
|
||||
// {
|
||||
// Vec3 point = Vec3(_renderdata._vertexs[index * stride ], _renderdata._vertexs[ index * stride + 1], _renderdata._vertexs[index * stride + 2 ]);
|
||||
// aabb.updateMinMax(&point, 1);
|
||||
// }
|
||||
// subMesh->_aabb = aabb;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void Mesh::cleanAndFreeBuffers()
|
||||
//{
|
||||
// if(glIsBuffer(_vertexBuffer))
|
||||
// {
|
||||
// glDeleteBuffers(1, &_vertexBuffer);
|
||||
// _vertexBuffer = 0;
|
||||
// }
|
||||
//
|
||||
// for (auto& it : _subMeshes) {
|
||||
// (*it).cleanAndFreeBuffers();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void Mesh::buildBuffer()
|
||||
//{
|
||||
// cleanAndFreeBuffers();
|
||||
//
|
||||
// glGenBuffers(1, &_vertexBuffer);
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
|
||||
//
|
||||
// glBufferData(GL_ARRAY_BUFFER,
|
||||
// _renderdata._vertexs.size() * sizeof(_renderdata._vertexs[0]),
|
||||
// &_renderdata._vertexs[0],
|
||||
// GL_STATIC_DRAW);
|
||||
// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
//
|
||||
// for (size_t i = 0; i < _subMeshes.size(); i++) {
|
||||
// _subMeshes.at(i)->buildBuffer(_renderdata._subMeshIndices[i]);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void Mesh::restore()
|
||||
//{
|
||||
// _vertexBuffer = 0;
|
||||
// for (auto& it : _subMeshes) {
|
||||
// it->_indexBuffer = 0;
|
||||
// }
|
||||
//
|
||||
// buildBuffer();
|
||||
//}
|
||||
//
|
||||
//SubMesh* Mesh::getSubMeshById(const std::string& subMeshId) const
|
||||
//{
|
||||
// for (auto it : _subMeshes) {
|
||||
// if (it->getSubMeshId() == subMeshId)
|
||||
// return it;
|
||||
// }
|
||||
// return nullptr;
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * MeshCache
|
||||
// */
|
||||
//MeshCache* MeshCache::_cacheInstance = nullptr;
|
||||
//
|
||||
//MeshCache* MeshCache::getInstance()
|
||||
//{
|
||||
// if (_cacheInstance == nullptr)
|
||||
// _cacheInstance = new MeshCache();
|
||||
//
|
||||
// return _cacheInstance;
|
||||
//}
|
||||
//void MeshCache::destroyInstance()
|
||||
//{
|
||||
// if (_cacheInstance)
|
||||
// CC_SAFE_DELETE(_cacheInstance);
|
||||
//}
|
||||
//
|
||||
//Mesh* MeshCache::getMesh(const std::string& key) const
|
||||
//{
|
||||
// auto it = _meshes.find(key);
|
||||
// if (it != _meshes.end())
|
||||
// return it->second;
|
||||
//
|
||||
// return nullptr;
|
||||
//}
|
||||
//
|
||||
//bool MeshCache::addMesh(const std::string& key, Mesh* mesh)
|
||||
//{
|
||||
// auto it = _meshes.find(key);
|
||||
// if (it == _meshes.end())
|
||||
// {
|
||||
// mesh->retain();
|
||||
// _meshes[key] = mesh;
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
//
|
||||
//void MeshCache::removeAllMeshes()
|
||||
//{
|
||||
// for (auto it : _meshes) {
|
||||
// CC_SAFE_RELEASE(it.second);
|
||||
// }
|
||||
// _meshes.clear();
|
||||
//}
|
||||
//
|
||||
//void MeshCache::removeUnusedMesh()
|
||||
//{
|
||||
// for( auto it=_meshes.cbegin(); it!=_meshes.cend(); /* nothing */) {
|
||||
// if(it->second->getReferenceCount() == 1)
|
||||
// {
|
||||
// it->second->release();
|
||||
// _meshes.erase(it++);
|
||||
// }
|
||||
// else
|
||||
// ++it;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//MeshCache::MeshCache()
|
||||
//{
|
||||
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
// // listen the event that renderer was recreated on Android/WP8
|
||||
// _rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(MeshCache::listenRendererRecreated, this));
|
||||
// Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
|
||||
//#endif
|
||||
//}
|
||||
//MeshCache::~MeshCache()
|
||||
//{
|
||||
// removeAllMeshes();
|
||||
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
// Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
|
||||
//#endif
|
||||
//}
|
||||
//
|
||||
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
//void MeshCache::listenRendererRecreated(EventCustom* event)
|
||||
//{
|
||||
// for (auto iter = _meshes.begin(); iter != _meshes.end(); ++iter)
|
||||
// {
|
||||
// auto mesh = iter->second;
|
||||
// mesh->restore();
|
||||
// }
|
||||
//}
|
||||
//#endif
|
||||
Mesh::Mesh()
|
||||
: _visible(true)
|
||||
, _texture(nullptr)
|
||||
, _skin(nullptr)
|
||||
, _meshIndexData(nullptr)
|
||||
, _visibleChanged(nullptr)
|
||||
, _glProgramState(nullptr)
|
||||
, _blend(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||
{
|
||||
|
||||
}
|
||||
Mesh::~Mesh()
|
||||
{
|
||||
CC_SAFE_RELEASE(_texture);
|
||||
CC_SAFE_RELEASE(_skin);
|
||||
CC_SAFE_RELEASE(_meshIndexData);
|
||||
CC_SAFE_RELEASE(_glProgramState);
|
||||
}
|
||||
|
||||
GLuint Mesh::getVertexBuffer() const
|
||||
{
|
||||
return _meshIndexData->getVertexBuffer()->getVBO();
|
||||
}
|
||||
|
||||
bool Mesh::hasVertexAttrib(int attrib) const
|
||||
{
|
||||
return _meshIndexData->getMeshVertexData()->hasVertexAttrib(attrib);
|
||||
}
|
||||
|
||||
ssize_t Mesh::getMeshVertexAttribCount() const
|
||||
{
|
||||
return _meshIndexData->getMeshVertexData()->getMeshVertexAttribCount();
|
||||
}
|
||||
|
||||
const MeshVertexAttrib& Mesh::getMeshVertexAttribute(int idx)
|
||||
{
|
||||
return _meshIndexData->getMeshVertexData()->getMeshVertexAttrib(idx);
|
||||
}
|
||||
|
||||
int Mesh::getVertexSizeInBytes() const
|
||||
{
|
||||
return _meshIndexData->getVertexBuffer()->getSizePerVertex();
|
||||
}
|
||||
|
||||
Mesh* Mesh::create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const IndexArray& indices)
|
||||
{
|
||||
int perVertexSizeInFloat = 0;
|
||||
std::vector<float> vertices;
|
||||
std::vector<MeshVertexAttrib> attribs;
|
||||
MeshVertexAttrib att;
|
||||
att.size = 3;
|
||||
att.type = GL_FLOAT;
|
||||
att.attribSizeBytes = att.size * sizeof(float);
|
||||
|
||||
if (positions.size())
|
||||
{
|
||||
perVertexSizeInFloat += 3;
|
||||
att.vertexAttrib = GLProgram::VERTEX_ATTRIB_POSITION;
|
||||
attribs.push_back(att);
|
||||
}
|
||||
if (normals.size())
|
||||
{
|
||||
perVertexSizeInFloat += 3;
|
||||
att.vertexAttrib = GLProgram::VERTEX_ATTRIB_NORMAL;
|
||||
attribs.push_back(att);
|
||||
}
|
||||
if (texs.size())
|
||||
{
|
||||
perVertexSizeInFloat += 2;
|
||||
att.vertexAttrib = GLProgram::VERTEX_ATTRIB_TEX_COORD;
|
||||
att.size = 2;
|
||||
att.attribSizeBytes = att.size * sizeof(float);
|
||||
attribs.push_back(att);
|
||||
}
|
||||
|
||||
bool hasNormal = (normals.size() != 0);
|
||||
bool hasTexCoord = (texs.size() != 0);
|
||||
//position, normal, texCoordinate into _vertexs
|
||||
size_t vertexNum = positions.size() / 3;
|
||||
for(size_t i = 0; i < vertexNum; i++)
|
||||
{
|
||||
vertices.push_back(positions[i * 3]);
|
||||
vertices.push_back(positions[i * 3 + 1]);
|
||||
vertices.push_back(positions[i * 3 + 2]);
|
||||
|
||||
if (hasNormal)
|
||||
{
|
||||
vertices.push_back(normals[i * 3]);
|
||||
vertices.push_back(normals[i * 3 + 1]);
|
||||
vertices.push_back(normals[i * 3 + 2]);
|
||||
}
|
||||
|
||||
if (hasTexCoord)
|
||||
{
|
||||
vertices.push_back(texs[i * 2]);
|
||||
vertices.push_back(texs[i * 2 + 1]);
|
||||
}
|
||||
}
|
||||
return create(vertices, perVertexSizeInFloat, indices, attribs);
|
||||
}
|
||||
|
||||
Mesh* Mesh::create(const std::vector<float>& vertices, int perVertexSizeInFloat, const IndexArray& indices, const std::vector<MeshVertexAttrib>& attribs)
|
||||
{
|
||||
MeshData meshdata;
|
||||
meshdata.attribs = attribs;
|
||||
meshdata.vertex = vertices;
|
||||
meshdata.subMeshIndices.push_back(indices);
|
||||
meshdata.subMeshIds.push_back("");
|
||||
auto meshvertexdata = MeshVertexData::create(meshdata);
|
||||
auto indexbuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, (int)indices.size());
|
||||
|
||||
AABB aabb = MeshVertexData::calculateAABB(meshdata.vertex, meshdata.getPerVertexSize(), indices);
|
||||
auto indexData = MeshIndexData::create("", meshvertexdata, indexbuffer, aabb);
|
||||
|
||||
return create("", indexData);
|
||||
}
|
||||
|
||||
Mesh* Mesh::create(const std::string& name, MeshIndexData* indexData, MeshSkin* skin)
|
||||
{
|
||||
auto state = new Mesh();
|
||||
state->autorelease();
|
||||
state->bindMeshCommand();
|
||||
state->_name = name;
|
||||
state->setMeshIndexData(indexData);
|
||||
state->setSkin(skin);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void Mesh::setVisible(bool visible)
|
||||
{
|
||||
if (_visible != visible)
|
||||
{
|
||||
_visible = visible;
|
||||
if (_visibleChanged)
|
||||
_visibleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setTexture(const std::string& texPath)
|
||||
{
|
||||
auto tex = Director::getInstance()->getTextureCache()->addImage(texPath);
|
||||
setTexture(tex);
|
||||
}
|
||||
|
||||
void Mesh::setTexture(Texture2D* tex)
|
||||
{
|
||||
if (tex != _texture)
|
||||
{
|
||||
CC_SAFE_RETAIN(tex);
|
||||
CC_SAFE_RELEASE(_texture);
|
||||
_texture = tex;
|
||||
bindMeshCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setSkin(MeshSkin* skin)
|
||||
{
|
||||
if (_skin != skin)
|
||||
{
|
||||
CC_SAFE_RETAIN(skin);
|
||||
CC_SAFE_RELEASE(_skin);
|
||||
_skin = skin;
|
||||
calcuateAABB();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setMeshIndexData(MeshIndexData* subMesh)
|
||||
{
|
||||
if (_meshIndexData != subMesh)
|
||||
{
|
||||
CC_SAFE_RETAIN(subMesh);
|
||||
CC_SAFE_RELEASE(_meshIndexData);
|
||||
_meshIndexData = subMesh;
|
||||
calcuateAABB();
|
||||
bindMeshCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setGLProgramState(GLProgramState* glProgramState)
|
||||
{
|
||||
if (_glProgramState != glProgramState)
|
||||
{
|
||||
CC_SAFE_RETAIN(glProgramState);
|
||||
CC_SAFE_RELEASE(_glProgramState);
|
||||
_glProgramState = glProgramState;
|
||||
bindMeshCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::calcuateAABB()
|
||||
{
|
||||
if (_meshIndexData)
|
||||
{
|
||||
_aabb = _meshIndexData->getAABB();
|
||||
if (_skin)
|
||||
{
|
||||
Bone3D* root = _skin->getRootBone();
|
||||
if (root)
|
||||
{
|
||||
_aabb.transform(root->getWorldMat());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::bindMeshCommand()
|
||||
{
|
||||
if (_glProgramState && _meshIndexData && _texture)
|
||||
{
|
||||
GLuint texID = _texture ? _texture->getName() : 0;
|
||||
_meshCommand.genMaterialID(texID, _glProgramState, _meshIndexData->getVertexBuffer()->getVBO(), _meshIndexData->getIndexBuffer()->getVBO(), _blend);
|
||||
_meshCommand.setCullFaceEnabled(true);
|
||||
_meshCommand.setDepthTestEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setBlendFunc(const BlendFunc &blendFunc)
|
||||
{
|
||||
if(_blend.src != blendFunc.src || _blend.dst != blendFunc.dst)
|
||||
{
|
||||
_blend = blendFunc;
|
||||
bindMeshCommand();
|
||||
}
|
||||
}
|
||||
const BlendFunc &Mesh::getBlendFunc() const
|
||||
{
|
||||
return _blend;
|
||||
}
|
||||
|
||||
GLenum Mesh::getPrimitiveType() const
|
||||
{
|
||||
return _meshIndexData->getPrimitiveType();
|
||||
}
|
||||
|
||||
ssize_t Mesh::getIndexCount() const
|
||||
{
|
||||
return _meshIndexData->getIndexBuffer()->getIndexNumber();
|
||||
}
|
||||
|
||||
GLenum Mesh::getIndexFormat() const
|
||||
{
|
||||
return GL_UNSIGNED_SHORT;
|
||||
}
|
||||
|
||||
GLuint Mesh::getIndexBuffer() const
|
||||
{
|
||||
return _meshIndexData->getIndexBuffer()->getVBO();
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -29,183 +29,121 @@
|
|||
#include <vector>
|
||||
|
||||
#include "3d/CCBundle3DData.h"
|
||||
#include "3d/CCSubMesh.h"
|
||||
#include "3d/CCAABB.h"
|
||||
|
||||
#include "base/CCRef.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "base/CCVector.h"
|
||||
#include "math/CCMath.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
|
||||
#include "CCAABB.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/CCMeshCommand.h"
|
||||
#include "3d/3dExport.h"
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class EventListenerCustom;
|
||||
class EventCustom;
|
||||
class Texture2D;
|
||||
class MeshSkin;
|
||||
class MeshIndexData;
|
||||
/**
|
||||
* SubMeshState: visibility and apperence of submesh
|
||||
*/
|
||||
class CC_3D_DLL Mesh : public Ref
|
||||
{
|
||||
friend class Sprite3D;
|
||||
public:
|
||||
typedef std::vector<unsigned short> IndexArray;
|
||||
/**create mesh from positions, normals, and so on, sigle SubMesh*/
|
||||
static Mesh* create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const IndexArray& indices);
|
||||
/**create mesh with vertex attributes*/
|
||||
CC_DEPRECATED_ATTRIBUTE static Mesh* create(const std::vector<float>& vertices, int perVertexSizeInFloat, const IndexArray& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount){ return create(vertices, perVertexSizeInFloat, indices, attribs); }
|
||||
|
||||
static Mesh* create(const std::vector<float>& vertices, int perVertexSizeInFloat, const IndexArray& indices, const std::vector<MeshVertexAttrib>& attribs);
|
||||
|
||||
/** create mesh */
|
||||
static Mesh* create(const std::string& name, MeshIndexData* indexData, MeshSkin* skin = nullptr);
|
||||
|
||||
/**get vertex buffer*/
|
||||
GLuint getVertexBuffer() const;
|
||||
/**has vertex attribute?*/
|
||||
bool hasVertexAttrib(int attrib) const;
|
||||
/**get mesh vertex attribute count*/
|
||||
ssize_t getMeshVertexAttribCount() const;
|
||||
/**get MeshVertexAttribute by index*/
|
||||
const MeshVertexAttrib& getMeshVertexAttribute(int idx);
|
||||
/**get per vertex size in bytes*/
|
||||
int getVertexSizeInBytes() const;
|
||||
|
||||
//class CC_3D_DLL RenderMeshData
|
||||
//{
|
||||
// typedef std::vector<unsigned short> IndexArray;
|
||||
// friend class Mesh;
|
||||
//public:
|
||||
// RenderMeshData(): _vertexsizeBytes(0)
|
||||
// {
|
||||
// }
|
||||
// bool hasVertexAttrib(int attrib);
|
||||
// bool init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<IndexArray>& subMeshIndices);
|
||||
// bool init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<IndexArray>& subMeshIndices, const std::vector<MeshVertexAttrib>& attribs);
|
||||
//
|
||||
//protected:
|
||||
//
|
||||
// int calVertexSizeBytes();
|
||||
//
|
||||
// int _vertexsizeBytes;
|
||||
// ssize_t _vertexNum;
|
||||
// std::vector<float> _vertexs;
|
||||
// std::vector<IndexArray> _subMeshIndices;
|
||||
// std::vector<MeshVertexAttrib> _vertexAttribs;
|
||||
//};
|
||||
//
|
||||
///**
|
||||
// * Mesh: Geometry with a collection of vertex.
|
||||
// * Supporting various vertex formats.
|
||||
// */
|
||||
//class CC_3D_DLL Mesh : public Ref
|
||||
//{
|
||||
// typedef std::vector<unsigned short> IndexArray;
|
||||
//public:
|
||||
// /**create mesh from positions, normals, and so on, sigle SubMesh*/
|
||||
// static Mesh* create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const IndexArray& indices);
|
||||
//
|
||||
// /**create mesh from positions, normals, and so on, multi-SubMesh*/
|
||||
// static Mesh* create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<IndexArray>& subMeshIndices);
|
||||
//
|
||||
// /**create mesh with vertex attributes*/
|
||||
// CC_DEPRECATED_ATTRIBUTE static Mesh* create(const std::vector<float>& vertices, int vertexSizeInFloat, const IndexArray& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount) { return create(vertices, vertexSizeInFloat, indices, attribs); }
|
||||
//
|
||||
// /**
|
||||
// * create Mesh
|
||||
// * @param vertices vertices buffer data
|
||||
// * @param vertexSizeInFloat size of each vertex
|
||||
// * @param indices index buffer data that denotes how to connect the vertex, sigle SubMesh
|
||||
// * @param attribs vertex attributes
|
||||
// */
|
||||
// static Mesh* create(const std::vector<float>& vertices, int vertexSizeInFloat, const IndexArray& indices, const std::vector<MeshVertexAttrib>& attribs);
|
||||
//
|
||||
// /**
|
||||
// * create Mesh
|
||||
// * @param vertices vertices buffer data
|
||||
// * @param vertexSizeInFloat size of each vertex
|
||||
// * @param subMeshIndices index buffer data that denotes how to connect the vertex, multi-SubMesh
|
||||
// * @param attribs vertex attributes
|
||||
// */
|
||||
// static Mesh* create(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<IndexArray>& subMeshIndices, const std::vector<MeshVertexAttrib>& attribs);
|
||||
//
|
||||
// static Mesh* create(const MeshData& meshdata);
|
||||
//
|
||||
// /**get vertex buffer*/
|
||||
// inline GLuint getVertexBuffer() const { return _vertexBuffer; }
|
||||
//
|
||||
// /**get mesh vertex attribute count*/
|
||||
// ssize_t getMeshVertexAttribCount() const { return _renderdata._vertexAttribs.size(); }
|
||||
// /**get MeshVertexAttribute by index*/
|
||||
// const MeshVertexAttrib& getMeshVertexAttribute(int idx) const { return _renderdata._vertexAttribs[idx]; }
|
||||
// /**has vertex attribute?*/
|
||||
// bool hasVertexAttrib(int attrib) { return _renderdata.hasVertexAttrib(attrib); }
|
||||
// /**get per vertex size in bytes*/
|
||||
// int getVertexSizeInBytes() const { return _renderdata._vertexsizeBytes; }
|
||||
//
|
||||
// /**get sub mesh count*/
|
||||
// ssize_t getSubMeshCount() const { return _subMeshes.size(); }
|
||||
//
|
||||
// /**get sub mesh by index*/
|
||||
// SubMesh* getSubMesh(int index) const { return _subMeshes.at(index); }
|
||||
//
|
||||
// /**build vertex buffer from renderdata*/
|
||||
// void restore();
|
||||
//
|
||||
// /** get submesh by id */
|
||||
// SubMesh* getSubMeshById(const std::string& subMeshId) const;
|
||||
//
|
||||
// /**to be deprecated, those functions have been moved to SubMesh*/
|
||||
// /** get primitive type*/
|
||||
// CC_DEPRECATED_ATTRIBUTE PrimitiveType getPrimitiveType() const { return _subMeshes.at(0)->getPrimitiveType(); }
|
||||
// /**get index count*/
|
||||
// CC_DEPRECATED_ATTRIBUTE ssize_t getIndexCount() const { return _subMeshes.at(0)->getIndexCount(); }
|
||||
// /**get index format*/
|
||||
// CC_DEPRECATED_ATTRIBUTE IndexFormat getIndexFormat() const { return _subMeshes.at(0)->getIndexFormat(); }
|
||||
// /**get index buffer*/
|
||||
// CC_DEPRECATED_ATTRIBUTE GLuint getIndexBuffer() const {return _subMeshes.at(0)->getIndexBuffer(); }
|
||||
//
|
||||
//CC_CONSTRUCTOR_ACCESS:
|
||||
//
|
||||
// Mesh();
|
||||
// virtual ~Mesh();
|
||||
// /**init mesh*/
|
||||
// bool init(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const std::vector<IndexArray>& indices);
|
||||
//
|
||||
// /**init mesh*/
|
||||
// bool init(const std::vector<float>& vertices, int vertexSizeInFloat, const std::vector<IndexArray>& indices, const std::vector<MeshVertexAttrib>& attribs);
|
||||
//
|
||||
// /**build sub meshes*/
|
||||
// void buildSubMeshes();
|
||||
// /**build buffer*/
|
||||
// void buildBuffer();
|
||||
// /**free buffer*/
|
||||
// void cleanAndFreeBuffers();
|
||||
//
|
||||
//protected:
|
||||
// GLuint _vertexBuffer;
|
||||
// Vector<SubMesh*> _subMeshes;
|
||||
//
|
||||
// RenderMeshData _renderdata;
|
||||
//};
|
||||
//
|
||||
///**
|
||||
// * Mesh Cache
|
||||
// */
|
||||
//class MeshCache
|
||||
//{
|
||||
//public:
|
||||
// /**get & destroy*/
|
||||
// static MeshCache* getInstance();
|
||||
// static void destroyInstance();
|
||||
//
|
||||
// /**get mesh from cache*/
|
||||
// Mesh* getMesh(const std::string& key) const;
|
||||
//
|
||||
// /**add mesh to cache*/
|
||||
// bool addMesh(const std::string& key, Mesh* mesh);
|
||||
//
|
||||
// /**remove all meshes*/
|
||||
// void removeAllMeshes();
|
||||
//
|
||||
// /**remove unused meshes*/
|
||||
// void removeUnusedMesh();
|
||||
//
|
||||
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
// void listenRendererRecreated(EventCustom* event);
|
||||
//#endif
|
||||
//
|
||||
//CC_CONSTRUCTOR_ACCESS:
|
||||
//
|
||||
// MeshCache();
|
||||
// ~MeshCache();
|
||||
//
|
||||
//protected:
|
||||
//
|
||||
// static MeshCache* _cacheInstance;//instance
|
||||
//
|
||||
// std::unordered_map<std::string, Mesh*> _meshes; //cached meshes
|
||||
//
|
||||
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
// EventListenerCustom* _rendererRecreatedListener;
|
||||
//#endif
|
||||
//};
|
||||
/**texture getter and setter*/
|
||||
void setTexture(const std::string& texPath);
|
||||
void setTexture(Texture2D* tex);
|
||||
Texture2D* getTexture() const { return _texture; }
|
||||
|
||||
/**visible getter and setter*/
|
||||
void setVisible(bool visible);
|
||||
bool isVisible() const { return _visible; }
|
||||
|
||||
/**skin getter */
|
||||
MeshSkin* getSkin() const { return _skin; }
|
||||
|
||||
/**mesh index data getter */
|
||||
MeshIndexData* getMeshIndexData() const { return _meshIndexData; }
|
||||
|
||||
/**get GLProgramState*/
|
||||
GLProgramState* getGLProgramState() const { return _glProgramState; }
|
||||
|
||||
/**name getter */
|
||||
const std::string& getName() const { return _name; }
|
||||
|
||||
void setBlendFunc(const BlendFunc &blendFunc);
|
||||
const BlendFunc &getBlendFunc() const;
|
||||
|
||||
/** get primitive type*/
|
||||
GLenum getPrimitiveType() const;
|
||||
/**get index count*/
|
||||
ssize_t getIndexCount() const;
|
||||
/**get index format*/
|
||||
GLenum getIndexFormat() const;
|
||||
/**get index buffer*/
|
||||
GLuint getIndexBuffer() const;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
Mesh();
|
||||
virtual ~Mesh();
|
||||
|
||||
GLProgram* getDefaultGLProgram(bool textured);
|
||||
|
||||
void setGLProgramState(GLProgramState* glProgramState);
|
||||
|
||||
MeshCommand& getMeshCommand() { return _meshCommand; }
|
||||
|
||||
/**skin setter*/
|
||||
void setSkin(MeshSkin* skin);
|
||||
/**Mesh index data setter*/
|
||||
void setMeshIndexData(MeshIndexData* indexdata);
|
||||
/**name setter*/
|
||||
void setName(const std::string& name) { _name = name; }
|
||||
|
||||
const AABB& getAABB() const { return _aabb; }
|
||||
|
||||
void calcuateAABB();
|
||||
|
||||
void bindMeshCommand();
|
||||
protected:
|
||||
Texture2D* _texture; //texture that submesh is using
|
||||
MeshSkin* _skin; //skin
|
||||
bool _visible; // is the submesh visible
|
||||
|
||||
//since 3.3
|
||||
std::string _name;
|
||||
MeshIndexData* _meshIndexData;
|
||||
GLProgramState* _glProgramState;
|
||||
MeshCommand _meshCommand;
|
||||
BlendFunc _blend;
|
||||
AABB _aabb;
|
||||
std::function<void()> _visibleChanged;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCMESH_H_
|
||||
#endif // __CCMESH_H__
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCSubMesh.h"
|
||||
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "3d/CCMeshVertexIndexData.h"
|
||||
#include "3d/CCObjLoader.h"
|
||||
#include "3d/CCSprite3DMaterial.h"
|
||||
#include "3d/CCMesh.h"
|
|
@ -22,8 +22,8 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCSUBMESH_H__
|
||||
#define __CCSUBMESH_H__
|
||||
#ifndef __CCMESHVERTEXINDEXDATA_H__
|
||||
#define __CCMESHVERTEXINDEXDATA_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -126,4 +126,4 @@ protected:
|
|||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCSUBMESH_H_
|
||||
#endif // __CCMESHVERTEXINDEXDATA_H__
|
|
@ -23,14 +23,11 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "3d/CCSprite3D.h"
|
||||
#include "3d/CCMesh.h"
|
||||
#include "3d/CCObjLoader.h"
|
||||
#include "3d/CCMeshSkin.h"
|
||||
#include "3d/CCBundle3D.h"
|
||||
#include "3d/CCSprite3DMaterial.h"
|
||||
#include "3d/CCSubMesh.h"
|
||||
#include "3d/CCAttachNode.h"
|
||||
#include "3d/CCSubMeshState.h"
|
||||
#include "3d/CCSkeleton3D.h"
|
||||
|
||||
#include "base/CCDirector.h"
|
||||
|
|
|
@ -36,8 +36,7 @@
|
|||
#include "3d/CCAABB.h"
|
||||
#include "3d/CCBundle3DData.h"
|
||||
#include "3d/CCMesh.h"
|
||||
#include "3d/CCSubMeshState.h"
|
||||
#include "3d/CCSubMesh.h"
|
||||
#include "3d/CCMeshVertexIndexData.h"
|
||||
#include "3d/3dExport.h"
|
||||
|
||||
|
||||
|
|
|
@ -1,301 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "3d/CCSubMeshState.h"
|
||||
#include "3d/CCMeshSkin.h"
|
||||
#include "3d/CCSubMesh.h"
|
||||
#include "3d/CCSprite3D.h"
|
||||
|
||||
#include "base/ccMacros.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
#include "base/CCEventListenerCustom.h"
|
||||
#include "base/CCEventDispatcher.h"
|
||||
#include "base/CCEventType.h"
|
||||
#include "base/CCDirector.h"
|
||||
#include "renderer/ccGLStateCache.h"
|
||||
#include "renderer/CCTexture2D.h"
|
||||
#include "renderer/CCTextureCache.h"
|
||||
#include "renderer/CCGLProgramCache.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Mesh::Mesh()
|
||||
: _visible(true)
|
||||
, _texture(nullptr)
|
||||
, _skin(nullptr)
|
||||
, _meshIndexData(nullptr)
|
||||
, _visibleChanged(nullptr)
|
||||
, _glProgramState(nullptr)
|
||||
, _blend(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||
{
|
||||
|
||||
}
|
||||
Mesh::~Mesh()
|
||||
{
|
||||
CC_SAFE_RELEASE(_texture);
|
||||
CC_SAFE_RELEASE(_skin);
|
||||
CC_SAFE_RELEASE(_meshIndexData);
|
||||
CC_SAFE_RELEASE(_glProgramState);
|
||||
}
|
||||
|
||||
GLuint Mesh::getVertexBuffer() const
|
||||
{
|
||||
return _meshIndexData->getVertexBuffer()->getVBO();
|
||||
}
|
||||
|
||||
bool Mesh::hasVertexAttrib(int attrib) const
|
||||
{
|
||||
return _meshIndexData->getMeshVertexData()->hasVertexAttrib(attrib);
|
||||
}
|
||||
|
||||
ssize_t Mesh::getMeshVertexAttribCount() const
|
||||
{
|
||||
return _meshIndexData->getMeshVertexData()->getMeshVertexAttribCount();
|
||||
}
|
||||
|
||||
const MeshVertexAttrib& Mesh::getMeshVertexAttribute(int idx)
|
||||
{
|
||||
return _meshIndexData->getMeshVertexData()->getMeshVertexAttrib(idx);
|
||||
}
|
||||
|
||||
int Mesh::getVertexSizeInBytes() const
|
||||
{
|
||||
return _meshIndexData->getVertexBuffer()->getSizePerVertex();
|
||||
}
|
||||
|
||||
Mesh* Mesh::create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const IndexArray& indices)
|
||||
{
|
||||
int perVertexSizeInFloat = 0;
|
||||
std::vector<float> vertices;
|
||||
std::vector<MeshVertexAttrib> attribs;
|
||||
MeshVertexAttrib att;
|
||||
att.size = 3;
|
||||
att.type = GL_FLOAT;
|
||||
att.attribSizeBytes = att.size * sizeof(float);
|
||||
|
||||
if (positions.size())
|
||||
{
|
||||
perVertexSizeInFloat += 3;
|
||||
att.vertexAttrib = GLProgram::VERTEX_ATTRIB_POSITION;
|
||||
attribs.push_back(att);
|
||||
}
|
||||
if (normals.size())
|
||||
{
|
||||
perVertexSizeInFloat += 3;
|
||||
att.vertexAttrib = GLProgram::VERTEX_ATTRIB_NORMAL;
|
||||
attribs.push_back(att);
|
||||
}
|
||||
if (texs.size())
|
||||
{
|
||||
perVertexSizeInFloat += 2;
|
||||
att.vertexAttrib = GLProgram::VERTEX_ATTRIB_TEX_COORD;
|
||||
att.size = 2;
|
||||
att.attribSizeBytes = att.size * sizeof(float);
|
||||
attribs.push_back(att);
|
||||
}
|
||||
|
||||
bool hasNormal = (normals.size() != 0);
|
||||
bool hasTexCoord = (texs.size() != 0);
|
||||
//position, normal, texCoordinate into _vertexs
|
||||
size_t vertexNum = positions.size() / 3;
|
||||
for(size_t i = 0; i < vertexNum; i++)
|
||||
{
|
||||
vertices.push_back(positions[i * 3]);
|
||||
vertices.push_back(positions[i * 3 + 1]);
|
||||
vertices.push_back(positions[i * 3 + 2]);
|
||||
|
||||
if (hasNormal)
|
||||
{
|
||||
vertices.push_back(normals[i * 3]);
|
||||
vertices.push_back(normals[i * 3 + 1]);
|
||||
vertices.push_back(normals[i * 3 + 2]);
|
||||
}
|
||||
|
||||
if (hasTexCoord)
|
||||
{
|
||||
vertices.push_back(texs[i * 2]);
|
||||
vertices.push_back(texs[i * 2 + 1]);
|
||||
}
|
||||
}
|
||||
return create(vertices, perVertexSizeInFloat, indices, attribs);
|
||||
}
|
||||
|
||||
Mesh* Mesh::create(const std::vector<float>& vertices, int perVertexSizeInFloat, const IndexArray& indices, const std::vector<MeshVertexAttrib>& attribs)
|
||||
{
|
||||
MeshData meshdata;
|
||||
meshdata.attribs = attribs;
|
||||
meshdata.vertex = vertices;
|
||||
meshdata.subMeshIndices.push_back(indices);
|
||||
meshdata.subMeshIds.push_back("");
|
||||
auto meshvertexdata = MeshVertexData::create(meshdata);
|
||||
auto indexbuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, (int)indices.size());
|
||||
|
||||
AABB aabb = MeshVertexData::calculateAABB(meshdata.vertex, meshdata.getPerVertexSize(), indices);
|
||||
auto indexData = MeshIndexData::create("", meshvertexdata, indexbuffer, aabb);
|
||||
|
||||
return create("", indexData);
|
||||
}
|
||||
|
||||
Mesh* Mesh::create(const std::string& name, MeshIndexData* indexData, MeshSkin* skin)
|
||||
{
|
||||
auto state = new Mesh();
|
||||
state->autorelease();
|
||||
state->bindMeshCommand();
|
||||
state->_name = name;
|
||||
state->setMeshIndexData(indexData);
|
||||
state->setSkin(skin);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void Mesh::setVisible(bool visible)
|
||||
{
|
||||
if (_visible != visible)
|
||||
{
|
||||
_visible = visible;
|
||||
if (_visibleChanged)
|
||||
_visibleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setTexture(const std::string& texPath)
|
||||
{
|
||||
auto tex = Director::getInstance()->getTextureCache()->addImage(texPath);
|
||||
setTexture(tex);
|
||||
}
|
||||
|
||||
void Mesh::setTexture(Texture2D* tex)
|
||||
{
|
||||
if (tex != _texture)
|
||||
{
|
||||
CC_SAFE_RETAIN(tex);
|
||||
CC_SAFE_RELEASE(_texture);
|
||||
_texture = tex;
|
||||
bindMeshCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setSkin(MeshSkin* skin)
|
||||
{
|
||||
if (_skin != skin)
|
||||
{
|
||||
CC_SAFE_RETAIN(skin);
|
||||
CC_SAFE_RELEASE(_skin);
|
||||
_skin = skin;
|
||||
calcuateAABB();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setMeshIndexData(MeshIndexData* subMesh)
|
||||
{
|
||||
if (_meshIndexData != subMesh)
|
||||
{
|
||||
CC_SAFE_RETAIN(subMesh);
|
||||
CC_SAFE_RELEASE(_meshIndexData);
|
||||
_meshIndexData = subMesh;
|
||||
calcuateAABB();
|
||||
bindMeshCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setGLProgramState(GLProgramState* glProgramState)
|
||||
{
|
||||
if (_glProgramState != glProgramState)
|
||||
{
|
||||
CC_SAFE_RETAIN(glProgramState);
|
||||
CC_SAFE_RELEASE(_glProgramState);
|
||||
_glProgramState = glProgramState;
|
||||
bindMeshCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::calcuateAABB()
|
||||
{
|
||||
if (_meshIndexData)
|
||||
{
|
||||
_aabb = _meshIndexData->getAABB();
|
||||
if (_skin)
|
||||
{
|
||||
Bone3D* root = _skin->getRootBone();
|
||||
if (root)
|
||||
{
|
||||
_aabb.transform(root->getWorldMat());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::bindMeshCommand()
|
||||
{
|
||||
if (_glProgramState && _meshIndexData && _texture)
|
||||
{
|
||||
GLuint texID = _texture ? _texture->getName() : 0;
|
||||
_meshCommand.genMaterialID(texID, _glProgramState, _meshIndexData->getVertexBuffer()->getVBO(), _meshIndexData->getIndexBuffer()->getVBO(), _blend);
|
||||
_meshCommand.setCullFaceEnabled(true);
|
||||
_meshCommand.setDepthTestEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Mesh::setBlendFunc(const BlendFunc &blendFunc)
|
||||
{
|
||||
if(_blend.src != blendFunc.src || _blend.dst != blendFunc.dst)
|
||||
{
|
||||
_blend = blendFunc;
|
||||
bindMeshCommand();
|
||||
}
|
||||
}
|
||||
const BlendFunc &Mesh::getBlendFunc() const
|
||||
{
|
||||
return _blend;
|
||||
}
|
||||
|
||||
GLenum Mesh::getPrimitiveType() const
|
||||
{
|
||||
return _meshIndexData->getPrimitiveType();
|
||||
}
|
||||
|
||||
ssize_t Mesh::getIndexCount() const
|
||||
{
|
||||
return _meshIndexData->getIndexBuffer()->getIndexNumber();
|
||||
}
|
||||
|
||||
GLenum Mesh::getIndexFormat() const
|
||||
{
|
||||
return GL_UNSIGNED_SHORT;
|
||||
}
|
||||
|
||||
GLuint Mesh::getIndexBuffer() const
|
||||
{
|
||||
return _meshIndexData->getIndexBuffer()->getVBO();
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -1,149 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCSUBMESHSTATE_H__
|
||||
#define __CCSUBMESHSTATE_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "3d/CCBundle3DData.h"
|
||||
#include "3d/CCAABB.h"
|
||||
|
||||
#include "base/CCRef.h"
|
||||
#include "base/ccTypes.h"
|
||||
#include "math/CCMath.h"
|
||||
#include "renderer/CCGLProgram.h"
|
||||
#include "renderer/CCGLProgramState.h"
|
||||
#include "renderer/CCMeshCommand.h"
|
||||
#include "3d/3dExport.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Texture2D;
|
||||
class MeshSkin;
|
||||
class MeshIndexData;
|
||||
/**
|
||||
* SubMeshState: visibility and apperence of submesh
|
||||
*/
|
||||
class CC_3D_DLL Mesh : public Ref
|
||||
{
|
||||
friend class Sprite3D;
|
||||
public:
|
||||
typedef std::vector<unsigned short> IndexArray;
|
||||
/**create mesh from positions, normals, and so on, sigle SubMesh*/
|
||||
static Mesh* create(const std::vector<float>& positions, const std::vector<float>& normals, const std::vector<float>& texs, const IndexArray& indices);
|
||||
/**create mesh with vertex attributes*/
|
||||
CC_DEPRECATED_ATTRIBUTE static Mesh* create(const std::vector<float>& vertices, int perVertexSizeInFloat, const IndexArray& indices, int numIndex, const std::vector<MeshVertexAttrib>& attribs, int attribCount){ return create(vertices, perVertexSizeInFloat, indices, attribs); }
|
||||
|
||||
static Mesh* create(const std::vector<float>& vertices, int perVertexSizeInFloat, const IndexArray& indices, const std::vector<MeshVertexAttrib>& attribs);
|
||||
|
||||
/** create mesh */
|
||||
static Mesh* create(const std::string& name, MeshIndexData* indexData, MeshSkin* skin = nullptr);
|
||||
|
||||
/**get vertex buffer*/
|
||||
GLuint getVertexBuffer() const;
|
||||
/**has vertex attribute?*/
|
||||
bool hasVertexAttrib(int attrib) const;
|
||||
/**get mesh vertex attribute count*/
|
||||
ssize_t getMeshVertexAttribCount() const;
|
||||
/**get MeshVertexAttribute by index*/
|
||||
const MeshVertexAttrib& getMeshVertexAttribute(int idx);
|
||||
/**get per vertex size in bytes*/
|
||||
int getVertexSizeInBytes() const;
|
||||
|
||||
/**texture getter and setter*/
|
||||
void setTexture(const std::string& texPath);
|
||||
void setTexture(Texture2D* tex);
|
||||
Texture2D* getTexture() const { return _texture; }
|
||||
|
||||
/**visible getter and setter*/
|
||||
void setVisible(bool visible);
|
||||
bool isVisible() const { return _visible; }
|
||||
|
||||
/**skin getter */
|
||||
MeshSkin* getSkin() const { return _skin; }
|
||||
|
||||
/**mesh index data getter */
|
||||
MeshIndexData* getMeshIndexData() const { return _meshIndexData; }
|
||||
|
||||
/**get GLProgramState*/
|
||||
GLProgramState* getGLProgramState() const { return _glProgramState; }
|
||||
|
||||
/**name getter */
|
||||
const std::string& getName() const { return _name; }
|
||||
|
||||
void setBlendFunc(const BlendFunc &blendFunc);
|
||||
const BlendFunc &getBlendFunc() const;
|
||||
|
||||
/** get primitive type*/
|
||||
GLenum getPrimitiveType() const;
|
||||
/**get index count*/
|
||||
ssize_t getIndexCount() const;
|
||||
/**get index format*/
|
||||
GLenum getIndexFormat() const;
|
||||
/**get index buffer*/
|
||||
GLuint getIndexBuffer() const;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
||||
Mesh();
|
||||
virtual ~Mesh();
|
||||
|
||||
GLProgram* getDefaultGLProgram(bool textured);
|
||||
|
||||
void setGLProgramState(GLProgramState* glProgramState);
|
||||
|
||||
MeshCommand& getMeshCommand() { return _meshCommand; }
|
||||
|
||||
/**skin setter*/
|
||||
void setSkin(MeshSkin* skin);
|
||||
/**Mesh index data setter*/
|
||||
void setMeshIndexData(MeshIndexData* indexdata);
|
||||
/**name setter*/
|
||||
void setName(const std::string& name) { _name = name; }
|
||||
|
||||
const AABB& getAABB() const { return _aabb; }
|
||||
|
||||
void calcuateAABB();
|
||||
|
||||
void bindMeshCommand();
|
||||
protected:
|
||||
Texture2D* _texture; //texture that submesh is using
|
||||
MeshSkin* _skin; //skin
|
||||
bool _visible; // is the submesh visible
|
||||
|
||||
//since 3.3
|
||||
std::string _name;
|
||||
MeshIndexData* _meshIndexData;
|
||||
GLProgramState* _glProgramState;
|
||||
MeshCommand _meshCommand;
|
||||
BlendFunc _blend;
|
||||
AABB _aabb;
|
||||
std::function<void()> _visibleChanged;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CCSUBMESHSTATE_H__
|
|
@ -35,7 +35,7 @@
|
|||
#include "3d/CCAnimate3D.h"
|
||||
#include "3d/CCAnimation3D.h"
|
||||
#include "3d/CCSprite3DMaterial.h"
|
||||
#include "3d/CCSubMeshState.h"
|
||||
#include "3d/CCAttachNode.h"
|
||||
#include "3d/CCMeshVertexIndexData.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "Sprite3DTest.h"
|
||||
#include "3d/CCAnimation3D.h"
|
||||
#include "3d/CCAnimate3D.h"
|
||||
#include "3d/CCSubMesh.h"
|
||||
#include "3d/CCAttachNode.h"
|
||||
#include "3d/CCRay.h"
|
||||
#include "3d/CCSprite3D.h"
|
||||
|
|
Loading…
Reference in New Issue