Implemented KRBundle's
Implementation of logic to allow dynamic loading and unloading of meshes and models for scenes larger than RAM in progress --HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%4090
This commit is contained in:
@@ -23,6 +23,8 @@
|
|||||||
E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = E42CB1EB158446940066E0D8 /* KRQuaternion.h */; };
|
E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */ = {isa = PBXBuildFile; fileRef = E42CB1EB158446940066E0D8 /* KRQuaternion.h */; };
|
||||||
E42CB1F0158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; };
|
E42CB1F0158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; };
|
||||||
E42CB1F1158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; };
|
E42CB1F1158446AB0066E0D8 /* KRQuaternion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */; };
|
||||||
|
E430D08115F8882F0010558D /* occlusion_test.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E430D08015F8882F0010558D /* occlusion_test.fsh */; };
|
||||||
|
E430D08915F88AD10010558D /* occlusion_test.vsh in Sources */ = {isa = PBXBuildFile; fileRef = E430D08815F88AD10010558D /* occlusion_test.vsh */; };
|
||||||
E43B0AC915DDBB8500A5CB9F /* KRNotified.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AC715DDBB8500A5CB9F /* KRNotified.cpp */; };
|
E43B0AC915DDBB8500A5CB9F /* KRNotified.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AC715DDBB8500A5CB9F /* KRNotified.cpp */; };
|
||||||
E43B0ACA15DDBB8500A5CB9F /* KRNotified.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AC715DDBB8500A5CB9F /* KRNotified.cpp */; };
|
E43B0ACA15DDBB8500A5CB9F /* KRNotified.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AC715DDBB8500A5CB9F /* KRNotified.cpp */; };
|
||||||
E43B0ACB15DDBB8500A5CB9F /* KRNotified.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AC815DDBB8500A5CB9F /* KRNotified.h */; };
|
E43B0ACB15DDBB8500A5CB9F /* KRNotified.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AC815DDBB8500A5CB9F /* KRNotified.h */; };
|
||||||
@@ -67,7 +69,7 @@
|
|||||||
E46F4A05155DF47C00CCF8B8 /* KRWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46F4A03155DF47C00CCF8B8 /* KRWorld.cpp */; };
|
E46F4A05155DF47C00CCF8B8 /* KRWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46F4A03155DF47C00CCF8B8 /* KRWorld.cpp */; };
|
||||||
E46F4A09155DF6E400CCF8B8 /* KRWorld.cpp in Headers */ = {isa = PBXBuildFile; fileRef = E46F4A03155DF47C00CCF8B8 /* KRWorld.cpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
E46F4A09155DF6E400CCF8B8 /* KRWorld.cpp in Headers */ = {isa = PBXBuildFile; fileRef = E46F4A03155DF47C00CCF8B8 /* KRWorld.cpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E46F4A0B155E002100CCF8B8 /* KRDataBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = E46F4A0A155E002100CCF8B8 /* KRDataBlock.h */; };
|
E46F4A0B155E002100CCF8B8 /* KRDataBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = E46F4A0A155E002100CCF8B8 /* KRDataBlock.h */; };
|
||||||
E46F4A0C155E002100CCF8B8 /* KRDataBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = E46F4A0A155E002100CCF8B8 /* KRDataBlock.h */; };
|
E46F4A0C155E002100CCF8B8 /* KRDataBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = E46F4A0A155E002100CCF8B8 /* KRDataBlock.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E46F4A0E155E003000CCF8B8 /* KRDataBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46F4A0D155E003000CCF8B8 /* KRDataBlock.cpp */; };
|
E46F4A0E155E003000CCF8B8 /* KRDataBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46F4A0D155E003000CCF8B8 /* KRDataBlock.cpp */; };
|
||||||
E46F4A0F155E003000CCF8B8 /* KRDataBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46F4A0D155E003000CCF8B8 /* KRDataBlock.cpp */; };
|
E46F4A0F155E003000CCF8B8 /* KRDataBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46F4A0D155E003000CCF8B8 /* KRDataBlock.cpp */; };
|
||||||
E46F4A10155E004100CCF8B8 /* KRDataBlock.cpp in Headers */ = {isa = PBXBuildFile; fileRef = E46F4A0D155E003000CCF8B8 /* KRDataBlock.cpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
E46F4A10155E004100CCF8B8 /* KRDataBlock.cpp in Headers */ = {isa = PBXBuildFile; fileRef = E46F4A0D155E003000CCF8B8 /* KRDataBlock.cpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
@@ -75,7 +77,15 @@
|
|||||||
E47C25A513F4F66F00FF4370 /* KRShader.h in Headers */ = {isa = PBXBuildFile; fileRef = E47C25A413F4F66F00FF4370 /* KRShader.h */; };
|
E47C25A513F4F66F00FF4370 /* KRShader.h in Headers */ = {isa = PBXBuildFile; fileRef = E47C25A413F4F66F00FF4370 /* KRShader.h */; };
|
||||||
E47C25A713F4F6AB00FF4370 /* KRShaderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */; };
|
E47C25A713F4F6AB00FF4370 /* KRShaderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */; };
|
||||||
E47C25A913F4F6DD00FF4370 /* KRShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47C25A813F4F6DD00FF4370 /* KRShader.cpp */; };
|
E47C25A913F4F6DD00FF4370 /* KRShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47C25A813F4F6DD00FF4370 /* KRShader.cpp */; };
|
||||||
E48278B115F03028001C9431 /* visualize_overlay.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E48278B015F03028001C9431 /* visualize_overlay.fsh */; };
|
E488399415F928CA00BD66D5 /* KRBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E488399215F928CA00BD66D5 /* KRBundle.cpp */; };
|
||||||
|
E488399515F928CA00BD66D5 /* KRBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E488399215F928CA00BD66D5 /* KRBundle.cpp */; };
|
||||||
|
E488399615F928CA00BD66D5 /* KRBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = E488399315F928CA00BD66D5 /* KRBundle.h */; };
|
||||||
|
E488399715F928CA00BD66D5 /* KRBundle.h in Headers */ = {isa = PBXBuildFile; fileRef = E488399315F928CA00BD66D5 /* KRBundle.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
E488399C15F92BE000BD66D5 /* KRBundleManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E488399A15F92BE000BD66D5 /* KRBundleManager.cpp */; };
|
||||||
|
E488399D15F92BE000BD66D5 /* KRBundleManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E488399A15F92BE000BD66D5 /* KRBundleManager.cpp */; };
|
||||||
|
E488399E15F92BE000BD66D5 /* KRBundleManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E488399B15F92BE000BD66D5 /* KRBundleManager.h */; };
|
||||||
|
E488399F15F92BE000BD66D5 /* KRBundleManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E488399B15F92BE000BD66D5 /* KRBundleManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
E48839A115F92C2800BD66D5 /* visualize_overlay.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E48839A015F92C2800BD66D5 /* visualize_overlay.fsh */; };
|
||||||
E48B3CBD14393DF5000C50E2 /* KRCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = E48B3CBC14393DF5000C50E2 /* KRCamera.h */; };
|
E48B3CBD14393DF5000C50E2 /* KRCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = E48B3CBC14393DF5000C50E2 /* KRCamera.h */; };
|
||||||
E48B3CC014393E30000C50E2 /* KRCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */; };
|
E48B3CC014393E30000C50E2 /* KRCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */; };
|
||||||
E48C696F15374F5B00232E28 /* KRContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E48C696E15374F5A00232E28 /* KRContext.h */; };
|
E48C696F15374F5B00232E28 /* KRContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E48C696E15374F5A00232E28 /* KRContext.h */; };
|
||||||
@@ -189,6 +199,8 @@
|
|||||||
E414BAEC14355EFF00A668C4 /* KRBoundingVolume.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRBoundingVolume.cpp; path = Classes/KRBoundingVolume.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E414BAEC14355EFF00A668C4 /* KRBoundingVolume.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRBoundingVolume.cpp; path = Classes/KRBoundingVolume.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E42CB1EB158446940066E0D8 /* KRQuaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRQuaternion.h; path = Classes/KRQuaternion.h; sourceTree = "<group>"; };
|
E42CB1EB158446940066E0D8 /* KRQuaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRQuaternion.h; path = Classes/KRQuaternion.h; sourceTree = "<group>"; };
|
||||||
E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRQuaternion.cpp; path = Classes/KRQuaternion.cpp; sourceTree = "<group>"; };
|
E42CB1EF158446AB0066E0D8 /* KRQuaternion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRQuaternion.cpp; path = Classes/KRQuaternion.cpp; sourceTree = "<group>"; };
|
||||||
|
E430D08015F8882F0010558D /* occlusion_test.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = occlusion_test.fsh; path = Shaders/occlusion_test.fsh; sourceTree = "<group>"; };
|
||||||
|
E430D08815F88AD10010558D /* occlusion_test.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = occlusion_test.vsh; path = Shaders/occlusion_test.vsh; sourceTree = "<group>"; };
|
||||||
E43B0AC715DDBB8500A5CB9F /* KRNotified.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRNotified.cpp; path = Classes/KRNotified.cpp; sourceTree = "<group>"; };
|
E43B0AC715DDBB8500A5CB9F /* KRNotified.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRNotified.cpp; path = Classes/KRNotified.cpp; sourceTree = "<group>"; };
|
||||||
E43B0AC815DDBB8500A5CB9F /* KRNotified.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRNotified.h; path = Classes/KRNotified.h; sourceTree = "<group>"; };
|
E43B0AC815DDBB8500A5CB9F /* KRNotified.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRNotified.h; path = Classes/KRNotified.h; sourceTree = "<group>"; };
|
||||||
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRContextObject.cpp; path = Classes/KRContextObject.cpp; sourceTree = "<group>"; };
|
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRContextObject.cpp; path = Classes/KRContextObject.cpp; sourceTree = "<group>"; };
|
||||||
@@ -227,7 +239,11 @@
|
|||||||
E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRShaderManager.cpp; path = Classes/KRShaderManager.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRShaderManager.cpp; path = Classes/KRShaderManager.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E47C25A813F4F6DD00FF4370 /* KRShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRShader.cpp; path = Classes/KRShader.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E47C25A813F4F6DD00FF4370 /* KRShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRShader.cpp; path = Classes/KRShader.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E48278AE15F03010001C9431 /* visualize_overlay.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = visualize_overlay.vsh; path = Shaders/visualize_overlay.vsh; sourceTree = "<group>"; };
|
E48278AE15F03010001C9431 /* visualize_overlay.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = visualize_overlay.vsh; path = Shaders/visualize_overlay.vsh; sourceTree = "<group>"; };
|
||||||
E48278B015F03028001C9431 /* visualize_overlay.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = visualize_overlay.fsh; sourceTree = "<group>"; };
|
E488399215F928CA00BD66D5 /* KRBundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRBundle.cpp; path = Classes/KRBundle.cpp; sourceTree = "<group>"; };
|
||||||
|
E488399315F928CA00BD66D5 /* KRBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRBundle.h; path = Classes/KRBundle.h; sourceTree = "<group>"; };
|
||||||
|
E488399A15F92BE000BD66D5 /* KRBundleManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRBundleManager.cpp; path = Classes/KRBundleManager.cpp; sourceTree = "<group>"; };
|
||||||
|
E488399B15F92BE000BD66D5 /* KRBundleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRBundleManager.h; path = Classes/KRBundleManager.h; sourceTree = "<group>"; };
|
||||||
|
E48839A015F92C2800BD66D5 /* visualize_overlay.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = visualize_overlay.fsh; path = Shaders/visualize_overlay.fsh; sourceTree = "<group>"; };
|
||||||
E48B3CBC14393DF5000C50E2 /* KRCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRCamera.h; path = Classes/KRCamera.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E48B3CBC14393DF5000C50E2 /* KRCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = KRCamera.h; path = Classes/KRCamera.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRCamera.cpp; path = Classes/KRCamera.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = KRCamera.cpp; path = Classes/KRCamera.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E48C696E15374F5A00232E28 /* KRContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRContext.h; path = Classes/KRContext.h; sourceTree = "<group>"; };
|
E48C696E15374F5A00232E28 /* KRContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRContext.h; path = Classes/KRContext.h; sourceTree = "<group>"; };
|
||||||
@@ -331,7 +347,9 @@
|
|||||||
E4769DEC158A78B6004B83AC /* flare.fsh */,
|
E4769DEC158A78B6004B83AC /* flare.fsh */,
|
||||||
E4769DEF158A78C6004B83AC /* flare.vsh */,
|
E4769DEF158A78C6004B83AC /* flare.vsh */,
|
||||||
E48278AE15F03010001C9431 /* visualize_overlay.vsh */,
|
E48278AE15F03010001C9431 /* visualize_overlay.vsh */,
|
||||||
E48278B015F03028001C9431 /* visualize_overlay.fsh */,
|
E430D08015F8882F0010558D /* occlusion_test.fsh */,
|
||||||
|
E430D08815F88AD10010558D /* occlusion_test.vsh */,
|
||||||
|
E48839A015F92C2800BD66D5 /* visualize_overlay.fsh */,
|
||||||
);
|
);
|
||||||
name = Shaders;
|
name = Shaders;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -339,9 +357,7 @@
|
|||||||
E461A170152E598200F2044A /* Resources */ = {
|
E461A170152E598200F2044A /* Resources */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
E48C696C15374A1500232E28 /* Scene Graph */,
|
|
||||||
E461A174152E5A1300F2044A /* Meshes */,
|
E461A174152E5A1300F2044A /* Meshes */,
|
||||||
E461A172152E59BC00F2044A /* Materials */,
|
|
||||||
E497B949151BCEE900D3DC67 /* KRResource.h */,
|
E497B949151BCEE900D3DC67 /* KRResource.h */,
|
||||||
E497B94C151BCF2500D3DC67 /* KRResource.cpp */,
|
E497B94C151BCF2500D3DC67 /* KRResource.cpp */,
|
||||||
E497B94F151BD2CE00D3DC67 /* KRResource+obj.cpp */,
|
E497B94F151BD2CE00D3DC67 /* KRResource+obj.cpp */,
|
||||||
@@ -367,15 +383,6 @@
|
|||||||
name = Lights;
|
name = Lights;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
E461A172152E59BC00F2044A /* Materials */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
E491017C13C99BDC0098455B /* KRMaterial.cpp */,
|
|
||||||
E491017D13C99BDC0098455B /* KRMaterial.h */,
|
|
||||||
);
|
|
||||||
name = Materials;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
E461A173152E59DF00F2044A /* Math */ = {
|
E461A173152E59DF00F2044A /* Math */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@@ -414,7 +421,87 @@
|
|||||||
name = tinyxml2;
|
name = tinyxml2;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
E48C696C15374A1500232E28 /* Scene Graph */ = {
|
E488399915F92BA300BD66D5 /* Managers */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
E48839AB15F930E200BD66D5 /* Bundle */,
|
||||||
|
E48839AA15F9309E00BD66D5 /* Material */,
|
||||||
|
E48839A915F9307E00BD66D5 /* Model */,
|
||||||
|
E48839A815F9304C00BD66D5 /* Texture */,
|
||||||
|
E48839A715F9302E00BD66D5 /* Shader */,
|
||||||
|
E48839A615F92FC300BD66D5 /* Scene */,
|
||||||
|
);
|
||||||
|
name = Managers;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
E48839A615F92FC300BD66D5 /* Scene */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
E46C214915364DDB009CABF3 /* KRSceneManager.h */,
|
||||||
|
E46C214A15364DEC009CABF3 /* KRSceneManager.cpp */,
|
||||||
|
E414BAE6143557D200A668C4 /* KRScene.h */,
|
||||||
|
E414BAE81435585A00A668C4 /* KRScene.cpp */,
|
||||||
|
E48C696C15374A1500232E28 /* Scene Graph Nodes */,
|
||||||
|
);
|
||||||
|
name = Scene;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
E48839A715F9302E00BD66D5 /* Shader */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
E47C25A113F4F65A00FF4370 /* KRShaderManager.h */,
|
||||||
|
E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */,
|
||||||
|
E47C25A413F4F66F00FF4370 /* KRShader.h */,
|
||||||
|
E47C25A813F4F6DD00FF4370 /* KRShader.cpp */,
|
||||||
|
);
|
||||||
|
name = Shader;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
E48839A815F9304C00BD66D5 /* Texture */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
E491018513C99BDC0098455B /* KRTextureManager.h */,
|
||||||
|
E491018013C99BDC0098455B /* KRTextureManager.cpp */,
|
||||||
|
E491018613C99BDC0098455B /* KRTexture.h */,
|
||||||
|
E491018113C99BDC0098455B /* KRTexture.cpp */,
|
||||||
|
);
|
||||||
|
name = Texture;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
E48839A915F9307E00BD66D5 /* Model */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
E491018313C99BDC0098455B /* KRModelManager.h */,
|
||||||
|
E491018213C99BDC0098455B /* KRModelManager.cpp */,
|
||||||
|
E491017A13C99BDC0098455B /* KRModel.h */,
|
||||||
|
E491017913C99BDC0098455B /* KRModel.cpp */,
|
||||||
|
);
|
||||||
|
name = Model;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
E48839AA15F9309E00BD66D5 /* Material */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
E491018413C99BDC0098455B /* KRMaterialManager.h */,
|
||||||
|
E491017B13C99BDC0098455B /* KRMaterialManager.cpp */,
|
||||||
|
E491017D13C99BDC0098455B /* KRMaterial.h */,
|
||||||
|
E491017C13C99BDC0098455B /* KRMaterial.cpp */,
|
||||||
|
);
|
||||||
|
name = Material;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
E48839AB15F930E200BD66D5 /* Bundle */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
E488399B15F92BE000BD66D5 /* KRBundleManager.h */,
|
||||||
|
E488399A15F92BE000BD66D5 /* KRBundleManager.cpp */,
|
||||||
|
E488399315F928CA00BD66D5 /* KRBundle.h */,
|
||||||
|
E488399215F928CA00BD66D5 /* KRBundle.cpp */,
|
||||||
|
);
|
||||||
|
name = Bundle;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
E48C696C15374A1500232E28 /* Scene Graph Nodes */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
E414BAE11435557300A668C4 /* KRInstance.h */,
|
E414BAE11435557300A668C4 /* KRInstance.h */,
|
||||||
@@ -422,12 +509,10 @@
|
|||||||
E461A171152E599E00F2044A /* Lights */,
|
E461A171152E599E00F2044A /* Lights */,
|
||||||
E4F975311536220900FD60B2 /* KRNode.h */,
|
E4F975311536220900FD60B2 /* KRNode.h */,
|
||||||
E4F975351536221C00FD60B2 /* KRNode.cpp */,
|
E4F975351536221C00FD60B2 /* KRNode.cpp */,
|
||||||
E414BAE6143557D200A668C4 /* KRScene.h */,
|
|
||||||
E414BAE81435585A00A668C4 /* KRScene.cpp */,
|
|
||||||
1000469C15E6EF550053B072 /* KRSkyBox.h */,
|
1000469C15E6EF550053B072 /* KRSkyBox.h */,
|
||||||
1000469B15E6EF550053B072 /* KRSkyBox.cpp */,
|
1000469B15E6EF550053B072 /* KRSkyBox.cpp */,
|
||||||
);
|
);
|
||||||
name = "Scene Graph";
|
name = "Scene Graph Nodes";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
E491015613C99B9D0098455B = {
|
E491015613C99B9D0098455B = {
|
||||||
@@ -484,40 +569,25 @@
|
|||||||
E491016E13C99BAE0098455B /* Classes */ = {
|
E491016E13C99BAE0098455B /* Classes */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
E4F9753815362A5200FD60B2 /* 3rdparty */,
|
||||||
|
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */,
|
||||||
|
E48B3CBC14393DF5000C50E2 /* KRCamera.h */,
|
||||||
|
E48C697115374F7E00232E28 /* KRContext.cpp */,
|
||||||
|
E48C696E15374F5A00232E28 /* KRContext.h */,
|
||||||
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */,
|
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */,
|
||||||
E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */,
|
E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */,
|
||||||
E4F9753815362A5200FD60B2 /* 3rdparty */,
|
E46F4A0D155E003000CCF8B8 /* KRDataBlock.cpp */,
|
||||||
E461A173152E59DF00F2044A /* Math */,
|
E46F4A0A155E002100CCF8B8 /* KRDataBlock.h */,
|
||||||
E461A170152E598200F2044A /* Resources */,
|
|
||||||
E491016F13C99BDC0098455B /* KREngine.mm */,
|
|
||||||
E491017213C99BDC0098455B /* KREngine.h */,
|
|
||||||
E491017913C99BDC0098455B /* KRModel.cpp */,
|
|
||||||
E491017A13C99BDC0098455B /* KRModel.h */,
|
|
||||||
E491018413C99BDC0098455B /* KRMaterialManager.h */,
|
|
||||||
E491017B13C99BDC0098455B /* KRMaterialManager.cpp */,
|
|
||||||
E491018213C99BDC0098455B /* KRModelManager.cpp */,
|
|
||||||
E491018313C99BDC0098455B /* KRModelManager.h */,
|
|
||||||
E491018513C99BDC0098455B /* KRTextureManager.h */,
|
|
||||||
E491018013C99BDC0098455B /* KRTextureManager.cpp */,
|
|
||||||
E491018613C99BDC0098455B /* KRTexture.h */,
|
|
||||||
E491018113C99BDC0098455B /* KRTexture.cpp */,
|
|
||||||
E47C25A113F4F65A00FF4370 /* KRShaderManager.h */,
|
|
||||||
E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */,
|
|
||||||
E47C25A413F4F66F00FF4370 /* KRShader.h */,
|
|
||||||
E47C25A813F4F6DD00FF4370 /* KRShader.cpp */,
|
|
||||||
E48B3CBC14393DF5000C50E2 /* KRCamera.h */,
|
|
||||||
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */,
|
|
||||||
E46DBE841512B9E200D59F86 /* KREngine-common.h */,
|
E46DBE841512B9E200D59F86 /* KREngine-common.h */,
|
||||||
E46C214915364DDB009CABF3 /* KRSceneManager.h */,
|
E491017213C99BDC0098455B /* KREngine.h */,
|
||||||
E46C214A15364DEC009CABF3 /* KRSceneManager.cpp */,
|
E491016F13C99BDC0098455B /* KREngine.mm */,
|
||||||
E48C696E15374F5A00232E28 /* KRContext.h */,
|
|
||||||
E48C697115374F7E00232E28 /* KRContext.cpp */,
|
|
||||||
E43B0AC715DDBB8500A5CB9F /* KRNotified.cpp */,
|
E43B0AC715DDBB8500A5CB9F /* KRNotified.cpp */,
|
||||||
E43B0AC815DDBB8500A5CB9F /* KRNotified.h */,
|
E43B0AC815DDBB8500A5CB9F /* KRNotified.h */,
|
||||||
E46F49FF155DF46700CCF8B8 /* KRWorld.h */,
|
|
||||||
E46F4A0A155E002100CCF8B8 /* KRDataBlock.h */,
|
|
||||||
E46F4A0D155E003000CCF8B8 /* KRDataBlock.cpp */,
|
|
||||||
E46F4A03155DF47C00CCF8B8 /* KRWorld.cpp */,
|
E46F4A03155DF47C00CCF8B8 /* KRWorld.cpp */,
|
||||||
|
E46F49FF155DF46700CCF8B8 /* KRWorld.h */,
|
||||||
|
E488399915F92BA300BD66D5 /* Managers */,
|
||||||
|
E461A173152E59DF00F2044A /* Math */,
|
||||||
|
E461A170152E598200F2044A /* Resources */,
|
||||||
);
|
);
|
||||||
name = Classes;
|
name = Classes;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -604,6 +674,8 @@
|
|||||||
E4924C2C15EE96AB00B965C6 /* KROctreeNode.h in Headers */,
|
E4924C2C15EE96AB00B965C6 /* KROctreeNode.h in Headers */,
|
||||||
1000469E15E6EF550053B072 /* KRSkyBox.h in Headers */,
|
1000469E15E6EF550053B072 /* KRSkyBox.h in Headers */,
|
||||||
E40BA45615EFF79500D7C3DD /* KRAABB.h in Headers */,
|
E40BA45615EFF79500D7C3DD /* KRAABB.h in Headers */,
|
||||||
|
E488399615F928CA00BD66D5 /* KRBundle.h in Headers */,
|
||||||
|
E488399E15F92BE000BD66D5 /* KRBundleManager.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -620,14 +692,17 @@
|
|||||||
E43B0AD915DDCA0F00A5CB9F /* KRContextObject.h in Headers */,
|
E43B0AD915DDCA0F00A5CB9F /* KRContextObject.h in Headers */,
|
||||||
E4F975331536220900FD60B2 /* KRNode.h in Headers */,
|
E4F975331536220900FD60B2 /* KRNode.h in Headers */,
|
||||||
E4B2A4391523B027004CB0EC /* KRMaterial.h in Headers */,
|
E4B2A4391523B027004CB0EC /* KRMaterial.h in Headers */,
|
||||||
|
E46F4A0C155E002100CCF8B8 /* KRDataBlock.h in Headers */,
|
||||||
E46DBE811512AFE600D59F86 /* KRMesh.h in Headers */,
|
E46DBE811512AFE600D59F86 /* KRMesh.h in Headers */,
|
||||||
E4F9754115362CD900FD60B2 /* KRScene.h in Headers */,
|
E4F9754115362CD900FD60B2 /* KRScene.h in Headers */,
|
||||||
E4F9754A153632AA00FD60B2 /* KRModelManager.cpp in Headers */,
|
E4F9754A153632AA00FD60B2 /* KRModelManager.cpp in Headers */,
|
||||||
E4F9754215362D0D00FD60B2 /* KRInstance.h in Headers */,
|
E4F9754215362D0D00FD60B2 /* KRInstance.h in Headers */,
|
||||||
E4F975491536329E00FD60B2 /* KRTextureManager.h in Headers */,
|
E4F975491536329E00FD60B2 /* KRTextureManager.h in Headers */,
|
||||||
E46DBE851512B9FA00D59F86 /* KREngine-common.h in Headers */,
|
E46DBE851512B9FA00D59F86 /* KREngine-common.h in Headers */,
|
||||||
|
E488399715F928CA00BD66D5 /* KRBundle.h in Headers */,
|
||||||
E4F9754C153632F000FD60B2 /* KRCamera.h in Headers */,
|
E4F9754C153632F000FD60B2 /* KRCamera.h in Headers */,
|
||||||
E4F975501536333500FD60B2 /* KRModel.h in Headers */,
|
E4F975501536333500FD60B2 /* KRModel.h in Headers */,
|
||||||
|
E488399F15F92BE000BD66D5 /* KRBundleManager.h in Headers */,
|
||||||
E4AFC6BC15F7C95D00DDB4C8 /* KRSceneManager.h in Headers */,
|
E4AFC6BC15F7C95D00DDB4C8 /* KRSceneManager.h in Headers */,
|
||||||
E4D133661537685A0070068C /* KRShader.h in Headers */,
|
E4D133661537685A0070068C /* KRShader.h in Headers */,
|
||||||
E461A153152E54B500F2044A /* KRLight.h in Headers */,
|
E461A153152E54B500F2044A /* KRLight.h in Headers */,
|
||||||
@@ -648,7 +723,6 @@
|
|||||||
E461A15D152E563100F2044A /* KRDirectionalLight.h in Headers */,
|
E461A15D152E563100F2044A /* KRDirectionalLight.h in Headers */,
|
||||||
E461A169152E570700F2044A /* KRSpotLight.h in Headers */,
|
E461A169152E570700F2044A /* KRSpotLight.h in Headers */,
|
||||||
E46A6B701559EF0A000DBD37 /* KRResource+blend.h in Headers */,
|
E46A6B701559EF0A000DBD37 /* KRResource+blend.h in Headers */,
|
||||||
E46F4A0C155E002100CCF8B8 /* KRDataBlock.h in Headers */,
|
|
||||||
E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */,
|
E42CB1ED158446940066E0D8 /* KRQuaternion.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -771,7 +845,11 @@
|
|||||||
E4924C2B15EE96AB00B965C6 /* KROctreeNode.cpp in Sources */,
|
E4924C2B15EE96AB00B965C6 /* KROctreeNode.cpp in Sources */,
|
||||||
1000469D15E6EF550053B072 /* KRSkyBox.cpp in Sources */,
|
1000469D15E6EF550053B072 /* KRSkyBox.cpp in Sources */,
|
||||||
E40BA45415EFF79500D7C3DD /* KRAABB.cpp in Sources */,
|
E40BA45415EFF79500D7C3DD /* KRAABB.cpp in Sources */,
|
||||||
E48278B115F03028001C9431 /* visualize_overlay.fsh in Sources */,
|
E430D08115F8882F0010558D /* occlusion_test.fsh in Sources */,
|
||||||
|
E430D08915F88AD10010558D /* occlusion_test.vsh in Sources */,
|
||||||
|
E488399415F928CA00BD66D5 /* KRBundle.cpp in Sources */,
|
||||||
|
E488399C15F92BE000BD66D5 /* KRBundleManager.cpp in Sources */,
|
||||||
|
E48839A115F92C2800BD66D5 /* visualize_overlay.fsh in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -816,6 +894,8 @@
|
|||||||
E43B0ACA15DDBB8500A5CB9F /* KRNotified.cpp in Sources */,
|
E43B0ACA15DDBB8500A5CB9F /* KRNotified.cpp in Sources */,
|
||||||
E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */,
|
E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */,
|
||||||
E40BA45515EFF79500D7C3DD /* KRAABB.cpp in Sources */,
|
E40BA45515EFF79500D7C3DD /* KRAABB.cpp in Sources */,
|
||||||
|
E488399515F928CA00BD66D5 /* KRBundle.cpp in Sources */,
|
||||||
|
E488399D15F92BE000BD66D5 /* KRBundleManager.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "KRAABB.h"
|
#include "KRAABB.h"
|
||||||
|
#include "KRMat4.h"
|
||||||
|
|
||||||
KRAABB::KRAABB(const KRVector3 &minPoint, const KRVector3 &maxPoint)
|
KRAABB::KRAABB(const KRVector3 &minPoint, const KRVector3 &maxPoint)
|
||||||
{
|
{
|
||||||
@@ -79,3 +80,67 @@ bool KRAABB::intersects(const KRAABB& b) const
|
|||||||
// Return true if the two volumes intersect
|
// Return true if the two volumes intersect
|
||||||
return min.x <= b.max.x && min.y <= b.max.y && min.z <= b.max.z && max.x >= b.min.x && max.y >= b.min.y && max.z >= b.max.z;
|
return min.x <= b.max.x && min.y <= b.max.y && min.z <= b.max.z && max.x >= b.min.x && max.y >= b.min.y && max.z >= b.max.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KRAABB::contains(const KRAABB &b) const
|
||||||
|
{
|
||||||
|
// Return true if the passed KRAABB is entirely contained within this KRAABB
|
||||||
|
return b.min.x >= min.x && b.min.y >= min.y && b.min.z >= min.z && b.max.x <= max.x && b.max.y <= max.y && b.max.z <= max.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRAABB KRAABB::Infinite()
|
||||||
|
{
|
||||||
|
return KRAABB(KRVector3::Min(), KRVector3::Max());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KRAABB::visible(const KRMat4 &matViewProjection) const
|
||||||
|
{
|
||||||
|
// test if bounding box would be within the visible range of the clip space transformed by matViewProjection
|
||||||
|
// This is used for view frustrum culling
|
||||||
|
|
||||||
|
KRVector3 minCorner, maxCorner;
|
||||||
|
|
||||||
|
int outside_count[6] = {0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
for(int iCorner=0; iCorner<8; iCorner++) {
|
||||||
|
KRVector3 cornerVertex = KRVector3(
|
||||||
|
(iCorner & 1) == 0 ? min.x : max.x,
|
||||||
|
(iCorner & 2) == 0 ? min.y : max.y,
|
||||||
|
(iCorner & 4) == 0 ? min.z : max.z);
|
||||||
|
|
||||||
|
cornerVertex = KRMat4::Dot(matViewProjection, cornerVertex);
|
||||||
|
float cornerVertexW = KRMat4::DotW(matViewProjection, cornerVertex);
|
||||||
|
|
||||||
|
if(cornerVertex.x < -cornerVertexW) {
|
||||||
|
outside_count[0]++;
|
||||||
|
}
|
||||||
|
if(cornerVertex.y < -cornerVertexW) {
|
||||||
|
outside_count[1]++;
|
||||||
|
}
|
||||||
|
if(cornerVertex.z < -cornerVertexW) {
|
||||||
|
outside_count[2]++;
|
||||||
|
}
|
||||||
|
if(cornerVertex.x > cornerVertexW) {
|
||||||
|
outside_count[3]++;
|
||||||
|
}
|
||||||
|
if(cornerVertex.y > cornerVertexW) {
|
||||||
|
outside_count[4]++;
|
||||||
|
}
|
||||||
|
if(cornerVertex.z > cornerVertexW) {
|
||||||
|
outside_count[5]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_visible = true;
|
||||||
|
for(int iFace=0; iFace < 6; iFace++) {
|
||||||
|
if(outside_count[iFace] == 8) {
|
||||||
|
is_visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_visible) {
|
||||||
|
fprintf(stderr, "AABB culled: %i%i%i%i%i%i out, (%f, %f, %f) - (%f, %f, %f)\n", outside_count[0], outside_count[1], outside_count[2], outside_count[3], outside_count[4], outside_count[5], min.x, min.y, min.z, max.x, max.y, max.z);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "AABB visible: %i%i%i%i%i%i out, (%f, %f, %f) - (%f, %f, %f)\n", outside_count[0], outside_count[1], outside_count[2], outside_count[3], outside_count[4], outside_count[5], min.x, min.y, min.z, max.x, max.y, max.z);
|
||||||
|
}
|
||||||
|
return is_visible;
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include "KRVector3.h"
|
#include "KRVector3.h"
|
||||||
|
|
||||||
|
class KRMat4;
|
||||||
|
|
||||||
class KRAABB {
|
class KRAABB {
|
||||||
public:
|
public:
|
||||||
KRAABB(const KRVector3 &minPoint, const KRVector3 &maxPoint);
|
KRAABB(const KRVector3 &minPoint, const KRVector3 &maxPoint);
|
||||||
@@ -21,6 +23,8 @@ public:
|
|||||||
KRVector3 center() const;
|
KRVector3 center() const;
|
||||||
KRVector3 size() const;
|
KRVector3 size() const;
|
||||||
bool intersects(const KRAABB& b) const;
|
bool intersects(const KRAABB& b) const;
|
||||||
|
bool contains(const KRAABB &b) const;
|
||||||
|
bool visible(const KRMat4 &matViewProjection) const;
|
||||||
|
|
||||||
KRAABB& operator =(const KRAABB& b);
|
KRAABB& operator =(const KRAABB& b);
|
||||||
bool operator ==(const KRAABB& b) const;
|
bool operator ==(const KRAABB& b) const;
|
||||||
@@ -32,6 +36,8 @@ public:
|
|||||||
|
|
||||||
KRVector3 min;
|
KRVector3 min;
|
||||||
KRVector3 max;
|
KRVector3 max;
|
||||||
|
|
||||||
|
static KRAABB Infinite();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ bool KRBoundingVolume::test_intersect(const KRBoundingVolume &p) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool KRBoundingVolume::test_intersect(const KRAABB &p) const {
|
bool KRBoundingVolume::test_intersect(const KRAABB &p) const {
|
||||||
// Simple, non-aligned bounding box intersection test
|
// Axis aligned bounding box intersection test
|
||||||
|
|
||||||
KRVector3 minPoint = m_vertices[0], maxPoint = m_vertices[0], minPoint2 = p.min, maxPoint2 = p.max;
|
KRVector3 minPoint = m_vertices[0], maxPoint = m_vertices[0], minPoint2 = p.min, maxPoint2 = p.max;
|
||||||
for(int iVertex=1; iVertex < 8; iVertex++) {
|
for(int iVertex=1; iVertex < 8; iVertex++) {
|
||||||
|
|||||||
86
KREngine/KREngine/Classes/KRBundle.cpp
Normal file
86
KREngine/KREngine/Classes/KRBundle.cpp
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
//
|
||||||
|
// KRBundle.cpp
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
// provided with the distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
// or implied, of Kearwood Gilbert.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "KRBundle.h"
|
||||||
|
#include "KRContext.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
typedef struct _tar_header
|
||||||
|
{
|
||||||
|
char file_name[100];
|
||||||
|
char file_mode[8];
|
||||||
|
char owner_id[8]; // Owner's numeric user ID (OCTAL!)
|
||||||
|
char group_id[8]; // Group's numeric user ID (OCTAL!)
|
||||||
|
char file_size[12]; // File size in bytes (OCTAL!)
|
||||||
|
char mod_time[12]; // Last modification time in numeric Unix time format
|
||||||
|
char checksum[8]; // Checksum for header block
|
||||||
|
char file_type[1]; // Link indicator (file type)
|
||||||
|
char linked_file[100]; // Name of linked file
|
||||||
|
|
||||||
|
} tar_header_type;
|
||||||
|
|
||||||
|
KRBundle::KRBundle(KRContext &context, std::string name, KRDataBlock *pData) : KRContextObject(context)
|
||||||
|
{
|
||||||
|
m_pData = pData;
|
||||||
|
|
||||||
|
unsigned char *pFile = (unsigned char *)m_pData->getStart();
|
||||||
|
while(pFile < m_pData->getEnd() ) {
|
||||||
|
tar_header_type *file_header = (tar_header_type *)pFile;
|
||||||
|
size_t file_size = strtol(file_header->file_size, NULL, 8);
|
||||||
|
pFile += 512; // Skip past the header to the file contents
|
||||||
|
|
||||||
|
if(file_header->file_name[0] != '\0' && file_header->file_name[0] != '.') {
|
||||||
|
// We ignore the last two records in the tar file, which are zero'ed out tar_header structures
|
||||||
|
KRDataBlock *pFileData = new KRDataBlock();
|
||||||
|
if(pFileData->load(pFile, file_size)) {
|
||||||
|
context.loadResource(file_header->file_name, pFileData);
|
||||||
|
} else {
|
||||||
|
delete pFileData;
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Advance past the end of the file
|
||||||
|
if((file_size & 0x01ff) == 0) {
|
||||||
|
// file size is a multiple of 512 bytes, we can just add it
|
||||||
|
pFile += file_size;
|
||||||
|
} else {
|
||||||
|
// We would not be on a 512 byte boundary, round up to the next one
|
||||||
|
pFile += (file_size + 0x0200) - (file_size & 0x1ff);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KRBundle::~KRBundle()
|
||||||
|
{
|
||||||
|
delete m_pData;
|
||||||
|
}
|
||||||
47
KREngine/KREngine/Classes/KRBundle.h
Normal file
47
KREngine/KREngine/Classes/KRBundle.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
//
|
||||||
|
// KRBundle.h
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
// provided with the distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
// or implied, of Kearwood Gilbert.
|
||||||
|
//
|
||||||
|
#ifndef KRBUNDLE_H
|
||||||
|
#define KRBUNDLE_H
|
||||||
|
|
||||||
|
#import "KREngine-common.h"
|
||||||
|
#import "KRResource.h"
|
||||||
|
#import "KRDataBlock.h"
|
||||||
|
|
||||||
|
class KRBundle : public KRContextObject {
|
||||||
|
public:
|
||||||
|
KRBundle(KRContext &context, std::string name, KRDataBlock *pData);
|
||||||
|
virtual ~KRBundle();
|
||||||
|
|
||||||
|
private:
|
||||||
|
KRDataBlock *m_pData;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(KRBUNDLE_H) */
|
||||||
60
KREngine/KREngine/Classes/KRBundleManager.cpp
Normal file
60
KREngine/KREngine/Classes/KRBundleManager.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// KRBundleManager.cpp
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
// provided with the distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
// or implied, of Kearwood Gilbert.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "KRBundleManager.h"
|
||||||
|
|
||||||
|
#import "KRBundle.h"
|
||||||
|
|
||||||
|
KRBundleManager::KRBundleManager(KRContext &context) : KRContextObject(context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
KRBundleManager::~KRBundleManager() {
|
||||||
|
for(map<std::string, KRBundle *>::iterator itr = m_bundles.begin(); itr != m_bundles.end(); ++itr){
|
||||||
|
delete (*itr).second;
|
||||||
|
}
|
||||||
|
m_bundles.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
KRBundle *KRBundleManager::loadBundle(const char *szName, KRDataBlock *pData)
|
||||||
|
{
|
||||||
|
KRBundle *pBundle = new KRBundle(*m_pContext, szName, pData);
|
||||||
|
m_bundles[szName] = pBundle;
|
||||||
|
return pBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRBundle *KRBundleManager::getBundle(const char *szName) {
|
||||||
|
return m_bundles[szName];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, KRBundle *> KRBundleManager::getBundles() {
|
||||||
|
return m_bundles;
|
||||||
|
}
|
||||||
62
KREngine/KREngine/Classes/KRBundleManager.h
Normal file
62
KREngine/KREngine/Classes/KRBundleManager.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
//
|
||||||
|
// KRBundleManager.h
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
// provided with the distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
// or implied, of Kearwood Gilbert.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef KRBUNDLEMANAGER_H
|
||||||
|
#define KRBUNDLEMANAGER_H
|
||||||
|
|
||||||
|
#import "KREngine-common.h"
|
||||||
|
#import "KRContextObject.h"
|
||||||
|
#import "KRDataBlock.h"
|
||||||
|
|
||||||
|
class KRContext;
|
||||||
|
class KRBundle;
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#import <string>
|
||||||
|
using std::map;
|
||||||
|
|
||||||
|
class KRBundleManager : public KRContextObject {
|
||||||
|
public:
|
||||||
|
KRBundleManager(KRContext &context);
|
||||||
|
~KRBundleManager();
|
||||||
|
|
||||||
|
KRBundle *loadBundle(const char *szName, KRDataBlock *pData);
|
||||||
|
KRBundle *getBundle(const char *szName);
|
||||||
|
|
||||||
|
std::vector<std::string> getBundleNames();
|
||||||
|
std::map<std::string, KRBundle *> getBundles();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<std::string, KRBundle *> m_bundles;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(KRBUNDLEMANAGER_H) */
|
||||||
@@ -47,6 +47,7 @@ KRCamera::KRCamera(KRContext &context, GLint width, GLint height) : KRNotified(c
|
|||||||
double const D2R = PI * 2 / 360;
|
double const D2R = PI * 2 / 360;
|
||||||
|
|
||||||
bShowShadowBuffer = false;
|
bShowShadowBuffer = false;
|
||||||
|
bShowOctree = false;
|
||||||
bEnablePerPixel = true;
|
bEnablePerPixel = true;
|
||||||
bEnableDiffuseMap = true;
|
bEnableDiffuseMap = true;
|
||||||
bEnableNormalMap = true;
|
bEnableNormalMap = true;
|
||||||
@@ -230,8 +231,10 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix, KRVector3 &lightD
|
|||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
// Set source to buffers from pass 1
|
// Set source to buffers from pass 1
|
||||||
|
m_pContext->getTextureManager()->selectTexture(6, NULL);
|
||||||
glActiveTexture(GL_TEXTURE6);
|
glActiveTexture(GL_TEXTURE6);
|
||||||
glBindTexture(GL_TEXTURE_2D, compositeColorTexture);
|
glBindTexture(GL_TEXTURE_2D, compositeColorTexture);
|
||||||
|
m_pContext->getTextureManager()->selectTexture(7, NULL);
|
||||||
glActiveTexture(GL_TEXTURE7);
|
glActiveTexture(GL_TEXTURE7);
|
||||||
glBindTexture(GL_TEXTURE_2D, compositeDepthTexture);
|
glBindTexture(GL_TEXTURE_2D, compositeDepthTexture);
|
||||||
|
|
||||||
@@ -251,6 +254,7 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix, KRVector3 &lightD
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
// Set source to buffers from pass 2
|
// Set source to buffers from pass 2
|
||||||
|
m_pContext->getTextureManager()->selectTexture(6, NULL);
|
||||||
glActiveTexture(GL_TEXTURE6);
|
glActiveTexture(GL_TEXTURE6);
|
||||||
glBindTexture(GL_TEXTURE_2D, lightAccumulationTexture);
|
glBindTexture(GL_TEXTURE_2D, lightAccumulationTexture);
|
||||||
|
|
||||||
@@ -270,8 +274,10 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix, KRVector3 &lightD
|
|||||||
scene.render(this, m_visibleBounds, m_pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, shadowmvpmatrix, shadowDepthTexture, m_cShadowBuffers, KRNode::RENDER_PASS_DEFERRED_OPAQUE);
|
scene.render(this, m_visibleBounds, m_pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, shadowmvpmatrix, shadowDepthTexture, m_cShadowBuffers, KRNode::RENDER_PASS_DEFERRED_OPAQUE);
|
||||||
|
|
||||||
// Deactivate source buffer texture units
|
// Deactivate source buffer texture units
|
||||||
|
m_pContext->getTextureManager()->selectTexture(6, NULL);
|
||||||
glActiveTexture(GL_TEXTURE6);
|
glActiveTexture(GL_TEXTURE6);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
m_pContext->getTextureManager()->selectTexture(7, NULL);
|
||||||
glActiveTexture(GL_TEXTURE7);
|
glActiveTexture(GL_TEXTURE7);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
} else {
|
} else {
|
||||||
@@ -355,38 +361,36 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix, KRVector3 &lightD
|
|||||||
|
|
||||||
// ----====---- Debug Overlay ----====----
|
// ----====---- Debug Overlay ----====----
|
||||||
|
|
||||||
bool bVisualize = false; // MIKE EDIT: True->false
|
if(bShowOctree) {
|
||||||
if(bVisualize) {
|
|
||||||
// Enable z-buffer test
|
// Enable z-buffer test
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthRangef(0.0, 1.0);
|
glDepthRangef(0.0, 1.0);
|
||||||
|
|
||||||
|
|
||||||
// Enable backface culling
|
// Enable backface culling
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
|
|
||||||
KRShader *pVisShader = m_pContext->getShaderManager()->getShader("visualize_overlay", this, false, false, false, 0, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
KRShader *pVisShader = m_pContext->getShaderManager()->getShader("visualize_overlay", this, false, false, false, 0, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
|
||||||
KRMat4 projectionMatrix = getProjectionMatrix();
|
KRMat4 projectionMatrix = getProjectionMatrix();
|
||||||
|
|
||||||
static const GLfloat cubeVertices[] = {
|
static const GLfloat cubeVertices[] = {
|
||||||
-1.0, 1.0, 1.0,
|
1.0, 1.0, 1.0,
|
||||||
1.0, 1.0, 1.0,
|
-1.0, 1.0, 1.0,
|
||||||
-1.0, -1.0, 1.0,
|
1.0,-1.0, 1.0,
|
||||||
1.0, -1.0, 1.0,
|
-1.0,-1.0, 1.0,
|
||||||
-1.0, -1.0, -1.0,
|
-1.0,-1.0,-1.0,
|
||||||
1.0, -1.0, -1.0,
|
-1.0, 1.0, 1.0,
|
||||||
-1.0, 1.0, -1.0,
|
-1.0, 1.0,-1.0,
|
||||||
1.0, 1.0, -1.0,
|
1.0, 1.0, 1.0,
|
||||||
-1.0, 1.0, 1.0,
|
1.0, 1.0,-1.0,
|
||||||
1.0, 1.0, 1.0,
|
1.0,-1.0, 1.0,
|
||||||
1.0, -1.0, 1.0,
|
1.0,-1.0,-1.0,
|
||||||
1.0, 1.0, -1.0,
|
-1.0,-1.0,-1.0,
|
||||||
1.0, -1.0, -1.0,
|
1.0, 1.0,-1.0,
|
||||||
-1.0, -1.0, -1.0,
|
-1.0, 1.0,-1.0
|
||||||
-1.0, 1.0, -1.0,
|
|
||||||
-1.0, -1.0, 1.0,
|
|
||||||
-1.0, 1.0, 1.0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
@@ -400,17 +404,18 @@ void KRCamera::renderFrame(KRScene &scene, KRMat4 &viewMatrix, KRVector3 &lightD
|
|||||||
KRMat4 mvpmatrix = matModel * viewMatrix * projectionMatrix;
|
KRMat4 mvpmatrix = matModel * viewMatrix * projectionMatrix;
|
||||||
|
|
||||||
pVisShader->bind(this, viewMatrix, mvpmatrix, cameraPosition, lightDirection, shadowmvpmatrix, shadowDepthTexture, 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
pVisShader->bind(this, viewMatrix, mvpmatrix, cameraPosition, lightDirection, shadowmvpmatrix, shadowDepthTexture, 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 17);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scene.getOcclusionQueryResults(m_visibleBounds);
|
scene.getOcclusionQueryResults(m_visibleBounds);
|
||||||
|
|
||||||
fprintf(stderr, "visible bounds: %i\n", (int)m_visibleBounds.size());
|
// fprintf(stderr, "visible bounds: %i\n", (int)m_visibleBounds.size());
|
||||||
|
|
||||||
// Re-enable z-buffer write
|
// Re-enable z-buffer write
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -664,10 +669,12 @@ void KRCamera::renderPost()
|
|||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
bindPostShader();
|
bindPostShader();
|
||||||
|
|
||||||
|
m_pContext->getTextureManager()->selectTexture(0, NULL);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, compositeDepthTexture);
|
glBindTexture(GL_TEXTURE_2D, compositeDepthTexture);
|
||||||
glUniform1i(glGetUniformLocation(m_postShaderProgram, "depthFrame"), 0);
|
glUniform1i(glGetUniformLocation(m_postShaderProgram, "depthFrame"), 0);
|
||||||
|
|
||||||
|
m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, compositeColorTexture);
|
glBindTexture(GL_TEXTURE_2D, compositeColorTexture);
|
||||||
//glBindTexture(GL_TEXTURE_2D, lightAccumulationTexture);
|
//glBindTexture(GL_TEXTURE_2D, lightAccumulationTexture);
|
||||||
@@ -682,9 +689,11 @@ void KRCamera::renderPost()
|
|||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
m_pContext->getTextureManager()->selectTexture(0, NULL);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
@@ -693,6 +702,7 @@ void KRCamera::renderPost()
|
|||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glUseProgram(m_postShaderProgram);
|
glUseProgram(m_postShaderProgram);
|
||||||
|
|
||||||
|
m_pContext->getTextureManager()->selectTexture(0, NULL);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, compositeDepthTexture);
|
glBindTexture(GL_TEXTURE_2D, compositeDepthTexture);
|
||||||
glUniform1i(glGetUniformLocation(m_postShaderProgram, "depthFrame"), 0);
|
glUniform1i(glGetUniformLocation(m_postShaderProgram, "depthFrame"), 0);
|
||||||
@@ -706,6 +716,7 @@ void KRCamera::renderPost()
|
|||||||
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_TEXUVA);
|
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_TEXUVA);
|
||||||
|
|
||||||
for(int iShadow=0; iShadow < m_cShadowBuffers; iShadow++) {
|
for(int iShadow=0; iShadow < m_cShadowBuffers; iShadow++) {
|
||||||
|
m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, shadowDepthTexture[iShadow]);
|
glBindTexture(GL_TEXTURE_2D, shadowDepthTexture[iShadow]);
|
||||||
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, squareVerticesShadow[iShadow]);
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, squareVerticesShadow[iShadow]);
|
||||||
@@ -713,9 +724,11 @@ void KRCamera::renderPost()
|
|||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pContext->getTextureManager()->selectTexture(0, NULL);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
@@ -729,11 +742,11 @@ void KRCamera::renderPost()
|
|||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glUseProgram(m_postShaderProgram);
|
glUseProgram(m_postShaderProgram);
|
||||||
|
|
||||||
|
m_pContext->getTextureManager()->selectTexture(0, NULL);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, compositeDepthTexture);
|
glBindTexture(GL_TEXTURE_2D, compositeDepthTexture);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
m_pContext->getTextureManager()->selectTexture(1, pFontTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, pFontTexture->getName());
|
|
||||||
|
|
||||||
glUniform1i(glGetUniformLocation(m_postShaderProgram, "depthFrame"), 0);
|
glUniform1i(glGetUniformLocation(m_postShaderProgram, "depthFrame"), 0);
|
||||||
glUniform1i(glGetUniformLocation(m_postShaderProgram, "renderFrame"), 1);
|
glUniform1i(glGetUniformLocation(m_postShaderProgram, "renderFrame"), 1);
|
||||||
@@ -774,8 +787,7 @@ void KRCamera::renderPost()
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ public:
|
|||||||
bool bDebugPSSM;
|
bool bDebugPSSM;
|
||||||
bool bDebugSuperShiny;
|
bool bDebugSuperShiny;
|
||||||
bool bShowShadowBuffer;
|
bool bShowShadowBuffer;
|
||||||
|
bool bShowOctree;
|
||||||
bool bEnableAmbient;
|
bool bEnableAmbient;
|
||||||
bool bEnableDiffuse;
|
bool bEnableDiffuse;
|
||||||
bool bEnableSpecular;
|
bool bEnableSpecular;
|
||||||
|
|||||||
@@ -12,14 +12,16 @@
|
|||||||
#include "KRCamera.h"
|
#include "KRCamera.h"
|
||||||
|
|
||||||
KRContext::KRContext() {
|
KRContext::KRContext() {
|
||||||
m_pShaderManager = new KRShaderManager(*this);
|
m_pBundleManager = new KRBundleManager(*this);
|
||||||
m_pTextureManager = new KRTextureManager(*this);
|
m_pShaderManager = new KRShaderManager(*this);
|
||||||
m_pMaterialManager = new KRMaterialManager(*this, m_pTextureManager, m_pShaderManager);
|
m_pTextureManager = new KRTextureManager(*this);
|
||||||
m_pModelManager = new KRModelManager(*this);
|
m_pMaterialManager = new KRMaterialManager(*this, m_pTextureManager, m_pShaderManager);
|
||||||
m_pSceneManager = new KRSceneManager(*this);
|
m_pModelManager = new KRModelManager(*this);
|
||||||
|
m_pSceneManager = new KRSceneManager(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
KRContext::~KRContext() {
|
KRContext::~KRContext() {
|
||||||
|
|
||||||
if(m_pSceneManager) {
|
if(m_pSceneManager) {
|
||||||
delete m_pSceneManager;
|
delete m_pSceneManager;
|
||||||
m_pSceneManager = NULL;
|
m_pSceneManager = NULL;
|
||||||
@@ -44,9 +46,17 @@ KRContext::~KRContext() {
|
|||||||
delete m_pShaderManager;
|
delete m_pShaderManager;
|
||||||
m_pShaderManager = NULL;
|
m_pShaderManager = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The bundles must be destroyed last, as the other objects may be using mmap'ed data from bundles
|
||||||
|
if(m_pBundleManager) {
|
||||||
|
delete m_pBundleManager;
|
||||||
|
m_pBundleManager = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KRBundleManager *KRContext::getBundleManager() {
|
||||||
|
return m_pBundleManager;
|
||||||
|
}
|
||||||
KRSceneManager *KRContext::getSceneManager() {
|
KRSceneManager *KRContext::getSceneManager() {
|
||||||
return m_pSceneManager;
|
return m_pSceneManager;
|
||||||
}
|
}
|
||||||
@@ -63,24 +73,41 @@ KRModelManager *KRContext::getModelManager() {
|
|||||||
return m_pModelManager;
|
return m_pModelManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRContext::loadResource(std::string path) {
|
void KRContext::loadResource(const std::string &file_name, KRDataBlock *data) {
|
||||||
std::string name = KRResource::GetFileBase(path);
|
std::string name = KRResource::GetFileBase(file_name);
|
||||||
std::string extension = KRResource::GetFileExtension(path);
|
std::string extension = KRResource::GetFileExtension(file_name);
|
||||||
if(extension.compare("krobject") == 0) {
|
|
||||||
m_pModelManager->loadModel(name.c_str(), path.c_str());
|
fprintf(stderr, "KRContext::loadResource - Loading: %s\n", file_name.c_str());
|
||||||
|
|
||||||
|
if(extension.compare("krbundle") == 0) {
|
||||||
|
m_pBundleManager->loadBundle(name.c_str(), data);
|
||||||
|
} else if(extension.compare("krobject") == 0) {
|
||||||
|
m_pModelManager->loadModel(name.c_str(), data);
|
||||||
} else if(extension.compare("krscene") == 0) {
|
} else if(extension.compare("krscene") == 0) {
|
||||||
m_pSceneManager->loadScene(name.c_str(), path.c_str());
|
m_pSceneManager->loadScene(name.c_str(), data);
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
} else if(extension.compare("pvr") == 0) {
|
} else if(extension.compare("pvr") == 0) {
|
||||||
m_pTextureManager->loadTexture(name.c_str(), path.c_str());
|
m_pTextureManager->loadTexture(name.c_str(), data);
|
||||||
#endif
|
#endif
|
||||||
} else if(extension.compare("vsh") == 0) {
|
} else if(extension.compare("vsh") == 0) {
|
||||||
m_pShaderManager->loadVertexShader(name.c_str(), path.c_str());
|
m_pShaderManager->loadVertexShader(name.c_str(), data);
|
||||||
} else if(extension.compare("fsh") == 0) {
|
} else if(extension.compare("fsh") == 0) {
|
||||||
m_pShaderManager->loadFragmentShader(name.c_str(), path.c_str());
|
m_pShaderManager->loadFragmentShader(name.c_str(), data);
|
||||||
} else if(extension.compare("mtl") == 0) {
|
} else if(extension.compare("mtl") == 0) {
|
||||||
m_pMaterialManager->loadFile(path.c_str());
|
m_pMaterialManager->load(name.c_str(), data);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "KRContext::loadResource - Unknown resource file type: %s\n", path.c_str());
|
fprintf(stderr, "KRContext::loadResource - Unknown resource file type: %s\n", file_name.c_str());
|
||||||
|
delete data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRContext::loadResource(std::string path) {
|
||||||
|
KRDataBlock *data = new KRDataBlock();
|
||||||
|
if(data->load(path)) {
|
||||||
|
loadResource(path, data);
|
||||||
|
} else {
|
||||||
|
delete data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#ifndef KREngine_KRContext_h
|
#ifndef KREngine_KRContext_h
|
||||||
#define KREngine_KRContext_h
|
#define KREngine_KRContext_h
|
||||||
|
|
||||||
|
#import "KRBundleManager.h"
|
||||||
#import "KRSceneManager.h"
|
#import "KRSceneManager.h"
|
||||||
#import "KRTextureManager.h"
|
#import "KRTextureManager.h"
|
||||||
#import "KRMaterialManager.h"
|
#import "KRMaterialManager.h"
|
||||||
@@ -21,8 +22,10 @@ public:
|
|||||||
KRContext();
|
KRContext();
|
||||||
~KRContext();
|
~KRContext();
|
||||||
|
|
||||||
|
void loadResource(const std::string &file_name, KRDataBlock *data);
|
||||||
void loadResource(std::string path);
|
void loadResource(std::string path);
|
||||||
|
|
||||||
|
KRBundleManager *getBundleManager();
|
||||||
KRSceneManager *getSceneManager();
|
KRSceneManager *getSceneManager();
|
||||||
KRTextureManager *getTextureManager();
|
KRTextureManager *getTextureManager();
|
||||||
KRMaterialManager *getMaterialManager();
|
KRMaterialManager *getMaterialManager();
|
||||||
@@ -32,6 +35,7 @@ public:
|
|||||||
KRCamera *createCamera(int width, int height);
|
KRCamera *createCamera(int width, int height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
KRBundleManager *m_pBundleManager;
|
||||||
KRSceneManager *m_pSceneManager;
|
KRSceneManager *m_pSceneManager;
|
||||||
KRTextureManager *m_pTextureManager;
|
KRTextureManager *m_pTextureManager;
|
||||||
KRMaterialManager *m_pMaterialManager;
|
KRMaterialManager *m_pMaterialManager;
|
||||||
|
|||||||
@@ -2,41 +2,188 @@
|
|||||||
// KRDataBlock.cpp
|
// KRDataBlock.cpp
|
||||||
// KREngine
|
// KREngine
|
||||||
//
|
//
|
||||||
// Created by Kearwood Gilbert on 12-05-11.
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
// provided with the distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "KRDataBlock.h"
|
#include "KRDataBlock.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
KRDataBlock::KRDataBlock() {
|
KRDataBlock::KRDataBlock() {
|
||||||
m_data = NULL;
|
m_data = NULL;
|
||||||
m_data_size = 0;
|
m_data_size = 0;
|
||||||
|
m_fdPackFile = 0;
|
||||||
|
m_bMalloced = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRDataBlock::~KRDataBlock() {
|
KRDataBlock::~KRDataBlock() {
|
||||||
if(m_data) {
|
unload();
|
||||||
free(m_data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *KRDataBlock::getData() {
|
// Unload a file, releasing any mmap'ed file handles or malloc'ed ram that was in use
|
||||||
|
void KRDataBlock::unload()
|
||||||
|
{
|
||||||
|
if(m_fdPackFile) {
|
||||||
|
// Memory mapped file
|
||||||
|
if(m_bMalloced) {
|
||||||
|
munmap(m_data, m_data_size);
|
||||||
|
}
|
||||||
|
close(m_fdPackFile);
|
||||||
|
} else if(m_data != NULL && m_bMalloced) {
|
||||||
|
// Malloc'ed data
|
||||||
|
free(m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bMalloced = false;
|
||||||
|
m_data = NULL;
|
||||||
|
m_data_size = 0;
|
||||||
|
m_fdPackFile = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encapsulate a pointer. Note - The pointer will not be free'ed
|
||||||
|
bool KRDataBlock::load(void *data, size_t size)
|
||||||
|
{
|
||||||
|
unload();
|
||||||
|
m_data = data;
|
||||||
|
m_data_size = size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load a file into memory using mmap. The data pointer will be protected as read-only until append() or expand() is called
|
||||||
|
bool KRDataBlock::load(const std::string &path)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
unload();
|
||||||
|
|
||||||
|
struct stat statbuf;
|
||||||
|
m_fdPackFile = open(path.c_str(), O_RDONLY);
|
||||||
|
if(m_fdPackFile >= 0) {
|
||||||
|
if(fstat(m_fdPackFile, &statbuf) >= 0) {
|
||||||
|
if ((m_data = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, m_fdPackFile, 0)) == (caddr_t) -1) {
|
||||||
|
} else {
|
||||||
|
m_data_size = statbuf.st_size;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!success) {
|
||||||
|
// If anything failed, don't leave the object in an invalid state
|
||||||
|
unload();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return a pointer to the start of the data block
|
||||||
|
void *KRDataBlock::getStart() {
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KRDataBlock::getSize() {
|
// Return a pointer to the byte after the end of the data block
|
||||||
|
void *KRDataBlock::getEnd() {
|
||||||
|
return (unsigned char *)m_data + m_data_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the size of the data block. Use append() or expand() to make the data block larger
|
||||||
|
size_t KRDataBlock::getSize() const {
|
||||||
return m_data_size;
|
return m_data_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRDataBlock::append(void *data, int size) {
|
// Expand the data block, and switch it to read-write mode. Note - this may result in a mmap'ed file being copied to malloc'ed ram and then closed
|
||||||
|
void KRDataBlock::expand(size_t size)
|
||||||
|
{
|
||||||
if(m_data == NULL) {
|
if(m_data == NULL) {
|
||||||
|
// Starting with an empty data block; allocate memory on the heap
|
||||||
m_data = malloc(size);
|
m_data = malloc(size);
|
||||||
memcpy(m_data, data, size);
|
|
||||||
m_data_size = size;
|
m_data_size = size;
|
||||||
} else {
|
m_bMalloced = true;
|
||||||
|
} else if(m_bMalloced) {
|
||||||
|
// Starting with a malloc'ed data block; realloc it expand
|
||||||
m_data = realloc(m_data, m_data_size + size);
|
m_data = realloc(m_data, m_data_size + size);
|
||||||
memcpy((unsigned char *)m_data + size, data, size);
|
|
||||||
m_data_size += size;
|
m_data_size += size;
|
||||||
|
} else {
|
||||||
|
// Starting with a mmap'ed data block; copy it to ram before expanding to avoid updating the original file until save() is called
|
||||||
|
// ... Or starting with a pointer reference, we must make our own copy and must not free the pointer
|
||||||
|
void *pNewData = malloc(m_data_size + size);
|
||||||
|
memcpy((unsigned char *)pNewData, m_data, m_data_size); // Copy exising data
|
||||||
|
// Unload existing data allocation, which is now redundant
|
||||||
|
size_t new_size = m_data_size + size; // We need to store this before unload() as unload() will reset it
|
||||||
|
unload();
|
||||||
|
m_bMalloced = true;
|
||||||
|
m_data = pNewData;
|
||||||
|
m_data_size = new_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append data to the end of the block, increasing the size of the block and making it read-write.
|
||||||
|
void KRDataBlock::append(void *data, size_t size) {
|
||||||
|
// Expand the data block
|
||||||
|
expand(size);
|
||||||
|
|
||||||
|
// Fill the new space with the data to append
|
||||||
|
memcpy((unsigned char *)m_data + m_data_size - size, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the data to a file, and switch to read-only mode. The data pointer will be replaced with a mmap'ed address of the file; the malloc'ed data will be freed
|
||||||
|
bool KRDataBlock::save(const std::string& path) {
|
||||||
|
int fdNewFile = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
|
||||||
|
if(fdNewFile == -1) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// Seek to end of file and write a byte to enlarge it
|
||||||
|
lseek(fdNewFile, m_data_size-1, SEEK_SET);
|
||||||
|
write(fdNewFile, "", 1);
|
||||||
|
|
||||||
|
// Now map it...
|
||||||
|
void *pNewData = mmap(0, m_data_size, PROT_READ | PROT_WRITE, MAP_SHARED, fdNewFile, 0);
|
||||||
|
if(pNewData == (caddr_t) -1) {
|
||||||
|
close(fdNewFile);
|
||||||
|
return false;
|
||||||
|
} else if(m_data != NULL) {
|
||||||
|
// Copy data to new file
|
||||||
|
memcpy(pNewData, m_data, m_data_size);
|
||||||
|
|
||||||
|
// Unload existing data allocation, which is now redundant
|
||||||
|
size_t new_size = m_data_size; // We need to store this, as unload() will reset it
|
||||||
|
unload();
|
||||||
|
|
||||||
|
// Protect new mmap'ed memory
|
||||||
|
mprotect(pNewData, m_data_size, PROT_READ);
|
||||||
|
|
||||||
|
// Switch pointer to use new mmap'ed memory
|
||||||
|
m_data_size = new_size;
|
||||||
|
m_fdPackFile = fdNewFile;
|
||||||
|
m_data = pNewData;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,31 @@
|
|||||||
// KRDataBlock.h
|
// KRDataBlock.h
|
||||||
// KREngine
|
// KREngine
|
||||||
//
|
//
|
||||||
// Created by Kearwood Gilbert on 12-05-11.
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
// provided with the distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef KREngine_KRDataBlock_h
|
#ifndef KREngine_KRDataBlock_h
|
||||||
@@ -14,13 +37,41 @@ public:
|
|||||||
KRDataBlock();
|
KRDataBlock();
|
||||||
~KRDataBlock();
|
~KRDataBlock();
|
||||||
|
|
||||||
void append(void *data, int size);
|
// Encapsulate a pointer. Note - The pointer will not be free'ed
|
||||||
|
bool load(void *data, size_t size);
|
||||||
|
|
||||||
void *getData();
|
// Load a file into memory using mmap. The data pointer will be protected as read-only until append() or expand() is called
|
||||||
int getSize();
|
bool load(const std::string &path);
|
||||||
|
|
||||||
|
// Save the data to a file, and switch to read-only mode. The data pointer will be replaced with a mmap'ed address of the file; the malloc'ed data will be freed
|
||||||
|
bool save(const std::string& path);
|
||||||
|
|
||||||
|
// Append data to the end of the block, increasing the size of the block and making it read-write.
|
||||||
|
void append(void *data, size_t size);
|
||||||
|
|
||||||
|
// Expand the data block, and switch it to read-write mode. Note - this may result in a mmap'ed file being copied to malloc'ed ram and then closed
|
||||||
|
void expand(size_t size);
|
||||||
|
|
||||||
|
// Unload a file, releasing any mmap'ed file handles or malloc'ed ram that was in use
|
||||||
|
void unload();
|
||||||
|
|
||||||
|
// Return a pointer to the start of the data block
|
||||||
|
void *getStart();
|
||||||
|
|
||||||
|
// Return a pointer to the one byte after the end of the data block
|
||||||
|
void *getEnd();
|
||||||
|
|
||||||
|
// Return the size of the data block. Use append() or expand() to make the data block larger
|
||||||
|
size_t getSize() const;
|
||||||
private:
|
private:
|
||||||
void *m_data;
|
void *m_data;
|
||||||
int m_data_size;
|
size_t m_data_size;
|
||||||
|
|
||||||
|
// For memory mapped objects:
|
||||||
|
int m_fdPackFile;
|
||||||
|
|
||||||
|
// For malloc'ed objects:
|
||||||
|
bool m_bMalloced;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ KRVector3 KRDirectionalLight::getLocalLightDirection() {
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
bool KRDirectionalLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
void KRDirectionalLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
bool bRendered = KRLight::render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
KRLight::render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
||||||
|
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_DEFERRED_LIGHTS) {
|
if(renderPass == KRNode::RENDER_PASS_DEFERRED_LIGHTS) {
|
||||||
@@ -109,8 +109,6 @@ bool KRDirectionalLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundi
|
|||||||
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_VERTEX);
|
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_VERTEX);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bRendered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
virtual bool render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass);
|
virtual void render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ double const PI = 3.141592653589793f;
|
|||||||
@"debug_enable_diffuse" : @27,
|
@"debug_enable_diffuse" : @27,
|
||||||
@"debug_enable_specular" : @28,
|
@"debug_enable_specular" : @28,
|
||||||
@"debug_super_shiny" : @29,
|
@"debug_super_shiny" : @29,
|
||||||
@"enable_deferred_lighting" : @30
|
@"debug_octree" : @30,
|
||||||
|
@"enable_deferred_lighting" : @31
|
||||||
} copy];
|
} copy];
|
||||||
[self loadShaders];
|
[self loadShaders];
|
||||||
|
|
||||||
@@ -151,7 +152,7 @@ double const PI = 3.141592653589793f;
|
|||||||
|
|
||||||
-(int)getParameterCount
|
-(int)getParameterCount
|
||||||
{
|
{
|
||||||
return 31;
|
return 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSString *)getParameterNameWithIndex: (int)i
|
-(NSString *)getParameterNameWithIndex: (int)i
|
||||||
@@ -161,7 +162,7 @@ double const PI = 3.141592653589793f;
|
|||||||
|
|
||||||
-(NSString *)getParameterLabelWithIndex: (int)i
|
-(NSString *)getParameterLabelWithIndex: (int)i
|
||||||
{
|
{
|
||||||
NSString *parameter_labels[31] = {
|
NSString *parameter_labels[32] = {
|
||||||
@"Camera FOV",
|
@"Camera FOV",
|
||||||
@"Shadow Quality (0 - 2)",
|
@"Shadow Quality (0 - 2)",
|
||||||
@"Enable per-pixel lighting",
|
@"Enable per-pixel lighting",
|
||||||
@@ -192,13 +193,14 @@ double const PI = 3.141592653589793f;
|
|||||||
@"Debug - Enable Diffuse",
|
@"Debug - Enable Diffuse",
|
||||||
@"Debug - Enable Specular",
|
@"Debug - Enable Specular",
|
||||||
@"Debug - Super Shiny",
|
@"Debug - Super Shiny",
|
||||||
|
@"Debug - Octree Visualize",
|
||||||
@"Enable Deferred Lighting"
|
@"Enable Deferred Lighting"
|
||||||
};
|
};
|
||||||
return parameter_labels[i];
|
return parameter_labels[i];
|
||||||
}
|
}
|
||||||
-(KREngineParameterType)getParameterTypeWithIndex: (int)i
|
-(KREngineParameterType)getParameterTypeWithIndex: (int)i
|
||||||
{
|
{
|
||||||
KREngineParameterType types[31] = {
|
KREngineParameterType types[32] = {
|
||||||
|
|
||||||
KRENGINE_PARAMETER_FLOAT,
|
KRENGINE_PARAMETER_FLOAT,
|
||||||
KRENGINE_PARAMETER_INT,
|
KRENGINE_PARAMETER_INT,
|
||||||
@@ -230,13 +232,14 @@ double const PI = 3.141592653589793f;
|
|||||||
KRENGINE_PARAMETER_BOOL,
|
KRENGINE_PARAMETER_BOOL,
|
||||||
KRENGINE_PARAMETER_BOOL,
|
KRENGINE_PARAMETER_BOOL,
|
||||||
KRENGINE_PARAMETER_BOOL,
|
KRENGINE_PARAMETER_BOOL,
|
||||||
|
KRENGINE_PARAMETER_BOOL,
|
||||||
KRENGINE_PARAMETER_BOOL
|
KRENGINE_PARAMETER_BOOL
|
||||||
};
|
};
|
||||||
return types[i];
|
return types[i];
|
||||||
}
|
}
|
||||||
-(double)getParameterValueWithIndex: (int)i
|
-(double)getParameterValueWithIndex: (int)i
|
||||||
{
|
{
|
||||||
double values[31] = {
|
double values[32] = {
|
||||||
_camera->perspective_fov,
|
_camera->perspective_fov,
|
||||||
(double)_camera->m_cShadowBuffers,
|
(double)_camera->m_cShadowBuffers,
|
||||||
_camera->bEnablePerPixel ? 1.0f : 0.0f,
|
_camera->bEnablePerPixel ? 1.0f : 0.0f,
|
||||||
@@ -267,6 +270,7 @@ double const PI = 3.141592653589793f;
|
|||||||
_camera->bEnableDiffuse ? 1.0f : 0.0f,
|
_camera->bEnableDiffuse ? 1.0f : 0.0f,
|
||||||
_camera->bEnableSpecular ? 1.0f : 0.0f,
|
_camera->bEnableSpecular ? 1.0f : 0.0f,
|
||||||
_camera->bDebugSuperShiny ? 1.0f : 0.0f,
|
_camera->bDebugSuperShiny ? 1.0f : 0.0f,
|
||||||
|
_camera->bShowOctree ? 1.0f : 0.0f,
|
||||||
_camera->bEnableDeferredLighting ? 1.0f : 0.0f
|
_camera->bEnableDeferredLighting ? 1.0f : 0.0f
|
||||||
};
|
};
|
||||||
return values[i];
|
return values[i];
|
||||||
@@ -409,21 +413,38 @@ double const PI = 3.141592653589793f;
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 30:
|
case 30:
|
||||||
|
if(_camera->bShowOctree != bNewBoolVal) {
|
||||||
|
_camera->bShowOctree = bNewBoolVal;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 31:
|
||||||
if(_camera->bEnableDeferredLighting != bNewBoolVal) {
|
if(_camera->bEnableDeferredLighting != bNewBoolVal) {
|
||||||
_camera->bEnableDeferredLighting = bNewBoolVal;
|
_camera->bEnableDeferredLighting = bNewBoolVal;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(double)getParameterMinWithIndex: (int)i
|
-(double)getParameterMinWithIndex: (int)i
|
||||||
{
|
{
|
||||||
double minValues[31] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
double minValues[32] = {
|
||||||
|
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f
|
||||||
|
};
|
||||||
return minValues[i];
|
return minValues[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(double)getParameterMaxWithIndex: (int)i
|
-(double)getParameterMaxWithIndex: (int)i
|
||||||
{
|
{
|
||||||
double maxValues[31] = {PI, 3.0f, 1.0f, 1.0, 1.0f, 1.0f, 1.0f, 1.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 2.0f, 1.0f, 1.0f, 1.0f, 5.0f, 1.0f, 0.5f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
|
double maxValues[32] = {
|
||||||
|
PI, 3.0f, 1.0f, 1.0, 1.0f, 1.0f, 1.0f, 1.0f, 3.0f, 3.0f,
|
||||||
|
3.0f, 3.0f, 3.0f, 3.0f, 2.0f, 1.0f, 1.0f, 1.0f, 5.0f, 1.0f,
|
||||||
|
0.5f, 1.0f, 2.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
|
||||||
|
1.0f, 1.0f
|
||||||
|
};
|
||||||
|
|
||||||
return maxValues[i];
|
return maxValues[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,34 +74,31 @@ void KRInstance::loadModel() {
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
bool KRInstance::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
void KRInstance::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
bool bRendered = KRNode::render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
KRNode::render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
||||||
|
|
||||||
if(renderPass != KRNode::RENDER_PASS_DEFERRED_LIGHTS && (renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT || this->hasTransparency()) && renderPass != KRNode::RENDER_PASS_FLARES) {
|
if(renderPass != KRNode::RENDER_PASS_DEFERRED_LIGHTS && (renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT || this->hasTransparency()) && renderPass != KRNode::RENDER_PASS_FLARES) {
|
||||||
// Don't render meshes on second pass of the deferred lighting renderer, as only lights will be applied
|
// Don't render meshes on second pass of the deferred lighting renderer, as only lights will be applied
|
||||||
|
|
||||||
loadModel();
|
loadModel();
|
||||||
|
|
||||||
|
KRMat4 projectionMatrix;
|
||||||
|
if(renderPass != KRNode::RENDER_PASS_SHADOWMAP) {
|
||||||
|
projectionMatrix = pCamera->getProjectionMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
if(m_pModel != NULL && (getExtents(pContext).test_intersect(frustrumVolume) || renderPass == RENDER_PASS_SHADOWMAP)) {
|
if(m_pModel != NULL && (getExtents(pContext).test_intersect(frustrumVolume) || renderPass == RENDER_PASS_SHADOWMAP)) {
|
||||||
|
//if(m_pModel != NULL && (getBounds().visible(viewMatrix * projectionMatrix) || renderPass == RENDER_PASS_SHADOWMAP)) {
|
||||||
|
|
||||||
if(m_pLightMap == NULL && m_lightMap.size()) {
|
if(m_pLightMap == NULL && m_lightMap.size()) {
|
||||||
m_pLightMap = pContext->getTextureManager()->getTexture(m_lightMap.c_str());
|
m_pLightMap = pContext->getTextureManager()->getTexture(m_lightMap.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cShadowBuffers == 0 && m_pLightMap && pCamera->bEnableLightMap && renderPass != RENDER_PASS_SHADOWMAP) {
|
if(cShadowBuffers == 0 && m_pLightMap && pCamera->bEnableLightMap && renderPass != RENDER_PASS_SHADOWMAP) {
|
||||||
int iTextureName = m_pLightMap->getName();
|
m_pContext->getTextureManager()->selectTexture(3, m_pLightMap);
|
||||||
glActiveTexture(GL_TEXTURE3);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, iTextureName);
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMat4 projectionMatrix;
|
|
||||||
if(renderPass != RENDER_PASS_SHADOWMAP) {
|
|
||||||
projectionMatrix = pCamera->getProjectionMatrix();
|
|
||||||
}
|
|
||||||
KRMat4 mvpmatrix = m_modelMatrix * viewMatrix * projectionMatrix;
|
KRMat4 mvpmatrix = m_modelMatrix * viewMatrix * projectionMatrix;
|
||||||
KRMat4 matModelToView = viewMatrix * m_modelMatrix;
|
KRMat4 matModelToView = viewMatrix * m_modelMatrix;
|
||||||
matModelToView.transpose();
|
matModelToView.transpose();
|
||||||
@@ -113,30 +110,15 @@ bool KRInstance::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume
|
|||||||
KRVector3 cameraPosObject = KRMat4::Dot(inverseModelMatrix, cameraPosition);
|
KRVector3 cameraPosObject = KRMat4::Dot(inverseModelMatrix, cameraPosition);
|
||||||
KRVector3 lightDirObject = KRMat4::Dot(inverseModelMatrix, lightDirection);
|
KRVector3 lightDirObject = KRMat4::Dot(inverseModelMatrix, lightDirection);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLuint occlusionTest,hasBeenTested,theParams = 0;
|
|
||||||
glGenQueriesEXT(1, &occlusionTest);
|
|
||||||
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, occlusionTest);
|
|
||||||
m_pModel->render(pCamera, pContext, matModelToView, mvpmatrix, cameraPosObject, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, m_pLightMap, renderPass);
|
m_pModel->render(pCamera, pContext, matModelToView, mvpmatrix, cameraPosObject, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, m_pLightMap, renderPass);
|
||||||
glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
|
|
||||||
/*
|
|
||||||
glGetQueryObjectuivEXT(occlusionTest, GL_QUERY_RESULT_AVAILABLE_EXT, &hasBeenTested);
|
|
||||||
if (hasBeenTested) glGetQueryObjectuivEXT(occlusionTest, GL_QUERY_RESULT_EXT, &theParams);
|
|
||||||
if (theParams) {
|
|
||||||
bRendered = true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
bRendered = true;
|
|
||||||
glDeleteQueriesEXT(1, &occlusionTest);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bRendered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void KRInstance::calcExtents(KRContext *pContext) {
|
void KRInstance::calcExtents(KRContext *pContext)
|
||||||
|
{
|
||||||
KRNode::calcExtents(pContext);
|
KRNode::calcExtents(pContext);
|
||||||
loadModel();
|
loadModel();
|
||||||
KRMesh *pMesh = m_pModel->getMesh();
|
KRMesh *pMesh = m_pModel->getMesh();
|
||||||
@@ -156,12 +138,47 @@ bool KRInstance::hasTransparency() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KRVector3 KRInstance::getMinPoint() {
|
KRAABB KRInstance::getBounds() {
|
||||||
loadModel();
|
loadModel();
|
||||||
return KRMat4::Dot(m_modelMatrix, m_pModel->getMesh()->getMinPoint());
|
|
||||||
}
|
|
||||||
|
|
||||||
KRVector3 KRInstance::getMaxPoint() {
|
KRMesh *pMesh = m_pModel->getMesh();
|
||||||
loadModel();
|
KRVector3 meshMin = pMesh->getMinPoint();
|
||||||
return KRMat4::Dot(m_modelMatrix, m_pModel->getMesh()->getMaxPoint());
|
KRVector3 meshMax = pMesh->getMaxPoint();
|
||||||
|
|
||||||
|
KRVector3 min, max;
|
||||||
|
for(int iCorner=0; iCorner < 8; iCorner++) {
|
||||||
|
KRVector3 cornerVertex = KRVector3(
|
||||||
|
(iCorner & 1) == 0 ? meshMin.x : meshMax.x,
|
||||||
|
(iCorner & 2) == 0 ? meshMin.y : meshMax.y,
|
||||||
|
(iCorner & 4) == 0 ? meshMin.z : meshMax.z);
|
||||||
|
|
||||||
|
cornerVertex = KRMat4::Dot(m_modelMatrix, cornerVertex);
|
||||||
|
if(iCorner == 0) {
|
||||||
|
// Prime with first point
|
||||||
|
min = cornerVertex;
|
||||||
|
max = cornerVertex;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(cornerVertex.x < min.x) {
|
||||||
|
min.x = cornerVertex.x;
|
||||||
|
}
|
||||||
|
if(cornerVertex.y < min.y) {
|
||||||
|
min.y = cornerVertex.y;
|
||||||
|
}
|
||||||
|
if(cornerVertex.z < min.z) {
|
||||||
|
min.z = cornerVertex.z;
|
||||||
|
}
|
||||||
|
if(cornerVertex.x > max.x) {
|
||||||
|
max.x = cornerVertex.x;
|
||||||
|
}
|
||||||
|
if(cornerVertex.y > max.y) {
|
||||||
|
max.y = cornerVertex.y;
|
||||||
|
}
|
||||||
|
if(cornerVertex.z > max.z) {
|
||||||
|
max.z = cornerVertex.z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return KRAABB(min, max);
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
virtual bool render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, RenderPass renderPass);
|
virtual void render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, RenderPass renderPass);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void calcExtents(KRContext *pContext);
|
virtual void calcExtents(KRContext *pContext);
|
||||||
@@ -71,8 +71,7 @@ public:
|
|||||||
bool hasTransparency();
|
bool hasTransparency();
|
||||||
|
|
||||||
|
|
||||||
virtual KRVector3 getMinPoint();
|
virtual KRAABB getBounds();
|
||||||
virtual KRVector3 getMaxPoint();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KRModel *m_pModel;
|
KRModel *m_pModel;
|
||||||
|
|||||||
@@ -117,9 +117,9 @@ float KRLight::getDecayStart() {
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
bool KRLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
void KRLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
bool bRendered = KRNode::render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
KRNode::render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_FLARES) {
|
if(renderPass == KRNode::RENDER_PASS_FLARES) {
|
||||||
if(m_flareTexture.size() && m_flareSize > 0.0f) {
|
if(m_flareTexture.size() && m_flareSize > 0.0f) {
|
||||||
@@ -146,8 +146,7 @@ bool KRLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &f
|
|||||||
// Render light flare on transparency pass
|
// Render light flare on transparency pass
|
||||||
KRShader *pShader = pContext->getShaderManager()->getShader("flare", pCamera, false, false, false, 0, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = pContext->getShaderManager()->getShader("flare", pCamera, false, false, false, 0, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
pShader->bind(pCamera, matModelToView, mvpmatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, 0, renderPass);
|
pShader->bind(pCamera, matModelToView, mvpmatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, 0, renderPass);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_pFlareTexture->getName());
|
|
||||||
|
|
||||||
static const GLfloat squareVertices[] = {
|
static const GLfloat squareVertices[] = {
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
@@ -169,8 +168,6 @@ bool KRLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &f
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bRendered || true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
virtual bool render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass);
|
virtual void render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ void KRMat4::transpose() {
|
|||||||
memcpy(m_mat, trans, sizeof(GLfloat) * 16);
|
memcpy(m_mat, trans, sizeof(GLfloat) * 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dot Product */
|
/* Dot Product, returning KRVector3 */
|
||||||
KRVector3 KRMat4::Dot(const KRMat4 &m, const KRVector3 &v) {
|
KRVector3 KRMat4::Dot(const KRMat4 &m, const KRVector3 &v) {
|
||||||
return KRVector3(
|
return KRVector3(
|
||||||
v.x * (float)m[0*4 + 0] + v.y * (float)m[1*4 + 0] + v.z * (float)m[2*4 + 0] + (float)m[3*4 + 0],
|
v.x * (float)m[0*4 + 0] + v.y * (float)m[1*4 + 0] + v.z * (float)m[2*4 + 0] + (float)m[3*4 + 0],
|
||||||
@@ -286,3 +286,20 @@ KRVector3 KRMat4::Dot(const KRMat4 &m, const KRVector3 &v) {
|
|||||||
v.x * (float)m[0*4 + 2] + v.y * (float)m[1*4 + 2] + v.z * (float)m[2*4 + 2] + (float)m[3*4 + 2]
|
v.x * (float)m[0*4 + 2] + v.y * (float)m[1*4 + 2] + v.z * (float)m[2*4 + 2] + (float)m[3*4 + 2]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dot Product, returning w component as if it were a KRVector4 (This will be deprecated once KRVector4 is implemented instead*/
|
||||||
|
float KRMat4::DotW(const KRMat4 &m, const KRVector3 &v) {
|
||||||
|
return v.x * (float)m[0*4 + 3] + v.y * (float)m[1*4 + 3] + v.z * (float)m[2*4 + 3] + (float)m[3*4 + 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dot Product followed by W-divide */
|
||||||
|
KRVector3 KRMat4::DotWDiv(const KRMat4 &m, const KRVector3 &v) {
|
||||||
|
KRVector3 r = KRVector3(
|
||||||
|
v.x * (float)m[0*4 + 0] + v.y * (float)m[1*4 + 0] + v.z * (float)m[2*4 + 0] + (float)m[3*4 + 0],
|
||||||
|
v.x * (float)m[0*4 + 1] + v.y * (float)m[1*4 + 1] + v.z * (float)m[2*4 + 1] + (float)m[3*4 + 1],
|
||||||
|
v.x * (float)m[0*4 + 2] + v.y * (float)m[1*4 + 2] + v.z * (float)m[2*4 + 2] + (float)m[3*4 + 2]
|
||||||
|
);
|
||||||
|
// Get W component, then divide x, y, and z by w.
|
||||||
|
r /= DotW(m, v);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ public:
|
|||||||
void transpose();
|
void transpose();
|
||||||
|
|
||||||
static KRVector3 Dot(const KRMat4 &m, const KRVector3 &v);
|
static KRVector3 Dot(const KRMat4 &m, const KRVector3 &v);
|
||||||
|
static float DotW(const KRMat4 &m, const KRVector3 &v);
|
||||||
|
static KRVector3 DotWDiv(const KRMat4 &m, const KRVector3 &v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KRMAT4_I
|
#endif // KRMAT4_I
|
||||||
@@ -390,65 +390,27 @@ void KRMaterial::bind(KRMaterial **prevBoundMaterial, char *szPrevShaderKey, KRC
|
|||||||
glUniform1f(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA], 1.0f - m_tr);
|
glUniform1f(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA], 1.0f - m_tr);
|
||||||
glUniform1f(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_REFLECTIVITY], m_reflectionFactor);
|
glUniform1f(pShader->m_uniforms[KRShader::KRENGINE_UNIFORM_MATERIAL_REFLECTIVITY], m_reflectionFactor);
|
||||||
|
|
||||||
bool bSameDiffuseMap = false;
|
if(bDiffuseMap) {
|
||||||
bool bSameSpecMap = false;
|
m_pContext->getTextureManager()->selectTexture(0, m_pDiffuseMap);
|
||||||
bool bSameNormalMap = false;
|
|
||||||
bool bSameReflectionMap = false;
|
|
||||||
if(*prevBoundMaterial) {
|
|
||||||
if((*prevBoundMaterial)->m_pDiffuseMap == m_pDiffuseMap) {
|
|
||||||
bSameDiffuseMap = true;
|
|
||||||
}
|
|
||||||
if((*prevBoundMaterial)->m_pSpecularMap == m_pSpecularMap) {
|
|
||||||
bSameSpecMap = true;
|
|
||||||
}
|
|
||||||
if((*prevBoundMaterial)->m_pReflectionMap == m_pReflectionMap) {
|
|
||||||
bSameReflectionMap = true;
|
|
||||||
}
|
|
||||||
if((*prevBoundMaterial)->m_pNormalMap == m_pNormalMap) {
|
|
||||||
bSameNormalMap = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bDiffuseMap && !bSameDiffuseMap) {
|
if(bSpecMap) {
|
||||||
int iTextureName = m_pDiffuseMap->getName();
|
m_pContext->getTextureManager()->selectTexture(1, m_pSpecularMap);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, iTextureName);
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bSpecMap && !bSameSpecMap) {
|
if(bNormalMap) {
|
||||||
int iTextureName = m_pSpecularMap->getName();
|
m_pContext->getTextureManager()->selectTexture(2, m_pNormalMap);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, iTextureName);
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bNormalMap && !bSameNormalMap) {
|
if(bReflectionMap && (renderPass == KRNode::RENDER_PASS_FORWARD_OPAQUE || renderPass == KRNode::RENDER_PASS_DEFERRED_OPAQUE)) {
|
||||||
int iTextureName = m_pNormalMap->getName();
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, iTextureName);
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bReflectionMap && !bSameReflectionMap && (renderPass == KRNode::RENDER_PASS_FORWARD_OPAQUE || renderPass == KRNode::RENDER_PASS_DEFERRED_OPAQUE)) {
|
|
||||||
// GL_TEXTURE7 is used for reading the depth buffer in gBuffer pass 2 and re-used for the reflection map in gBuffer Pass 3 and in forward rendering
|
// GL_TEXTURE7 is used for reading the depth buffer in gBuffer pass 2 and re-used for the reflection map in gBuffer Pass 3 and in forward rendering
|
||||||
int iTextureName = m_pReflectionMap->getName();
|
m_pContext->getTextureManager()->selectTexture(7, m_pReflectionMap);
|
||||||
glActiveTexture(GL_TEXTURE7);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, iTextureName);
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*prevBoundMaterial = this;
|
*prevBoundMaterial = this;
|
||||||
} // if(!bSameMaterial)
|
} // if(!bSameMaterial)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *KRMaterial::getName() {
|
char *KRMaterial::getName() {
|
||||||
|
|||||||
@@ -59,212 +59,187 @@ KRMaterial *KRMaterialManager::getMaterial(const char *szName) {
|
|||||||
return (*itr).second;
|
return (*itr).second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool KRMaterialManager::load(const char *szName, KRDataBlock *data) {
|
||||||
bool KRMaterialManager::loadFile(const char *szPath) {
|
|
||||||
bool bSuccess = false;
|
|
||||||
|
|
||||||
int fdFile = 0;
|
|
||||||
int fileSize = 0;
|
|
||||||
void *pFile = NULL;
|
|
||||||
KRMaterial *pMaterial = NULL;
|
KRMaterial *pMaterial = NULL;
|
||||||
char szSymbol[16][64];
|
char szSymbol[16][64];
|
||||||
|
|
||||||
struct stat statbuf;
|
|
||||||
fdFile = open(szPath, O_RDONLY);
|
|
||||||
if(fdFile >= 0) {
|
|
||||||
if(fstat(fdFile, &statbuf) >= 0) {
|
|
||||||
if ((pFile = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, fdFile, 0)) == (caddr_t) -1) {
|
|
||||||
} else {
|
|
||||||
fileSize = statbuf.st_size;
|
|
||||||
|
|
||||||
char *pScan = (char *)pFile;
|
char *pScan = (char *)data->getStart();
|
||||||
char *pEnd = (char *)pFile + fileSize;
|
char *pEnd = (char *)data->getEnd();
|
||||||
while(pScan < pEnd) {
|
while(pScan < pEnd) {
|
||||||
|
|
||||||
// Scan through whitespace
|
// Scan through whitespace
|
||||||
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t' || *pScan == '\r' || *pScan == '\n')) {
|
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t' || *pScan == '\r' || *pScan == '\n')) {
|
||||||
pScan++;
|
pScan++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*pScan == '#') {
|
if(*pScan == '#') {
|
||||||
// Line is a comment line
|
// Line is a comment line
|
||||||
|
|
||||||
// Scan to the end of the line
|
// Scan to the end of the line
|
||||||
while(pScan < pEnd && *pScan != '\r' && *pScan != '\n') {
|
while(pScan < pEnd && *pScan != '\r' && *pScan != '\n') {
|
||||||
pScan++;
|
pScan++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int cSymbols = 0;
|
int cSymbols = 0;
|
||||||
while(pScan < pEnd && *pScan != '\n' && *pScan != '\r') {
|
while(pScan < pEnd && *pScan != '\n' && *pScan != '\r') {
|
||||||
|
|
||||||
char *pDest = szSymbol[cSymbols++];
|
char *pDest = szSymbol[cSymbols++];
|
||||||
while(pScan < pEnd && *pScan != ' ' && *pScan != '\n' && *pScan != '\r') {
|
while(pScan < pEnd && *pScan != ' ' && *pScan != '\n' && *pScan != '\r') {
|
||||||
*pDest++ = *pScan++;
|
*pDest++ = *pScan++;
|
||||||
}
|
}
|
||||||
*pDest = '\0';
|
*pDest = '\0';
|
||||||
|
|
||||||
// Scan through whitespace, but don't advance to next line
|
// Scan through whitespace, but don't advance to next line
|
||||||
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t')) {
|
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t')) {
|
||||||
pScan++;
|
pScan++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(cSymbols > 0) {
|
||||||
|
|
||||||
|
if(strcmp(szSymbol[0], "newmtl") == 0 && cSymbols >= 2) {
|
||||||
|
|
||||||
|
pMaterial = new KRMaterial(*m_pContext, szSymbol[1]);
|
||||||
|
m_materials[szSymbol[1]] = pMaterial;
|
||||||
|
}
|
||||||
|
if(pMaterial != NULL) {
|
||||||
|
if(strcmp(szSymbol[0], "alpha_mode") == 0) {
|
||||||
|
if(cSymbols == 2) {
|
||||||
|
if(strcmp(szSymbol[1], "test") == 0) {
|
||||||
|
pMaterial->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_TEST);
|
||||||
|
} else if(strcmp(szSymbol[1], "blendoneside") == 0) {
|
||||||
|
pMaterial->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE);
|
||||||
|
} else if(strcmp(szSymbol[1], "blendtwoside") == 0) {
|
||||||
|
pMaterial->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE);
|
||||||
|
} else {
|
||||||
|
pMaterial->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_OPAQUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(strcmp(szSymbol[0], "Ka") == 0) {
|
||||||
if(cSymbols > 0) {
|
char *pScan2 = szSymbol[1];
|
||||||
|
double r = strtof(pScan2, &pScan2);
|
||||||
if(strcmp(szSymbol[0], "newmtl") == 0 && cSymbols >= 2) {
|
if(cSymbols == 2) {
|
||||||
|
pMaterial->setAmbient(KRVector3(r, r, r));
|
||||||
pMaterial = new KRMaterial(*m_pContext, szSymbol[1]);
|
} else if(cSymbols == 4) {
|
||||||
m_materials[szSymbol[1]] = pMaterial;
|
pScan2 = szSymbol[2];
|
||||||
|
double g = strtof(pScan2, &pScan2);
|
||||||
|
pScan2 = szSymbol[3];
|
||||||
|
double b = strtof(pScan2, &pScan2);
|
||||||
|
pMaterial->setAmbient(KRVector3(r, g, b));
|
||||||
|
}
|
||||||
|
} else if(strcmp(szSymbol[0], "Kd") == 0) {
|
||||||
|
char *pScan2 = szSymbol[1];
|
||||||
|
double r = strtof(pScan2, &pScan2);
|
||||||
|
if(cSymbols == 2) {
|
||||||
|
pMaterial->setDiffuse(KRVector3(r, r, r));
|
||||||
|
} else if(cSymbols == 4) {
|
||||||
|
pScan2 = szSymbol[2];
|
||||||
|
double g = strtof(pScan2, &pScan2);
|
||||||
|
pScan2 = szSymbol[3];
|
||||||
|
double b = strtof(pScan2, &pScan2);
|
||||||
|
pMaterial->setDiffuse(KRVector3(r, g, b));
|
||||||
|
}
|
||||||
|
} else if(strcmp(szSymbol[0], "Ks") == 0) {
|
||||||
|
char *pScan2 = szSymbol[1];
|
||||||
|
double r = strtof(pScan2, &pScan2);
|
||||||
|
if(cSymbols == 2) {
|
||||||
|
pMaterial->setSpecular(KRVector3(r, r, r));
|
||||||
|
} else if(cSymbols == 4) {
|
||||||
|
pScan2 = szSymbol[2];
|
||||||
|
double g = strtof(pScan2, &pScan2);
|
||||||
|
pScan2 = szSymbol[3];
|
||||||
|
double b = strtof(pScan2, &pScan2);
|
||||||
|
pMaterial->setSpecular(KRVector3(r, g, b));
|
||||||
|
}
|
||||||
|
} else if(strcmp(szSymbol[0], "Kr") == 0) {
|
||||||
|
char *pScan2 = szSymbol[1];
|
||||||
|
double r = strtof(pScan2, &pScan2);
|
||||||
|
if(cSymbols == 2) {
|
||||||
|
pMaterial->setReflection(KRVector3(r, r, r));
|
||||||
|
} else if(cSymbols == 4) {
|
||||||
|
pScan2 = szSymbol[2];
|
||||||
|
double g = strtof(pScan2, &pScan2);
|
||||||
|
pScan2 = szSymbol[3];
|
||||||
|
double b = strtof(pScan2, &pScan2);
|
||||||
|
pMaterial->setReflection(KRVector3(r, g, b));
|
||||||
|
}
|
||||||
|
} else if(strcmp(szSymbol[0], "Tr") == 0) {
|
||||||
|
char *pScan2 = szSymbol[1];
|
||||||
|
double a = strtof(pScan2, &pScan2);
|
||||||
|
pMaterial->setTransparency(a);
|
||||||
|
} else if(strcmp(szSymbol[0], "Ns") == 0) {
|
||||||
|
char *pScan2 = szSymbol[1];
|
||||||
|
double a = strtof(pScan2, &pScan2);
|
||||||
|
pMaterial->setShininess(a);
|
||||||
|
} else if(strncmp(szSymbol[0], "map", 3) == 0) {
|
||||||
|
// Truncate file extension
|
||||||
|
char *pScan2 = szSymbol[1];
|
||||||
|
char *pLastPeriod = NULL;
|
||||||
|
while(*pScan2 != '\0') {
|
||||||
|
if(*pScan2 == '.') {
|
||||||
|
pLastPeriod = pScan2;
|
||||||
}
|
}
|
||||||
if(pMaterial != NULL) {
|
pScan2++;
|
||||||
if(strcmp(szSymbol[0], "alpha_mode") == 0) {
|
}
|
||||||
if(cSymbols == 2) {
|
if(pLastPeriod) {
|
||||||
if(strcmp(szSymbol[1], "test") == 0) {
|
*pLastPeriod = '\0';
|
||||||
pMaterial->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_TEST);
|
}
|
||||||
} else if(strcmp(szSymbol[1], "blendoneside") == 0) {
|
|
||||||
pMaterial->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE);
|
|
||||||
} else if(strcmp(szSymbol[1], "blendtwoside") == 0) {
|
|
||||||
pMaterial->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_BLENDONESIDE);
|
|
||||||
} else {
|
|
||||||
pMaterial->setAlphaMode(KRMaterial::KRMATERIAL_ALPHA_MODE_OPAQUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if(strcmp(szSymbol[0], "Ka") == 0) {
|
|
||||||
char *pScan2 = szSymbol[1];
|
|
||||||
double r = strtof(pScan2, &pScan2);
|
|
||||||
if(cSymbols == 2) {
|
|
||||||
pMaterial->setAmbient(KRVector3(r, r, r));
|
|
||||||
} else if(cSymbols == 4) {
|
|
||||||
pScan2 = szSymbol[2];
|
|
||||||
double g = strtof(pScan2, &pScan2);
|
|
||||||
pScan2 = szSymbol[3];
|
|
||||||
double b = strtof(pScan2, &pScan2);
|
|
||||||
pMaterial->setAmbient(KRVector3(r, g, b));
|
|
||||||
}
|
|
||||||
} else if(strcmp(szSymbol[0], "Kd") == 0) {
|
|
||||||
char *pScan2 = szSymbol[1];
|
|
||||||
double r = strtof(pScan2, &pScan2);
|
|
||||||
if(cSymbols == 2) {
|
|
||||||
pMaterial->setDiffuse(KRVector3(r, r, r));
|
|
||||||
} else if(cSymbols == 4) {
|
|
||||||
pScan2 = szSymbol[2];
|
|
||||||
double g = strtof(pScan2, &pScan2);
|
|
||||||
pScan2 = szSymbol[3];
|
|
||||||
double b = strtof(pScan2, &pScan2);
|
|
||||||
pMaterial->setDiffuse(KRVector3(r, g, b));
|
|
||||||
}
|
|
||||||
} else if(strcmp(szSymbol[0], "Ks") == 0) {
|
|
||||||
char *pScan2 = szSymbol[1];
|
|
||||||
double r = strtof(pScan2, &pScan2);
|
|
||||||
if(cSymbols == 2) {
|
|
||||||
pMaterial->setSpecular(KRVector3(r, r, r));
|
|
||||||
} else if(cSymbols == 4) {
|
|
||||||
pScan2 = szSymbol[2];
|
|
||||||
double g = strtof(pScan2, &pScan2);
|
|
||||||
pScan2 = szSymbol[3];
|
|
||||||
double b = strtof(pScan2, &pScan2);
|
|
||||||
pMaterial->setSpecular(KRVector3(r, g, b));
|
|
||||||
}
|
|
||||||
} else if(strcmp(szSymbol[0], "Kr") == 0) {
|
|
||||||
char *pScan2 = szSymbol[1];
|
|
||||||
double r = strtof(pScan2, &pScan2);
|
|
||||||
if(cSymbols == 2) {
|
|
||||||
pMaterial->setReflection(KRVector3(r, r, r));
|
|
||||||
} else if(cSymbols == 4) {
|
|
||||||
pScan2 = szSymbol[2];
|
|
||||||
double g = strtof(pScan2, &pScan2);
|
|
||||||
pScan2 = szSymbol[3];
|
|
||||||
double b = strtof(pScan2, &pScan2);
|
|
||||||
pMaterial->setReflection(KRVector3(r, g, b));
|
|
||||||
}
|
|
||||||
} else if(strcmp(szSymbol[0], "Tr") == 0) {
|
|
||||||
char *pScan2 = szSymbol[1];
|
|
||||||
double a = strtof(pScan2, &pScan2);
|
|
||||||
pMaterial->setTransparency(a);
|
|
||||||
} else if(strcmp(szSymbol[0], "Ns") == 0) {
|
|
||||||
char *pScan2 = szSymbol[1];
|
|
||||||
double a = strtof(pScan2, &pScan2);
|
|
||||||
pMaterial->setShininess(a);
|
|
||||||
} else if(strncmp(szSymbol[0], "map", 3) == 0) {
|
|
||||||
// Truncate file extension
|
|
||||||
char *pScan2 = szSymbol[1];
|
|
||||||
char *pLastPeriod = NULL;
|
|
||||||
while(*pScan2 != '\0') {
|
|
||||||
if(*pScan2 == '.') {
|
|
||||||
pLastPeriod = pScan2;
|
|
||||||
}
|
|
||||||
pScan2++;
|
|
||||||
}
|
|
||||||
if(pLastPeriod) {
|
|
||||||
*pLastPeriod = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
KRVector2 texture_scale = KRVector2(1.0f, 1.0f);
|
KRVector2 texture_scale = KRVector2(1.0f, 1.0f);
|
||||||
KRVector2 texture_offset = KRVector2(0.0f, 0.0f);
|
KRVector2 texture_offset = KRVector2(0.0f, 0.0f);
|
||||||
|
|
||||||
int iScanSymbol = 2;
|
|
||||||
int iScaleParam = -1;
|
|
||||||
int iOffsetParam = -1;
|
|
||||||
while(iScanSymbol < cSymbols) {
|
|
||||||
if(strcmp(szSymbol[iScanSymbol], "-s") == 0) {
|
|
||||||
// Scale
|
|
||||||
iScaleParam = 0;
|
|
||||||
iOffsetParam = -1;
|
|
||||||
} else if(strcmp(szSymbol[iScanSymbol], "-o") == 0) {
|
|
||||||
// Offset
|
|
||||||
iOffsetParam = 0;
|
|
||||||
iScaleParam = -1;
|
|
||||||
} else {
|
|
||||||
char *pScan3 = szSymbol[iScanSymbol];
|
|
||||||
double v = strtof(pScan3, &pScan3);
|
|
||||||
if(iScaleParam == 0) {
|
|
||||||
texture_scale.x = v;
|
|
||||||
iScaleParam++;
|
|
||||||
} else if(iScaleParam == 1) {
|
|
||||||
texture_scale.y = v;
|
|
||||||
iScaleParam++;
|
|
||||||
} else if(iOffsetParam == 0) {
|
|
||||||
texture_offset.x = v;
|
|
||||||
iOffsetParam++;
|
|
||||||
} else if(iOffsetParam == 1) {
|
|
||||||
texture_offset.y = v;
|
|
||||||
iOffsetParam++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iScanSymbol++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strcmp(szSymbol[0], "map_Ka") == 0) {
|
|
||||||
pMaterial->setAmbientMap(szSymbol[1], texture_scale, texture_offset);
|
|
||||||
} else if(strcmp(szSymbol[0], "map_Kd") == 0) {
|
|
||||||
pMaterial->setDiffuseMap(szSymbol[1], texture_scale, texture_offset);
|
|
||||||
} else if(strcmp(szSymbol[0], "map_Ks") == 0) {
|
|
||||||
pMaterial->setSpecularMap(szSymbol[1], texture_scale, texture_offset);
|
|
||||||
} else if(strcmp(szSymbol[0], "map_Normal") == 0) {
|
|
||||||
pMaterial->setNormalMap(szSymbol[1], texture_scale, texture_offset);
|
|
||||||
} else if(strcmp(szSymbol[0], "map_Reflection") == 0) {
|
|
||||||
pMaterial->setReflectionMap(szSymbol[1], texture_scale, texture_offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
int iScanSymbol = 2;
|
||||||
|
int iScaleParam = -1;
|
||||||
|
int iOffsetParam = -1;
|
||||||
|
while(iScanSymbol < cSymbols) {
|
||||||
|
if(strcmp(szSymbol[iScanSymbol], "-s") == 0) {
|
||||||
|
// Scale
|
||||||
|
iScaleParam = 0;
|
||||||
|
iOffsetParam = -1;
|
||||||
|
} else if(strcmp(szSymbol[iScanSymbol], "-o") == 0) {
|
||||||
|
// Offset
|
||||||
|
iOffsetParam = 0;
|
||||||
|
iScaleParam = -1;
|
||||||
|
} else {
|
||||||
|
char *pScan3 = szSymbol[iScanSymbol];
|
||||||
|
double v = strtof(pScan3, &pScan3);
|
||||||
|
if(iScaleParam == 0) {
|
||||||
|
texture_scale.x = v;
|
||||||
|
iScaleParam++;
|
||||||
|
} else if(iScaleParam == 1) {
|
||||||
|
texture_scale.y = v;
|
||||||
|
iScaleParam++;
|
||||||
|
} else if(iOffsetParam == 0) {
|
||||||
|
texture_offset.x = v;
|
||||||
|
iOffsetParam++;
|
||||||
|
} else if(iOffsetParam == 1) {
|
||||||
|
texture_offset.y = v;
|
||||||
|
iOffsetParam++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
iScanSymbol++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strcmp(szSymbol[0], "map_Ka") == 0) {
|
||||||
|
pMaterial->setAmbientMap(szSymbol[1], texture_scale, texture_offset);
|
||||||
|
} else if(strcmp(szSymbol[0], "map_Kd") == 0) {
|
||||||
|
pMaterial->setDiffuseMap(szSymbol[1], texture_scale, texture_offset);
|
||||||
|
} else if(strcmp(szSymbol[0], "map_Ks") == 0) {
|
||||||
|
pMaterial->setSpecularMap(szSymbol[1], texture_scale, texture_offset);
|
||||||
|
} else if(strcmp(szSymbol[0], "map_Normal") == 0) {
|
||||||
|
pMaterial->setNormalMap(szSymbol[1], texture_scale, texture_offset);
|
||||||
|
} else if(strcmp(szSymbol[0], "map_Reflection") == 0) {
|
||||||
|
pMaterial->setReflectionMap(szSymbol[1], texture_scale, texture_offset);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bSuccess = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pFile != NULL) {
|
delete data;
|
||||||
munmap(pFile, fileSize);
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
if(fdFile != 0) {
|
|
||||||
close(fdFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
return bSuccess;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
#define KRMATERIALMANAGER_H
|
#define KRMATERIALMANAGER_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#import "KREngine-common.h"
|
#import "KREngine-common.h"
|
||||||
|
|
||||||
#include "KRMaterial.h"
|
#include "KRMaterial.h"
|
||||||
@@ -50,13 +52,16 @@ public:
|
|||||||
KRMaterialManager(KRContext &context, KRTextureManager *pTextureManager, KRShaderManager *pShaderManager);
|
KRMaterialManager(KRContext &context, KRTextureManager *pTextureManager, KRShaderManager *pShaderManager);
|
||||||
virtual ~KRMaterialManager();
|
virtual ~KRMaterialManager();
|
||||||
|
|
||||||
bool loadFile(const char *szPath);
|
bool load(const char *szName, KRDataBlock *data);
|
||||||
KRMaterial *getMaterial(const char *szName);
|
KRMaterial *getMaterial(const char *szName);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
map<std::string, KRMaterial *> m_materials;
|
map<std::string, KRMaterial *> m_materials;
|
||||||
KRTextureManager *m_pTextureManager;
|
KRTextureManager *m_pTextureManager;
|
||||||
KRShaderManager *m_pShaderManager;
|
KRShaderManager *m_pShaderManager;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "KRMesh.h"
|
#include "KRMesh.h"
|
||||||
#import "KRShader.h"
|
#import "KRShader.h"
|
||||||
|
#import "KRContext.h"
|
||||||
#import <stdint.h>
|
#import <stdint.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -41,15 +42,12 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
KRMesh::KRMesh(KRContext &context, std::string name) : KRResource(context, name) {
|
KRMesh::KRMesh(KRContext &context, std::string name) : KRResource(context, name) {
|
||||||
m_fdPackFile = 0;
|
m_pData = new KRDataBlock();
|
||||||
m_pPackData = NULL;
|
|
||||||
m_iPackFileSize = 0;
|
|
||||||
m_cBuffers = 0;
|
|
||||||
m_pBuffers = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMesh::~KRMesh() {
|
KRMesh::~KRMesh() {
|
||||||
clearData();
|
clearData();
|
||||||
|
if(m_pData) delete m_pData;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string KRMesh::getExtension() {
|
std::string KRMesh::getExtension() {
|
||||||
@@ -57,96 +55,25 @@ std::string KRMesh::getExtension() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::clearData() {
|
void KRMesh::clearData() {
|
||||||
clearBuffers();
|
m_pData->unload();
|
||||||
if(m_fdPackFile) {
|
|
||||||
if(m_pPackData != NULL) {
|
|
||||||
munmap(m_pPackData, m_iPackFileSize);
|
|
||||||
m_pPackData = NULL;
|
|
||||||
}
|
|
||||||
close(m_fdPackFile);
|
|
||||||
m_fdPackFile = 0;
|
|
||||||
} else {
|
|
||||||
// If we didn't load a packed file, then the data was calculated at run time and malloc'ed
|
|
||||||
if(m_pPackData != NULL) {
|
|
||||||
free(m_pPackData);
|
|
||||||
m_pPackData = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::clearBuffers() {
|
void KRMesh::clearBuffers() {
|
||||||
m_submeshes.clear();
|
m_submeshes.clear();
|
||||||
if(m_pBuffers != NULL) {
|
|
||||||
glDeleteBuffers(m_cBuffers, m_pBuffers);
|
|
||||||
delete m_pBuffers;
|
|
||||||
m_pBuffers = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::loadPack(std::string path) {
|
void KRMesh::loadPack(KRDataBlock *data) {
|
||||||
clearData();
|
clearData();
|
||||||
struct stat statbuf;
|
delete m_pData;
|
||||||
m_fdPackFile = open(path.c_str(), O_RDONLY);
|
m_pData = data;
|
||||||
if(m_fdPackFile >= 0) {
|
pack_header *pHeader = (pack_header *)m_pData->getStart();
|
||||||
if(fstat(m_fdPackFile, &statbuf) >= 0) {
|
m_minPoint = KRVector3(pHeader->minx, pHeader->miny, pHeader->minz);
|
||||||
if ((m_pPackData = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, m_fdPackFile, 0)) == (caddr_t) -1) {
|
m_maxPoint = KRVector3(pHeader->maxx, pHeader->maxy, pHeader->maxz);
|
||||||
} else {
|
|
||||||
m_iPackFileSize = statbuf.st_size;
|
|
||||||
|
|
||||||
pack_header *pHeader = (pack_header *)m_pPackData;
|
|
||||||
m_minPoint = KRVector3(pHeader->minx, pHeader->miny, pHeader->minz);
|
|
||||||
m_maxPoint = KRVector3(pHeader->maxx, pHeader->maxy, pHeader->maxz);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRMesh::save(const std::string& path) {
|
bool KRMesh::save(const std::string& path) {
|
||||||
clearBuffers();
|
clearBuffers();
|
||||||
|
return m_pData->save(path);
|
||||||
int fdNewFile = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
|
|
||||||
if(fdNewFile == -1) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
// Seek to end of file and write a byte to enlarge it
|
|
||||||
lseek(fdNewFile, m_iPackFileSize-1, SEEK_SET);
|
|
||||||
write(fdNewFile, "", 1);
|
|
||||||
|
|
||||||
// Now map it...
|
|
||||||
void *pNewData = mmap(0, m_iPackFileSize, PROT_READ | PROT_WRITE, MAP_SHARED, fdNewFile, 0);
|
|
||||||
if(pNewData == (caddr_t) -1) {
|
|
||||||
close(fdNewFile);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
memcpy(pNewData, m_pPackData, m_iPackFileSize);
|
|
||||||
mprotect(pNewData, m_iPackFileSize, PROT_READ);
|
|
||||||
if(m_fdPackFile) {
|
|
||||||
if(m_pPackData != NULL) {
|
|
||||||
void *malloc_data = malloc(m_iPackFileSize);
|
|
||||||
memcpy(malloc_data, m_pPackData, m_iPackFileSize);
|
|
||||||
munmap(m_pPackData, m_iPackFileSize);
|
|
||||||
}
|
|
||||||
close(m_fdPackFile);
|
|
||||||
}
|
|
||||||
m_fdPackFile = fdNewFile;
|
|
||||||
m_pPackData = pNewData;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KRMesh::unmap() {
|
|
||||||
clearBuffers();
|
|
||||||
if(m_fdPackFile) {
|
|
||||||
if(m_pPackData != NULL) {
|
|
||||||
void *malloc_data = malloc(m_iPackFileSize);
|
|
||||||
memcpy(malloc_data, m_pPackData, m_iPackFileSize);
|
|
||||||
munmap(m_pPackData, m_iPackFileSize);
|
|
||||||
m_pPackData = malloc_data;
|
|
||||||
}
|
|
||||||
close(m_fdPackFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLfloat KRMesh::getMaxDimension() {
|
GLfloat KRMesh::getMaxDimension() {
|
||||||
@@ -159,7 +86,7 @@ GLfloat KRMesh::getMaxDimension() {
|
|||||||
|
|
||||||
vector<KRMesh::Submesh *> KRMesh::getSubmeshes() {
|
vector<KRMesh::Submesh *> KRMesh::getSubmeshes() {
|
||||||
if(m_submeshes.size() == 0) {
|
if(m_submeshes.size() == 0) {
|
||||||
pack_header *pHeader = (pack_header *)m_pPackData;
|
pack_header *pHeader = (pack_header *)m_pData->getStart();
|
||||||
pack_material *pPackMaterials = (pack_material *)(pHeader+1);
|
pack_material *pPackMaterials = (pack_material *)(pHeader+1);
|
||||||
m_submeshes.clear();
|
m_submeshes.clear();
|
||||||
for(int iMaterial=0; iMaterial < pHeader->submesh_count; iMaterial++) {
|
for(int iMaterial=0; iMaterial < pHeader->submesh_count; iMaterial++) {
|
||||||
@@ -177,20 +104,23 @@ vector<KRMesh::Submesh *> KRMesh::getSubmeshes() {
|
|||||||
|
|
||||||
void KRMesh::renderSubmesh(int iSubmesh, int *iPrevBuffer) {
|
void KRMesh::renderSubmesh(int iSubmesh, int *iPrevBuffer) {
|
||||||
VertexData *pVertexData = getVertexData();
|
VertexData *pVertexData = getVertexData();
|
||||||
|
//
|
||||||
|
// if(m_cBuffers == 0) {
|
||||||
|
// pack_header *pHeader = (pack_header *)m_pData->getStart();
|
||||||
|
// m_cBuffers = (pHeader->vertex_count + MAX_VBO_SIZE - 1) / MAX_VBO_SIZE;
|
||||||
|
// m_pBuffers = new GLuint[m_cBuffers];
|
||||||
|
// glGenBuffers(m_cBuffers, m_pBuffers);
|
||||||
|
// for(GLsizei iBuffer=0; iBuffer < m_cBuffers; iBuffer++) {
|
||||||
|
// GLsizei cVertexes = iBuffer < m_cBuffers - 1 ? MAX_VBO_SIZE : pHeader->vertex_count % MAX_VBO_SIZE;
|
||||||
|
// glBindBuffer(GL_ARRAY_BUFFER, m_pBuffers[iBuffer]);
|
||||||
|
// glBufferData(GL_ARRAY_BUFFER, sizeof(VertexData) * cVertexes, pVertexData + iBuffer * MAX_VBO_SIZE, GL_STATIC_DRAW);
|
||||||
|
// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if(m_cBuffers == 0) {
|
pack_header *pHeader = (pack_header *)m_pData->getStart();
|
||||||
pack_header *pHeader = (pack_header *)m_pPackData;
|
int cBuffers = (pHeader->vertex_count + MAX_VBO_SIZE - 1) / MAX_VBO_SIZE;
|
||||||
m_cBuffers = (pHeader->vertex_count + MAX_VBO_SIZE - 1) / MAX_VBO_SIZE;
|
|
||||||
m_pBuffers = new GLuint[m_cBuffers];
|
|
||||||
glGenBuffers(m_cBuffers, m_pBuffers);
|
|
||||||
for(GLsizei iBuffer=0; iBuffer < m_cBuffers; iBuffer++) {
|
|
||||||
GLsizei cVertexes = iBuffer < m_cBuffers - 1 ? MAX_VBO_SIZE : pHeader->vertex_count % MAX_VBO_SIZE;
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, m_pBuffers[iBuffer]);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(VertexData) * cVertexes, pVertexData + iBuffer * MAX_VBO_SIZE, GL_STATIC_DRAW);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<KRMesh::Submesh *> submeshes = getSubmeshes();
|
vector<KRMesh::Submesh *> submeshes = getSubmeshes();
|
||||||
Submesh *pSubmesh = submeshes[iSubmesh];
|
Submesh *pSubmesh = submeshes[iSubmesh];
|
||||||
@@ -200,8 +130,9 @@ void KRMesh::renderSubmesh(int iSubmesh, int *iPrevBuffer) {
|
|||||||
iVertex = iVertex % MAX_VBO_SIZE;
|
iVertex = iVertex % MAX_VBO_SIZE;
|
||||||
int cVertexes = pSubmesh->vertex_count;
|
int cVertexes = pSubmesh->vertex_count;
|
||||||
while(cVertexes > 0) {
|
while(cVertexes > 0) {
|
||||||
if(*iPrevBuffer != iBuffer) {
|
//if(*iPrevBuffer != iBuffer) {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, m_pBuffers[iBuffer]);
|
GLsizei cBufferVertexes = iBuffer < cBuffers - 1 ? MAX_VBO_SIZE : pHeader->vertex_count % MAX_VBO_SIZE;
|
||||||
|
m_pContext->getModelManager()->bindVBO(pVertexData + iBuffer * MAX_VBO_SIZE, sizeof(VertexData) * cBufferVertexes);
|
||||||
|
|
||||||
if(*iPrevBuffer == -1) {
|
if(*iPrevBuffer == -1) {
|
||||||
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_VERTEX);
|
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_VERTEX);
|
||||||
@@ -211,6 +142,7 @@ void KRMesh::renderSubmesh(int iSubmesh, int *iPrevBuffer) {
|
|||||||
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_TEXUVB);
|
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_TEXUVB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int data_size = sizeof(VertexData);
|
int data_size = sizeof(VertexData);
|
||||||
|
|
||||||
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_VERTEX, 3, GL_FLOAT, 0, data_size, BUFFER_OFFSET(0));
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_VERTEX, 3, GL_FLOAT, 0, data_size, BUFFER_OFFSET(0));
|
||||||
@@ -218,9 +150,8 @@ void KRMesh::renderSubmesh(int iSubmesh, int *iPrevBuffer) {
|
|||||||
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TANGENT, 3, GL_FLOAT, 0, data_size, BUFFER_OFFSET(sizeof(KRVector3D) * 2));
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TANGENT, 3, GL_FLOAT, 0, data_size, BUFFER_OFFSET(sizeof(KRVector3D) * 2));
|
||||||
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TEXUVA, 2, GL_FLOAT, 0, data_size, BUFFER_OFFSET(sizeof(KRVector3D) * 3));
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TEXUVA, 2, GL_FLOAT, 0, data_size, BUFFER_OFFSET(sizeof(KRVector3D) * 3));
|
||||||
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TEXUVB, 2, GL_FLOAT, 0, data_size, BUFFER_OFFSET(sizeof(KRVector3D) * 3 + sizeof(TexCoord)));
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_TEXUVB, 2, GL_FLOAT, 0, data_size, BUFFER_OFFSET(sizeof(KRVector3D) * 3 + sizeof(TexCoord)));
|
||||||
|
//}
|
||||||
*iPrevBuffer = iBuffer;
|
*iPrevBuffer = iBuffer;
|
||||||
}
|
|
||||||
|
|
||||||
if(iVertex + cVertexes >= MAX_VBO_SIZE) {
|
if(iVertex + cVertexes >= MAX_VBO_SIZE) {
|
||||||
glDrawArrays(GL_TRIANGLES, iVertex, (MAX_VBO_SIZE - iVertex));
|
glDrawArrays(GL_TRIANGLES, iVertex, (MAX_VBO_SIZE - iVertex));
|
||||||
@@ -235,7 +166,7 @@ void KRMesh::renderSubmesh(int iSubmesh, int *iPrevBuffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KRMesh::VertexData *KRMesh::getVertexData() {
|
KRMesh::VertexData *KRMesh::getVertexData() {
|
||||||
pack_header *pHeader = (pack_header *)m_pPackData;
|
pack_header *pHeader = (pack_header *)m_pData->getStart();
|
||||||
pack_material *pPackMaterials = (pack_material *)(pHeader+1);
|
pack_material *pPackMaterials = (pack_material *)(pHeader+1);
|
||||||
return (VertexData *)(pPackMaterials + pHeader->submesh_count);
|
return (VertexData *)(pPackMaterials + pHeader->submesh_count);
|
||||||
}
|
}
|
||||||
@@ -246,10 +177,10 @@ void KRMesh::LoadData(std::vector<KRVector3> vertices, std::vector<KRVector2> uv
|
|||||||
|
|
||||||
int submesh_count = submesh_lengths.size();
|
int submesh_count = submesh_lengths.size();
|
||||||
int vertex_count = vertices.size();
|
int vertex_count = vertices.size();
|
||||||
m_iPackFileSize = sizeof(pack_header) + sizeof(pack_material) * submesh_count + sizeof(VertexData) * vertex_count;
|
size_t new_file_size = sizeof(pack_header) + sizeof(pack_material) * submesh_count + sizeof(VertexData) * vertex_count;
|
||||||
m_pPackData = malloc(m_iPackFileSize);
|
m_pData->expand(new_file_size);
|
||||||
|
|
||||||
pack_header *pHeader = (pack_header *)m_pPackData;
|
pack_header *pHeader = (pack_header *)m_pData->getStart();
|
||||||
memset(pHeader, 0, sizeof(pack_header));
|
memset(pHeader, 0, sizeof(pack_header));
|
||||||
|
|
||||||
pHeader->submesh_count = submesh_lengths.size();
|
pHeader->submesh_count = submesh_lengths.size();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#import "KRVector2.h"
|
#import "KRVector2.h"
|
||||||
#import "KRVector3.h"
|
#import "KRVector3.h"
|
||||||
#import "KRResource.h"
|
#import "KRResource.h"
|
||||||
|
#import "KRDataBlock.h"
|
||||||
|
|
||||||
#import "KREngine-common.h"
|
#import "KREngine-common.h"
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ public:
|
|||||||
virtual bool save(const std::string& path);
|
virtual bool save(const std::string& path);
|
||||||
|
|
||||||
void LoadData(std::vector<KRVector3> vertices, std::vector<KRVector2> uva, std::vector<KRVector2> uvb, std::vector<KRVector3> normals, std::vector<KRVector3> tangents, std::vector<int> submesh_starts, std::vector<int> submesh_lengths, std::vector<std::string> material_names);
|
void LoadData(std::vector<KRVector3> vertices, std::vector<KRVector2> uva, std::vector<KRVector2> uvb, std::vector<KRVector3> normals, std::vector<KRVector3> tangents, std::vector<int> submesh_starts, std::vector<int> submesh_lengths, std::vector<std::string> material_names);
|
||||||
void loadPack(std::string path);
|
void loadPack(KRDataBlock *data);
|
||||||
|
|
||||||
|
|
||||||
void renderSubmesh(int iSubmesh, int *iPrevBuffer);
|
void renderSubmesh(int iSubmesh, int *iPrevBuffer);
|
||||||
@@ -113,9 +114,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
KRVector3 m_minPoint, m_maxPoint;
|
KRVector3 m_minPoint, m_maxPoint;
|
||||||
|
|
||||||
int m_fdPackFile;
|
KRDataBlock *m_pData;
|
||||||
void *m_pPackData;
|
|
||||||
int m_iPackFileSize;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char szTag[16];
|
char szTag[16];
|
||||||
@@ -124,15 +123,8 @@ protected:
|
|||||||
int32_t submesh_count;
|
int32_t submesh_count;
|
||||||
} pack_header;
|
} pack_header;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLsizei m_cBuffers;
|
|
||||||
GLuint *m_pBuffers;
|
|
||||||
|
|
||||||
vector<Submesh *> m_submeshes;
|
vector<Submesh *> m_submeshes;
|
||||||
|
|
||||||
void unmap();
|
|
||||||
void clearData();
|
void clearData();
|
||||||
void clearBuffers();
|
void clearBuffers();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,17 +46,13 @@
|
|||||||
#import "KRShaderManager.h"
|
#import "KRShaderManager.h"
|
||||||
#import "KRContext.h"
|
#import "KRContext.h"
|
||||||
|
|
||||||
KRModel::KRModel(KRContext &context, std::string name, std::string path) : KRContextObject(context) {
|
KRModel::KRModel(KRContext &context, std::string name, KRDataBlock *data) : KRContextObject(context) {
|
||||||
m_name = name;
|
m_name = name;
|
||||||
loadPack(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void KRModel::loadPack(std::string path) {
|
|
||||||
m_hasTransparency = false;
|
m_hasTransparency = false;
|
||||||
m_materials.clear();
|
m_materials.clear();
|
||||||
m_uniqueMaterials.clear();
|
m_uniqueMaterials.clear();
|
||||||
m_pMesh = new KRMesh(*m_pContext, KRResource::GetFileBase(path));
|
m_pMesh = new KRMesh(*m_pContext, name);
|
||||||
m_pMesh->loadPack(path);
|
m_pMesh->loadPack(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string KRModel::getName() {
|
std::string KRModel::getName() {
|
||||||
@@ -70,6 +66,8 @@ KRModel::~KRModel() {
|
|||||||
|
|
||||||
void KRModel::render(KRCamera *pCamera, KRContext *pContext, KRMat4 &matModelToView, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRTexture *pLightMap, KRNode::RenderPass renderPass) {
|
void KRModel::render(KRCamera *pCamera, KRContext *pContext, KRMat4 &matModelToView, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRTexture *pLightMap, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
|
// fprintf(stderr, "Rendering model: %s\n", m_name.c_str());
|
||||||
|
|
||||||
if(renderPass != KRNode::RENDER_PASS_FLARES) {
|
if(renderPass != KRNode::RENDER_PASS_FLARES) {
|
||||||
|
|
||||||
if(m_materials.size() == 0) {
|
if(m_materials.size() == 0) {
|
||||||
@@ -78,7 +76,9 @@ void KRModel::render(KRCamera *pCamera, KRContext *pContext, KRMat4 &matModelToV
|
|||||||
for(std::vector<KRMesh::Submesh *>::iterator itr = submeshes.begin(); itr != submeshes.end(); itr++) {
|
for(std::vector<KRMesh::Submesh *>::iterator itr = submeshes.begin(); itr != submeshes.end(); itr++) {
|
||||||
KRMaterial *pMaterial = pContext->getMaterialManager()->getMaterial((*itr)->szMaterialName);
|
KRMaterial *pMaterial = pContext->getMaterialManager()->getMaterial((*itr)->szMaterialName);
|
||||||
m_materials.push_back(pMaterial);
|
m_materials.push_back(pMaterial);
|
||||||
m_uniqueMaterials.insert(pMaterial);
|
if(pMaterial) {
|
||||||
|
m_uniqueMaterials.insert(pMaterial);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hasTransparency = false;
|
m_hasTransparency = false;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class KRMaterial;
|
|||||||
class KRModel : public KRContextObject {
|
class KRModel : public KRContextObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KRModel(KRContext &context, std::string name, std::string path);
|
KRModel(KRContext &context, std::string name, KRDataBlock *data);
|
||||||
virtual ~KRModel();
|
virtual ~KRModel();
|
||||||
|
|
||||||
bool hasTransparency();
|
bool hasTransparency();
|
||||||
@@ -67,8 +67,6 @@ public:
|
|||||||
std::string getName();
|
std::string getName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadPack(std::string path);
|
|
||||||
|
|
||||||
vector<KRMaterial *> m_materials;
|
vector<KRMaterial *> m_materials;
|
||||||
set<KRMaterial *> m_uniqueMaterials;
|
set<KRMaterial *> m_uniqueMaterials;
|
||||||
KRMesh *m_pMesh;
|
KRMesh *m_pMesh;
|
||||||
|
|||||||
@@ -34,7 +34,8 @@
|
|||||||
#import "KRModel.h"
|
#import "KRModel.h"
|
||||||
|
|
||||||
KRModelManager::KRModelManager(KRContext &context) : KRContextObject(context) {
|
KRModelManager::KRModelManager(KRContext &context) : KRContextObject(context) {
|
||||||
|
m_currentVBO.handle = 0;
|
||||||
|
m_currentVBO.data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRModelManager::~KRModelManager() {
|
KRModelManager::~KRModelManager() {
|
||||||
@@ -44,8 +45,8 @@ KRModelManager::~KRModelManager() {
|
|||||||
m_models.empty();
|
m_models.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRModel *KRModelManager::loadModel(const char *szName, const char *szPath) {
|
KRModel *KRModelManager::loadModel(const char *szName, KRDataBlock *pData) {
|
||||||
KRModel *pModel = new KRModel(*m_pContext, szName, szPath);
|
KRModel *pModel = new KRModel(*m_pContext, szName, pData);
|
||||||
m_models[szName] = pModel;
|
m_models[szName] = pModel;
|
||||||
return pModel;
|
return pModel;
|
||||||
}
|
}
|
||||||
@@ -63,3 +64,35 @@ std::map<std::string, KRModel *> KRModelManager::getModels() {
|
|||||||
return m_models;
|
return m_models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRModelManager::bindVBO(const GLvoid *data, GLsizeiptr size) {
|
||||||
|
assert(size > 0);
|
||||||
|
|
||||||
|
if(m_currentVBO.data != data || m_currentVBO.size != size) {
|
||||||
|
|
||||||
|
if(m_vbos.find(data) != m_vbos.end()) {
|
||||||
|
m_currentVBO = m_vbos[data];
|
||||||
|
assert(m_currentVBO.size == size);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, m_currentVBO.handle);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
while(m_vbos.size() >= KRENGINE_MAX_VBO_HANDLES) {
|
||||||
|
// TODO - This should maintain a max size limit for VBO's rather than a limit on the number of VBO's. As meshes are split to multiple small VBO's, this is not too bad, but still not optimial.
|
||||||
|
std::map<const GLvoid *, vbo_info_type>::iterator first_itr = m_vbos.begin();
|
||||||
|
vbo_info_type firstVBO = first_itr->second;
|
||||||
|
glDeleteBuffers(1, &firstVBO.handle);
|
||||||
|
m_vbos.erase(first_itr);
|
||||||
|
fprintf(stderr, "VBO Swapping...");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentVBO.handle = -1;
|
||||||
|
glGenBuffers(1, &m_currentVBO.handle);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, m_currentVBO.handle);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW);
|
||||||
|
m_currentVBO.size = size;
|
||||||
|
m_currentVBO.data = data;
|
||||||
|
|
||||||
|
m_vbos[data] = m_currentVBO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,11 @@
|
|||||||
#ifndef KRMODELMANAGER_H
|
#ifndef KRMODELMANAGER_H
|
||||||
#define KRMODELMANAGER_H
|
#define KRMODELMANAGER_H
|
||||||
|
|
||||||
|
#define KRENGINE_MAX_VBO_HANDLES 50
|
||||||
|
|
||||||
#import "KREngine-common.h"
|
#import "KREngine-common.h"
|
||||||
#import "KRContextObject.h"
|
#import "KRContextObject.h"
|
||||||
|
#import "KRDataBlock.h"
|
||||||
|
|
||||||
class KRContext;
|
class KRContext;
|
||||||
class KRModel;
|
class KRModel;
|
||||||
@@ -47,15 +50,30 @@ public:
|
|||||||
KRModelManager(KRContext &context);
|
KRModelManager(KRContext &context);
|
||||||
virtual ~KRModelManager();
|
virtual ~KRModelManager();
|
||||||
|
|
||||||
KRModel *loadModel(const char *szName, const char *szPath);
|
KRModel *loadModel(const char *szName, KRDataBlock *pData);
|
||||||
KRModel *getModel(const char *szName);
|
KRModel *getModel(const char *szName);
|
||||||
KRModel *getFirstModel();
|
KRModel *getFirstModel();
|
||||||
|
|
||||||
std::vector<std::string> getModelNames();
|
std::vector<std::string> getModelNames();
|
||||||
std::map<std::string, KRModel *> getModels();
|
std::map<std::string, KRModel *> getModels();
|
||||||
|
|
||||||
|
|
||||||
|
void bindVBO(const GLvoid *data, GLsizeiptr size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, KRModel *> m_models;
|
std::map<std::string, KRModel *> m_models;
|
||||||
|
|
||||||
|
typedef struct vbo_info {
|
||||||
|
GLuint handle;
|
||||||
|
GLsizeiptr size;
|
||||||
|
const GLvoid *data;
|
||||||
|
} vbo_info_type;
|
||||||
|
|
||||||
|
vbo_info_type m_currentVBO;
|
||||||
|
|
||||||
|
std::map<const GLvoid *, vbo_info_type> m_vbos;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#import "KRDirectionalLight.h"
|
#import "KRDirectionalLight.h"
|
||||||
#import "KRInstance.h"
|
#import "KRInstance.h"
|
||||||
#import "KRSkyBox.h"
|
#import "KRSkyBox.h"
|
||||||
|
#import "KRAABB.h"
|
||||||
|
|
||||||
|
|
||||||
KRNode::KRNode(KRScene &scene, std::string name) : KRContextObject(scene.getContext())
|
KRNode::KRNode(KRScene &scene, std::string name) : KRContextObject(scene.getContext())
|
||||||
@@ -158,16 +159,7 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
bool KRNode::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
void KRNode::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
/*
|
|
||||||
for(std::vector<KRNode *>::iterator itr=m_childNodes.begin(); itr < m_childNodes.end(); ++itr) {
|
|
||||||
KRNode *child = (*itr);
|
|
||||||
child->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -191,6 +183,7 @@ KRBoundingVolume KRNode::getExtents(KRContext *pContext) {
|
|||||||
|
|
||||||
void KRNode::calcExtents(KRContext *pContext) {
|
void KRNode::calcExtents(KRContext *pContext) {
|
||||||
clearExtents();
|
clearExtents();
|
||||||
|
/*
|
||||||
for(std::vector<KRNode *>::iterator itr=m_childNodes.begin(); itr < m_childNodes.end(); ++itr) {
|
for(std::vector<KRNode *>::iterator itr=m_childNodes.begin(); itr < m_childNodes.end(); ++itr) {
|
||||||
KRNode *child = (*itr);
|
KRNode *child = (*itr);
|
||||||
if(m_pExtents) {
|
if(m_pExtents) {
|
||||||
@@ -199,6 +192,7 @@ void KRNode::calcExtents(KRContext *pContext) {
|
|||||||
m_pExtents = new KRBoundingVolume(child->getExtents(pContext));
|
m_pExtents = new KRBoundingVolume(child->getExtents(pContext));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<KRNode *> &KRNode::getChildren() {
|
const std::vector<KRNode *> &KRNode::getChildren() {
|
||||||
@@ -213,11 +207,6 @@ KRScene &KRNode::getScene() {
|
|||||||
return *m_pScene;
|
return *m_pScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KRAABB KRNode::getBounds() {
|
||||||
KRVector3 KRNode::getMinPoint() {
|
return KRAABB::Infinite();
|
||||||
return KRVector3::Min();
|
|
||||||
}
|
|
||||||
|
|
||||||
KRVector3 KRNode::getMaxPoint() {
|
|
||||||
return KRVector3::Max();
|
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,7 @@ class KRMat4;
|
|||||||
class KRTextureManager;
|
class KRTextureManager;
|
||||||
class KRContext;
|
class KRContext;
|
||||||
class KRScene;
|
class KRScene;
|
||||||
|
class KRAABB;
|
||||||
|
|
||||||
class KRNode : public KRContextObject
|
class KRNode : public KRContextObject
|
||||||
{
|
{
|
||||||
@@ -66,13 +67,12 @@ public:
|
|||||||
virtual void calcExtents(KRContext *Context);
|
virtual void calcExtents(KRContext *Context);
|
||||||
KRBoundingVolume getExtents(KRContext *pContext);
|
KRBoundingVolume getExtents(KRContext *pContext);
|
||||||
|
|
||||||
virtual KRVector3 getMinPoint();
|
virtual KRAABB getBounds();
|
||||||
virtual KRVector3 getMaxPoint();
|
|
||||||
|
|
||||||
KRScene &getScene();
|
KRScene &getScene();
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
virtual bool render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, RenderPass renderPass);
|
virtual void render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, RenderPass renderPass);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,14 @@ KROctree::~KROctree()
|
|||||||
|
|
||||||
void KROctree::add(KRNode *pNode)
|
void KROctree::add(KRNode *pNode)
|
||||||
{
|
{
|
||||||
KRVector3 minPoint = pNode->getMinPoint();
|
KRAABB nodeBounds = pNode->getBounds();
|
||||||
KRVector3 maxPoint = pNode->getMaxPoint();
|
if(nodeBounds == KRAABB::Infinite()) {
|
||||||
if(pNode->getMinPoint() == KRVector3::Min() && pNode->getMaxPoint() == KRVector3::Max()) {
|
|
||||||
// This item is infinitely large; we track it separately
|
// This item is infinitely large; we track it separately
|
||||||
m_outerSceneNodes.insert(pNode);
|
m_outerSceneNodes.insert(pNode);
|
||||||
} else {
|
} else {
|
||||||
if(m_pRootNode == NULL) {
|
if(m_pRootNode == NULL) {
|
||||||
// First item inserted, create a node large enough to fit it
|
// First item inserted, create a node large enough to fit it
|
||||||
m_pRootNode = new KROctreeNode(KRAABB(pNode->getMinPoint(), pNode->getMaxPoint()));
|
m_pRootNode = new KROctreeNode(nodeBounds);
|
||||||
m_pRootNode->add(pNode);
|
m_pRootNode->add(pNode);
|
||||||
} else {
|
} else {
|
||||||
// Keep encapsulating the root node until the new root contains the inserted node
|
// Keep encapsulating the root node until the new root contains the inserted node
|
||||||
@@ -39,9 +38,9 @@ void KROctree::add(KRNode *pNode)
|
|||||||
while(!bInsideRoot) {
|
while(!bInsideRoot) {
|
||||||
KRAABB rootBounds = m_pRootNode->getBounds();
|
KRAABB rootBounds = m_pRootNode->getBounds();
|
||||||
KRVector3 rootSize = rootBounds.size();
|
KRVector3 rootSize = rootBounds.size();
|
||||||
if(minPoint.x < rootBounds.min.x || minPoint.y < rootBounds.min.y || minPoint.z < rootBounds.min.z) {
|
if(nodeBounds.min.x < rootBounds.min.x || nodeBounds.min.y < rootBounds.min.y || nodeBounds.min.z < rootBounds.min.z) {
|
||||||
m_pRootNode = new KROctreeNode(KRAABB(rootBounds.min - rootSize, rootBounds.max), 7, m_pRootNode);
|
m_pRootNode = new KROctreeNode(KRAABB(rootBounds.min - rootSize, rootBounds.max), 7, m_pRootNode);
|
||||||
} else if(maxPoint.x > rootBounds.max.x || maxPoint.y > rootBounds.max.y || maxPoint.z > rootBounds.max.z) {
|
} else if(nodeBounds.max.x > rootBounds.max.x || nodeBounds.max.y > rootBounds.max.y || nodeBounds.max.z > rootBounds.max.z) {
|
||||||
m_pRootNode = new KROctreeNode(KRAABB(rootBounds.max, rootBounds.max + rootSize), 0, m_pRootNode);
|
m_pRootNode = new KROctreeNode(KRAABB(rootBounds.max, rootBounds.max + rootSize), 0, m_pRootNode);
|
||||||
} else {
|
} else {
|
||||||
bInsideRoot = true;
|
bInsideRoot = true;
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ bool KROctreeNode::getOcclusionQueryResults(std::set<KRAABB> &renderedBounds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FINDME - Test Code:
|
// FINDME - Test Code:
|
||||||
bGoDeeper = true;
|
//bGoDeeper = true;
|
||||||
bRendered = true;
|
//bRendered = true;
|
||||||
|
|
||||||
if(bGoDeeper) { // Only recurse deeper if we reached this level in the previous pass
|
if(bGoDeeper) { // Only recurse deeper if we reached this level in the previous pass
|
||||||
for(int i=0; i<8; i++) {
|
for(int i=0; i<8; i++) {
|
||||||
@@ -129,33 +129,40 @@ KRAABB KROctreeNode::getBounds()
|
|||||||
|
|
||||||
void KROctreeNode::add(KRNode *pNode)
|
void KROctreeNode::add(KRNode *pNode)
|
||||||
{
|
{
|
||||||
KRVector3 center = m_bounds.center();
|
|
||||||
|
|
||||||
int iChild = getChildIndex(pNode);
|
int iChild = getChildIndex(pNode);
|
||||||
if(iChild == -1) {
|
if(iChild == -1) {
|
||||||
m_sceneNodes.insert(pNode);
|
m_sceneNodes.insert(pNode);
|
||||||
} else {
|
} else {
|
||||||
if(m_children[iChild] == NULL) {
|
if(m_children[iChild] == NULL) {
|
||||||
m_children[iChild] = new KROctreeNode(KRAABB(
|
m_children[iChild] = new KROctreeNode(getChildBounds(iChild));
|
||||||
KRVector3(
|
|
||||||
(iChild & 1) == 0 ? m_bounds.min.x : center.x,
|
|
||||||
(iChild & 2) == 0 ? m_bounds.min.y : center.y,
|
|
||||||
(iChild & 4) == 0 ? m_bounds.min.z : center.z),
|
|
||||||
KRVector3(
|
|
||||||
(iChild & 1) == 0 ? center.x : m_bounds.max.x,
|
|
||||||
(iChild & 2) == 0 ? center.y : m_bounds.max.y,
|
|
||||||
(iChild & 4) == 0 ? center.z : m_bounds.max.z)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
m_children[iChild]->add(pNode);
|
m_children[iChild]->add(pNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KRAABB KROctreeNode::getChildBounds(int iChild)
|
||||||
|
{
|
||||||
|
KRVector3 center = m_bounds.center();
|
||||||
|
|
||||||
|
return KRAABB(
|
||||||
|
KRVector3(
|
||||||
|
(iChild & 1) == 0 ? m_bounds.min.x : center.x,
|
||||||
|
(iChild & 2) == 0 ? m_bounds.min.y : center.y,
|
||||||
|
(iChild & 4) == 0 ? m_bounds.min.z : center.z),
|
||||||
|
KRVector3(
|
||||||
|
(iChild & 1) == 0 ? center.x : m_bounds.max.x,
|
||||||
|
(iChild & 2) == 0 ? center.y : m_bounds.max.y,
|
||||||
|
(iChild & 4) == 0 ? center.z : m_bounds.max.z)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
int KROctreeNode::getChildIndex(KRNode *pNode)
|
int KROctreeNode::getChildIndex(KRNode *pNode)
|
||||||
{
|
{
|
||||||
KRVector3 min = pNode->getMinPoint();
|
/*
|
||||||
KRVector3 max = pNode->getMaxPoint();
|
|
||||||
|
KRVector3 min = pNode->getMinPoint();
|
||||||
|
KRVector3 max = pNode->getMaxPoint();
|
||||||
|
|
||||||
// 0: max.x < center.x && max.y < center.y && max.z < center.z
|
// 0: max.x < center.x && max.y < center.y && max.z < center.z
|
||||||
// 1: min.x > center.x && max.y < center.y && max.z < center.z
|
// 1: min.x > center.x && max.y < center.y && max.z < center.z
|
||||||
// 2: max.x < center.x && min.y > center.y && max.z < center.z
|
// 2: max.x < center.x && min.y > center.y && max.z < center.z
|
||||||
@@ -197,6 +204,14 @@ int KROctreeNode::getChildIndex(KRNode *pNode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return iChild;
|
return iChild;
|
||||||
|
*/
|
||||||
|
|
||||||
|
for(int iChild=0; iChild < 8; iChild++) {
|
||||||
|
if(getChildBounds(iChild).contains(pNode->getBounds())) {
|
||||||
|
return iChild;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KROctreeNode::remove(KRNode *pNode)
|
void KROctreeNode::remove(KRNode *pNode)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public:
|
|||||||
|
|
||||||
void setChildNode(int iChild, KROctreeNode *pChild);
|
void setChildNode(int iChild, KROctreeNode *pChild);
|
||||||
int getChildIndex(KRNode *pNode);
|
int getChildIndex(KRNode *pNode);
|
||||||
|
KRAABB getChildBounds(int iChild);
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
bool canShrinkRoot() const;
|
bool canShrinkRoot() const;
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ std::string KRPointLight::getElementName() {
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
bool KRPointLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
void KRPointLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
bool bRendered = KRLight::render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
KRLight::render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
||||||
|
|
||||||
|
|
||||||
if(renderPass == KRNode::RENDER_PASS_DEFERRED_LIGHTS) {
|
if(renderPass == KRNode::RENDER_PASS_DEFERRED_LIGHTS) {
|
||||||
@@ -140,8 +140,6 @@ bool KRPointLight::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolu
|
|||||||
glDrawArrays(GL_TRIANGLES, 0, m_cVertices);
|
glDrawArrays(GL_TRIANGLES, 0, m_cVertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bRendered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRPointLight::generateMesh() {
|
void KRPointLight::generateMesh() {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
virtual bool render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass);
|
virtual void render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "KRResource.h"
|
#include "KRResource.h"
|
||||||
#include "KRMesh.h"
|
|
||||||
#include "KRScene.h"
|
#include "KRScene.h"
|
||||||
#include "KRResource+blend.h"
|
#include "KRResource+blend.h"
|
||||||
|
|
||||||
@@ -27,33 +26,12 @@ std::vector<KRResource *> KRResource::LoadBlenderScene(KRContext &context, const
|
|||||||
KRScene *pScene = new KRScene(context, KRResource::GetFileBase(path));
|
KRScene *pScene = new KRScene(context, KRResource::GetFileBase(path));
|
||||||
resources.push_back(pScene);
|
resources.push_back(pScene);
|
||||||
|
|
||||||
int fdFile = 0;
|
KRDataBlock data;
|
||||||
int fileSize = 0;
|
|
||||||
void *pFile = NULL;
|
|
||||||
|
|
||||||
struct stat statbuf;
|
if(data.load(path)) {
|
||||||
fdFile = open(path.c_str(), O_RDONLY);
|
KRBlendFile blend_file = KRBlendFile(pFile);
|
||||||
if(fdFile >= 0) {
|
|
||||||
if(fstat(fdFile, &statbuf) >= 0) {
|
|
||||||
if ((pFile = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, fdFile, 0)) == (caddr_t) -1) {
|
|
||||||
} else {
|
|
||||||
fileSize = statbuf.st_size;
|
|
||||||
|
|
||||||
|
|
||||||
KRBlendFile blend_file = KRBlendFile(pFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pFile != NULL) {
|
|
||||||
munmap(pFile, fileSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fdFile != 0) {
|
|
||||||
close(fdFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return resources;
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,322 +36,304 @@ std::vector<KRResource *> KRResource::LoadObj(KRContext &context, const std::str
|
|||||||
|
|
||||||
std::vector<std::string> material_names_t;
|
std::vector<std::string> material_names_t;
|
||||||
|
|
||||||
int fdFile = 0;
|
KRDataBlock data;
|
||||||
int fileSize = 0;
|
|
||||||
void *pFile = NULL;
|
|
||||||
char szSymbol[500][64];
|
char szSymbol[500][64];
|
||||||
|
|
||||||
int *pFaces = NULL;
|
int *pFaces = NULL;
|
||||||
|
|
||||||
vector<KRMesh::pack_material *> m_materials;
|
vector<KRMesh::pack_material *> m_materials;
|
||||||
|
|
||||||
struct stat statbuf;
|
if(data.load(path)) {
|
||||||
fdFile = open(path.c_str(), O_RDONLY);
|
// -----=====----- Get counts -----=====-----
|
||||||
if(fdFile >= 0) {
|
|
||||||
if(fstat(fdFile, &statbuf) >= 0) {
|
int cVertexData = 0;
|
||||||
if ((pFile = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, fdFile, 0)) == (caddr_t) -1) {
|
|
||||||
|
|
||||||
|
int cFaces = 1;
|
||||||
|
int cMaterialFaceStart = 1;
|
||||||
|
|
||||||
|
char *pScan = (char *)data.getStart();
|
||||||
|
char *pEnd = (char *)data.getEnd();
|
||||||
|
while(pScan < pEnd) {
|
||||||
|
|
||||||
|
// Scan through whitespace
|
||||||
|
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t' || *pScan == '\r' || *pScan == '\n')) {
|
||||||
|
pScan++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*pScan == '#') {
|
||||||
|
// Line is a comment line
|
||||||
|
|
||||||
|
// Scan to the end of the line
|
||||||
|
while(pScan < pEnd && *pScan != '\r' && *pScan != '\n') {
|
||||||
|
pScan++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fileSize = statbuf.st_size;
|
int cSymbols = 0;
|
||||||
|
while(pScan < pEnd && *pScan != '\n' && *pScan != '\r') {
|
||||||
|
|
||||||
// -----=====----- Get counts -----=====-----
|
char *pDest = szSymbol[cSymbols++];
|
||||||
|
while(pScan < pEnd && *pScan != ' ' && *pScan != '\n' && *pScan != '\r') {
|
||||||
int cVertexData = 0;
|
*pDest++ = *pScan++;
|
||||||
|
|
||||||
|
|
||||||
int cFaces = 1;
|
|
||||||
int cMaterialFaceStart = 1;
|
|
||||||
|
|
||||||
char *pScan = (char *)pFile;
|
|
||||||
char *pEnd = (char *)pFile + fileSize;
|
|
||||||
while(pScan < pEnd) {
|
|
||||||
|
|
||||||
// Scan through whitespace
|
|
||||||
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t' || *pScan == '\r' || *pScan == '\n')) {
|
|
||||||
pScan++;
|
|
||||||
}
|
}
|
||||||
|
*pDest = '\0';
|
||||||
|
|
||||||
if(*pScan == '#') {
|
// Scan through whitespace, but don't advance to next line
|
||||||
// Line is a comment line
|
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t')) {
|
||||||
|
pScan++;
|
||||||
// Scan to the end of the line
|
|
||||||
while(pScan < pEnd && *pScan != '\r' && *pScan != '\n') {
|
|
||||||
pScan++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int cSymbols = 0;
|
|
||||||
while(pScan < pEnd && *pScan != '\n' && *pScan != '\r') {
|
|
||||||
|
|
||||||
char *pDest = szSymbol[cSymbols++];
|
|
||||||
while(pScan < pEnd && *pScan != ' ' && *pScan != '\n' && *pScan != '\r') {
|
|
||||||
*pDest++ = *pScan++;
|
|
||||||
}
|
|
||||||
*pDest = '\0';
|
|
||||||
|
|
||||||
// Scan through whitespace, but don't advance to next line
|
|
||||||
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t')) {
|
|
||||||
pScan++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(strcmp(szSymbol[0], "v") == 0) {
|
|
||||||
// Vertex (v)
|
|
||||||
} else if(strcmp(szSymbol[0], "vt") == 0) {
|
|
||||||
// Vertex Texture UV Coordinate (vt)
|
|
||||||
} else if(strcmp(szSymbol[0], "vn") == 0) {
|
|
||||||
// Vertex Normal (vn)
|
|
||||||
} else if(strcmp(szSymbol[0], "f") == 0) {
|
|
||||||
// Face (f)
|
|
||||||
int cFaceVertexes = (cSymbols - 3) * 3; // 3 vertexes per triangle. Triangles have 4 symbols. Quads have 5 symbols and generate two triangles.
|
|
||||||
cVertexData += cFaceVertexes;
|
|
||||||
cFaces += cFaceVertexes * 3 + 1; // Allocate space for count of vertices, Vertex Index, Texture Coordinate Index, and Normal Index
|
|
||||||
|
|
||||||
} else if(strcmp(szSymbol[0], "usemtl") == 0) {
|
|
||||||
// Use Material (usemtl)
|
|
||||||
if(cMaterialFaceStart - cFaces > 0) {
|
|
||||||
cFaces++;
|
|
||||||
|
|
||||||
}
|
|
||||||
material_names_t.push_back(std::string(szSymbol[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strcmp(szSymbol[0], "v") == 0) {
|
||||||
|
// Vertex (v)
|
||||||
|
} else if(strcmp(szSymbol[0], "vt") == 0) {
|
||||||
|
// Vertex Texture UV Coordinate (vt)
|
||||||
|
} else if(strcmp(szSymbol[0], "vn") == 0) {
|
||||||
|
// Vertex Normal (vn)
|
||||||
|
} else if(strcmp(szSymbol[0], "f") == 0) {
|
||||||
|
// Face (f)
|
||||||
|
int cFaceVertexes = (cSymbols - 3) * 3; // 3 vertexes per triangle. Triangles have 4 symbols. Quads have 5 symbols and generate two triangles.
|
||||||
|
cVertexData += cFaceVertexes;
|
||||||
|
cFaces += cFaceVertexes * 3 + 1; // Allocate space for count of vertices, Vertex Index, Texture Coordinate Index, and Normal Index
|
||||||
|
|
||||||
// -----=====----- Populate vertexes and faces -----=====-----
|
} else if(strcmp(szSymbol[0], "usemtl") == 0) {
|
||||||
|
// Use Material (usemtl)
|
||||||
|
if(cMaterialFaceStart - cFaces > 0) {
|
||||||
|
cFaces++;
|
||||||
|
|
||||||
int *pFaces = (int *)malloc(sizeof(int *) * (cFaces + 1));
|
}
|
||||||
|
material_names_t.push_back(std::string(szSymbol[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<KRVector3> indexed_vertices;
|
// -----=====----- Populate vertexes and faces -----=====-----
|
||||||
std::vector<KRVector2> indexed_uva;
|
|
||||||
std::vector<KRVector3> indexed_normals;
|
|
||||||
|
|
||||||
int *pFace = pFaces;
|
int *pFaces = (int *)malloc(sizeof(int *) * (cFaces + 1));
|
||||||
int *pMaterialFaces = pFace++;
|
|
||||||
*pMaterialFaces = 0;
|
|
||||||
|
std::vector<KRVector3> indexed_vertices;
|
||||||
|
std::vector<KRVector2> indexed_uva;
|
||||||
|
std::vector<KRVector3> indexed_normals;
|
||||||
|
|
||||||
|
int *pFace = pFaces;
|
||||||
|
int *pMaterialFaces = pFace++;
|
||||||
|
*pMaterialFaces = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|
||||||
pScan = (char *)pFile;
|
pScan = (char *)data.getStart();
|
||||||
while(pScan < pEnd) {
|
while(pScan < pEnd) {
|
||||||
|
|
||||||
// Scan through whitespace
|
// Scan through whitespace
|
||||||
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t' || *pScan == '\r' || *pScan == '\n')) {
|
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t' || *pScan == '\r' || *pScan == '\n')) {
|
||||||
|
pScan++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*pScan == '#') {
|
||||||
|
// Line is a comment line
|
||||||
|
|
||||||
|
// Scan to the end of the line
|
||||||
|
while(pScan < pEnd && *pScan != '\r' && *pScan != '\n') {
|
||||||
|
pScan++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int cSymbols = 0;
|
||||||
|
while(pScan < pEnd && *pScan != '\n' && *pScan != '\r') {
|
||||||
|
|
||||||
|
char *pDest = szSymbol[cSymbols++];
|
||||||
|
while(pScan < pEnd && *pScan != ' ' && *pScan != '\n' && *pScan != '\r') {
|
||||||
|
*pDest++ = *pScan++;
|
||||||
|
}
|
||||||
|
*pDest = '\0';
|
||||||
|
|
||||||
|
// Scan through whitespace, but don't advance to next line
|
||||||
|
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t')) {
|
||||||
pScan++;
|
pScan++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(*pScan == '#') {
|
if(strcmp(szSymbol[0], "v") == 0) {
|
||||||
// Line is a comment line
|
// Vertex (v)
|
||||||
|
float x, y, z;
|
||||||
|
char *pChar = szSymbol[1];
|
||||||
|
x = strtof(pChar, &pChar);
|
||||||
|
pChar = szSymbol[2];
|
||||||
|
y = strtof(pChar, &pChar);
|
||||||
|
pChar = szSymbol[3];
|
||||||
|
z = strtof(pChar, &pChar);
|
||||||
|
indexed_vertices.push_back(KRVector3(x,y,z));
|
||||||
|
} else if(strcmp(szSymbol[0], "vt") == 0) {
|
||||||
|
// Vertex Texture UV Coordinate (vt)
|
||||||
|
char *pChar = szSymbol[1];
|
||||||
|
float u,v;
|
||||||
|
|
||||||
// Scan to the end of the line
|
u = strtof(pChar, &pChar);
|
||||||
while(pScan < pEnd && *pScan != '\r' && *pScan != '\n') {
|
pChar = szSymbol[2];
|
||||||
pScan++;
|
v = strtof(pChar, &pChar);
|
||||||
}
|
indexed_uva.push_back(KRVector2(u,v));
|
||||||
} else {
|
} else if(strcmp(szSymbol[0], "vn") == 0) {
|
||||||
int cSymbols = 0;
|
// Vertex Normal (vn)
|
||||||
while(pScan < pEnd && *pScan != '\n' && *pScan != '\r') {
|
float x,y,z;
|
||||||
|
char *pChar = szSymbol[1];
|
||||||
|
x = strtof(pChar, &pChar);
|
||||||
|
pChar = szSymbol[2];
|
||||||
|
y = strtof(pChar, &pChar);
|
||||||
|
pChar = szSymbol[3];
|
||||||
|
z = strtof(pChar, &pChar);
|
||||||
|
indexed_normals.push_back(KRVector3(x,y,z));
|
||||||
|
} else if(strcmp(szSymbol[0], "f") == 0) {
|
||||||
|
// Face (f)
|
||||||
|
int cFaceVertices = cSymbols - 1;
|
||||||
|
|
||||||
char *pDest = szSymbol[cSymbols++];
|
*pFace++ = cFaceVertices;
|
||||||
while(pScan < pEnd && *pScan != ' ' && *pScan != '\n' && *pScan != '\r') {
|
for(int iSymbol=1; iSymbol < cSymbols; iSymbol++) {
|
||||||
*pDest++ = *pScan++;
|
char *pChar = szSymbol[iSymbol];
|
||||||
}
|
if(*pChar == '.' || (*pChar >= '0' && *pChar <= '9')) {
|
||||||
*pDest = '\0';
|
*pFace++ = strtol(pChar, &pChar, 10) - 1; // Vertex Index
|
||||||
|
|
||||||
// Scan through whitespace, but don't advance to next line
|
if(*pChar == '/') {
|
||||||
while(pScan < pEnd && (*pScan == ' ' || *pScan == '\t')) {
|
pChar++;
|
||||||
pScan++;
|
if(*pChar == '/') {
|
||||||
}
|
*pFace++ = -1;
|
||||||
}
|
} else {
|
||||||
|
*pFace++ = strtol(pChar, &pChar, 10) - 1; // Texture Coordinate Index
|
||||||
if(strcmp(szSymbol[0], "v") == 0) {
|
|
||||||
// Vertex (v)
|
|
||||||
float x, y, z;
|
|
||||||
char *pChar = szSymbol[1];
|
|
||||||
x = strtof(pChar, &pChar);
|
|
||||||
pChar = szSymbol[2];
|
|
||||||
y = strtof(pChar, &pChar);
|
|
||||||
pChar = szSymbol[3];
|
|
||||||
z = strtof(pChar, &pChar);
|
|
||||||
indexed_vertices.push_back(KRVector3(x,y,z));
|
|
||||||
} else if(strcmp(szSymbol[0], "vt") == 0) {
|
|
||||||
// Vertex Texture UV Coordinate (vt)
|
|
||||||
char *pChar = szSymbol[1];
|
|
||||||
float u,v;
|
|
||||||
|
|
||||||
u = strtof(pChar, &pChar);
|
|
||||||
pChar = szSymbol[2];
|
|
||||||
v = strtof(pChar, &pChar);
|
|
||||||
indexed_uva.push_back(KRVector2(u,v));
|
|
||||||
} else if(strcmp(szSymbol[0], "vn") == 0) {
|
|
||||||
// Vertex Normal (vn)
|
|
||||||
float x,y,z;
|
|
||||||
char *pChar = szSymbol[1];
|
|
||||||
x = strtof(pChar, &pChar);
|
|
||||||
pChar = szSymbol[2];
|
|
||||||
y = strtof(pChar, &pChar);
|
|
||||||
pChar = szSymbol[3];
|
|
||||||
z = strtof(pChar, &pChar);
|
|
||||||
indexed_normals.push_back(KRVector3(x,y,z));
|
|
||||||
} else if(strcmp(szSymbol[0], "f") == 0) {
|
|
||||||
// Face (f)
|
|
||||||
int cFaceVertices = cSymbols - 1;
|
|
||||||
|
|
||||||
*pFace++ = cFaceVertices;
|
|
||||||
for(int iSymbol=1; iSymbol < cSymbols; iSymbol++) {
|
|
||||||
char *pChar = szSymbol[iSymbol];
|
|
||||||
if(*pChar == '.' || (*pChar >= '0' && *pChar <= '9')) {
|
|
||||||
*pFace++ = strtol(pChar, &pChar, 10) - 1; // Vertex Index
|
|
||||||
|
|
||||||
if(*pChar == '/') {
|
|
||||||
pChar++;
|
|
||||||
if(*pChar == '/') {
|
|
||||||
*pFace++ = -1;
|
|
||||||
} else {
|
|
||||||
*pFace++ = strtol(pChar, &pChar, 10) - 1; // Texture Coordinate Index
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*pFace++ = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(*pChar == '/') {
|
|
||||||
pChar++;
|
|
||||||
if(*pChar == '/') {
|
|
||||||
*pFace++ = -1;
|
|
||||||
} else {
|
|
||||||
*pFace++ = strtol(pChar, &pChar, 10) - 1; // Normal Index
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*pFace++ = -1;
|
|
||||||
}
|
|
||||||
while(*pChar == '/') {
|
|
||||||
pChar++;
|
|
||||||
strtol(pChar, &pChar, 10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
*pFace++ = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(*pChar == '/') {
|
||||||
} else if(strcmp(szSymbol[0], "usemtl") == 0) {
|
pChar++;
|
||||||
// Use Material (usemtl)
|
if(*pChar == '/') {
|
||||||
if(pFace - pMaterialFaces > 1) {
|
*pFace++ = -1;
|
||||||
*pMaterialFaces = pFace - pMaterialFaces - 1;
|
} else {
|
||||||
pMaterialFaces = pFace++;
|
*pFace++ = strtol(pChar, &pChar, 10) - 1; // Normal Index
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*pFace++ = -1;
|
||||||
|
}
|
||||||
|
while(*pChar == '/') {
|
||||||
|
pChar++;
|
||||||
|
strtol(pChar, &pChar, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else if(strcmp(szSymbol[0], "usemtl") == 0) {
|
||||||
|
// Use Material (usemtl)
|
||||||
|
if(pFace - pMaterialFaces > 1) {
|
||||||
|
*pMaterialFaces = pFace - pMaterialFaces - 1;
|
||||||
|
pMaterialFaces = pFace++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
*pMaterialFaces = pFace - pMaterialFaces - 1;
|
*pMaterialFaces = pFace - pMaterialFaces - 1;
|
||||||
*pFace++ = 0;
|
*pFace++ = 0;
|
||||||
|
|
||||||
|
|
||||||
int iVertex = 0;
|
int iVertex = 0;
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string>::iterator material_itr = material_names_t.begin();
|
std::vector<std::string>::iterator material_itr = material_names_t.begin();
|
||||||
KRMesh::pack_material *pMaterial = new KRMesh::pack_material();
|
KRMesh::pack_material *pMaterial = new KRMesh::pack_material();
|
||||||
|
pMaterial->start_vertex = iVertex;
|
||||||
|
pMaterial->vertex_count = 0;
|
||||||
|
memset(pMaterial->szName, 64, 0);
|
||||||
|
if(material_itr < material_names_t.end()) {
|
||||||
|
strncpy(pMaterial->szName, (*material_itr++).c_str(), 64);
|
||||||
|
}
|
||||||
|
m_materials.push_back(pMaterial);
|
||||||
|
|
||||||
|
|
||||||
|
pFace = pFaces;
|
||||||
|
while(*pFace != 0 && iVertex < cVertexData) {
|
||||||
|
pMaterial->start_vertex = iVertex;
|
||||||
|
|
||||||
|
int *pMaterialEndFace = pFace + *pFace++;
|
||||||
|
while(pFace < pMaterialEndFace && iVertex < cVertexData) {
|
||||||
|
int cFaceVertexes = *pFace;
|
||||||
|
KRVector3 firstFaceVertex;
|
||||||
|
KRVector3 prevFaceVertex;
|
||||||
|
KRVector3 firstFaceNormal;
|
||||||
|
KRVector3 prevFaceNormal;
|
||||||
|
KRVector2 firstFaceUva;
|
||||||
|
KRVector2 prevFaceUva;
|
||||||
|
for(int iFaceVertex=0; iFaceVertex < cFaceVertexes; iFaceVertex++) {
|
||||||
|
if(iFaceVertex > 2) {
|
||||||
|
// There have already been 3 vertices. Now we need to split the quad into a second triangle composed of the 1st, 3rd, and 4th vertices
|
||||||
|
iVertex+=2;
|
||||||
|
|
||||||
|
vertices.push_back(firstFaceVertex);
|
||||||
|
uva.push_back(firstFaceUva);
|
||||||
|
normals.push_back(firstFaceNormal);
|
||||||
|
|
||||||
|
vertices.push_back(prevFaceVertex);
|
||||||
|
uva.push_back(prevFaceUva);
|
||||||
|
normals.push_back(prevFaceNormal);
|
||||||
|
}
|
||||||
|
KRVector3 vertex = indexed_vertices[pFace[iFaceVertex*3+1]];
|
||||||
|
KRVector2 new_uva;
|
||||||
|
if(pFace[iFaceVertex*3+2] >= 0) {
|
||||||
|
new_uva = indexed_uva[pFace[iFaceVertex*3+2]];
|
||||||
|
}
|
||||||
|
KRVector3 normal;
|
||||||
|
if(pFace[iFaceVertex*3+3] >= 0){
|
||||||
|
KRVector3 normal = indexed_normals[pFace[iFaceVertex*3+3]];
|
||||||
|
}
|
||||||
|
|
||||||
|
vertices.push_back(vertex);
|
||||||
|
uva.push_back(new_uva);
|
||||||
|
normals.push_back(normal);
|
||||||
|
|
||||||
|
if(iFaceVertex==0) {
|
||||||
|
firstFaceVertex = vertex;
|
||||||
|
firstFaceUva = new_uva;
|
||||||
|
firstFaceNormal = normal;
|
||||||
|
}
|
||||||
|
prevFaceVertex = vertex;
|
||||||
|
prevFaceUva = new_uva;
|
||||||
|
prevFaceNormal = normal;
|
||||||
|
|
||||||
|
iVertex++;
|
||||||
|
}
|
||||||
|
pFace += cFaceVertexes * 3 + 1;
|
||||||
|
}
|
||||||
|
pMaterial->vertex_count = iVertex - pMaterial->start_vertex;
|
||||||
|
if(*pFace != 0) {
|
||||||
|
pMaterial = new KRMesh::pack_material();
|
||||||
pMaterial->start_vertex = iVertex;
|
pMaterial->start_vertex = iVertex;
|
||||||
pMaterial->vertex_count = 0;
|
pMaterial->vertex_count = 0;
|
||||||
memset(pMaterial->szName, 64, 0);
|
memset(pMaterial->szName, 64, 0);
|
||||||
|
|
||||||
if(material_itr < material_names_t.end()) {
|
if(material_itr < material_names_t.end()) {
|
||||||
strncpy(pMaterial->szName, (*material_itr++).c_str(), 64);
|
strncpy(pMaterial->szName, (*material_itr++).c_str(), 64);
|
||||||
}
|
}
|
||||||
m_materials.push_back(pMaterial);
|
m_materials.push_back(pMaterial);
|
||||||
|
|
||||||
|
|
||||||
pFace = pFaces;
|
|
||||||
while(*pFace != 0 && iVertex < cVertexData) {
|
|
||||||
pMaterial->start_vertex = iVertex;
|
|
||||||
|
|
||||||
int *pMaterialEndFace = pFace + *pFace++;
|
|
||||||
while(pFace < pMaterialEndFace && iVertex < cVertexData) {
|
|
||||||
int cFaceVertexes = *pFace;
|
|
||||||
KRVector3 firstFaceVertex;
|
|
||||||
KRVector3 prevFaceVertex;
|
|
||||||
KRVector3 firstFaceNormal;
|
|
||||||
KRVector3 prevFaceNormal;
|
|
||||||
KRVector2 firstFaceUva;
|
|
||||||
KRVector2 prevFaceUva;
|
|
||||||
for(int iFaceVertex=0; iFaceVertex < cFaceVertexes; iFaceVertex++) {
|
|
||||||
if(iFaceVertex > 2) {
|
|
||||||
// There have already been 3 vertices. Now we need to split the quad into a second triangle composed of the 1st, 3rd, and 4th vertices
|
|
||||||
iVertex+=2;
|
|
||||||
|
|
||||||
vertices.push_back(firstFaceVertex);
|
|
||||||
uva.push_back(firstFaceUva);
|
|
||||||
normals.push_back(firstFaceNormal);
|
|
||||||
|
|
||||||
vertices.push_back(prevFaceVertex);
|
|
||||||
uva.push_back(prevFaceUva);
|
|
||||||
normals.push_back(prevFaceNormal);
|
|
||||||
}
|
|
||||||
KRVector3 vertex = indexed_vertices[pFace[iFaceVertex*3+1]];
|
|
||||||
KRVector2 new_uva;
|
|
||||||
if(pFace[iFaceVertex*3+2] >= 0) {
|
|
||||||
new_uva = indexed_uva[pFace[iFaceVertex*3+2]];
|
|
||||||
}
|
|
||||||
KRVector3 normal;
|
|
||||||
if(pFace[iFaceVertex*3+3] >= 0){
|
|
||||||
KRVector3 normal = indexed_normals[pFace[iFaceVertex*3+3]];
|
|
||||||
}
|
|
||||||
|
|
||||||
vertices.push_back(vertex);
|
|
||||||
uva.push_back(new_uva);
|
|
||||||
normals.push_back(normal);
|
|
||||||
|
|
||||||
if(iFaceVertex==0) {
|
|
||||||
firstFaceVertex = vertex;
|
|
||||||
firstFaceUva = new_uva;
|
|
||||||
firstFaceNormal = normal;
|
|
||||||
}
|
|
||||||
prevFaceVertex = vertex;
|
|
||||||
prevFaceUva = new_uva;
|
|
||||||
prevFaceNormal = normal;
|
|
||||||
|
|
||||||
iVertex++;
|
|
||||||
}
|
|
||||||
pFace += cFaceVertexes * 3 + 1;
|
|
||||||
}
|
|
||||||
pMaterial->vertex_count = iVertex - pMaterial->start_vertex;
|
|
||||||
if(*pFace != 0) {
|
|
||||||
pMaterial = new KRMesh::pack_material();
|
|
||||||
pMaterial->start_vertex = iVertex;
|
|
||||||
pMaterial->vertex_count = 0;
|
|
||||||
memset(pMaterial->szName, 64, 0);
|
|
||||||
|
|
||||||
if(material_itr < material_names_t.end()) {
|
|
||||||
strncpy(pMaterial->szName, (*material_itr++).c_str(), 64);
|
|
||||||
}
|
|
||||||
m_materials.push_back(pMaterial);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int iMaterial=0; iMaterial < m_materials.size(); iMaterial++) {
|
|
||||||
KRMesh::pack_material *pNewMaterial = m_materials[iMaterial];
|
|
||||||
if(pNewMaterial->vertex_count > 0) {
|
|
||||||
material_names.push_back(std::string(pNewMaterial->szName));
|
|
||||||
submesh_starts.push_back(pNewMaterial->start_vertex);
|
|
||||||
submesh_lengths.push_back(pNewMaterial->vertex_count);
|
|
||||||
}
|
|
||||||
delete pNewMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_mesh->LoadData(vertices, uva, uvb, normals, tangents, submesh_starts, submesh_lengths, material_names);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(pFile != NULL) {
|
for(int iMaterial=0; iMaterial < m_materials.size(); iMaterial++) {
|
||||||
munmap(pFile, fileSize);
|
KRMesh::pack_material *pNewMaterial = m_materials[iMaterial];
|
||||||
}
|
if(pNewMaterial->vertex_count > 0) {
|
||||||
|
material_names.push_back(std::string(pNewMaterial->szName));
|
||||||
|
submesh_starts.push_back(pNewMaterial->start_vertex);
|
||||||
|
submesh_lengths.push_back(pNewMaterial->vertex_count);
|
||||||
|
}
|
||||||
|
delete pNewMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
if(fdFile != 0) {
|
new_mesh->LoadData(vertices, uva, uvb, normals, tangents, submesh_starts, submesh_lengths, material_names);
|
||||||
close(fdFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pFaces) {
|
if(pFaces) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#import "KRDirectionalLight.h"
|
#import "KRDirectionalLight.h"
|
||||||
|
|
||||||
#import "KRScene.h"
|
#import "KRScene.h"
|
||||||
|
#import "KRNode.h"
|
||||||
|
|
||||||
KRScene::KRScene(KRContext &context, std::string name) : KRResource(context, name) {
|
KRScene::KRScene(KRContext &context, std::string name) : KRResource(context, name) {
|
||||||
m_pContext = &context;
|
m_pContext = &context;
|
||||||
@@ -61,6 +62,7 @@ void KRScene::render(KRCamera *pCamera, std::set<KRAABB> &visibleBounds, KRConte
|
|||||||
if(renderPass != KRNode::RENDER_PASS_SHADOWMAP) {
|
if(renderPass != KRNode::RENDER_PASS_SHADOWMAP) {
|
||||||
|
|
||||||
if(cShadowBuffers > 0) {
|
if(cShadowBuffers > 0) {
|
||||||
|
m_pContext->getTextureManager()->selectTexture(3, NULL);
|
||||||
glActiveTexture(GL_TEXTURE3);
|
glActiveTexture(GL_TEXTURE3);
|
||||||
glBindTexture(GL_TEXTURE_2D, shadowDepthTextures[0]);
|
glBindTexture(GL_TEXTURE_2D, shadowDepthTextures[0]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@@ -70,6 +72,7 @@ void KRScene::render(KRCamera *pCamera, std::set<KRAABB> &visibleBounds, KRConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(cShadowBuffers > 1) {
|
if(cShadowBuffers > 1) {
|
||||||
|
m_pContext->getTextureManager()->selectTexture(4, NULL);
|
||||||
glActiveTexture(GL_TEXTURE4);
|
glActiveTexture(GL_TEXTURE4);
|
||||||
glBindTexture(GL_TEXTURE_2D, shadowDepthTextures[1]);
|
glBindTexture(GL_TEXTURE_2D, shadowDepthTextures[1]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@@ -79,6 +82,7 @@ void KRScene::render(KRCamera *pCamera, std::set<KRAABB> &visibleBounds, KRConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(cShadowBuffers > 2) {
|
if(cShadowBuffers > 2) {
|
||||||
|
m_pContext->getTextureManager()->selectTexture(5, NULL);
|
||||||
glActiveTexture(GL_TEXTURE5);
|
glActiveTexture(GL_TEXTURE5);
|
||||||
glBindTexture(GL_TEXTURE_2D, shadowDepthTextures[2]);
|
glBindTexture(GL_TEXTURE_2D, shadowDepthTextures[2]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@@ -135,17 +139,93 @@ void KRScene::render(KRCamera *pCamera, std::set<KRAABB> &visibleBounds, KRConte
|
|||||||
void KRScene::render(KROctreeNode *pOctreeNode, std::set<KRAABB> &visibleBounds, KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass)
|
void KRScene::render(KROctreeNode *pOctreeNode, std::set<KRAABB> &visibleBounds, KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass)
|
||||||
{
|
{
|
||||||
if(pOctreeNode) {
|
if(pOctreeNode) {
|
||||||
if(frustrumVolume.test_intersect(pOctreeNode->getBounds())) { // Only recurse deeper if within the view frustrum
|
KRMat4 projectionMatrix;
|
||||||
pOctreeNode->beginOcclusionQuery(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
if(renderPass != KRNode::RENDER_PASS_SHADOWMAP) {
|
||||||
for(std::set<KRNode *>::iterator itr=pOctreeNode->getSceneNodes().begin(); itr != pOctreeNode->getSceneNodes().end(); itr++) {
|
projectionMatrix = pCamera->getProjectionMatrix();
|
||||||
(*itr)->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
}
|
||||||
}
|
|
||||||
pOctreeNode->endOcclusionQuery();
|
KRAABB octreeBounds = pOctreeNode->getBounds();
|
||||||
for(int i=0; i<8; i++) {
|
|
||||||
render(pOctreeNode->getChildren()[i], visibleBounds, pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
if(true) {
|
||||||
|
//if(pOctreeNode->getBounds().visible(viewMatrix * projectionMatrix)) { // Only recurse deeper if within the view frustrum
|
||||||
|
//if(frustrumVolume.test_intersect(pOctreeNode->getBounds())) { // Only recurse deeper if within the view frustrum
|
||||||
|
|
||||||
|
bool can_occlusion_test = renderPass == KRNode::RENDER_PASS_FORWARD_OPAQUE || renderPass == KRNode::RENDER_PASS_DEFERRED_OPAQUE || renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT;
|
||||||
|
|
||||||
|
if(true) {
|
||||||
|
//if(visibleBounds.find(octreeBounds) != visibleBounds.end()) {
|
||||||
|
if(can_occlusion_test) {
|
||||||
|
pOctreeNode->beginOcclusionQuery(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Occlusion test indicates that this bounding box was visible in the last frame
|
||||||
|
for(std::set<KRNode *>::iterator itr=pOctreeNode->getSceneNodes().begin(); itr != pOctreeNode->getSceneNodes().end(); itr++) {
|
||||||
|
//assert(pOctreeNode->getBounds().contains((*itr)->getBounds())); // Sanity check
|
||||||
|
|
||||||
|
(*itr)->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(can_occlusion_test) {
|
||||||
|
pOctreeNode->endOcclusionQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<8; i++) {
|
||||||
|
render(pOctreeNode->getChildren()[i], visibleBounds, pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
||||||
|
}
|
||||||
|
} else if(KRNode::RENDER_PASS_FORWARD_OPAQUE || renderPass == KRNode::RENDER_PASS_DEFERRED_OPAQUE) {
|
||||||
|
if(pOctreeNode->getSceneNodes().empty()) {
|
||||||
|
for(int i=0; i<8; i++) {
|
||||||
|
render(pOctreeNode->getChildren()[i], visibleBounds, pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pOctreeNode->beginOcclusionQuery(renderPass == KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
|
||||||
|
KRShader *pVisShader = m_pContext->getShaderManager()->getShader("occlusion_test", pCamera, false, false, false, 0, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
|
||||||
|
KRMat4 projectionMatrix = pCamera->getProjectionMatrix();
|
||||||
|
|
||||||
|
static const GLfloat cubeVertices[] = {
|
||||||
|
1.0, 1.0, 1.0,
|
||||||
|
-1.0, 1.0, 1.0,
|
||||||
|
1.0,-1.0, 1.0,
|
||||||
|
-1.0,-1.0, 1.0,
|
||||||
|
-1.0,-1.0,-1.0,
|
||||||
|
-1.0, 1.0, 1.0,
|
||||||
|
-1.0, 1.0,-1.0,
|
||||||
|
1.0, 1.0, 1.0,
|
||||||
|
1.0, 1.0,-1.0,
|
||||||
|
1.0,-1.0, 1.0,
|
||||||
|
1.0,-1.0,-1.0,
|
||||||
|
-1.0,-1.0,-1.0,
|
||||||
|
1.0, 1.0,-1.0,
|
||||||
|
-1.0, 1.0,-1.0
|
||||||
|
};
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glVertexAttribPointer(KRShader::KRENGINE_ATTRIB_VERTEX, 3, GL_FLOAT, 0, 0, cubeVertices);
|
||||||
|
glEnableVertexAttribArray(KRShader::KRENGINE_ATTRIB_VERTEX);
|
||||||
|
|
||||||
|
KRMat4 matModel = KRMat4();
|
||||||
|
matModel.scale(octreeBounds.size() / 2.0f);
|
||||||
|
matModel.translate(octreeBounds.center());
|
||||||
|
KRMat4 mvpmatrix = matModel * viewMatrix * projectionMatrix;
|
||||||
|
|
||||||
|
// Enable additive blending
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_ONE, GL_ONE);
|
||||||
|
|
||||||
|
|
||||||
|
pVisShader->bind(pCamera, viewMatrix, mvpmatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 14);
|
||||||
|
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
pOctreeNode->endOcclusionQuery();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Octree culled: (%f, %f, %f) - (%f, %f, %f)\n", pOctreeNode->getBounds().min.x, pOctreeNode->getBounds().min.y, pOctreeNode->getBounds().min.z, pOctreeNode->getBounds().max.x, pOctreeNode->getBounds().max.y, pOctreeNode->getBounds().max.z);
|
//fprintf(stderr, "Octree culled: (%f, %f, %f) - (%f, %f, %f)\n", pOctreeNode->getBounds().min.x, pOctreeNode->getBounds().min.y, pOctreeNode->getBounds().min.z, pOctreeNode->getBounds().max.x, pOctreeNode->getBounds().max.y, pOctreeNode->getBounds().max.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,16 +270,20 @@ KRDirectionalLight *KRScene::findFirstDirectionalLight(KRNode &node) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRScene *KRScene::LoadXML(KRContext &context, const std::string& path)
|
KRScene *KRScene::Load(KRContext &context, const std::string &name, KRDataBlock *data)
|
||||||
{
|
{
|
||||||
|
data->append((void *)"\0", 1); // Ensure data is null terminated, to read as a string safely
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
doc.LoadFile(path.c_str());
|
fprintf(stderr, "Scene Content: %s\n", data->getStart());
|
||||||
KRScene *new_scene = new KRScene(context, KRResource::GetFileBase(path));
|
doc.Parse((char *)data->getStart());
|
||||||
|
KRScene *new_scene = new KRScene(context, name);
|
||||||
|
|
||||||
KRNode *n = KRNode::LoadXML(*new_scene, doc.RootElement()->FirstChildElement());
|
KRNode *n = KRNode::LoadXML(*new_scene, doc.RootElement()->FirstChildElement());
|
||||||
if(n) {
|
if(n) {
|
||||||
new_scene->getRootNode()->addChild(n);
|
new_scene->getRootNode()->addChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete data;
|
||||||
return new_scene;
|
return new_scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public:
|
|||||||
virtual std::string getExtension();
|
virtual std::string getExtension();
|
||||||
virtual bool save(const std::string& path);
|
virtual bool save(const std::string& path);
|
||||||
|
|
||||||
static KRScene *LoadXML(KRContext &context, const std::string& path);
|
static KRScene *Load(KRContext &context, const std::string &name, KRDataBlock *data);
|
||||||
|
|
||||||
KRNode *getRootNode();
|
KRNode *getRootNode();
|
||||||
KRDirectionalLight *getFirstDirectionalLight();
|
KRDirectionalLight *getFirstDirectionalLight();
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ KRSceneManager::~KRSceneManager() {
|
|||||||
m_scenes.empty();
|
m_scenes.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRScene *KRSceneManager::loadScene(const char *szName, const char *szPath) {
|
KRScene *KRSceneManager::loadScene(const char *szName, KRDataBlock *data) {
|
||||||
KRScene *pScene = KRScene::LoadXML(*m_pContext, szPath);
|
KRScene *pScene = KRScene::Load(*m_pContext, szName, data);
|
||||||
m_scenes[szName] = pScene;
|
m_scenes[szName] = pScene;
|
||||||
return pScene;
|
return pScene;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#import "KREngine-common.h"
|
#import "KREngine-common.h"
|
||||||
#import "KRContextObject.h"
|
#import "KRContextObject.h"
|
||||||
|
#import "KRDataBlock.h"
|
||||||
|
|
||||||
class KRScene;
|
class KRScene;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ public:
|
|||||||
KRSceneManager(KRContext &context);
|
KRSceneManager(KRContext &context);
|
||||||
virtual ~KRSceneManager();
|
virtual ~KRSceneManager();
|
||||||
|
|
||||||
KRScene *loadScene(const char *szName, const char *szPath);
|
KRScene *loadScene(const char *szName, KRDataBlock *data);
|
||||||
|
|
||||||
KRScene *getScene(const char *szName);
|
KRScene *getScene(const char *szName);
|
||||||
KRScene *getFirstScene();
|
KRScene *getFirstScene();
|
||||||
|
|||||||
@@ -113,28 +113,14 @@ KRShader *KRShaderManager::getShader(std::string shader_name, KRCamera *pCamera,
|
|||||||
return pShader;
|
return pShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRShaderManager::loadFragmentShader(const std::string &name, const std::string &path) {
|
void KRShaderManager::loadFragmentShader(const std::string &name, KRDataBlock *data) {
|
||||||
ifstream ifs(path.c_str(), ios::in | ios::binary | ios::ate);
|
m_fragShaderSource[name] = string((char *)data->getStart(), data->getSize());
|
||||||
|
delete data;
|
||||||
ifstream::pos_type fileSize = ifs.tellg();
|
|
||||||
ifs.seekg(0, ios::beg);
|
|
||||||
|
|
||||||
vector<char> bytes(fileSize);
|
|
||||||
ifs.read(&bytes[0], fileSize);
|
|
||||||
|
|
||||||
m_fragShaderSource[name] = string(&bytes[0], fileSize);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void KRShaderManager::loadVertexShader(const std::string &name, const std::string &path) {
|
|
||||||
ifstream ifs(path.c_str(), ios::in | ios::binary | ios::ate);
|
|
||||||
|
|
||||||
ifstream::pos_type fileSize = ifs.tellg();
|
void KRShaderManager::loadVertexShader(const std::string &name, KRDataBlock *data) {
|
||||||
ifs.seekg(0, ios::beg);
|
m_vertShaderSource[name] = string((char *)data->getStart(), data->getSize());
|
||||||
|
delete data;
|
||||||
vector<char> bytes(fileSize);
|
|
||||||
ifs.read(&bytes[0], fileSize);
|
|
||||||
|
|
||||||
m_vertShaderSource[name] = string(&bytes[0], fileSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &KRShaderManager::getFragShaderSource(const std::string &name) {
|
const std::string &KRShaderManager::getFragShaderSource(const std::string &name) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#import <map>
|
#import <map>
|
||||||
#import <string>
|
#import <string>
|
||||||
#import "KRCamera.h"
|
#import "KRCamera.h"
|
||||||
|
#import "KRDataBlock.h"
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@@ -50,8 +51,8 @@ public:
|
|||||||
KRShaderManager(KRContext &context);
|
KRShaderManager(KRContext &context);
|
||||||
virtual ~KRShaderManager();
|
virtual ~KRShaderManager();
|
||||||
|
|
||||||
void loadFragmentShader(const std::string &name, const std::string &path);
|
void loadFragmentShader(const std::string &name, KRDataBlock *data);
|
||||||
void loadVertexShader(const std::string &name, const std::string &path);
|
void loadVertexShader(const std::string &name, KRDataBlock *data);
|
||||||
const std::string &getFragShaderSource(const std::string &name);
|
const std::string &getFragShaderSource(const std::string &name);
|
||||||
const std::string &getVertShaderSource(const std::string &name);
|
const std::string &getVertShaderSource(const std::string &name);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#import "KRContext.h"
|
#import "KRContext.h"
|
||||||
#import "KRMat4.h"
|
#import "KRMat4.h"
|
||||||
#import "KRResource.h"
|
#import "KRResource.h"
|
||||||
|
#import "KRContext.h"
|
||||||
|
|
||||||
KRSkyBox::KRSkyBox(KRScene &scene, std::string name) : KRNode(scene, name)
|
KRSkyBox::KRSkyBox(KRScene &scene, std::string name) : KRNode(scene, name)
|
||||||
{
|
{
|
||||||
@@ -138,13 +139,12 @@ void KRSkyBox::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &
|
|||||||
// KRShader *pShader = pContext->getShaderManager()->getShader("sky_box", pCamera, false, false, false, 0, false, false, false, false, false, false, false, false, renderPass);
|
// KRShader *pShader = pContext->getShaderManager()->getShader("sky_box", pCamera, false, false, false, 0, false, false, false, false, false, false, false, false, renderPass);
|
||||||
// pShader->bind(pCamera, matModelToView, mvpmatrix, cameraPosition, NULL, NULL, NULL, 0, renderPass);
|
// pShader->bind(pCamera, matModelToView, mvpmatrix, cameraPosition, NULL, NULL, NULL, 0, renderPass);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
m_pContext->getTextureManager()->selectTexture(0, m_pFrontTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_pFrontTexture->getName());
|
m_pContext->getTextureManager()->selectTexture(1, m_pBackTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_pBackTexture->getName());
|
m_pContext->getTextureManager()->selectTexture(2, m_pTopTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_pTopTexture->getName());
|
m_pContext->getTextureManager()->selectTexture(3, m_pBottomTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_pBottomTexture->getName());
|
m_pContext->getTextureManager()->selectTexture(4, m_pLeftTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_pLeftTexture->getName());
|
m_pContext->getTextureManager()->selectTexture(5, m_pRightTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_pRightTexture->getName());
|
|
||||||
|
|
||||||
// Disable z-buffer write
|
// Disable z-buffer write
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "KRTexture.h"
|
#include "KRTexture.h"
|
||||||
|
#include "KRTextureManager.h"
|
||||||
|
|
||||||
#import <stdint.h>
|
#import <stdint.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
@@ -68,117 +69,93 @@ typedef struct _PVRTexHeader
|
|||||||
uint32_t numSurfs;
|
uint32_t numSurfs;
|
||||||
} PVRTexHeader;
|
} PVRTexHeader;
|
||||||
|
|
||||||
KRTexture::KRTexture() {
|
KRTexture::KRTexture(KRDataBlock *data, KRTextureManager *manager) {
|
||||||
|
m_pData = data;
|
||||||
m_iName = 0;
|
m_iName = 0;
|
||||||
m_fdFile = 0;
|
m_pManager = manager;
|
||||||
m_pFile = NULL;
|
load();
|
||||||
m_fileSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRTexture::~KRTexture() {
|
KRTexture::~KRTexture() {
|
||||||
if(m_iName != 0) {
|
releaseHandle();
|
||||||
glDeleteTextures(1, &m_iName);
|
delete m_pData;
|
||||||
}
|
|
||||||
if(m_pFile != NULL) {
|
|
||||||
munmap(m_pFile, m_fileSize);
|
|
||||||
}
|
|
||||||
if(m_fdFile != 0) {
|
|
||||||
close(m_fdFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
bool KRTexture::loadFromFile(const char *szFile) {
|
bool KRTexture::load() {
|
||||||
struct stat statbuf;
|
|
||||||
m_fdFile = open(szFile, O_RDONLY);
|
PVRTexHeader *header = (PVRTexHeader *)m_pData->getStart();
|
||||||
if(m_fdFile < 0) {
|
uint32_t formatFlags = header->flags & PVR_TEXTURE_FLAG_TYPE_MASK;
|
||||||
return false;
|
if (formatFlags == kPVRTextureFlagTypePVRTC_4) {
|
||||||
|
m_internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
||||||
|
} else if(formatFlags == kPVRTextureFlagTypePVRTC_2) {
|
||||||
|
m_internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
|
||||||
} else {
|
} else {
|
||||||
if(fstat(m_fdFile,&statbuf) < 0) {
|
assert(false);
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
uint32_t pvrTag = header->pvrTag;
|
||||||
|
if (gPVRTexIdentifier[0] != ((pvrTag >> 0) & 0xff) ||
|
||||||
|
gPVRTexIdentifier[1] != ((pvrTag >> 8) & 0xff) ||
|
||||||
|
gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) ||
|
||||||
|
gPVRTexIdentifier[3] != ((pvrTag >> 24) & 0xff))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_iWidth = header->width; // Note: call __builtin_bswap32 when needed to switch endianness
|
||||||
|
m_iHeight = header->height;
|
||||||
|
m_bHasAlpha = header->bitmaskAlpha;
|
||||||
|
|
||||||
|
uint8_t *bytes = ((uint8_t *)m_pData->getStart()) + sizeof(PVRTexHeader);
|
||||||
|
uint32_t dataLength = header->dataLength, dataOffset = 0, dataSize = 0;
|
||||||
|
uint32_t width = m_iWidth, height = m_iHeight, bpp = 4;
|
||||||
|
uint32_t blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
||||||
|
|
||||||
|
// Calculate the data size for each texture level and respect the minimum number of blocks
|
||||||
|
while(dataOffset < dataLength) {
|
||||||
|
if (formatFlags == kPVRTextureFlagTypePVRTC_4) {
|
||||||
|
blockSize = 4 * 4; // Pixel by pixel block size for 4bpp
|
||||||
|
widthBlocks = width / 4;
|
||||||
|
heightBlocks = height / 4;
|
||||||
|
bpp = 4;
|
||||||
} else {
|
} else {
|
||||||
void *pFile;
|
blockSize = 8 * 4; // Pixel by pixel block size for 2bpp
|
||||||
if ((pFile = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, m_fdFile, 0))
|
widthBlocks = width / 8;
|
||||||
== (caddr_t) -1) {
|
heightBlocks = height / 4;
|
||||||
return false;
|
bpp = 2;
|
||||||
} else {
|
}
|
||||||
m_fileSize = statbuf.st_size;
|
|
||||||
m_pFile = pFile;
|
|
||||||
|
|
||||||
PVRTexHeader *header = (PVRTexHeader *)pFile;
|
// Clamp to minimum number of blocks
|
||||||
uint32_t formatFlags = header->flags & PVR_TEXTURE_FLAG_TYPE_MASK;
|
if (widthBlocks < 2) {
|
||||||
if (formatFlags == kPVRTextureFlagTypePVRTC_4) {
|
widthBlocks = 2;
|
||||||
m_internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
}
|
||||||
} else if(formatFlags == kPVRTextureFlagTypePVRTC_2) {
|
if (heightBlocks < 2) {
|
||||||
m_internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
|
heightBlocks = 2;
|
||||||
} else {
|
}
|
||||||
assert(false);
|
dataSize = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t pvrTag = header->pvrTag;
|
dataBlockStruct newBlock;
|
||||||
if (gPVRTexIdentifier[0] != ((pvrTag >> 0) & 0xff) ||
|
newBlock.start = bytes+dataOffset;
|
||||||
gPVRTexIdentifier[1] != ((pvrTag >> 8) & 0xff) ||
|
newBlock.length = dataSize;
|
||||||
gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) ||
|
|
||||||
gPVRTexIdentifier[3] != ((pvrTag >> 24) & 0xff))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_iWidth = header->width; // Note: call __builtin_bswap32 when needed to switch endianness
|
m_blocks.push_back(newBlock);
|
||||||
m_iHeight = header->height;
|
|
||||||
m_bHasAlpha = header->bitmaskAlpha;
|
|
||||||
|
|
||||||
uint8_t *bytes = ((uint8_t *)pFile) + sizeof(PVRTexHeader);
|
dataOffset += dataSize;
|
||||||
uint32_t dataLength = header->dataLength, dataOffset = 0, dataSize = 0;
|
|
||||||
uint32_t width = m_iWidth, height = m_iHeight, bpp = 4;
|
|
||||||
uint32_t blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
|
||||||
|
|
||||||
// Calculate the data size for each texture level and respect the minimum number of blocks
|
width = width >> 1;
|
||||||
while(dataOffset < dataLength) {
|
if(width < 1) {
|
||||||
if (formatFlags == kPVRTextureFlagTypePVRTC_4) {
|
width = 1;
|
||||||
blockSize = 4 * 4; // Pixel by pixel block size for 4bpp
|
}
|
||||||
widthBlocks = width / 4;
|
height = height >> 1;
|
||||||
heightBlocks = height / 4;
|
if(height < 1) {
|
||||||
bpp = 4;
|
height = 1;
|
||||||
} else {
|
|
||||||
blockSize = 8 * 4; // Pixel by pixel block size for 2bpp
|
|
||||||
widthBlocks = width / 8;
|
|
||||||
heightBlocks = height / 4;
|
|
||||||
bpp = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clamp to minimum number of blocks
|
|
||||||
if (widthBlocks < 2) {
|
|
||||||
widthBlocks = 2;
|
|
||||||
}
|
|
||||||
if (heightBlocks < 2) {
|
|
||||||
heightBlocks = 2;
|
|
||||||
}
|
|
||||||
dataSize = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
|
|
||||||
|
|
||||||
dataBlockStruct newBlock;
|
|
||||||
newBlock.start = bytes+dataOffset;
|
|
||||||
newBlock.length = dataSize;
|
|
||||||
|
|
||||||
m_blocks.push_back(newBlock);
|
|
||||||
|
|
||||||
dataOffset += dataSize;
|
|
||||||
|
|
||||||
width = width >> 1;
|
|
||||||
if(width < 1) {
|
|
||||||
width = 1;
|
|
||||||
}
|
|
||||||
height = height >> 1;
|
|
||||||
if(height < 1) {
|
|
||||||
height = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -228,9 +205,20 @@ bool KRTexture::createGLTexture() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLuint KRTexture::getName() {
|
GLuint KRTexture::getHandle() {
|
||||||
if(m_iName == 0) {
|
if(m_iName == 0) {
|
||||||
|
if(!createGLTexture()) {
|
||||||
|
createGLTexture(); // FINDME - HACK! The first texture fails with 0x501 return code but loads on second try
|
||||||
|
}
|
||||||
|
|
||||||
createGLTexture();
|
createGLTexture();
|
||||||
}
|
}
|
||||||
return m_iName;
|
return m_iName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRTexture::releaseHandle() {
|
||||||
|
if(m_iName != 0) {
|
||||||
|
glDeleteTextures(1, &m_iName);
|
||||||
|
m_iName = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,24 +34,23 @@
|
|||||||
#import <string>
|
#import <string>
|
||||||
|
|
||||||
#import "KREngine-common.h"
|
#import "KREngine-common.h"
|
||||||
|
#import "KRDataBlock.h"
|
||||||
|
|
||||||
using std::list;
|
using std::list;
|
||||||
|
|
||||||
#ifndef KRTEXTURE_H
|
#ifndef KRTEXTURE_H
|
||||||
#define KRTEXTURE_H
|
#define KRTEXTURE_H
|
||||||
|
|
||||||
|
class KRTextureManager;
|
||||||
|
|
||||||
class KRTexture {
|
class KRTexture {
|
||||||
public:
|
public:
|
||||||
KRTexture();
|
KRTexture(KRDataBlock *data, KRTextureManager *manager);
|
||||||
~KRTexture();
|
~KRTexture();
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
|
||||||
|
|
||||||
bool loadFromFile(const char *szFile);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
bool createGLTexture();
|
bool createGLTexture();
|
||||||
GLuint getName();
|
GLuint getHandle();
|
||||||
|
void releaseHandle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -68,9 +67,11 @@ private:
|
|||||||
|
|
||||||
std::list<dataBlockStruct> m_blocks;
|
std::list<dataBlockStruct> m_blocks;
|
||||||
|
|
||||||
int m_fdFile;
|
KRDataBlock *m_pData;
|
||||||
int m_fileSize;
|
|
||||||
void *m_pFile;
|
bool load();
|
||||||
|
|
||||||
|
KRTextureManager *m_pManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -33,7 +33,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
KRTextureManager::KRTextureManager(KRContext &context) : KRContextObject(context) {
|
KRTextureManager::KRTextureManager(KRContext &context) : KRContextObject(context) {
|
||||||
|
for(int iTexture=0; iTexture<KRENGINE_MAX_TEXTURE_UNITS; iTexture++) {
|
||||||
|
m_activeTextures[iTexture] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KRTextureManager::~KRTextureManager() {
|
KRTextureManager::~KRTextureManager() {
|
||||||
@@ -44,19 +46,8 @@ KRTextureManager::~KRTextureManager() {
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
KRTexture *KRTextureManager::loadTexture(const char *szName, const char *szPath) {
|
KRTexture *KRTextureManager::loadTexture(const char *szName, KRDataBlock *data) {
|
||||||
KRTexture *pTexture = new KRTexture();
|
KRTexture *pTexture = new KRTexture(data, this);
|
||||||
if(!pTexture->loadFromFile(szPath)) {
|
|
||||||
delete pTexture;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!pTexture->createGLTexture()) {
|
|
||||||
if(!pTexture->createGLTexture()) { // FINDME - HACK! The first texture fails with 0x501 return code but loads on second try
|
|
||||||
delete pTexture;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string lowerName = szName;
|
std::string lowerName = szName;
|
||||||
std::transform(lowerName.begin(), lowerName.end(),
|
std::transform(lowerName.begin(), lowerName.end(),
|
||||||
@@ -70,15 +61,6 @@ KRTexture *KRTextureManager::loadTexture(const char *szName, const char *szPath)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GLuint KRTextureManager::getTextureName(const char *szName) {
|
|
||||||
KRTexture *pTexture = getTexture(szName);
|
|
||||||
if(pTexture) {
|
|
||||||
return pTexture->getName();
|
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
KRTexture *KRTextureManager::getTexture(const char *szName) {
|
KRTexture *KRTextureManager::getTexture(const char *szName) {
|
||||||
std::string lowerName = szName;
|
std::string lowerName = szName;
|
||||||
std::transform(lowerName.begin(), lowerName.end(),
|
std::transform(lowerName.begin(), lowerName.end(),
|
||||||
@@ -93,3 +75,43 @@ KRTexture *KRTextureManager::getTexture(const char *szName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRTextureManager::selectTexture(int iTextureUnit, KRTexture *pTexture) {
|
||||||
|
if(m_activeTextures[iTextureUnit] != pTexture) {
|
||||||
|
glActiveTexture(GL_TEXTURE0 + iTextureUnit);
|
||||||
|
if(pTexture != NULL) {
|
||||||
|
m_textureCache.erase(pTexture); // Ensure that the texture will not be deleted while it is bound to a texture unit, and return it to the top of the texture cache when it is released
|
||||||
|
glBindTexture(GL_TEXTURE_2D, pTexture->getHandle());
|
||||||
|
// TODO - These texture parameters should be assigned by the material or texture parameters
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
} else {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
}
|
||||||
|
if(m_activeTextures[iTextureUnit] != NULL) {
|
||||||
|
KRTexture *unloadedTexture = m_activeTextures[iTextureUnit];
|
||||||
|
bool bActive = false;
|
||||||
|
for(int iTexture=0; iTexture < KRENGINE_MAX_TEXTURE_UNITS; iTexture++) {
|
||||||
|
if(m_activeTextures[iTexture] == unloadedTexture) {
|
||||||
|
bActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!bActive) {
|
||||||
|
// Only return a texture to the cache when the last texture unit referencing it is re-assigned to a different texture
|
||||||
|
if(m_textureCache.find(unloadedTexture) == m_textureCache.end()) {
|
||||||
|
m_textureCache.insert(unloadedTexture);
|
||||||
|
while(m_textureCache.size() > KRENGINE_MAX_TEXTURE_HANDLES) {
|
||||||
|
// Keep texture size within limits
|
||||||
|
KRTexture *droppedTexture = (*m_textureCache.begin());
|
||||||
|
droppedTexture->releaseHandle();
|
||||||
|
m_textureCache.erase(droppedTexture);
|
||||||
|
fprintf(stderr, "Texture Swapping...\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_activeTextures[iTextureUnit] = pTexture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#define KRENGINE_MAX_TEXTURE_UNITS 8
|
||||||
|
#define KRENGINE_MAX_TEXTURE_HANDLES 20
|
||||||
|
|
||||||
#ifndef KRTEXTUREMANAGER_H
|
#ifndef KRTEXTUREMANAGER_H
|
||||||
#define KRTEXTUREMANAGER_H
|
#define KRTEXTUREMANAGER_H
|
||||||
|
|
||||||
@@ -45,17 +48,21 @@ public:
|
|||||||
KRTextureManager(KRContext &context);
|
KRTextureManager(KRContext &context);
|
||||||
virtual ~KRTextureManager();
|
virtual ~KRTextureManager();
|
||||||
|
|
||||||
|
void selectTexture(int iTextureUnit, KRTexture *pTexture);
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
KRTexture *loadTexture(const char *szName, const char *szPath);
|
KRTexture *loadTexture(const char *szName, KRDataBlock *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GLuint getTextureName(const char *szName);
|
|
||||||
KRTexture *getTexture(const char *szFile);
|
KRTexture *getTexture(const char *szFile);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, KRTexture *> m_textures;
|
std::map<std::string, KRTexture *> m_textures;
|
||||||
|
|
||||||
|
KRTexture *m_activeTextures[KRENGINE_MAX_TEXTURE_UNITS];
|
||||||
|
std::set<KRTexture *> m_textureCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
34
KREngine/KREngine/Shaders/occlusion_test.fsh
Normal file
34
KREngine/KREngine/Shaders/occlusion_test.fsh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// flare.fsh
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
// provided with the distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
// or implied, of Kearwood Gilbert.
|
||||||
|
//
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_FragColor = vec4(0.00, 0.00, 0.00, 0.00);
|
||||||
|
}
|
||||||
34
KREngine/KREngine/Shaders/occlusion_test.vsh
Normal file
34
KREngine/KREngine/Shaders/occlusion_test.vsh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
// permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
// conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
// provided with the distribution.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// The views and conclusions contained in the software and documentation are those of the
|
||||||
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
// or implied, of Kearwood Gilbert.
|
||||||
|
//
|
||||||
|
|
||||||
|
attribute vec4 vertex_position;
|
||||||
|
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = mvp_matrix * vertex_position;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// flare.fsh
|
// visualize_overlay.fsh
|
||||||
// KREngine
|
// KREngine
|
||||||
//
|
//
|
||||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
@@ -32,3 +32,4 @@
|
|||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = vec4(0.0, 0.05, 0.05, 0.0);
|
gl_FragColor = vec4(0.0, 0.05, 0.05, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
//
|
||||||
|
// visualize_overlay.vsh
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
// Copyright 2012 Kearwood Gilbert. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
// Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
28D7ACF80DDB3853001CB0EB /* KRObjViewViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* KRObjViewViewController.mm */; };
|
28D7ACF80DDB3853001CB0EB /* KRObjViewViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* KRObjViewViewController.mm */; };
|
||||||
E40611D714E4E98B0065996A /* README.txt in Resources */ = {isa = PBXBuildFile; fileRef = E40611D314E4E98B0065996A /* README.txt */; };
|
E40611D714E4E98B0065996A /* README.txt in Resources */ = {isa = PBXBuildFile; fileRef = E40611D314E4E98B0065996A /* README.txt */; };
|
||||||
E40611D814E4E98B0065996A /* release_notes.txt in Resources */ = {isa = PBXBuildFile; fileRef = E40611D414E4E98B0065996A /* release_notes.txt */; };
|
E40611D814E4E98B0065996A /* release_notes.txt in Resources */ = {isa = PBXBuildFile; fileRef = E40611D414E4E98B0065996A /* release_notes.txt */; };
|
||||||
|
E430D08615F88A9F0010558D /* occlusion_test.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E430D08515F88A9F0010558D /* occlusion_test.fsh */; };
|
||||||
|
E430D08B15F88B950010558D /* occlusion_test.vsh in Sources */ = {isa = PBXBuildFile; fileRef = E430D08A15F88B950010558D /* occlusion_test.vsh */; };
|
||||||
|
E430D08C15F88BC50010558D /* occlusion_test.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E430D08A15F88B950010558D /* occlusion_test.vsh */; };
|
||||||
|
E430D08D15F88BC70010558D /* occlusion_test.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E430D08515F88A9F0010558D /* occlusion_test.fsh */; };
|
||||||
E43A7A6E13CA2BA2000A565E /* libKREngine.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E43A7A6D13CA2BA2000A565E /* libKREngine.a */; };
|
E43A7A6E13CA2BA2000A565E /* libKREngine.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E43A7A6D13CA2BA2000A565E /* libKREngine.a */; };
|
||||||
E46DBE831512B7C300D59F86 /* libTestFlight.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E40611D214E4E98B0065996A /* libTestFlight.a */; };
|
E46DBE831512B7C300D59F86 /* libTestFlight.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E40611D214E4E98B0065996A /* libTestFlight.a */; };
|
||||||
E46FED2D13C9A49F009F5814 /* ShadowShader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E46FED2113C9A488009F5814 /* ShadowShader.vsh */; };
|
E46FED2D13C9A49F009F5814 /* ShadowShader.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E46FED2113C9A488009F5814 /* ShadowShader.vsh */; };
|
||||||
@@ -32,7 +36,8 @@
|
|||||||
E4769DF3158A7915004B83AC /* flare.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4769DF1158A7915004B83AC /* flare.fsh */; };
|
E4769DF3158A7915004B83AC /* flare.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4769DF1158A7915004B83AC /* flare.fsh */; };
|
||||||
E4769DF4158A7915004B83AC /* flare.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4769DF2158A7915004B83AC /* flare.vsh */; };
|
E4769DF4158A7915004B83AC /* flare.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4769DF2158A7915004B83AC /* flare.vsh */; };
|
||||||
E48278B415F037B9001C9431 /* visualize_overlay.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E48278B215F037B9001C9431 /* visualize_overlay.vsh */; };
|
E48278B415F037B9001C9431 /* visualize_overlay.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E48278B215F037B9001C9431 /* visualize_overlay.vsh */; };
|
||||||
E48278B515F037B9001C9431 /* visualize_overlay.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E48278B315F037B9001C9431 /* visualize_overlay.fsh */; };
|
E48839A415F92C6900BD66D5 /* visualize_overlay.fsh in Sources */ = {isa = PBXBuildFile; fileRef = E48839A315F92C6900BD66D5 /* visualize_overlay.fsh */; };
|
||||||
|
E48839A515F92C8D00BD66D5 /* visualize_overlay.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E48839A315F92C6900BD66D5 /* visualize_overlay.fsh */; };
|
||||||
E49EB29C13806C5D00A4E727 /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = E49EB29B13806C5D00A4E727 /* MainWindow-iPad.xib */; };
|
E49EB29C13806C5D00A4E727 /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = E49EB29B13806C5D00A4E727 /* MainWindow-iPad.xib */; };
|
||||||
E4A9DEC715412923009DF363 /* light_point.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4A9DEC2154128F0009DF363 /* light_point.fsh */; };
|
E4A9DEC715412923009DF363 /* light_point.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4A9DEC2154128F0009DF363 /* light_point.fsh */; };
|
||||||
E4A9DEC815412923009DF363 /* light_point.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4A9DEC515412906009DF363 /* light_point.vsh */; };
|
E4A9DEC815412923009DF363 /* light_point.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4A9DEC515412906009DF363 /* light_point.vsh */; };
|
||||||
@@ -63,6 +68,8 @@
|
|||||||
E40611D314E4E98B0065996A /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = "<group>"; };
|
E40611D314E4E98B0065996A /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = "<group>"; };
|
||||||
E40611D414E4E98B0065996A /* release_notes.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = release_notes.txt; sourceTree = "<group>"; };
|
E40611D414E4E98B0065996A /* release_notes.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = release_notes.txt; sourceTree = "<group>"; };
|
||||||
E40611D514E4E98B0065996A /* TestFlight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = TestFlight.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E40611D514E4E98B0065996A /* TestFlight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = TestFlight.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
|
E430D08515F88A9F0010558D /* occlusion_test.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = occlusion_test.fsh; path = ../KREngine/KREngine/Shaders/occlusion_test.fsh; sourceTree = "<group>"; };
|
||||||
|
E430D08A15F88B950010558D /* occlusion_test.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = occlusion_test.vsh; path = ../KREngine/KREngine/Shaders/occlusion_test.vsh; sourceTree = "<group>"; };
|
||||||
E43A7A6D13CA2BA2000A565E /* libKREngine.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libKREngine.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
E43A7A6D13CA2BA2000A565E /* libKREngine.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libKREngine.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E46FED2113C9A488009F5814 /* ShadowShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; lineEnding = 0; name = ShadowShader.vsh; path = ../KREngine/KREngine/Shaders/ShadowShader.vsh; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.glsl; };
|
E46FED2113C9A488009F5814 /* ShadowShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; lineEnding = 0; name = ShadowShader.vsh; path = ../KREngine/KREngine/Shaders/ShadowShader.vsh; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.glsl; };
|
||||||
E46FED2213C9A488009F5814 /* ShadowShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = ShadowShader.fsh; path = ../KREngine/KREngine/Shaders/ShadowShader.fsh; sourceTree = "<group>"; };
|
E46FED2213C9A488009F5814 /* ShadowShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = ShadowShader.fsh; path = ../KREngine/KREngine/Shaders/ShadowShader.fsh; sourceTree = "<group>"; };
|
||||||
@@ -72,8 +79,8 @@
|
|||||||
E46FED2613C9A488009F5814 /* PostShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = PostShader.vsh; path = ../KREngine/KREngine/Shaders/PostShader.vsh; sourceTree = "<group>"; };
|
E46FED2613C9A488009F5814 /* PostShader.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = PostShader.vsh; path = ../KREngine/KREngine/Shaders/PostShader.vsh; sourceTree = "<group>"; };
|
||||||
E4769DF1158A7915004B83AC /* flare.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = flare.fsh; path = ../KREngine/KREngine/Shaders/flare.fsh; sourceTree = "<group>"; };
|
E4769DF1158A7915004B83AC /* flare.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = flare.fsh; path = ../KREngine/KREngine/Shaders/flare.fsh; sourceTree = "<group>"; };
|
||||||
E4769DF2158A7915004B83AC /* flare.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = flare.vsh; path = ../KREngine/KREngine/Shaders/flare.vsh; sourceTree = "<group>"; };
|
E4769DF2158A7915004B83AC /* flare.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = flare.vsh; path = ../KREngine/KREngine/Shaders/flare.vsh; sourceTree = "<group>"; };
|
||||||
E48278B215F037B9001C9431 /* visualize_overlay.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; name = visualize_overlay.vsh; path = ../KREngine/KREngine/Shaders/visualize_overlay.vsh; sourceTree = "<group>"; };
|
E48278B215F037B9001C9431 /* visualize_overlay.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = visualize_overlay.vsh; path = ../KREngine/KREngine/Shaders/visualize_overlay.vsh; sourceTree = "<group>"; };
|
||||||
E48278B315F037B9001C9431 /* visualize_overlay.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; name = visualize_overlay.fsh; path = ../KREngine/KREngine/visualize_overlay.fsh; sourceTree = "<group>"; };
|
E48839A315F92C6900BD66D5 /* visualize_overlay.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = visualize_overlay.fsh; path = ../KREngine/KREngine/Shaders/visualize_overlay.fsh; sourceTree = "<group>"; };
|
||||||
E49EB29B13806C5D00A4E727 /* MainWindow-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MainWindow-iPad.xib"; path = "iPad/MainWindow-iPad.xib"; sourceTree = "<group>"; };
|
E49EB29B13806C5D00A4E727 /* MainWindow-iPad.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = "MainWindow-iPad.xib"; path = "iPad/MainWindow-iPad.xib"; sourceTree = "<group>"; };
|
||||||
E4A9DEC2154128F0009DF363 /* light_point.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = light_point.fsh; path = ../KREngine/KREngine/Shaders/light_point.fsh; sourceTree = "<group>"; };
|
E4A9DEC2154128F0009DF363 /* light_point.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = light_point.fsh; path = ../KREngine/KREngine/Shaders/light_point.fsh; sourceTree = "<group>"; };
|
||||||
E4A9DEC515412906009DF363 /* light_point.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = light_point.vsh; path = ../KREngine/KREngine/Shaders/light_point.vsh; sourceTree = "<group>"; };
|
E4A9DEC515412906009DF363 /* light_point.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = light_point.vsh; path = ../KREngine/KREngine/Shaders/light_point.vsh; sourceTree = "<group>"; };
|
||||||
@@ -192,8 +199,10 @@
|
|||||||
E46FED2013C9A472009F5814 /* Shaders */ = {
|
E46FED2013C9A472009F5814 /* Shaders */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
E48839A315F92C6900BD66D5 /* visualize_overlay.fsh */,
|
||||||
|
E430D08A15F88B950010558D /* occlusion_test.vsh */,
|
||||||
|
E430D08515F88A9F0010558D /* occlusion_test.fsh */,
|
||||||
E48278B215F037B9001C9431 /* visualize_overlay.vsh */,
|
E48278B215F037B9001C9431 /* visualize_overlay.vsh */,
|
||||||
E48278B315F037B9001C9431 /* visualize_overlay.fsh */,
|
|
||||||
E4769DF1158A7915004B83AC /* flare.fsh */,
|
E4769DF1158A7915004B83AC /* flare.fsh */,
|
||||||
E4769DF2158A7915004B83AC /* flare.vsh */,
|
E4769DF2158A7915004B83AC /* flare.vsh */,
|
||||||
E4A9DEC2154128F0009DF363 /* light_point.fsh */,
|
E4A9DEC2154128F0009DF363 /* light_point.fsh */,
|
||||||
@@ -279,6 +288,7 @@
|
|||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
E48839A515F92C8D00BD66D5 /* visualize_overlay.fsh in Resources */,
|
||||||
E4769DF3158A7915004B83AC /* flare.fsh in Resources */,
|
E4769DF3158A7915004B83AC /* flare.fsh in Resources */,
|
||||||
E4769DF4158A7915004B83AC /* flare.vsh in Resources */,
|
E4769DF4158A7915004B83AC /* flare.vsh in Resources */,
|
||||||
E4A9DEC715412923009DF363 /* light_point.fsh in Resources */,
|
E4A9DEC715412923009DF363 /* light_point.fsh in Resources */,
|
||||||
@@ -292,7 +302,8 @@
|
|||||||
E46FED3113C9A49F009F5814 /* ObjectShader.vsh in Resources */,
|
E46FED3113C9A49F009F5814 /* ObjectShader.vsh in Resources */,
|
||||||
E46FED3213C9A49F009F5814 /* PostShader.vsh in Resources */,
|
E46FED3213C9A49F009F5814 /* PostShader.vsh in Resources */,
|
||||||
E48278B415F037B9001C9431 /* visualize_overlay.vsh in Resources */,
|
E48278B415F037B9001C9431 /* visualize_overlay.vsh in Resources */,
|
||||||
E48278B515F037B9001C9431 /* visualize_overlay.fsh in Resources */,
|
E430D08C15F88BC50010558D /* occlusion_test.vsh in Resources */,
|
||||||
|
E430D08D15F88BC70010558D /* occlusion_test.fsh in Resources */,
|
||||||
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */,
|
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */,
|
||||||
E49EB29C13806C5D00A4E727 /* MainWindow-iPad.xib in Resources */,
|
E49EB29C13806C5D00A4E727 /* MainWindow-iPad.xib in Resources */,
|
||||||
E40611D714E4E98B0065996A /* README.txt in Resources */,
|
E40611D714E4E98B0065996A /* README.txt in Resources */,
|
||||||
@@ -311,6 +322,9 @@
|
|||||||
1D3623260D0F684500981E51 /* KRObjViewAppDelegate.mm in Sources */,
|
1D3623260D0F684500981E51 /* KRObjViewAppDelegate.mm in Sources */,
|
||||||
28D7ACF80DDB3853001CB0EB /* KRObjViewViewController.mm in Sources */,
|
28D7ACF80DDB3853001CB0EB /* KRObjViewViewController.mm in Sources */,
|
||||||
1063FC77136D6A1B00EE555B /* KRObjViewGLView.mm in Sources */,
|
1063FC77136D6A1B00EE555B /* KRObjViewGLView.mm in Sources */,
|
||||||
|
E430D08615F88A9F0010558D /* occlusion_test.fsh in Sources */,
|
||||||
|
E430D08B15F88B950010558D /* occlusion_test.vsh in Sources */,
|
||||||
|
E48839A415F92C6900BD66D5 /* visualize_overlay.fsh in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user