Merge
This commit is contained in:
@@ -16,6 +16,14 @@
|
|||||||
E40BA45515EFF79500D7C3DD /* KRAABB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E40BA45215EFF79500D7C3DD /* KRAABB.cpp */; };
|
E40BA45515EFF79500D7C3DD /* KRAABB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E40BA45215EFF79500D7C3DD /* KRAABB.cpp */; };
|
||||||
E40BA45615EFF79500D7C3DD /* KRAABB.h in Headers */ = {isa = PBXBuildFile; fileRef = E40BA45315EFF79500D7C3DD /* KRAABB.h */; settings = {ATTRIBUTES = (); }; };
|
E40BA45615EFF79500D7C3DD /* KRAABB.h in Headers */ = {isa = PBXBuildFile; fileRef = E40BA45315EFF79500D7C3DD /* KRAABB.h */; settings = {ATTRIBUTES = (); }; };
|
||||||
E40BA45715EFF79500D7C3DD /* KRAABB.h in Headers */ = {isa = PBXBuildFile; fileRef = E40BA45315EFF79500D7C3DD /* KRAABB.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E40BA45715EFF79500D7C3DD /* KRAABB.h in Headers */ = {isa = PBXBuildFile; fileRef = E40BA45315EFF79500D7C3DD /* KRAABB.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
E40F982C184A7A2700CFA4D8 /* KRMeshQuad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E40F982A184A7A2700CFA4D8 /* KRMeshQuad.cpp */; };
|
||||||
|
E40F982D184A7A2700CFA4D8 /* KRMeshQuad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E40F982A184A7A2700CFA4D8 /* KRMeshQuad.cpp */; };
|
||||||
|
E40F982E184A7A2700CFA4D8 /* KRMeshQuad.h in Headers */ = {isa = PBXBuildFile; fileRef = E40F982B184A7A2700CFA4D8 /* KRMeshQuad.h */; };
|
||||||
|
E40F982F184A7A2700CFA4D8 /* KRMeshQuad.h in Headers */ = {isa = PBXBuildFile; fileRef = E40F982B184A7A2700CFA4D8 /* KRMeshQuad.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
E40F9832184A7BAC00CFA4D8 /* KRSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E40F9830184A7BAC00CFA4D8 /* KRSprite.cpp */; };
|
||||||
|
E40F9833184A7BAC00CFA4D8 /* KRSprite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E40F9830184A7BAC00CFA4D8 /* KRSprite.cpp */; };
|
||||||
|
E40F9834184A7BAC00CFA4D8 /* KRSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = E40F9831184A7BAC00CFA4D8 /* KRSprite.h */; };
|
||||||
|
E40F9835184A7BAC00CFA4D8 /* KRSprite.h in Headers */ = {isa = PBXBuildFile; fileRef = E40F9831184A7BAC00CFA4D8 /* KRSprite.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E414BAE21435557300A668C4 /* KRModel.h in Headers */ = {isa = PBXBuildFile; fileRef = E414BAE11435557300A668C4 /* KRModel.h */; settings = {ATTRIBUTES = (); }; };
|
E414BAE21435557300A668C4 /* KRModel.h in Headers */ = {isa = PBXBuildFile; fileRef = E414BAE11435557300A668C4 /* KRModel.h */; settings = {ATTRIBUTES = (); }; };
|
||||||
E414BAE51435558900A668C4 /* KRModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E414BAE41435558800A668C4 /* KRModel.cpp */; };
|
E414BAE51435558900A668C4 /* KRModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E414BAE41435558800A668C4 /* KRModel.cpp */; };
|
||||||
E414BAE7143557D200A668C4 /* KRScene.h in Headers */ = {isa = PBXBuildFile; fileRef = E414BAE6143557D200A668C4 /* KRScene.h */; settings = {ATTRIBUTES = (); }; };
|
E414BAE7143557D200A668C4 /* KRScene.h in Headers */ = {isa = PBXBuildFile; fileRef = E414BAE6143557D200A668C4 /* KRScene.h */; settings = {ATTRIBUTES = (); }; };
|
||||||
@@ -73,6 +81,18 @@
|
|||||||
E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; };
|
E43B0AD715DDCA0F00A5CB9F /* KRContextObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */; };
|
||||||
E43B0AD815DDCA0F00A5CB9F /* KRContextObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */; settings = {ATTRIBUTES = (); }; };
|
E43B0AD815DDCA0F00A5CB9F /* KRContextObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */; settings = {ATTRIBUTES = (); }; };
|
||||||
E43B0AD915DDCA0F00A5CB9F /* KRContextObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E43B0AD915DDCA0F00A5CB9F /* KRContextObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
E43F70DC181B20E400136169 /* KRLODSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43F70DA181B20E300136169 /* KRLODSet.cpp */; };
|
||||||
|
E43F70DD181B20E400136169 /* KRLODSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43F70DA181B20E300136169 /* KRLODSet.cpp */; };
|
||||||
|
E43F70DE181B20E400136169 /* KRLODSet.h in Headers */ = {isa = PBXBuildFile; fileRef = E43F70DB181B20E400136169 /* KRLODSet.h */; };
|
||||||
|
E43F70DF181B20E400136169 /* KRLODSet.h in Headers */ = {isa = PBXBuildFile; fileRef = E43F70DB181B20E400136169 /* KRLODSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
E43F70E51824D9AB00136169 /* KRTextureStreamer.mm in Sources */ = {isa = PBXBuildFile; fileRef = E43F70E31824D9AB00136169 /* KRTextureStreamer.mm */; };
|
||||||
|
E43F70E61824D9AB00136169 /* KRTextureStreamer.mm in Sources */ = {isa = PBXBuildFile; fileRef = E43F70E31824D9AB00136169 /* KRTextureStreamer.mm */; };
|
||||||
|
E43F70E71824D9AB00136169 /* KRTextureStreamer.h in Headers */ = {isa = PBXBuildFile; fileRef = E43F70E41824D9AB00136169 /* KRTextureStreamer.h */; };
|
||||||
|
E43F70E81824D9AB00136169 /* KRTextureStreamer.h in Headers */ = {isa = PBXBuildFile; fileRef = E43F70E41824D9AB00136169 /* KRTextureStreamer.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
E43F70FF1824E73100136169 /* KRMeshStreamer.mm in Sources */ = {isa = PBXBuildFile; fileRef = E43F70FD1824E73100136169 /* KRMeshStreamer.mm */; };
|
||||||
|
E43F71001824E73100136169 /* KRMeshStreamer.mm in Sources */ = {isa = PBXBuildFile; fileRef = E43F70FD1824E73100136169 /* KRMeshStreamer.mm */; };
|
||||||
|
E43F71011824E73100136169 /* KRMeshStreamer.h in Headers */ = {isa = PBXBuildFile; fileRef = E43F70FE1824E73100136169 /* KRMeshStreamer.h */; };
|
||||||
|
E43F71021824E73100136169 /* KRMeshStreamer.h in Headers */ = {isa = PBXBuildFile; fileRef = E43F70FE1824E73100136169 /* KRMeshStreamer.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E4409D2916FA748700310F76 /* font.tga in Resources */ = {isa = PBXBuildFile; fileRef = E41AE1DD16B124CA00980428 /* font.tga */; };
|
E4409D2916FA748700310F76 /* font.tga in Resources */ = {isa = PBXBuildFile; fileRef = E41AE1DD16B124CA00980428 /* font.tga */; };
|
||||||
E44F38241683B23000399B5D /* KRRenderSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = E44F38231683B22C00399B5D /* KRRenderSettings.h */; settings = {ATTRIBUTES = (); }; };
|
E44F38241683B23000399B5D /* KRRenderSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = E44F38231683B22C00399B5D /* KRRenderSettings.h */; settings = {ATTRIBUTES = (); }; };
|
||||||
E44F38251683B23000399B5D /* KRRenderSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = E44F38231683B22C00399B5D /* KRRenderSettings.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E44F38251683B23000399B5D /* KRRenderSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = E44F38231683B22C00399B5D /* KRRenderSettings.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
@@ -90,7 +110,7 @@
|
|||||||
E459040616C30CD9002B00A0 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E459040516C30CD9002B00A0 /* AudioUnit.framework */; };
|
E459040616C30CD9002B00A0 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E459040516C30CD9002B00A0 /* AudioUnit.framework */; };
|
||||||
E460292616681CFF00261BB9 /* KRTextureAnimated.h in Headers */ = {isa = PBXBuildFile; fileRef = E460292516681CFE00261BB9 /* KRTextureAnimated.h */; settings = {ATTRIBUTES = (); }; };
|
E460292616681CFF00261BB9 /* KRTextureAnimated.h in Headers */ = {isa = PBXBuildFile; fileRef = E460292516681CFE00261BB9 /* KRTextureAnimated.h */; settings = {ATTRIBUTES = (); }; };
|
||||||
E460292816681D1000261BB9 /* KRTextureAnimated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E460292716681D1000261BB9 /* KRTextureAnimated.cpp */; };
|
E460292816681D1000261BB9 /* KRTextureAnimated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E460292716681D1000261BB9 /* KRTextureAnimated.cpp */; };
|
||||||
E460292B16682BF700261BB9 /* libfbxsdk-2013.3-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E460292916682BD900261BB9 /* libfbxsdk-2013.3-static.a */; };
|
E460292B16682BF700261BB9 /* libfbxsdk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E460292916682BD900261BB9 /* libfbxsdk.a */; };
|
||||||
E460292C166834AB00261BB9 /* KRTextureAnimated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E460292716681D1000261BB9 /* KRTextureAnimated.cpp */; };
|
E460292C166834AB00261BB9 /* KRTextureAnimated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E460292716681D1000261BB9 /* KRTextureAnimated.cpp */; };
|
||||||
E461A152152E54B500F2044A /* KRLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A151152E54B500F2044A /* KRLight.h */; settings = {ATTRIBUTES = (); }; };
|
E461A152152E54B500F2044A /* KRLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A151152E54B500F2044A /* KRLight.h */; settings = {ATTRIBUTES = (); }; };
|
||||||
E461A153152E54B500F2044A /* KRLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A151152E54B500F2044A /* KRLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E461A153152E54B500F2044A /* KRLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A151152E54B500F2044A /* KRLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
@@ -109,6 +129,10 @@
|
|||||||
E461A176152E5C5600F2044A /* KRPointLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A157152E555400F2044A /* KRPointLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E461A176152E5C5600F2044A /* KRPointLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A157152E555400F2044A /* KRPointLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E461A177152E5C6600F2044A /* KRMat4.h in Headers */ = {isa = PBXBuildFile; fileRef = E491017613C99BDC0098455B /* KRMat4.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E461A177152E5C6600F2044A /* KRMat4.h in Headers */ = {isa = PBXBuildFile; fileRef = E491017613C99BDC0098455B /* KRMat4.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E461A17A152E5C9100F2044A /* KRMat4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017713C99BDC0098455B /* KRMat4.cpp */; };
|
E461A17A152E5C9100F2044A /* KRMat4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017713C99BDC0098455B /* KRMat4.cpp */; };
|
||||||
|
E468447F17FFDF51001F1FA1 /* KRLocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E468447D17FFDF51001F1FA1 /* KRLocator.cpp */; };
|
||||||
|
E468448017FFDF51001F1FA1 /* KRLocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E468447D17FFDF51001F1FA1 /* KRLocator.cpp */; };
|
||||||
|
E468448117FFDF51001F1FA1 /* KRLocator.h in Headers */ = {isa = PBXBuildFile; fileRef = E468447E17FFDF51001F1FA1 /* KRLocator.h */; };
|
||||||
|
E468448217FFDF51001F1FA1 /* KRLocator.h in Headers */ = {isa = PBXBuildFile; fileRef = E468447E17FFDF51001F1FA1 /* KRLocator.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E46A6B6D1559E97D000DBD37 /* KRResource+blend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46A6B6C1559E97D000DBD37 /* KRResource+blend.cpp */; };
|
E46A6B6D1559E97D000DBD37 /* KRResource+blend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46A6B6C1559E97D000DBD37 /* KRResource+blend.cpp */; };
|
||||||
E46A6B701559EF0A000DBD37 /* KRResource+blend.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A6B6F1559EF0A000DBD37 /* KRResource+blend.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E46A6B701559EF0A000DBD37 /* KRResource+blend.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A6B6F1559EF0A000DBD37 /* KRResource+blend.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E46C214515364BC8009CABF3 /* tinyxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46C214215364BC8009CABF3 /* tinyxml2.cpp */; };
|
E46C214515364BC8009CABF3 /* tinyxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46C214215364BC8009CABF3 /* tinyxml2.cpp */; };
|
||||||
@@ -267,8 +291,8 @@
|
|||||||
E4E6F68716BA5DF700E410F8 /* debug_font.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */; };
|
E4E6F68716BA5DF700E410F8 /* debug_font.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */; };
|
||||||
E4E6F68816BA5DF700E410F8 /* dust_particle.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */; };
|
E4E6F68816BA5DF700E410F8 /* dust_particle.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */; };
|
||||||
E4E6F68916BA5DF700E410F8 /* dust_particle.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */; };
|
E4E6F68916BA5DF700E410F8 /* dust_particle.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */; };
|
||||||
E4E6F68A16BA5DF700E410F8 /* flare.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64E16BA5D9400E410F8 /* flare.fsh */; };
|
E4E6F68A16BA5DF700E410F8 /* sprite.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64E16BA5D9400E410F8 /* sprite.fsh */; };
|
||||||
E4E6F68B16BA5DF700E410F8 /* flare.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64F16BA5D9400E410F8 /* flare.vsh */; };
|
E4E6F68B16BA5DF700E410F8 /* sprite.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F64F16BA5D9400E410F8 /* sprite.vsh */; };
|
||||||
E4E6F68C16BA5DF700E410F8 /* light_directional.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65016BA5D9400E410F8 /* light_directional.fsh */; };
|
E4E6F68C16BA5DF700E410F8 /* light_directional.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65016BA5D9400E410F8 /* light_directional.fsh */; };
|
||||||
E4E6F68D16BA5DF700E410F8 /* light_directional.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65116BA5D9400E410F8 /* light_directional.vsh */; };
|
E4E6F68D16BA5DF700E410F8 /* light_directional.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65116BA5D9400E410F8 /* light_directional.vsh */; };
|
||||||
E4E6F68E16BA5DF700E410F8 /* light_point_inside.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */; };
|
E4E6F68E16BA5DF700E410F8 /* light_point_inside.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */; };
|
||||||
@@ -299,8 +323,8 @@
|
|||||||
E4E6F6A716BA5E0A00E410F8 /* debug_font_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */; };
|
E4E6F6A716BA5E0A00E410F8 /* debug_font_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */; };
|
||||||
E4E6F6A816BA5E0A00E410F8 /* dust_particle_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */; };
|
E4E6F6A816BA5E0A00E410F8 /* dust_particle_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */; };
|
||||||
E4E6F6A916BA5E0A00E410F8 /* dust_particle_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */; };
|
E4E6F6A916BA5E0A00E410F8 /* dust_particle_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */; };
|
||||||
E4E6F6AA16BA5E0A00E410F8 /* flare_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61416BA5D8300E410F8 /* flare_osx.fsh */; };
|
E4E6F6AA16BA5E0A00E410F8 /* sprite_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61416BA5D8300E410F8 /* sprite_osx.fsh */; };
|
||||||
E4E6F6AB16BA5E0A00E410F8 /* flare_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61516BA5D8300E410F8 /* flare_osx.vsh */; };
|
E4E6F6AB16BA5E0A00E410F8 /* sprite_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61516BA5D8300E410F8 /* sprite_osx.vsh */; };
|
||||||
E4E6F6AC16BA5E0A00E410F8 /* light_directional_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */; };
|
E4E6F6AC16BA5E0A00E410F8 /* light_directional_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */; };
|
||||||
E4E6F6AD16BA5E0A00E410F8 /* light_directional_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */; };
|
E4E6F6AD16BA5E0A00E410F8 /* light_directional_osx.vsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */; };
|
||||||
E4E6F6AE16BA5E0A00E410F8 /* light_point_inside_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */; };
|
E4E6F6AE16BA5E0A00E410F8 /* light_point_inside_osx.fsh in Resources */ = {isa = PBXBuildFile; fileRef = E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */; };
|
||||||
@@ -387,6 +411,10 @@
|
|||||||
E4030E4B160A3CF000592648 /* KRStockGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRStockGeometry.h; sourceTree = "<group>"; };
|
E4030E4B160A3CF000592648 /* KRStockGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRStockGeometry.h; sourceTree = "<group>"; };
|
||||||
E40BA45215EFF79500D7C3DD /* KRAABB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRAABB.cpp; sourceTree = "<group>"; };
|
E40BA45215EFF79500D7C3DD /* KRAABB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRAABB.cpp; sourceTree = "<group>"; };
|
||||||
E40BA45315EFF79500D7C3DD /* KRAABB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAABB.h; sourceTree = "<group>"; };
|
E40BA45315EFF79500D7C3DD /* KRAABB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAABB.h; sourceTree = "<group>"; };
|
||||||
|
E40F982A184A7A2700CFA4D8 /* KRMeshQuad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRMeshQuad.cpp; sourceTree = "<group>"; };
|
||||||
|
E40F982B184A7A2700CFA4D8 /* KRMeshQuad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRMeshQuad.h; sourceTree = "<group>"; };
|
||||||
|
E40F9830184A7BAC00CFA4D8 /* KRSprite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRSprite.cpp; sourceTree = "<group>"; };
|
||||||
|
E40F9831184A7BAC00CFA4D8 /* KRSprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRSprite.h; sourceTree = "<group>"; };
|
||||||
E414BAE11435557300A668C4 /* KRModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRModel.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E414BAE11435557300A668C4 /* KRModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRModel.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
E414BAE41435558800A668C4 /* KRModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRModel.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E414BAE41435558800A668C4 /* KRModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRModel.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E414BAE6143557D200A668C4 /* KRScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRScene.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E414BAE6143557D200A668C4 /* KRScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRScene.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
@@ -400,6 +428,10 @@
|
|||||||
E41AE1DD16B124CA00980428 /* font.tga */ = {isa = PBXFileReference; lastKnownFileType = file; path = font.tga; sourceTree = "<group>"; };
|
E41AE1DD16B124CA00980428 /* font.tga */ = {isa = PBXFileReference; lastKnownFileType = file; path = font.tga; sourceTree = "<group>"; };
|
||||||
E41B6BA716BE436100B510EB /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
|
E41B6BA716BE436100B510EB /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
|
||||||
E41B6BA916BE437800B510EB /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreAudio.framework; sourceTree = DEVELOPER_DIR; };
|
E41B6BA916BE437800B510EB /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreAudio.framework; sourceTree = DEVELOPER_DIR; };
|
||||||
|
E42559AA184DD4490081BB20 /* flare.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare.fsh; sourceTree = "<group>"; };
|
||||||
|
E42559AC184DD45A0081BB20 /* flare.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare.vsh; sourceTree = "<group>"; };
|
||||||
|
E42559AE184DD4730081BB20 /* flare_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare_osx.fsh; sourceTree = "<group>"; };
|
||||||
|
E42559B0184DD48B0081BB20 /* flare_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare_osx.vsh; sourceTree = "<group>"; };
|
||||||
E428C2F11669610500A16EDF /* KRAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAnimationManager.h; sourceTree = "<group>"; };
|
E428C2F11669610500A16EDF /* KRAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAnimationManager.h; sourceTree = "<group>"; };
|
||||||
E428C2F41669611600A16EDF /* KRAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRAnimationManager.cpp; sourceTree = "<group>"; };
|
E428C2F41669611600A16EDF /* KRAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRAnimationManager.cpp; sourceTree = "<group>"; };
|
||||||
E428C2F71669612500A16EDF /* KRAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAnimation.h; sourceTree = "<group>"; };
|
E428C2F71669612500A16EDF /* KRAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRAnimation.h; sourceTree = "<group>"; };
|
||||||
@@ -419,6 +451,12 @@
|
|||||||
E437849716C488360037FD43 /* hrtf_kemar.krbundle */ = {isa = PBXFileReference; lastKnownFileType = file; path = hrtf_kemar.krbundle; sourceTree = "<group>"; };
|
E437849716C488360037FD43 /* hrtf_kemar.krbundle */ = {isa = PBXFileReference; lastKnownFileType = file; path = hrtf_kemar.krbundle; sourceTree = "<group>"; };
|
||||||
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRContextObject.cpp; sourceTree = "<group>"; };
|
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRContextObject.cpp; sourceTree = "<group>"; };
|
||||||
E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRContextObject.h; sourceTree = "<group>"; };
|
E43B0AD515DDCA0D00A5CB9F /* KRContextObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRContextObject.h; sourceTree = "<group>"; };
|
||||||
|
E43F70DA181B20E300136169 /* KRLODSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRLODSet.cpp; sourceTree = "<group>"; };
|
||||||
|
E43F70DB181B20E400136169 /* KRLODSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRLODSet.h; sourceTree = "<group>"; };
|
||||||
|
E43F70E31824D9AB00136169 /* KRTextureStreamer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KRTextureStreamer.mm; sourceTree = "<group>"; };
|
||||||
|
E43F70E41824D9AB00136169 /* KRTextureStreamer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRTextureStreamer.h; sourceTree = "<group>"; };
|
||||||
|
E43F70FD1824E73100136169 /* KRMeshStreamer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KRMeshStreamer.mm; sourceTree = "<group>"; };
|
||||||
|
E43F70FE1824E73100136169 /* KRMeshStreamer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRMeshStreamer.h; sourceTree = "<group>"; };
|
||||||
E44F38231683B22C00399B5D /* KRRenderSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRRenderSettings.h; sourceTree = "<group>"; };
|
E44F38231683B22C00399B5D /* KRRenderSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRRenderSettings.h; sourceTree = "<group>"; };
|
||||||
E44F38271683B24400399B5D /* KRRenderSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRRenderSettings.cpp; sourceTree = "<group>"; };
|
E44F38271683B24400399B5D /* KRRenderSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRRenderSettings.cpp; sourceTree = "<group>"; };
|
||||||
E450273716E0491D00FDEC5C /* KRReverbZone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRReverbZone.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E450273716E0491D00FDEC5C /* KRReverbZone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRReverbZone.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
@@ -429,7 +467,7 @@
|
|||||||
E459040516C30CD9002B00A0 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; };
|
E459040516C30CD9002B00A0 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; };
|
||||||
E460292516681CFE00261BB9 /* KRTextureAnimated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRTextureAnimated.h; sourceTree = "<group>"; };
|
E460292516681CFE00261BB9 /* KRTextureAnimated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRTextureAnimated.h; sourceTree = "<group>"; };
|
||||||
E460292716681D1000261BB9 /* KRTextureAnimated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRTextureAnimated.cpp; sourceTree = "<group>"; };
|
E460292716681D1000261BB9 /* KRTextureAnimated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRTextureAnimated.cpp; sourceTree = "<group>"; };
|
||||||
E460292916682BD900261BB9 /* libfbxsdk-2013.3-static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libfbxsdk-2013.3-static.a"; path = "lib/gcc4/ub/libfbxsdk-2013.3-static.a"; sourceTree = FBXSDK; };
|
E460292916682BD900261BB9 /* libfbxsdk.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfbxsdk.a; path = "../../FBX SDK/2014.2/lib/ios-i386/release/libfbxsdk.a"; sourceTree = FBXSDK; };
|
||||||
E461A151152E54B500F2044A /* KRLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRLight.h; sourceTree = "<group>"; };
|
E461A151152E54B500F2044A /* KRLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRLight.h; sourceTree = "<group>"; };
|
||||||
E461A155152E54F700F2044A /* KRLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRLight.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E461A155152E54F700F2044A /* KRLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRLight.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E461A157152E555400F2044A /* KRPointLight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRPointLight.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E461A157152E555400F2044A /* KRPointLight.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRPointLight.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
@@ -438,6 +476,8 @@
|
|||||||
E461A15E152E565700F2044A /* KRDirectionalLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRDirectionalLight.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
E461A15E152E565700F2044A /* KRDirectionalLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = KRDirectionalLight.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
E461A164152E56C000F2044A /* KRSpotLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRSpotLight.cpp; sourceTree = "<group>"; };
|
E461A164152E56C000F2044A /* KRSpotLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRSpotLight.cpp; sourceTree = "<group>"; };
|
||||||
E461A167152E570500F2044A /* KRSpotLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRSpotLight.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
E461A167152E570500F2044A /* KRSpotLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = KRSpotLight.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
|
E468447D17FFDF51001F1FA1 /* KRLocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KRLocator.cpp; sourceTree = "<group>"; };
|
||||||
|
E468447E17FFDF51001F1FA1 /* KRLocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KRLocator.h; sourceTree = "<group>"; };
|
||||||
E46A6B6C1559E97D000DBD37 /* KRResource+blend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "KRResource+blend.cpp"; sourceTree = "<group>"; };
|
E46A6B6C1559E97D000DBD37 /* KRResource+blend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "KRResource+blend.cpp"; sourceTree = "<group>"; };
|
||||||
E46A6B6F1559EF0A000DBD37 /* KRResource+blend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KRResource+blend.h"; sourceTree = "<group>"; };
|
E46A6B6F1559EF0A000DBD37 /* KRResource+blend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KRResource+blend.h"; sourceTree = "<group>"; };
|
||||||
E46C214115364BC8009CABF3 /* tinyxml2_readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tinyxml2_readme.txt; sourceTree = "<group>"; };
|
E46C214115364BC8009CABF3 /* tinyxml2_readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = tinyxml2_readme.txt; sourceTree = "<group>"; };
|
||||||
@@ -545,8 +585,8 @@
|
|||||||
E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = debug_font_osx.vsh; sourceTree = "<group>"; };
|
E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = debug_font_osx.vsh; sourceTree = "<group>"; };
|
||||||
E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle_osx.fsh; sourceTree = "<group>"; };
|
E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle_osx.fsh; sourceTree = "<group>"; };
|
||||||
E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle_osx.vsh; sourceTree = "<group>"; };
|
E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle_osx.vsh; sourceTree = "<group>"; };
|
||||||
E4E6F61416BA5D8300E410F8 /* flare_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare_osx.fsh; sourceTree = "<group>"; };
|
E4E6F61416BA5D8300E410F8 /* sprite_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = sprite_osx.fsh; sourceTree = "<group>"; };
|
||||||
E4E6F61516BA5D8300E410F8 /* flare_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare_osx.vsh; sourceTree = "<group>"; };
|
E4E6F61516BA5D8300E410F8 /* sprite_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = sprite_osx.vsh; sourceTree = "<group>"; };
|
||||||
E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional_osx.fsh; sourceTree = "<group>"; };
|
E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional_osx.fsh; sourceTree = "<group>"; };
|
||||||
E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional_osx.vsh; sourceTree = "<group>"; };
|
E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional_osx.vsh; sourceTree = "<group>"; };
|
||||||
E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_point_inside_osx.fsh; sourceTree = "<group>"; };
|
E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_point_inside_osx.fsh; sourceTree = "<group>"; };
|
||||||
@@ -573,8 +613,8 @@
|
|||||||
E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = debug_font.vsh; sourceTree = "<group>"; };
|
E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = debug_font.vsh; sourceTree = "<group>"; };
|
||||||
E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle.fsh; sourceTree = "<group>"; };
|
E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle.fsh; sourceTree = "<group>"; };
|
||||||
E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle.vsh; sourceTree = "<group>"; };
|
E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = dust_particle.vsh; sourceTree = "<group>"; };
|
||||||
E4E6F64E16BA5D9400E410F8 /* flare.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare.fsh; sourceTree = "<group>"; };
|
E4E6F64E16BA5D9400E410F8 /* sprite.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = sprite.fsh; sourceTree = "<group>"; };
|
||||||
E4E6F64F16BA5D9400E410F8 /* flare.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = flare.vsh; sourceTree = "<group>"; };
|
E4E6F64F16BA5D9400E410F8 /* sprite.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = sprite.vsh; sourceTree = "<group>"; };
|
||||||
E4E6F65016BA5D9400E410F8 /* light_directional.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional.fsh; sourceTree = "<group>"; };
|
E4E6F65016BA5D9400E410F8 /* light_directional.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional.fsh; sourceTree = "<group>"; };
|
||||||
E4E6F65116BA5D9400E410F8 /* light_directional.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional.vsh; sourceTree = "<group>"; };
|
E4E6F65116BA5D9400E410F8 /* light_directional.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_directional.vsh; sourceTree = "<group>"; };
|
||||||
E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_point_inside.fsh; sourceTree = "<group>"; };
|
E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = light_point_inside.fsh; sourceTree = "<group>"; };
|
||||||
@@ -647,7 +687,7 @@
|
|||||||
E4BBBB9F1512A4B100F43B5B /* Cocoa.framework in Frameworks */,
|
E4BBBB9F1512A4B100F43B5B /* Cocoa.framework in Frameworks */,
|
||||||
E497B95D151BF05F00D3DC67 /* CoreServices.framework in Frameworks */,
|
E497B95D151BF05F00D3DC67 /* CoreServices.framework in Frameworks */,
|
||||||
E497B95F151BF09600D3DC67 /* SystemConfiguration.framework in Frameworks */,
|
E497B95F151BF09600D3DC67 /* SystemConfiguration.framework in Frameworks */,
|
||||||
E460292B16682BF700261BB9 /* libfbxsdk-2013.3-static.a in Frameworks */,
|
E460292B16682BF700261BB9 /* libfbxsdk.a in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -698,8 +738,8 @@
|
|||||||
E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */,
|
E4E6F64B16BA5D9400E410F8 /* debug_font.vsh */,
|
||||||
E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */,
|
E4E6F64C16BA5D9400E410F8 /* dust_particle.fsh */,
|
||||||
E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */,
|
E4E6F64D16BA5D9400E410F8 /* dust_particle.vsh */,
|
||||||
E4E6F64E16BA5D9400E410F8 /* flare.fsh */,
|
E4E6F64E16BA5D9400E410F8 /* sprite.fsh */,
|
||||||
E4E6F64F16BA5D9400E410F8 /* flare.vsh */,
|
E4E6F64F16BA5D9400E410F8 /* sprite.vsh */,
|
||||||
E4E6F65016BA5D9400E410F8 /* light_directional.fsh */,
|
E4E6F65016BA5D9400E410F8 /* light_directional.fsh */,
|
||||||
E4E6F65116BA5D9400E410F8 /* light_directional.vsh */,
|
E4E6F65116BA5D9400E410F8 /* light_directional.vsh */,
|
||||||
E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */,
|
E4E6F65216BA5D9400E410F8 /* light_point_inside.fsh */,
|
||||||
@@ -723,6 +763,8 @@
|
|||||||
E4E6F66416BA5D9400E410F8 /* volumetric_fog_downsampled.vsh */,
|
E4E6F66416BA5D9400E410F8 /* volumetric_fog_downsampled.vsh */,
|
||||||
E4E6F66516BA5D9400E410F8 /* volumetric_fog.fsh */,
|
E4E6F66516BA5D9400E410F8 /* volumetric_fog.fsh */,
|
||||||
E4E6F66616BA5D9400E410F8 /* volumetric_fog.vsh */,
|
E4E6F66616BA5D9400E410F8 /* volumetric_fog.vsh */,
|
||||||
|
E42559AA184DD4490081BB20 /* flare.fsh */,
|
||||||
|
E42559AC184DD45A0081BB20 /* flare.vsh */,
|
||||||
);
|
);
|
||||||
path = Shaders;
|
path = Shaders;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -878,6 +920,8 @@
|
|||||||
E4CA10EE1637BD58005D9400 /* KRTextureTGA.cpp */,
|
E4CA10EE1637BD58005D9400 /* KRTextureTGA.cpp */,
|
||||||
E460292516681CFE00261BB9 /* KRTextureAnimated.h */,
|
E460292516681CFE00261BB9 /* KRTextureAnimated.h */,
|
||||||
E460292716681D1000261BB9 /* KRTextureAnimated.cpp */,
|
E460292716681D1000261BB9 /* KRTextureAnimated.cpp */,
|
||||||
|
E43F70E31824D9AB00136169 /* KRTextureStreamer.mm */,
|
||||||
|
E43F70E41824D9AB00136169 /* KRTextureStreamer.h */,
|
||||||
);
|
);
|
||||||
name = Texture;
|
name = Texture;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -893,6 +937,10 @@
|
|||||||
E4C454AE167BB8FC003586CD /* KRMeshCube.cpp */,
|
E4C454AE167BB8FC003586CD /* KRMeshCube.cpp */,
|
||||||
E4C454B1167BC04B003586CD /* KRMeshSphere.h */,
|
E4C454B1167BC04B003586CD /* KRMeshSphere.h */,
|
||||||
E4C454B4167BC05C003586CD /* KRMeshSphere.cpp */,
|
E4C454B4167BC05C003586CD /* KRMeshSphere.cpp */,
|
||||||
|
E43F70FD1824E73100136169 /* KRMeshStreamer.mm */,
|
||||||
|
E43F70FE1824E73100136169 /* KRMeshStreamer.h */,
|
||||||
|
E40F982A184A7A2700CFA4D8 /* KRMeshQuad.cpp */,
|
||||||
|
E40F982B184A7A2700CFA4D8 /* KRMeshQuad.h */,
|
||||||
);
|
);
|
||||||
name = Mesh;
|
name = Mesh;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -971,6 +1019,12 @@
|
|||||||
E480BE6B1671C653004EC8AD /* KRBone.cpp */,
|
E480BE6B1671C653004EC8AD /* KRBone.cpp */,
|
||||||
E4AE635B1704FB0A00B460CD /* KRLODGroup.cpp */,
|
E4AE635B1704FB0A00B460CD /* KRLODGroup.cpp */,
|
||||||
E4AE635C1704FB0A00B460CD /* KRLODGroup.h */,
|
E4AE635C1704FB0A00B460CD /* KRLODGroup.h */,
|
||||||
|
E468447D17FFDF51001F1FA1 /* KRLocator.cpp */,
|
||||||
|
E468447E17FFDF51001F1FA1 /* KRLocator.h */,
|
||||||
|
E43F70DA181B20E300136169 /* KRLODSet.cpp */,
|
||||||
|
E43F70DB181B20E400136169 /* KRLODSet.h */,
|
||||||
|
E40F9830184A7BAC00CFA4D8 /* KRSprite.cpp */,
|
||||||
|
E40F9831184A7BAC00CFA4D8 /* KRSprite.h */,
|
||||||
);
|
);
|
||||||
name = "Scene Graph Nodes";
|
name = "Scene Graph Nodes";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -1059,7 +1113,7 @@
|
|||||||
E459040316C30CC5002B00A0 /* AudioUnit.framework */,
|
E459040316C30CC5002B00A0 /* AudioUnit.framework */,
|
||||||
E41B6BA916BE437800B510EB /* CoreAudio.framework */,
|
E41B6BA916BE437800B510EB /* CoreAudio.framework */,
|
||||||
10CC33A3168530A300BB9846 /* libPVRTexLib.a */,
|
10CC33A3168530A300BB9846 /* libPVRTexLib.a */,
|
||||||
E460292916682BD900261BB9 /* libfbxsdk-2013.3-static.a */,
|
E460292916682BD900261BB9 /* libfbxsdk.a */,
|
||||||
E4BBBB9A1512A48200F43B5B /* Foundation.framework */,
|
E4BBBB9A1512A48200F43B5B /* Foundation.framework */,
|
||||||
E46DBE7D1512AD4900D59F86 /* OpenGL.framework */,
|
E46DBE7D1512AD4900D59F86 /* OpenGL.framework */,
|
||||||
E4F027D41697A02D00D4427D /* OpenAL.framework */,
|
E4F027D41697A02D00D4427D /* OpenAL.framework */,
|
||||||
@@ -1105,8 +1159,8 @@
|
|||||||
E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */,
|
E4E6F61116BA5D8300E410F8 /* debug_font_osx.vsh */,
|
||||||
E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */,
|
E4E6F61216BA5D8300E410F8 /* dust_particle_osx.fsh */,
|
||||||
E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */,
|
E4E6F61316BA5D8300E410F8 /* dust_particle_osx.vsh */,
|
||||||
E4E6F61416BA5D8300E410F8 /* flare_osx.fsh */,
|
E4E6F61416BA5D8300E410F8 /* sprite_osx.fsh */,
|
||||||
E4E6F61516BA5D8300E410F8 /* flare_osx.vsh */,
|
E4E6F61516BA5D8300E410F8 /* sprite_osx.vsh */,
|
||||||
E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */,
|
E4E6F61616BA5D8300E410F8 /* light_directional_osx.fsh */,
|
||||||
E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */,
|
E4E6F61716BA5D8300E410F8 /* light_directional_osx.vsh */,
|
||||||
E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */,
|
E4E6F61816BA5D8300E410F8 /* light_point_inside_osx.fsh */,
|
||||||
@@ -1128,6 +1182,8 @@
|
|||||||
E4E6F62816BA5D8300E410F8 /* volumetric_fog_downsampled_osx.vsh */,
|
E4E6F62816BA5D8300E410F8 /* volumetric_fog_downsampled_osx.vsh */,
|
||||||
E4E6F62916BA5D8300E410F8 /* volumetric_fog_osx.fsh */,
|
E4E6F62916BA5D8300E410F8 /* volumetric_fog_osx.fsh */,
|
||||||
E4E6F62A16BA5D8300E410F8 /* volumetric_fog_osx.vsh */,
|
E4E6F62A16BA5D8300E410F8 /* volumetric_fog_osx.vsh */,
|
||||||
|
E42559AE184DD4730081BB20 /* flare_osx.fsh */,
|
||||||
|
E42559B0184DD48B0081BB20 /* flare_osx.vsh */,
|
||||||
);
|
);
|
||||||
path = Shaders;
|
path = Shaders;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -1180,6 +1236,7 @@
|
|||||||
isa = PBXHeadersBuildPhase;
|
isa = PBXHeadersBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
E43F70DE181B20E400136169 /* KRLODSet.h in Headers */,
|
||||||
E491019513C99BDC0098455B /* KRMaterial.h in Headers */,
|
E491019513C99BDC0098455B /* KRMaterial.h in Headers */,
|
||||||
E491019C13C99BDC0098455B /* KRMaterialManager.h in Headers */,
|
E491019C13C99BDC0098455B /* KRMaterialManager.h in Headers */,
|
||||||
E491019D13C99BDC0098455B /* KRTextureManager.h in Headers */,
|
E491019D13C99BDC0098455B /* KRTextureManager.h in Headers */,
|
||||||
@@ -1194,10 +1251,13 @@
|
|||||||
E414BAE21435557300A668C4 /* KRModel.h in Headers */,
|
E414BAE21435557300A668C4 /* KRModel.h in Headers */,
|
||||||
E414BAE7143557D200A668C4 /* KRScene.h in Headers */,
|
E414BAE7143557D200A668C4 /* KRScene.h in Headers */,
|
||||||
E48B3CBD14393DF5000C50E2 /* KRCamera.h in Headers */,
|
E48B3CBD14393DF5000C50E2 /* KRCamera.h in Headers */,
|
||||||
|
E40F982E184A7A2700CFA4D8 /* KRMeshQuad.h in Headers */,
|
||||||
E497B94A151BCEE900D3DC67 /* KRResource.h in Headers */,
|
E497B94A151BCEE900D3DC67 /* KRResource.h in Headers */,
|
||||||
E461A152152E54B500F2044A /* KRLight.h in Headers */,
|
E461A152152E54B500F2044A /* KRLight.h in Headers */,
|
||||||
E461A15C152E563100F2044A /* KRDirectionalLight.h in Headers */,
|
E461A15C152E563100F2044A /* KRDirectionalLight.h in Headers */,
|
||||||
E461A168152E570700F2044A /* KRSpotLight.h in Headers */,
|
E461A168152E570700F2044A /* KRSpotLight.h in Headers */,
|
||||||
|
E468448117FFDF51001F1FA1 /* KRLocator.h in Headers */,
|
||||||
|
E43F70E71824D9AB00136169 /* KRTextureStreamer.h in Headers */,
|
||||||
E4F975321536220900FD60B2 /* KRNode.h in Headers */,
|
E4F975321536220900FD60B2 /* KRNode.h in Headers */,
|
||||||
E46C214715364BC8009CABF3 /* tinyxml2.h in Headers */,
|
E46C214715364BC8009CABF3 /* tinyxml2.h in Headers */,
|
||||||
E48C696F15374F5B00232E28 /* KRContext.h in Headers */,
|
E48C696F15374F5B00232E28 /* KRContext.h in Headers */,
|
||||||
@@ -1207,6 +1267,7 @@
|
|||||||
E4924C2715EE95E800B965C6 /* KROctree.h in Headers */,
|
E4924C2715EE95E800B965C6 /* KROctree.h in Headers */,
|
||||||
E4924C2C15EE96AB00B965C6 /* KROctreeNode.h in Headers */,
|
E4924C2C15EE96AB00B965C6 /* KROctreeNode.h in Headers */,
|
||||||
E40BA45615EFF79500D7C3DD /* KRAABB.h in Headers */,
|
E40BA45615EFF79500D7C3DD /* KRAABB.h in Headers */,
|
||||||
|
E40F9834184A7BAC00CFA4D8 /* KRSprite.h in Headers */,
|
||||||
E488399615F928CA00BD66D5 /* KRBundle.h in Headers */,
|
E488399615F928CA00BD66D5 /* KRBundle.h in Headers */,
|
||||||
E488399E15F92BE000BD66D5 /* KRBundleManager.h in Headers */,
|
E488399E15F92BE000BD66D5 /* KRBundleManager.h in Headers */,
|
||||||
E4030E4C160A3CF000592648 /* KRStockGeometry.h in Headers */,
|
E4030E4C160A3CF000592648 /* KRStockGeometry.h in Headers */,
|
||||||
@@ -1246,6 +1307,7 @@
|
|||||||
E4AE635F1704FB0A00B460CD /* KRLODGroup.h in Headers */,
|
E4AE635F1704FB0A00B460CD /* KRLODGroup.h in Headers */,
|
||||||
E4EC73C31720B1FF0065299F /* KRVector4.h in Headers */,
|
E4EC73C31720B1FF0065299F /* KRVector4.h in Headers */,
|
||||||
E48CF944173453990005EBBB /* KRFloat.h in Headers */,
|
E48CF944173453990005EBBB /* KRFloat.h in Headers */,
|
||||||
|
E43F71011824E73100136169 /* KRMeshStreamer.h in Headers */,
|
||||||
E45134B81746A4A300443C21 /* KRBehavior.h in Headers */,
|
E45134B81746A4A300443C21 /* KRBehavior.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -1321,8 +1383,14 @@
|
|||||||
E44F38251683B23000399B5D /* KRRenderSettings.h in Headers */,
|
E44F38251683B23000399B5D /* KRRenderSettings.h in Headers */,
|
||||||
E499BF1D16AE74FF007FCDBE /* KRTextureAnimated.h in Headers */,
|
E499BF1D16AE74FF007FCDBE /* KRTextureAnimated.h in Headers */,
|
||||||
E4EC73C41720B1FF0065299F /* KRVector4.h in Headers */,
|
E4EC73C41720B1FF0065299F /* KRVector4.h in Headers */,
|
||||||
|
E468448217FFDF51001F1FA1 /* KRLocator.h in Headers */,
|
||||||
|
E43F70DF181B20E400136169 /* KRLODSet.h in Headers */,
|
||||||
E4AE63601704FB0A00B460CD /* KRLODGroup.h in Headers */,
|
E4AE63601704FB0A00B460CD /* KRLODGroup.h in Headers */,
|
||||||
E45134B91746A4A300443C21 /* KRBehavior.h in Headers */,
|
E45134B91746A4A300443C21 /* KRBehavior.h in Headers */,
|
||||||
|
E43F71021824E73100136169 /* KRMeshStreamer.h in Headers */,
|
||||||
|
E43F70E81824D9AB00136169 /* KRTextureStreamer.h in Headers */,
|
||||||
|
E40F982F184A7A2700CFA4D8 /* KRMeshQuad.h in Headers */,
|
||||||
|
E40F9835184A7BAC00CFA4D8 /* KRSprite.h in Headers */,
|
||||||
E48CF945173453990005EBBB /* KRFloat.h in Headers */,
|
E48CF945173453990005EBBB /* KRFloat.h in Headers */,
|
||||||
E499BF1F16AE753E007FCDBE /* KRCollider.h in Headers */,
|
E499BF1F16AE753E007FCDBE /* KRCollider.h in Headers */,
|
||||||
E499BF2316AE7636007FCDBE /* kraken-prefix.pch in Headers */,
|
E499BF2316AE7636007FCDBE /* kraken-prefix.pch in Headers */,
|
||||||
@@ -1451,8 +1519,8 @@
|
|||||||
E4E6F68716BA5DF700E410F8 /* debug_font.vsh in Resources */,
|
E4E6F68716BA5DF700E410F8 /* debug_font.vsh in Resources */,
|
||||||
E4E6F68816BA5DF700E410F8 /* dust_particle.fsh in Resources */,
|
E4E6F68816BA5DF700E410F8 /* dust_particle.fsh in Resources */,
|
||||||
E4E6F68916BA5DF700E410F8 /* dust_particle.vsh in Resources */,
|
E4E6F68916BA5DF700E410F8 /* dust_particle.vsh in Resources */,
|
||||||
E4E6F68A16BA5DF700E410F8 /* flare.fsh in Resources */,
|
E4E6F68A16BA5DF700E410F8 /* sprite.fsh in Resources */,
|
||||||
E4E6F68B16BA5DF700E410F8 /* flare.vsh in Resources */,
|
E4E6F68B16BA5DF700E410F8 /* sprite.vsh in Resources */,
|
||||||
E4E6F68C16BA5DF700E410F8 /* light_directional.fsh in Resources */,
|
E4E6F68C16BA5DF700E410F8 /* light_directional.fsh in Resources */,
|
||||||
E4E6F68D16BA5DF700E410F8 /* light_directional.vsh in Resources */,
|
E4E6F68D16BA5DF700E410F8 /* light_directional.vsh in Resources */,
|
||||||
E4E6F68E16BA5DF700E410F8 /* light_point_inside.fsh in Resources */,
|
E4E6F68E16BA5DF700E410F8 /* light_point_inside.fsh in Resources */,
|
||||||
@@ -1491,8 +1559,8 @@
|
|||||||
E4E6F6A716BA5E0A00E410F8 /* debug_font_osx.vsh in Resources */,
|
E4E6F6A716BA5E0A00E410F8 /* debug_font_osx.vsh in Resources */,
|
||||||
E4E6F6A816BA5E0A00E410F8 /* dust_particle_osx.fsh in Resources */,
|
E4E6F6A816BA5E0A00E410F8 /* dust_particle_osx.fsh in Resources */,
|
||||||
E4E6F6A916BA5E0A00E410F8 /* dust_particle_osx.vsh in Resources */,
|
E4E6F6A916BA5E0A00E410F8 /* dust_particle_osx.vsh in Resources */,
|
||||||
E4E6F6AA16BA5E0A00E410F8 /* flare_osx.fsh in Resources */,
|
E4E6F6AA16BA5E0A00E410F8 /* sprite_osx.fsh in Resources */,
|
||||||
E4E6F6AB16BA5E0A00E410F8 /* flare_osx.vsh in Resources */,
|
E4E6F6AB16BA5E0A00E410F8 /* sprite_osx.vsh in Resources */,
|
||||||
E4E6F6AC16BA5E0A00E410F8 /* light_directional_osx.fsh in Resources */,
|
E4E6F6AC16BA5E0A00E410F8 /* light_directional_osx.fsh in Resources */,
|
||||||
E4E6F6AD16BA5E0A00E410F8 /* light_directional_osx.vsh in Resources */,
|
E4E6F6AD16BA5E0A00E410F8 /* light_directional_osx.vsh in Resources */,
|
||||||
E4E6F6AE16BA5E0A00E410F8 /* light_point_inside_osx.fsh in Resources */,
|
E4E6F6AE16BA5E0A00E410F8 /* light_point_inside_osx.fsh in Resources */,
|
||||||
@@ -1536,14 +1604,17 @@
|
|||||||
E491019A13C99BDC0098455B /* KRMeshManager.cpp in Sources */,
|
E491019A13C99BDC0098455B /* KRMeshManager.cpp in Sources */,
|
||||||
E47C25A713F4F6AB00FF4370 /* KRShaderManager.cpp in Sources */,
|
E47C25A713F4F6AB00FF4370 /* KRShaderManager.cpp in Sources */,
|
||||||
E47C25A913F4F6DD00FF4370 /* KRShader.cpp in Sources */,
|
E47C25A913F4F6DD00FF4370 /* KRShader.cpp in Sources */,
|
||||||
|
E43F70DC181B20E400136169 /* KRLODSet.cpp in Sources */,
|
||||||
E414BAE51435558900A668C4 /* KRModel.cpp in Sources */,
|
E414BAE51435558900A668C4 /* KRModel.cpp in Sources */,
|
||||||
E414BAE91435585A00A668C4 /* KRScene.cpp in Sources */,
|
E414BAE91435585A00A668C4 /* KRScene.cpp in Sources */,
|
||||||
E48B3CC014393E30000C50E2 /* KRCamera.cpp in Sources */,
|
E48B3CC014393E30000C50E2 /* KRCamera.cpp in Sources */,
|
||||||
E497B946151BA99500D3DC67 /* KRVector2.cpp in Sources */,
|
E497B946151BA99500D3DC67 /* KRVector2.cpp in Sources */,
|
||||||
E497B94D151BCF2500D3DC67 /* KRResource.cpp in Sources */,
|
E497B94D151BCF2500D3DC67 /* KRResource.cpp in Sources */,
|
||||||
E497B950151BD2CE00D3DC67 /* KRResource+obj.cpp in Sources */,
|
E497B950151BD2CE00D3DC67 /* KRResource+obj.cpp in Sources */,
|
||||||
|
E43F70FF1824E73100136169 /* KRMeshStreamer.mm in Sources */,
|
||||||
E461A156152E54F800F2044A /* KRLight.cpp in Sources */,
|
E461A156152E54F800F2044A /* KRLight.cpp in Sources */,
|
||||||
E461A159152E557E00F2044A /* KRPointLight.cpp in Sources */,
|
E461A159152E557E00F2044A /* KRPointLight.cpp in Sources */,
|
||||||
|
E468447F17FFDF51001F1FA1 /* KRLocator.cpp in Sources */,
|
||||||
E461A15F152E565700F2044A /* KRDirectionalLight.cpp in Sources */,
|
E461A15F152E565700F2044A /* KRDirectionalLight.cpp in Sources */,
|
||||||
E461A165152E56C000F2044A /* KRSpotLight.cpp in Sources */,
|
E461A165152E56C000F2044A /* KRSpotLight.cpp in Sources */,
|
||||||
E4F975361536221C00FD60B2 /* KRNode.cpp in Sources */,
|
E4F975361536221C00FD60B2 /* KRNode.cpp in Sources */,
|
||||||
@@ -1566,6 +1637,7 @@
|
|||||||
E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */,
|
E4324BA816444C230043185B /* KRParticleSystem.cpp in Sources */,
|
||||||
E4324BAE16444E120043185B /* KRParticleSystemNewtonian.cpp in Sources */,
|
E4324BAE16444E120043185B /* KRParticleSystemNewtonian.cpp in Sources */,
|
||||||
E460292816681D1000261BB9 /* KRTextureAnimated.cpp in Sources */,
|
E460292816681D1000261BB9 /* KRTextureAnimated.cpp in Sources */,
|
||||||
|
E43F70E51824D9AB00136169 /* KRTextureStreamer.mm in Sources */,
|
||||||
E428C2F51669611600A16EDF /* KRAnimationManager.cpp in Sources */,
|
E428C2F51669611600A16EDF /* KRAnimationManager.cpp in Sources */,
|
||||||
E428C2FB1669613200A16EDF /* KRAnimation.cpp in Sources */,
|
E428C2FB1669613200A16EDF /* KRAnimation.cpp in Sources */,
|
||||||
E428C3071669628A00A16EDF /* KRAnimationCurve.cpp in Sources */,
|
E428C3071669628A00A16EDF /* KRAnimationCurve.cpp in Sources */,
|
||||||
@@ -1577,11 +1649,13 @@
|
|||||||
E4C454AF167BB8FC003586CD /* KRMeshCube.cpp in Sources */,
|
E4C454AF167BB8FC003586CD /* KRMeshCube.cpp in Sources */,
|
||||||
E4C454B5167BC05C003586CD /* KRMeshSphere.cpp in Sources */,
|
E4C454B5167BC05C003586CD /* KRMeshSphere.cpp in Sources */,
|
||||||
E4C454BB167BD248003586CD /* KRHitInfo.cpp in Sources */,
|
E4C454BB167BD248003586CD /* KRHitInfo.cpp in Sources */,
|
||||||
|
E40F9832184A7BAC00CFA4D8 /* KRSprite.cpp in Sources */,
|
||||||
E44F38281683B24800399B5D /* KRRenderSettings.cpp in Sources */,
|
E44F38281683B24800399B5D /* KRRenderSettings.cpp in Sources */,
|
||||||
E414F9A61694D977000B3D58 /* KRUnknownManager.cpp in Sources */,
|
E414F9A61694D977000B3D58 /* KRUnknownManager.cpp in Sources */,
|
||||||
E414F9AC1694DA37000B3D58 /* KRUnknown.cpp in Sources */,
|
E414F9AC1694DA37000B3D58 /* KRUnknown.cpp in Sources */,
|
||||||
E48B68151697794F00D99917 /* KRAudioSource.cpp in Sources */,
|
E48B68151697794F00D99917 /* KRAudioSource.cpp in Sources */,
|
||||||
E4F027C716979CCD00D4427D /* KRAudioManager.cpp in Sources */,
|
E4F027C716979CCD00D4427D /* KRAudioManager.cpp in Sources */,
|
||||||
|
E40F982C184A7A2700CFA4D8 /* KRMeshQuad.cpp in Sources */,
|
||||||
E4F027CE16979CE200D4427D /* KRAudioSample.cpp in Sources */,
|
E4F027CE16979CE200D4427D /* KRAudioSample.cpp in Sources */,
|
||||||
E4F027DE1697BFFF00D4427D /* KRAudioBuffer.cpp in Sources */,
|
E4F027DE1697BFFF00D4427D /* KRAudioBuffer.cpp in Sources */,
|
||||||
E4943231169E08D200BCB891 /* KRAmbientZone.cpp in Sources */,
|
E4943231169E08D200BCB891 /* KRAmbientZone.cpp in Sources */,
|
||||||
@@ -1607,6 +1681,7 @@
|
|||||||
E4BBBBA71512A6DC00F43B5B /* KRVector3.cpp in Sources */,
|
E4BBBBA71512A6DC00F43B5B /* KRVector3.cpp in Sources */,
|
||||||
E4B2A43B1523B02E004CB0EC /* KRMaterial.cpp in Sources */,
|
E4B2A43B1523B02E004CB0EC /* KRMaterial.cpp in Sources */,
|
||||||
E4BBBB8E1512A40300F43B5B /* krengine_osx.mm in Sources */,
|
E4BBBB8E1512A40300F43B5B /* krengine_osx.mm in Sources */,
|
||||||
|
E468448017FFDF51001F1FA1 /* KRLocator.cpp in Sources */,
|
||||||
E497B947151BA99500D3DC67 /* KRVector2.cpp in Sources */,
|
E497B947151BA99500D3DC67 /* KRVector2.cpp in Sources */,
|
||||||
E497B94E151BCF2500D3DC67 /* KRResource.cpp in Sources */,
|
E497B94E151BCF2500D3DC67 /* KRResource.cpp in Sources */,
|
||||||
E497B951151BD2CE00D3DC67 /* KRResource+obj.cpp in Sources */,
|
E497B951151BD2CE00D3DC67 /* KRResource+obj.cpp in Sources */,
|
||||||
@@ -1629,6 +1704,7 @@
|
|||||||
E46C214C15364DEC009CABF3 /* KRSceneManager.cpp in Sources */,
|
E46C214C15364DEC009CABF3 /* KRSceneManager.cpp in Sources */,
|
||||||
E48C697315374F7E00232E28 /* KRContext.cpp in Sources */,
|
E48C697315374F7E00232E28 /* KRContext.cpp in Sources */,
|
||||||
E46A6B6D1559E97D000DBD37 /* KRResource+blend.cpp in Sources */,
|
E46A6B6D1559E97D000DBD37 /* KRResource+blend.cpp in Sources */,
|
||||||
|
E40F982D184A7A2700CFA4D8 /* KRMeshQuad.cpp in Sources */,
|
||||||
E46F4A0F155E003000CCF8B8 /* KRDataBlock.cpp in Sources */,
|
E46F4A0F155E003000CCF8B8 /* KRDataBlock.cpp in Sources */,
|
||||||
E42CB1F1158446AB0066E0D8 /* KRQuaternion.cpp in Sources */,
|
E42CB1F1158446AB0066E0D8 /* KRQuaternion.cpp in Sources */,
|
||||||
E4AFC6BB15F7C7D600DDB4C8 /* KROctreeNode.cpp in Sources */,
|
E4AFC6BB15F7C7D600DDB4C8 /* KROctreeNode.cpp in Sources */,
|
||||||
@@ -1636,8 +1712,11 @@
|
|||||||
E40BA45515EFF79500D7C3DD /* KRAABB.cpp in Sources */,
|
E40BA45515EFF79500D7C3DD /* KRAABB.cpp in Sources */,
|
||||||
E488399515F928CA00BD66D5 /* KRBundle.cpp in Sources */,
|
E488399515F928CA00BD66D5 /* KRBundle.cpp in Sources */,
|
||||||
E488399D15F92BE000BD66D5 /* KRBundleManager.cpp in Sources */,
|
E488399D15F92BE000BD66D5 /* KRBundleManager.cpp in Sources */,
|
||||||
|
E43F70DD181B20E400136169 /* KRLODSet.cpp in Sources */,
|
||||||
|
E43F71001824E73100136169 /* KRMeshStreamer.mm in Sources */,
|
||||||
E4B175AD161F5A1000B8FB80 /* KRTexture.cpp in Sources */,
|
E4B175AD161F5A1000B8FB80 /* KRTexture.cpp in Sources */,
|
||||||
E4B175B3161F5FAF00B8FB80 /* KRTextureCube.cpp in Sources */,
|
E4B175B3161F5FAF00B8FB80 /* KRTextureCube.cpp in Sources */,
|
||||||
|
E40F9833184A7BAC00CFA4D8 /* KRSprite.cpp in Sources */,
|
||||||
E4CA10EA1637BD2B005D9400 /* KRTexturePVR.cpp in Sources */,
|
E4CA10EA1637BD2B005D9400 /* KRTexturePVR.cpp in Sources */,
|
||||||
E4CA10F01637BD58005D9400 /* KRTextureTGA.cpp in Sources */,
|
E4CA10F01637BD58005D9400 /* KRTextureTGA.cpp in Sources */,
|
||||||
E4CA11791639CC90005D9400 /* KRViewport.cpp in Sources */,
|
E4CA11791639CC90005D9400 /* KRViewport.cpp in Sources */,
|
||||||
@@ -1651,6 +1730,7 @@
|
|||||||
E428C31A1669A25D00A16EDF /* KRAnimationAttribute.cpp in Sources */,
|
E428C31A1669A25D00A16EDF /* KRAnimationAttribute.cpp in Sources */,
|
||||||
E416AA9D1671375C000F6786 /* KRAnimationCurveManager.cpp in Sources */,
|
E416AA9D1671375C000F6786 /* KRAnimationCurveManager.cpp in Sources */,
|
||||||
E480BE6D1671C653004EC8AD /* KRBone.cpp in Sources */,
|
E480BE6D1671C653004EC8AD /* KRBone.cpp in Sources */,
|
||||||
|
E43F70E61824D9AB00136169 /* KRTextureStreamer.mm in Sources */,
|
||||||
E4C454B0167BB8FC003586CD /* KRMeshCube.cpp in Sources */,
|
E4C454B0167BB8FC003586CD /* KRMeshCube.cpp in Sources */,
|
||||||
E4C454B6167BC05C003586CD /* KRMeshSphere.cpp in Sources */,
|
E4C454B6167BC05C003586CD /* KRMeshSphere.cpp in Sources */,
|
||||||
E4C454BC167BD248003586CD /* KRHitInfo.cpp in Sources */,
|
E4C454BC167BD248003586CD /* KRHitInfo.cpp in Sources */,
|
||||||
@@ -1701,21 +1781,22 @@
|
|||||||
E491016913C99B9E0098455B /* Debug */ = {
|
E491016913C99B9E0098455B /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
GCC_C_LANGUAGE_STANDARD = c11;
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
|
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
|
||||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
GCC_UNROLL_LOOPS = YES;
|
||||||
|
GCC_VERSION = "";
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
/usr/local/include,
|
/usr/local/include,
|
||||||
"$(SRCROOT)/3rdparty/**",
|
"$(SRCROOT)/3rdparty/**",
|
||||||
);
|
);
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
LLVM_VECTORIZE_LOOPS = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
@@ -1725,18 +1806,20 @@
|
|||||||
E491016A13C99B9E0098455B /* Release */ = {
|
E491016A13C99B9E0098455B /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)";
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
GCC_C_LANGUAGE_STANDARD = c11;
|
||||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
GCC_OPTIMIZATION_LEVEL = fast;
|
||||||
|
GCC_UNROLL_LOOPS = YES;
|
||||||
|
GCC_VERSION = "";
|
||||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
/usr/local/include,
|
/usr/local/include,
|
||||||
"$(SRCROOT)/3rdparty/**",
|
"$(SRCROOT)/3rdparty/**",
|
||||||
);
|
);
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
|
LLVM_VECTORIZE_LOOPS = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
MACOSX_DEPLOYMENT_TARGET = 10.6;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
@@ -1747,6 +1830,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||||
|
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||||
DSTROOT = /tmp/KREngine.dst;
|
DSTROOT = /tmp/KREngine.dst;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@@ -1754,7 +1838,7 @@
|
|||||||
);
|
);
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "kraken_ios/Kraken-Prefix.pch";
|
GCC_PREFIX_HEADER = "kraken_ios/Kraken-Prefix.pch";
|
||||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"\"$(SYSTEM_APPS_DIR)/Autodesk/FBX SDK/2013.3/lib/gcc4/ub\"",
|
"\"$(SYSTEM_APPS_DIR)/Autodesk/FBX SDK/2013.3/lib/gcc4/ub\"",
|
||||||
@@ -1762,7 +1846,6 @@
|
|||||||
OTHER_LDFLAGS = "-ObjC";
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
PRODUCT_NAME = kraken;
|
PRODUCT_NAME = kraken;
|
||||||
SHARED_PRECOMPS_DIR = "$(CACHE_ROOT)/SharedPrecompiledHeaders";
|
SHARED_PRECOMPS_DIR = "$(CACHE_ROOT)/SharedPrecompiledHeaders";
|
||||||
SKIP_INSTALL = YES;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@@ -1771,6 +1854,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||||
|
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||||
DSTROOT = /tmp/KREngine.dst;
|
DSTROOT = /tmp/KREngine.dst;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@@ -1778,7 +1862,7 @@
|
|||||||
);
|
);
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "kraken_ios/Kraken-Prefix.pch";
|
GCC_PREFIX_HEADER = "kraken_ios/Kraken-Prefix.pch";
|
||||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"\"$(SYSTEM_APPS_DIR)/Autodesk/FBX SDK/2013.3/lib/gcc4/ub\"",
|
"\"$(SYSTEM_APPS_DIR)/Autodesk/FBX SDK/2013.3/lib/gcc4/ub\"",
|
||||||
@@ -1786,7 +1870,6 @@
|
|||||||
OTHER_LDFLAGS = "-ObjC";
|
OTHER_LDFLAGS = "-ObjC";
|
||||||
PRODUCT_NAME = kraken;
|
PRODUCT_NAME = kraken;
|
||||||
SHARED_PRECOMPS_DIR = "$(CACHE_ROOT)/SharedPrecompiledHeaders";
|
SHARED_PRECOMPS_DIR = "$(CACHE_ROOT)/SharedPrecompiledHeaders";
|
||||||
SKIP_INSTALL = YES;
|
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
@@ -1796,7 +1879,6 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||||
CLANG_CXX_LIBRARY = "libstdc++";
|
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
@@ -1815,14 +1897,14 @@
|
|||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
"\"/Applications/Autodesk/FBX SDK/2013.3/include\"",
|
"\"/Applications/Autodesk/FBX SDK/2014.2/include\"",
|
||||||
/usr/local/include,
|
/usr/local/include,
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = "kraken_osx/Kraken-Info.plist";
|
INFOPLIST_FILE = "kraken_osx/Kraken-Info.plist";
|
||||||
LD_DYLIB_INSTALL_NAME = "@rpath/${EXECUTABLE_PATH}";
|
LD_DYLIB_INSTALL_NAME = "@rpath/${EXECUTABLE_PATH}";
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"\"$(SYSTEM_APPS_DIR)/Autodesk/FBX SDK/2013.3/lib/gcc4/ub\"",
|
"\"$(SYSTEM_APPS_DIR)/Autodesk/FBX SDK/2014.2/lib/ios-i386/release\"",
|
||||||
"\"$(SYSTEM_APPS_DIR)/Imagination/PowerVR/GraphicsSDK/PVRTexTool/Library/OSX_x86/Static\"",
|
"\"$(SYSTEM_APPS_DIR)/Imagination/PowerVR/GraphicsSDK/PVRTexTool/Library/OSX_x86/Static\"",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||||
@@ -1840,7 +1922,6 @@
|
|||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = YES;
|
ALWAYS_SEARCH_USER_PATHS = YES;
|
||||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||||
CLANG_CXX_LIBRARY = "libstdc++";
|
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
COPY_PHASE_STRIP = YES;
|
COPY_PHASE_STRIP = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
@@ -1859,14 +1940,14 @@
|
|||||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
"\"/Applications/Autodesk/FBX SDK/2013.3/include\"",
|
"\"/Applications/Autodesk/FBX SDK/2014.2/include\"",
|
||||||
/usr/local/include,
|
/usr/local/include,
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = "kraken_osx/Kraken-Info.plist";
|
INFOPLIST_FILE = "kraken_osx/Kraken-Info.plist";
|
||||||
LD_DYLIB_INSTALL_NAME = "@rpath/${EXECUTABLE_PATH}";
|
LD_DYLIB_INSTALL_NAME = "@rpath/${EXECUTABLE_PATH}";
|
||||||
LIBRARY_SEARCH_PATHS = (
|
LIBRARY_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"\"$(SYSTEM_APPS_DIR)/Autodesk/FBX SDK/2013.3/lib/gcc4/ub\"",
|
"\"$(SYSTEM_APPS_DIR)/Autodesk/FBX SDK/2014.2/lib/ios-i386/release\"",
|
||||||
"\"$(SYSTEM_APPS_DIR)/Imagination/PowerVR/GraphicsSDK/PVRTexTool/Library/OSX_x86/Static\"",
|
"\"$(SYSTEM_APPS_DIR)/Imagination/PowerVR/GraphicsSDK/PVRTexTool/Library/OSX_x86/Static\"",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0500"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "E491016013C99B9E0098455B"
|
||||||
|
BuildableName = "libkraken.a"
|
||||||
|
BlueprintName = "Kraken - ios"
|
||||||
|
ReferencedContainer = "container:Kraken.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0500"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "E4BBBB7D1512A40300F43B5B"
|
||||||
|
BuildableName = "kraken.framework"
|
||||||
|
BlueprintName = "Kraken - osx"
|
||||||
|
ReferencedContainer = "container:Kraken.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0500"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "E4C8E4F316B9B2E20031DDCB"
|
||||||
|
BuildableName = "kraken_standard_assets_osx.bundle"
|
||||||
|
BlueprintName = "Kraken Standard Assets - OSX"
|
||||||
|
ReferencedContainer = "container:Kraken.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0500"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "E4C8E4E316B9B2D50031DDCB"
|
||||||
|
BuildableName = "kraken_standard_assets_ios.bundle"
|
||||||
|
BlueprintName = "Kraken Standard Assets - iOS"
|
||||||
|
ReferencedContainer = "container:Kraken.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>SchemeUserState</key>
|
||||||
|
<dict>
|
||||||
|
<key>Kraken - ios.xcscheme</key>
|
||||||
|
<dict>
|
||||||
|
<key>isShown</key>
|
||||||
|
<false/>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>30</integer>
|
||||||
|
</dict>
|
||||||
|
<key>Kraken - osx.xcscheme</key>
|
||||||
|
<dict>
|
||||||
|
<key>isShown</key>
|
||||||
|
<false/>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>31</integer>
|
||||||
|
</dict>
|
||||||
|
<key>Kraken Standard Assets - OSX.xcscheme</key>
|
||||||
|
<dict>
|
||||||
|
<key>isShown</key>
|
||||||
|
<false/>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>33</integer>
|
||||||
|
</dict>
|
||||||
|
<key>Kraken Standard Assets - iOS.xcscheme</key>
|
||||||
|
<dict>
|
||||||
|
<key>isShown</key>
|
||||||
|
<false/>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>32</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>SuppressBuildableAutocreation</key>
|
||||||
|
<dict>
|
||||||
|
<key>E491016013C99B9E0098455B</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>E4BBBB7D1512A40300F43B5B</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>E4C8E4E316B9B2D50031DDCB</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>E4C8E4F316B9B2E20031DDCB</key>
|
||||||
|
<dict>
|
||||||
|
<key>primary</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -97,7 +97,8 @@ void KRAmbientZone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point
|
|||||||
|
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
KRVector3 rim_color;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
|
|||||||
@@ -85,9 +85,10 @@ bool KRAnimation::save(KRDataBlock &data) {
|
|||||||
|
|
||||||
KRAnimation *KRAnimation::Load(KRContext &context, const std::string &name, KRDataBlock *data)
|
KRAnimation *KRAnimation::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
|
std::string xml_string = data->getString();
|
||||||
|
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
doc.Parse((char *)data->getStart());
|
doc.Parse(xml_string.c_str());
|
||||||
KRAnimation *new_animation = new KRAnimation(context, name);
|
KRAnimation *new_animation = new KRAnimation(context, name);
|
||||||
|
|
||||||
tinyxml2::XMLElement *animation_node = doc.RootElement();
|
tinyxml2::XMLElement *animation_node = doc.RootElement();
|
||||||
@@ -172,7 +173,6 @@ void KRAnimation::update(float deltaTime)
|
|||||||
|
|
||||||
void KRAnimation::Play()
|
void KRAnimation::Play()
|
||||||
{
|
{
|
||||||
m_local_time = 0.0f;
|
|
||||||
m_playing = true;
|
m_playing = true;
|
||||||
getContext().getAnimationManager()->updateActiveAnimations(this);
|
getContext().getAnimationManager()->updateActiveAnimations(this);
|
||||||
}
|
}
|
||||||
@@ -296,3 +296,31 @@ void KRAnimation::deleteCurves()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRAnimation::_lockData()
|
||||||
|
{
|
||||||
|
for(unordered_map<std::string, KRAnimationLayer *>::iterator layer_itr = m_layers.begin(); layer_itr != m_layers.end(); layer_itr++) {
|
||||||
|
KRAnimationLayer *layer = (*layer_itr).second;
|
||||||
|
for(std::vector<KRAnimationAttribute *>::iterator attribute_itr = layer->getAttributes().begin(); attribute_itr != layer->getAttributes().end(); attribute_itr++) {
|
||||||
|
KRAnimationAttribute *attribute = *attribute_itr;
|
||||||
|
KRAnimationCurve *curve = attribute->getCurve();
|
||||||
|
if(curve) {
|
||||||
|
curve->_lockData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRAnimation::_unlockData()
|
||||||
|
{
|
||||||
|
for(unordered_map<std::string, KRAnimationLayer *>::iterator layer_itr = m_layers.begin(); layer_itr != m_layers.end(); layer_itr++) {
|
||||||
|
KRAnimationLayer *layer = (*layer_itr).second;
|
||||||
|
for(std::vector<KRAnimationAttribute *>::iterator attribute_itr = layer->getAttributes().begin(); attribute_itr != layer->getAttributes().end(); attribute_itr++) {
|
||||||
|
KRAnimationAttribute *attribute = *attribute_itr;
|
||||||
|
KRAnimationCurve *curve = attribute->getCurve();
|
||||||
|
if(curve) {
|
||||||
|
curve->_unlockData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ public:
|
|||||||
KRAnimation *split(const std::string &name, float start_time, float duration, bool strip_unchanging_attributes = true, bool clone_curves = true);
|
KRAnimation *split(const std::string &name, float start_time, float duration, bool strip_unchanging_attributes = true, bool clone_curves = true);
|
||||||
void deleteCurves();
|
void deleteCurves();
|
||||||
|
|
||||||
|
void _lockData();
|
||||||
|
void _unlockData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unordered_map<std::string, KRAnimationLayer *> m_layers;
|
unordered_map<std::string, KRAnimationLayer *> m_layers;
|
||||||
bool m_auto_play;
|
bool m_auto_play;
|
||||||
|
|||||||
@@ -37,11 +37,13 @@ KRAnimationCurve::KRAnimationCurve(KRContext &context, const std::string &name)
|
|||||||
{
|
{
|
||||||
m_pData = new KRDataBlock();
|
m_pData = new KRDataBlock();
|
||||||
m_pData->expand(sizeof(animation_curve_header));
|
m_pData->expand(sizeof(animation_curve_header));
|
||||||
|
m_pData->lock();
|
||||||
animation_curve_header *header = (animation_curve_header *)m_pData->getStart();
|
animation_curve_header *header = (animation_curve_header *)m_pData->getStart();
|
||||||
strcpy(header->szTag, "KRCURVE1.0 ");
|
strcpy(header->szTag, "KRCURVE1.0 ");
|
||||||
header->frame_rate = 30.0f;
|
header->frame_rate = 30.0f;
|
||||||
header->frame_start = 0;
|
header->frame_start = 0;
|
||||||
header->frame_count = 0;
|
header->frame_count = 0;
|
||||||
|
m_pData->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRAnimationCurve::~KRAnimationCurve()
|
KRAnimationCurve::~KRAnimationCurve()
|
||||||
@@ -84,11 +86,16 @@ KRAnimationCurve *KRAnimationCurve::Load(KRContext &context, const std::string &
|
|||||||
|
|
||||||
int KRAnimationCurve::getFrameCount()
|
int KRAnimationCurve::getFrameCount()
|
||||||
{
|
{
|
||||||
return ((animation_curve_header *)m_pData->getStart())->frame_count;
|
m_pData->lock();
|
||||||
|
int frame_count = ((animation_curve_header *)m_pData->getStart())->frame_count;
|
||||||
|
m_pData->unlock();
|
||||||
|
|
||||||
|
return frame_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAnimationCurve::setFrameCount(int frame_count)
|
void KRAnimationCurve::setFrameCount(int frame_count)
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
int prev_frame_count = getFrameCount();
|
int prev_frame_count = getFrameCount();
|
||||||
if(frame_count != prev_frame_count) {
|
if(frame_count != prev_frame_count) {
|
||||||
float fill_value = 0.0f;
|
float fill_value = 0.0f;
|
||||||
@@ -102,30 +109,42 @@ void KRAnimationCurve::setFrameCount(int frame_count)
|
|||||||
}
|
}
|
||||||
((animation_curve_header *)m_pData->getStart())->frame_count = frame_count;
|
((animation_curve_header *)m_pData->getStart())->frame_count = frame_count;
|
||||||
}
|
}
|
||||||
|
m_pData->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
float KRAnimationCurve::getFrameRate()
|
float KRAnimationCurve::getFrameRate()
|
||||||
{
|
{
|
||||||
return ((animation_curve_header *)m_pData->getStart())->frame_rate;
|
m_pData->lock();
|
||||||
|
float frame_rate =((animation_curve_header *)m_pData->getStart())->frame_rate;
|
||||||
|
m_pData->unlock();
|
||||||
|
return frame_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAnimationCurve::setFrameRate(float frame_rate)
|
void KRAnimationCurve::setFrameRate(float frame_rate)
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
((animation_curve_header *)m_pData->getStart())->frame_rate = frame_rate;
|
((animation_curve_header *)m_pData->getStart())->frame_rate = frame_rate;
|
||||||
|
m_pData->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
int KRAnimationCurve::getFrameStart()
|
int KRAnimationCurve::getFrameStart()
|
||||||
{
|
{
|
||||||
return ((animation_curve_header *)m_pData->getStart())->frame_start;
|
m_pData->lock();
|
||||||
|
int frame_start = ((animation_curve_header *)m_pData->getStart())->frame_start;
|
||||||
|
m_pData->unlock();
|
||||||
|
return frame_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAnimationCurve::setFrameStart(int frame_number)
|
void KRAnimationCurve::setFrameStart(int frame_number)
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
((animation_curve_header *)m_pData->getStart())->frame_start = frame_number;
|
((animation_curve_header *)m_pData->getStart())->frame_start = frame_number;
|
||||||
|
m_pData->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
float KRAnimationCurve::getValue(int frame_number)
|
float KRAnimationCurve::getValue(int frame_number)
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
//printf("frame_number: %i\n", frame_number);
|
//printf("frame_number: %i\n", frame_number);
|
||||||
int clamped_frame = frame_number - getFrameStart();
|
int clamped_frame = frame_number - getFrameStart();
|
||||||
if(clamped_frame < 0) {
|
if(clamped_frame < 0) {
|
||||||
@@ -134,43 +153,56 @@ float KRAnimationCurve::getValue(int frame_number)
|
|||||||
clamped_frame = getFrameCount()-1;
|
clamped_frame = getFrameCount()-1;
|
||||||
}
|
}
|
||||||
float *frame_data = (float *)((char *)m_pData->getStart() + sizeof(animation_curve_header));
|
float *frame_data = (float *)((char *)m_pData->getStart() + sizeof(animation_curve_header));
|
||||||
return frame_data[clamped_frame];
|
float v = frame_data[clamped_frame];
|
||||||
|
m_pData->unlock();
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAnimationCurve::setValue(int frame_number, float value)
|
void KRAnimationCurve::setValue(int frame_number, float value)
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
int clamped_frame = frame_number - getFrameStart();
|
int clamped_frame = frame_number - getFrameStart();
|
||||||
if(clamped_frame >= 0 && clamped_frame < getFrameCount()) {
|
if(clamped_frame >= 0 && clamped_frame < getFrameCount()) {
|
||||||
float *frame_data = (float *)((char *)m_pData->getStart() + sizeof(animation_curve_header));
|
float *frame_data = (float *)((char *)m_pData->getStart() + sizeof(animation_curve_header));
|
||||||
frame_data[clamped_frame] = value;
|
frame_data[clamped_frame] = value;
|
||||||
}
|
}
|
||||||
|
m_pData->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
float KRAnimationCurve::getValue(float local_time)
|
float KRAnimationCurve::getValue(float local_time)
|
||||||
{
|
{
|
||||||
// TODO - Need to add interpolation for time values between frames.
|
// TODO - Need to add interpolation for time values between frames.
|
||||||
// Must consider looping animations when determining which two frames to interpolate between.
|
// Must consider looping animations when determining which two frames to interpolate between.
|
||||||
return getValue((int)(local_time * getFrameRate()));
|
m_pData->lock();
|
||||||
|
float v = getValue((int)(local_time * getFrameRate()));
|
||||||
|
m_pData->unlock();
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRAnimationCurve::valueChanges(float start_time, float duration)
|
bool KRAnimationCurve::valueChanges(float start_time, float duration)
|
||||||
{
|
{
|
||||||
return valueChanges((int)(start_time * getFrameRate()), (int)(duration * getFrameRate()));
|
m_pData->lock();
|
||||||
|
bool c = valueChanges((int)(start_time * getFrameRate()), (int)(duration * getFrameRate()));
|
||||||
|
m_pData->unlock();
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRAnimationCurve::valueChanges(int start_frame, int frame_count)
|
bool KRAnimationCurve::valueChanges(int start_frame, int frame_count)
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
float first_value = getValue(start_frame);
|
float first_value = getValue(start_frame);
|
||||||
|
|
||||||
|
bool change_found = false;
|
||||||
|
|
||||||
// Range of frames is not inclusive of last frame
|
// Range of frames is not inclusive of last frame
|
||||||
for(int frame_number = start_frame + 1; frame_number < start_frame + frame_count; frame_number++) {
|
for(int frame_number = start_frame + 1; frame_number < start_frame + frame_count && !change_found; frame_number++) {
|
||||||
if(getValue(frame_number) != first_value) {
|
if(getValue(frame_number) != first_value) {
|
||||||
return true;
|
change_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
m_pData->unlock();
|
||||||
|
return change_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRAnimationCurve *KRAnimationCurve::split(const std::string &name, float start_time, float duration)
|
KRAnimationCurve *KRAnimationCurve::split(const std::string &name, float start_time, float duration)
|
||||||
@@ -185,12 +217,24 @@ KRAnimationCurve *KRAnimationCurve::split(const std::string &name, int start_fra
|
|||||||
new_curve->setFrameRate(getFrameRate());
|
new_curve->setFrameRate(getFrameRate());
|
||||||
new_curve->setFrameStart(start_frame);
|
new_curve->setFrameStart(start_frame);
|
||||||
new_curve->setFrameCount(frame_count);
|
new_curve->setFrameCount(frame_count);
|
||||||
|
new_curve->m_pData->lock();
|
||||||
|
|
||||||
// Range of frames is not inclusive of last frame
|
// Range of frames is not inclusive of last frame
|
||||||
for(int frame_number = start_frame; frame_number < start_frame + frame_count; frame_number++) {
|
for(int frame_number = start_frame; frame_number < start_frame + frame_count; frame_number++) {
|
||||||
new_curve->setValue(frame_number, getValue(frame_number)); // TODO - MEMCPY here?
|
new_curve->setValue(frame_number, getValue(frame_number)); // TODO - MEMCPY here?
|
||||||
}
|
}
|
||||||
|
new_curve->m_pData->unlock();
|
||||||
|
|
||||||
getContext().getAnimationCurveManager()->addAnimationCurve(new_curve);
|
getContext().getAnimationCurveManager()->addAnimationCurve(new_curve);
|
||||||
return new_curve;
|
return new_curve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRAnimationCurve::_lockData()
|
||||||
|
{
|
||||||
|
m_pData->lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRAnimationCurve::_unlockData()
|
||||||
|
{
|
||||||
|
m_pData->unlock();
|
||||||
|
}
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ public:
|
|||||||
KRAnimationCurve *split(const std::string &name, float start_time, float duration);
|
KRAnimationCurve *split(const std::string &name, float start_time, float duration);
|
||||||
KRAnimationCurve *split(const std::string &name, int start_frame, int frame_count);
|
KRAnimationCurve *split(const std::string &name, int start_frame, int frame_count);
|
||||||
|
|
||||||
|
void _lockData();
|
||||||
|
void _unlockData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KRDataBlock *m_pData;
|
KRDataBlock *m_pData;
|
||||||
|
|
||||||
|
|||||||
@@ -50,12 +50,19 @@ void KRAnimationCurveManager::deleteAnimationCurve(KRAnimationCurve *curve) {
|
|||||||
|
|
||||||
KRAnimationCurve *KRAnimationCurveManager::loadAnimationCurve(const std::string &name, KRDataBlock *data) {
|
KRAnimationCurve *KRAnimationCurveManager::loadAnimationCurve(const std::string &name, KRDataBlock *data) {
|
||||||
KRAnimationCurve *pAnimationCurve = KRAnimationCurve::Load(*m_pContext, name, data);
|
KRAnimationCurve *pAnimationCurve = KRAnimationCurve::Load(*m_pContext, name, data);
|
||||||
m_animationCurves[name] = pAnimationCurve;
|
if(pAnimationCurve) {
|
||||||
|
m_animationCurves[name] = pAnimationCurve;
|
||||||
|
}
|
||||||
return pAnimationCurve;
|
return pAnimationCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRAnimationCurve *KRAnimationCurveManager::getAnimationCurve(const std::string &name) {
|
KRAnimationCurve *KRAnimationCurveManager::getAnimationCurve(const std::string &name) {
|
||||||
return m_animationCurves[name];
|
unordered_map<std::string, KRAnimationCurve *>::iterator itr = m_animationCurves.find(name);
|
||||||
|
if(itr == m_animationCurves.end()) {
|
||||||
|
return NULL; // Not found
|
||||||
|
} else {
|
||||||
|
return (*itr).second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unordered_map<std::string, KRAnimationCurve *> &KRAnimationCurveManager::getAnimationCurves() {
|
unordered_map<std::string, KRAnimationCurve *> &KRAnimationCurveManager::getAnimationCurves() {
|
||||||
@@ -64,6 +71,7 @@ unordered_map<std::string, KRAnimationCurve *> &KRAnimationCurveManager::getAnim
|
|||||||
|
|
||||||
void KRAnimationCurveManager::addAnimationCurve(KRAnimationCurve *new_animation_curve)
|
void KRAnimationCurveManager::addAnimationCurve(KRAnimationCurve *new_animation_curve)
|
||||||
{
|
{
|
||||||
|
assert(new_animation_curve != NULL);
|
||||||
m_animationCurves[new_animation_curve->getName()] = new_animation_curve;
|
m_animationCurves[new_animation_curve->getName()] = new_animation_curve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ KRAnimationManager::KRAnimationManager(KRContext &context) : KRContextObject(con
|
|||||||
}
|
}
|
||||||
|
|
||||||
KRAnimationManager::~KRAnimationManager() {
|
KRAnimationManager::~KRAnimationManager() {
|
||||||
|
for(std::set<KRAnimation *>::iterator itr = m_activeAnimations.begin(); itr != m_activeAnimations.end(); itr++) {
|
||||||
|
KRAnimation *animation = *itr;
|
||||||
|
animation->_unlockData();
|
||||||
|
}
|
||||||
|
|
||||||
for(unordered_map<std::string, KRAnimation *>::iterator itr = m_animations.begin(); itr != m_animations.end(); ++itr){
|
for(unordered_map<std::string, KRAnimation *>::iterator itr = m_animations.begin(); itr != m_animations.end(); ++itr){
|
||||||
delete (*itr).second;
|
delete (*itr).second;
|
||||||
}
|
}
|
||||||
@@ -52,11 +57,13 @@ void KRAnimationManager::startFrame(float deltaTime)
|
|||||||
// Add playing animations to the active animations list
|
// Add playing animations to the active animations list
|
||||||
if(active_animations_itr == m_activeAnimations.end()) {
|
if(active_animations_itr == m_activeAnimations.end()) {
|
||||||
m_activeAnimations.insert(animation);
|
m_activeAnimations.insert(animation);
|
||||||
|
animation->_lockData();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Remove stopped animations from the active animations list
|
// Remove stopped animations from the active animations list
|
||||||
if(active_animations_itr != m_activeAnimations.end()) {
|
if(active_animations_itr != m_activeAnimations.end()) {
|
||||||
m_activeAnimations.erase(active_animations_itr);
|
m_activeAnimations.erase(active_animations_itr);
|
||||||
|
animation->_unlockData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,8 +214,8 @@ void KRAudioManager::renderAudio(UInt32 inNumberFrames, AudioBufferList *ioData)
|
|||||||
|
|
||||||
|
|
||||||
uint64_t end_time = mach_absolute_time();
|
uint64_t end_time = mach_absolute_time();
|
||||||
uint64_t duration = (end_time - start_time) * m_timebase_info.numer / m_timebase_info.denom; // Nanoseconds
|
// uint64_t duration = (end_time - start_time) * m_timebase_info.numer / m_timebase_info.denom; // Nanoseconds
|
||||||
uint64_t max_duration = (uint64_t)inNumberFrames * 1000000000 / 44100;
|
// uint64_t max_duration = (uint64_t)inNumberFrames * 1000000000 / 44100;
|
||||||
// fprintf(stderr, "audio load: %5.1f%% hrtf channels: %li\n", (float)(duration * 1000 / max_duration) / 10.0f, m_mapped_sources.size());
|
// fprintf(stderr, "audio load: %5.1f%% hrtf channels: %li\n", (float)(duration * 1000 / max_duration) / 10.0f, m_mapped_sources.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1364,14 +1364,14 @@ KRDataBlock *KRAudioManager::getBufferData(int size)
|
|||||||
data = new KRDataBlock();
|
data = new KRDataBlock();
|
||||||
data->expand(size);
|
data->expand(size);
|
||||||
}
|
}
|
||||||
|
data->lock();
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAudioManager::recycleBufferData(KRDataBlock *data)
|
void KRAudioManager::recycleBufferData(KRDataBlock *data)
|
||||||
{
|
{
|
||||||
if(data != NULL) {
|
if(data != NULL) {
|
||||||
|
data->unlock();
|
||||||
if(data->getSize() == KRENGINE_AUDIO_MAX_BUFFER_SIZE && m_bufferPoolIdle.size() < KRENGINE_AUDIO_MAX_POOL_SIZE) {
|
if(data->getSize() == KRENGINE_AUDIO_MAX_BUFFER_SIZE && m_bufferPoolIdle.size() < KRENGINE_AUDIO_MAX_POOL_SIZE) {
|
||||||
m_bufferPoolIdle.push_back(data);
|
m_bufferPoolIdle.push_back(data);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ OSStatus KRAudioSample::ReadProc( // AudioFile_ReadProc
|
|||||||
KRAudioSample *sound = (KRAudioSample *)inClientData;
|
KRAudioSample *sound = (KRAudioSample *)inClientData;
|
||||||
UInt32 max_count = sound->m_pData->getSize() - inPosition;
|
UInt32 max_count = sound->m_pData->getSize() - inPosition;
|
||||||
*actualCount = requestCount < max_count ? requestCount : max_count;
|
*actualCount = requestCount < max_count ? requestCount : max_count;
|
||||||
memcpy(buffer, (unsigned char *)sound->m_pData->getStart() + inPosition, *actualCount);
|
sound->m_pData->copy(buffer, inPosition, *actualCount);
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +231,7 @@ void KRAudioSample::openFile()
|
|||||||
{
|
{
|
||||||
// AudioFileInitializeWithCallbacks
|
// AudioFileInitializeWithCallbacks
|
||||||
if(m_fileRef == NULL) {
|
if(m_fileRef == NULL) {
|
||||||
|
|
||||||
// Temp variables
|
// Temp variables
|
||||||
UInt32 propertySize;
|
UInt32 propertySize;
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ KRAudioSource::KRAudioSource(KRScene &scene, std::string name) : KRNode(scene, n
|
|||||||
m_enable_obstruction = true;
|
m_enable_obstruction = true;
|
||||||
|
|
||||||
m_start_audio_frame = -1;
|
m_start_audio_frame = -1;
|
||||||
|
m_paused_audio_frame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRAudioSource::~KRAudioSource()
|
KRAudioSource::~KRAudioSource()
|
||||||
@@ -208,7 +209,8 @@ void KRAudioSource::render(KRCamera *pCamera, std::vector<KRPointLight *> &point
|
|||||||
|
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
KRVector3 rim_light;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_light, 0.0f)) {
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
@@ -314,12 +316,13 @@ void KRAudioSource::setRolloffFactor(float rolloff_factor)
|
|||||||
|
|
||||||
void KRAudioSource::setLooping(bool looping)
|
void KRAudioSource::setLooping(bool looping)
|
||||||
{
|
{
|
||||||
|
// Enable or disable looping playback; Audio source must be stopped and re-started for loop mode changes to take effect
|
||||||
m_looping = looping;
|
m_looping = looping;
|
||||||
// Audio source must be stopped and re-started for loop mode changes to take effect
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRAudioSource::getLooping()
|
bool KRAudioSource::getLooping()
|
||||||
{
|
{
|
||||||
|
// Returns true if the playback will automatically loop
|
||||||
return m_looping;
|
return m_looping;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,38 +403,54 @@ void KRAudioSource::physicsUpdate(float deltaTime)
|
|||||||
|
|
||||||
void KRAudioSource::play()
|
void KRAudioSource::play()
|
||||||
{
|
{
|
||||||
KRAudioManager *audioManager = getContext().getAudioManager();
|
// Start playback of audio at the current audio sample position. If audio is already playing, this has no effect.
|
||||||
m_start_audio_frame = audioManager->getAudioFrame();
|
// play() does not automatically seek to the beginning of the sample. Call setAudioFrame( 0 ) first if you wish the playback to begin at the start of the audio sample.
|
||||||
audioManager->activateAudioSource(this);
|
// If not set to looping, audio playback ends automatically at the end of the sample
|
||||||
if(audioManager->getAudioEngine() == KRAudioManager::KRAKEN_AUDIO_OPENAL) {
|
|
||||||
getContext().getAudioManager()->makeCurrentContext();
|
if(!m_playing) {
|
||||||
prime();
|
KRAudioManager *audioManager = getContext().getAudioManager();
|
||||||
updatePosition();
|
assert(m_start_audio_frame == -1);
|
||||||
|
m_start_audio_frame = audioManager->getAudioFrame() - m_paused_audio_frame;
|
||||||
|
m_paused_audio_frame = -1;
|
||||||
|
audioManager->activateAudioSource(this);
|
||||||
|
if(audioManager->getAudioEngine() == KRAudioManager::KRAKEN_AUDIO_OPENAL) {
|
||||||
|
getContext().getAudioManager()->makeCurrentContext();
|
||||||
|
prime();
|
||||||
|
updatePosition();
|
||||||
|
|
||||||
if(m_is3d) {
|
if(m_is3d) {
|
||||||
ALDEBUG(alSource3f(m_sourceID, AL_VELOCITY, 0.0f, 0.0f, 0.0f));
|
ALDEBUG(alSource3f(m_sourceID, AL_VELOCITY, 0.0f, 0.0f, 0.0f));
|
||||||
ALDEBUG(alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance));
|
ALDEBUG(alSourcef(m_sourceID, AL_REFERENCE_DISTANCE, m_referenceDistance));
|
||||||
ALDEBUG(alSourcef(m_sourceID, AL_ROLLOFF_FACTOR, m_rolloffFactor));
|
ALDEBUG(alSourcef(m_sourceID, AL_ROLLOFF_FACTOR, m_rolloffFactor));
|
||||||
ALDEBUG(alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb)));
|
ALDEBUG(alcASASetSourceProc(ALC_ASA_REVERB_SEND_LEVEL, m_sourceID, &m_reverb, sizeof(m_reverb)));
|
||||||
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_FALSE));
|
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_FALSE));
|
||||||
} else {
|
} else {
|
||||||
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_TRUE));
|
ALDEBUG(alSourcei(m_sourceID, AL_SOURCE_RELATIVE, AL_TRUE));
|
||||||
ALDEBUG(alSource3f(m_sourceID, AL_POSITION, 0.0, 0.0, 0.0));
|
ALDEBUG(alSource3f(m_sourceID, AL_POSITION, 0.0, 0.0, 0.0));
|
||||||
|
}
|
||||||
|
ALDEBUG(alSourcePlay(m_sourceID));
|
||||||
}
|
}
|
||||||
ALDEBUG(alSourcePlay(m_sourceID));
|
|
||||||
}
|
}
|
||||||
m_playing = true;
|
m_playing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAudioSource::stop()
|
void KRAudioSource::stop()
|
||||||
{
|
{
|
||||||
m_start_audio_frame = -1;
|
// Stop playback of audio. If audio is already stopped, this has no effect.
|
||||||
m_playing = false;
|
// If play() is called afterwards, playback will continue at the current audio sample position.
|
||||||
getContext().getAudioManager()->deactivateAudioSource(this);
|
|
||||||
|
if(m_playing) {
|
||||||
|
m_paused_audio_frame = getAudioFrame();
|
||||||
|
m_start_audio_frame = -1;
|
||||||
|
m_playing = false;
|
||||||
|
getContext().getAudioManager()->deactivateAudioSource(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRAudioSource::isPlaying()
|
bool KRAudioSource::isPlaying()
|
||||||
{
|
{
|
||||||
|
// Returns true if audio is playing. Will return false if a non-looped playback has reached the end of the audio sample.
|
||||||
|
|
||||||
return m_playing;
|
return m_playing;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,16 +523,46 @@ int KRAudioSource::getBufferFrame()
|
|||||||
return m_currentBufferFrame;
|
return m_currentBufferFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64_t KRAudioSource::getStartAudioFrame()
|
__int64_t KRAudioSource::getAudioFrame()
|
||||||
{
|
{
|
||||||
return m_start_audio_frame;
|
// Returns the audio playback position in units of integer audio frames.
|
||||||
|
|
||||||
|
if(m_playing) {
|
||||||
|
return getContext().getAudioManager()->getAudioFrame() - m_start_audio_frame;
|
||||||
|
} else {
|
||||||
|
return m_paused_audio_frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRAudioSource::setAudioFrame(__int64_t next_frame)
|
||||||
|
{
|
||||||
|
// Sets the audio playback position with units of integer audio frames.
|
||||||
|
if(m_playing) {
|
||||||
|
m_start_audio_frame = getContext().getAudioManager()->getAudioFrame() - next_frame;
|
||||||
|
} else {
|
||||||
|
m_paused_audio_frame = next_frame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float KRAudioSource::getAudioTime()
|
||||||
|
{
|
||||||
|
// Gets the audio playback position with units of floating point seconds.
|
||||||
|
|
||||||
|
return getAudioFrame() / 44100.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRAudioSource::setAudioTime(float new_position)
|
||||||
|
{
|
||||||
|
// Sets the audio playback position with units of floating point seconds.
|
||||||
|
setAudioFrame(new_position * 44100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRAudioSource::sample(int frame_count, int channel, float *buffer, float gain)
|
void KRAudioSource::sample(int frame_count, int channel, float *buffer, float gain)
|
||||||
{
|
{
|
||||||
KRAudioSample *source_sample = getAudioSample();
|
KRAudioSample *source_sample = getAudioSample();
|
||||||
if(source_sample && m_playing) {
|
if(source_sample && m_playing) {
|
||||||
__int64_t next_frame = getContext().getAudioManager()->getAudioFrame() - getStartAudioFrame();
|
__int64_t next_frame = getAudioFrame();
|
||||||
source_sample->sample(next_frame, frame_count, channel, buffer, gain, m_looping);
|
source_sample->sample(next_frame, frame_count, channel, buffer, gain, m_looping);
|
||||||
if(!m_looping && next_frame > source_sample->getFrameCount()) {
|
if(!m_looping && next_frame > source_sample->getFrameCount()) {
|
||||||
stop();
|
stop();
|
||||||
|
|||||||
@@ -51,10 +51,41 @@ public:
|
|||||||
virtual void physicsUpdate(float deltaTime);
|
virtual void physicsUpdate(float deltaTime);
|
||||||
|
|
||||||
void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
|
// ---- Audio Playback Controls ----
|
||||||
|
|
||||||
|
// Start playback of audio at the current audio sample position. If audio is already playing, this has no effect.
|
||||||
|
// play() does not automatically seek to the beginning of the sample. Call setAudioFrame( 0 ) first if you wish the playback to begin at the start of the audio sample.
|
||||||
|
// If not set to looping, audio playback ends automatically at the end of the sample
|
||||||
void play();
|
void play();
|
||||||
|
|
||||||
|
// Stop playback of audio. If audio is already stopped, this has no effect.
|
||||||
|
// If play() is called afterwards, playback will continue at the current audio sample position.
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
// Returns true if audio is playing. Will return false if a non-looped playback has reached the end of the audio sample.
|
||||||
bool isPlaying();
|
bool isPlaying();
|
||||||
|
|
||||||
|
// Returns the audio playback position in units of integer audio frames.
|
||||||
|
__int64_t getAudioFrame();
|
||||||
|
|
||||||
|
// Sets the audio playback position with units of integer audio frames.
|
||||||
|
void setAudioFrame(__int64_t next_frame);
|
||||||
|
|
||||||
|
// Gets the audio playback position with units of floating point seconds.
|
||||||
|
float getAudioTime();
|
||||||
|
|
||||||
|
// Sets the audio playback position with units of floating point seconds.
|
||||||
|
void setAudioTime(float new_position);
|
||||||
|
|
||||||
|
// Returns true if the playback will automatically loop
|
||||||
|
bool getLooping();
|
||||||
|
|
||||||
|
// Enable or disable looping playback; Audio source must be stopped and re-started for loop mode changes to take effect
|
||||||
|
void setLooping(bool looping);
|
||||||
|
|
||||||
|
// ---- End: Audio Playback Controls ----
|
||||||
|
|
||||||
void setSample(const std::string &sound_name);
|
void setSample(const std::string &sound_name);
|
||||||
std::string getSample();
|
std::string getSample();
|
||||||
|
|
||||||
@@ -66,8 +97,7 @@ public:
|
|||||||
float getPitch();
|
float getPitch();
|
||||||
void setPitch(float pitch);
|
void setPitch(float pitch);
|
||||||
|
|
||||||
bool getLooping();
|
|
||||||
void setLooping(bool looping);
|
|
||||||
|
|
||||||
bool getIs3D();
|
bool getIs3D();
|
||||||
void setIs3D(bool is3D);
|
void setIs3D(bool is3D);
|
||||||
@@ -94,12 +124,11 @@ public:
|
|||||||
KRAudioBuffer *getBuffer();
|
KRAudioBuffer *getBuffer();
|
||||||
int getBufferFrame();
|
int getBufferFrame();
|
||||||
|
|
||||||
|
|
||||||
__int64_t getStartAudioFrame();
|
|
||||||
void sample(int frame_count, int channel, float *buffer, float gain);
|
void sample(int frame_count, int channel, float *buffer, float gain);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
__int64_t m_start_audio_frame; // Global audio frame that matches the start of the audio sample playback
|
__int64_t m_start_audio_frame; // Global audio frame that matches the start of the audio sample playback; when paused or not playing, this contains a value of -1
|
||||||
|
__int64_t m_paused_audio_frame; // When paused or not playing, this contains the local audio frame number. When playing, this contains a value of -1
|
||||||
int m_currentBufferFrame; // Siren Audio Engine frame number within current buffer
|
int m_currentBufferFrame; // Siren Audio Engine frame number within current buffer
|
||||||
void advanceBuffer();
|
void advanceBuffer();
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ void KRBone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights
|
|||||||
|
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
KRVector3 rim_color;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
||||||
std::vector<KRMesh *> sphereModels = getContext().getModelManager()->getModel("__sphere");
|
std::vector<KRMesh *> sphereModels = getContext().getModelManager()->getModel("__sphere");
|
||||||
if(sphereModels.size()) {
|
if(sphereModels.size()) {
|
||||||
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
||||||
|
|||||||
@@ -53,35 +53,18 @@ KRBundle::KRBundle(KRContext &context, std::string name, KRDataBlock *pData) : K
|
|||||||
{
|
{
|
||||||
m_pData = pData;
|
m_pData = pData;
|
||||||
|
|
||||||
unsigned char *pFile = (unsigned char *)m_pData->getStart();
|
__int64_t file_pos = 0;
|
||||||
while(pFile < m_pData->getEnd() ) {
|
while(file_pos < m_pData->getSize()) {
|
||||||
tar_header_type *file_header = (tar_header_type *)pFile;
|
tar_header_type file_header;
|
||||||
size_t file_size = strtol(file_header->file_size, NULL, 8);
|
m_pData->copy(&file_header, file_pos, sizeof(file_header));
|
||||||
pFile += 512; // Skip past the header to the file contents
|
size_t file_size = strtol(file_header.file_size, NULL, 8);
|
||||||
|
file_pos += 512; // Skip past the header to the file contents
|
||||||
if(file_header->file_name[0] != '\0' && file_header->file_name[0] != '.') {
|
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
|
// We ignore the last two records in the tar file, which are zero'ed out tar_header structures
|
||||||
KRDataBlock *pFileData = new KRDataBlock();
|
KRDataBlock *pFileData = pData->getSubBlock(file_pos, file_size);
|
||||||
if(pFileData->load(pFile, file_size)) {
|
context.loadResource(file_header.file_name, pFileData);
|
||||||
context.loadResource(file_header->file_name, pFileData);
|
|
||||||
} else {
|
|
||||||
delete pFileData;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
file_pos += RoundUpSize(file_size);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
pFile += RoundUpSize(file_size);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +73,9 @@ KRBundle::KRBundle(KRContext &context, std::string name) : KRResource(context, n
|
|||||||
// Create an empty krbundle (tar) file, initialized with two zero-ed out file headers, which terminate it.
|
// Create an empty krbundle (tar) file, initialized with two zero-ed out file headers, which terminate it.
|
||||||
m_pData = new KRDataBlock();
|
m_pData = new KRDataBlock();
|
||||||
m_pData->expand(KRENGINE_KRBUNDLE_HEADER_SIZE * 2);
|
m_pData->expand(KRENGINE_KRBUNDLE_HEADER_SIZE * 2);
|
||||||
|
m_pData->lock();
|
||||||
memset(m_pData->getStart(), 0, m_pData->getSize());
|
memset(m_pData->getStart(), 0, m_pData->getSize());
|
||||||
|
m_pData->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t KRBundle::RoundUpSize(size_t s)
|
size_t KRBundle::RoundUpSize(size_t s)
|
||||||
@@ -142,6 +127,8 @@ void KRBundle::append(KRResource &resource)
|
|||||||
|
|
||||||
m_pData->expand(KRENGINE_KRBUNDLE_HEADER_SIZE + resource_data.getSize() + padding_size - KRENGINE_KRBUNDLE_HEADER_SIZE * 2); // We will overwrite the existing zero-ed out file headers that marked the end of the archive, so we don't have to include their size here
|
m_pData->expand(KRENGINE_KRBUNDLE_HEADER_SIZE + resource_data.getSize() + padding_size - KRENGINE_KRBUNDLE_HEADER_SIZE * 2); // We will overwrite the existing zero-ed out file headers that marked the end of the archive, so we don't have to include their size here
|
||||||
|
|
||||||
|
m_pData->lock();
|
||||||
|
|
||||||
// Get location of file header
|
// Get location of file header
|
||||||
tar_header_type *file_header = (tar_header_type *)((unsigned char *)m_pData->getEnd() - padding_size - resource_data.getSize() - KRENGINE_KRBUNDLE_HEADER_SIZE);
|
tar_header_type *file_header = (tar_header_type *)((unsigned char *)m_pData->getEnd() - padding_size - resource_data.getSize() - KRENGINE_KRBUNDLE_HEADER_SIZE);
|
||||||
|
|
||||||
@@ -149,7 +136,9 @@ void KRBundle::append(KRResource &resource)
|
|||||||
memset(file_header, 0, KRENGINE_KRBUNDLE_HEADER_SIZE);
|
memset(file_header, 0, KRENGINE_KRBUNDLE_HEADER_SIZE);
|
||||||
|
|
||||||
// Copy resource data
|
// Copy resource data
|
||||||
|
resource_data.lock();
|
||||||
memcpy((unsigned char *)m_pData->getEnd() - padding_size - resource_data.getSize(), resource_data.getStart(), resource_data.getSize());
|
memcpy((unsigned char *)m_pData->getEnd() - padding_size - resource_data.getSize(), resource_data.getStart(), resource_data.getSize());
|
||||||
|
resource_data.unlock();
|
||||||
|
|
||||||
// Zero out alignment padding and terminating set of file header blocks
|
// Zero out alignment padding and terminating set of file header blocks
|
||||||
memset((unsigned char *)m_pData->getEnd() - padding_size, 0, padding_size);
|
memset((unsigned char *)m_pData->getEnd() - padding_size, 0, padding_size);
|
||||||
@@ -172,4 +161,6 @@ void KRBundle::append(KRResource &resource)
|
|||||||
check_sum += byte_ptr[i];
|
check_sum += byte_ptr[i];
|
||||||
}
|
}
|
||||||
sprintf(file_header->checksum, "%07o", check_sum);
|
sprintf(file_header->checksum, "%07o", check_sum);
|
||||||
|
|
||||||
|
m_pData->unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,14 +54,9 @@ KRCamera::KRCamera(KRScene &scene, std::string name) : KRNode(scene, name) {
|
|||||||
volumetricLightAccumulationBuffer = 0;
|
volumetricLightAccumulationBuffer = 0;
|
||||||
volumetricLightAccumulationTexture = 0;
|
volumetricLightAccumulationTexture = 0;
|
||||||
m_frame_times_filled = 0;
|
m_frame_times_filled = 0;
|
||||||
|
|
||||||
m_debug_text_vertices = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRCamera::~KRCamera() {
|
KRCamera::~KRCamera() {
|
||||||
if(m_debug_text_vertices) {
|
|
||||||
delete m_debug_text_vertices;
|
|
||||||
}
|
|
||||||
destroyBuffers();
|
destroyBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,12 +305,13 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(m_pSkyBoxTexture) {
|
if(m_pSkyBoxTexture) {
|
||||||
getContext().getShaderManager()->selectShader("sky_box", *this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, m_viewport, KRMat4(), false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_OPAQUE);
|
KRVector3 rim_color;
|
||||||
|
getContext().getShaderManager()->selectShader("sky_box", *this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, m_viewport, KRMat4(), false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_OPAQUE, rim_color, 0.0f);
|
||||||
|
|
||||||
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture);
|
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture);
|
||||||
|
|
||||||
// Render a full screen quad
|
// Render a full screen quad
|
||||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,13 +468,13 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
|||||||
|
|
||||||
KRShader *pVisShader = getContext().getShaderManager()->getShader("visualize_overlay", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
KRShader *pVisShader = getContext().getShaderManager()->getShader("visualize_overlay", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
|
||||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_3D_CUBE, KRENGINE_VBO_3D_CUBE_SIZE, NULL, 0, KRENGINE_VBO_3D_CUBE_ATTRIBS, true);
|
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_3D_CUBE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_3D_CUBE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_3D_CUBE_ATTRIBS, true);
|
||||||
for(unordered_map<KRAABB, int>::iterator itr=m_viewport.getVisibleBounds().begin(); itr != m_viewport.getVisibleBounds().end(); itr++) {
|
for(unordered_map<KRAABB, int>::iterator itr=m_viewport.getVisibleBounds().begin(); itr != m_viewport.getVisibleBounds().end(); itr++) {
|
||||||
KRMat4 matModel = KRMat4();
|
KRMat4 matModel = KRMat4();
|
||||||
matModel.scale((*itr).first.size() * 0.5f);
|
matModel.scale((*itr).first.size() * 0.5f);
|
||||||
matModel.translate((*itr).first.center());
|
matModel.translate((*itr).first.center());
|
||||||
|
KRVector3 rim_color;
|
||||||
if(getContext().getShaderManager()->selectShader(*this, pVisShader, m_viewport, matModel, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT)) {
|
if(getContext().getShaderManager()->selectShader(*this, pVisShader, m_viewport, matModel, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, rim_color, 0.0f)) {
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -687,7 +683,9 @@ void KRCamera::renderPost()
|
|||||||
|
|
||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
KRShader *postShader = m_pContext->getShaderManager()->getShader("PostShader", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
KRShader *postShader = m_pContext->getShaderManager()->getShader("PostShader", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
getContext().getShaderManager()->selectShader(*this, postShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
|
||||||
|
KRVector3 rim_color;
|
||||||
|
getContext().getShaderManager()->selectShader(*this, postShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, rim_color, 0.0f);
|
||||||
|
|
||||||
m_pContext->getTextureManager()->selectTexture(0, NULL);
|
m_pContext->getTextureManager()->selectTexture(0, NULL);
|
||||||
m_pContext->getTextureManager()->_setActiveTexture(0);
|
m_pContext->getTextureManager()->_setActiveTexture(0);
|
||||||
@@ -704,7 +702,7 @@ void KRCamera::renderPost()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update attribute values.
|
// Update attribute values.
|
||||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||||
|
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
|
|
||||||
@@ -726,7 +724,7 @@ void KRCamera::renderPost()
|
|||||||
// viewMatrix.translate(-0.70, 0.70 - 0.45 * iShadow, 0.0);
|
// viewMatrix.translate(-0.70, 0.70 - 0.45 * iShadow, 0.0);
|
||||||
// getContext().getShaderManager()->selectShader(blitShader, KRViewport(getViewportSize(), viewMatrix, KRMat4()), shadowViewports, KRMat4(), KRVector3(), NULL, 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
// getContext().getShaderManager()->selectShader(blitShader, KRViewport(getViewportSize(), viewMatrix, KRMat4()), shadowViewports, KRMat4(), KRVector3(), NULL, 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
// m_pContext->getTextureManager()->selectTexture(1, NULL);
|
// m_pContext->getTextureManager()->selectTexture(1, NULL);
|
||||||
// m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
// m_pContext->getModelManager()->bindVBO(KRENGINE_VBO_2D_SQUARE_INDICES, KRENGINE_VBO_2D_SQUARE_VERTEXES, KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||||
// m_pContext->getTextureManager()->_setActiveTexture(0);
|
// m_pContext->getTextureManager()->_setActiveTexture(0);
|
||||||
// GLDEBUG(glBindTexture(GL_TEXTURE_2D, shadowDepthTexture[iShadow]));
|
// GLDEBUG(glBindTexture(GL_TEXTURE_2D, shadowDepthTexture[iShadow]));
|
||||||
//#if GL_EXT_shadow_samplers
|
//#if GL_EXT_shadow_samplers
|
||||||
@@ -745,7 +743,7 @@ void KRCamera::renderPost()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(m_debug_text_vertices) {
|
if(m_debug_text_vertices.getSize()) {
|
||||||
m_pContext->getModelManager()->releaseVBO(m_debug_text_vertices);
|
m_pContext->getModelManager()->releaseVBO(m_debug_text_vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -791,12 +789,13 @@ void KRCamera::renderPost()
|
|||||||
const int DEBUG_TEXT_COLUMNS = 256;
|
const int DEBUG_TEXT_COLUMNS = 256;
|
||||||
const int DEBUG_TEXT_ROWS = 128;
|
const int DEBUG_TEXT_ROWS = 128;
|
||||||
|
|
||||||
if(m_debug_text_vertices == NULL) {
|
if(m_debug_text_vertices.getSize() == 0) {
|
||||||
m_debug_text_vertices = new DebugTextVertexData[DEBUG_TEXT_COLUMNS * DEBUG_TEXT_ROWS * 6];
|
m_debug_text_vertices.expand(sizeof(DebugTextVertexData) * DEBUG_TEXT_COLUMNS * DEBUG_TEXT_ROWS * 6);
|
||||||
}
|
}
|
||||||
int vertex_count = 0;
|
int vertex_count = 0;
|
||||||
|
|
||||||
|
m_debug_text_vertices.lock();
|
||||||
|
DebugTextVertexData *vertex_data = (DebugTextVertexData *)m_debug_text_vertices.getStart();
|
||||||
|
|
||||||
pChar = szText;
|
pChar = szText;
|
||||||
float dScaleX = 2.0 / (1024 / 16);
|
float dScaleX = 2.0 / (1024 / 16);
|
||||||
@@ -824,47 +823,47 @@ void KRCamera::renderPost()
|
|||||||
KRVector2 top_left_uv = KRVector2(dTexScale * iTexCol, dTexScale * iTexRow);
|
KRVector2 top_left_uv = KRVector2(dTexScale * iTexCol, dTexScale * iTexRow);
|
||||||
KRVector2 bottom_right_uv = KRVector2(dTexScale * iTexCol + dTexScale, dTexScale * iTexRow + dTexScale);
|
KRVector2 bottom_right_uv = KRVector2(dTexScale * iTexCol + dTexScale, dTexScale * iTexRow + dTexScale);
|
||||||
|
|
||||||
m_debug_text_vertices[vertex_count].x = top_left_pos.x;
|
vertex_data[vertex_count].x = top_left_pos.x;
|
||||||
m_debug_text_vertices[vertex_count].y = top_left_pos.y;
|
vertex_data[vertex_count].y = top_left_pos.y;
|
||||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
vertex_data[vertex_count].z = 0.0f;
|
||||||
m_debug_text_vertices[vertex_count].u = top_left_uv.x;
|
vertex_data[vertex_count].u = top_left_uv.x;
|
||||||
m_debug_text_vertices[vertex_count].v = top_left_uv.y;
|
vertex_data[vertex_count].v = top_left_uv.y;
|
||||||
vertex_count++;
|
vertex_count++;
|
||||||
|
|
||||||
m_debug_text_vertices[vertex_count].x = bottom_right_pos.x;
|
vertex_data[vertex_count].x = bottom_right_pos.x;
|
||||||
m_debug_text_vertices[vertex_count].y = bottom_right_pos.y;
|
vertex_data[vertex_count].y = bottom_right_pos.y;
|
||||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
vertex_data[vertex_count].z = 0.0f;
|
||||||
m_debug_text_vertices[vertex_count].u = bottom_right_uv.x;
|
vertex_data[vertex_count].u = bottom_right_uv.x;
|
||||||
m_debug_text_vertices[vertex_count].v = bottom_right_uv.y;
|
vertex_data[vertex_count].v = bottom_right_uv.y;
|
||||||
vertex_count++;
|
vertex_count++;
|
||||||
|
|
||||||
m_debug_text_vertices[vertex_count].x = top_left_pos.x;
|
vertex_data[vertex_count].x = top_left_pos.x;
|
||||||
m_debug_text_vertices[vertex_count].y = bottom_right_pos.y;
|
vertex_data[vertex_count].y = bottom_right_pos.y;
|
||||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
vertex_data[vertex_count].z = 0.0f;
|
||||||
m_debug_text_vertices[vertex_count].u = top_left_uv.x;
|
vertex_data[vertex_count].u = top_left_uv.x;
|
||||||
m_debug_text_vertices[vertex_count].v = bottom_right_uv.y;
|
vertex_data[vertex_count].v = bottom_right_uv.y;
|
||||||
vertex_count++;
|
vertex_count++;
|
||||||
|
|
||||||
|
|
||||||
m_debug_text_vertices[vertex_count].x = top_left_pos.x;
|
vertex_data[vertex_count].x = top_left_pos.x;
|
||||||
m_debug_text_vertices[vertex_count].y = top_left_pos.y;
|
vertex_data[vertex_count].y = top_left_pos.y;
|
||||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
vertex_data[vertex_count].z = 0.0f;
|
||||||
m_debug_text_vertices[vertex_count].u = top_left_uv.x;
|
vertex_data[vertex_count].u = top_left_uv.x;
|
||||||
m_debug_text_vertices[vertex_count].v = top_left_uv.y;
|
vertex_data[vertex_count].v = top_left_uv.y;
|
||||||
vertex_count++;
|
vertex_count++;
|
||||||
|
|
||||||
m_debug_text_vertices[vertex_count].x = bottom_right_pos.x;
|
vertex_data[vertex_count].x = bottom_right_pos.x;
|
||||||
m_debug_text_vertices[vertex_count].y = top_left_pos.y;
|
vertex_data[vertex_count].y = top_left_pos.y;
|
||||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
vertex_data[vertex_count].z = 0.0f;
|
||||||
m_debug_text_vertices[vertex_count].u = bottom_right_uv.x;
|
vertex_data[vertex_count].u = bottom_right_uv.x;
|
||||||
m_debug_text_vertices[vertex_count].v = top_left_uv.y;
|
vertex_data[vertex_count].v = top_left_uv.y;
|
||||||
vertex_count++;
|
vertex_count++;
|
||||||
|
|
||||||
m_debug_text_vertices[vertex_count].x = bottom_right_pos.x;
|
vertex_data[vertex_count].x = bottom_right_pos.x;
|
||||||
m_debug_text_vertices[vertex_count].y = bottom_right_pos.y;
|
vertex_data[vertex_count].y = bottom_right_pos.y;
|
||||||
m_debug_text_vertices[vertex_count].z = 0.0f;
|
vertex_data[vertex_count].z = 0.0f;
|
||||||
m_debug_text_vertices[vertex_count].u = bottom_right_uv.x;
|
vertex_data[vertex_count].u = bottom_right_uv.x;
|
||||||
m_debug_text_vertices[vertex_count].v = bottom_right_uv.y;
|
vertex_data[vertex_count].v = bottom_right_uv.y;
|
||||||
vertex_count++;
|
vertex_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -888,22 +887,25 @@ void KRCamera::renderPost()
|
|||||||
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
|
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
|
||||||
KRShader *fontShader = m_pContext->getShaderManager()->getShader("debug_font", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
KRShader *fontShader = m_pContext->getShaderManager()->getShader("debug_font", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
getContext().getShaderManager()->selectShader(*this, fontShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
KRVector3 rim_color;
|
||||||
|
getContext().getShaderManager()->selectShader(*this, fontShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, rim_color, 0.0f);
|
||||||
|
|
||||||
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"));
|
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"));
|
||||||
|
|
||||||
|
KRDataBlock index_data;
|
||||||
m_pContext->getModelManager()->bindVBO((void *)m_debug_text_vertices, vertex_count * sizeof(DebugTextVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true);
|
//m_pContext->getModelManager()->bindVBO((void *)m_debug_text_vertices, vertex_count * sizeof(DebugTextVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true);
|
||||||
|
m_pContext->getModelManager()->bindVBO(m_debug_text_vertices, index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true);
|
||||||
|
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, vertex_count));
|
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, vertex_count));
|
||||||
|
|
||||||
// Re-enable z-buffer write
|
// Re-enable z-buffer write
|
||||||
GLDEBUG(glDepthMask(GL_TRUE));
|
GLDEBUG(glDepthMask(GL_TRUE));
|
||||||
|
|
||||||
|
m_debug_text_vertices.unlock();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(m_debug_text_vertices) {
|
if(m_debug_text_vertices.getSize() > 0) {
|
||||||
delete m_debug_text_vertices;
|
m_debug_text_vertices = KRDataBlock();
|
||||||
m_debug_text_vertices = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ private:
|
|||||||
GLfloat v;
|
GLfloat v;
|
||||||
} DebugTextVertexData;
|
} DebugTextVertexData;
|
||||||
|
|
||||||
DebugTextVertexData *m_debug_text_vertices;
|
KRDataBlock m_debug_text_vertices;
|
||||||
|
|
||||||
// std::string getDebugText();
|
// std::string getDebugText();
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,8 @@ void KRCollider::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_li
|
|||||||
|
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
KRVector3 rim_color;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ int KRContext::KRENGINE_MAX_SHADER_HANDLES;
|
|||||||
int KRContext::KRENGINE_MAX_TEXTURE_HANDLES;
|
int KRContext::KRENGINE_MAX_TEXTURE_HANDLES;
|
||||||
int KRContext::KRENGINE_MAX_TEXTURE_MEM;
|
int KRContext::KRENGINE_MAX_TEXTURE_MEM;
|
||||||
int KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX;
|
int KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX;
|
||||||
int KRContext::KRENGINE_TARGET_TEXTURE_MEM_MIN;
|
|
||||||
int KRContext::KRENGINE_MAX_TEXTURE_DIM;
|
int KRContext::KRENGINE_MAX_TEXTURE_DIM;
|
||||||
int KRContext::KRENGINE_MIN_TEXTURE_DIM;
|
int KRContext::KRENGINE_MIN_TEXTURE_DIM;
|
||||||
int KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT;
|
int KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT;
|
||||||
@@ -27,6 +26,7 @@ const char *KRContext::extension_names[KRENGINE_NUM_EXTENSIONS] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
KRContext::KRContext() {
|
KRContext::KRContext() {
|
||||||
|
m_streamingEnabled = false;
|
||||||
mach_timebase_info(&m_timebase_info);
|
mach_timebase_info(&m_timebase_info);
|
||||||
|
|
||||||
m_bDetectedExtensions = false;
|
m_bDetectedExtensions = false;
|
||||||
@@ -43,7 +43,7 @@ KRContext::KRContext() {
|
|||||||
m_pAnimationCurveManager = new KRAnimationCurveManager(*this);
|
m_pAnimationCurveManager = new KRAnimationCurveManager(*this);
|
||||||
m_pSoundManager = new KRAudioManager(*this);
|
m_pSoundManager = new KRAudioManager(*this);
|
||||||
m_pUnknownManager = new KRUnknownManager(*this);
|
m_pUnknownManager = new KRUnknownManager(*this);
|
||||||
|
m_streamingEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRContext::~KRContext() {
|
KRContext::~KRContext() {
|
||||||
@@ -271,3 +271,35 @@ long KRContext::getAbsoluteTimeMilliseconds()
|
|||||||
return (long)(mach_absolute_time() / 1000 * m_timebase_info.numer / m_timebase_info.denom); // Division done first to avoid potential overflow
|
return (long)(mach_absolute_time() / 1000 * m_timebase_info.numer / m_timebase_info.denom); // Division done first to avoid potential overflow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KRContext::getStreamingEnabled()
|
||||||
|
{
|
||||||
|
return m_streamingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRContext::setStreamingEnabled(bool enable)
|
||||||
|
{
|
||||||
|
m_streamingEnabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRContext::getMemoryStats(long &free_memory)
|
||||||
|
{
|
||||||
|
free_memory = 0;
|
||||||
|
#if TARGET_OS_IPHONE || TARGET_OS_MAC
|
||||||
|
mach_port_t host_port = mach_host_self();
|
||||||
|
mach_msg_type_number_t host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
|
||||||
|
vm_size_t pagesize = 0;
|
||||||
|
vm_statistics_data_t vm_stat;
|
||||||
|
int total_ram = 256 * 1024 * 1024;
|
||||||
|
if(host_page_size(host_port, &pagesize) != KERN_SUCCESS) {
|
||||||
|
fprintf(stderr, "ERROR: Could not get VM page size.\n");
|
||||||
|
} else if(host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
|
||||||
|
fprintf(stderr, "ERROR: Could not get VM stats.\n");
|
||||||
|
} else {
|
||||||
|
total_ram = (vm_stat.wire_count + vm_stat.active_count + vm_stat.inactive_count + vm_stat.free_count) * pagesize;
|
||||||
|
|
||||||
|
free_memory = vm_stat.free_count * pagesize;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#error Unsupported Platform
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public:
|
|||||||
static int KRENGINE_MAX_TEXTURE_HANDLES;
|
static int KRENGINE_MAX_TEXTURE_HANDLES;
|
||||||
static int KRENGINE_MAX_TEXTURE_MEM;
|
static int KRENGINE_MAX_TEXTURE_MEM;
|
||||||
static int KRENGINE_TARGET_TEXTURE_MEM_MAX;
|
static int KRENGINE_TARGET_TEXTURE_MEM_MAX;
|
||||||
static int KRENGINE_TARGET_TEXTURE_MEM_MIN;
|
|
||||||
static int KRENGINE_MAX_TEXTURE_DIM;
|
static int KRENGINE_MAX_TEXTURE_DIM;
|
||||||
static int KRENGINE_MIN_TEXTURE_DIM;
|
static int KRENGINE_MIN_TEXTURE_DIM;
|
||||||
static int KRENGINE_MAX_TEXTURE_THROUGHPUT;
|
static int KRENGINE_MAX_TEXTURE_THROUGHPUT;
|
||||||
@@ -73,6 +72,10 @@ public:
|
|||||||
long getAbsoluteTimeMilliseconds();
|
long getAbsoluteTimeMilliseconds();
|
||||||
|
|
||||||
std::vector<KRResource *> getResources();
|
std::vector<KRResource *> getResources();
|
||||||
|
bool getStreamingEnabled();
|
||||||
|
void setStreamingEnabled(bool enable);
|
||||||
|
|
||||||
|
void getMemoryStats(long &free_memory);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KRBundleManager *m_pBundleManager;
|
KRBundleManager *m_pBundleManager;
|
||||||
@@ -93,6 +96,8 @@ private:
|
|||||||
float m_absolute_time;
|
float m_absolute_time;
|
||||||
|
|
||||||
mach_timebase_info_data_t m_timebase_info;
|
mach_timebase_info_data_t m_timebase_info;
|
||||||
|
|
||||||
|
std::atomic<bool> m_streamingEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,12 +30,44 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "KRDataBlock.h"
|
#include "KRDataBlock.h"
|
||||||
|
#include "KREngine-common.h"
|
||||||
|
#include "KRResource.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
int KRAKEN_MEM_PAGE_SIZE = getpagesize();
|
||||||
|
#define KRAKEN_MEM_ROUND_DOWN_PAGE(x) ((x) & ~(KRAKEN_MEM_PAGE_SIZE - 1))
|
||||||
|
#define KRAKEN_MEM_ROUND_UP_PAGE(x) ((((x) - 1) & ~(KRAKEN_MEM_PAGE_SIZE - 1)) + KRAKEN_MEM_PAGE_SIZE)
|
||||||
|
|
||||||
|
int m_mapCount = 0;
|
||||||
|
size_t m_mapSize = 0;
|
||||||
|
size_t m_mapOverhead = 0;
|
||||||
|
|
||||||
KRDataBlock::KRDataBlock() {
|
KRDataBlock::KRDataBlock() {
|
||||||
m_data = NULL;
|
m_data = NULL;
|
||||||
m_data_size = 0;
|
m_data_size = 0;
|
||||||
|
m_data_offset = 0;
|
||||||
m_fdPackFile = 0;
|
m_fdPackFile = 0;
|
||||||
|
m_fileName = "";
|
||||||
|
m_mmapData = NULL;
|
||||||
|
m_fileOwnerDataBlock = NULL;
|
||||||
m_bMalloced = false;
|
m_bMalloced = false;
|
||||||
|
m_lockCount = 0;
|
||||||
|
m_bReadOnly = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRDataBlock::KRDataBlock(void *data, size_t size) {
|
||||||
|
m_data = NULL;
|
||||||
|
m_data_size = 0;
|
||||||
|
m_data_offset = 0;
|
||||||
|
m_fdPackFile = 0;
|
||||||
|
m_fileName = "";
|
||||||
|
m_mmapData = NULL;
|
||||||
|
m_fileOwnerDataBlock = NULL;
|
||||||
|
m_bMalloced = false;
|
||||||
|
m_lockCount = 0;
|
||||||
|
m_bReadOnly = false;
|
||||||
|
load(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
KRDataBlock::~KRDataBlock() {
|
KRDataBlock::~KRDataBlock() {
|
||||||
@@ -45,10 +77,13 @@ KRDataBlock::~KRDataBlock() {
|
|||||||
// Unload a file, releasing any mmap'ed file handles or malloc'ed ram that was in use
|
// Unload a file, releasing any mmap'ed file handles or malloc'ed ram that was in use
|
||||||
void KRDataBlock::unload()
|
void KRDataBlock::unload()
|
||||||
{
|
{
|
||||||
|
assert(m_lockCount == 0);
|
||||||
|
|
||||||
if(m_fdPackFile) {
|
if(m_fdPackFile) {
|
||||||
// Memory mapped file
|
// Memory mapped file
|
||||||
munmap(m_data, m_data_size);
|
if(m_fileOwnerDataBlock == this) {
|
||||||
close(m_fdPackFile);
|
close(m_fdPackFile);
|
||||||
|
}
|
||||||
} else if(m_data != NULL && m_bMalloced) {
|
} else if(m_data != NULL && m_bMalloced) {
|
||||||
// Malloc'ed data
|
// Malloc'ed data
|
||||||
free(m_data);
|
free(m_data);
|
||||||
@@ -57,7 +92,12 @@ void KRDataBlock::unload()
|
|||||||
m_bMalloced = false;
|
m_bMalloced = false;
|
||||||
m_data = NULL;
|
m_data = NULL;
|
||||||
m_data_size = 0;
|
m_data_size = 0;
|
||||||
|
m_data_offset = 0;
|
||||||
m_fdPackFile = 0;
|
m_fdPackFile = 0;
|
||||||
|
m_fileName = "";
|
||||||
|
m_mmapData = NULL;
|
||||||
|
m_fileOwnerDataBlock = NULL;
|
||||||
|
m_bReadOnly = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encapsulate a pointer. Note - The pointer will not be free'ed
|
// Encapsulate a pointer. Note - The pointer will not be free'ed
|
||||||
@@ -66,6 +106,8 @@ bool KRDataBlock::load(void *data, size_t size)
|
|||||||
unload();
|
unload();
|
||||||
m_data = data;
|
m_data = data;
|
||||||
m_data_size = size;
|
m_data_size = size;
|
||||||
|
m_data_offset = 0;
|
||||||
|
m_bReadOnly = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,14 +118,15 @@ bool KRDataBlock::load(const std::string &path)
|
|||||||
unload();
|
unload();
|
||||||
|
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
m_bReadOnly = true;
|
||||||
m_fdPackFile = open(path.c_str(), O_RDONLY);
|
m_fdPackFile = open(path.c_str(), O_RDONLY);
|
||||||
if(m_fdPackFile >= 0) {
|
if(m_fdPackFile >= 0) {
|
||||||
|
m_fileOwnerDataBlock = this;
|
||||||
|
m_fileName = KRResource::GetFileBase(path);
|
||||||
if(fstat(m_fdPackFile, &statbuf) >= 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) {
|
m_data_size = statbuf.st_size;
|
||||||
} else {
|
m_data_offset = 0;
|
||||||
m_data_size = statbuf.st_size;
|
success = true;
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!success) {
|
if(!success) {
|
||||||
@@ -93,13 +136,33 @@ bool KRDataBlock::load(const std::string &path)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a KRDataBlock encapsulating a sub-region of this block. The caller is responsible to free the object.
|
||||||
|
KRDataBlock *KRDataBlock::getSubBlock(int start, int length)
|
||||||
|
{
|
||||||
|
KRDataBlock *new_block = new KRDataBlock();
|
||||||
|
|
||||||
|
new_block->m_data_size = length;
|
||||||
|
if(m_fdPackFile) {
|
||||||
|
new_block->m_fdPackFile = m_fdPackFile;
|
||||||
|
new_block->m_fileOwnerDataBlock = m_fileOwnerDataBlock;
|
||||||
|
new_block->m_data_offset = start + m_data_offset;
|
||||||
|
} else if(m_bMalloced) {
|
||||||
|
new_block->m_data = (unsigned char *)m_data + start + m_data_offset;
|
||||||
|
}
|
||||||
|
new_block->m_bReadOnly = true;
|
||||||
|
|
||||||
|
return new_block;
|
||||||
|
}
|
||||||
|
|
||||||
// Return a pointer to the start of the data block
|
// Return a pointer to the start of the data block
|
||||||
void *KRDataBlock::getStart() {
|
void *KRDataBlock::getStart() {
|
||||||
|
assertLocked();
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a pointer to the byte after the end of the data block
|
// Return a pointer to the byte after the end of the data block
|
||||||
void *KRDataBlock::getEnd() {
|
void *KRDataBlock::getEnd() {
|
||||||
|
assertLocked();
|
||||||
return (unsigned char *)m_data + m_data_size;
|
return (unsigned char *)m_data + m_data_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,28 +174,33 @@ size_t KRDataBlock::getSize() const {
|
|||||||
// 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
|
// 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)
|
void KRDataBlock::expand(size_t size)
|
||||||
{
|
{
|
||||||
if(m_data == NULL) {
|
if(m_data == NULL && m_fdPackFile == 0) {
|
||||||
// Starting with an empty data block; allocate memory on the heap
|
// Starting with an empty data block; allocate memory on the heap
|
||||||
m_data = malloc(size);
|
m_data = malloc(size);
|
||||||
assert(m_data != NULL);
|
assert(m_data != NULL);
|
||||||
m_data_size = size;
|
m_data_size = size;
|
||||||
|
m_data_offset = 0;
|
||||||
m_bMalloced = true;
|
m_bMalloced = true;
|
||||||
} else if(m_bMalloced) {
|
} else if(m_bMalloced) {
|
||||||
// Starting with a malloc'ed data block; realloc it expand
|
// 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);
|
||||||
m_data_size += size;
|
m_data_size += size;
|
||||||
} else {
|
} else {
|
||||||
// Starting with a mmap'ed data block; copy it to ram before expanding to avoid updating the original file until save() is called
|
// Starting with a mmap'ed data block, an encapsulated pointer, or a sub-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
|
// ... 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);
|
void *pNewData = malloc(m_data_size + size);
|
||||||
assert(pNewData != NULL);
|
assert(pNewData != NULL);
|
||||||
memcpy((unsigned char *)pNewData, m_data, m_data_size); // Copy exising data
|
|
||||||
|
// Copy exising data
|
||||||
|
copy(pNewData);
|
||||||
|
|
||||||
// Unload existing data allocation, which is now redundant
|
// 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
|
size_t new_size = m_data_size + size; // We need to store this before unload() as unload() will reset it
|
||||||
unload();
|
unload();
|
||||||
m_bMalloced = true;
|
m_bMalloced = true;
|
||||||
m_data = pNewData;
|
m_data = pNewData;
|
||||||
m_data_size = new_size;
|
m_data_size = new_size;
|
||||||
|
m_data_offset = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,12 +210,35 @@ void KRDataBlock::append(void *data, size_t size) {
|
|||||||
expand(size);
|
expand(size);
|
||||||
|
|
||||||
// Fill the new space with the data to append
|
// Fill the new space with the data to append
|
||||||
|
lock();
|
||||||
memcpy((unsigned char *)m_data + m_data_size - size, data, size);
|
memcpy((unsigned char *)m_data + m_data_size - size, data, size);
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Copy the entire data block to the destination pointer
|
||||||
|
void KRDataBlock::copy(void *dest) {
|
||||||
|
copy(dest, 0, m_data_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy a range of data to the destination pointer
|
||||||
|
void KRDataBlock::copy(void *dest, int start, int count) {
|
||||||
|
if(m_lockCount == 0 && m_fdPackFile != 0) {
|
||||||
|
// Optimization: If we haven't mmap'ed or malloced the data already, pread() it directly from the file into the buffer
|
||||||
|
ssize_t r = pread(m_fdPackFile, dest, count, start + m_data_offset);
|
||||||
|
assert(r != -1);
|
||||||
|
} else {
|
||||||
|
lock();
|
||||||
|
memcpy((unsigned char *)dest, (unsigned char *)m_data + start, count);
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append data to the end of the block, increasing the size of the block and making it read-write.
|
// Append data to the end of the block, increasing the size of the block and making it read-write.
|
||||||
void KRDataBlock::append(KRDataBlock &data) {
|
void KRDataBlock::append(KRDataBlock &data) {
|
||||||
|
data.lock();
|
||||||
append(data.getStart(), data.getSize());
|
append(data.getStart(), data.getSize());
|
||||||
|
data.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append string to the end of the block, increasing the size of the block and making it read-write. The null terminating character is included
|
// Append string to the end of the block, increasing the size of the block and making it read-write. The null terminating character is included
|
||||||
@@ -157,7 +248,7 @@ void KRDataBlock::append(const std::string &s)
|
|||||||
append((void *)szText, strlen(szText)+1);
|
append((void *)szText, strlen(szText)+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// Save the data to a file.
|
||||||
bool KRDataBlock::save(const std::string& path) {
|
bool KRDataBlock::save(const std::string& path) {
|
||||||
int fdNewFile = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
|
int fdNewFile = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
|
||||||
if(fdNewFile == -1) {
|
if(fdNewFile == -1) {
|
||||||
@@ -173,20 +264,16 @@ bool KRDataBlock::save(const std::string& path) {
|
|||||||
close(fdNewFile);
|
close(fdNewFile);
|
||||||
return false;
|
return false;
|
||||||
} else if(m_data != NULL) {
|
} else if(m_data != NULL) {
|
||||||
|
|
||||||
|
|
||||||
// Copy data to new file
|
// Copy data to new file
|
||||||
memcpy(pNewData, m_data, m_data_size);
|
copy(pNewData);
|
||||||
|
|
||||||
// Unload existing data allocation, which is now redundant
|
// Unmap the new file
|
||||||
size_t new_size = m_data_size; // We need to store this, as unload() will reset it
|
munmap(pNewData, m_data_size);
|
||||||
unload();
|
|
||||||
|
|
||||||
// Protect new mmap'ed memory
|
|
||||||
mprotect(pNewData, m_data_size, PROT_READ);
|
|
||||||
|
|
||||||
// Switch pointer to use new mmap'ed memory
|
// Close the new file
|
||||||
m_data_size = new_size;
|
close(fdNewFile);
|
||||||
m_fdPackFile = fdNewFile;
|
|
||||||
m_data = pNewData;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -198,5 +285,102 @@ std::string KRDataBlock::getString()
|
|||||||
KRDataBlock b;
|
KRDataBlock b;
|
||||||
b.append(*this);
|
b.append(*this);
|
||||||
b.append((void *)"\0", 1); // Ensure data is null terminated, to read as a string safely
|
b.append((void *)"\0", 1); // Ensure data is null terminated, to read as a string safely
|
||||||
return std::string((char *)b.getStart());
|
b.lock();
|
||||||
|
std::string ret = std::string((char *)b.getStart());
|
||||||
|
b.unlock();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock the memory, forcing it to be loaded into a contiguous block of address space
|
||||||
|
void KRDataBlock::lock()
|
||||||
|
{
|
||||||
|
if(m_lockCount == 0) {
|
||||||
|
|
||||||
|
// Memory mapped file; ensure data is mapped to ram
|
||||||
|
if(m_fdPackFile) {
|
||||||
|
if(m_data_size < KRENGINE_MIN_MMAP) {
|
||||||
|
m_data = malloc(m_data_size);
|
||||||
|
assert(m_data != NULL);
|
||||||
|
copy(m_data);
|
||||||
|
} else {
|
||||||
|
//fprintf(stderr, "KRDataBlock::lock - \"%s\" (%i)\n", m_fileOwnerDataBlock->m_fileName.c_str(), m_lockCount);
|
||||||
|
|
||||||
|
// Round m_data_offset down to the next memory page, as required by mmap
|
||||||
|
size_t alignment_offset = m_data_offset & (KRAKEN_MEM_PAGE_SIZE - 1);
|
||||||
|
if ((m_mmapData = mmap(0, m_data_size + alignment_offset, m_bReadOnly ? PROT_READ : PROT_WRITE, MAP_SHARED, m_fdPackFile, m_data_offset - alignment_offset)) == (caddr_t) -1) {
|
||||||
|
int iError = errno;
|
||||||
|
switch(iError) {
|
||||||
|
case EACCES:
|
||||||
|
fprintf(stderr, "mmap failed with EACCES\n");
|
||||||
|
break;
|
||||||
|
case EBADF:
|
||||||
|
fprintf(stderr, "mmap failed with EBADF\n");
|
||||||
|
break;
|
||||||
|
case EMFILE:
|
||||||
|
fprintf(stderr, "mmap failed with EMFILE\n");
|
||||||
|
break;
|
||||||
|
case EINVAL:
|
||||||
|
fprintf(stderr, "mmap failed with EINVAL\n");
|
||||||
|
break;
|
||||||
|
case ENOMEM:
|
||||||
|
fprintf(stderr, "mmap failed with ENOMEM\n");
|
||||||
|
break;
|
||||||
|
case ENXIO:
|
||||||
|
fprintf(stderr, "mmap failed with ENXIO\n");
|
||||||
|
break;
|
||||||
|
case EOVERFLOW:
|
||||||
|
fprintf(stderr, "mmap failed with EOVERFLOW\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "mmap failed with errno: %i\n", iError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
assert(false); // mmap() failed.
|
||||||
|
}
|
||||||
|
m_mapCount++;
|
||||||
|
m_mapSize += m_data_size;
|
||||||
|
m_mapOverhead += alignment_offset + KRAKEN_MEM_ROUND_UP_PAGE(m_data_size + alignment_offset) - m_data_size + alignment_offset;
|
||||||
|
// fprintf(stderr, "Mapped: %i Size: %d Overhead: %d\n", m_mapCount, m_mapSize, m_mapOverhead);
|
||||||
|
m_data = (unsigned char *)m_mmapData + alignment_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_lockCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unlock the memory, releasing the address space for use by other allocations
|
||||||
|
void KRDataBlock::unlock()
|
||||||
|
{
|
||||||
|
// We expect that the data block was previously locked
|
||||||
|
assertLocked();
|
||||||
|
|
||||||
|
|
||||||
|
if(m_lockCount == 1) {
|
||||||
|
|
||||||
|
// Memory mapped file; ensure data is unmapped from ram
|
||||||
|
if(m_fdPackFile) {
|
||||||
|
if(m_data_size < KRENGINE_MIN_MMAP) {
|
||||||
|
free(m_data);
|
||||||
|
m_data = NULL;
|
||||||
|
} else {
|
||||||
|
//fprintf(stderr, "KRDataBlock::unlock - \"%s\" (%i)\n", m_fileOwnerDataBlock->m_fileName.c_str(), m_lockCount);
|
||||||
|
|
||||||
|
munmap(m_mmapData, m_data_size);
|
||||||
|
m_data = NULL;
|
||||||
|
m_mmapData = NULL;
|
||||||
|
m_mapCount--;
|
||||||
|
m_mapSize -= m_data_size;
|
||||||
|
size_t alignment_offset = m_data_offset & (KRAKEN_MEM_PAGE_SIZE - 1);
|
||||||
|
m_mapOverhead -= alignment_offset + KRAKEN_MEM_ROUND_UP_PAGE(m_data_size + alignment_offset) - m_data_size + alignment_offset;
|
||||||
|
// fprintf(stderr, "Mapped: %i Size: %d Overhead: %d\n", m_mapCount, m_mapSize, m_mapOverhead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_lockCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assert if not locked
|
||||||
|
void KRDataBlock::assertLocked()
|
||||||
|
{
|
||||||
|
assert(m_lockCount > 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,12 @@
|
|||||||
|
|
||||||
#include "KREngine-common.h"
|
#include "KREngine-common.h"
|
||||||
|
|
||||||
|
#define KRENGINE_MIN_MMAP 32768
|
||||||
|
|
||||||
class KRDataBlock {
|
class KRDataBlock {
|
||||||
public:
|
public:
|
||||||
KRDataBlock();
|
KRDataBlock();
|
||||||
|
KRDataBlock(void *data, size_t size);
|
||||||
~KRDataBlock();
|
~KRDataBlock();
|
||||||
|
|
||||||
// Encapsulate a pointer. Note - The pointer will not be free'ed
|
// Encapsulate a pointer. Note - The pointer will not be free'ed
|
||||||
@@ -45,9 +48,12 @@ public:
|
|||||||
// Load a file into memory using mmap. The data pointer will be protected as read-only until append() or expand() is called
|
// Load a file into memory using mmap. The data pointer will be protected as read-only until append() or expand() is called
|
||||||
bool load(const std::string &path);
|
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
|
// Save the data to a file.
|
||||||
bool save(const std::string& path);
|
bool save(const std::string& path);
|
||||||
|
|
||||||
|
// Create a KRDataBlock encapsulating a sub-region of this block. The caller is responsible to free the object.
|
||||||
|
KRDataBlock *getSubBlock(int start, int length);
|
||||||
|
|
||||||
// Append data to the end of the block, increasing the size of the block and making it read-write.
|
// 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);
|
void append(void *data, size_t size);
|
||||||
|
|
||||||
@@ -74,15 +80,42 @@ public:
|
|||||||
|
|
||||||
// Get the contents as a string
|
// Get the contents as a string
|
||||||
std::string getString();
|
std::string getString();
|
||||||
|
|
||||||
|
// Copy the entire data block to the destination pointer
|
||||||
|
void copy(void *dest);
|
||||||
|
|
||||||
|
// Copy a range of data to the destination pointer
|
||||||
|
void copy(void *dest, int start, int count);
|
||||||
|
|
||||||
|
// Lock the memory, forcing it to be loaded into a contiguous block of address space
|
||||||
|
void lock();
|
||||||
|
|
||||||
|
// Unlock the memory, releasing the address space for use by other allocations
|
||||||
|
void unlock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void *m_data;
|
void *m_data;
|
||||||
size_t m_data_size;
|
size_t m_data_size;
|
||||||
|
size_t m_data_offset;
|
||||||
|
|
||||||
// For memory mapped objects:
|
// For memory mapped objects:
|
||||||
int m_fdPackFile;
|
int m_fdPackFile;
|
||||||
|
std::string m_fileName;
|
||||||
|
KRDataBlock *m_fileOwnerDataBlock;
|
||||||
|
void *m_mmapData;
|
||||||
|
|
||||||
// For malloc'ed objects:
|
// For malloc'ed objects:
|
||||||
bool m_bMalloced;
|
bool m_bMalloced;
|
||||||
|
|
||||||
|
// Lock refcount
|
||||||
|
int m_lockCount;
|
||||||
|
|
||||||
|
// Read-only allocation
|
||||||
|
bool m_bReadOnly;
|
||||||
|
|
||||||
|
// Assert if not locked
|
||||||
|
void assertLocked();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -105,8 +105,10 @@ void KRDirectionalLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &
|
|||||||
light_direction_view_space = KRMat4::Dot(matModelViewInverseTranspose, light_direction_view_space);
|
light_direction_view_space = KRMat4::Dot(matModelViewInverseTranspose, light_direction_view_space);
|
||||||
light_direction_view_space.normalize();
|
light_direction_view_space.normalize();
|
||||||
|
|
||||||
|
KRVector3 rim_color;
|
||||||
|
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("light_directional", pCamera, std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = getContext().getShaderManager()->getShader("light_directional", pCamera, std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, renderPass)) {
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, renderPass, rim_color, 0.0f)) {
|
||||||
|
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_DIRECTION_VIEW_SPACE, light_direction_view_space);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_DIRECTION_VIEW_SPACE, light_direction_view_space);
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
||||||
@@ -119,7 +121,7 @@ void KRDirectionalLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &
|
|||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
// Render a full screen quad
|
// Render a full screen quad
|
||||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,10 @@
|
|||||||
#ifndef KRENGINE_COMMON_H
|
#ifndef KRENGINE_COMMON_H
|
||||||
#define KRENGINE_COMMON_H
|
#define KRENGINE_COMMON_H
|
||||||
|
|
||||||
#define KRENGINE_MAX_TEXTURE_UNITS 8
|
|
||||||
|
|
||||||
float const PI = 3.141592653589793f;
|
float const PI = 3.141592653589793f;
|
||||||
float const D2R = PI * 2 / 360;
|
float const D2R = PI * 2 / 360;
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -47,6 +46,9 @@ float const D2R = PI * 2 / 360;
|
|||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/signals2/mutex.hpp>
|
#include <boost/signals2/mutex.hpp>
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -69,29 +71,19 @@ using std::queue;
|
|||||||
#define KRAKEN_HAVE_BLAS 1
|
#define KRAKEN_HAVE_BLAS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define KRENGINE_MAX_TEXTURE_UNITS 8
|
||||||
|
|
||||||
|
|
||||||
#if !defined(__i386__) && defined(__arm__)
|
#if !defined(__i386__) && defined(__arm__)
|
||||||
#define KRAKEN_USE_ARM_NEON
|
#define KRAKEN_USE_ARM_NEON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
using std::unordered_map;
|
using std::unordered_map;
|
||||||
using std::unordered_multimap;
|
using std::unordered_multimap;
|
||||||
using std::hash;
|
using std::hash;
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <tr1/unordered_map>
|
|
||||||
using std::tr1::unordered_map;
|
|
||||||
using std::tr1::unordered_multimap;
|
|
||||||
using std::tr1::hash;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
#include <OpenGLES/ES2/gl.h>
|
#include <OpenGLES/ES2/gl.h>
|
||||||
@@ -129,9 +121,6 @@ using std::tr1::hash;
|
|||||||
#include <OpenAL/MacOSX_OALExtensions.h>
|
#include <OpenAL/MacOSX_OALExtensions.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#define GLDEBUG(x) \
|
#define GLDEBUG(x) \
|
||||||
@@ -197,3 +186,5 @@ fprintf(stderr, "Error at line number %d, in file %s. Returned %d for call %s\n"
|
|||||||
#include "KRVector3.h"
|
#include "KRVector3.h"
|
||||||
#include "KRVector2.h"
|
#include "KRVector2.h"
|
||||||
#include "KRBehavior.h"
|
#include "KRBehavior.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ void kraken::set_debug_text(const std::string &print_text)
|
|||||||
KRContext::KRENGINE_MAX_VBO_MEM = total_ram * 2 / 4;
|
KRContext::KRENGINE_MAX_VBO_MEM = total_ram * 2 / 4;
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_MEM = total_ram * 1 / 8;
|
KRContext::KRENGINE_MAX_TEXTURE_MEM = total_ram * 1 / 8;
|
||||||
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = KRContext::KRENGINE_MAX_TEXTURE_MEM * 3 / 4;
|
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = KRContext::KRENGINE_MAX_TEXTURE_MEM * 3 / 4;
|
||||||
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MIN = KRContext::KRENGINE_MAX_TEXTURE_MEM / 2;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -115,7 +114,6 @@ void kraken::set_debug_text(const std::string &print_text)
|
|||||||
KRContext::KRENGINE_MAX_TEXTURE_HANDLES = 10000;
|
KRContext::KRENGINE_MAX_TEXTURE_HANDLES = 10000;
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_MEM = 64000000 * 2;
|
KRContext::KRENGINE_MAX_TEXTURE_MEM = 64000000 * 2;
|
||||||
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = 48000000 * 2;
|
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = 48000000 * 2;
|
||||||
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MIN = 32000000 * 2;
|
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_DIM = 2048;
|
KRContext::KRENGINE_MAX_TEXTURE_DIM = 2048;
|
||||||
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 32000000;
|
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 32000000;
|
||||||
@@ -126,7 +124,6 @@ void kraken::set_debug_text(const std::string &print_text)
|
|||||||
KRContext::KRENGINE_MAX_TEXTURE_HANDLES = 10000;
|
KRContext::KRENGINE_MAX_TEXTURE_HANDLES = 10000;
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_MEM = 64000000;
|
KRContext::KRENGINE_MAX_TEXTURE_MEM = 64000000;
|
||||||
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = 48000000;
|
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = 48000000;
|
||||||
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MIN = 32000000;
|
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_DIM = 2048;
|
KRContext::KRENGINE_MAX_TEXTURE_DIM = 2048;
|
||||||
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 32000000;
|
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 32000000;
|
||||||
@@ -139,7 +136,6 @@ void kraken::set_debug_text(const std::string &print_text)
|
|||||||
KRContext::KRENGINE_MAX_TEXTURE_HANDLES = 10000;
|
KRContext::KRENGINE_MAX_TEXTURE_HANDLES = 10000;
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_MEM = 512000000;
|
KRContext::KRENGINE_MAX_TEXTURE_MEM = 512000000;
|
||||||
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = 384000000;
|
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MAX = 384000000;
|
||||||
KRContext::KRENGINE_TARGET_TEXTURE_MEM_MIN = 256000000;
|
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_DIM = 2048;
|
KRContext::KRENGINE_MAX_TEXTURE_DIM = 2048;
|
||||||
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
KRContext::KRENGINE_MIN_TEXTURE_DIM = 64;
|
||||||
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 128000000;
|
KRContext::KRENGINE_MAX_TEXTURE_THROUGHPUT = 128000000;
|
||||||
@@ -425,7 +421,7 @@ void kraken::set_debug_text(const std::string &print_text)
|
|||||||
[self getAmbientIntensity],
|
[self getAmbientIntensity],
|
||||||
[self getSunTemperature],
|
[self getSunTemperature],
|
||||||
[self getSunIntensity],
|
[self getSunIntensity],
|
||||||
_settings.dof_quality,
|
static_cast<float>(_settings.dof_quality),
|
||||||
_settings.dof_depth,
|
_settings.dof_depth,
|
||||||
_settings.dof_falloff,
|
_settings.dof_falloff,
|
||||||
_settings.bEnableFlash ? 1.0f : 0.0f,
|
_settings.bEnableFlash ? 1.0f : 0.0f,
|
||||||
@@ -445,26 +441,26 @@ void kraken::set_debug_text(const std::string &print_text)
|
|||||||
_settings.bEnableDeferredLighting ? 1.0f : 0.0f,
|
_settings.bEnableDeferredLighting ? 1.0f : 0.0f,
|
||||||
_settings.getPerspectiveNearZ(),
|
_settings.getPerspectiveNearZ(),
|
||||||
_settings.getPerspectiveFarZ(),
|
_settings.getPerspectiveFarZ(),
|
||||||
_settings.volumetric_environment_enable,
|
static_cast<float>(_settings.volumetric_environment_enable),
|
||||||
5 - _settings.volumetric_environment_downsample,
|
static_cast<float>(5 - _settings.volumetric_environment_downsample),
|
||||||
_settings.volumetric_environment_max_distance,
|
_settings.volumetric_environment_max_distance,
|
||||||
_settings.volumetric_environment_quality,
|
_settings.volumetric_environment_quality,
|
||||||
_settings.volumetric_environment_intensity,
|
_settings.volumetric_environment_intensity,
|
||||||
_settings.fog_type,
|
static_cast<float>(_settings.fog_type),
|
||||||
_settings.fog_near,
|
_settings.fog_near,
|
||||||
_settings.fog_far,
|
_settings.fog_far,
|
||||||
_settings.fog_density,
|
_settings.fog_density,
|
||||||
_settings.fog_color.x,
|
_settings.fog_color.x,
|
||||||
_settings.fog_color.y,
|
_settings.fog_color.y,
|
||||||
_settings.fog_color.z,
|
_settings.fog_color.z,
|
||||||
_settings.dust_particle_enable,
|
static_cast<float>(_settings.dust_particle_enable),
|
||||||
_settings.dust_particle_intensity,
|
_settings.dust_particle_intensity,
|
||||||
_settings.getLODBias(),
|
_settings.getLODBias(),
|
||||||
_settings.getEnableRealtimeOcclusion(),
|
static_cast<float>(_settings.getEnableRealtimeOcclusion()),
|
||||||
_settings.debug_display,
|
_settings.debug_display,
|
||||||
_settings.siren_enable,
|
static_cast<float>(_settings.siren_enable),
|
||||||
_settings.siren_enable_reverb,
|
static_cast<float>(_settings.siren_enable_reverb),
|
||||||
_settings.siren_enable_hrtf,
|
static_cast<float>(_settings.siren_enable_hrtf),
|
||||||
_settings.siren_reverb_max_length,
|
_settings.siren_reverb_max_length,
|
||||||
_settings.max_anisotropy
|
_settings.max_anisotropy
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include "KRResource.h"
|
#include "KRResource.h"
|
||||||
#include "KRNode.h"
|
#include "KRNode.h"
|
||||||
#include "KRTexture.h"
|
|
||||||
|
|
||||||
class KRLODGroup : public KRNode {
|
class KRLODGroup : public KRNode {
|
||||||
public:
|
public:
|
||||||
|
|||||||
35
KREngine/kraken/KRLODSet.cpp
Normal file
35
KREngine/kraken/KRLODSet.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// KRLODSet.cpp
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Created by Kearwood Gilbert on 2012-12-06.
|
||||||
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "KRLODSet.h"
|
||||||
|
#include "KRContext.h"
|
||||||
|
|
||||||
|
KRLODSet::KRLODSet(KRScene &scene, std::string name) : KRNode(scene, name)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
KRLODSet::~KRLODSet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string KRLODSet::getElementName() {
|
||||||
|
return "lod_set";
|
||||||
|
}
|
||||||
|
|
||||||
|
tinyxml2::XMLElement *KRLODSet::saveXML( tinyxml2::XMLNode *parent)
|
||||||
|
{
|
||||||
|
tinyxml2::XMLElement *e = KRNode::saveXML(parent);
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRLODSet::loadXML(tinyxml2::XMLElement *e)
|
||||||
|
{
|
||||||
|
KRNode::loadXML(e);
|
||||||
|
}
|
||||||
26
KREngine/kraken/KRLODSet.h
Normal file
26
KREngine/kraken/KRLODSet.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// KRLODSet
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Created by Kearwood Gilbert on 2012-12-06.
|
||||||
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef KRLODSET_H
|
||||||
|
#define KRLODSET_H
|
||||||
|
|
||||||
|
#include "KRResource.h"
|
||||||
|
#include "KRNode.h"
|
||||||
|
|
||||||
|
class KRLODSet : public KRNode {
|
||||||
|
public:
|
||||||
|
KRLODSet(KRScene &scene, std::string name);
|
||||||
|
virtual ~KRLODSet();
|
||||||
|
virtual std::string getElementName();
|
||||||
|
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||||
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -220,13 +220,15 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
|
|
||||||
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, particleModelMatrix, this_point_light, this_directional_light, this_spot_light, 0, renderPass)) {
|
KRVector3 rim_color;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, particleModelMatrix, this_point_light, this_directional_light, this_spot_light, 0, renderPass, rim_color, 0.0f)) {
|
||||||
|
|
||||||
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color * pCamera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
|
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color * pCamera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
|
||||||
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_PARTICLE_ORIGIN, KRMat4::DotWDiv(KRMat4::Invert(particleModelMatrix), KRVector3::Zero()));
|
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_PARTICLE_ORIGIN, KRMat4::DotWDiv(KRMat4::Invert(particleModelMatrix), KRVector3::Zero()));
|
||||||
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_dust_particle_size);
|
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_dust_particle_size);
|
||||||
|
|
||||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), KRMeshManager::KRENGINE_MAX_RANDOM_PARTICLES * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true);
|
KRDataBlock particle_index_data;
|
||||||
|
m_pContext->getModelManager()->bindVBO(m_pContext->getModelManager()->getRandomParticles(), particle_index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), true);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,8 +257,8 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
|
|
||||||
KRShader *pFogShader = m_pContext->getShaderManager()->getShader(shader_name, pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_ADDITIVE_PARTICLES);
|
KRShader *pFogShader = m_pContext->getShaderManager()->getShader(shader_name, pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_ADDITIVE_PARTICLES);
|
||||||
|
|
||||||
|
KRVector3 rim_color;
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pFogShader, viewport, KRMat4(), this_point_light, this_directional_light, this_spot_light, 0, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE)) {
|
if(getContext().getShaderManager()->selectShader(*pCamera, pFogShader, viewport, KRMat4(), this_point_light, this_directional_light, this_spot_light, 0, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, rim_color, 0.0f)) {
|
||||||
int slice_count = (int)(pCamera->settings.volumetric_environment_quality * 495.0) + 5;
|
int slice_count = (int)(pCamera->settings.volumetric_environment_quality * 495.0) + 5;
|
||||||
|
|
||||||
float slice_near = -pCamera->settings.getPerspectiveNearZ();
|
float slice_near = -pCamera->settings.getPerspectiveNearZ();
|
||||||
@@ -266,7 +268,8 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
pFogShader->setUniform(KRShader::KRENGINE_UNIFORM_SLICE_DEPTH_SCALE, KRVector2(slice_near, slice_spacing));
|
pFogShader->setUniform(KRShader::KRENGINE_UNIFORM_SLICE_DEPTH_SCALE, KRVector2(slice_near, slice_spacing));
|
||||||
pFogShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, (m_color * pCamera->settings.volumetric_environment_intensity * m_intensity * -slice_spacing / 1000.0f));
|
pFogShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, (m_color * pCamera->settings.volumetric_environment_intensity * m_intensity * -slice_spacing / 1000.0f));
|
||||||
|
|
||||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getVolumetricLightingVertexes(), KRMeshManager::KRENGINE_MAX_VOLUMETRIC_PLANES * 6 * sizeof(KRMeshManager::VolumetricLightingVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX), true);
|
KRDataBlock index_data;
|
||||||
|
m_pContext->getModelManager()->bindVBO(m_pContext->getModelManager()->getVolumetricLightingVertexes(), index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX), true);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, slice_count*6));
|
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, slice_count*6));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +286,8 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
occlusion_test_sphere_matrix *= m_parentNode->getModelMatrix();
|
occlusion_test_sphere_matrix *= m_parentNode->getModelMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass)) {
|
KRVector3 rim_color;
|
||||||
|
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass, rim_color, 0.0f)) {
|
||||||
|
|
||||||
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
@@ -330,10 +334,12 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
|
|
||||||
// Render light flare on transparency pass
|
// Render light flare on transparency pass
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("flare", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = getContext().getShaderManager()->getShader("flare", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
KRVector3 rim_light;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_light, 0.0f)) {
|
||||||
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, 1.0f);
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
|
||||||
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture);
|
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture);
|
||||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -446,7 +452,8 @@ void KRLight::renderShadowBuffers(KRCamera *pCamera)
|
|||||||
// Use shader program
|
// Use shader program
|
||||||
KRShader *shadowShader = m_pContext->getShaderManager()->getShader("ShadowShader", pCamera, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
KRShader *shadowShader = m_pContext->getShaderManager()->getShader("ShadowShader", pCamera, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
|
||||||
|
|
||||||
getContext().getShaderManager()->selectShader(*pCamera, shadowShader, m_shadowViewports[iShadow], KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_SHADOWMAP);
|
KRVector3 rim_light;
|
||||||
|
getContext().getShaderManager()->selectShader(*pCamera, shadowShader, m_shadowViewports[iShadow], KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_SHADOWMAP, rim_light, 0.0f);
|
||||||
|
|
||||||
|
|
||||||
getScene().render(pCamera, m_shadowViewports[iShadow].getVisibleBounds(), m_shadowViewports[iShadow], KRNode::RENDER_PASS_SHADOWMAP, true);
|
getScene().render(pCamera, m_shadowViewports[iShadow].getVisibleBounds(), m_shadowViewports[iShadow], KRNode::RENDER_PASS_SHADOWMAP, true);
|
||||||
|
|||||||
40
KREngine/kraken/KRLocator.cpp
Normal file
40
KREngine/kraken/KRLocator.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// KRLocator.cpp
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Created by Kearwood Gilbert on 2012-12-06.
|
||||||
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "KRLocator.h"
|
||||||
|
#include "KRContext.h"
|
||||||
|
|
||||||
|
KRLocator::KRLocator(KRScene &scene, std::string name) : KRNode(scene, name)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
KRLocator::~KRLocator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string KRLocator::getElementName() {
|
||||||
|
return "locator";
|
||||||
|
}
|
||||||
|
|
||||||
|
tinyxml2::XMLElement *KRLocator::saveXML( tinyxml2::XMLNode *parent)
|
||||||
|
{
|
||||||
|
tinyxml2::XMLElement *e = KRNode::saveXML(parent);
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRLocator::loadXML(tinyxml2::XMLElement *e)
|
||||||
|
{
|
||||||
|
KRNode::loadXML(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
unordered_map<std::string, boost::variant<int, double, bool, std::string> > &KRLocator::getUserAttributes()
|
||||||
|
{
|
||||||
|
return m_userAttributes;
|
||||||
|
}
|
||||||
32
KREngine/kraken/KRLocator.h
Normal file
32
KREngine/kraken/KRLocator.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// KRLocator
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Created by Kearwood Gilbert on 2012-12-06.
|
||||||
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef KRLOCATOR_H
|
||||||
|
#define KRLOCATOR_H
|
||||||
|
|
||||||
|
#include "KRResource.h"
|
||||||
|
#include "KRNode.h"
|
||||||
|
#include "KRTexture.h"
|
||||||
|
|
||||||
|
#include "boost/variant.hpp"
|
||||||
|
|
||||||
|
class KRLocator : public KRNode {
|
||||||
|
public:
|
||||||
|
KRLocator(KRScene &scene, std::string name);
|
||||||
|
virtual ~KRLocator();
|
||||||
|
virtual std::string getElementName();
|
||||||
|
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||||
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
|
unordered_map<std::string, boost::variant<int, double, bool, std::string> > &getUserAttributes();
|
||||||
|
|
||||||
|
private:
|
||||||
|
unordered_map<std::string, boost::variant<int, double, bool, std::string> > m_userAttributes;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -87,7 +87,7 @@ float KRMat4::operator[](unsigned i) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Overload comparison operator
|
// Overload comparison operator
|
||||||
bool KRMat4::operator==(const KRMat4 &m) {
|
bool KRMat4::operator==(const KRMat4 &m) const {
|
||||||
return memcmp(c, m.c, sizeof(float) * 16) == 0;
|
return memcmp(c, m.c, sizeof(float) * 16) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class KRMat4 {
|
|||||||
KRMat4& operator=(const KRMat4 &m);
|
KRMat4& operator=(const KRMat4 &m);
|
||||||
|
|
||||||
// Overload comparison operator
|
// Overload comparison operator
|
||||||
bool operator==(const KRMat4 &m);
|
bool operator==(const KRMat4 &m) const;
|
||||||
|
|
||||||
// Overload compound multiply operator
|
// Overload compound multiply operator
|
||||||
KRMat4& operator*=(const KRMat4 &m);
|
KRMat4& operator*=(const KRMat4 &m);
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ bool KRMaterial::isTransparent() {
|
|||||||
return m_tr < 1.0 || m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE || m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE;
|
return m_tr < 1.0 || m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE || m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRMaterial::bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const std::vector<KRBone *> &bones, const std::vector<KRMat4> &bind_poses, const KRViewport &viewport, const KRMat4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass) {
|
bool KRMaterial::bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const std::vector<KRBone *> &bones, const std::vector<KRMat4> &bind_poses, const KRViewport &viewport, const KRMat4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass, const KRVector3 &rim_color, float rim_power) {
|
||||||
bool bLightMap = pLightMap && pCamera->settings.bEnableLightMap;
|
bool bLightMap = pLightMap && pCamera->settings.bEnableLightMap;
|
||||||
|
|
||||||
if(!m_pAmbientMap && m_ambientMap.size()) {
|
if(!m_pAmbientMap && m_ambientMap.size()) {
|
||||||
@@ -251,10 +251,9 @@ bool KRMaterial::bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
|
|||||||
bool bAlphaTest = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_TEST) && bDiffuseMap;
|
bool bAlphaTest = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_TEST) && bDiffuseMap;
|
||||||
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
bool bAlphaBlend = (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDONESIDE) || (m_alpha_mode == KRMATERIAL_ALPHA_MODE_BLENDTWOSIDE);
|
||||||
|
|
||||||
|
KRShader *pShader = getContext().getShaderManager()->getShader("ObjectShader", pCamera, point_lights, directional_lights, spot_lights, bones.size(), bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_reflectionMapScale != default_scale && bReflectionMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, m_reflectionMapOffset != default_offset && bReflectionMap, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("ObjectShader", pCamera, point_lights, directional_lights, spot_lights, bones.size(), bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_reflectionMapScale != default_scale && bReflectionMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, m_reflectionMapOffset != default_offset && bReflectionMap, bAlphaTest, bAlphaBlend, renderPass);
|
|
||||||
|
|
||||||
if(!getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
if(!getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, rim_power)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include "KRCamera.h"
|
#include "KRCamera.h"
|
||||||
#include "KRResource.h"
|
#include "KRResource.h"
|
||||||
#include "KRVector2.h"
|
#include "KRVector2.h"
|
||||||
|
#include "KRVector3.h"
|
||||||
#include "KRScene.h"
|
#include "KRScene.h"
|
||||||
#include "KRBone.h"
|
#include "KRBone.h"
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ public:
|
|||||||
bool isTransparent();
|
bool isTransparent();
|
||||||
const std::string &getName() const;
|
const std::string &getName() const;
|
||||||
|
|
||||||
bool bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const std::vector<KRBone *> &bones, const std::vector<KRMat4> &bind_poses, const KRViewport &viewport, const KRMat4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass);
|
bool bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const std::vector<KRBone *> &bones, const std::vector<KRMat4> &bind_poses, const KRViewport &viewport, const KRMat4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass, const KRVector3 &rim_color, float rim_power);
|
||||||
|
|
||||||
bool needsVertexTangents();
|
bool needsVertexTangents();
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ void KRMaterialManager::add(KRMaterial *new_material) {
|
|||||||
bool KRMaterialManager::load(const char *szName, KRDataBlock *data) {
|
bool KRMaterialManager::load(const char *szName, KRDataBlock *data) {
|
||||||
KRMaterial *pMaterial = NULL;
|
KRMaterial *pMaterial = NULL;
|
||||||
char szSymbol[16][256];
|
char szSymbol[16][256];
|
||||||
|
data->lock();
|
||||||
|
|
||||||
char *pScan = (char *)data->getStart();
|
char *pScan = (char *)data->getStart();
|
||||||
char *pEnd = (char *)data->getEnd();
|
char *pEnd = (char *)data->getEnd();
|
||||||
@@ -282,7 +282,7 @@ bool KRMaterialManager::load(const char *szName, KRDataBlock *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
data->unlock();
|
||||||
delete data;
|
delete data;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,20 +42,23 @@
|
|||||||
|
|
||||||
|
|
||||||
KRMesh::KRMesh(KRContext &context, std::string name) : KRResource(context, name) {
|
KRMesh::KRMesh(KRContext &context, std::string name) : KRResource(context, name) {
|
||||||
m_hasTransparency = false;
|
|
||||||
m_materials.clear();
|
|
||||||
m_uniqueMaterials.clear();
|
|
||||||
m_pData = new KRDataBlock();
|
|
||||||
setName(name);
|
setName(name);
|
||||||
|
|
||||||
|
m_hasTransparency = false;
|
||||||
|
m_pData = NULL;
|
||||||
|
m_pMetaData = NULL;
|
||||||
|
m_pIndexBaseData = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMesh::KRMesh(KRContext &context, std::string name, KRDataBlock *data) : KRResource(context, name) {
|
KRMesh::KRMesh(KRContext &context, std::string name, KRDataBlock *data) : KRResource(context, name) {
|
||||||
m_hasTransparency = false;
|
|
||||||
m_materials.clear();
|
|
||||||
m_uniqueMaterials.clear();
|
|
||||||
m_pData = new KRDataBlock();
|
|
||||||
setName(name);
|
setName(name);
|
||||||
|
|
||||||
|
m_hasTransparency = false;
|
||||||
|
m_pData = NULL;
|
||||||
|
m_pMetaData = NULL;
|
||||||
|
m_pIndexBaseData = NULL;
|
||||||
|
|
||||||
loadPack(data);
|
loadPack(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,8 +106,26 @@ int KRMesh::GetLODCoverage(const std::string &name)
|
|||||||
|
|
||||||
|
|
||||||
KRMesh::~KRMesh() {
|
KRMesh::~KRMesh() {
|
||||||
clearData();
|
releaseData();
|
||||||
if(m_pData) delete m_pData;
|
}
|
||||||
|
|
||||||
|
void KRMesh::releaseData() {
|
||||||
|
m_hasTransparency = false;
|
||||||
|
m_submeshes.clear();
|
||||||
|
if(m_pIndexBaseData) {
|
||||||
|
m_pIndexBaseData->unlock();
|
||||||
|
delete m_pIndexBaseData;
|
||||||
|
m_pIndexBaseData = NULL;
|
||||||
|
}
|
||||||
|
if(m_pMetaData) {
|
||||||
|
m_pMetaData->unlock();
|
||||||
|
delete m_pMetaData;
|
||||||
|
m_pMetaData = NULL;
|
||||||
|
}
|
||||||
|
if(m_pData) {
|
||||||
|
delete m_pData;
|
||||||
|
m_pData = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string KRMesh::getExtension() {
|
std::string KRMesh::getExtension() {
|
||||||
@@ -112,28 +133,36 @@ std::string KRMesh::getExtension() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool KRMesh::save(const std::string& path) {
|
bool KRMesh::save(const std::string& path) {
|
||||||
clearBuffers();
|
|
||||||
return m_pData->save(path);
|
return m_pData->save(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRMesh::save(KRDataBlock &data) {
|
bool KRMesh::save(KRDataBlock &data) {
|
||||||
clearBuffers();
|
|
||||||
data.append(*m_pData);
|
data.append(*m_pData);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::loadPack(KRDataBlock *data) {
|
void KRMesh::loadPack(KRDataBlock *data) {
|
||||||
clearData();
|
releaseData();
|
||||||
delete m_pData;
|
|
||||||
m_pData = data;
|
m_pData = data;
|
||||||
|
|
||||||
|
pack_header ph;
|
||||||
|
m_pData->copy((void *)&ph, 0, sizeof(ph));
|
||||||
|
m_pMetaData = m_pData->getSubBlock(0, sizeof(pack_header) + sizeof(pack_material) * ph.submesh_count + sizeof(pack_bone) * ph.bone_count);
|
||||||
|
m_pMetaData->lock();
|
||||||
|
|
||||||
|
m_pIndexBaseData = m_pData->getSubBlock(sizeof(pack_header) + sizeof(pack_material) * ph.submesh_count + sizeof(pack_bone) * ph.bone_count + KRALIGN(2 * ph.index_count), ph.index_base_count * 8);
|
||||||
|
m_pIndexBaseData->lock();
|
||||||
|
|
||||||
|
m_minPoint = KRVector3(ph.minx, ph.miny, ph.minz);
|
||||||
|
m_maxPoint = KRVector3(ph.maxx, ph.maxy, ph.maxz);
|
||||||
|
|
||||||
updateAttributeOffsets();
|
updateAttributeOffsets();
|
||||||
pack_header *pHeader = getHeader();
|
|
||||||
m_minPoint = KRVector3(pHeader->minx, pHeader->miny, pHeader->minz);
|
|
||||||
m_maxPoint = KRVector3(pHeader->maxx, pHeader->maxy, pHeader->maxz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::render(const std::string &object_name, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, const KRMat4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass, const std::vector<KRBone *> &bones) {
|
void KRMesh::render(const std::string &object_name, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, const KRMat4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass, const std::vector<KRBone *> &bones, const KRVector3 &rim_color, float rim_power) {
|
||||||
|
|
||||||
|
|
||||||
//fprintf(stderr, "Rendering model: %s\n", m_name.c_str());
|
//fprintf(stderr, "Rendering model: %s\n", m_name.c_str());
|
||||||
if(renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_PARTICLE_OCCLUSION && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE) {
|
if(renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_PARTICLE_OCCLUSION && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE) {
|
||||||
getSubmeshes();
|
getSubmeshes();
|
||||||
@@ -185,7 +214,7 @@ void KRMesh::render(const std::string &object_name, KRCamera *pCamera, std::vect
|
|||||||
for(int i=0; i < bones.size(); i++) {
|
for(int i=0; i < bones.size(); i++) {
|
||||||
bone_bind_poses.push_back(getBoneBindPose(i));
|
bone_bind_poses.push_back(getBoneBindPose(i));
|
||||||
}
|
}
|
||||||
if(pMaterial->bind(pCamera, point_lights, directional_lights, spot_lights, bones, bone_bind_poses, viewport, matModel, pLightMap, renderPass)) {
|
if(pMaterial->bind(pCamera, point_lights, directional_lights, spot_lights, bones, bone_bind_poses, viewport, matModel, pLightMap, renderPass, rim_color, rim_power)) {
|
||||||
|
|
||||||
switch(pMaterial->getAlphaMode()) {
|
switch(pMaterial->getAlphaMode()) {
|
||||||
case KRMaterial::KRMATERIAL_ALPHA_MODE_OPAQUE: // Non-transparent materials
|
case KRMaterial::KRMATERIAL_ALPHA_MODE_OPAQUE: // Non-transparent materials
|
||||||
@@ -250,21 +279,21 @@ void KRMesh::getSubmeshes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::renderSubmesh(int iSubmesh, KRNode::RenderPass renderPass, const std::string &object_name, const std::string &material_name) {
|
void KRMesh::renderSubmesh(int iSubmesh, KRNode::RenderPass renderPass, const std::string &object_name, const std::string &material_name) {
|
||||||
|
//m_pData->lock();
|
||||||
getSubmeshes();
|
getSubmeshes();
|
||||||
Submesh *pSubmesh = m_submeshes[iSubmesh];
|
Submesh *pSubmesh = m_submeshes[iSubmesh];
|
||||||
int cVertexes = pSubmesh->vertex_count;
|
int cVertexes = pSubmesh->vertex_count;
|
||||||
// fprintf(stderr, "start - object: %s material: %s vertices: %i\n", object_name.c_str(), material_name.c_str(), cVertexes);
|
// fprintf(stderr, "start - object: %s material: %s vertices: %i\n", object_name.c_str(), material_name.c_str(), cVertexes);
|
||||||
unsigned char *pVertexData = getVertexData();
|
int vertex_data_offset = getVertexDataOffset();
|
||||||
|
int index_data_offset = getIndexDataOffset();
|
||||||
pack_header *pHeader = getHeader();
|
pack_header *pHeader = getHeader();
|
||||||
|
int32_t vertex_attrib_flags = pHeader->vertex_attrib_flags;
|
||||||
|
int32_t vertex_count = pHeader->vertex_count;
|
||||||
|
|
||||||
|
|
||||||
|
int vbo_index=0;
|
||||||
if(getModelFormat() == KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) {
|
if(getModelFormat() == KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__uint16_t *index_data = getIndexData();
|
|
||||||
int index_group = getSubmesh(iSubmesh)->index_group;
|
int index_group = getSubmesh(iSubmesh)->index_group;
|
||||||
int index_group_offset = getSubmesh(iSubmesh)->index_group_offset;
|
int index_group_offset = getSubmesh(iSubmesh)->index_group_offset;
|
||||||
while(cVertexes > 0) {
|
while(cVertexes > 0) {
|
||||||
@@ -272,7 +301,22 @@ void KRMesh::renderSubmesh(int iSubmesh, KRNode::RenderPass renderPass, const st
|
|||||||
int start_index_offset, start_vertex_offset, index_count, vertex_count;
|
int start_index_offset, start_vertex_offset, index_count, vertex_count;
|
||||||
getIndexedRange(index_group++, start_index_offset, start_vertex_offset, index_count, vertex_count);
|
getIndexedRange(index_group++, start_index_offset, start_vertex_offset, index_count, vertex_count);
|
||||||
|
|
||||||
m_pContext->getModelManager()->bindVBO((unsigned char *)pVertexData + start_vertex_offset * m_vertex_size, vertex_count * m_vertex_size, index_data + start_index_offset, index_count * 2, pHeader->vertex_attrib_flags, true);
|
KRDataBlock *vertex_data_block = NULL;
|
||||||
|
KRDataBlock *index_data_block = NULL;
|
||||||
|
if(m_submeshes[iSubmesh]->vertex_data_blocks.size() <= vbo_index) {
|
||||||
|
vertex_data_block = m_pData->getSubBlock(vertex_data_offset + start_vertex_offset * m_vertex_size, vertex_count * m_vertex_size);
|
||||||
|
index_data_block = m_pData->getSubBlock(index_data_offset + start_index_offset * 2, index_count * 2);
|
||||||
|
m_submeshes[iSubmesh]->vertex_data_blocks.push_back(vertex_data_block);
|
||||||
|
m_submeshes[iSubmesh]->index_data_blocks.push_back(index_data_block);
|
||||||
|
} else {
|
||||||
|
vertex_data_block = m_submeshes[iSubmesh]->vertex_data_blocks[vbo_index];
|
||||||
|
index_data_block = m_submeshes[iSubmesh]->index_data_blocks[vbo_index];
|
||||||
|
}
|
||||||
|
vbo_index++;
|
||||||
|
|
||||||
|
//m_pContext->getModelManager()->bindVBO((unsigned char *)pVertexData + start_vertex_offset * m_vertex_size, vertex_count * m_vertex_size, index_data + start_index_offset, index_count * 2, vertex_attrib_flags, true);
|
||||||
|
m_pContext->getModelManager()->bindVBO(*vertex_data_block, *index_data_block, vertex_attrib_flags, true);
|
||||||
|
|
||||||
|
|
||||||
int vertex_draw_count = cVertexes;
|
int vertex_draw_count = cVertexes;
|
||||||
if(vertex_draw_count > index_count - index_group_offset) vertex_draw_count = index_count - index_group_offset;
|
if(vertex_draw_count > index_count - index_group_offset) vertex_draw_count = index_count - index_group_offset;
|
||||||
@@ -284,21 +328,27 @@ void KRMesh::renderSubmesh(int iSubmesh, KRNode::RenderPass renderPass, const st
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int cBuffers = (pHeader->vertex_count + MAX_VBO_SIZE - 1) / MAX_VBO_SIZE;
|
int cBuffers = (vertex_count + MAX_VBO_SIZE - 1) / MAX_VBO_SIZE;
|
||||||
int iVertex = pSubmesh->start_vertex;
|
int iVertex = pSubmesh->start_vertex;
|
||||||
int iBuffer = iVertex / MAX_VBO_SIZE;
|
int iBuffer = iVertex / MAX_VBO_SIZE;
|
||||||
iVertex = iVertex % MAX_VBO_SIZE;
|
iVertex = iVertex % MAX_VBO_SIZE;
|
||||||
while(cVertexes > 0) {
|
while(cVertexes > 0) {
|
||||||
GLsizei cBufferVertexes = iBuffer < cBuffers - 1 ? MAX_VBO_SIZE : pHeader->vertex_count % MAX_VBO_SIZE;
|
GLsizei cBufferVertexes = iBuffer < cBuffers - 1 ? MAX_VBO_SIZE : vertex_count % MAX_VBO_SIZE;
|
||||||
int vertex_size = m_vertex_size;
|
int vertex_size = m_vertex_size;
|
||||||
|
|
||||||
void *vbo_end = (unsigned char *)pVertexData + iBuffer * MAX_VBO_SIZE * vertex_size + vertex_size * cBufferVertexes;
|
KRDataBlock *vertex_data_block = NULL;
|
||||||
void *buffer_end = m_pData->getEnd();
|
KRDataBlock *index_data_block = NULL;
|
||||||
assert(vbo_end <= buffer_end);
|
if(m_submeshes[iSubmesh]->vertex_data_blocks.size() <= vbo_index) {
|
||||||
assert(cBufferVertexes <= 65535);
|
vertex_data_block = m_pData->getSubBlock(vertex_data_offset + iBuffer * MAX_VBO_SIZE * vertex_size, vertex_size * cBufferVertexes);
|
||||||
|
|
||||||
|
m_submeshes[iSubmesh]->vertex_data_blocks.push_back(vertex_data_block);
|
||||||
|
} else {
|
||||||
|
vertex_data_block = m_submeshes[iSubmesh]->vertex_data_blocks[vbo_index];
|
||||||
|
}
|
||||||
|
vbo_index++;
|
||||||
|
|
||||||
|
//m_pContext->getModelManager()->bindVBO((unsigned char *)pVertexData + iBuffer * MAX_VBO_SIZE * vertex_size, vertex_size * cBufferVertexes, NULL, 0, vertex_attrib_flags, true);
|
||||||
m_pContext->getModelManager()->bindVBO((unsigned char *)pVertexData + iBuffer * MAX_VBO_SIZE * vertex_size, vertex_size * cBufferVertexes, NULL, 0, pHeader->vertex_attrib_flags, true);
|
m_pContext->getModelManager()->bindVBO(*vertex_data_block, *index_data_block, vertex_attrib_flags, true);
|
||||||
|
|
||||||
|
|
||||||
if(iVertex + cVertexes >= MAX_VBO_SIZE) {
|
if(iVertex + cVertexes >= MAX_VBO_SIZE) {
|
||||||
@@ -344,13 +394,12 @@ void KRMesh::renderSubmesh(int iSubmesh, KRNode::RenderPass renderPass, const st
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fprintf(stderr, "end object\n");
|
//m_pData->unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::LoadData(/*std::vector<__uint16_t> vertex_indexes, std::vector<std::pair<int, int> > vertex_index_bases, 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, std::vector<std::string> bone_names, std::vector<KRMat4> bone_bind_poses, std::vector<std::vector<int> > bone_indexes, std::vector<std::vector<float> > bone_weights, model_format_t model_format, */const KRMesh::mesh_info &mi, bool calculate_normals, bool calculate_tangents) {
|
void KRMesh::LoadData(const KRMesh::mesh_info &mi, bool calculate_normals, bool calculate_tangents) {
|
||||||
|
|
||||||
clearData();
|
releaseData();
|
||||||
|
|
||||||
// TODO, FINDME - These values should be passed as a parameter and set by GUI flags
|
// TODO, FINDME - These values should be passed as a parameter and set by GUI flags
|
||||||
bool use_short_vertexes = false;
|
bool use_short_vertexes = false;
|
||||||
@@ -429,9 +478,10 @@ void KRMesh::LoadData(/*std::vector<__uint16_t> vertex_indexes, std::vector<std:
|
|||||||
size_t vertex_count = mi.vertices.size();
|
size_t vertex_count = mi.vertices.size();
|
||||||
size_t bone_count = mi.bone_names.size();
|
size_t bone_count = mi.bone_names.size();
|
||||||
size_t new_file_size = sizeof(pack_header) + sizeof(pack_material) * submesh_count + sizeof(pack_bone) * bone_count + KRALIGN(2 * index_count) + KRALIGN(8 * index_base_count) + vertex_size * vertex_count;
|
size_t new_file_size = sizeof(pack_header) + sizeof(pack_material) * submesh_count + sizeof(pack_bone) * bone_count + KRALIGN(2 * index_count) + KRALIGN(8 * index_base_count) + vertex_size * vertex_count;
|
||||||
|
m_pData = new KRDataBlock();
|
||||||
|
m_pMetaData = m_pData;
|
||||||
m_pData->expand(new_file_size);
|
m_pData->expand(new_file_size);
|
||||||
|
m_pData->lock();
|
||||||
pack_header *pHeader = getHeader();
|
pack_header *pHeader = getHeader();
|
||||||
memset(pHeader, 0, sizeof(pack_header));
|
memset(pHeader, 0, sizeof(pack_header));
|
||||||
pHeader->vertex_attrib_flags = vertex_attrib_flags;
|
pHeader->vertex_attrib_flags = vertex_attrib_flags;
|
||||||
@@ -573,6 +623,18 @@ void KRMesh::LoadData(/*std::vector<__uint16_t> vertex_indexes, std::vector<std:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_pData->unlock();
|
||||||
|
|
||||||
|
// ----
|
||||||
|
|
||||||
|
pack_header ph;
|
||||||
|
m_pData->copy((void *)&ph, 0, sizeof(ph));
|
||||||
|
m_pMetaData = m_pData->getSubBlock(0, sizeof(pack_header) + sizeof(pack_material) * ph.submesh_count + sizeof(pack_bone) * ph.bone_count);
|
||||||
|
m_pMetaData->lock();
|
||||||
|
m_pIndexBaseData = m_pData->getSubBlock(sizeof(pack_header) + sizeof(pack_material) * ph.submesh_count + sizeof(pack_bone) * ph.bone_count + KRALIGN(2 * ph.index_count), ph.index_base_count * 8);
|
||||||
|
m_pIndexBaseData->lock();
|
||||||
|
|
||||||
|
// ----
|
||||||
|
|
||||||
optimize();
|
optimize();
|
||||||
}
|
}
|
||||||
@@ -585,14 +647,6 @@ KRVector3 KRMesh::getMaxPoint() const {
|
|||||||
return m_maxPoint;
|
return m_maxPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::clearData() {
|
|
||||||
m_pData->unload();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KRMesh::clearBuffers() {
|
|
||||||
m_submeshes.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
int KRMesh::getLODCoverage() const {
|
int KRMesh::getLODCoverage() const {
|
||||||
return m_lodCoverage;
|
return m_lodCoverage;
|
||||||
}
|
}
|
||||||
@@ -620,34 +674,47 @@ bool KRMesh::has_vertex_attribute(int vertex_attrib_flags, vertex_attrib_t attri
|
|||||||
|
|
||||||
KRMesh::pack_header *KRMesh::getHeader() const
|
KRMesh::pack_header *KRMesh::getHeader() const
|
||||||
{
|
{
|
||||||
return (pack_header *)m_pData->getStart();
|
return (pack_header *)m_pMetaData->getStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMesh::pack_bone *KRMesh::getBone(int index)
|
KRMesh::pack_bone *KRMesh::getBone(int index)
|
||||||
{
|
{
|
||||||
pack_header *header = getHeader();
|
pack_header *header = getHeader();
|
||||||
return (pack_bone *)((unsigned char *)m_pData->getStart() + sizeof(pack_header) + sizeof(pack_material) * header->submesh_count + sizeof(pack_bone) * index);
|
return (pack_bone *)((unsigned char *)m_pMetaData->getStart() + sizeof(pack_header) + sizeof(pack_material) * header->submesh_count + sizeof(pack_bone) * index);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *KRMesh::getVertexData() const {
|
unsigned char *KRMesh::getVertexData() const {
|
||||||
|
return ((unsigned char *)m_pData->getStart()) + getVertexDataOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t KRMesh::getVertexDataOffset() const {
|
||||||
pack_header *pHeader = getHeader();
|
pack_header *pHeader = getHeader();
|
||||||
return ((unsigned char *)m_pData->getStart()) + sizeof(pack_header) + sizeof(pack_material) * pHeader->submesh_count + sizeof(pack_bone) * pHeader->bone_count + KRALIGN(2 * pHeader->index_count) + KRALIGN(8 * pHeader->index_base_count);
|
return sizeof(pack_header) + sizeof(pack_material) * pHeader->submesh_count + sizeof(pack_bone) * pHeader->bone_count + KRALIGN(2 * pHeader->index_count) + KRALIGN(8 * pHeader->index_base_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
__uint16_t *KRMesh::getIndexData() const {
|
__uint16_t *KRMesh::getIndexData() const {
|
||||||
|
|
||||||
|
return (__uint16_t *)((unsigned char *)m_pData->getStart() + getIndexDataOffset());
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t KRMesh::getIndexDataOffset() const {
|
||||||
pack_header *pHeader = getHeader();
|
pack_header *pHeader = getHeader();
|
||||||
return (__uint16_t *)((unsigned char *)m_pData->getStart() + sizeof(pack_header) + sizeof(pack_material) * pHeader->submesh_count + sizeof(pack_bone) * pHeader->bone_count);
|
return sizeof(pack_header) + sizeof(pack_material) * pHeader->submesh_count + sizeof(pack_bone) * pHeader->bone_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
__uint32_t *KRMesh::getIndexBaseData() const {
|
__uint32_t *KRMesh::getIndexBaseData() const {
|
||||||
pack_header *pHeader = getHeader();
|
if(m_pIndexBaseData == NULL) {
|
||||||
return (__uint32_t *)((unsigned char *)m_pData->getStart() + sizeof(pack_header) + sizeof(pack_material) * pHeader->submesh_count + sizeof(pack_bone) * pHeader->bone_count + KRALIGN(2 * pHeader->index_count));
|
pack_header *pHeader = getHeader();
|
||||||
|
return (__uint32_t *)((unsigned char *)m_pData->getStart() + sizeof(pack_header) + sizeof(pack_material) * pHeader->submesh_count + sizeof(pack_bone) * pHeader->bone_count + KRALIGN(2 * pHeader->index_count));
|
||||||
|
} else {
|
||||||
|
return (__uint32_t *)m_pIndexBaseData->getStart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KRMesh::pack_material *KRMesh::getSubmesh(int mesh_index) const
|
KRMesh::pack_material *KRMesh::getSubmesh(int mesh_index) const
|
||||||
{
|
{
|
||||||
return (pack_material *)((unsigned char *)m_pData->getStart() + sizeof(pack_header)) + mesh_index;
|
return (pack_material *)((unsigned char *)m_pMetaData->getStart() + sizeof(pack_header)) + mesh_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *KRMesh::getVertexData(int index) const
|
unsigned char *KRMesh::getVertexData(int index) const
|
||||||
@@ -658,7 +725,8 @@ unsigned char *KRMesh::getVertexData(int index) const
|
|||||||
int KRMesh::getSubmeshCount() const
|
int KRMesh::getSubmeshCount() const
|
||||||
{
|
{
|
||||||
pack_header *header = getHeader();
|
pack_header *header = getHeader();
|
||||||
return header->submesh_count;
|
int submesh_count = header->submesh_count;
|
||||||
|
return submesh_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KRMesh::getVertexCount(int submesh) const
|
int KRMesh::getVertexCount(int submesh) const
|
||||||
@@ -893,7 +961,8 @@ size_t KRMesh::AttributeOffset(__int32_t vertex_attrib, __int32_t vertex_attrib_
|
|||||||
int KRMesh::getBoneCount()
|
int KRMesh::getBoneCount()
|
||||||
{
|
{
|
||||||
pack_header *header = getHeader();
|
pack_header *header = getHeader();
|
||||||
return header->bone_count;
|
int bone_count = header->bone_count;
|
||||||
|
return bone_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *KRMesh::getBoneName(int bone_index)
|
char *KRMesh::getBoneName(int bone_index)
|
||||||
@@ -908,7 +977,8 @@ KRMat4 KRMesh::getBoneBindPose(int bone_index)
|
|||||||
|
|
||||||
KRMesh::model_format_t KRMesh::getModelFormat() const
|
KRMesh::model_format_t KRMesh::getModelFormat() const
|
||||||
{
|
{
|
||||||
return (model_format_t)getHeader()->model_format;
|
model_format_t f = (model_format_t)getHeader()->model_format;
|
||||||
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRMesh::rayCast(const KRVector3 &line_v0, const KRVector3 &dir, const KRVector3 &tri_v0, const KRVector3 &tri_v1, const KRVector3 &tri_v2, const KRVector3 &tri_n0, const KRVector3 &tri_n1, const KRVector3 &tri_n2, KRHitInfo &hitinfo)
|
bool KRMesh::rayCast(const KRVector3 &line_v0, const KRVector3 &dir, const KRVector3 &tri_v0, const KRVector3 &tri_v1, const KRVector3 &tri_v2, const KRVector3 &tri_n0, const KRVector3 &tri_n1, const KRVector3 &tri_n2, KRHitInfo &hitinfo)
|
||||||
@@ -1000,6 +1070,7 @@ bool KRMesh::rayCast(const KRVector3 &line_v0, const KRVector3 &dir, int tri_ind
|
|||||||
|
|
||||||
bool KRMesh::rayCast(const KRVector3 &v0, const KRVector3 &dir, KRHitInfo &hitinfo) const
|
bool KRMesh::rayCast(const KRVector3 &v0, const KRVector3 &dir, KRHitInfo &hitinfo) const
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
bool hit_found = false;
|
bool hit_found = false;
|
||||||
for(int submesh_index=0; submesh_index < getSubmeshCount(); submesh_index++) {
|
for(int submesh_index=0; submesh_index < getSubmeshCount(); submesh_index++) {
|
||||||
// int vertex_start = getSubmesh(submesh_index)->start_vertex;
|
// int vertex_start = getSubmesh(submesh_index)->start_vertex;
|
||||||
@@ -1036,26 +1107,30 @@ bool KRMesh::rayCast(const KRVector3 &v0, const KRVector3 &dir, KRHitInfo &hitin
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_pData->unlock();
|
||||||
return hit_found;
|
return hit_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRMesh::lineCast(const KRVector3 &v0, const KRVector3 &v1, KRHitInfo &hitinfo) const
|
bool KRMesh::lineCast(const KRVector3 &v0, const KRVector3 &v1, KRHitInfo &hitinfo) const
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
KRHitInfo new_hitinfo;
|
KRHitInfo new_hitinfo;
|
||||||
KRVector3 dir = KRVector3::Normalize(v1 - v0);
|
KRVector3 dir = KRVector3::Normalize(v1 - v0);
|
||||||
if(rayCast(v0, dir, new_hitinfo)) {
|
if(rayCast(v0, dir, new_hitinfo)) {
|
||||||
if((new_hitinfo.getPosition() - v0).sqrMagnitude() <= (v1 - v0).sqrMagnitude()) {
|
if((new_hitinfo.getPosition() - v0).sqrMagnitude() <= (v1 - v0).sqrMagnitude()) {
|
||||||
// The hit was between v1 and v2
|
// The hit was between v1 and v2
|
||||||
hitinfo = new_hitinfo;
|
hitinfo = new_hitinfo;
|
||||||
|
m_pData->unlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_pData->unlock();
|
||||||
return false; // Either no hit, or the hit was beyond v1
|
return false; // Either no hit, or the hit was beyond v1
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMesh::convertToIndexed()
|
void KRMesh::convertToIndexed()
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
char *szKey = new char[m_vertex_size * 2 + 1];
|
char *szKey = new char[m_vertex_size * 2 + 1];
|
||||||
|
|
||||||
// Convert model to indexed vertices, identying vertexes with identical attributes and optimizing order of trianges for best usage post-vertex-transform cache on GPU
|
// Convert model to indexed vertices, identying vertexes with identical attributes and optimizing order of trianges for best usage post-vertex-transform cache on GPU
|
||||||
@@ -1230,6 +1305,8 @@ void KRMesh::convertToIndexed()
|
|||||||
|
|
||||||
|
|
||||||
mi.format = KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES;
|
mi.format = KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES;
|
||||||
|
|
||||||
|
m_pData->unlock();
|
||||||
LoadData(mi, false, false);
|
LoadData(mi, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1264,6 +1341,9 @@ int KRMesh::getTriangleVertexIndex(int submesh, int index) const
|
|||||||
switch(getModelFormat()) {
|
switch(getModelFormat()) {
|
||||||
case KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES:
|
case KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES:
|
||||||
{
|
{
|
||||||
|
__uint16_t *index_data = getIndexData();
|
||||||
|
|
||||||
|
|
||||||
int start_index_offset, start_vertex_offset, index_count, vertex_count;
|
int start_index_offset, start_vertex_offset, index_count, vertex_count;
|
||||||
int index_group = getSubmesh(submesh)->index_group;
|
int index_group = getSubmesh(submesh)->index_group;
|
||||||
int index_group_offset = getSubmesh(submesh)->index_group_offset;
|
int index_group_offset = getSubmesh(submesh)->index_group_offset;
|
||||||
@@ -1273,7 +1353,7 @@ int KRMesh::getTriangleVertexIndex(int submesh, int index) const
|
|||||||
remaining_vertices -= index_count;
|
remaining_vertices -= index_count;
|
||||||
getIndexedRange(index_group++, start_index_offset, start_vertex_offset, index_count, vertex_count);
|
getIndexedRange(index_group++, start_index_offset, start_vertex_offset, index_count, vertex_count);
|
||||||
}
|
}
|
||||||
return getIndexData()[start_index_offset + remaining_vertices] + start_vertex_offset;
|
return index_data[start_index_offset + remaining_vertices] + start_vertex_offset;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1284,85 +1364,89 @@ int KRMesh::getTriangleVertexIndex(int submesh, int index) const
|
|||||||
|
|
||||||
void KRMesh::optimizeIndexes()
|
void KRMesh::optimizeIndexes()
|
||||||
{
|
{
|
||||||
if(getModelFormat() != KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) return;
|
m_pData->lock();
|
||||||
|
if(getModelFormat() == KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES) {
|
||||||
__uint16_t *new_indices = (__uint16_t *)malloc(0x10000 * sizeof(__uint16_t));
|
|
||||||
__uint16_t *vertex_mapping = (__uint16_t *)malloc(0x10000 * sizeof(__uint16_t));
|
__uint16_t *new_indices = (__uint16_t *)malloc(0x10000 * sizeof(__uint16_t));
|
||||||
unsigned char *new_vertex_data = (unsigned char *)malloc(m_vertex_size * 0x10000);
|
__uint16_t *vertex_mapping = (__uint16_t *)malloc(0x10000 * sizeof(__uint16_t));
|
||||||
|
unsigned char *new_vertex_data = (unsigned char *)malloc(m_vertex_size * 0x10000);
|
||||||
// FINDME, TODO, HACK - This will segfault if the KRData object is still mmap'ed to a read-only file. Need to detach from the file before calling this function. Currently, this function is only being used during the import process, so it isn't going to cause any problems for now.
|
|
||||||
|
// FINDME, TODO, HACK - This will segfault if the KRData object is still mmap'ed to a read-only file. Need to detach from the file before calling this function. Currently, this function is only being used during the import process, so it isn't going to cause any problems for now.
|
||||||
pack_header *header = getHeader();
|
|
||||||
|
pack_header *header = getHeader();
|
||||||
__uint16_t *index_data = getIndexData();
|
|
||||||
unsigned char *vertex_data = getVertexData();
|
__uint16_t *index_data = getIndexData();
|
||||||
|
unsigned char *vertex_data = getVertexData();
|
||||||
for(int submesh_index=0; submesh_index < header->submesh_count; submesh_index++) {
|
|
||||||
pack_material *submesh = getSubmesh(submesh_index);
|
for(int submesh_index=0; submesh_index < header->submesh_count; submesh_index++) {
|
||||||
int vertexes_remaining = submesh->vertex_count;
|
pack_material *submesh = getSubmesh(submesh_index);
|
||||||
int index_group = getSubmesh(submesh_index)->index_group;
|
int vertexes_remaining = submesh->vertex_count;
|
||||||
int index_group_offset = getSubmesh(submesh_index)->index_group_offset;
|
int index_group = getSubmesh(submesh_index)->index_group;
|
||||||
while(vertexes_remaining > 0) {
|
int index_group_offset = getSubmesh(submesh_index)->index_group_offset;
|
||||||
int start_index_offset, start_vertex_offset, index_count, vertex_count;
|
while(vertexes_remaining > 0) {
|
||||||
getIndexedRange(index_group++, start_index_offset, start_vertex_offset, index_count, vertex_count);
|
int start_index_offset, start_vertex_offset, index_count, vertex_count;
|
||||||
|
getIndexedRange(index_group++, start_index_offset, start_vertex_offset, index_count, vertex_count);
|
||||||
int vertexes_to_process = vertexes_remaining;
|
|
||||||
if(vertexes_to_process + index_group_offset > 0xffff) {
|
int vertexes_to_process = vertexes_remaining;
|
||||||
vertexes_to_process = 0xffff - index_group_offset;
|
if(vertexes_to_process + index_group_offset > 0xffff) {
|
||||||
}
|
vertexes_to_process = 0xffff - index_group_offset;
|
||||||
|
|
||||||
__uint16_t *index_data_start = index_data + start_index_offset + index_group_offset;
|
|
||||||
|
|
||||||
|
|
||||||
// ----====---- Step 1: Optimize triangle drawing order to maximize use of the GPU's post-transform vertex cache ----====----
|
|
||||||
Forsyth::OptimizeFaces(index_data_start, vertexes_to_process, vertex_count, new_indices, 16); // FINDME, TODO - GPU post-transform vertex cache size of 16 should be configureable
|
|
||||||
memcpy(index_data_start, new_indices, vertexes_to_process * sizeof(__uint16_t));
|
|
||||||
vertexes_remaining -= vertexes_to_process;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
unsigned char * vertex_data_start = vertex_data + start_vertex_offset;
|
|
||||||
|
|
||||||
// ----====---- Step 2: Re-order the vertex data to maintain cache coherency ----====----
|
|
||||||
for(int i=0; i < vertex_count; i++) {
|
|
||||||
vertex_mapping[i] = i;
|
|
||||||
}
|
|
||||||
int new_vertex_index=0;
|
|
||||||
for(int index_number=0; index_number<index_count; index_number++) {
|
|
||||||
int prev_vertex_index = index_data_start[index_number];
|
|
||||||
if(prev_vertex_index > new_vertex_index) {
|
|
||||||
// Swap prev_vertex_index and new_vertex_index
|
|
||||||
|
|
||||||
for(int i=0; i < index_count; i++) {
|
|
||||||
if(index_data_start[i] == prev_vertex_index) {
|
|
||||||
index_data_start[i] = new_vertex_index;
|
|
||||||
} else if(index_data_start[i] == new_vertex_index) {
|
|
||||||
index_data_start[i] = prev_vertex_index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int tmp = vertex_mapping[prev_vertex_index];
|
|
||||||
vertex_mapping[prev_vertex_index] = vertex_mapping[new_vertex_index];
|
|
||||||
vertex_mapping[new_vertex_index] = tmp;
|
|
||||||
|
|
||||||
|
|
||||||
new_vertex_index++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__uint16_t *index_data_start = index_data + start_index_offset + index_group_offset;
|
||||||
|
|
||||||
|
|
||||||
|
// ----====---- Step 1: Optimize triangle drawing order to maximize use of the GPU's post-transform vertex cache ----====----
|
||||||
|
Forsyth::OptimizeFaces(index_data_start, vertexes_to_process, vertex_count, new_indices, 16); // FINDME, TODO - GPU post-transform vertex cache size of 16 should be configureable
|
||||||
|
memcpy(index_data_start, new_indices, vertexes_to_process * sizeof(__uint16_t));
|
||||||
|
vertexes_remaining -= vertexes_to_process;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
unsigned char * vertex_data_start = vertex_data + start_vertex_offset;
|
||||||
|
|
||||||
|
// ----====---- Step 2: Re-order the vertex data to maintain cache coherency ----====----
|
||||||
|
for(int i=0; i < vertex_count; i++) {
|
||||||
|
vertex_mapping[i] = i;
|
||||||
|
}
|
||||||
|
int new_vertex_index=0;
|
||||||
|
for(int index_number=0; index_number<index_count; index_number++) {
|
||||||
|
int prev_vertex_index = index_data_start[index_number];
|
||||||
|
if(prev_vertex_index > new_vertex_index) {
|
||||||
|
// Swap prev_vertex_index and new_vertex_index
|
||||||
|
|
||||||
|
for(int i=0; i < index_count; i++) {
|
||||||
|
if(index_data_start[i] == prev_vertex_index) {
|
||||||
|
index_data_start[i] = new_vertex_index;
|
||||||
|
} else if(index_data_start[i] == new_vertex_index) {
|
||||||
|
index_data_start[i] = prev_vertex_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int tmp = vertex_mapping[prev_vertex_index];
|
||||||
|
vertex_mapping[prev_vertex_index] = vertex_mapping[new_vertex_index];
|
||||||
|
vertex_mapping[new_vertex_index] = tmp;
|
||||||
|
|
||||||
|
|
||||||
|
new_vertex_index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i < vertex_count; i++) {
|
||||||
|
memcpy(new_vertex_data + vertex_mapping[i] * m_vertex_size, vertex_data_start + i * m_vertex_size, m_vertex_size);
|
||||||
|
}
|
||||||
|
memcpy(vertex_data_start, new_vertex_data, vertex_count * m_vertex_size);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
index_group_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=0; i < vertex_count; i++) {
|
|
||||||
memcpy(new_vertex_data + vertex_mapping[i] * m_vertex_size, vertex_data_start + i * m_vertex_size, m_vertex_size);
|
|
||||||
}
|
|
||||||
memcpy(vertex_data_start, new_vertex_data, vertex_count * m_vertex_size);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
index_group_offset = 0;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
free(new_indices);
|
||||||
|
free(vertex_mapping);
|
||||||
|
free(new_vertex_data);
|
||||||
|
} // if(getModelFormat() == KRENGINE_MODEL_FORMAT_INDEXED_TRIANGLES)
|
||||||
|
|
||||||
free(new_indices);
|
m_pData->unlock();
|
||||||
free(vertex_mapping);
|
|
||||||
free(new_vertex_data);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
std::vector<std::vector<float> > bone_weights;
|
std::vector<std::vector<float> > bone_weights;
|
||||||
} mesh_info;
|
} mesh_info;
|
||||||
|
|
||||||
void render(const std::string &object_name, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, const KRMat4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass, const std::vector<KRBone *> &bones);
|
void render(const std::string &object_name, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, const KRMat4 &matModel, KRTexture *pLightMap, KRNode::RenderPass renderPass, const std::vector<KRBone *> &bones, const KRVector3 &rim_color, float rim_power);
|
||||||
|
|
||||||
std::string m_lodBaseName;
|
std::string m_lodBaseName;
|
||||||
|
|
||||||
@@ -133,11 +133,24 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
class Submesh {
|
||||||
|
public:
|
||||||
|
Submesh() {};
|
||||||
|
~Submesh() {
|
||||||
|
for(std::vector<KRDataBlock *>::iterator itr = vertex_data_blocks.begin(); itr != vertex_data_blocks.end(); itr++) {
|
||||||
|
delete (*itr);
|
||||||
|
}
|
||||||
|
for(std::vector<KRDataBlock *>::iterator itr = index_data_blocks.begin(); itr != index_data_blocks.end(); itr++) {
|
||||||
|
delete (*itr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GLint start_vertex;
|
GLint start_vertex;
|
||||||
GLsizei vertex_count;
|
GLsizei vertex_count;
|
||||||
char szMaterialName[KRENGINE_MAX_NAME_LENGTH];
|
char szMaterialName[KRENGINE_MAX_NAME_LENGTH];
|
||||||
} Submesh;
|
vector<KRDataBlock *> vertex_data_blocks;
|
||||||
|
vector<KRDataBlock *> index_data_blocks;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
@@ -198,6 +211,10 @@ public:
|
|||||||
|
|
||||||
static int GetLODCoverage(const std::string &name);
|
static int GetLODCoverage(const std::string &name);
|
||||||
private:
|
private:
|
||||||
|
KRDataBlock *m_pData;
|
||||||
|
KRDataBlock *m_pMetaData;
|
||||||
|
KRDataBlock *m_pIndexBaseData;
|
||||||
|
|
||||||
void getSubmeshes();
|
void getSubmeshes();
|
||||||
|
|
||||||
// bool rayCast(const KRVector3 &line_v0, const KRVector3 &dir, int tri_index0, int tri_index1, int tri_index2, KRHitInfo &hitinfo) const;
|
// bool rayCast(const KRVector3 &line_v0, const KRVector3 &dir, int tri_index0, int tri_index1, int tri_index2, KRHitInfo &hitinfo) const;
|
||||||
@@ -212,8 +229,7 @@ private:
|
|||||||
|
|
||||||
KRVector3 m_minPoint, m_maxPoint;
|
KRVector3 m_minPoint, m_maxPoint;
|
||||||
|
|
||||||
KRDataBlock *m_pData;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -234,24 +250,25 @@ private:
|
|||||||
int m_vertex_size;
|
int m_vertex_size;
|
||||||
void updateAttributeOffsets();
|
void updateAttributeOffsets();
|
||||||
|
|
||||||
|
|
||||||
void clearData();
|
|
||||||
void clearBuffers();
|
|
||||||
|
|
||||||
void setName(const std::string name);
|
void setName(const std::string name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pack_material *getSubmesh(int mesh_index) const;
|
pack_material *getSubmesh(int mesh_index) const;
|
||||||
unsigned char *getVertexData() const;
|
unsigned char *getVertexData() const;
|
||||||
|
size_t getVertexDataOffset() const;
|
||||||
unsigned char *getVertexData(int index) const;
|
unsigned char *getVertexData(int index) const;
|
||||||
__uint16_t *getIndexData() const;
|
__uint16_t *getIndexData() const;
|
||||||
|
size_t getIndexDataOffset() const;
|
||||||
__uint32_t *getIndexBaseData() const;
|
__uint32_t *getIndexBaseData() const;
|
||||||
pack_header *getHeader() const;
|
pack_header *getHeader() const;
|
||||||
pack_bone *getBone(int index);
|
pack_bone *getBone(int index);
|
||||||
|
|
||||||
|
|
||||||
void getIndexedRange(int index_group, int &start_index_offset, int &start_vertex_offset, int &index_count, int &vertex_count) const;
|
void getIndexedRange(int index_group, int &start_index_offset, int &start_vertex_offset, int &index_count, int &vertex_count) const;
|
||||||
|
|
||||||
|
void releaseData();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,23 +35,61 @@
|
|||||||
|
|
||||||
#include "KRMesh.h"
|
#include "KRMesh.h"
|
||||||
#include "KRMeshCube.h"
|
#include "KRMeshCube.h"
|
||||||
|
#include "KRMeshQuad.h"
|
||||||
#include "KRMeshSphere.h"
|
#include "KRMeshSphere.h"
|
||||||
|
|
||||||
KRMeshManager::KRMeshManager(KRContext &context) : KRContextObject(context) {
|
KRMeshManager::KRMeshManager(KRContext &context) : KRContextObject(context), m_streamer(context) {
|
||||||
m_currentVBO.vbo_handle = -1;
|
m_currentVBO.vbo_handle = -1;
|
||||||
m_currentVBO.vbo_handle_indexes = -1;
|
m_currentVBO.vbo_handle_indexes = -1;
|
||||||
m_currentVBO.vao_handle = -1;
|
m_currentVBO.vao_handle = -1;
|
||||||
m_currentVBO.data = NULL;
|
m_currentVBO.data = NULL;
|
||||||
m_vboMemUsed = 0;
|
m_vboMemUsed = 0;
|
||||||
m_randomParticleVertexData = NULL;
|
|
||||||
m_volumetricLightingVertexData = NULL;
|
|
||||||
m_memoryTransferredThisFrame = 0;
|
m_memoryTransferredThisFrame = 0;
|
||||||
|
|
||||||
// addModel(new KRMeshCube(context)); // FINDME - HACK! This needs to be fixed, as it currently segfaults
|
addModel(new KRMeshCube(context)); // FINDME - HACK! This needs to be fixed, as it currently segfaults
|
||||||
|
addModel(new KRMeshQuad(context)); // FINDME - HACK! This needs to be fixed, as it currently segfaults
|
||||||
addModel(new KRMeshSphere(context));
|
addModel(new KRMeshSphere(context));
|
||||||
m_draw_call_logging_enabled = false;
|
m_draw_call_logging_enabled = false;
|
||||||
m_draw_call_log_used = false;
|
m_draw_call_log_used = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ---- Initialize stock models ----
|
||||||
|
|
||||||
|
static const GLfloat _KRENGINE_VBO_3D_CUBE_VERTEX_DATA[] = {
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
KRENGINE_VBO_3D_CUBE_ATTRIBS = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX);
|
||||||
|
KRENGINE_VBO_3D_CUBE_VERTICES.expand(sizeof(GLfloat) * 3 * 14);
|
||||||
|
KRENGINE_VBO_3D_CUBE_VERTICES.lock();
|
||||||
|
memcpy(KRENGINE_VBO_3D_CUBE_VERTICES.getStart(), _KRENGINE_VBO_3D_CUBE_VERTEX_DATA, sizeof(GLfloat) * 3 * 14);
|
||||||
|
KRENGINE_VBO_3D_CUBE_VERTICES.unlock();
|
||||||
|
|
||||||
|
static const GLfloat _KRENGINE_VBO_2D_SQUARE_VERTEX_DATA[] = {
|
||||||
|
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
1.0f, 1.0f, 0.0f, 1.0f, 1.0f
|
||||||
|
};
|
||||||
|
KRENGINE_VBO_2D_SQUARE_ATTRIBS = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA);
|
||||||
|
KRENGINE_VBO_2D_SQUARE_VERTICES.expand(sizeof(GLfloat) * 5 * 4);
|
||||||
|
KRENGINE_VBO_2D_SQUARE_VERTICES.lock();
|
||||||
|
memcpy(KRENGINE_VBO_2D_SQUARE_VERTICES.getStart(), _KRENGINE_VBO_2D_SQUARE_VERTEX_DATA, sizeof(GLfloat) * 5 * 4);
|
||||||
|
KRENGINE_VBO_2D_SQUARE_VERTICES.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMeshManager::~KRMeshManager() {
|
KRMeshManager::~KRMeshManager() {
|
||||||
@@ -59,8 +97,6 @@ KRMeshManager::~KRMeshManager() {
|
|||||||
delete (*itr).second;
|
delete (*itr).second;
|
||||||
}
|
}
|
||||||
m_models.empty();
|
m_models.empty();
|
||||||
if(m_randomParticleVertexData != NULL) delete m_randomParticleVertexData;
|
|
||||||
if(m_volumetricLightingVertexData != NULL) delete m_volumetricLightingVertexData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMesh *KRMeshManager::loadModel(const char *szName, KRDataBlock *pData) {
|
KRMesh *KRMeshManager::loadModel(const char *szName, KRDataBlock *pData) {
|
||||||
@@ -115,24 +151,24 @@ void KRMeshManager::unbindVBO() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMeshManager::releaseVBO(GLvoid *data)
|
void KRMeshManager::releaseVBO(KRDataBlock &data)
|
||||||
{
|
{
|
||||||
if(m_currentVBO.data == data) {
|
if(m_currentVBO.data == &data) {
|
||||||
unbindVBO();
|
unbindVBO();
|
||||||
}
|
}
|
||||||
|
|
||||||
vbo_info_type vbo_to_release;
|
vbo_info_type vbo_to_release;
|
||||||
if(m_vbosActive.find(data) != m_vbosActive.end()) {
|
if(m_vbosActive.find(&data) != m_vbosActive.end()) {
|
||||||
fprintf(stderr, "glFinish called due to releasing a VBO that is active in the current frame.\n");
|
fprintf(stderr, "glFinish called due to releasing a VBO that is active in the current frame.\n");
|
||||||
GLDEBUG(glFinish());
|
GLDEBUG(glFinish());
|
||||||
|
|
||||||
// The VBO is active
|
// The VBO is active
|
||||||
vbo_to_release = m_vbosActive[data];
|
vbo_to_release = m_vbosActive[&data];
|
||||||
m_vbosActive.erase(data);
|
m_vbosActive.erase(&data);
|
||||||
} else {
|
} else {
|
||||||
// The VBO is inactive
|
// The VBO is inactive
|
||||||
vbo_to_release = m_vbosPool[data];
|
vbo_to_release = m_vbosPool[&data];
|
||||||
m_vbosPool.erase(data);
|
m_vbosPool.erase(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vboMemUsed -= vbo_to_release.size;
|
m_vboMemUsed -= vbo_to_release.size;
|
||||||
@@ -146,12 +182,12 @@ void KRMeshManager::releaseVBO(GLvoid *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, GLsizeiptr index_data_size, int vertex_attrib_flags, bool static_vbo) {
|
void KRMeshManager::bindVBO(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo) {
|
||||||
|
|
||||||
if(m_currentVBO.data != data || m_currentVBO.size != size + index_data_size) {
|
if(m_currentVBO.data != &data) {
|
||||||
|
|
||||||
if(m_vbosActive.find(data) != m_vbosActive.end()) {
|
if(m_vbosActive.find(&data) != m_vbosActive.end()) {
|
||||||
m_currentVBO = m_vbosActive[data];
|
m_currentVBO = m_vbosActive[&data];
|
||||||
#if GL_OES_vertex_array_object
|
#if GL_OES_vertex_array_object
|
||||||
GLDEBUG(glBindVertexArrayOES(m_currentVBO.vao_handle));
|
GLDEBUG(glBindVertexArrayOES(m_currentVBO.vao_handle));
|
||||||
#else
|
#else
|
||||||
@@ -163,10 +199,10 @@ void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, G
|
|||||||
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_currentVBO.vbo_handle_indexes));
|
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_currentVBO.vbo_handle_indexes));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if(m_vbosPool.find(data) != m_vbosPool.end()) {
|
} else if(m_vbosPool.find(&data) != m_vbosPool.end()) {
|
||||||
m_currentVBO = m_vbosPool[data];
|
m_currentVBO = m_vbosPool[&data];
|
||||||
m_vbosPool.erase(data);
|
m_vbosPool.erase(&data);
|
||||||
m_vbosActive[data] = m_currentVBO;
|
m_vbosActive[&data] = m_currentVBO;
|
||||||
#if GL_OES_vertex_array_object
|
#if GL_OES_vertex_array_object
|
||||||
GLDEBUG(glBindVertexArrayOES(m_currentVBO.vao_handle));
|
GLDEBUG(glBindVertexArrayOES(m_currentVBO.vao_handle));
|
||||||
#else
|
#else
|
||||||
@@ -181,12 +217,12 @@ void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, G
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
while(m_vbosPool.size() + m_vbosActive.size() + 1 >= KRContext::KRENGINE_MAX_VBO_HANDLES || m_vboMemUsed + size + index_data_size >= KRContext::KRENGINE_MAX_VBO_MEM) {
|
while(m_vbosPool.size() + m_vbosActive.size() + 1 >= KRContext::KRENGINE_MAX_VBO_HANDLES || m_vboMemUsed + data.getSize() + index_data.getSize() >= KRContext::KRENGINE_MAX_VBO_MEM) {
|
||||||
if(m_vbosPool.empty()) {
|
if(m_vbosPool.empty()) {
|
||||||
fprintf(stderr, "flushBuffers due to VBO exhaustion...\n");
|
fprintf(stderr, "flushBuffers due to VBO exhaustion...\n");
|
||||||
m_pContext->rotateBuffers(false);
|
m_pContext->rotateBuffers(false);
|
||||||
}
|
}
|
||||||
unordered_map<GLvoid *, vbo_info_type>::iterator first_itr = m_vbosPool.begin();
|
unordered_map<KRDataBlock *, vbo_info_type>::iterator first_itr = m_vbosPool.begin();
|
||||||
vbo_info_type firstVBO = first_itr->second;
|
vbo_info_type firstVBO = first_itr->second;
|
||||||
#if GL_OES_vertex_array_object
|
#if GL_OES_vertex_array_object
|
||||||
GLDEBUG(glDeleteVertexArraysOES(1, &firstVBO.vao_handle));
|
GLDEBUG(glDeleteVertexArraysOES(1, &firstVBO.vao_handle));
|
||||||
@@ -204,7 +240,7 @@ void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, G
|
|||||||
m_currentVBO.vbo_handle = -1;
|
m_currentVBO.vbo_handle = -1;
|
||||||
m_currentVBO.vbo_handle_indexes = -1;
|
m_currentVBO.vbo_handle_indexes = -1;
|
||||||
GLDEBUG(glGenBuffers(1, &m_currentVBO.vbo_handle));
|
GLDEBUG(glGenBuffers(1, &m_currentVBO.vbo_handle));
|
||||||
if(index_data != NULL) {
|
if(index_data.getSize() > 0) {
|
||||||
GLDEBUG(glGenBuffers(1, &m_currentVBO.vbo_handle_indexes));
|
GLDEBUG(glGenBuffers(1, &m_currentVBO.vbo_handle_indexes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,25 +250,49 @@ void KRMeshManager::bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, G
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
GLDEBUG(glBindBuffer(GL_ARRAY_BUFFER, m_currentVBO.vbo_handle));
|
GLDEBUG(glBindBuffer(GL_ARRAY_BUFFER, m_currentVBO.vbo_handle));
|
||||||
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, size, data, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
#if GL_OES_mapbuffer
|
||||||
m_memoryTransferredThisFrame += size;
|
|
||||||
m_vboMemUsed += size;
|
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, data.getSize(), NULL, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||||
|
GLDEBUG(void *map_ptr = glMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES));
|
||||||
|
data.copy(map_ptr);
|
||||||
|
//memcpy(map_ptr, data, size);
|
||||||
|
GLDEBUG(glUnmapBufferOES(GL_ARRAY_BUFFER));
|
||||||
|
#else
|
||||||
|
data.lock();
|
||||||
|
GLDEBUG(glBufferData(GL_ARRAY_BUFFER, data.getSize(), data.getStart(), static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||||
|
data.unlock();
|
||||||
|
#endif
|
||||||
|
m_memoryTransferredThisFrame += data.getSize();
|
||||||
|
m_vboMemUsed += data.getSize();
|
||||||
configureAttribs(vertex_attrib_flags);
|
configureAttribs(vertex_attrib_flags);
|
||||||
|
|
||||||
m_currentVBO.size = size;
|
m_currentVBO.size = data.getSize();
|
||||||
m_currentVBO.data = data;
|
m_currentVBO.data = &data;
|
||||||
|
|
||||||
if(index_data == NULL) {
|
if(index_data.getSize() == 0) {
|
||||||
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
|
||||||
} else {
|
} else {
|
||||||
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_currentVBO.vbo_handle_indexes));
|
GLDEBUG(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_currentVBO.vbo_handle_indexes));
|
||||||
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_data_size, index_data, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
|
||||||
m_memoryTransferredThisFrame += index_data_size;
|
#if GL_OES_mapbuffer
|
||||||
m_vboMemUsed += index_data_size;
|
|
||||||
m_currentVBO.size += index_data_size;
|
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_data.getSize(), NULL, static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||||
|
GLDEBUG(void *map_ptr = glMapBufferOES(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY_OES));
|
||||||
|
index_data.copy(map_ptr);
|
||||||
|
//memcpy(map_ptr, index_data, index_data.getSize());
|
||||||
|
GLDEBUG(glUnmapBufferOES(GL_ELEMENT_ARRAY_BUFFER));
|
||||||
|
#else
|
||||||
|
index_data.lock();
|
||||||
|
GLDEBUG(glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_data.getSize(), index_data.getStart(), static_vbo ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW));
|
||||||
|
index_data.unlock();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_memoryTransferredThisFrame += index_data.getSize();
|
||||||
|
m_vboMemUsed += index_data.getSize();
|
||||||
|
m_currentVBO.size += index_data.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vbosActive[data] = m_currentVBO;
|
m_vbosActive[&data] = m_currentVBO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,7 +374,7 @@ long KRMeshManager::getMemUsed()
|
|||||||
long KRMeshManager::getMemActive()
|
long KRMeshManager::getMemActive()
|
||||||
{
|
{
|
||||||
long mem_active = 0;
|
long mem_active = 0;
|
||||||
for(unordered_map<GLvoid *, vbo_info_type>::iterator itr = m_vbosActive.begin(); itr != m_vbosActive.end(); itr++) {
|
for(unordered_map<KRDataBlock *, vbo_info_type>::iterator itr = m_vbosActive.begin(); itr != m_vbosActive.end(); itr++) {
|
||||||
mem_active += (*itr).second.size;
|
mem_active += (*itr).second.size;
|
||||||
}
|
}
|
||||||
return mem_active;
|
return mem_active;
|
||||||
@@ -332,56 +392,56 @@ void KRMeshManager::rotateBuffers(bool new_frame)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMeshManager::VolumetricLightingVertexData *KRMeshManager::getVolumetricLightingVertexes()
|
KRDataBlock &KRMeshManager::getVolumetricLightingVertexes()
|
||||||
{
|
{
|
||||||
if(m_volumetricLightingVertexData == NULL) {
|
if(m_volumetricLightingVertexData.getSize() == 0) {
|
||||||
m_volumetricLightingVertexData = (VolumetricLightingVertexData *)malloc(sizeof(VolumetricLightingVertexData) * KRENGINE_MAX_VOLUMETRIC_PLANES * 6);
|
m_volumetricLightingVertexData.expand(sizeof(VolumetricLightingVertexData) * KRENGINE_MAX_VOLUMETRIC_PLANES * 6);
|
||||||
|
m_volumetricLightingVertexData.lock();
|
||||||
|
VolumetricLightingVertexData * vertex_data = (VolumetricLightingVertexData *)m_volumetricLightingVertexData.getStart();
|
||||||
int iVertex=0;
|
int iVertex=0;
|
||||||
for(int iPlane=0; iPlane < KRENGINE_MAX_VOLUMETRIC_PLANES; iPlane++) {
|
for(int iPlane=0; iPlane < KRENGINE_MAX_VOLUMETRIC_PLANES; iPlane++) {
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.x = -1.0f;
|
vertex_data[iVertex].vertex.x = -1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.y = -1.0f;
|
vertex_data[iVertex].vertex.y = -1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.z = iPlane;
|
vertex_data[iVertex].vertex.z = iPlane;
|
||||||
iVertex++;
|
iVertex++;
|
||||||
|
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.x = 1.0f;
|
vertex_data[iVertex].vertex.x = 1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.y = -1.0f;
|
vertex_data[iVertex].vertex.y = -1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.z = iPlane;
|
vertex_data[iVertex].vertex.z = iPlane;
|
||||||
iVertex++;
|
iVertex++;
|
||||||
|
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.x = -1.0f;
|
vertex_data[iVertex].vertex.x = -1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.y = 1.0f;
|
vertex_data[iVertex].vertex.y = 1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.z = iPlane;
|
vertex_data[iVertex].vertex.z = iPlane;
|
||||||
iVertex++;
|
iVertex++;
|
||||||
|
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.x = -1.0f;
|
vertex_data[iVertex].vertex.x = -1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.y = 1.0f;
|
vertex_data[iVertex].vertex.y = 1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.z = iPlane;
|
vertex_data[iVertex].vertex.z = iPlane;
|
||||||
iVertex++;
|
iVertex++;
|
||||||
|
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.x = 1.0f;
|
vertex_data[iVertex].vertex.x = 1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.y = -1.0f;
|
vertex_data[iVertex].vertex.y = -1.0f;
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.z = iPlane;
|
vertex_data[iVertex].vertex.z = iPlane;
|
||||||
iVertex++;
|
iVertex++;
|
||||||
|
|
||||||
|
vertex_data[iVertex].vertex.x = 1.0f;
|
||||||
|
vertex_data[iVertex].vertex.y = 1.0f;
|
||||||
|
vertex_data[iVertex].vertex.z = iPlane;
|
||||||
|
iVertex++;
|
||||||
|
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.x = 1.0f;
|
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.y = 1.0f;
|
|
||||||
m_volumetricLightingVertexData[iVertex].vertex.z = iPlane;
|
|
||||||
iVertex++;
|
|
||||||
|
|
||||||
// -1.0f, -1.0f,
|
|
||||||
// 1.0f, -1.0f,
|
|
||||||
// -1.0f, 1.0f,
|
|
||||||
// 1.0f, 1.0f,
|
|
||||||
}
|
}
|
||||||
|
m_volumetricLightingVertexData.unlock();
|
||||||
}
|
}
|
||||||
return m_volumetricLightingVertexData;
|
return m_volumetricLightingVertexData;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRMeshManager::RandomParticleVertexData *KRMeshManager::getRandomParticles()
|
KRDataBlock &KRMeshManager::getRandomParticles()
|
||||||
{
|
{
|
||||||
if(m_randomParticleVertexData == NULL) {
|
if(m_randomParticleVertexData.getSize() == 0) {
|
||||||
m_randomParticleVertexData = (RandomParticleVertexData *)malloc(sizeof(RandomParticleVertexData) * KRENGINE_MAX_RANDOM_PARTICLES * 3);
|
m_randomParticleVertexData.expand(sizeof(RandomParticleVertexData) * KRENGINE_MAX_RANDOM_PARTICLES * 3);
|
||||||
|
m_randomParticleVertexData.lock();
|
||||||
|
RandomParticleVertexData *vertex_data = (RandomParticleVertexData *)m_randomParticleVertexData.getStart();
|
||||||
|
|
||||||
// Generate vertices for randomly placed equilateral triangles with a side length of 1 and an origin point centered so that an inscribed circle can be efficiently rendered without wasting fill
|
// Generate vertices for randomly placed equilateral triangles with a side length of 1 and an origin point centered so that an inscribed circle can be efficiently rendered without wasting fill
|
||||||
|
|
||||||
@@ -390,27 +450,28 @@ KRMeshManager::RandomParticleVertexData *KRMeshManager::getRandomParticles()
|
|||||||
|
|
||||||
int iVertex=0;
|
int iVertex=0;
|
||||||
for(int iParticle=0; iParticle < KRENGINE_MAX_RANDOM_PARTICLES; iParticle++) {
|
for(int iParticle=0; iParticle < KRENGINE_MAX_RANDOM_PARTICLES; iParticle++) {
|
||||||
m_randomParticleVertexData[iVertex].vertex.x = (float)(arc4random() % 2000) / 1000.0f - 1000.0f;
|
vertex_data[iVertex].vertex.x = (float)(arc4random() % 2000) / 1000.0f - 1000.0f;
|
||||||
m_randomParticleVertexData[iVertex].vertex.y = (float)(arc4random() % 2000) / 1000.0f - 1000.0f;
|
vertex_data[iVertex].vertex.y = (float)(arc4random() % 2000) / 1000.0f - 1000.0f;
|
||||||
m_randomParticleVertexData[iVertex].vertex.z = (float)(arc4random() % 2000) / 1000.0f - 1000.0f;
|
vertex_data[iVertex].vertex.z = (float)(arc4random() % 2000) / 1000.0f - 1000.0f;
|
||||||
m_randomParticleVertexData[iVertex].uva.u = -0.5f;
|
vertex_data[iVertex].uva.u = -0.5f;
|
||||||
m_randomParticleVertexData[iVertex].uva.v = -inscribed_circle_radius;
|
vertex_data[iVertex].uva.v = -inscribed_circle_radius;
|
||||||
iVertex++;
|
iVertex++;
|
||||||
|
|
||||||
m_randomParticleVertexData[iVertex].vertex.x = m_randomParticleVertexData[iVertex-1].vertex.x;
|
vertex_data[iVertex].vertex.x = vertex_data[iVertex-1].vertex.x;
|
||||||
m_randomParticleVertexData[iVertex].vertex.y = m_randomParticleVertexData[iVertex-1].vertex.y;
|
vertex_data[iVertex].vertex.y = vertex_data[iVertex-1].vertex.y;
|
||||||
m_randomParticleVertexData[iVertex].vertex.z = m_randomParticleVertexData[iVertex-1].vertex.z;
|
vertex_data[iVertex].vertex.z = vertex_data[iVertex-1].vertex.z;
|
||||||
m_randomParticleVertexData[iVertex].uva.u = 0.5f;
|
vertex_data[iVertex].uva.u = 0.5f;
|
||||||
m_randomParticleVertexData[iVertex].uva.v = -inscribed_circle_radius;
|
vertex_data[iVertex].uva.v = -inscribed_circle_radius;
|
||||||
iVertex++;
|
iVertex++;
|
||||||
|
|
||||||
m_randomParticleVertexData[iVertex].vertex.x = m_randomParticleVertexData[iVertex-1].vertex.x;
|
vertex_data[iVertex].vertex.x = vertex_data[iVertex-1].vertex.x;
|
||||||
m_randomParticleVertexData[iVertex].vertex.y = m_randomParticleVertexData[iVertex-1].vertex.y;
|
vertex_data[iVertex].vertex.y = vertex_data[iVertex-1].vertex.y;
|
||||||
m_randomParticleVertexData[iVertex].vertex.z = m_randomParticleVertexData[iVertex-1].vertex.z;
|
vertex_data[iVertex].vertex.z = vertex_data[iVertex-1].vertex.z;
|
||||||
m_randomParticleVertexData[iVertex].uva.u = 0.0f;
|
vertex_data[iVertex].uva.u = 0.0f;
|
||||||
m_randomParticleVertexData[iVertex].uva.v = -inscribed_circle_radius + equilateral_triangle_height;
|
vertex_data[iVertex].uva.v = -inscribed_circle_radius + equilateral_triangle_height;
|
||||||
iVertex++;
|
iVertex++;
|
||||||
}
|
}
|
||||||
|
m_randomParticleVertexData.unlock();
|
||||||
}
|
}
|
||||||
return m_randomParticleVertexData;
|
return m_randomParticleVertexData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
#include "KRDataBlock.h"
|
#include "KRDataBlock.h"
|
||||||
#include "KRNode.h"
|
#include "KRNode.h"
|
||||||
|
|
||||||
|
#include "KRMeshStreamer.h"
|
||||||
|
|
||||||
class KRContext;
|
class KRContext;
|
||||||
class KRMesh;
|
class KRMesh;
|
||||||
|
|
||||||
@@ -59,8 +61,8 @@ public:
|
|||||||
std::vector<std::string> getModelNames();
|
std::vector<std::string> getModelNames();
|
||||||
unordered_multimap<std::string, KRMesh *> &getModels();
|
unordered_multimap<std::string, KRMesh *> &getModels();
|
||||||
|
|
||||||
void bindVBO(GLvoid *data, GLsizeiptr size, GLvoid *index_data, GLsizeiptr index_data_size, int vertex_attrib_flags, bool static_vbo);
|
void bindVBO(KRDataBlock &data, KRDataBlock &index_data, int vertex_attrib_flags, bool static_vbo);
|
||||||
void releaseVBO(GLvoid *data);
|
void releaseVBO(KRDataBlock &data);
|
||||||
void unbindVBO();
|
void unbindVBO();
|
||||||
long getMemUsed();
|
long getMemUsed();
|
||||||
long getMemActive();
|
long getMemActive();
|
||||||
@@ -88,10 +90,8 @@ public:
|
|||||||
} VolumetricLightingVertexData;
|
} VolumetricLightingVertexData;
|
||||||
|
|
||||||
|
|
||||||
|
KRDataBlock &getRandomParticles();
|
||||||
|
KRDataBlock &getVolumetricLightingVertexes();
|
||||||
RandomParticleVertexData *getRandomParticles();
|
|
||||||
VolumetricLightingVertexData *getVolumetricLightingVertexes();
|
|
||||||
|
|
||||||
|
|
||||||
long getMemoryTransferedThisFrame();
|
long getMemoryTransferedThisFrame();
|
||||||
@@ -108,7 +108,13 @@ public:
|
|||||||
|
|
||||||
void log_draw_call(KRNode::RenderPass pass, const std::string &object_name, const std::string &material_name, int vertex_count);
|
void log_draw_call(KRNode::RenderPass pass, const std::string &object_name, const std::string &material_name, int vertex_count);
|
||||||
std::vector<draw_call_info> getDrawCalls();
|
std::vector<draw_call_info> getDrawCalls();
|
||||||
|
|
||||||
|
|
||||||
|
KRDataBlock KRENGINE_VBO_3D_CUBE_VERTICES, KRENGINE_VBO_3D_CUBE_INDEXES;
|
||||||
|
__int32_t KRENGINE_VBO_3D_CUBE_ATTRIBS;
|
||||||
|
|
||||||
|
KRDataBlock KRENGINE_VBO_2D_SQUARE_VERTICES, KRENGINE_VBO_2D_SQUARE_INDEXES;
|
||||||
|
__int32_t KRENGINE_VBO_2D_SQUARE_ATTRIBS;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unordered_multimap<std::string, KRMesh *> m_models; // Multiple models with the same name/key may be inserted, representing multiple LOD levels of the model
|
unordered_multimap<std::string, KRMesh *> m_models; // Multiple models with the same name/key may be inserted, representing multiple LOD levels of the model
|
||||||
@@ -118,23 +124,25 @@ private:
|
|||||||
GLuint vbo_handle_indexes;
|
GLuint vbo_handle_indexes;
|
||||||
GLuint vao_handle;
|
GLuint vao_handle;
|
||||||
GLsizeiptr size;
|
GLsizeiptr size;
|
||||||
GLvoid *data;
|
KRDataBlock *data;
|
||||||
} vbo_info_type;
|
} vbo_info_type;
|
||||||
|
|
||||||
long m_vboMemUsed;
|
long m_vboMemUsed;
|
||||||
vbo_info_type m_currentVBO;
|
vbo_info_type m_currentVBO;
|
||||||
|
|
||||||
unordered_map<GLvoid *, vbo_info_type> m_vbosActive;
|
unordered_map<KRDataBlock *, vbo_info_type> m_vbosActive;
|
||||||
unordered_map<GLvoid *, vbo_info_type> m_vbosPool;
|
unordered_map<KRDataBlock *, vbo_info_type> m_vbosPool;
|
||||||
|
|
||||||
RandomParticleVertexData *m_randomParticleVertexData;
|
KRDataBlock m_randomParticleVertexData;
|
||||||
VolumetricLightingVertexData *m_volumetricLightingVertexData;
|
KRDataBlock m_volumetricLightingVertexData;
|
||||||
|
|
||||||
long m_memoryTransferredThisFrame;
|
long m_memoryTransferredThisFrame;
|
||||||
|
|
||||||
std::vector<draw_call_info> m_draw_calls;
|
std::vector<draw_call_info> m_draw_calls;
|
||||||
bool m_draw_call_logging_enabled;
|
bool m_draw_call_logging_enabled;
|
||||||
bool m_draw_call_log_used;
|
bool m_draw_call_log_used;
|
||||||
|
|
||||||
|
KRMeshStreamer m_streamer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
62
KREngine/kraken/KRMeshQuad.cpp
Normal file
62
KREngine/kraken/KRMeshQuad.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
//
|
||||||
|
// KRMeshQuad.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 "KRMeshQuad.h"
|
||||||
|
|
||||||
|
|
||||||
|
KRMeshQuad::KRMeshQuad(KRContext &context) : KRMesh(context, "__quad")
|
||||||
|
{
|
||||||
|
KRMesh::mesh_info mi;
|
||||||
|
|
||||||
|
mi.vertices.push_back(KRVector3(-1.0f, -1.0f, 0.0f));
|
||||||
|
mi.vertices.push_back(KRVector3(1.0f, -1.0f, 0.0f));
|
||||||
|
mi.vertices.push_back(KRVector3(-1.0f, 1.0f, 0.0f));
|
||||||
|
mi.vertices.push_back(KRVector3(1.0f, 1.0f, 0.0f));
|
||||||
|
|
||||||
|
mi.uva.push_back(KRVector2(0.0f, 0.0f));
|
||||||
|
mi.uva.push_back(KRVector2(1.0f, 0.0f));
|
||||||
|
mi.uva.push_back(KRVector2(0.0f, 1.0f));
|
||||||
|
mi.uva.push_back(KRVector2(1.0f, 1.0f));
|
||||||
|
|
||||||
|
|
||||||
|
mi.submesh_starts.push_back(0);
|
||||||
|
mi.submesh_lengths.push_back(mi.vertices.size());
|
||||||
|
mi.material_names.push_back("");
|
||||||
|
mi.format = KRENGINE_MODEL_FORMAT_STRIP;
|
||||||
|
|
||||||
|
|
||||||
|
LoadData(mi, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRMeshQuad::~KRMeshQuad()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
44
KREngine/kraken/KRMeshQuad.h
Normal file
44
KREngine/kraken/KRMeshQuad.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// KRMeshQuad.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 KRMESHQUAD_H
|
||||||
|
#define KRMESHQUAD_H
|
||||||
|
|
||||||
|
#include "KRMesh.h"
|
||||||
|
|
||||||
|
class KRMeshQuad : public KRMesh {
|
||||||
|
public:
|
||||||
|
KRMeshQuad(KRContext &context);
|
||||||
|
virtual ~KRMeshQuad();
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
60
KREngine/kraken/KRMeshStreamer.h
Normal file
60
KREngine/kraken/KRMeshStreamer.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// KRMeshManager.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 KRMESHSTREAMER_H
|
||||||
|
#define KRMESHSTREAMER_H
|
||||||
|
|
||||||
|
#include "KREngine-common.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
class KRContext;
|
||||||
|
|
||||||
|
class KRMeshStreamer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KRMeshStreamer(KRContext &context);
|
||||||
|
~KRMeshStreamer();
|
||||||
|
|
||||||
|
void startStreamer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
KRContext &m_context;
|
||||||
|
|
||||||
|
std::thread m_thread;
|
||||||
|
std::atomic<bool> m_stop;
|
||||||
|
std::atomic<bool> m_running;
|
||||||
|
|
||||||
|
void run();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(KRMESHSTREAMER_H) */
|
||||||
91
KREngine/kraken/KRMeshStreamer.mm
Normal file
91
KREngine/kraken/KRMeshStreamer.mm
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
//
|
||||||
|
// KRMeshStreamer.cpp
|
||||||
|
// Kraken
|
||||||
|
//
|
||||||
|
// Created by Kearwood Gilbert on 11/1/2013.
|
||||||
|
// Copyright (c) 2013 Kearwood Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "KRMeshStreamer.h"
|
||||||
|
|
||||||
|
#include "KREngine-common.h"
|
||||||
|
#include "KRContext.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
|
EAGLContext *gMeshStreamerContext = nil;
|
||||||
|
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
|
||||||
|
NSOpenGLContext *gMeshStreamerContext = nil;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#error Unsupported Platform
|
||||||
|
#endif
|
||||||
|
|
||||||
|
KRMeshStreamer::KRMeshStreamer(KRContext &context) : m_context(context)
|
||||||
|
{
|
||||||
|
m_running = false;
|
||||||
|
m_stop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRMeshStreamer::startStreamer()
|
||||||
|
{
|
||||||
|
if(!m_running) {
|
||||||
|
m_running = true;
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
gMeshStreamerContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: [EAGLContext currentContext].sharegroup];
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes] autorelease];
|
||||||
|
gMeshStreamerContext = [[[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: [NSOpenGLContext currentContext] ] autorelease];
|
||||||
|
#else
|
||||||
|
#error Unsupported Platform
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_thread = std::thread(&KRMeshStreamer::run, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KRMeshStreamer::~KRMeshStreamer()
|
||||||
|
{
|
||||||
|
if(m_running) {
|
||||||
|
m_stop = true;
|
||||||
|
m_thread.join();
|
||||||
|
m_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[gMeshStreamerContext release];
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRMeshStreamer::run()
|
||||||
|
{
|
||||||
|
pthread_setname_np("Kraken - Mesh Streamer");
|
||||||
|
|
||||||
|
std::chrono::microseconds sleep_duration( 100 );
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
[EAGLContext setCurrentContext: gMeshStreamerContext];
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
[gMeshStreamerContext makeCurrentContext];
|
||||||
|
#else
|
||||||
|
#error Unsupported Platform
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
while(!m_stop)
|
||||||
|
{
|
||||||
|
if(m_context.getStreamingEnabled()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for( sleep_duration );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,13 +36,32 @@
|
|||||||
#include "KRMesh.h"
|
#include "KRMesh.h"
|
||||||
#include "KRQuaternion.h"
|
#include "KRQuaternion.h"
|
||||||
|
|
||||||
KRModel::KRModel(KRScene &scene, std::string instance_name, std::string model_name, std::string light_map, float lod_min_coverage, bool receives_shadow, bool faces_camera) : KRNode(scene, instance_name) {
|
KRModel::KRModel(KRScene &scene, std::string instance_name, std::string model_name, std::string light_map, float lod_min_coverage, bool receives_shadow, bool faces_camera, KRVector3 rim_color, float rim_power) : KRNode(scene, instance_name) {
|
||||||
m_lightMap = light_map;
|
m_lightMap = light_map;
|
||||||
m_pLightMap = NULL;
|
m_pLightMap = NULL;
|
||||||
m_model_name = model_name;
|
m_model_name = model_name;
|
||||||
m_min_lod_coverage = lod_min_coverage;
|
m_min_lod_coverage = lod_min_coverage;
|
||||||
m_receivesShadow = receives_shadow;
|
m_receivesShadow = receives_shadow;
|
||||||
m_faces_camera = faces_camera;
|
m_faces_camera = faces_camera;
|
||||||
|
m_rim_color = rim_color;
|
||||||
|
m_rim_power = rim_power;
|
||||||
|
|
||||||
|
m_boundsCachedMat.c[0] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[1] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[2] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[3] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[4] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[5] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[6] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[7] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[8] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[9] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[10] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[11] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[12] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[13] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[14] = -1.0f;
|
||||||
|
m_boundsCachedMat.c[15] = -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRModel::~KRModel() {
|
KRModel::~KRModel() {
|
||||||
@@ -61,9 +80,31 @@ tinyxml2::XMLElement *KRModel::saveXML( tinyxml2::XMLNode *parent)
|
|||||||
e->SetAttribute("lod_min_coverage", m_min_lod_coverage);
|
e->SetAttribute("lod_min_coverage", m_min_lod_coverage);
|
||||||
e->SetAttribute("receives_shadow", m_receivesShadow ? "true" : "false");
|
e->SetAttribute("receives_shadow", m_receivesShadow ? "true" : "false");
|
||||||
e->SetAttribute("faces_camera", m_faces_camera ? "true" : "false");
|
e->SetAttribute("faces_camera", m_faces_camera ? "true" : "false");
|
||||||
|
m_rim_color.setXMLAttribute("rim_color", e);
|
||||||
|
e->SetAttribute("rim_power", m_rim_power);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRModel::setRimColor(const const KRVector3 &rim_color)
|
||||||
|
{
|
||||||
|
m_rim_color = rim_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRModel::setRimPower(float rim_power)
|
||||||
|
{
|
||||||
|
m_rim_power = rim_power;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector3 KRModel::getRimColor()
|
||||||
|
{
|
||||||
|
return m_rim_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
float KRModel::getRimPower()
|
||||||
|
{
|
||||||
|
return m_rim_power;
|
||||||
|
}
|
||||||
|
|
||||||
void KRModel::loadModel() {
|
void KRModel::loadModel() {
|
||||||
if(m_models.size() == 0) {
|
if(m_models.size() == 0) {
|
||||||
std::vector<KRMesh *> models = m_pContext->getModelManager()->getModel(m_model_name.c_str()); // The model manager returns the LOD levels in sorted order, with the highest detail first
|
std::vector<KRMesh *> models = m_pContext->getModelManager()->getModel(m_model_name.c_str()); // The model manager returns the LOD levels in sorted order, with the highest detail first
|
||||||
@@ -141,7 +182,7 @@ void KRModel::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
matModel = KRQuaternion(KRVector3::Forward(), KRVector3::Normalize(camera_pos - model_center)).rotationMatrix() * matModel;
|
matModel = KRQuaternion(KRVector3::Forward(), KRVector3::Normalize(camera_pos - model_center)).rotationMatrix() * matModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
pModel->render(getName(), pCamera, point_lights, directional_lights, spot_lights, viewport, matModel, m_pLightMap, renderPass, m_bones[pModel]);
|
pModel->render(getName(), pCamera, point_lights, directional_lights, spot_lights, viewport, matModel, m_pLightMap, renderPass, m_bones[pModel], m_rim_color, m_rim_power);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +196,12 @@ KRAABB KRModel::getBounds() {
|
|||||||
float max_dimension = normal_bounds.longest_radius();
|
float max_dimension = normal_bounds.longest_radius();
|
||||||
return KRAABB(normal_bounds.center()-KRVector3(max_dimension), normal_bounds.center() + KRVector3(max_dimension));
|
return KRAABB(normal_bounds.center()-KRVector3(max_dimension), normal_bounds.center() + KRVector3(max_dimension));
|
||||||
} else {
|
} else {
|
||||||
return KRAABB(m_models[0]->getMinPoint(), m_models[0]->getMaxPoint(), getModelMatrix());
|
|
||||||
|
if(!(m_boundsCachedMat == getModelMatrix())) {
|
||||||
|
m_boundsCachedMat = getModelMatrix();
|
||||||
|
m_boundsCached = KRAABB(m_models[0]->getMinPoint(), m_models[0]->getMaxPoint(), getModelMatrix());
|
||||||
|
}
|
||||||
|
return m_boundsCached;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return KRAABB::Infinite();
|
return KRAABB::Infinite();
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
class KRModel : public KRNode {
|
class KRModel : public KRNode {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KRModel(KRScene &scene, std::string instance_name, std::string model_name, std::string light_map, float lod_min_coverage, bool receives_shadow, bool faces_camera);
|
KRModel(KRScene &scene, std::string instance_name, std::string model_name, std::string light_map, float lod_min_coverage, bool receives_shadow, bool faces_camera, KRVector3 rim_color = KRVector3::Zero(), float rim_power = 0.0f);
|
||||||
virtual ~KRModel();
|
virtual ~KRModel();
|
||||||
|
|
||||||
virtual std::string getElementName();
|
virtual std::string getElementName();
|
||||||
@@ -61,6 +61,11 @@ public:
|
|||||||
|
|
||||||
virtual KRAABB getBounds();
|
virtual KRAABB getBounds();
|
||||||
|
|
||||||
|
void setRimColor(const const KRVector3 &rim_color);
|
||||||
|
void setRimPower(float rim_power);
|
||||||
|
KRVector3 getRimColor();
|
||||||
|
float getRimPower();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<KRMesh *> m_models;
|
std::vector<KRMesh *> m_models;
|
||||||
unordered_map<KRMesh *, std::vector<KRBone *> > m_bones; // Outer std::map connects model to set of bones
|
unordered_map<KRMesh *, std::vector<KRBone *> > m_bones; // Outer std::map connects model to set of bones
|
||||||
@@ -74,6 +79,14 @@ private:
|
|||||||
|
|
||||||
bool m_receivesShadow;
|
bool m_receivesShadow;
|
||||||
bool m_faces_camera;
|
bool m_faces_camera;
|
||||||
|
|
||||||
|
|
||||||
|
KRMat4 m_boundsCachedMat;
|
||||||
|
KRAABB m_boundsCached;
|
||||||
|
|
||||||
|
|
||||||
|
KRVector3 m_rim_color;
|
||||||
|
float m_rim_power;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,11 @@
|
|||||||
#include "KRAABB.h"
|
#include "KRAABB.h"
|
||||||
#include "KRQuaternion.h"
|
#include "KRQuaternion.h"
|
||||||
#include "KRBone.h"
|
#include "KRBone.h"
|
||||||
|
#include "KRLocator.h"
|
||||||
#include "KRAudioSource.h"
|
#include "KRAudioSource.h"
|
||||||
#include "KRAmbientZone.h"
|
#include "KRAmbientZone.h"
|
||||||
#include "KRReverbZone.h"
|
#include "KRReverbZone.h"
|
||||||
|
#include "KRSprite.h"
|
||||||
|
|
||||||
KRNode::KRNode(KRScene &scene, std::string name) : KRContextObject(scene.getContext())
|
KRNode::KRNode(KRScene &scene, std::string name) : KRContextObject(scene.getContext())
|
||||||
{
|
{
|
||||||
@@ -403,6 +405,8 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
|
|||||||
new_node = new KRSpotLight(scene, szName);
|
new_node = new KRSpotLight(scene, szName);
|
||||||
} else if(strcmp(szElementName, "particles_newtonian") == 0) {
|
} else if(strcmp(szElementName, "particles_newtonian") == 0) {
|
||||||
new_node = new KRParticleSystemNewtonian(scene, szName);
|
new_node = new KRParticleSystemNewtonian(scene, szName);
|
||||||
|
} else if(strcmp(szElementName, "sprite") == 0) {
|
||||||
|
new_node = new KRSprite(scene, szName);
|
||||||
} else if(strcmp(szElementName, "model") == 0) {
|
} else if(strcmp(szElementName, "model") == 0) {
|
||||||
float lod_min_coverage = 0.0f;
|
float lod_min_coverage = 0.0f;
|
||||||
if(e->QueryFloatAttribute("lod_min_coverage", &lod_min_coverage) != tinyxml2::XML_SUCCESS) {
|
if(e->QueryFloatAttribute("lod_min_coverage", &lod_min_coverage) != tinyxml2::XML_SUCCESS) {
|
||||||
@@ -416,11 +420,19 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
|
|||||||
if(e->QueryBoolAttribute("faces_camera", &faces_camera) != tinyxml2::XML_SUCCESS) {
|
if(e->QueryBoolAttribute("faces_camera", &faces_camera) != tinyxml2::XML_SUCCESS) {
|
||||||
faces_camera = false;
|
faces_camera = false;
|
||||||
}
|
}
|
||||||
new_node = new KRModel(scene, szName, e->Attribute("mesh"), e->Attribute("light_map"), lod_min_coverage, receives_shadow, faces_camera);
|
float rim_power = 0.0f;
|
||||||
|
if(e->QueryFloatAttribute("rim_power", &rim_power) != tinyxml2::XML_SUCCESS) {
|
||||||
|
rim_power = 0.0f;
|
||||||
|
}
|
||||||
|
KRVector3 rim_color = KRVector3::Zero();
|
||||||
|
rim_color.getXMLAttribute("rim_color", e, KRVector3::Zero());
|
||||||
|
new_node = new KRModel(scene, szName, e->Attribute("mesh"), e->Attribute("light_map"), lod_min_coverage, receives_shadow, faces_camera, rim_color, rim_power);
|
||||||
} else if(strcmp(szElementName, "collider") == 0) {
|
} else if(strcmp(szElementName, "collider") == 0) {
|
||||||
new_node = new KRCollider(scene, szName, e->Attribute("mesh"), 65535, 1.0f);
|
new_node = new KRCollider(scene, szName, e->Attribute("mesh"), 65535, 1.0f);
|
||||||
} else if(strcmp(szElementName, "bone") == 0) {
|
} else if(strcmp(szElementName, "bone") == 0) {
|
||||||
new_node = new KRBone(scene, szName);
|
new_node = new KRBone(scene, szName);
|
||||||
|
} else if(strcmp(szElementName, "locator") == 0) {
|
||||||
|
new_node = new KRLocator(scene, szName);
|
||||||
} else if(strcmp(szElementName, "audio_source") == 0) {
|
} else if(strcmp(szElementName, "audio_source") == 0) {
|
||||||
new_node = new KRAudioSource(scene, szName);
|
new_node = new KRAudioSource(scene, szName);
|
||||||
} else if(strcmp(szElementName, "ambient_zone") == 0) {
|
} else if(strcmp(szElementName, "ambient_zone") == 0) {
|
||||||
@@ -447,6 +459,10 @@ const std::set<KRNode *> &KRNode::getChildren() {
|
|||||||
return m_childNodes;
|
return m_childNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KRNode *KRNode::getParent() {
|
||||||
|
return m_parentNode;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string &KRNode::getName() const {
|
const std::string &KRNode::getName() const {
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
@@ -910,4 +926,9 @@ void KRNode::addBehavior(KRBehavior *behavior)
|
|||||||
m_behaviors.insert(behavior);
|
m_behaviors.insert(behavior);
|
||||||
behavior->__setNode(this);
|
behavior->__setNode(this);
|
||||||
getScene().notify_sceneGraphModify(this);
|
getScene().notify_sceneGraphModify(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<KRBehavior *> &KRNode::getBehaviors()
|
||||||
|
{
|
||||||
|
return m_behaviors;
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public:
|
|||||||
|
|
||||||
void addChild(KRNode *child);
|
void addChild(KRNode *child);
|
||||||
const std::set<KRNode *> &getChildren();
|
const std::set<KRNode *> &getChildren();
|
||||||
|
KRNode *getParent();
|
||||||
|
|
||||||
void setLocalTranslation(const KRVector3 &v, bool set_original = false);
|
void setLocalTranslation(const KRVector3 &v, bool set_original = false);
|
||||||
void setLocalScale(const KRVector3 &v, bool set_original = false);
|
void setLocalScale(const KRVector3 &v, bool set_original = false);
|
||||||
@@ -226,6 +227,17 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void addBehavior(KRBehavior *behavior);
|
void addBehavior(KRBehavior *behavior);
|
||||||
|
std::set<KRBehavior *> &getBehaviors();
|
||||||
|
template <class T> T *getBehavior()
|
||||||
|
{
|
||||||
|
for(std::set<KRBehavior *>::iterator itr=m_behaviors.begin(); itr != m_behaviors.end(); itr++) {
|
||||||
|
T *behavior = dynamic_cast<T *>(*itr);
|
||||||
|
if(behavior) {
|
||||||
|
return behavior;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
void removeFromOctreeNodes();
|
void removeFromOctreeNodes();
|
||||||
void addToOctreeNode(KROctreeNode *octree_node);
|
void addToOctreeNode(KROctreeNode *octree_node);
|
||||||
void childDeleted(KRNode *child_node);
|
void childDeleted(KRNode *child_node);
|
||||||
|
|||||||
@@ -74,10 +74,13 @@ void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRPointLig
|
|||||||
|
|
||||||
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
KRVector3 rim_color;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
||||||
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
|
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
|
||||||
|
|
||||||
m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), particle_count * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false);
|
//m_pContext->getModelManager()->bindVBO((void *)m_pContext->getModelManager()->getRandomParticles(), particle_count * 3 * sizeof(KRMeshManager::RandomParticleVertexData), NULL, 0, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false);
|
||||||
|
KRDataBlock index_data;
|
||||||
|
m_pContext->getModelManager()->bindVBO(m_pContext->getModelManager()->getRandomParticles(), index_data, (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA), false);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
GLDEBUG(glDrawArrays(GL_TRIANGLES, 0, particle_count*3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ void KRPointLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
|
|||||||
bool bInsideLight = view_light_position.sqrMagnitude() <= (influence_radius + pCamera->settings.getPerspectiveNearZ()) * (influence_radius + pCamera->settings.getPerspectiveNearZ());
|
bool bInsideLight = view_light_position.sqrMagnitude() <= (influence_radius + pCamera->settings.getPerspectiveNearZ()) * (influence_radius + pCamera->settings.getPerspectiveNearZ());
|
||||||
|
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader(bVisualize ? "visualize_overlay" : (bInsideLight ? "light_point_inside" : "light_point"), pCamera, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = getContext().getShaderManager()->getShader(bVisualize ? "visualize_overlay" : (bInsideLight ? "light_point_inside" : "light_point"), pCamera, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
KRVector3 rim_color;
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, renderPass)) {
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, renderPass, rim_color, 0.0f)) {
|
||||||
|
|
||||||
|
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
||||||
@@ -96,7 +96,7 @@ void KRPointLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
|
|||||||
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
GLDEBUG(glDisable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
// Render a full screen quad
|
// Render a full screen quad
|
||||||
m_pContext->getModelManager()->bindVBO((void *)KRENGINE_VBO_2D_SQUARE, KRENGINE_VBO_2D_SQUARE_SIZE, NULL, 0, KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
} else {
|
} else {
|
||||||
#if GL_OES_vertex_array_object
|
#if GL_OES_vertex_array_object
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "KREngine-common.h"
|
#include "KREngine-common.h"
|
||||||
#include <boost/tokenizer.hpp>
|
#include <boost/tokenizer.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include <boost/variant.hpp>
|
||||||
#include <fbxsdk.h>
|
#include <fbxsdk.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
#include "KRScene.h"
|
#include "KRScene.h"
|
||||||
#include "KRQuaternion.h"
|
#include "KRQuaternion.h"
|
||||||
#include "KRBone.h"
|
#include "KRBone.h"
|
||||||
|
#include "KRLocator.h"
|
||||||
#include "KRBundle.h"
|
#include "KRBundle.h"
|
||||||
#include "KRModel.h"
|
#include "KRModel.h"
|
||||||
#include "KRLODGroup.h"
|
#include "KRLODGroup.h"
|
||||||
@@ -33,20 +35,21 @@
|
|||||||
#define IOS_REF (*(pSdkManager->GetIOSettings()))
|
#define IOS_REF (*(pSdkManager->GetIOSettings()))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void InitializeSdkObjects(KFbxSdkManager*& pSdkManager, KFbxScene*& pScene);
|
void InitializeSdkObjects(FbxManager*& pSdkManager, FbxScene*& pScene);
|
||||||
void DestroySdkObjects(KFbxSdkManager* pSdkManager);
|
void DestroySdkObjects(FbxManager* pSdkManager);
|
||||||
bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename);
|
bool LoadScene(FbxManager* pSdkManager, FbxDocument* pScene, const char* pFilename);
|
||||||
KRAnimation *LoadAnimation(KRContext &context, FbxAnimStack* pAnimStack);
|
KRAnimation *LoadAnimation(KRContext &context, FbxAnimStack* pAnimStack);
|
||||||
KRAnimationCurve *LoadAnimationCurve(KRContext &context, FbxAnimCurve* pAnimCurve);
|
KRAnimationCurve *LoadAnimationCurve(KRContext &context, FbxAnimCurve* pAnimCurve);
|
||||||
KRAnimationLayer *LoadAnimationLayer(KRContext &context, FbxAnimLayer *pAnimLayer);
|
KRAnimationLayer *LoadAnimationLayer(KRContext &context, FbxAnimLayer *pAnimLayer);
|
||||||
void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
void LoadNode(FbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *pGeometryConverter, FbxNode* pNode);
|
||||||
//void BakeNode(KFbxNode* pNode);
|
//void BakeNode(KFbxNode* pNode);
|
||||||
void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial);
|
void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial);
|
||||||
void LoadMesh(KRContext &context, KFbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, KFbxMesh* pSourceMesh);
|
void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxMesh* pSourceMesh);
|
||||||
KRNode *LoadMesh(KRNode *parent_node, KFbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
KRNode *LoadMesh(KRNode *parent_node, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxNode* pNode);
|
||||||
KRNode *LoadLight(KRNode *parent_node, KFbxNode* pNode);
|
KRNode *LoadLight(KRNode *parent_node, FbxNode* pNode);
|
||||||
KRNode *LoadSkeleton(KRNode *parent_node, FbxScene* pScene, KFbxNode* pNode);
|
KRNode *LoadSkeleton(KRNode *parent_node, FbxScene* pScene, FbxNode* pNode);
|
||||||
KRNode *LoadCamera(KRNode *parent_node, KFbxNode* pNode);
|
KRNode *LoadLocator(KRNode *parent_node, FbxScene* pScene, FbxNode* pNode);
|
||||||
|
KRNode *LoadCamera(KRNode *parent_node, FbxNode* pNode);
|
||||||
std::string GetFbxObjectName(FbxObject *obj);
|
std::string GetFbxObjectName(FbxObject *obj);
|
||||||
|
|
||||||
const float KRAKEN_FBX_ANIMATION_FRAMERATE = 30.0f; // FINDME - This should be configurable
|
const float KRAKEN_FBX_ANIMATION_FRAMERATE = 30.0f; // FINDME - This should be configurable
|
||||||
@@ -54,9 +57,28 @@ const float KRAKEN_FBX_ANIMATION_FRAMERATE = 30.0f; // FINDME - This should be c
|
|||||||
|
|
||||||
std::string GetFbxObjectName(FbxObject *obj)
|
std::string GetFbxObjectName(FbxObject *obj)
|
||||||
{
|
{
|
||||||
|
bool is_locator = false;
|
||||||
|
FbxNode *node = FbxCast<FbxNode>(obj);
|
||||||
|
if(node) {
|
||||||
|
FbxNodeAttribute::EType attribute_type = (node->GetNodeAttribute()->GetAttributeType());
|
||||||
|
if(attribute_type == FbxNodeAttribute::eNull) {
|
||||||
|
FbxNull* pSourceNull = (FbxNull*) node->GetNodeAttribute();
|
||||||
|
if(pSourceNull->Look.Get() == FbxNull::eCross ) {
|
||||||
|
is_locator = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Object names from FBX files are now concatenated with the FBX numerical ID to ensure that they are unique
|
// Object names from FBX files are now concatenated with the FBX numerical ID to ensure that they are unique
|
||||||
// TODO - This should be updated to only add a prefix or suffix if needed to make the name unique
|
// TODO - This should be updated to only add a prefix or suffix if needed to make the name unique
|
||||||
if(strcmp(obj->GetName(), "default_camera") == 0) {
|
if(is_locator) {
|
||||||
|
// We do not rename locators
|
||||||
|
return std::string(obj->GetName());
|
||||||
|
} else if(strncmp(obj->GetName(), "so_", 3) == 0) {
|
||||||
|
// An so_ prefix indicates that this is a "Scriptable Object" that should not have the name decorated;
|
||||||
|
return obj->GetName();
|
||||||
|
} else if(strcmp(obj->GetName(), "default_camera") == 0) {
|
||||||
// There is currently support for rendering from only one camera, "default_camera". We don't translate this node's name, so that animations can drive the camera
|
// There is currently support for rendering from only one camera, "default_camera". We don't translate this node's name, so that animations can drive the camera
|
||||||
return "default_camera";
|
return "default_camera";
|
||||||
} else {
|
} else {
|
||||||
@@ -76,8 +98,8 @@ void KRResource::LoadFbx(KRContext &context, const std::string& path)
|
|||||||
KRScene *pScene = new KRScene(context, KRResource::GetFileBase(path));
|
KRScene *pScene = new KRScene(context, KRResource::GetFileBase(path));
|
||||||
context.getSceneManager()->add(pScene);
|
context.getSceneManager()->add(pScene);
|
||||||
|
|
||||||
KFbxSdkManager* lSdkManager = NULL;
|
FbxManager* lSdkManager = NULL;
|
||||||
KFbxScene* pFbxScene = NULL;
|
FbxScene* pFbxScene = NULL;
|
||||||
bool lResult;
|
bool lResult;
|
||||||
FbxGeometryConverter *pGeometryConverter = NULL;
|
FbxGeometryConverter *pGeometryConverter = NULL;
|
||||||
|
|
||||||
@@ -90,7 +112,7 @@ void KRResource::LoadFbx(KRContext &context, const std::string& path)
|
|||||||
// Load the scene.
|
// Load the scene.
|
||||||
lResult = LoadScene(lSdkManager, pFbxScene, path.c_str());
|
lResult = LoadScene(lSdkManager, pFbxScene, path.c_str());
|
||||||
|
|
||||||
KFbxNode* pNode = pFbxScene->GetRootNode();
|
FbxNode* pNode = pFbxScene->GetRootNode();
|
||||||
|
|
||||||
// ----====---- Bake pivots into transforms, as Kraken doesn't support them directly ----====----
|
// ----====---- Bake pivots into transforms, as Kraken doesn't support them directly ----====----
|
||||||
/*
|
/*
|
||||||
@@ -120,7 +142,9 @@ void KRResource::LoadFbx(KRContext &context, const std::string& path)
|
|||||||
FbxAnimCurve *curve = pFbxScene->GetSrcObject<FbxAnimCurve>(i);
|
FbxAnimCurve *curve = pFbxScene->GetSrcObject<FbxAnimCurve>(i);
|
||||||
printf(" Animation Curve %i of %i: %s\n", i+1, curve_count, curve->GetName());
|
printf(" Animation Curve %i of %i: %s\n", i+1, curve_count, curve->GetName());
|
||||||
KRAnimationCurve *new_curve = LoadAnimationCurve(context, curve);
|
KRAnimationCurve *new_curve = LoadAnimationCurve(context, curve);
|
||||||
|
|
||||||
if(new_curve) {
|
if(new_curve) {
|
||||||
|
printf("Adding a curve\n");
|
||||||
context.getAnimationCurveManager()->addAnimationCurve(new_curve);
|
context.getAnimationCurveManager()->addAnimationCurve(new_curve);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,11 +195,11 @@ void KRResource::LoadFbx(KRContext &context, const std::string& path)
|
|||||||
DestroySdkObjects(lSdkManager);
|
DestroySdkObjects(lSdkManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeSdkObjects(KFbxSdkManager*& pSdkManager, KFbxScene*& pScene)
|
void InitializeSdkObjects(FbxManager*& pSdkManager, FbxScene*& pScene)
|
||||||
{
|
{
|
||||||
// The first thing to do is to create the FBX SDK manager which is the
|
// The first thing to do is to create the FBX SDK manager which is the
|
||||||
// object allocator for almost all the classes in the SDK.
|
// object allocator for almost all the classes in the SDK.
|
||||||
pSdkManager = KFbxSdkManager::Create();
|
pSdkManager = FbxManager::Create();
|
||||||
|
|
||||||
if (!pSdkManager)
|
if (!pSdkManager)
|
||||||
{
|
{
|
||||||
@@ -184,25 +208,27 @@ void InitializeSdkObjects(KFbxSdkManager*& pSdkManager, KFbxScene*& pScene)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create an IOSettings object
|
// create an IOSettings object
|
||||||
KFbxIOSettings * ios = KFbxIOSettings::Create(pSdkManager, IOSROOT );
|
FbxIOSettings * ios = FbxIOSettings::Create(pSdkManager, IOSROOT );
|
||||||
pSdkManager->SetIOSettings(ios);
|
pSdkManager->SetIOSettings(ios);
|
||||||
|
|
||||||
// Load plugins from the executable directory
|
// Load plugins from the executable directory
|
||||||
KString lPath = FbxGetApplicationDirectory();
|
FbxString lPath = FbxGetApplicationDirectory();
|
||||||
#if defined(KARCH_ENV_WIN)
|
#if TARGET_OS_WIN32
|
||||||
KString lExtension = "dll";
|
FbxString lExtension = "dll";
|
||||||
#elif defined(KARCH_ENV_MACOSX)
|
#elif TARGET_OS_MAC
|
||||||
KString lExtension = "dylib";
|
FbxString lExtension = "dylib";
|
||||||
#elif defined(KARCH_ENV_LINUX)
|
#elif TARGET_OS_UNIX
|
||||||
KString lExtension = "so";
|
FbxString lExtension = "so";
|
||||||
|
#elif
|
||||||
|
#error Unsupported Platform
|
||||||
#endif
|
#endif
|
||||||
pSdkManager->LoadPluginsDirectory(lPath.Buffer(), lExtension.Buffer());
|
pSdkManager->LoadPluginsDirectory(lPath.Buffer(), lExtension.Buffer());
|
||||||
|
|
||||||
// Create the entity that will hold the scene.
|
// Create the entity that will hold the scene.
|
||||||
pScene = KFbxScene::Create(pSdkManager,"");
|
pScene = FbxScene::Create(pSdkManager,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroySdkObjects(KFbxSdkManager* pSdkManager)
|
void DestroySdkObjects(FbxManager* pSdkManager)
|
||||||
{
|
{
|
||||||
// Delete the FBX SDK manager. All the objects that have been allocated
|
// Delete the FBX SDK manager. All the objects that have been allocated
|
||||||
// using the FBX SDK manager and that haven't been explicitly destroyed
|
// using the FBX SDK manager and that haven't been explicitly destroyed
|
||||||
@@ -212,7 +238,7 @@ void DestroySdkObjects(KFbxSdkManager* pSdkManager)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename)
|
bool LoadScene(FbxManager* pSdkManager, FbxDocument* pScene, const char* pFilename)
|
||||||
{
|
{
|
||||||
int lFileMajor, lFileMinor, lFileRevision;
|
int lFileMajor, lFileMinor, lFileRevision;
|
||||||
int lSDKMajor, lSDKMinor, lSDKRevision;
|
int lSDKMajor, lSDKMinor, lSDKRevision;
|
||||||
@@ -222,10 +248,10 @@ bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pF
|
|||||||
char lPassword[1024];
|
char lPassword[1024];
|
||||||
|
|
||||||
// Get the file version number generate by the FBX SDK.
|
// Get the file version number generate by the FBX SDK.
|
||||||
KFbxSdkManager::GetFileFormatVersion(lSDKMajor, lSDKMinor, lSDKRevision);
|
FbxManager::GetFileFormatVersion(lSDKMajor, lSDKMinor, lSDKRevision);
|
||||||
|
|
||||||
// Create an importer.
|
// Create an importer.
|
||||||
KFbxImporter* lImporter = KFbxImporter::Create(pSdkManager,"");
|
FbxImporter* lImporter = FbxImporter::Create(pSdkManager,"");
|
||||||
|
|
||||||
// Initialize the importer by providing a filename.
|
// Initialize the importer by providing a filename.
|
||||||
const bool lImportStatus = lImporter->Initialize(pFilename, -1, pSdkManager->GetIOSettings());
|
const bool lImportStatus = lImporter->Initialize(pFilename, -1, pSdkManager->GetIOSettings());
|
||||||
@@ -233,11 +259,14 @@ bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pF
|
|||||||
|
|
||||||
if( !lImportStatus )
|
if( !lImportStatus )
|
||||||
{
|
{
|
||||||
printf("Call to KFbxImporter::Initialize() failed.\n");
|
FbxStatus &status = lImporter->GetStatus();
|
||||||
printf("Error returned: %s\n\n", lImporter->GetLastErrorString());
|
|
||||||
|
|
||||||
if (lImporter->GetLastErrorID() == FbxIOBase::eFileVersionNotSupportedYet ||
|
printf("Call to KFbxImporter::Initialize() failed.\n");
|
||||||
lImporter->GetLastErrorID() == FbxIOBase::eFileVersionNotSupportedAnymore)
|
printf("Error returned: %s\n\n", status.GetErrorString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (status.GetCode() == FbxStatus::EStatusCode::eInvalidFileVersion)
|
||||||
{
|
{
|
||||||
printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision);
|
printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision);
|
||||||
printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision);
|
printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision);
|
||||||
@@ -281,21 +310,21 @@ bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pF
|
|||||||
// Import the scene.
|
// Import the scene.
|
||||||
lStatus = lImporter->Import(pScene);
|
lStatus = lImporter->Import(pScene);
|
||||||
|
|
||||||
if(lStatus == false && lImporter->GetLastErrorID() == FbxIOBase::ePasswordError)
|
if(lStatus == false && lImporter->GetStatus().GetCode() == FbxStatus::EStatusCode::ePasswordError)
|
||||||
{
|
{
|
||||||
printf("Please enter password: ");
|
printf("Please enter password: ");
|
||||||
|
|
||||||
lPassword[0] = '\0';
|
lPassword[0] = '\0';
|
||||||
|
|
||||||
scanf("%s", lPassword);
|
scanf("%s", lPassword);
|
||||||
KString lString(lPassword);
|
FbxString lString(lPassword);
|
||||||
|
|
||||||
IOS_REF.SetStringProp(IMP_FBX_PASSWORD, lString);
|
IOS_REF.SetStringProp(IMP_FBX_PASSWORD, lString);
|
||||||
IOS_REF.SetBoolProp(IMP_FBX_PASSWORD_ENABLE, true);
|
IOS_REF.SetBoolProp(IMP_FBX_PASSWORD_ENABLE, true);
|
||||||
|
|
||||||
lStatus = lImporter->Import(pScene);
|
lStatus = lImporter->Import(pScene);
|
||||||
|
|
||||||
if(lStatus == false && lImporter->GetLastErrorID() == FbxIOBase::ePasswordError)
|
if(lStatus == false && lImporter->GetStatus().GetCode() == FbxStatus::EStatusCode::ePasswordError)
|
||||||
{
|
{
|
||||||
printf("\nPassword is wrong, import aborted.\n");
|
printf("\nPassword is wrong, import aborted.\n");
|
||||||
}
|
}
|
||||||
@@ -543,8 +572,8 @@ KRAnimationLayer *LoadAnimationLayer(KRContext &context, FbxAnimLayer *pAnimLaye
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
void LoadNode(FbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *pGeometryConverter, FbxNode* pNode) {
|
||||||
KFbxVector4 lTmpVector;
|
FbxVector4 lTmpVector;
|
||||||
pNode->UpdatePropertiesFromPivotsAndLimits();
|
pNode->UpdatePropertiesFromPivotsAndLimits();
|
||||||
|
|
||||||
|
|
||||||
@@ -813,27 +842,27 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fbxDouble3 local_rotation = pNode->LclRotation.Get(); // pNode->GetGeometricRotation(KFbxNode::eSourcePivot);
|
FbxDouble3 local_rotation = pNode->LclRotation.Get(); // pNode->GetGeometricRotation(KFbxNode::eSourcePivot);
|
||||||
fbxDouble3 local_translation = pNode->LclTranslation.Get(); // pNode->GetGeometricTranslation(KFbxNode::eSourcePivot);
|
FbxDouble3 local_translation = pNode->LclTranslation.Get(); // pNode->GetGeometricTranslation(KFbxNode::eSourcePivot);
|
||||||
fbxDouble3 local_scale = pNode->LclScaling.Get(); // pNode->GetGeometricScaling(KFbxNode::eSourcePivot);
|
FbxDouble3 local_scale = pNode->LclScaling.Get(); // pNode->GetGeometricScaling(KFbxNode::eSourcePivot);
|
||||||
|
|
||||||
bool rotation_active = pNode->RotationActive.Get();
|
bool rotation_active = pNode->RotationActive.Get();
|
||||||
|
|
||||||
fbxDouble3 post_rotation = pNode->PostRotation.Get();
|
FbxDouble3 post_rotation = pNode->PostRotation.Get();
|
||||||
fbxDouble3 pre_rotation = pNode->PreRotation.Get();
|
FbxDouble3 pre_rotation = pNode->PreRotation.Get();
|
||||||
fbxDouble3 rotation_offset = pNode->RotationOffset.Get();
|
FbxDouble3 rotation_offset = pNode->RotationOffset.Get();
|
||||||
fbxDouble3 scaling_offset = pNode->ScalingOffset.Get();
|
FbxDouble3 scaling_offset = pNode->ScalingOffset.Get();
|
||||||
fbxDouble3 rotation_pivot = pNode->RotationPivot.Get();
|
FbxDouble3 rotation_pivot = pNode->RotationPivot.Get();
|
||||||
fbxDouble3 scaling_pivot = pNode->ScalingPivot.Get();
|
FbxDouble3 scaling_pivot = pNode->ScalingPivot.Get();
|
||||||
fbxDouble3 geometric_rotation = pNode->GeometricRotation.Get();
|
FbxDouble3 geometric_rotation = pNode->GeometricRotation.Get();
|
||||||
fbxDouble3 geometric_translation = pNode->GeometricTranslation.Get();
|
FbxDouble3 geometric_translation = pNode->GeometricTranslation.Get();
|
||||||
fbxDouble3 geometric_scaling = pNode->GeometricScaling.Get();
|
FbxDouble3 geometric_scaling = pNode->GeometricScaling.Get();
|
||||||
ERotationOrder rotation_order = pNode->RotationOrder.Get();
|
EFbxRotationOrder rotation_order = pNode->RotationOrder.Get();
|
||||||
|
|
||||||
|
|
||||||
KFbxVector4 lZero(0.0, 0.0, 0.0);
|
FbxVector4 lZero(0.0, 0.0, 0.0);
|
||||||
KFbxVector4 lOne(1.0, 1.0, 1.0);
|
FbxVector4 lOne(1.0, 1.0, 1.0);
|
||||||
|
|
||||||
assert(geometric_rotation == lZero);
|
assert(geometric_rotation == lZero);
|
||||||
assert(geometric_translation == lZero);
|
assert(geometric_translation == lZero);
|
||||||
@@ -861,8 +890,8 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *p
|
|||||||
// printf(" Local Rotation: %f %f %f\n", local_rotation[0], local_rotation[1], local_rotation[2]);
|
// printf(" Local Rotation: %f %f %f\n", local_rotation[0], local_rotation[1], local_rotation[2]);
|
||||||
// printf(" Local Scaling: %f %f %f\n", local_scale[0], local_scale[1], local_scale[2]);
|
// printf(" Local Scaling: %f %f %f\n", local_scale[0], local_scale[1], local_scale[2]);
|
||||||
|
|
||||||
KFbxNodeAttribute::EType attribute_type = (pNode->GetNodeAttribute()->GetAttributeType());
|
FbxNodeAttribute::EType attribute_type = (pNode->GetNodeAttribute()->GetAttributeType());
|
||||||
if(attribute_type == KFbxNodeAttribute::eLODGroup) {
|
if(attribute_type == FbxNodeAttribute::eLODGroup) {
|
||||||
std::string name = GetFbxObjectName(pNode);
|
std::string name = GetFbxObjectName(pNode);
|
||||||
FbxLODGroup *fbx_lod_group = (FbxLODGroup*) pNode->GetNodeAttribute(); // FbxCast<FbxLODGroup>(pNode);
|
FbxLODGroup *fbx_lod_group = (FbxLODGroup*) pNode->GetNodeAttribute(); // FbxCast<FbxLODGroup>(pNode);
|
||||||
bool use_world_space_units = fbx_lod_group->WorldSpace.Get();
|
bool use_world_space_units = fbx_lod_group->WorldSpace.Get();
|
||||||
@@ -946,69 +975,55 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *p
|
|||||||
} else {
|
} else {
|
||||||
KRNode *new_node = NULL;
|
KRNode *new_node = NULL;
|
||||||
switch(attribute_type) {
|
switch(attribute_type) {
|
||||||
case KFbxNodeAttribute::eMesh:
|
case FbxNodeAttribute::eMesh:
|
||||||
new_node = LoadMesh(parent_node, pFbxScene, pGeometryConverter, pNode);
|
new_node = LoadMesh(parent_node, pFbxScene, pGeometryConverter, pNode);
|
||||||
break;
|
break;
|
||||||
case KFbxNodeAttribute::eLight:
|
case FbxNodeAttribute::eLight:
|
||||||
new_node = LoadLight(parent_node, pNode);
|
new_node = LoadLight(parent_node, pNode);
|
||||||
break;
|
break;
|
||||||
case KFbxNodeAttribute::eSkeleton:
|
case FbxNodeAttribute::eSkeleton:
|
||||||
new_node = LoadSkeleton(parent_node, pFbxScene, pNode);
|
new_node = LoadSkeleton(parent_node, pFbxScene, pNode);
|
||||||
break;
|
break;
|
||||||
case KFbxNodeAttribute::eCamera:
|
|
||||||
|
case FbxNodeAttribute::eCamera:
|
||||||
new_node = LoadCamera(parent_node, pNode);
|
new_node = LoadCamera(parent_node, pNode);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if(pNode->GetChildCount() > 0) {
|
bool is_locator = false;
|
||||||
// Create an empty node, for inheritence of transforms
|
if(attribute_type == FbxNodeAttribute::eNull) {
|
||||||
std::string name = GetFbxObjectName(pNode);
|
FbxNull* pSourceNull = (FbxNull*) pNode->GetNodeAttribute();
|
||||||
|
if(pSourceNull->Look.Get() == FbxNull::eCross ) {
|
||||||
float min_distance = 0.0f;
|
is_locator = true;
|
||||||
float max_distance = 0.0f;
|
|
||||||
|
|
||||||
typedef boost::tokenizer<boost::char_separator<char> > char_tokenizer;
|
|
||||||
|
|
||||||
int step = 0;
|
|
||||||
|
|
||||||
char_tokenizer name_components(name, boost::char_separator<char>("_"));
|
|
||||||
for(char_tokenizer::iterator itr=name_components.begin(); itr != name_components.end(); itr++) {
|
|
||||||
std::string component = *itr;
|
|
||||||
std::transform(component.begin(), component.end(),
|
|
||||||
component.begin(), ::tolower);
|
|
||||||
if(component.compare("lod") == 0) {
|
|
||||||
step = 1;
|
|
||||||
} else if(step == 1) {
|
|
||||||
min_distance = boost::lexical_cast<float>(component);
|
|
||||||
step++;
|
|
||||||
} else if(step == 2) {
|
|
||||||
max_distance = boost::lexical_cast<float>(component);
|
|
||||||
step++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/*
|
|
||||||
if(min_distance == 0.0f && max_distance == 0.0f) {
|
if(is_locator) {
|
||||||
// Regular node for grouping children together under one transform
|
new_node = LoadLocator(parent_node, pFbxScene, pNode);
|
||||||
new_node = new KRNode(parent_node->getScene(), name);
|
} else {
|
||||||
} else {
|
if(pNode->GetChildCount() > 0) {
|
||||||
*/
|
// Create an empty node, for inheritence of transforms
|
||||||
// LOD Enabled group node
|
std::string name = GetFbxObjectName(pNode);
|
||||||
KRLODGroup *lod_group = new KRLODGroup(parent_node->getScene(), name);
|
|
||||||
lod_group->setMinDistance(min_distance);
|
|
||||||
lod_group->setMaxDistance(max_distance);
|
/*
|
||||||
new_node = lod_group;
|
if(min_distance == 0.0f && max_distance == 0.0f) {
|
||||||
/*
|
// Regular node for grouping children together under one transform
|
||||||
|
new_node = new KRNode(parent_node->getScene(), name);
|
||||||
|
} else {
|
||||||
|
*/
|
||||||
|
// LOD Enabled group node
|
||||||
|
KRLODGroup *lod_group = new KRLODGroup(parent_node->getScene(), name);
|
||||||
|
lod_group->setMinDistance(0.0f);
|
||||||
|
lod_group->setMaxDistance(0.0f);
|
||||||
|
new_node = lod_group;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this is a KRNode
|
||||||
if(new_node != NULL) {
|
if(new_node != NULL) {
|
||||||
new_node->setLocalRotation(node_rotation);
|
new_node->setLocalRotation(node_rotation);
|
||||||
new_node->setLocalTranslation(node_translation);
|
new_node->setLocalTranslation(node_translation);
|
||||||
@@ -1020,7 +1035,7 @@ void LoadNode(KFbxScene* pFbxScene, KRNode *parent_node, FbxGeometryConverter *p
|
|||||||
new_node->setPreRotation(node_pre_rotation);
|
new_node->setPreRotation(node_pre_rotation);
|
||||||
new_node->setPostRotation(node_post_rotation);
|
new_node->setPostRotation(node_post_rotation);
|
||||||
parent_node->addChild(new_node);
|
parent_node->addChild(new_node);
|
||||||
|
|
||||||
// Load child nodes
|
// Load child nodes
|
||||||
for(int i = 0; i < pNode->GetChildCount(); i++)
|
for(int i = 0; i < pNode->GetChildCount(); i++)
|
||||||
{
|
{
|
||||||
@@ -1055,7 +1070,7 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
FbxPropertyT<FbxDouble3> lKFbxDouble3;
|
FbxPropertyT<FbxDouble3> lKFbxDouble3;
|
||||||
FbxPropertyT<FbxDouble> lKFbxDouble1;
|
FbxPropertyT<FbxDouble> lKFbxDouble1;
|
||||||
|
|
||||||
if (pMaterial->GetClassId().Is(KFbxSurfacePhong::ClassId)) {
|
if (pMaterial->GetClassId().Is(FbxSurfacePhong::ClassId)) {
|
||||||
// We found a Phong material.
|
// We found a Phong material.
|
||||||
|
|
||||||
// Ambient Color
|
// Ambient Color
|
||||||
@@ -1063,11 +1078,11 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
new_material->setAmbient(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
new_material->setAmbient(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
||||||
|
|
||||||
// Diffuse Color
|
// Diffuse Color
|
||||||
lKFbxDouble3 =((KFbxSurfacePhong *) pMaterial)->Diffuse;
|
lKFbxDouble3 =((FbxSurfacePhong *) pMaterial)->Diffuse;
|
||||||
new_material->setDiffuse(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
new_material->setDiffuse(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
||||||
|
|
||||||
// Specular Color (unique to Phong materials)
|
// Specular Color (unique to Phong materials)
|
||||||
lKFbxDouble3 =((KFbxSurfacePhong *) pMaterial)->Specular;
|
lKFbxDouble3 =((FbxSurfacePhong *) pMaterial)->Specular;
|
||||||
new_material->setSpecular(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
new_material->setSpecular(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
||||||
|
|
||||||
// Emissive Color
|
// Emissive Color
|
||||||
@@ -1080,7 +1095,7 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Shininess
|
// Shininess
|
||||||
lKFbxDouble1 =((KFbxSurfacePhong *) pMaterial)->Shininess;
|
lKFbxDouble1 =((FbxSurfacePhong *) pMaterial)->Shininess;
|
||||||
new_material->setShininess(lKFbxDouble1.Get());
|
new_material->setShininess(lKFbxDouble1.Get());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1090,27 +1105,27 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Transparency Color
|
// Transparency Color
|
||||||
lKFbxDouble3 =((KFbxSurfacePhong *) pMaterial)->TransparentColor;
|
lKFbxDouble3 =((FbxSurfacePhong *) pMaterial)->TransparentColor;
|
||||||
new_material->setTransparency( 1.0f - (lKFbxDouble3.Get()[0] + lKFbxDouble3.Get()[1] + lKFbxDouble3.Get()[2]) / 3.0f);
|
new_material->setTransparency( 1.0f - (lKFbxDouble3.Get()[0] + lKFbxDouble3.Get()[1] + lKFbxDouble3.Get()[2]) / 3.0f);
|
||||||
|
|
||||||
// Reflection factor
|
// Reflection factor
|
||||||
lKFbxDouble1 =((KFbxSurfacePhong *) pMaterial)->ReflectionFactor;
|
lKFbxDouble1 =((FbxSurfacePhong *) pMaterial)->ReflectionFactor;
|
||||||
|
|
||||||
// Reflection color
|
// Reflection color
|
||||||
lKFbxDouble3 =((KFbxSurfacePhong *) pMaterial)->Reflection;
|
lKFbxDouble3 =((FbxSurfacePhong *) pMaterial)->Reflection;
|
||||||
|
|
||||||
// We modulate Relection color by reflection factor, as we only have one "reflection color" variable in Kraken
|
// We modulate Relection color by reflection factor, as we only have one "reflection color" variable in Kraken
|
||||||
new_material->setReflection(KRVector3(lKFbxDouble3.Get()[0] * lKFbxDouble1.Get(), lKFbxDouble3.Get()[1] * lKFbxDouble1.Get(), lKFbxDouble3.Get()[2] * lKFbxDouble1.Get()));
|
new_material->setReflection(KRVector3(lKFbxDouble3.Get()[0] * lKFbxDouble1.Get(), lKFbxDouble3.Get()[1] * lKFbxDouble1.Get(), lKFbxDouble3.Get()[2] * lKFbxDouble1.Get()));
|
||||||
|
|
||||||
} else if(pMaterial->GetClassId().Is(KFbxSurfaceLambert::ClassId) ) {
|
} else if(pMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId) ) {
|
||||||
// We found a Lambert material.
|
// We found a Lambert material.
|
||||||
|
|
||||||
// Ambient Color
|
// Ambient Color
|
||||||
lKFbxDouble3=((KFbxSurfaceLambert *)pMaterial)->Ambient;
|
lKFbxDouble3=((FbxSurfaceLambert *)pMaterial)->Ambient;
|
||||||
new_material->setAmbient(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
new_material->setAmbient(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
||||||
|
|
||||||
// Diffuse Color
|
// Diffuse Color
|
||||||
lKFbxDouble3 =((KFbxSurfaceLambert *)pMaterial)->Diffuse;
|
lKFbxDouble3 =((FbxSurfaceLambert *)pMaterial)->Diffuse;
|
||||||
new_material->setDiffuse(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
new_material->setDiffuse(KRVector3(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2]));
|
||||||
|
|
||||||
// Emissive
|
// Emissive
|
||||||
@@ -1122,7 +1137,7 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Transparency Color
|
// Transparency Color
|
||||||
lKFbxDouble3 =((KFbxSurfaceLambert *) pMaterial)->TransparentColor;
|
lKFbxDouble3 =((FbxSurfaceLambert *) pMaterial)->TransparentColor;
|
||||||
new_material->setTransparency(1.0f - (lKFbxDouble3.Get()[0] + lKFbxDouble3.Get()[1] + lKFbxDouble3.Get()[2]) / 3.0f);
|
new_material->setTransparency(1.0f - (lKFbxDouble3.Get()[0] + lKFbxDouble3.Get()[1] + lKFbxDouble3.Get()[2]) / 3.0f);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -1131,31 +1146,31 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
KFbxProperty pProperty;
|
FbxProperty pProperty;
|
||||||
|
|
||||||
// Diffuse Map Texture
|
// Diffuse Map Texture
|
||||||
pProperty = pMaterial->FindProperty(KFbxSurfaceMaterial::sDiffuse);
|
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sDiffuse);
|
||||||
if(pProperty.GetSrcObjectCount(KFbxLayeredTexture::ClassId) > 0) {
|
if(pProperty.GetSrcObjectCount(FbxLayeredTexture::ClassId) > 0) {
|
||||||
printf("Warning! Layered textures not supported.\n");
|
printf("Warning! Layered textures not supported.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int texture_count = pProperty.GetSrcObjectCount(KFbxTexture::ClassId);
|
int texture_count = pProperty.GetSrcObjectCount(FbxTexture::ClassId);
|
||||||
if(texture_count > 1) {
|
if(texture_count > 1) {
|
||||||
printf("Error! Multiple diffuse textures not supported.\n");
|
printf("Error! Multiple diffuse textures not supported.\n");
|
||||||
} else if(texture_count == 1) {
|
} else if(texture_count == 1) {
|
||||||
KFbxTexture* pTexture = FbxCast <KFbxTexture> (pProperty.GetSrcObject(KFbxTexture::ClassId,0));
|
FbxTexture* pTexture = FbxCast <FbxTexture> (pProperty.GetSrcObject(FbxTexture::ClassId,0));
|
||||||
assert(!pTexture->GetSwapUV());
|
assert(!pTexture->GetSwapUV());
|
||||||
assert(pTexture->GetCroppingTop() == 0);
|
assert(pTexture->GetCroppingTop() == 0);
|
||||||
assert(pTexture->GetCroppingLeft() == 0);
|
assert(pTexture->GetCroppingLeft() == 0);
|
||||||
assert(pTexture->GetCroppingRight() == 0);
|
assert(pTexture->GetCroppingRight() == 0);
|
||||||
assert(pTexture->GetCroppingBottom() == 0);
|
assert(pTexture->GetCroppingBottom() == 0);
|
||||||
assert(pTexture->GetWrapModeU() == KFbxTexture::eRepeat);
|
assert(pTexture->GetWrapModeU() == FbxTexture::eRepeat);
|
||||||
assert(pTexture->GetWrapModeV() == KFbxTexture::eRepeat);
|
assert(pTexture->GetWrapModeV() == FbxTexture::eRepeat);
|
||||||
assert(pTexture->GetRotationU() == 0.0f);
|
assert(pTexture->GetRotationU() == 0.0f);
|
||||||
assert(pTexture->GetRotationV() == 0.0f);
|
assert(pTexture->GetRotationV() == 0.0f);
|
||||||
assert(pTexture->GetRotationW() == 0.0f);
|
assert(pTexture->GetRotationW() == 0.0f);
|
||||||
|
|
||||||
KFbxFileTexture *pFileTexture = FbxCast<KFbxFileTexture>(pTexture);
|
FbxFileTexture *pFileTexture = FbxCast<FbxFileTexture>(pTexture);
|
||||||
if(pFileTexture) {
|
if(pFileTexture) {
|
||||||
new_material->setDiffuseMap(KRResource::GetFileBase(pFileTexture->GetFileName()), KRVector2(pTexture->GetScaleU(), pTexture->GetScaleV()), KRVector2(pTexture->GetTranslationU(), pTexture->GetTranslationV()));
|
new_material->setDiffuseMap(KRResource::GetFileBase(pFileTexture->GetFileName()), KRVector2(pTexture->GetScaleU(), pTexture->GetScaleV()), KRVector2(pTexture->GetTranslationU(), pTexture->GetTranslationV()));
|
||||||
}
|
}
|
||||||
@@ -1163,24 +1178,24 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
|
|
||||||
|
|
||||||
// Specular Map Texture
|
// Specular Map Texture
|
||||||
pProperty = pMaterial->FindProperty(KFbxSurfaceMaterial::sSpecular);
|
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sSpecular);
|
||||||
if(pProperty.GetSrcObjectCount(KFbxLayeredTexture::ClassId) > 0) {
|
if(pProperty.GetSrcObjectCount(FbxLayeredTexture::ClassId) > 0) {
|
||||||
printf("Warning! Layered textures not supported.\n");
|
printf("Warning! Layered textures not supported.\n");
|
||||||
}
|
}
|
||||||
texture_count = pProperty.GetSrcObjectCount(KFbxTexture::ClassId);
|
texture_count = pProperty.GetSrcObjectCount(FbxTexture::ClassId);
|
||||||
if(texture_count > 1) {
|
if(texture_count > 1) {
|
||||||
printf("Error! Multiple specular textures not supported.\n");
|
printf("Error! Multiple specular textures not supported.\n");
|
||||||
} else if(texture_count == 1) {
|
} else if(texture_count == 1) {
|
||||||
KFbxTexture* pTexture = FbxCast <KFbxTexture> (pProperty.GetSrcObject(KFbxTexture::ClassId,0));
|
FbxTexture* pTexture = FbxCast <FbxTexture> (pProperty.GetSrcObject(FbxTexture::ClassId,0));
|
||||||
KFbxFileTexture *pFileTexture = FbxCast<KFbxFileTexture>(pTexture);
|
FbxFileTexture *pFileTexture = FbxCast<FbxFileTexture>(pTexture);
|
||||||
if(pFileTexture) {
|
if(pFileTexture) {
|
||||||
new_material->setSpecularMap(KRResource::GetFileBase(pFileTexture->GetFileName()), KRVector2(pTexture->GetScaleU(), pTexture->GetScaleV()), KRVector2(pTexture->GetTranslationU(), pTexture->GetTranslationV()));
|
new_material->setSpecularMap(KRResource::GetFileBase(pFileTexture->GetFileName()), KRVector2(pTexture->GetScaleU(), pTexture->GetScaleV()), KRVector2(pTexture->GetTranslationU(), pTexture->GetTranslationV()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal Map Texture
|
// Normal Map Texture
|
||||||
pProperty = pMaterial->FindProperty(KFbxSurfaceMaterial::sNormalMap);
|
pProperty = pMaterial->FindProperty(FbxSurfaceMaterial::sNormalMap);
|
||||||
if(pProperty.GetSrcObjectCount(KFbxLayeredTexture::ClassId) > 0) {
|
if(pProperty.GetSrcObjectCount(FbxLayeredTexture::ClassId) > 0) {
|
||||||
printf("Warning! Layered textures not supported.\n");
|
printf("Warning! Layered textures not supported.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1189,8 +1204,8 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
if(texture_count > 1) {
|
if(texture_count > 1) {
|
||||||
printf("Error! Multiple normal map textures not supported.\n");
|
printf("Error! Multiple normal map textures not supported.\n");
|
||||||
} else if(texture_count == 1) {
|
} else if(texture_count == 1) {
|
||||||
KFbxTexture* pTexture = pProperty.GetSrcObject<KFbxTexture>(0);
|
FbxTexture* pTexture = pProperty.GetSrcObject<FbxTexture>(0);
|
||||||
KFbxFileTexture *pFileTexture = FbxCast<KFbxFileTexture>(pTexture);
|
FbxFileTexture *pFileTexture = FbxCast<FbxFileTexture>(pTexture);
|
||||||
if(pFileTexture) {
|
if(pFileTexture) {
|
||||||
new_material->setNormalMap(KRResource::GetFileBase(pFileTexture->GetFileName()), KRVector2(pTexture->GetScaleU(), pTexture->GetScaleV()), KRVector2(pTexture->GetTranslationU(), pTexture->GetTranslationV()));
|
new_material->setNormalMap(KRResource::GetFileBase(pFileTexture->GetFileName()), KRVector2(pTexture->GetScaleU(), pTexture->GetScaleV()), KRVector2(pTexture->GetTranslationU(), pTexture->GetTranslationV()));
|
||||||
}
|
}
|
||||||
@@ -1207,8 +1222,8 @@ void LoadMaterial(KRContext &context, FbxSurfaceMaterial *pMaterial) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LoadMesh(KRContext &context, KFbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, KFbxMesh* pSourceMesh) {
|
void LoadMesh(KRContext &context, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxMesh* pSourceMesh) {
|
||||||
KFbxMesh* pMesh = pGeometryConverter->TriangulateMesh(pSourceMesh);
|
FbxMesh* pMesh = pGeometryConverter->TriangulateMesh(pSourceMesh);
|
||||||
|
|
||||||
KRMesh::mesh_info mi;
|
KRMesh::mesh_info mi;
|
||||||
mi.format = KRMesh::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
mi.format = KRMesh::KRENGINE_MODEL_FORMAT_TRIANGLES;
|
||||||
@@ -1219,7 +1234,7 @@ void LoadMesh(KRContext &context, KFbxScene* pFbxScene, FbxGeometryConverter *pG
|
|||||||
} control_point_weight_info_t;
|
} control_point_weight_info_t;
|
||||||
|
|
||||||
int control_point_count = pMesh->GetControlPointsCount();
|
int control_point_count = pMesh->GetControlPointsCount();
|
||||||
KFbxVector4* control_points = pMesh->GetControlPoints();
|
FbxVector4* control_points = pMesh->GetControlPoints();
|
||||||
|
|
||||||
control_point_weight_info_t *control_point_weights = new control_point_weight_info_t[control_point_count];
|
control_point_weight_info_t *control_point_weights = new control_point_weight_info_t[control_point_count];
|
||||||
for(int control_point=0; control_point < control_point_count; control_point++) {
|
for(int control_point=0; control_point < control_point_count; control_point++) {
|
||||||
@@ -1342,7 +1357,7 @@ void LoadMesh(KRContext &context, KFbxScene* pFbxScene, FbxGeometryConverter *pG
|
|||||||
bool need_tangents = false;
|
bool need_tangents = false;
|
||||||
|
|
||||||
for(int iMaterial=0; iMaterial < material_count; iMaterial++) {
|
for(int iMaterial=0; iMaterial < material_count; iMaterial++) {
|
||||||
KFbxSurfaceMaterial *pMaterial = pSourceMesh->GetNode()->GetMaterial(iMaterial);
|
FbxSurfaceMaterial *pMaterial = pSourceMesh->GetNode()->GetMaterial(iMaterial);
|
||||||
|
|
||||||
KRMaterial *material = context.getMaterialManager()->getMaterial(pMaterial->GetName());
|
KRMaterial *material = context.getMaterialManager()->getMaterial(pMaterial->GetName());
|
||||||
if(material) {
|
if(material) {
|
||||||
@@ -1380,7 +1395,7 @@ void LoadMesh(KRContext &context, KFbxScene* pFbxScene, FbxGeometryConverter *pG
|
|||||||
for(int iVertex=0; iVertex<3; iVertex++) {
|
for(int iVertex=0; iVertex<3; iVertex++) {
|
||||||
// ----====---- Read Vertex Position ----====----
|
// ----====---- Read Vertex Position ----====----
|
||||||
int lControlPointIndex = pMesh->GetPolygonVertex(iPolygon, iVertex);
|
int lControlPointIndex = pMesh->GetPolygonVertex(iPolygon, iVertex);
|
||||||
KFbxVector4 v = control_points[lControlPointIndex];
|
FbxVector4 v = control_points[lControlPointIndex];
|
||||||
mi.vertices.push_back(KRVector3(v[0], v[1], v[2]));
|
mi.vertices.push_back(KRVector3(v[0], v[1], v[2]));
|
||||||
|
|
||||||
if(mi.bone_names.size() > 0) {
|
if(mi.bone_names.size() > 0) {
|
||||||
@@ -1401,29 +1416,35 @@ void LoadMesh(KRContext &context, KFbxScene* pFbxScene, FbxGeometryConverter *pG
|
|||||||
|
|
||||||
// ----====---- Read UVs ----====----
|
// ----====---- Read UVs ----====----
|
||||||
|
|
||||||
KStringList uvNames;
|
FbxStringList uvNames;
|
||||||
pMesh->GetUVSetNames(uvNames);
|
pMesh->GetUVSetNames(uvNames);
|
||||||
if(uv_count >= 1) {
|
if(uv_count >= 1) {
|
||||||
const char *setName = uvNames[0].Buffer();
|
const char *setName = uvNames[0].Buffer();
|
||||||
KFbxVector2 uv;
|
FbxVector2 uv;
|
||||||
if(pMesh->GetPolygonVertexUV(iPolygon, iVertex, setName, uv)) {
|
bool unmapped = false;
|
||||||
new_uva = KRVector2(uv[0], uv[1]);
|
if(pMesh->GetPolygonVertexUV(iPolygon, iVertex, setName, uv, unmapped)) {
|
||||||
|
if(!unmapped) {
|
||||||
|
new_uva = KRVector2(uv[0], uv[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mi.uva.push_back(new_uva);
|
mi.uva.push_back(new_uva);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(uv_count >= 2) {
|
if(uv_count >= 2) {
|
||||||
const char *setName = uvNames[1].Buffer();
|
const char *setName = uvNames[1].Buffer();
|
||||||
KFbxVector2 uv;
|
FbxVector2 uv;
|
||||||
if(pMesh->GetPolygonVertexUV(iPolygon, iVertex, setName, uv)) {
|
bool unmapped = false;
|
||||||
new_uvb = KRVector2(uv[0], uv[1]);
|
if(pMesh->GetPolygonVertexUV(iPolygon, iVertex, setName, uv, unmapped)) {
|
||||||
|
if(!unmapped) {
|
||||||
|
new_uvb = KRVector2(uv[0], uv[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mi.uvb.push_back(new_uvb);
|
mi.uvb.push_back(new_uvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----====---- Read Normals ----====----
|
// ----====---- Read Normals ----====----
|
||||||
|
|
||||||
KFbxVector4 new_normal;
|
FbxVector4 new_normal;
|
||||||
if(pMesh->GetPolygonVertexNormal(iPolygon, iVertex, new_normal)) {
|
if(pMesh->GetPolygonVertexNormal(iPolygon, iVertex, new_normal)) {
|
||||||
mi.normals.push_back(KRVector3(new_normal[0], new_normal[1], new_normal[2]));
|
mi.normals.push_back(KRVector3(new_normal[0], new_normal[1], new_normal[2]));
|
||||||
}
|
}
|
||||||
@@ -1432,7 +1453,7 @@ void LoadMesh(KRContext &context, KFbxScene* pFbxScene, FbxGeometryConverter *pG
|
|||||||
// ----====---- Read Tangents ----====----
|
// ----====---- Read Tangents ----====----
|
||||||
for(int l = 0; l < tangent_count; ++l)
|
for(int l = 0; l < tangent_count; ++l)
|
||||||
{
|
{
|
||||||
KFbxVector4 new_tangent;
|
FbxVector4 new_tangent;
|
||||||
FbxGeometryElementTangent* leTangent = pMesh->GetElementTangent(l);
|
FbxGeometryElementTangent* leTangent = pMesh->GetElementTangent(l);
|
||||||
|
|
||||||
if(leTangent->GetMappingMode() == FbxGeometryElement::eByPolygonVertex) {
|
if(leTangent->GetMappingMode() == FbxGeometryElement::eByPolygonVertex) {
|
||||||
@@ -1484,10 +1505,10 @@ void LoadMesh(KRContext &context, KFbxScene* pFbxScene, FbxGeometryConverter *pG
|
|||||||
context.getModelManager()->addModel(new_mesh);
|
context.getModelManager()->addModel(new_mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
KRNode *LoadMesh(KRNode *parent_node, KFbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
KRNode *LoadMesh(KRNode *parent_node, FbxScene* pFbxScene, FbxGeometryConverter *pGeometryConverter, FbxNode* pNode) {
|
||||||
std::string name = GetFbxObjectName(pNode);
|
std::string name = GetFbxObjectName(pNode);
|
||||||
|
|
||||||
KFbxMesh* pSourceMesh = (KFbxMesh*) pNode->GetNodeAttribute();
|
FbxMesh* pSourceMesh = (FbxMesh*) pNode->GetNodeAttribute();
|
||||||
|
|
||||||
if(KRMesh::GetLODCoverage(pNode->GetName()) == 100) {
|
if(KRMesh::GetLODCoverage(pNode->GetName()) == 100) {
|
||||||
// If this is the full detail model, add an instance of it to the scene file
|
// If this is the full detail model, add an instance of it to the scene file
|
||||||
@@ -1500,9 +1521,23 @@ KRNode *LoadMesh(KRNode *parent_node, KFbxScene* pFbxScene, FbxGeometryConverter
|
|||||||
return new KRCollider(parent_node->getScene(), GetFbxObjectName(pNode), pSourceMesh->GetNode()->GetName(), KRAKEN_COLLIDER_PHYSICS, 0.0f);
|
return new KRCollider(parent_node->getScene(), GetFbxObjectName(pNode), pSourceMesh->GetNode()->GetName(), KRAKEN_COLLIDER_PHYSICS, 0.0f);
|
||||||
} else if(strncmp(node_name, "audio_collider_", strlen("audio_collider_")) == 0) {
|
} else if(strncmp(node_name, "audio_collider_", strlen("audio_collider_")) == 0) {
|
||||||
return new KRCollider(parent_node->getScene(), GetFbxObjectName(pNode), pSourceMesh->GetNode()->GetName(), KRAKEN_COLLIDER_AUDIO, 1.0f);
|
return new KRCollider(parent_node->getScene(), GetFbxObjectName(pNode), pSourceMesh->GetNode()->GetName(), KRAKEN_COLLIDER_AUDIO, 1.0f);
|
||||||
} else if(strncmp(node_name, "collider_", strlen("collider_")) == 0) {
|
} else if(strncmp(node_name, "collider_", 9) == 0) { // 9 == strlen("collider_")
|
||||||
|
// Colliders can have a prefix of collider_##_, where ## indicates the layer mask
|
||||||
|
// Colliders with a prefix of only collider_ will have a default layer mask of KRAKEN_COLLIDER_PHYSICS | KRAKEN_COLLIDER_AUDIO
|
||||||
|
|
||||||
return new KRCollider(parent_node->getScene(), GetFbxObjectName(pNode), pSourceMesh->GetNode()->GetName(), KRAKEN_COLLIDER_PHYSICS | KRAKEN_COLLIDER_AUDIO, 1.0f);
|
// Scan through the characters of the name until we no longer see digit characters (or see a '\0' indicating the end of the string)
|
||||||
|
unsigned int layer = 0;
|
||||||
|
const char *szNodeName = node_name + 9; // 9 == strlen("collider_")
|
||||||
|
const char *source_char = szNodeName;
|
||||||
|
while(*source_char >= '0' && *source_char <= '9') {
|
||||||
|
layer = layer * 10 + (*source_char++ - '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(layer == 0) {
|
||||||
|
// No layer mask number was found, use the default
|
||||||
|
layer = KRAKEN_COLLIDER_PHYSICS | KRAKEN_COLLIDER_AUDIO;
|
||||||
|
}
|
||||||
|
return new KRCollider(parent_node->getScene(), GetFbxObjectName(pNode), pSourceMesh->GetNode()->GetName(), layer, 1.0f);
|
||||||
} else {
|
} else {
|
||||||
return new KRModel(parent_node->getScene(), GetFbxObjectName(pNode), pSourceMesh->GetNode()->GetName(), light_map, 0.0f, true, false);
|
return new KRModel(parent_node->getScene(), GetFbxObjectName(pNode), pSourceMesh->GetNode()->GetName(), light_map, 0.0f, true, false);
|
||||||
}
|
}
|
||||||
@@ -1512,7 +1547,7 @@ KRNode *LoadMesh(KRNode *parent_node, KFbxScene* pFbxScene, FbxGeometryConverter
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KRNode *LoadSkeleton(KRNode *parent_node, FbxScene* pFbxScene, KFbxNode* pNode) {
|
KRNode *LoadSkeleton(KRNode *parent_node, FbxScene* pFbxScene, FbxNode* pNode) {
|
||||||
std::string name = GetFbxObjectName(pNode);
|
std::string name = GetFbxObjectName(pNode);
|
||||||
KRBone *new_bone = new KRBone(parent_node->getScene(), name.c_str());
|
KRBone *new_bone = new KRBone(parent_node->getScene(), name.c_str());
|
||||||
|
|
||||||
@@ -1526,7 +1561,56 @@ KRNode *LoadSkeleton(KRNode *parent_node, FbxScene* pFbxScene, KFbxNode* pNode)
|
|||||||
return new_bone;
|
return new_bone;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRNode *LoadCamera(KRNode *parent_node, KFbxNode* pNode) {
|
KRNode *LoadLocator(KRNode *parent_node, FbxScene* pFbxScene, FbxNode* pNode) {
|
||||||
|
std::string name = GetFbxObjectName(pNode);
|
||||||
|
|
||||||
|
KRLocator *new_locator = new KRLocator(parent_node->getScene(), name.c_str());
|
||||||
|
|
||||||
|
// Enumerate fbx properties so client code can convert locators into application-specific objects
|
||||||
|
FbxProperty fbx_property = pNode->GetFirstProperty();
|
||||||
|
while(fbx_property.IsValid()) {
|
||||||
|
std::string property_name = fbx_property.GetNameAsCStr();
|
||||||
|
std::transform(property_name.begin(), property_name.end(), property_name.begin(), ::tolower);
|
||||||
|
|
||||||
|
boost::variant<int, double, bool, std::string> property_value = "";
|
||||||
|
switch(fbx_property.GetPropertyDataType().GetType()) {
|
||||||
|
case eFbxInt:
|
||||||
|
new_locator->getUserAttributes()[property_name] = fbx_property.Get<FbxInt>();
|
||||||
|
break;
|
||||||
|
case eFbxDouble:
|
||||||
|
new_locator->getUserAttributes()[property_name] = fbx_property.Get<FbxDouble>();
|
||||||
|
break;
|
||||||
|
case eFbxBool:
|
||||||
|
new_locator->getUserAttributes()[property_name] = fbx_property.Get<FbxBool>();
|
||||||
|
break;
|
||||||
|
case eFbxFloat:
|
||||||
|
new_locator->getUserAttributes()[property_name] = fbx_property.Get<FbxDouble>();
|
||||||
|
break;
|
||||||
|
case eFbxString:
|
||||||
|
new_locator->getUserAttributes()[property_name] = std::string(fbx_property.Get<FbxString>().Buffer());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
fprintf(stderr, "FBX property not imported due to unsupported data type: %s.%s\n", name.c_str(), property_name.c_str());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fbx_property = pNode->GetNextProperty(fbx_property);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//static bool GetBindPoseContaining(FbxScene* pScene, FbxNode* pNode, PoseList& pPoseList, FbxArray<int>& pIndex);
|
||||||
|
// PoseList pose_list;
|
||||||
|
// FbxArray<int> pose_indices;
|
||||||
|
// if(FbxPose::GetBindPoseContaining(pFbxScene, pNode, pose_list, pose_indices)) {
|
||||||
|
// fprintf(stderr, "Found bind pose(s)!\n");
|
||||||
|
// }
|
||||||
|
|
||||||
|
return new_locator;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRNode *LoadCamera(KRNode *parent_node, FbxNode* pNode) {
|
||||||
FbxCamera *camera = (FbxCamera *)pNode->GetNodeAttribute();
|
FbxCamera *camera = (FbxCamera *)pNode->GetNodeAttribute();
|
||||||
const char *szName = pNode->GetName();
|
const char *szName = pNode->GetName();
|
||||||
|
|
||||||
@@ -1534,7 +1618,7 @@ KRNode *LoadCamera(KRNode *parent_node, KFbxNode* pNode) {
|
|||||||
return new_camera;
|
return new_camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRNode *LoadLight(KRNode *parent_node, KFbxNode* pNode) {
|
KRNode *LoadLight(KRNode *parent_node, FbxNode* pNode) {
|
||||||
const GLfloat PI = 3.14159265;
|
const GLfloat PI = 3.14159265;
|
||||||
const GLfloat d2r = PI * 2 / 360;
|
const GLfloat d2r = PI * 2 / 360;
|
||||||
|
|
||||||
@@ -1545,7 +1629,7 @@ KRNode *LoadLight(KRNode *parent_node, KFbxNode* pNode) {
|
|||||||
FbxDouble light_intensity = pLight->Intensity.Get();
|
FbxDouble light_intensity = pLight->Intensity.Get();
|
||||||
FbxDouble light_hotspot = pLight->InnerAngle.Get(); // light inner cone angle (in degrees). Also know as the HotSpot
|
FbxDouble light_hotspot = pLight->InnerAngle.Get(); // light inner cone angle (in degrees). Also know as the HotSpot
|
||||||
FbxDouble light_coneangle = pLight->OuterAngle.Get(); // light outer cone angle (in degrees). Also known as the Falloff
|
FbxDouble light_coneangle = pLight->OuterAngle.Get(); // light outer cone angle (in degrees). Also known as the Falloff
|
||||||
KFbxLight::EDecayType light_decaytype = pLight->DecayType.Get(); // decay type
|
FbxLight::EDecayType light_decaytype = pLight->DecayType.Get(); // decay type
|
||||||
FbxDouble light_decaystart = pLight->DecayStart.Get(); // decay start distance
|
FbxDouble light_decaystart = pLight->DecayStart.Get(); // decay start distance
|
||||||
|
|
||||||
|
|
||||||
@@ -1557,20 +1641,20 @@ KRNode *LoadLight(KRNode *parent_node, KFbxNode* pNode) {
|
|||||||
KRLight *new_light = NULL;
|
KRLight *new_light = NULL;
|
||||||
|
|
||||||
switch(pLight->LightType.Get()) {
|
switch(pLight->LightType.Get()) {
|
||||||
case KFbxLight::ePoint:
|
case FbxLight::ePoint:
|
||||||
{
|
{
|
||||||
KRPointLight *l = new KRPointLight(parent_node->getScene(), szName);
|
KRPointLight *l = new KRPointLight(parent_node->getScene(), szName);
|
||||||
new_light = l;
|
new_light = l;
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KFbxLight::eDirectional:
|
case FbxLight::eDirectional:
|
||||||
{
|
{
|
||||||
KRDirectionalLight *l = new KRDirectionalLight(parent_node->getScene(), szName);
|
KRDirectionalLight *l = new KRDirectionalLight(parent_node->getScene(), szName);
|
||||||
new_light = l;
|
new_light = l;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KFbxLight::eSpot:
|
case FbxLight::eSpot:
|
||||||
{
|
{
|
||||||
KRSpotLight *l = new KRSpotLight(parent_node->getScene(), szName);
|
KRSpotLight *l = new KRSpotLight(parent_node->getScene(), szName);
|
||||||
l->setInnerAngle(light_hotspot * d2r);
|
l->setInnerAngle(light_hotspot * d2r);
|
||||||
@@ -1578,8 +1662,8 @@ KRNode *LoadLight(KRNode *parent_node, KFbxNode* pNode) {
|
|||||||
new_light = l;
|
new_light = l;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KFbxLight::eVolume:
|
case FbxLight::eVolume:
|
||||||
case KFbxLight::eArea:
|
case FbxLight::eArea:
|
||||||
// Not supported yet
|
// Not supported yet
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ void KRReverbZone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
|
|||||||
|
|
||||||
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass)) {
|
KRVector3 rim_color;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ std::set<KRReverbZone *> &KRScene::getReverbZones()
|
|||||||
return m_reverbZoneNodes;
|
return m_reverbZoneNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::set<KRLocator *> &KRScene::getLocators()
|
||||||
|
{
|
||||||
|
return m_locatorNodes;
|
||||||
|
}
|
||||||
|
|
||||||
void KRScene::render(KRCamera *pCamera, unordered_map<KRAABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame) {
|
void KRScene::render(KRCamera *pCamera, unordered_map<KRAABB, int> &visibleBounds, const KRViewport &viewport, KRNode::RenderPass renderPass, bool new_frame) {
|
||||||
if(new_frame) {
|
if(new_frame) {
|
||||||
// Expire cached occlusion test results.
|
// Expire cached occlusion test results.
|
||||||
@@ -272,7 +277,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<KRAABB, int> &visi
|
|||||||
KRMat4 mvpmatrix = matModel * viewport.getViewProjectionMatrix();
|
KRMat4 mvpmatrix = matModel * viewport.getViewProjectionMatrix();
|
||||||
|
|
||||||
|
|
||||||
getContext().getModelManager()->bindVBO((void *)KRENGINE_VBO_3D_CUBE, KRENGINE_VBO_3D_CUBE_SIZE, NULL, 0, KRENGINE_VBO_3D_CUBE_ATTRIBS, true);
|
getContext().getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_3D_CUBE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_3D_CUBE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_3D_CUBE_ATTRIBS, true);
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE) {
|
if(renderPass != KRNode::RENDER_PASS_FORWARD_TRANSPARENT && renderPass != KRNode::RENDER_PASS_ADDITIVE_PARTICLES && renderPass != KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE) {
|
||||||
@@ -290,7 +295,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<KRAABB, int> &visi
|
|||||||
GLDEBUG(glDepthMask(GL_FALSE));
|
GLDEBUG(glDepthMask(GL_FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, matModel, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT)) {
|
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, matModel, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, KRVector3::Zero(), 0.0f)) {
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
|
||||||
m_pContext->getModelManager()->log_draw_call(renderPass, "octree", "occlusion_test", 14);
|
m_pContext->getModelManager()->log_draw_call(renderPass, "octree", "occlusion_test", 14);
|
||||||
}
|
}
|
||||||
@@ -404,9 +409,10 @@ bool KRScene::save(KRDataBlock &data) {
|
|||||||
|
|
||||||
KRScene *KRScene::Load(KRContext &context, const std::string &name, KRDataBlock *data)
|
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
|
std::string xml_string = data->getString();
|
||||||
|
delete data;
|
||||||
tinyxml2::XMLDocument doc;
|
tinyxml2::XMLDocument doc;
|
||||||
doc.Parse((char *)data->getStart());
|
doc.Parse(xml_string.c_str());
|
||||||
KRScene *new_scene = new KRScene(context, name);
|
KRScene *new_scene = new KRScene(context, name);
|
||||||
|
|
||||||
tinyxml2::XMLElement *scene_element = doc.RootElement();
|
tinyxml2::XMLElement *scene_element = doc.RootElement();
|
||||||
@@ -418,7 +424,7 @@ KRScene *KRScene::Load(KRContext &context, const std::string &name, KRDataBlock
|
|||||||
new_scene->getRootNode()->addChild(n);
|
new_scene->getRootNode()->addChild(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete data;
|
|
||||||
return new_scene;
|
return new_scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,6 +465,10 @@ void KRScene::notify_sceneGraphDelete(KRNode *pNode)
|
|||||||
if(ReverbZoneNode) {
|
if(ReverbZoneNode) {
|
||||||
m_reverbZoneNodes.erase(ReverbZoneNode);
|
m_reverbZoneNodes.erase(ReverbZoneNode);
|
||||||
}
|
}
|
||||||
|
KRLocator *locator = dynamic_cast<KRLocator *>(pNode);
|
||||||
|
if(locator) {
|
||||||
|
m_locatorNodes.erase(locator);
|
||||||
|
}
|
||||||
m_modifiedNodes.erase(pNode);
|
m_modifiedNodes.erase(pNode);
|
||||||
if(!m_newNodes.erase(pNode)) {
|
if(!m_newNodes.erase(pNode)) {
|
||||||
m_nodeTree.remove(pNode);
|
m_nodeTree.remove(pNode);
|
||||||
@@ -480,20 +490,30 @@ void KRScene::updateOctree(const KRViewport &viewport)
|
|||||||
if(node->hasPhysics()) {
|
if(node->hasPhysics()) {
|
||||||
m_physicsNodes.insert(node);
|
m_physicsNodes.insert(node);
|
||||||
}
|
}
|
||||||
KRAmbientZone *AmbientZoneNode = dynamic_cast<KRAmbientZone *>(node);
|
KRAmbientZone *ambientZoneNode = dynamic_cast<KRAmbientZone *>(node);
|
||||||
if(dynamic_cast<KRAmbientZone *>(node)) {
|
if(ambientZoneNode) {
|
||||||
m_ambientZoneNodes.insert(AmbientZoneNode);
|
m_ambientZoneNodes.insert(ambientZoneNode);
|
||||||
}
|
}
|
||||||
KRReverbZone *ReverbZoneNode = dynamic_cast<KRReverbZone *>(node);
|
KRReverbZone *reverbZoneNode = dynamic_cast<KRReverbZone *>(node);
|
||||||
if(dynamic_cast<KRReverbZone *>(node)) {
|
if(reverbZoneNode) {
|
||||||
m_reverbZoneNodes.insert(ReverbZoneNode);
|
m_reverbZoneNodes.insert(reverbZoneNode);
|
||||||
}
|
}
|
||||||
|
KRLocator *locatorNode = dynamic_cast<KRLocator *>(node);
|
||||||
|
if(locatorNode) {
|
||||||
|
m_locatorNodes.insert(locatorNode);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for(std::set<KRNode *>::iterator itr=modifiedNodes.begin(); itr != modifiedNodes.end(); itr++) {
|
for(std::set<KRNode *>::iterator itr=modifiedNodes.begin(); itr != modifiedNodes.end(); itr++) {
|
||||||
KRNode *node = *itr;
|
KRNode *node = *itr;
|
||||||
if(node->lodIsVisible()) {
|
if(node->lodIsVisible()) {
|
||||||
m_nodeTree.update(node);
|
m_nodeTree.update(node);
|
||||||
}
|
}
|
||||||
|
if(node->hasPhysics()) {
|
||||||
|
m_physicsNodes.insert(node);
|
||||||
|
} else if(!node->hasPhysics()) {
|
||||||
|
m_physicsNodes.erase(node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "KRCamera.h"
|
#include "KRCamera.h"
|
||||||
#include "KRMeshManager.h"
|
#include "KRMeshManager.h"
|
||||||
#include "KRNode.h"
|
#include "KRNode.h"
|
||||||
|
#include "KRLocator.h"
|
||||||
#include "KRAmbientZone.h"
|
#include "KRAmbientZone.h"
|
||||||
#include "KRReverbZone.h"
|
#include "KRReverbZone.h"
|
||||||
#include "KROctree.h"
|
#include "KROctree.h"
|
||||||
@@ -84,6 +85,7 @@ public:
|
|||||||
|
|
||||||
std::set<KRAmbientZone *> &getAmbientZones();
|
std::set<KRAmbientZone *> &getAmbientZones();
|
||||||
std::set<KRReverbZone *> &getReverbZones();
|
std::set<KRReverbZone *> &getReverbZones();
|
||||||
|
std::set<KRLocator *> &getLocators();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -98,6 +100,7 @@ private:
|
|||||||
std::set<KRNode *> m_physicsNodes;
|
std::set<KRNode *> m_physicsNodes;
|
||||||
std::set<KRAmbientZone *> m_ambientZoneNodes;
|
std::set<KRAmbientZone *> m_ambientZoneNodes;
|
||||||
std::set<KRReverbZone *> m_reverbZoneNodes;
|
std::set<KRReverbZone *> m_reverbZoneNodes;
|
||||||
|
std::set<KRLocator *> m_locatorNodes;
|
||||||
|
|
||||||
KROctree m_nodeTree;
|
KROctree m_nodeTree;
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,9 @@ const char *KRShader::KRENGINE_UNIFORM_NAMES[] = {
|
|||||||
"fog_density_premultiplied_squared", // KRENGINE_UNIFORM_DENSITY_PREMULTIPLIED_SQUARED
|
"fog_density_premultiplied_squared", // KRENGINE_UNIFORM_DENSITY_PREMULTIPLIED_SQUARED
|
||||||
"slice_depth_scale", // KRENGINE_UNIFORM_SLICE_DEPTH_SCALE
|
"slice_depth_scale", // KRENGINE_UNIFORM_SLICE_DEPTH_SCALE
|
||||||
"particle_origin", // KRENGINE_UNIFORM_PARTICLE_ORIGIN
|
"particle_origin", // KRENGINE_UNIFORM_PARTICLE_ORIGIN
|
||||||
"bone_transforms" // KRENGINE_UNIFORM_BONE_TRANSFORMS
|
"bone_transforms", // KRENGINE_UNIFORM_BONE_TRANSFORMS
|
||||||
|
"rim_color", // KRENGINE_UNIFORM_RIM_COLOR
|
||||||
|
"rim_power" // KRENGINE_UNIFORM_RIM_POWER
|
||||||
};
|
};
|
||||||
|
|
||||||
KRShader::KRShader(KRContext &context, char *szKey, std::string options, std::string vertShaderSource, const std::string fragShaderSource) : KRContextObject(context)
|
KRShader::KRShader(KRContext &context, char *szKey, std::string options, std::string vertShaderSource, const std::string fragShaderSource) : KRContextObject(context)
|
||||||
@@ -340,7 +342,7 @@ void KRShader::setUniform(int location, const KRMat4 &value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass) {
|
bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power) {
|
||||||
if(m_iProgram == 0) {
|
if(m_iProgram == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -505,11 +507,15 @@ bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rim highlighting parameters
|
||||||
|
setUniform(KRENGINE_UNIFORM_RIM_COLOR, rim_color);
|
||||||
|
setUniform(KRENGINE_UNIFORM_RIM_POWER, rim_power);
|
||||||
|
|
||||||
// Fog parameters
|
// Fog parameters
|
||||||
setUniform(KRENGINE_UNIFORM_FOG_NEAR, camera.settings.fog_near);
|
setUniform(KRENGINE_UNIFORM_FOG_NEAR, camera.settings.fog_near);
|
||||||
setUniform(KRENGINE_UNIFORM_FOG_FAR, camera.settings.fog_far);
|
setUniform(KRENGINE_UNIFORM_FOG_FAR, camera.settings.fog_far);
|
||||||
setUniform(KRENGINE_UNIFORM_FOG_DENSITY, camera.settings.fog_density);
|
setUniform(KRENGINE_UNIFORM_FOG_DENSITY, camera.settings.fog_density);
|
||||||
setUniform(KRENGINE_UNIFORM_FOG_COLOR, camera.settings.fog_color);
|
setUniform(KRENGINE_UNIFORM_FOG_COLOR, camera.settings.fog_color);
|
||||||
|
|
||||||
if(m_uniforms[KRENGINE_UNIFORM_FOG_SCALE] != -1) {
|
if(m_uniforms[KRENGINE_UNIFORM_FOG_SCALE] != -1) {
|
||||||
setUniform(KRENGINE_UNIFORM_FOG_SCALE, 1.0f / (camera.settings.fog_far - camera.settings.fog_near));
|
setUniform(KRENGINE_UNIFORM_FOG_SCALE, 1.0f / (camera.settings.fog_far - camera.settings.fog_near));
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
virtual ~KRShader();
|
virtual ~KRShader();
|
||||||
const char *getKey() const;
|
const char *getKey() const;
|
||||||
|
|
||||||
bool bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass);
|
bool bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
KRENGINE_UNIFORM_MATERIAL_AMBIENT = 0,
|
KRENGINE_UNIFORM_MATERIAL_AMBIENT = 0,
|
||||||
@@ -114,6 +114,8 @@ public:
|
|||||||
KRENGINE_UNIFORM_SLICE_DEPTH_SCALE,
|
KRENGINE_UNIFORM_SLICE_DEPTH_SCALE,
|
||||||
KRENGINE_UNIFORM_PARTICLE_ORIGIN,
|
KRENGINE_UNIFORM_PARTICLE_ORIGIN,
|
||||||
KRENGINE_UNIFORM_BONE_TRANSFORMS,
|
KRENGINE_UNIFORM_BONE_TRANSFORMS,
|
||||||
|
KRENGINE_UNIFORM_RIM_COLOR,
|
||||||
|
KRENGINE_UNIFORM_RIM_POWER,
|
||||||
KRENGINE_NUM_UNIFORMS
|
KRENGINE_NUM_UNIFORMS
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ KRShaderManager::~KRShaderManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *pCamera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass) {
|
KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *pCamera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, bool bRimColor) {
|
||||||
|
|
||||||
int iShadowQuality = 0; // FINDME - HACK - Placeholder code, need to iterate through lights and dynamically build shader
|
int iShadowQuality = 0; // FINDME - HACK - Placeholder code, need to iterate through lights and dynamically build shader
|
||||||
|
|
||||||
@@ -114,6 +114,7 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
|||||||
key.second.push_back(pCamera->settings.flash_intensity * 1000.0f);
|
key.second.push_back(pCamera->settings.flash_intensity * 1000.0f);
|
||||||
key.second.push_back(pCamera->settings.vignette_radius * 1000.0f);
|
key.second.push_back(pCamera->settings.vignette_radius * 1000.0f);
|
||||||
key.second.push_back(pCamera->settings.vignette_falloff * 1000.0f);
|
key.second.push_back(pCamera->settings.vignette_falloff * 1000.0f);
|
||||||
|
key.second.push_back(bRimColor);
|
||||||
|
|
||||||
|
|
||||||
KRShader *pShader = m_shaders[key];
|
KRShader *pShader = m_shaders[key];
|
||||||
@@ -180,6 +181,7 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
|||||||
stream << "\n#define ENABLE_AMBIENT " << (pCamera->settings.bEnableAmbient ? "1" : "0");
|
stream << "\n#define ENABLE_AMBIENT " << (pCamera->settings.bEnableAmbient ? "1" : "0");
|
||||||
stream << "\n#define ENABLE_DIFFUSE " << (pCamera->settings.bEnableDiffuse ? "1" : "0");
|
stream << "\n#define ENABLE_DIFFUSE " << (pCamera->settings.bEnableDiffuse ? "1" : "0");
|
||||||
stream << "\n#define ENABLE_SPECULAR " << (pCamera->settings.bEnableSpecular ? "1" : "0");
|
stream << "\n#define ENABLE_SPECULAR " << (pCamera->settings.bEnableSpecular ? "1" : "0");
|
||||||
|
stream << "\n#define ENABLE_RIM_COLOR " << (bRimColor ? "1" : "0");
|
||||||
stream << "\n#define FOG_TYPE " << pCamera->settings.fog_type;
|
stream << "\n#define FOG_TYPE " << pCamera->settings.fog_type;
|
||||||
switch(renderPass) {
|
switch(renderPass) {
|
||||||
case KRNode::RENDER_PASS_DEFERRED_GBUFFER:
|
case KRNode::RENDER_PASS_DEFERRED_GBUFFER:
|
||||||
@@ -238,28 +240,28 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
|||||||
return pShader;
|
return pShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRShaderManager::selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass)
|
bool KRShaderManager::selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const KRVector3 &rim_color, float rim_power)
|
||||||
{
|
{
|
||||||
KRShader *pShader = getShader(shader_name, &camera, point_lights, directional_lights, spot_lights, bone_count, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, bDiffuseMapScale, bSpecMapScale, bNormalMapScale, bReflectionMapScale, bDiffuseMapOffset, bSpecMapOffset, bNormalMapOffset, bReflectionMapOffset, bAlphaTest, bAlphaBlend, renderPass);
|
KRShader *pShader = getShader(shader_name, &camera, point_lights, directional_lights, spot_lights, bone_count, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, bDiffuseMapScale, bSpecMapScale, bNormalMapScale, bReflectionMapScale, bDiffuseMapOffset, bSpecMapOffset, bNormalMapOffset, bReflectionMapOffset, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
|
||||||
return selectShader(camera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, bone_count, renderPass);
|
return selectShader(camera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, bone_count, renderPass, rim_color, rim_power);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRShaderManager::selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass)
|
bool KRShaderManager::selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power)
|
||||||
{
|
{
|
||||||
if(pShader) {
|
if(pShader) {
|
||||||
return pShader->bind(camera, viewport, matModel, point_lights, directional_lights, spot_lights, renderPass);
|
return pShader->bind(camera, viewport, matModel, point_lights, directional_lights, spot_lights, renderPass, rim_color, rim_power);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRShaderManager::loadFragmentShader(const std::string &name, KRDataBlock *data) {
|
void KRShaderManager::loadFragmentShader(const std::string &name, KRDataBlock *data) {
|
||||||
m_fragShaderSource[name] = string((char *)data->getStart(), data->getSize());
|
m_fragShaderSource[name] = data->getString();
|
||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRShaderManager::loadVertexShader(const std::string &name, KRDataBlock *data) {
|
void KRShaderManager::loadVertexShader(const std::string &name, KRDataBlock *data) {
|
||||||
m_vertShaderSource[name] = string((char *)data->getStart(), data->getSize());
|
m_vertShaderSource[name] = data->getString();
|
||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ public:
|
|||||||
const std::string &getVertShaderSource(const std::string &name);
|
const std::string &getVertShaderSource(const std::string &name);
|
||||||
|
|
||||||
|
|
||||||
KRShader *getShader(const std::string &shader_name, KRCamera *pCamera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass);
|
KRShader *getShader(const std::string &shader_name, KRCamera *pCamera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, bool bRimColor = false);
|
||||||
|
|
||||||
bool selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass);
|
bool selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power);
|
||||||
|
|
||||||
bool selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass);
|
bool selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const KRVector3 &rim_color, float rim_power);
|
||||||
|
|
||||||
long getShaderHandlesUsed();
|
long getShaderHandlesUsed();
|
||||||
|
|
||||||
|
|||||||
140
KREngine/kraken/KRSprite.cpp
Normal file
140
KREngine/kraken/KRSprite.cpp
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
//
|
||||||
|
// KRSprite.cpp
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Created by Kearwood Gilbert on 12-04-05.
|
||||||
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "KREngine-common.h"
|
||||||
|
#include "KRSprite.h"
|
||||||
|
|
||||||
|
#include "KRNode.h"
|
||||||
|
#include "KRMat4.h"
|
||||||
|
#include "KRVector3.h"
|
||||||
|
#include "KRCamera.h"
|
||||||
|
#include "KRContext.h"
|
||||||
|
|
||||||
|
#include "KRShaderManager.h"
|
||||||
|
#include "KRShader.h"
|
||||||
|
#include "KRStockGeometry.h"
|
||||||
|
#include "KRDirectionalLight.h"
|
||||||
|
#include "KRSpotLight.h"
|
||||||
|
#include "KRPointLight.h"
|
||||||
|
|
||||||
|
|
||||||
|
KRSprite::KRSprite(KRScene &scene, std::string name) : KRNode(scene, name)
|
||||||
|
{
|
||||||
|
m_spriteTexture = "";
|
||||||
|
m_pSpriteTexture = NULL;
|
||||||
|
m_spriteSize = 0.0f;
|
||||||
|
m_spriteAlpha = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRSprite::~KRSprite()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string KRSprite::getElementName() {
|
||||||
|
return "sprite";
|
||||||
|
}
|
||||||
|
|
||||||
|
tinyxml2::XMLElement *KRSprite::saveXML( tinyxml2::XMLNode *parent)
|
||||||
|
{
|
||||||
|
tinyxml2::XMLElement *e = KRNode::saveXML(parent);
|
||||||
|
e->SetAttribute("sprite_size", m_spriteSize);
|
||||||
|
e->SetAttribute("sprite_texture", m_spriteTexture.c_str());
|
||||||
|
e->SetAttribute("sprite_alpha", m_spriteAlpha);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRSprite::loadXML(tinyxml2::XMLElement *e) {
|
||||||
|
KRNode::loadXML(e);
|
||||||
|
|
||||||
|
if(e->QueryFloatAttribute("sprite_size", &m_spriteSize) != tinyxml2::XML_SUCCESS) {
|
||||||
|
m_spriteSize = 0.0f;
|
||||||
|
}
|
||||||
|
if(e->QueryFloatAttribute("sprite_alpha", &m_spriteAlpha) != tinyxml2::XML_SUCCESS) {
|
||||||
|
m_spriteAlpha = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *szSpriteTexture = e->Attribute("sprite_texture");
|
||||||
|
if(szSpriteTexture) {
|
||||||
|
m_spriteTexture = szSpriteTexture;
|
||||||
|
} else {
|
||||||
|
m_spriteTexture = "";
|
||||||
|
}
|
||||||
|
m_pSpriteTexture = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRSprite::setSpriteTexture(std::string sprite_texture) {
|
||||||
|
m_spriteTexture = sprite_texture;
|
||||||
|
m_pSpriteTexture = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRSprite::setSpriteSize(float sprite_size) {
|
||||||
|
// TODO - Deprecated - This should come from the localScale
|
||||||
|
m_spriteSize = sprite_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRSprite::setSpriteAlpha(float alpha)
|
||||||
|
{
|
||||||
|
m_spriteAlpha = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
float KRSprite::getSpriteAlpha() const
|
||||||
|
{
|
||||||
|
return m_spriteAlpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRAABB KRSprite::getBounds() {
|
||||||
|
return KRAABB(KRVector3(-m_spriteSize), KRVector3(m_spriteSize), getModelMatrix());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass) {
|
||||||
|
|
||||||
|
KRNode::render(pCamera, point_lights, directional_lights, spot_lights, viewport, renderPass);
|
||||||
|
|
||||||
|
|
||||||
|
if(renderPass == KRNode::RENDER_PASS_ADDITIVE_PARTICLES) {
|
||||||
|
if(m_spriteTexture.size() && m_spriteSize > 0.0f && m_spriteAlpha > 0.0f) {
|
||||||
|
|
||||||
|
|
||||||
|
if(!m_pSpriteTexture && m_spriteTexture.size()) {
|
||||||
|
m_pSpriteTexture = getContext().getTextureManager()->getTexture(m_spriteTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_pSpriteTexture) {
|
||||||
|
/*
|
||||||
|
// Enable additive blending
|
||||||
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
|
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE));
|
||||||
|
|
||||||
|
// Disable z-buffer write
|
||||||
|
GLDEBUG(glDepthMask(GL_FALSE));
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO - Sprites are currently additive only. Need to expose this and allow for multiple blending modes
|
||||||
|
|
||||||
|
// Enable z-buffer test
|
||||||
|
GLDEBUG(glEnable(GL_DEPTH_TEST));
|
||||||
|
GLDEBUG(glDepthFunc(GL_LEQUAL));
|
||||||
|
GLDEBUG(glDepthRangef(0.0, 1.0));
|
||||||
|
|
||||||
|
// Render light sprite on transparency pass
|
||||||
|
KRShader *pShader = getContext().getShaderManager()->getShader("sprite", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
|
||||||
|
KRVector3 rim_color;
|
||||||
|
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
||||||
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
|
||||||
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_spriteSize);
|
||||||
|
m_pContext->getTextureManager()->selectTexture(0, m_pSpriteTexture);
|
||||||
|
m_pContext->getModelManager()->bindVBO(getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_VERTICES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_INDEXES, getContext().getModelManager()->KRENGINE_VBO_2D_SQUARE_ATTRIBS, true);
|
||||||
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
42
KREngine/kraken/KRSprite.h
Normal file
42
KREngine/kraken/KRSprite.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// KRSprite.h
|
||||||
|
// KREngine
|
||||||
|
//
|
||||||
|
// Created by Kearwood Gilbert on 12-04-05.
|
||||||
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef KRSPRITE_H
|
||||||
|
#define KRSPRITE_H
|
||||||
|
|
||||||
|
#include "KRResource.h"
|
||||||
|
#include "KRNode.h"
|
||||||
|
#include "KRTexture.h"
|
||||||
|
|
||||||
|
class KRSprite : public KRNode {
|
||||||
|
public:
|
||||||
|
KRSprite(KRScene &scene, std::string name);
|
||||||
|
|
||||||
|
virtual ~KRSprite();
|
||||||
|
virtual std::string getElementName();
|
||||||
|
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||||
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
||||||
|
|
||||||
|
void setSpriteTexture(std::string sprite_texture);
|
||||||
|
void setSpriteSize(float sprite_size);
|
||||||
|
void setSpriteAlpha(float alpha);
|
||||||
|
float getSpriteAlpha() const;
|
||||||
|
|
||||||
|
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
||||||
|
|
||||||
|
virtual KRAABB getBounds();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
std::string m_spriteTexture;
|
||||||
|
KRTexture *m_pSpriteTexture;
|
||||||
|
float m_spriteSize;
|
||||||
|
float m_spriteAlpha;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -10,8 +10,9 @@
|
|||||||
#define KRSTOCKGEOMETRY_H
|
#define KRSTOCKGEOMETRY_H
|
||||||
|
|
||||||
#include "KRMesh.h"
|
#include "KRMesh.h"
|
||||||
|
#include "KRDataBlock.h"
|
||||||
static const GLfloat KRENGINE_VBO_3D_CUBE[] = {
|
/*
|
||||||
|
static const GLfloat _KRENGINE_VBO_3D_CUBE_VERTEX_DATA[] = {
|
||||||
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,
|
||||||
@@ -28,32 +29,20 @@ static const GLfloat KRENGINE_VBO_3D_CUBE[] = {
|
|||||||
-1.0, 1.0,-1.0
|
-1.0, 1.0,-1.0
|
||||||
};
|
};
|
||||||
|
|
||||||
static int KRENGINE_VBO_3D_CUBE_SIZE = sizeof(GLfloat) * 3 * 14;
|
static KRDataBlock KRENGINE_VBO_3D_CUBE_VERTICES, KRENGINE_VBO_3D_CUBE_INDEXES;
|
||||||
|
KRENGINE_VBO_3D_CUBE_VERTICES.load((void *)_KRENGINE_VBO_3D_CUBE_VERTEX_DATA, sizeof(GLfloat) * 3 * 14);
|
||||||
|
|
||||||
static const __int32_t KRENGINE_VBO_3D_CUBE_ATTRIBS = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX);
|
static const __int32_t KRENGINE_VBO_3D_CUBE_ATTRIBS = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX);
|
||||||
|
|
||||||
static const GLfloat KRENGINE_VERTICES_2D_SQUARE[] = {
|
static const GLfloat _KRENGINE_VBO_2D_SQUARE_VERTEX_DATA[] = {
|
||||||
-1.0f, -1.0f,
|
|
||||||
1.0f, -1.0f,
|
|
||||||
-1.0f, 1.0f,
|
|
||||||
1.0f, 1.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const GLfloat KRENGINE_VERTICES_2D_SQUARE_UV[] = {
|
|
||||||
0.0f, 0.0f,
|
|
||||||
1.0f, 0.0f,
|
|
||||||
0.0f, 1.0f,
|
|
||||||
1.0f, 1.0f,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const GLfloat KRENGINE_VBO_2D_SQUARE[] = {
|
|
||||||
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
|
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
|
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
|
||||||
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
|
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
|
||||||
1.0f, 1.0f, 0.0f, 1.0f, 1.0f
|
1.0f, 1.0f, 0.0f, 1.0f, 1.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int KRENGINE_VBO_2D_SQUARE_SIZE = sizeof(GLfloat) * 5 * 4;
|
static KRDataBlock KRENGINE_VBO_2D_SQUARE_VERTICES, KRENGINE_VBO_2D_SQUARE_INDEXES;
|
||||||
|
KRENGINE_VBO_2D_SQUARE_VERTICES.load((void *)_KRENGINE_VBO_2D_SQUARE_VERTEX_DATA, sizeof(GLfloat) * 5 * 4);
|
||||||
static const __int32_t KRENGINE_VBO_2D_SQUARE_ATTRIBS = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA);
|
static const __int32_t KRENGINE_VBO_2D_SQUARE_ATTRIBS = (1 << KRMesh::KRENGINE_ATTRIB_VERTEX) | (1 << KRMesh::KRENGINE_ATTRIB_TEXUVA);
|
||||||
|
*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,26 +15,42 @@
|
|||||||
KRTexture::KRTexture(KRContext &context, std::string name) : KRResource(context, name)
|
KRTexture::KRTexture(KRContext &context, std::string name) : KRResource(context, name)
|
||||||
{
|
{
|
||||||
m_iHandle = 0;
|
m_iHandle = 0;
|
||||||
|
m_iNewHandle = 0;
|
||||||
m_textureMemUsed = 0;
|
m_textureMemUsed = 0;
|
||||||
|
m_newTextureMemUsed = 0;
|
||||||
m_last_frame_used = 0;
|
m_last_frame_used = 0;
|
||||||
|
m_last_frame_bound = 0;
|
||||||
|
m_handle_lock.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRTexture::~KRTexture()
|
KRTexture::~KRTexture()
|
||||||
{
|
{
|
||||||
releaseHandle();
|
releaseHandles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRTexture::releaseHandle() {
|
void KRTexture::releaseHandles() {
|
||||||
|
long mem_size = getMemSize();
|
||||||
|
|
||||||
|
while(m_handle_lock.test_and_set()); // Spin lock
|
||||||
|
|
||||||
|
if(m_iNewHandle != 0) {
|
||||||
|
GLDEBUG(glDeleteTextures(1, &m_iNewHandle));
|
||||||
|
m_iNewHandle = 0;
|
||||||
|
m_newTextureMemUsed = 0;
|
||||||
|
}
|
||||||
if(m_iHandle != 0) {
|
if(m_iHandle != 0) {
|
||||||
GLDEBUG(glDeleteTextures(1, &m_iHandle));
|
GLDEBUG(glDeleteTextures(1, &m_iHandle));
|
||||||
getContext().getTextureManager()->memoryChanged(-getMemSize());
|
|
||||||
m_iHandle = 0;
|
m_iHandle = 0;
|
||||||
m_textureMemUsed = 0;
|
m_textureMemUsed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_handle_lock.clear();
|
||||||
|
|
||||||
|
getContext().getTextureManager()->memoryChanged(-mem_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
long KRTexture::getMemSize() {
|
long KRTexture::getMemSize() {
|
||||||
return m_textureMemUsed; // TODO - This is not 100% accurate, as loaded format may differ in size while in GPU memory
|
return m_textureMemUsed + m_newTextureMemUsed; // TODO - This is not 100% accurate, as loaded format may differ in size while in GPU memory
|
||||||
}
|
}
|
||||||
|
|
||||||
long KRTexture::getReferencedMemSize() {
|
long KRTexture::getReferencedMemSize() {
|
||||||
@@ -44,42 +60,36 @@ long KRTexture::getReferencedMemSize() {
|
|||||||
|
|
||||||
void KRTexture::resize(int max_dim)
|
void KRTexture::resize(int max_dim)
|
||||||
{
|
{
|
||||||
if(max_dim == 0) {
|
if(!m_handle_lock.test_and_set())
|
||||||
releaseHandle();
|
{
|
||||||
} else {
|
if(m_iHandle == m_iNewHandle) {
|
||||||
int target_dim = max_dim;
|
if(max_dim == 0) {
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
m_iNewHandle = 0;
|
||||||
int requiredMemoryTransfer = getThroughputRequiredForResize(target_dim);
|
} else {
|
||||||
int requiredMemoryDelta = getMemRequiredForSize(target_dim) - getMemSize() - getReferencedMemSize();
|
int target_dim = max_dim;
|
||||||
|
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
||||||
if(requiredMemoryDelta) {
|
|
||||||
// Only resize / regenerate the texture if it actually changes the size of the texture (Assumption: textures of different sizes will always consume different amounts of memory)
|
if(m_current_lod_max_dim != target_dim || (m_iHandle == 0 && m_iNewHandle == 0)) {
|
||||||
|
assert(m_newTextureMemUsed == 0);
|
||||||
if(getContext().getTextureManager()->getMemoryTransferedThisFrame() + requiredMemoryTransfer > getContext().KRENGINE_MAX_TEXTURE_THROUGHPUT) {
|
m_newTextureMemUsed = getMemRequiredForSize(target_dim);
|
||||||
// Exceeding per-frame transfer throughput; can't resize now
|
|
||||||
return;
|
getContext().getTextureManager()->memoryChanged(m_newTextureMemUsed);
|
||||||
}
|
getContext().getTextureManager()->addMemoryTransferredThisFrame(m_newTextureMemUsed);
|
||||||
|
|
||||||
if(getContext().getTextureManager()->getMemUsed() + requiredMemoryDelta > getContext().KRENGINE_MAX_TEXTURE_MEM) {
|
if(!createGLTexture(target_dim)) {
|
||||||
// Exceeding total memory allocated to textures; can't resize now
|
getContext().getTextureManager()->memoryChanged(-m_newTextureMemUsed);
|
||||||
return;
|
m_newTextureMemUsed = 0;
|
||||||
}
|
assert(false);
|
||||||
|
}
|
||||||
if(m_current_lod_max_dim != target_dim || m_iHandle == 0) {
|
|
||||||
if(!createGLTexture(target_dim)) {
|
|
||||||
assert(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_handle_lock.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GLuint KRTexture::getHandle() {
|
GLuint KRTexture::getHandle() {
|
||||||
if(m_iHandle == 0) {
|
|
||||||
//resize(getContext().KRENGINE_MIN_TEXTURE_DIM);
|
|
||||||
resize(m_min_lod_max_dim);
|
|
||||||
}
|
|
||||||
resetPoolExpiry();
|
resetPoolExpiry();
|
||||||
return m_iHandle;
|
return m_iHandle;
|
||||||
}
|
}
|
||||||
@@ -89,34 +99,6 @@ void KRTexture::resetPoolExpiry()
|
|||||||
m_last_frame_used = getContext().getCurrentFrame();
|
m_last_frame_used = getContext().getCurrentFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
long KRTexture::getThroughputRequiredForResize(int max_dim)
|
|
||||||
{
|
|
||||||
// Calculate the throughput required for GPU texture upload if the texture is resized to max_dim.
|
|
||||||
// This default behaviour assumes that the texture will need to be deleted and regenerated to change the maximum mip-map level.
|
|
||||||
// If an OpenGL extension is present that allows a texture to be resized incrementally, then this method should be overridden
|
|
||||||
|
|
||||||
if(max_dim == 0) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
int target_dim = max_dim;
|
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = target_dim;
|
|
||||||
|
|
||||||
|
|
||||||
if(target_dim != m_current_lod_max_dim) {
|
|
||||||
int requiredMemory = getMemRequiredForSize(target_dim);
|
|
||||||
int requiredMemoryDelta = requiredMemory - getMemSize() - getReferencedMemSize();
|
|
||||||
|
|
||||||
if(requiredMemoryDelta == 0) {
|
|
||||||
// Only resize / regenerate the texture if it actually changes the size of the texture (Assumption: textures of different sizes will always consume different amounts of memory)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return requiredMemory;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long KRTexture::getLastFrameUsed()
|
long KRTexture::getLastFrameUsed()
|
||||||
{
|
{
|
||||||
return m_last_frame_used;
|
return m_last_frame_used;
|
||||||
@@ -147,3 +129,28 @@ int KRTexture::getMinMipMap() {
|
|||||||
bool KRTexture::hasMipmaps() {
|
bool KRTexture::hasMipmaps() {
|
||||||
return m_max_lod_max_dim != m_min_lod_max_dim;
|
return m_max_lod_max_dim != m_min_lod_max_dim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRTexture::bind(GLuint texture_unit) {
|
||||||
|
m_last_frame_bound = getContext().getCurrentFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KRTexture::canStreamOut() const {
|
||||||
|
return (m_last_frame_bound + 2 > getContext().getCurrentFrame());
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRTexture::_swapHandles()
|
||||||
|
{
|
||||||
|
if(!m_handle_lock.test_and_set()) {
|
||||||
|
if(m_iHandle != m_iNewHandle) {
|
||||||
|
if(m_iHandle != 0) {
|
||||||
|
GLDEBUG(glDeleteTextures(1, &m_iHandle));
|
||||||
|
getContext().getTextureManager()->memoryChanged(-m_textureMemUsed);
|
||||||
|
}
|
||||||
|
m_textureMemUsed = (long)m_newTextureMemUsed;
|
||||||
|
m_newTextureMemUsed = 0;
|
||||||
|
m_iHandle = m_iNewHandle;
|
||||||
|
}
|
||||||
|
m_handle_lock.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,13 +46,12 @@ public:
|
|||||||
KRTexture(KRContext &context, std::string name);
|
KRTexture(KRContext &context, std::string name);
|
||||||
virtual ~KRTexture();
|
virtual ~KRTexture();
|
||||||
|
|
||||||
virtual void bind(GLuint texture_unit) = 0;
|
virtual void bind(GLuint texture_unit);
|
||||||
void releaseHandle();
|
void releaseHandles();
|
||||||
long getMemSize();
|
long getMemSize();
|
||||||
virtual long getReferencedMemSize();
|
virtual long getReferencedMemSize();
|
||||||
|
|
||||||
virtual long getMemRequiredForSize(int max_dim) = 0;
|
virtual long getMemRequiredForSize(int max_dim) = 0;
|
||||||
virtual long getThroughputRequiredForResize(int max_dim);
|
|
||||||
virtual void resize(int max_dim);
|
virtual void resize(int max_dim);
|
||||||
|
|
||||||
long getLastFrameUsed();
|
long getLastFrameUsed();
|
||||||
@@ -66,13 +65,17 @@ public:
|
|||||||
int getMinMipMap();
|
int getMinMipMap();
|
||||||
bool hasMipmaps();
|
bool hasMipmaps();
|
||||||
|
|
||||||
|
bool canStreamOut() const;
|
||||||
|
|
||||||
|
void _swapHandles();
|
||||||
protected:
|
protected:
|
||||||
virtual bool createGLTexture(int lod_max_dim) = 0;
|
virtual bool createGLTexture(int lod_max_dim) = 0;
|
||||||
GLuint getHandle();
|
GLuint getHandle();
|
||||||
|
|
||||||
|
|
||||||
GLuint m_iHandle;
|
GLuint m_iHandle;
|
||||||
long m_textureMemUsed;
|
GLuint m_iNewHandle;
|
||||||
|
std::atomic_flag m_handle_lock;
|
||||||
|
|
||||||
int m_current_lod_max_dim;
|
int m_current_lod_max_dim;
|
||||||
|
|
||||||
@@ -80,6 +83,11 @@ protected:
|
|||||||
uint32_t m_min_lod_max_dim;
|
uint32_t m_min_lod_max_dim;
|
||||||
|
|
||||||
long m_last_frame_used;
|
long m_last_frame_used;
|
||||||
|
long m_last_frame_bound;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::atomic<long> m_textureMemUsed;
|
||||||
|
std::atomic<long> m_newTextureMemUsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,54 +43,47 @@ KRTexture2D::~KRTexture2D() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool KRTexture2D::createGLTexture(int lod_max_dim) {
|
bool KRTexture2D::createGLTexture(int lod_max_dim) {
|
||||||
|
if(m_iHandle != m_iNewHandle) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
GLuint prev_handle = 0;
|
|
||||||
int prev_lod_max_dim = 0;
|
int prev_lod_max_dim = 0;
|
||||||
long prev_mem_size = 0;
|
|
||||||
#if GL_APPLE_copy_texture_levels && GL_EXT_texture_storage
|
#if GL_APPLE_copy_texture_levels && GL_EXT_texture_storage
|
||||||
|
|
||||||
if(m_iHandle != 0) {
|
if(m_iHandle != 0) {
|
||||||
prev_handle = m_iHandle;
|
|
||||||
prev_mem_size = getMemSize();
|
|
||||||
m_iHandle = 0;
|
|
||||||
m_textureMemUsed = 0;
|
|
||||||
prev_lod_max_dim = m_current_lod_max_dim;
|
prev_lod_max_dim = m_current_lod_max_dim;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
releaseHandle();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m_iNewHandle = 0;
|
||||||
m_current_lod_max_dim = 0;
|
m_current_lod_max_dim = 0;
|
||||||
GLDEBUG(glGenTextures(1, &m_iHandle));
|
GLDEBUG(glGenTextures(1, &m_iNewHandle));
|
||||||
|
|
||||||
if(m_iHandle == 0) {
|
if(m_iNewHandle == 0) {
|
||||||
success = false;
|
success = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
GLDEBUG(glBindTexture(GL_TEXTURE_2D, m_iHandle));
|
GLDEBUG(glBindTexture(GL_TEXTURE_2D, m_iNewHandle));
|
||||||
if (hasMipmaps()) {
|
if (hasMipmaps()) {
|
||||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
|
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
|
||||||
} else {
|
} else {
|
||||||
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
GLDEBUG(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!uploadTexture(GL_TEXTURE_2D, lod_max_dim, m_current_lod_max_dim, m_textureMemUsed, prev_lod_max_dim, prev_handle)) {
|
if(!uploadTexture(GL_TEXTURE_2D, lod_max_dim, m_current_lod_max_dim, prev_lod_max_dim)) {
|
||||||
GLDEBUG(glDeleteTextures(1, &m_iHandle));
|
GLDEBUG(glDeleteTextures(1, &m_iNewHandle));
|
||||||
m_iHandle = 0;
|
m_iNewHandle = m_iHandle;
|
||||||
m_current_lod_max_dim = 0;
|
m_current_lod_max_dim = prev_lod_max_dim;
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(prev_handle != 0) {
|
|
||||||
getContext().getTextureManager()->memoryChanged(-prev_mem_size);
|
|
||||||
GLDEBUG(glDeleteTextures(1, &prev_handle));
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRTexture2D::bind(GLuint texture_unit) {
|
void KRTexture2D::bind(GLuint texture_unit) {
|
||||||
|
KRTexture::bind(texture_unit);
|
||||||
GLuint handle = getHandle();
|
GLuint handle = getHandle();
|
||||||
|
|
||||||
GLDEBUG(glBindTexture(GL_TEXTURE_2D, handle));
|
GLDEBUG(glBindTexture(GL_TEXTURE_2D, handle));
|
||||||
@@ -101,7 +94,6 @@ void KRTexture2D::bind(GLuint texture_unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KRTexture2D::save(const std::string& path)
|
bool KRTexture2D::save(const std::string& path)
|
||||||
{
|
{
|
||||||
if(m_pData) {
|
if(m_pData) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
virtual bool save(const std::string& path);
|
virtual bool save(const std::string& path);
|
||||||
virtual bool save(KRDataBlock &data);
|
virtual bool save(KRDataBlock &data);
|
||||||
|
|
||||||
virtual bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, long &textureMemUsed, int prev_lod_max_dim, GLuint prev_handle) = 0;
|
virtual bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, int prev_lod_max_dim) = 0;
|
||||||
virtual void bind(GLuint texture_unit);
|
virtual void bind(GLuint texture_unit);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ KRTextureAnimated::KRTextureAnimated(KRContext &context, std::string name) : KRT
|
|||||||
int second_comma_pos = name.find(",", first_comma_pos + 1);
|
int second_comma_pos = name.find(",", first_comma_pos + 1);
|
||||||
|
|
||||||
|
|
||||||
m_texture_base_name = name.substr(8, first_comma_pos - 9);
|
m_texture_base_name = name.substr(8, first_comma_pos - 8);
|
||||||
m_frame_count = atoi(name.substr(first_comma_pos+1, second_comma_pos - first_comma_pos -1).c_str());
|
m_frame_count = atoi(name.substr(first_comma_pos+1, second_comma_pos - first_comma_pos -1).c_str());
|
||||||
m_frame_rate = atof(name.substr(second_comma_pos+1).c_str());
|
m_frame_rate = atof(name.substr(second_comma_pos+1).c_str());
|
||||||
|
|
||||||
@@ -87,17 +87,7 @@ bool KRTextureAnimated::createGLTexture(int lod_max_dim)
|
|||||||
|
|
||||||
long KRTextureAnimated::getMemRequiredForSize(int max_dim)
|
long KRTextureAnimated::getMemRequiredForSize(int max_dim)
|
||||||
{
|
{
|
||||||
int target_dim = max_dim;
|
return 0; // Memory is allocated by individual frame textures
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
|
||||||
|
|
||||||
long memoryRequired = 0;
|
|
||||||
for(int i=0; i<m_frame_count; i++) {
|
|
||||||
KRTexture2D *frame_texture = textureForFrame(i);
|
|
||||||
if(frame_texture) {
|
|
||||||
memoryRequired += frame_texture->getMemRequiredForSize(target_dim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return memoryRequired;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,12 +98,15 @@ void KRTextureAnimated::resetPoolExpiry()
|
|||||||
KRTexture2D *frame_texture = textureForFrame(i);
|
KRTexture2D *frame_texture = textureForFrame(i);
|
||||||
if(frame_texture) {
|
if(frame_texture) {
|
||||||
frame_texture->resetPoolExpiry(); // Ensure that frames of animated textures do not expire from the texture pool prematurely, as they are referenced indirectly
|
frame_texture->resetPoolExpiry(); // Ensure that frames of animated textures do not expire from the texture pool prematurely, as they are referenced indirectly
|
||||||
|
getContext().getTextureManager()->primeTexture(frame_texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KRTextureAnimated::bind(GLuint texture_unit)
|
void KRTextureAnimated::bind(GLuint texture_unit)
|
||||||
{
|
{
|
||||||
|
resetPoolExpiry();
|
||||||
|
KRTexture::bind(texture_unit);
|
||||||
int frame_number = (int)floor(fmodf(getContext().getAbsoluteTime() * m_frame_rate,m_frame_count));
|
int frame_number = (int)floor(fmodf(getContext().getAbsoluteTime() * m_frame_rate,m_frame_count));
|
||||||
KRTexture2D *frame_texture = textureForFrame(frame_number);
|
KRTexture2D *frame_texture = textureForFrame(frame_number);
|
||||||
if(frame_texture) {
|
if(frame_texture) {
|
||||||
@@ -153,3 +146,7 @@ bool KRTextureAnimated::save(KRDataBlock &data)
|
|||||||
return true; // Animated textures are just references; there are no files to output
|
return true; // Animated textures are just references; there are no files to output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRTextureAnimated::resize(int max_dim)
|
||||||
|
{
|
||||||
|
// Purposely not calling the superclass method
|
||||||
|
}
|
||||||
@@ -50,6 +50,7 @@ public:
|
|||||||
virtual long getReferencedMemSize();
|
virtual long getReferencedMemSize();
|
||||||
|
|
||||||
virtual bool isAnimated();
|
virtual bool isAnimated();
|
||||||
|
virtual void resize(int max_dim);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool createGLTexture(int lod_max_dim);
|
virtual bool createGLTexture(int lod_max_dim);
|
||||||
|
|||||||
@@ -55,57 +55,45 @@ KRTextureCube::~KRTextureCube()
|
|||||||
|
|
||||||
bool KRTextureCube::createGLTexture(int lod_max_dim)
|
bool KRTextureCube::createGLTexture(int lod_max_dim)
|
||||||
{
|
{
|
||||||
|
assert(m_iNewHandle == m_iHandle); // Only allow one resize per frame
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
GLuint prev_handle = 0;
|
|
||||||
int prev_lod_max_dim = 0;
|
int prev_lod_max_dim = 0;
|
||||||
long prev_mem_size = 0;
|
|
||||||
#if GL_APPLE_copy_texture_levels && GL_EXT_texture_storage
|
#if GL_APPLE_copy_texture_levels && GL_EXT_texture_storage
|
||||||
|
|
||||||
if(m_iHandle != 0) {
|
if(m_iHandle != 0) {
|
||||||
prev_handle = m_iHandle;
|
|
||||||
prev_mem_size = getMemSize();
|
|
||||||
m_iHandle = 0;
|
|
||||||
m_textureMemUsed = 0;
|
|
||||||
prev_lod_max_dim = m_current_lod_max_dim;
|
prev_lod_max_dim = m_current_lod_max_dim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
releaseHandle();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
m_iNewHandle = 0;
|
||||||
|
GLDEBUG(glGenTextures(1, &m_iNewHandle));
|
||||||
|
assert(m_iNewHandle != 0);
|
||||||
|
|
||||||
m_current_lod_max_dim = 0;
|
m_current_lod_max_dim = 0;
|
||||||
GLDEBUG(glGenTextures(1, &m_iHandle));
|
GLDEBUG(glBindTexture(GL_TEXTURE_CUBE_MAP, m_iNewHandle));
|
||||||
if(m_iHandle == 0) {
|
|
||||||
success = false;
|
bool bMipMaps = false;
|
||||||
} else {
|
|
||||||
|
|
||||||
GLDEBUG(glBindTexture(GL_TEXTURE_CUBE_MAP, m_iHandle));
|
|
||||||
|
|
||||||
bool bMipMaps = false;
|
|
||||||
|
|
||||||
for(int i=0; i<6; i++) {
|
for(int i=0; i<6; i++) {
|
||||||
std::string faceName = getName() + SUFFIXES[i];
|
std::string faceName = getName() + SUFFIXES[i];
|
||||||
KRTexture2D *faceTexture = (KRTexture2D *)getContext().getTextureManager()->getTexture(faceName);
|
KRTexture2D *faceTexture = (KRTexture2D *)getContext().getTextureManager()->getTexture(faceName);
|
||||||
if(faceTexture) {
|
if(faceTexture) {
|
||||||
if(faceTexture->hasMipmaps()) bMipMaps = true;
|
if(faceTexture->hasMipmaps()) bMipMaps = true;
|
||||||
faceTexture->uploadTexture(TARGETS[i], lod_max_dim, m_current_lod_max_dim, m_textureMemUsed, prev_lod_max_dim, prev_handle);
|
faceTexture->uploadTexture(TARGETS[i], lod_max_dim, m_current_lod_max_dim, prev_lod_max_dim);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bMipMaps) {
|
|
||||||
GLDEBUG(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
|
|
||||||
} else {
|
|
||||||
// GLDEBUG(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
|
||||||
GLDEBUG(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
|
|
||||||
GLDEBUG(glGenerateMipmap(GL_TEXTURE_CUBE_MAP));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(prev_handle != 0) {
|
if(bMipMaps) {
|
||||||
getContext().getTextureManager()->memoryChanged(-prev_mem_size);
|
GLDEBUG(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
|
||||||
GLDEBUG(glDeleteTextures(1, &prev_handle));
|
} else {
|
||||||
|
// GLDEBUG(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
|
||||||
|
GLDEBUG(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
|
||||||
|
GLDEBUG(glGenerateMipmap(GL_TEXTURE_CUBE_MAP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -141,6 +129,7 @@ void KRTextureCube::resetPoolExpiry()
|
|||||||
|
|
||||||
void KRTextureCube::bind(GLuint texture_unit)
|
void KRTextureCube::bind(GLuint texture_unit)
|
||||||
{
|
{
|
||||||
|
KRTexture::bind(texture_unit);
|
||||||
GLuint handle = getHandle();
|
GLuint handle = getHandle();
|
||||||
GLDEBUG(glBindTexture(GL_TEXTURE_CUBE_MAP, handle));
|
GLDEBUG(glBindTexture(GL_TEXTURE_CUBE_MAP, handle));
|
||||||
if(handle) {
|
if(handle) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
#include "KRTextureAnimated.h"
|
#include "KRTextureAnimated.h"
|
||||||
#include "KRContext.h"
|
#include "KRContext.h"
|
||||||
|
|
||||||
KRTextureManager::KRTextureManager(KRContext &context) : KRContextObject(context) {
|
KRTextureManager::KRTextureManager(KRContext &context) : KRContextObject(context), m_streamer(context) {
|
||||||
m_textureMemUsed = 0;
|
m_textureMemUsed = 0;
|
||||||
|
|
||||||
for(int iTexture=0; iTexture<KRENGINE_MAX_TEXTURE_UNITS; iTexture++) {
|
for(int iTexture=0; iTexture<KRENGINE_MAX_TEXTURE_UNITS; iTexture++) {
|
||||||
@@ -161,7 +161,7 @@ KRTexture *KRTextureManager::getTexture(const std::string &name) {
|
|||||||
if(itr == m_textures.end()) {
|
if(itr == m_textures.end()) {
|
||||||
if(lowerName.length() <= 8) {
|
if(lowerName.length() <= 8) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if(lowerName.substr(8).compare("animate:") == 0) {
|
} else if(lowerName.compare(0, 8, "animate:", 0, 8) == 0) {
|
||||||
// This is an animated texture, create KRTextureAnimated's on-demand
|
// This is an animated texture, create KRTextureAnimated's on-demand
|
||||||
KRTextureAnimated *pTexture = new KRTextureAnimated(getContext(), lowerName);
|
KRTextureAnimated *pTexture = new KRTextureAnimated(getContext(), lowerName);
|
||||||
m_textures[lowerName] = pTexture;
|
m_textures[lowerName] = pTexture;
|
||||||
@@ -185,10 +185,8 @@ void KRTextureManager::selectTexture(int iTextureUnit, KRTexture *pTexture) {
|
|||||||
if(m_boundTextures[iTextureUnit] != pTexture || is_animated) {
|
if(m_boundTextures[iTextureUnit] != pTexture || is_animated) {
|
||||||
_setActiveTexture(iTextureUnit);
|
_setActiveTexture(iTextureUnit);
|
||||||
if(pTexture != NULL) {
|
if(pTexture != NULL) {
|
||||||
m_poolTextures.erase(pTexture);
|
primeTexture(pTexture);
|
||||||
if(m_activeTextures.find(pTexture) == m_activeTextures.end()) {
|
|
||||||
m_activeTextures.insert(pTexture);
|
|
||||||
}
|
|
||||||
pTexture->bind(iTextureUnit);
|
pTexture->bind(iTextureUnit);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -199,6 +197,14 @@ void KRTextureManager::selectTexture(int iTextureUnit, KRTexture *pTexture) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRTextureManager::primeTexture(KRTexture *pTexture)
|
||||||
|
{
|
||||||
|
m_poolTextures.erase(pTexture);
|
||||||
|
if(m_activeTextures.find(pTexture) == m_activeTextures.end()) {
|
||||||
|
m_activeTextures.insert(pTexture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
long KRTextureManager::getMemUsed() {
|
long KRTextureManager::getMemUsed() {
|
||||||
return m_textureMemUsed;
|
return m_textureMemUsed;
|
||||||
}
|
}
|
||||||
@@ -215,9 +221,20 @@ long KRTextureManager::getMemActive() {
|
|||||||
|
|
||||||
void KRTextureManager::startFrame(float deltaTime)
|
void KRTextureManager::startFrame(float deltaTime)
|
||||||
{
|
{
|
||||||
|
m_streamer.startStreamer();
|
||||||
_clearGLState();
|
_clearGLState();
|
||||||
|
for(std::set<KRTexture *>::iterator itr=m_activeTextures.begin(); itr != m_activeTextures.end(); itr++) {
|
||||||
|
KRTexture *activeTexture = *itr;
|
||||||
|
activeTexture->_swapHandles();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO - Implement proper double-buffering to reduce copy operations
|
||||||
|
m_streamerFenceMutex.lock();
|
||||||
|
m_activeTextures_streamer_copy = m_activeTextures;
|
||||||
|
m_poolTextures_streamer_copy = m_poolTextures;
|
||||||
|
m_streamerFenceMutex.unlock();
|
||||||
|
|
||||||
m_memoryTransferredThisFrame = 0;
|
m_memoryTransferredThisFrame = 0;
|
||||||
balanceTextureMemory();
|
|
||||||
rotateBuffers();
|
rotateBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +247,17 @@ void KRTextureManager::endFrame(float deltaTime)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRTextureManager::doStreaming()
|
||||||
|
{
|
||||||
|
// TODO - Implement proper double-buffering to reduce copy operations
|
||||||
|
m_streamerFenceMutex.lock();
|
||||||
|
m_activeTextures_streamer = m_activeTextures_streamer_copy;
|
||||||
|
m_poolTextures_streamer = m_poolTextures_streamer_copy;
|
||||||
|
m_streamerFenceMutex.unlock();
|
||||||
|
|
||||||
|
balanceTextureMemory();
|
||||||
|
}
|
||||||
|
|
||||||
void KRTextureManager::balanceTextureMemory()
|
void KRTextureManager::balanceTextureMemory()
|
||||||
{
|
{
|
||||||
// Balance texture memory by reducing and increasing the maximum mip-map level of both active and inactive textures
|
// Balance texture memory by reducing and increasing the maximum mip-map level of both active and inactive textures
|
||||||
@@ -237,14 +265,14 @@ void KRTextureManager::balanceTextureMemory()
|
|||||||
|
|
||||||
// Determine the additional amount of memory required in order to resize all active textures to the maximum size
|
// Determine the additional amount of memory required in order to resize all active textures to the maximum size
|
||||||
long wantedTextureMem = 0;
|
long wantedTextureMem = 0;
|
||||||
for(std::set<KRTexture *>::iterator itr=m_activeTextures.begin(); itr != m_activeTextures.end(); itr++) {
|
for(std::set<KRTexture *>::iterator itr=m_activeTextures_streamer.begin(); itr != m_activeTextures_streamer.end(); itr++) {
|
||||||
KRTexture *activeTexture = *itr;
|
KRTexture *activeTexture = *itr;
|
||||||
|
|
||||||
wantedTextureMem = activeTexture->getMemRequiredForSize(getContext().KRENGINE_MAX_TEXTURE_DIM) - activeTexture->getMemSize();
|
wantedTextureMem = activeTexture->getMemRequiredForSize(getContext().KRENGINE_MAX_TEXTURE_DIM) - activeTexture->getMemSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine how much memory we need to free up
|
// Determine how much memory we need to free up
|
||||||
long memoryDeficit = wantedTextureMem - (getContext().KRENGINE_MAX_TEXTURE_MEM - getMemUsed());
|
long memoryDeficit = wantedTextureMem - (getContext().KRENGINE_TARGET_TEXTURE_MEM_MAX - getMemUsed());
|
||||||
|
|
||||||
|
|
||||||
// Determine how many mip map levels we need to strip off of inactive textures to free the memory we need
|
// Determine how many mip map levels we need to strip off of inactive textures to free the memory we need
|
||||||
@@ -254,7 +282,7 @@ void KRTextureManager::balanceTextureMemory()
|
|||||||
maxDimInactive = maxDimInactive >> 1;
|
maxDimInactive = maxDimInactive >> 1;
|
||||||
potentialMemorySaving = 0;
|
potentialMemorySaving = 0;
|
||||||
|
|
||||||
for(std::set<KRTexture *>::iterator itr=m_poolTextures.begin(); itr != m_poolTextures.end(); itr++) {
|
for(std::set<KRTexture *>::iterator itr=m_poolTextures_streamer.begin(); itr != m_poolTextures_streamer.end(); itr++) {
|
||||||
KRTexture *poolTexture = *itr;
|
KRTexture *poolTexture = *itr;
|
||||||
long potentialMemoryDelta = poolTexture->getMemRequiredForSize(maxDimInactive) - poolTexture->getMemSize();
|
long potentialMemoryDelta = poolTexture->getMemRequiredForSize(maxDimInactive) - poolTexture->getMemSize();
|
||||||
if(potentialMemoryDelta < 0) {
|
if(potentialMemoryDelta < 0) {
|
||||||
@@ -265,12 +293,19 @@ void KRTextureManager::balanceTextureMemory()
|
|||||||
|
|
||||||
// Strip off mipmap levels of inactive textures to free up memory
|
// Strip off mipmap levels of inactive textures to free up memory
|
||||||
long inactive_texture_mem_used_target = 0;
|
long inactive_texture_mem_used_target = 0;
|
||||||
for(std::set<KRTexture *>::iterator itr=m_poolTextures.begin(); itr != m_poolTextures.end(); itr++) {
|
for(std::set<KRTexture *>::iterator itr=m_poolTextures_streamer.begin(); itr != m_poolTextures_streamer.end(); itr++) {
|
||||||
KRTexture *poolTexture = *itr;
|
KRTexture *poolTexture = *itr;
|
||||||
long potentialMemoryDelta = poolTexture->getMemRequiredForSize(maxDimInactive) - poolTexture->getMemSize();
|
long mem_required = poolTexture->getMemRequiredForSize(maxDimInactive);
|
||||||
|
long potentialMemoryDelta = mem_required - poolTexture->getMemSize();
|
||||||
if(potentialMemoryDelta < 0) {
|
if(potentialMemoryDelta < 0) {
|
||||||
poolTexture->resize(maxDimInactive);
|
if(mem_required * 2 + getMemUsed() < KRContext::KRENGINE_MAX_TEXTURE_MEM) {
|
||||||
inactive_texture_mem_used_target += poolTexture->getMemRequiredForSize(maxDimInactive);
|
long mem_free;
|
||||||
|
m_pContext->getMemoryStats(mem_free);
|
||||||
|
if(mem_required * 2 < mem_free - 10000000) {
|
||||||
|
poolTexture->resize(maxDimInactive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inactive_texture_mem_used_target += mem_required;
|
||||||
} else {
|
} else {
|
||||||
inactive_texture_mem_used_target += poolTexture->getMemSize();
|
inactive_texture_mem_used_target += poolTexture->getMemSize();
|
||||||
}
|
}
|
||||||
@@ -280,8 +315,8 @@ void KRTextureManager::balanceTextureMemory()
|
|||||||
long memory_available = 0;
|
long memory_available = 0;
|
||||||
long maxDimActive = getContext().KRENGINE_MAX_TEXTURE_DIM;
|
long maxDimActive = getContext().KRENGINE_MAX_TEXTURE_DIM;
|
||||||
while(memory_available <= 0 && maxDimActive >= getContext().KRENGINE_MIN_TEXTURE_DIM) {
|
while(memory_available <= 0 && maxDimActive >= getContext().KRENGINE_MIN_TEXTURE_DIM) {
|
||||||
memory_available = getContext().KRENGINE_MAX_TEXTURE_MEM - inactive_texture_mem_used_target;
|
memory_available = getContext().KRENGINE_TARGET_TEXTURE_MEM_MAX - inactive_texture_mem_used_target;
|
||||||
for(std::set<KRTexture *>::iterator itr=m_activeTextures.begin(); itr != m_activeTextures.end() && memory_available > 0; itr++) {
|
for(std::set<KRTexture *>::iterator itr=m_activeTextures_streamer.begin(); itr != m_activeTextures_streamer.end() && memory_available > 0; itr++) {
|
||||||
KRTexture *activeTexture = *itr;
|
KRTexture *activeTexture = *itr;
|
||||||
memory_available -= activeTexture->getMemRequiredForSize(maxDimActive);
|
memory_available -= activeTexture->getMemRequiredForSize(maxDimActive);
|
||||||
}
|
}
|
||||||
@@ -292,9 +327,16 @@ void KRTextureManager::balanceTextureMemory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resize active textures to balance the memory usage and mipmap levels
|
// Resize active textures to balance the memory usage and mipmap levels
|
||||||
for(std::set<KRTexture *>::iterator itr=m_activeTextures.begin(); itr != m_activeTextures.end() && memory_available > 0; itr++) {
|
for(std::set<KRTexture *>::iterator itr=m_activeTextures_streamer.begin(); itr != m_activeTextures_streamer.end() && memory_available > 0; itr++) {
|
||||||
KRTexture *activeTexture = *itr;
|
KRTexture *activeTexture = *itr;
|
||||||
activeTexture->resize(maxDimActive);
|
long mem_required = activeTexture->getMemRequiredForSize(maxDimActive);
|
||||||
|
if(mem_required * 2 + getMemUsed() < KRContext::KRENGINE_MAX_TEXTURE_MEM) {
|
||||||
|
long mem_free;
|
||||||
|
m_pContext->getMemoryStats(mem_free);
|
||||||
|
if(mem_required * 2 < mem_free - 10000000) {
|
||||||
|
activeTexture->resize(maxDimActive);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr, "Active mipmap size: %i Inactive mapmap size: %i\n", (int)maxDimActive, (int)maxDimInactive);
|
//fprintf(stderr, "Active mipmap size: %i Inactive mapmap size: %i\n", (int)maxDimActive, (int)maxDimInactive);
|
||||||
@@ -310,7 +352,7 @@ void KRTextureManager::rotateBuffers()
|
|||||||
KRTexture *poolTexture = *itr;
|
KRTexture *poolTexture = *itr;
|
||||||
if(poolTexture->getLastFrameUsed() + KRENGINE_TEXTURE_EXPIRY_FRAMES < getContext().getCurrentFrame()) {
|
if(poolTexture->getLastFrameUsed() + KRENGINE_TEXTURE_EXPIRY_FRAMES < getContext().getCurrentFrame()) {
|
||||||
expiredTextures.insert(poolTexture);
|
expiredTextures.insert(poolTexture);
|
||||||
poolTexture->releaseHandle();
|
poolTexture->releaseHandles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(std::set<KRTexture *>::iterator itr=expiredTextures.begin(); itr != expiredTextures.end(); itr++) {
|
for(std::set<KRTexture *>::iterator itr=expiredTextures.begin(); itr != expiredTextures.end(); itr++) {
|
||||||
@@ -318,6 +360,7 @@ void KRTextureManager::rotateBuffers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----====---- Swap the buffers ----====----
|
// ----====---- Swap the buffers ----====----
|
||||||
|
|
||||||
m_poolTextures.insert(m_activeTextures.begin(), m_activeTextures.end());
|
m_poolTextures.insert(m_activeTextures.begin(), m_activeTextures.end());
|
||||||
m_activeTextures.clear();
|
m_activeTextures.clear();
|
||||||
}
|
}
|
||||||
@@ -335,6 +378,7 @@ void KRTextureManager::addMemoryTransferredThisFrame(long memoryTransferred)
|
|||||||
void KRTextureManager::memoryChanged(long memoryDelta)
|
void KRTextureManager::memoryChanged(long memoryDelta)
|
||||||
{
|
{
|
||||||
m_textureMemUsed += memoryDelta;
|
m_textureMemUsed += memoryDelta;
|
||||||
|
//fprintf(stderr, "Texture Memory: %ld / %i\n", (long)m_textureMemUsed, KRContext::KRENGINE_MAX_TEXTURE_MEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
unordered_map<std::string, KRTexture *> &KRTextureManager::getTextures()
|
unordered_map<std::string, KRTexture *> &KRTextureManager::getTextures()
|
||||||
|
|||||||
@@ -39,12 +39,14 @@
|
|||||||
#include "KREngine-common.h"
|
#include "KREngine-common.h"
|
||||||
#include "KRDataBlock.h"
|
#include "KRDataBlock.h"
|
||||||
#include "KRContext.h"
|
#include "KRContext.h"
|
||||||
|
#include "KRTextureStreamer.h"
|
||||||
|
|
||||||
class KRTextureManager : public KRContextObject {
|
class KRTextureManager : public KRContextObject {
|
||||||
public:
|
public:
|
||||||
KRTextureManager(KRContext &context);
|
KRTextureManager(KRContext &context);
|
||||||
virtual ~KRTextureManager();
|
virtual ~KRTextureManager();
|
||||||
|
|
||||||
|
void primeTexture(KRTexture *pTexture);
|
||||||
void selectTexture(int iTextureUnit, KRTexture *pTexture);
|
void selectTexture(int iTextureUnit, KRTexture *pTexture);
|
||||||
|
|
||||||
KRTexture *loadTexture(const char *szName, const char *szExtension, KRDataBlock *data);
|
KRTexture *loadTexture(const char *szName, const char *szExtension, KRDataBlock *data);
|
||||||
@@ -77,6 +79,8 @@ public:
|
|||||||
void _clearGLState();
|
void _clearGLState();
|
||||||
void setMaxAnisotropy(float max_anisotropy);
|
void setMaxAnisotropy(float max_anisotropy);
|
||||||
|
|
||||||
|
void doStreaming();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_iActiveTexture;
|
int m_iActiveTexture;
|
||||||
|
|
||||||
@@ -88,13 +92,24 @@ private:
|
|||||||
GLuint m_wrapModeS[KRENGINE_MAX_TEXTURE_UNITS];
|
GLuint m_wrapModeS[KRENGINE_MAX_TEXTURE_UNITS];
|
||||||
GLuint m_wrapModeT[KRENGINE_MAX_TEXTURE_UNITS];
|
GLuint m_wrapModeT[KRENGINE_MAX_TEXTURE_UNITS];
|
||||||
float m_maxAnisotropy[KRENGINE_MAX_TEXTURE_UNITS];
|
float m_maxAnisotropy[KRENGINE_MAX_TEXTURE_UNITS];
|
||||||
|
|
||||||
|
|
||||||
std::set<KRTexture *> m_activeTextures;
|
std::set<KRTexture *> m_activeTextures;
|
||||||
std::set<KRTexture *> m_poolTextures;
|
std::set<KRTexture *> m_poolTextures;
|
||||||
|
|
||||||
long m_textureMemUsed;
|
std::set<KRTexture *> m_activeTextures_streamer;
|
||||||
|
std::set<KRTexture *> m_poolTextures_streamer;
|
||||||
|
std::set<KRTexture *> m_activeTextures_streamer_copy;
|
||||||
|
std::set<KRTexture *> m_poolTextures_streamer_copy;
|
||||||
|
|
||||||
|
std::atomic<long> m_textureMemUsed;
|
||||||
|
|
||||||
void rotateBuffers();
|
void rotateBuffers();
|
||||||
void balanceTextureMemory();
|
void balanceTextureMemory();
|
||||||
|
|
||||||
|
KRTextureStreamer m_streamer;
|
||||||
|
|
||||||
|
std::mutex m_streamerFenceMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -64,8 +64,11 @@ typedef struct _PVRTexHeader
|
|||||||
|
|
||||||
KRTexturePVR::KRTexturePVR(KRContext &context, KRDataBlock *data, std::string name) : KRTexture2D(context, data, name) {
|
KRTexturePVR::KRTexturePVR(KRContext &context, KRDataBlock *data, std::string name) : KRTexture2D(context, data, name) {
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
PVRTexHeader *header = (PVRTexHeader *)m_pData->getStart();
|
|
||||||
uint32_t formatFlags = header->flags & PVR_TEXTURE_FLAG_TYPE_MASK;
|
PVRTexHeader header;
|
||||||
|
m_pData->copy(&header, 0, sizeof(PVRTexHeader));
|
||||||
|
|
||||||
|
uint32_t formatFlags = header.flags & PVR_TEXTURE_FLAG_TYPE_MASK;
|
||||||
if (formatFlags == kPVRTextureFlagTypePVRTC_4) {
|
if (formatFlags == kPVRTextureFlagTypePVRTC_4) {
|
||||||
m_internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
m_internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
||||||
} else if(formatFlags == kPVRTextureFlagTypePVRTC_2) {
|
} else if(formatFlags == kPVRTextureFlagTypePVRTC_2) {
|
||||||
@@ -74,7 +77,7 @@ KRTexturePVR::KRTexturePVR(KRContext &context, KRDataBlock *data, std::string na
|
|||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pvrTag = header->pvrTag;
|
uint32_t pvrTag = header.pvrTag;
|
||||||
if (gPVRTexIdentifier[0] != ((pvrTag >> 0) & 0xff) ||
|
if (gPVRTexIdentifier[0] != ((pvrTag >> 0) & 0xff) ||
|
||||||
gPVRTexIdentifier[1] != ((pvrTag >> 8) & 0xff) ||
|
gPVRTexIdentifier[1] != ((pvrTag >> 8) & 0xff) ||
|
||||||
gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) ||
|
gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) ||
|
||||||
@@ -82,12 +85,12 @@ KRTexturePVR::KRTexturePVR(KRContext &context, KRDataBlock *data, std::string na
|
|||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iWidth = header->width; // Note: call __builtin_bswap32 when needed to switch endianness
|
m_iWidth = header.width; // Note: call __builtin_bswap32 when needed to switch endianness
|
||||||
m_iHeight = header->height;
|
m_iHeight = header.height;
|
||||||
m_bHasAlpha = header->bitmaskAlpha;
|
m_bHasAlpha = header.bitmaskAlpha;
|
||||||
|
|
||||||
uint8_t *bytes = ((uint8_t *)m_pData->getStart()) + sizeof(PVRTexHeader);
|
uint32_t dataStart = sizeof(PVRTexHeader);
|
||||||
uint32_t dataLength = header->dataLength, dataOffset = 0, dataSize = 0;
|
uint32_t dataLength = header.dataLength, dataOffset = 0, dataSize = 0;
|
||||||
uint32_t width = m_iWidth, height = m_iHeight, bpp = 4;
|
uint32_t width = m_iWidth, height = m_iHeight, bpp = 4;
|
||||||
uint32_t blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
uint32_t blockSize = 0, widthBlocks = 0, heightBlocks = 0;
|
||||||
|
|
||||||
@@ -114,11 +117,7 @@ KRTexturePVR::KRTexturePVR(KRContext &context, KRDataBlock *data, std::string na
|
|||||||
}
|
}
|
||||||
dataSize = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
|
dataSize = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
|
||||||
|
|
||||||
dataBlockStruct newBlock;
|
m_blocks.push_back(m_pData->getSubBlock(dataStart + dataOffset, dataSize));
|
||||||
newBlock.start = bytes+dataOffset;
|
|
||||||
newBlock.length = dataSize;
|
|
||||||
|
|
||||||
m_blocks.push_back(newBlock);
|
|
||||||
|
|
||||||
dataOffset += dataSize;
|
dataOffset += dataSize;
|
||||||
|
|
||||||
@@ -134,12 +133,15 @@ KRTexturePVR::KRTexturePVR(KRContext &context, KRDataBlock *data, std::string na
|
|||||||
|
|
||||||
m_max_lod_max_dim = m_iWidth > m_iHeight ? m_iWidth : m_iHeight;
|
m_max_lod_max_dim = m_iWidth > m_iHeight ? m_iWidth : m_iHeight;
|
||||||
m_min_lod_max_dim = width > height ? width : height;
|
m_min_lod_max_dim = width > height ? width : height;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
KRTexturePVR::~KRTexturePVR() {
|
KRTexturePVR::~KRTexturePVR() {
|
||||||
|
for(std::list<KRDataBlock *>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
||||||
|
KRDataBlock *block = *itr;
|
||||||
|
delete block;
|
||||||
|
}
|
||||||
|
m_blocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
long KRTexturePVR::getMemRequiredForSize(int max_dim)
|
long KRTexturePVR::getMemRequiredForSize(int max_dim)
|
||||||
@@ -152,10 +154,10 @@ long KRTexturePVR::getMemRequiredForSize(int max_dim)
|
|||||||
int height = m_iHeight;
|
int height = m_iHeight;
|
||||||
long memoryRequired = 0;
|
long memoryRequired = 0;
|
||||||
|
|
||||||
for(std::list<dataBlockStruct>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
for(std::list<KRDataBlock *>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
||||||
dataBlockStruct block = *itr;
|
KRDataBlock *block = *itr;
|
||||||
if(width <= target_dim && height <= target_dim) {
|
if(width <= target_dim && height <= target_dim) {
|
||||||
memoryRequired += block.length;
|
memoryRequired += block->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
width = width >> 1;
|
width = width >> 1;
|
||||||
@@ -171,13 +173,11 @@ long KRTexturePVR::getMemRequiredForSize(int max_dim)
|
|||||||
return memoryRequired;
|
return memoryRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, long &textureMemUsed, int prev_lod_max_dim, GLuint prev_handle)
|
bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, int prev_lod_max_dim)
|
||||||
{
|
{
|
||||||
int target_dim = lod_max_dim;
|
int target_dim = lod_max_dim;
|
||||||
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
if(target_dim < m_min_lod_max_dim) target_dim = m_min_lod_max_dim;
|
||||||
|
|
||||||
GLenum err;
|
|
||||||
|
|
||||||
if(m_blocks.size() == 0) {
|
if(m_blocks.size() == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
|||||||
int level_count=0;
|
int level_count=0;
|
||||||
int max_lod_width=0;
|
int max_lod_width=0;
|
||||||
int max_lod_height=0;
|
int max_lod_height=0;
|
||||||
for(std::list<dataBlockStruct>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
for(std::list<KRDataBlock *>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
||||||
if(width <= target_dim && height <= target_dim) {
|
if(width <= target_dim && height <= target_dim) {
|
||||||
if(max_lod_width == 0) {
|
if(max_lod_width == 0) {
|
||||||
max_lod_width = width;
|
max_lod_width = width;
|
||||||
@@ -229,8 +229,8 @@ bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
|||||||
// Upload texture data
|
// Upload texture data
|
||||||
int destination_level=0;
|
int destination_level=0;
|
||||||
int source_level = 0;
|
int source_level = 0;
|
||||||
for(std::list<dataBlockStruct>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
for(std::list<KRDataBlock *>::iterator itr = m_blocks.begin(); itr != m_blocks.end(); itr++) {
|
||||||
dataBlockStruct block = *itr;
|
KRDataBlock *block = *itr;
|
||||||
if(width <= target_dim && height <= target_dim) {
|
if(width <= target_dim && height <= target_dim) {
|
||||||
|
|
||||||
if(width > current_lod_max_dim) {
|
if(width > current_lod_max_dim) {
|
||||||
@@ -243,22 +243,25 @@ bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
|||||||
if(target == GL_TEXTURE_2D && width <= prev_lod_max_dim && height <= prev_lod_max_dim) {
|
if(target == GL_TEXTURE_2D && width <= prev_lod_max_dim && height <= prev_lod_max_dim) {
|
||||||
//GLDEBUG(glCompressedTexImage2D(target, i, m_internalFormat, width, height, 0, block.length, NULL)); // Allocate, but don't copy
|
//GLDEBUG(glCompressedTexImage2D(target, i, m_internalFormat, width, height, 0, block.length, NULL)); // Allocate, but don't copy
|
||||||
// GLDEBUG(glTexImage2D(target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));
|
// GLDEBUG(glTexImage2D(target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));
|
||||||
GLDEBUG(glCopyTextureLevelsAPPLE(m_iHandle, prev_handle, source_level, 1));
|
GLDEBUG(glCopyTextureLevelsAPPLE(m_iNewHandle, m_iHandle, source_level, 1));
|
||||||
} else {
|
} else {
|
||||||
// glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
|
block->lock();
|
||||||
GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, m_internalFormat, block.length, block.start));
|
GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, m_internalFormat, (GLsizei)block->getSize(), block->getStart()));
|
||||||
// GLDEBUG(glCompressedTexImage2D(target, destination_level, m_internalFormat, width, height, 0, block.length, block.start));
|
block->unlock();
|
||||||
memoryTransferred += block.length; // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE
|
|
||||||
|
memoryTransferred += block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
block->lock();
|
||||||
#if GL_EXT_texture_storage
|
#if GL_EXT_texture_storage
|
||||||
GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, m_internalFormat, block.length, block.start));
|
GLDEBUG(glCompressedTexSubImage2D(target, destination_level, 0, 0, width, height, m_internalFormat, block->getSize(), block->getStart()));
|
||||||
#else
|
#else
|
||||||
GLDEBUG(glCompressedTexImage2D(target, destination_level, m_internalFormat, width, height, 0, block.length, block.start));
|
GLDEBUG(glCompressedTexImage2D(target, destination_level, m_internalFormat, width, height, 0, block->getSize(), block->getStart()));
|
||||||
#endif
|
#endif
|
||||||
memoryTransferred += block.length; // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE
|
block->unlock();
|
||||||
|
memoryTransferred += block->getSize(); // memoryTransferred does not include throughput of mipmap levels copied through glCopyTextureLevelsAPPLE
|
||||||
#endif
|
#endif
|
||||||
memoryRequired += block.length;
|
memoryRequired += block->getSize();
|
||||||
//
|
//
|
||||||
// err = glGetError();
|
// err = glGetError();
|
||||||
// if (err != GL_NO_ERROR) {
|
// if (err != GL_NO_ERROR) {
|
||||||
@@ -284,10 +287,6 @@ bool KRTexturePVR::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textureMemUsed += memoryRequired;
|
|
||||||
getContext().getTextureManager()->memoryChanged(memoryTransferred);
|
|
||||||
getContext().getTextureManager()->addMemoryTransferredThisFrame(memoryTransferred);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
virtual ~KRTexturePVR();
|
virtual ~KRTexturePVR();
|
||||||
virtual std::string getExtension();
|
virtual std::string getExtension();
|
||||||
|
|
||||||
bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, long &textureMemUsed, int prev_lod_max_dim, GLuint prev_handle);
|
bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, int prev_lod_max_dim);
|
||||||
|
|
||||||
virtual long getMemRequiredForSize(int max_dim);
|
virtual long getMemRequiredForSize(int max_dim);
|
||||||
|
|
||||||
@@ -29,12 +29,7 @@ protected:
|
|||||||
GLenum m_internalFormat;
|
GLenum m_internalFormat;
|
||||||
bool m_bHasAlpha;
|
bool m_bHasAlpha;
|
||||||
|
|
||||||
struct dataBlockStruct {
|
std::list<KRDataBlock *> m_blocks;
|
||||||
void *start;
|
|
||||||
uint32_t length;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::list<dataBlockStruct> m_blocks;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
60
KREngine/kraken/KRTextureStreamer.h
Normal file
60
KREngine/kraken/KRTextureStreamer.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// KRTextureManager.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 KRTEXTURESTREAMER_H
|
||||||
|
#define KRTEXTURESTREAMER_H
|
||||||
|
|
||||||
|
#include "KREngine-common.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
class KRContext;
|
||||||
|
|
||||||
|
class KRTextureStreamer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KRTextureStreamer(KRContext &context);
|
||||||
|
~KRTextureStreamer();
|
||||||
|
|
||||||
|
void startStreamer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
KRContext &m_context;
|
||||||
|
|
||||||
|
std::thread m_thread;
|
||||||
|
std::atomic<bool> m_stop;
|
||||||
|
std::atomic<bool> m_running;
|
||||||
|
|
||||||
|
void run();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* defined(KRTEXTURESTREAMER_H) */
|
||||||
97
KREngine/kraken/KRTextureStreamer.mm
Normal file
97
KREngine/kraken/KRTextureStreamer.mm
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
//
|
||||||
|
// KRTextureStreamer.cpp
|
||||||
|
// Kraken
|
||||||
|
//
|
||||||
|
// Created by Kearwood Gilbert on 11/1/2013.
|
||||||
|
// Copyright (c) 2013 Kearwood Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "KREngine-common.h"
|
||||||
|
|
||||||
|
#include "KRTextureStreamer.h"
|
||||||
|
#include "KRContext.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
|
EAGLContext *gTextureStreamerContext = nil;
|
||||||
|
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
|
||||||
|
NSOpenGLContext *gTextureStreamerContext = nil;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#error Unsupported Platform
|
||||||
|
#endif
|
||||||
|
|
||||||
|
KRTextureStreamer::KRTextureStreamer(KRContext &context) : m_context(context)
|
||||||
|
{
|
||||||
|
m_running = false;
|
||||||
|
m_stop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRTextureStreamer::startStreamer()
|
||||||
|
{
|
||||||
|
if(!m_running) {
|
||||||
|
m_running = true;
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
|
||||||
|
gTextureStreamerContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: [EAGLContext currentContext].sharegroup];
|
||||||
|
|
||||||
|
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
|
||||||
|
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] =
|
||||||
|
{
|
||||||
|
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes] autorelease];
|
||||||
|
gTextureStreamerContext = [[[NSOpenGLContext alloc] initWithFormat: pixelFormat shareContext: [NSOpenGLContext currentContext] ] autorelease];
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#error Unsupported Platform
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_thread = std::thread(&KRTextureStreamer::run, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KRTextureStreamer::~KRTextureStreamer()
|
||||||
|
{
|
||||||
|
if(m_running) {
|
||||||
|
m_stop = true;
|
||||||
|
m_thread.join();
|
||||||
|
m_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[gTextureStreamerContext release];
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRTextureStreamer::run()
|
||||||
|
{
|
||||||
|
pthread_setname_np("Kraken - Texture Streamer");
|
||||||
|
|
||||||
|
std::chrono::microseconds sleep_duration( 100 );
|
||||||
|
|
||||||
|
#if TARGET_OS_IPHONE
|
||||||
|
[EAGLContext setCurrentContext: gTextureStreamerContext];
|
||||||
|
#elif TARGET_OS_MAC
|
||||||
|
[gTextureStreamerContext makeCurrentContext];
|
||||||
|
#else
|
||||||
|
#error Unsupported Platform
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while(!m_stop)
|
||||||
|
{
|
||||||
|
if(m_context.getStreamingEnabled()) {
|
||||||
|
m_context.getTextureManager()->doStreaming();
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for( sleep_duration );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,10 +28,40 @@ typedef struct {
|
|||||||
|
|
||||||
KRTextureTGA::KRTextureTGA(KRContext &context, KRDataBlock *data, std::string name) : KRTexture2D(context, data, name)
|
KRTextureTGA::KRTextureTGA(KRContext &context, KRDataBlock *data, std::string name) : KRTexture2D(context, data, name)
|
||||||
{
|
{
|
||||||
|
data->lock();
|
||||||
TGA_HEADER *pHeader = (TGA_HEADER *)data->getStart();
|
TGA_HEADER *pHeader = (TGA_HEADER *)data->getStart();
|
||||||
|
|
||||||
m_max_lod_max_dim = pHeader->width > pHeader->height ? pHeader->width : pHeader->height;
|
m_max_lod_max_dim = pHeader->width > pHeader->height ? pHeader->width : pHeader->height;
|
||||||
m_min_lod_max_dim = m_max_lod_max_dim; // Mipmaps not yet supported for TGA images
|
m_min_lod_max_dim = m_max_lod_max_dim; // Mipmaps not yet supported for TGA images
|
||||||
|
switch(pHeader->imagetype) {
|
||||||
|
case 2: // rgb
|
||||||
|
switch(pHeader->bitsperpixel) {
|
||||||
|
case 24:
|
||||||
|
{
|
||||||
|
m_imageSize = pHeader->width * pHeader->height * 4;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
{
|
||||||
|
m_imageSize = pHeader->width * pHeader->height * 4;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
assert(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRTextureTGA::~KRTextureTGA()
|
KRTextureTGA::~KRTextureTGA()
|
||||||
@@ -39,12 +69,14 @@ KRTextureTGA::~KRTextureTGA()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, long &textureMemUsed, int prev_lod_max_dim, GLuint prev_handle)
|
bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, int prev_lod_max_dim)
|
||||||
{
|
{
|
||||||
|
m_pData->lock();
|
||||||
TGA_HEADER *pHeader = (TGA_HEADER *)m_pData->getStart();
|
TGA_HEADER *pHeader = (TGA_HEADER *)m_pData->getStart();
|
||||||
unsigned char *pData = (unsigned char *)pHeader + (long)pHeader->idlength + (long)pHeader->colourmaplength * (long)pHeader->colourmaptype + sizeof(TGA_HEADER);
|
unsigned char *pData = (unsigned char *)pHeader + (long)pHeader->idlength + (long)pHeader->colourmaplength * (long)pHeader->colourmaptype + sizeof(TGA_HEADER);
|
||||||
|
|
||||||
if(pHeader->colourmaptype != 0) {
|
if(pHeader->colourmaptype != 0) {
|
||||||
|
m_pData->unlock();
|
||||||
return false; // Mapped colors not supported
|
return false; // Mapped colors not supported
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,15 +105,12 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
|||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
glTexImage2D(target, 0, GL_RGBA, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image);
|
glTexImage2D(target, 0, GL_RGBA, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)converted_image);
|
||||||
delete converted_image;
|
free(converted_image);
|
||||||
err = glGetError();
|
err = glGetError();
|
||||||
if (err != GL_NO_ERROR) {
|
if (err != GL_NO_ERROR) {
|
||||||
|
m_pData->unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int memAllocated = pHeader->width * pHeader->height * 4;
|
|
||||||
textureMemUsed += memAllocated;
|
|
||||||
getContext().getTextureManager()->memoryChanged(memAllocated);
|
|
||||||
getContext().getTextureManager()->addMemoryTransferredThisFrame(memAllocated);
|
|
||||||
current_lod_max_dim = m_max_lod_max_dim;
|
current_lod_max_dim = m_max_lod_max_dim;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -90,47 +119,29 @@ bool KRTextureTGA::uploadTexture(GLenum target, int lod_max_dim, int ¤t_lo
|
|||||||
glTexImage2D(target, 0, GL_RGBA, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)pData);
|
glTexImage2D(target, 0, GL_RGBA, pHeader->width, pHeader->height, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid *)pData);
|
||||||
err = glGetError();
|
err = glGetError();
|
||||||
if (err != GL_NO_ERROR) {
|
if (err != GL_NO_ERROR) {
|
||||||
|
m_pData->unlock();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int memAllocated = pHeader->width * pHeader->height * 4;
|
|
||||||
textureMemUsed += memAllocated;
|
|
||||||
getContext().getTextureManager()->memoryChanged(memAllocated);
|
|
||||||
getContext().getTextureManager()->addMemoryTransferredThisFrame(memAllocated);
|
|
||||||
current_lod_max_dim = m_max_lod_max_dim;
|
current_lod_max_dim = m_max_lod_max_dim;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
m_pData->unlock();
|
||||||
return false; // 16-bit images not yet supported
|
return false; // 16-bit images not yet supported
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
m_pData->unlock();
|
||||||
return false; // Image type not yet supported
|
return false; // Image type not yet supported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_pData->unlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
long KRTextureTGA::getMemRequiredForSize(int max_dim)
|
long KRTextureTGA::getMemRequiredForSize(int max_dim)
|
||||||
{
|
{
|
||||||
TGA_HEADER *pHeader = (TGA_HEADER *)m_pData->getStart();
|
return m_imageSize;
|
||||||
switch(pHeader->imagetype) {
|
|
||||||
case 2: // rgb
|
|
||||||
switch(pHeader->bitsperpixel) {
|
|
||||||
case 24:
|
|
||||||
{
|
|
||||||
return pHeader->width * pHeader->height * 4;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 32:
|
|
||||||
{
|
|
||||||
return pHeader->width * pHeader->height * 4;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string KRTextureTGA::getExtension()
|
std::string KRTextureTGA::getExtension()
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ public:
|
|||||||
virtual ~KRTextureTGA();
|
virtual ~KRTextureTGA();
|
||||||
virtual std::string getExtension();
|
virtual std::string getExtension();
|
||||||
|
|
||||||
bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, long &textureMemUsed, int prev_lod_max_dim, GLuint prev_handle);
|
bool uploadTexture(GLenum target, int lod_max_dim, int ¤t_lod_max_dim, int prev_lod_max_dim);
|
||||||
|
|
||||||
virtual long getMemRequiredForSize(int max_dim);
|
virtual long getMemRequiredForSize(int max_dim);
|
||||||
|
private:
|
||||||
|
long m_imageSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
#extension GL_EXT_shadow_samplers : require
|
#extension GL_EXT_shadow_samplers : require
|
||||||
|
|
||||||
|
#if ENABLE_RIM_COLOR == 1
|
||||||
|
uniform lowp vec3 rim_color;
|
||||||
|
uniform mediump float rim_power;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if FOG_TYPE > 0
|
#if FOG_TYPE > 0
|
||||||
// FOG_TYPE 1 - Linear
|
// FOG_TYPE 1 - Linear
|
||||||
// FOG_TYPE 2 - Exponential
|
// FOG_TYPE 2 - Exponential
|
||||||
@@ -111,18 +116,27 @@
|
|||||||
uniform sampler2D reflectionTexture;
|
uniform sampler2D reflectionTexture;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_RIM_COLOR == 1
|
||||||
|
#define NEED_EYEVEC
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_REFLECTION_CUBE_MAP == 1
|
#if HAS_REFLECTION_CUBE_MAP == 1
|
||||||
uniform lowp vec3 material_reflection;
|
uniform lowp vec3 material_reflection;
|
||||||
uniform samplerCube reflectionCubeTexture;
|
uniform samplerCube reflectionCubeTexture;
|
||||||
#if HAS_NORMAL_MAP == 1
|
#if HAS_NORMAL_MAP == 1
|
||||||
varying highp mat3 tangent_to_world_matrix;
|
varying highp mat3 tangent_to_world_matrix;
|
||||||
varying mediump vec3 eyeVec;
|
#define NEED_EYEVEC
|
||||||
|
|
||||||
uniform highp mat4 model_matrix;
|
uniform highp mat4 model_matrix;
|
||||||
#else
|
#else
|
||||||
varying mediump vec3 reflectionVec;
|
varying mediump vec3 reflectionVec;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NEED_EYEVEC
|
||||||
|
varying mediump vec3 eyeVec;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if SHADOW_QUALITY >= 1
|
#if SHADOW_QUALITY >= 1
|
||||||
#ifdef GL_EXT_shadow_samplers
|
#ifdef GL_EXT_shadow_samplers
|
||||||
@@ -394,6 +408,12 @@ void main()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_RIM_COLOR == 1
|
||||||
|
lowp float rim = 1.0 - clamp(dot(normalize(eyeVec), normal), 0.0, 1.0);
|
||||||
|
|
||||||
|
gl_FragColor += vec4(rim_color, 1.0) * pow(rim, rim_power);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BONE_COUNT > 0
|
#if BONE_COUNT > 0
|
||||||
gl_FragColor.b = 1.0;
|
gl_FragColor.b = 1.0;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -138,11 +138,14 @@ uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying t
|
|||||||
varying mediump float specularFactor;
|
varying mediump float specularFactor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_RIM_COLOR == 1
|
||||||
|
#define NEED_EYEVEC
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_REFLECTION_CUBE_MAP == 1
|
#if HAS_REFLECTION_CUBE_MAP == 1
|
||||||
#if HAS_NORMAL_MAP == 1
|
#if HAS_NORMAL_MAP == 1
|
||||||
|
#define NEED_EYEVEC
|
||||||
uniform highp mat4 model_inverse_transpose_matrix;
|
uniform highp mat4 model_inverse_transpose_matrix;
|
||||||
varying mediump vec3 eyeVec;
|
|
||||||
varying highp mat3 tangent_to_world_matrix;
|
varying highp mat3 tangent_to_world_matrix;
|
||||||
#else
|
#else
|
||||||
uniform highp mat4 model_matrix;
|
uniform highp mat4 model_matrix;
|
||||||
@@ -150,6 +153,10 @@ uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying t
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NEED_EYEVEC
|
||||||
|
varying mediump vec3 eyeVec;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_DIFFUSE_MAP_SCALE == 1
|
#if HAS_DIFFUSE_MAP_SCALE == 1
|
||||||
uniform highp vec2 diffuseTexture_Scale;
|
uniform highp vec2 diffuseTexture_Scale;
|
||||||
#endif
|
#endif
|
||||||
@@ -246,7 +253,7 @@ void main()
|
|||||||
|
|
||||||
#if HAS_REFLECTION_CUBE_MAP == 1
|
#if HAS_REFLECTION_CUBE_MAP == 1
|
||||||
#if HAS_NORMAL_MAP == 1
|
#if HAS_NORMAL_MAP == 1
|
||||||
eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
|
|
||||||
#else
|
#else
|
||||||
// Calculate reflection vector as I - 2.0 * dot(N, I) * N
|
// Calculate reflection vector as I - 2.0 * dot(N, I) * N
|
||||||
mediump vec3 eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
|
mediump vec3 eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
|
||||||
@@ -255,6 +262,9 @@ void main()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NEED_EYEVEC
|
||||||
|
eyeVec = normalize(camera_position_model_space - vertex_position_skinned);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_LIGHT_MAP == 1
|
#if HAS_LIGHT_MAP == 1
|
||||||
// Pass shadow UV co-ordinates
|
// Pass shadow UV co-ordinates
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
// KREngine
|
// 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
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
// conditions and the following disclaimer.
|
// conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
// 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
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
// provided with the distribution.
|
// provided with the distribution.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
// 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
|
// 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
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
// 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
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
// 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
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
@@ -31,7 +31,8 @@
|
|||||||
|
|
||||||
varying mediump vec2 texCoord;
|
varying mediump vec2 texCoord;
|
||||||
uniform sampler2D diffuseTexture;
|
uniform sampler2D diffuseTexture;
|
||||||
|
uniform lowp float material_alpha;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0);
|
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0) * material_alpha;
|
||||||
}
|
}
|
||||||
@@ -3,17 +3,17 @@
|
|||||||
// KREngine
|
// 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
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
// conditions and the following disclaimer.
|
// conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
// 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
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
// provided with the distribution.
|
// provided with the distribution.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
// 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
|
// 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
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
// 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
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
// 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
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
|
|||||||
38
KREngine/kraken_standard_assets_ios/Shaders/sprite.fsh
Normal file
38
KREngine/kraken_standard_assets_ios/Shaders/sprite.fsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// sprite.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.
|
||||||
|
//
|
||||||
|
|
||||||
|
varying mediump vec2 texCoord;
|
||||||
|
uniform sampler2D diffuseTexture;
|
||||||
|
uniform lowp float material_alpha;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0) * material_alpha;
|
||||||
|
}
|
||||||
42
KREngine/kraken_standard_assets_ios/Shaders/sprite.vsh
Normal file
42
KREngine/kraken_standard_assets_ios/Shaders/sprite.vsh
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// sprite.vsh
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
|
||||||
|
attribute mediump vec2 vertex_uv;
|
||||||
|
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||||
|
uniform mediump vec4 viewport;
|
||||||
|
uniform mediump float flare_size;
|
||||||
|
|
||||||
|
varying mediump vec2 texCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
texCoord = vertex_uv;
|
||||||
|
gl_Position = mvp_matrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(vertex_uv.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 0.0) * flare_size;
|
||||||
|
}
|
||||||
@@ -27,6 +27,11 @@
|
|||||||
|
|
||||||
// #extension GL_EXT_shadow_samplers : require
|
// #extension GL_EXT_shadow_samplers : require
|
||||||
|
|
||||||
|
#if ENABLE_RIM_COLOR == 1
|
||||||
|
uniform lowp vec3 rim_color;
|
||||||
|
uniform mediump float rim_power;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if FOG_TYPE > 0
|
#if FOG_TYPE > 0
|
||||||
// FOG_TYPE 1 - Linear
|
// FOG_TYPE 1 - Linear
|
||||||
// FOG_TYPE 2 - Exponential
|
// FOG_TYPE 2 - Exponential
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
// KREngine
|
// 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
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
// conditions and the following disclaimer.
|
// conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
// 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
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
// provided with the distribution.
|
// provided with the distribution.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
// 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
|
// 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
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
// 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
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
// 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
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
@@ -31,7 +31,8 @@
|
|||||||
|
|
||||||
varying mediump vec2 texCoord;
|
varying mediump vec2 texCoord;
|
||||||
uniform sampler2D diffuseTexture;
|
uniform sampler2D diffuseTexture;
|
||||||
|
uniform lowp float material_alpha;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0);
|
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0) * material_alpha;
|
||||||
}
|
}
|
||||||
@@ -3,17 +3,17 @@
|
|||||||
// KREngine
|
// 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
|
||||||
// permitted provided that the following conditions are met:
|
// permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
// conditions and the following disclaimer.
|
// conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
// 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
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
// provided with the distribution.
|
// provided with the distribution.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
// 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
|
// 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
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
// 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
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
// 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
|
// authors and should not be interpreted as representing official policies, either expressed
|
||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
|
|||||||
38
KREngine/kraken_standard_assets_osx/Shaders/sprite_osx.fsh
Normal file
38
KREngine/kraken_standard_assets_osx/Shaders/sprite_osx.fsh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// sprite.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.
|
||||||
|
//
|
||||||
|
|
||||||
|
varying mediump vec2 texCoord;
|
||||||
|
uniform sampler2D diffuseTexture;
|
||||||
|
uniform lowp float material_alpha;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_FragColor = vec4(vec3(texture2D(diffuseTexture, texCoord)), 1.0) * material_alpha;
|
||||||
|
}
|
||||||
42
KREngine/kraken_standard_assets_osx/Shaders/sprite_osx.vsh
Normal file
42
KREngine/kraken_standard_assets_osx/Shaders/sprite_osx.vsh
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
//
|
||||||
|
// sprite.vsh
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
|
||||||
|
attribute mediump vec2 vertex_uv;
|
||||||
|
uniform highp mat4 mvp_matrix; // mvp_matrix is the result of multiplying the model, view, and projection matrices
|
||||||
|
uniform mediump vec4 viewport;
|
||||||
|
uniform mediump float flare_size;
|
||||||
|
|
||||||
|
varying mediump vec2 texCoord;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
texCoord = vertex_uv;
|
||||||
|
gl_Position = mvp_matrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(vertex_uv.x * viewport.w / viewport.z * 2.0 - 1.0, vertex_uv.y * 2.0 - 1.0, 0.0, 0.0) * flare_size;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user