Set up scene graph objects required for managing light sources
--HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%4033
This commit is contained in:
@@ -26,14 +26,17 @@
|
||||
E461A166152E56C000F2044A /* KRSpotLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A164152E56C000F2044A /* KRSpotLight.cpp */; };
|
||||
E461A168152E570700F2044A /* KRSpotLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A167152E570500F2044A /* KRSpotLight.h */; };
|
||||
E461A169152E570700F2044A /* KRSpotLight.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A167152E570500F2044A /* KRSpotLight.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E461A16B152E575800F2044A /* KRLightManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A16A152E575700F2044A /* KRLightManager.h */; };
|
||||
E461A16C152E575800F2044A /* KRLightManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E461A16A152E575700F2044A /* KRLightManager.h */; };
|
||||
E461A16E152E576700F2044A /* KRLightManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A16D152E576700F2044A /* KRLightManager.cpp */; };
|
||||
E461A16F152E576700F2044A /* KRLightManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A16D152E576700F2044A /* KRLightManager.cpp */; };
|
||||
E461A175152E5C4800F2044A /* KRLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461A155152E54F700F2044A /* KRLight.cpp */; };
|
||||
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, ); }; };
|
||||
E461A17A152E5C9100F2044A /* KRMat4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017713C99BDC0098455B /* KRMat4.cpp */; };
|
||||
E46C214415364BC8009CABF3 /* tinyxml2_readme.txt in Resources */ = {isa = PBXBuildFile; fileRef = E46C214115364BC8009CABF3 /* tinyxml2_readme.txt */; };
|
||||
E46C214515364BC8009CABF3 /* tinyxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46C214215364BC8009CABF3 /* tinyxml2.cpp */; };
|
||||
E46C214615364BC8009CABF3 /* tinyxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46C214215364BC8009CABF3 /* tinyxml2.cpp */; };
|
||||
E46C214715364BC8009CABF3 /* tinyxml2.h in Headers */ = {isa = PBXBuildFile; fileRef = E46C214315364BC8009CABF3 /* tinyxml2.h */; };
|
||||
E46C214815364BC8009CABF3 /* tinyxml2.h in Headers */ = {isa = PBXBuildFile; fileRef = E46C214315364BC8009CABF3 /* tinyxml2.h */; };
|
||||
E46C214B15364DEC009CABF3 /* KRSceneManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46C214A15364DEC009CABF3 /* KRSceneManager.cpp */; };
|
||||
E46C214C15364DEC009CABF3 /* KRSceneManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E46C214A15364DEC009CABF3 /* KRSceneManager.cpp */; };
|
||||
E46DBE7B1512ACE600D59F86 /* KRMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49E79FE1512615F009CF99C /* KRMesh.cpp */; };
|
||||
E46DBE7F1512AF0200D59F86 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E46DBE7D1512AD4900D59F86 /* OpenGL.framework */; };
|
||||
E46DBE801512AF4600D59F86 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E491016413C99B9E0098455B /* Foundation.framework */; };
|
||||
@@ -88,6 +91,28 @@
|
||||
E4BBBBA71512A6DC00F43B5B /* KRVector3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017F13C99BDC0098455B /* KRVector3.cpp */; };
|
||||
E4D0683F1512A790005FFBEB /* KRVector3.h in Headers */ = {isa = PBXBuildFile; fileRef = E491017E13C99BDC0098455B /* KRVector3.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F711A51512BB56007EE923 /* libfbxsdk-2012.2-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4F711A41512BB56007EE923 /* libfbxsdk-2012.2-static.a */; };
|
||||
E4F975321536220900FD60B2 /* KRNode.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F975311536220900FD60B2 /* KRNode.h */; };
|
||||
E4F975331536220900FD60B2 /* KRNode.h in Headers */ = {isa = PBXBuildFile; fileRef = E4F975311536220900FD60B2 /* KRNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F975361536221C00FD60B2 /* KRNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4F975351536221C00FD60B2 /* KRNode.cpp */; };
|
||||
E4F975371536221C00FD60B2 /* KRNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4F975351536221C00FD60B2 /* KRNode.cpp */; };
|
||||
E4F9754015362CD400FD60B2 /* KRScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E414BAE81435585A00A668C4 /* KRScene.cpp */; };
|
||||
E4F9754115362CD900FD60B2 /* KRScene.h in Headers */ = {isa = PBXBuildFile; fileRef = E414BAE6143557D200A668C4 /* KRScene.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F9754215362D0D00FD60B2 /* KRInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = E414BAE11435557300A668C4 /* KRInstance.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F9754315362D0F00FD60B2 /* KRInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E414BAE41435558800A668C4 /* KRInstance.cpp */; };
|
||||
E4F9754415362D2900FD60B2 /* KRBoundingVolume.h in Headers */ = {isa = PBXBuildFile; fileRef = E414BAEA14355E5500A668C4 /* KRBoundingVolume.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F9754515362D2C00FD60B2 /* KRBoundingVolume.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E414BAEC14355EFF00A668C4 /* KRBoundingVolume.cpp */; };
|
||||
E4F975461536327C00FD60B2 /* KRModelManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E491018313C99BDC0098455B /* KRModelManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F975491536329E00FD60B2 /* KRTextureManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E491018513C99BDC0098455B /* KRTextureManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F9754A153632AA00FD60B2 /* KRModelManager.cpp in Headers */ = {isa = PBXBuildFile; fileRef = E491018213C99BDC0098455B /* KRModelManager.cpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F9754B153632D800FD60B2 /* KRModelManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491018213C99BDC0098455B /* KRModelManager.cpp */; };
|
||||
E4F9754C153632F000FD60B2 /* KRCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = E48B3CBC14393DF5000C50E2 /* KRCamera.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F9754E1536331D00FD60B2 /* KRTextureManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491018013C99BDC0098455B /* KRTextureManager.cpp */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F9754F1536333200FD60B2 /* KRModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017913C99BDC0098455B /* KRModel.cpp */; };
|
||||
E4F975501536333500FD60B2 /* KRModel.h in Headers */ = {isa = PBXBuildFile; fileRef = E491017A13C99BDC0098455B /* KRModel.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F97551153633E200FD60B2 /* KRMaterialManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491017B13C99BDC0098455B /* KRMaterialManager.cpp */; };
|
||||
E4F97552153633EF00FD60B2 /* KRMaterialManager.h in Headers */ = {isa = PBXBuildFile; fileRef = E491018413C99BDC0098455B /* KRMaterialManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
E4F975531536340000FD60B2 /* KRTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E491018113C99BDC0098455B /* KRTexture.cpp */; };
|
||||
E4F975541536340400FD60B2 /* KRTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = E491018613C99BDC0098455B /* KRTexture.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXBuildRule section */
|
||||
@@ -123,8 +148,11 @@
|
||||
E461A15E152E565700F2044A /* KRDirectionalLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRDirectionalLight.cpp; path = Classes/KRDirectionalLight.cpp; sourceTree = "<group>"; };
|
||||
E461A164152E56C000F2044A /* KRSpotLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRSpotLight.cpp; path = Classes/KRSpotLight.cpp; sourceTree = "<group>"; };
|
||||
E461A167152E570500F2044A /* KRSpotLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRSpotLight.h; path = Classes/KRSpotLight.h; sourceTree = "<group>"; };
|
||||
E461A16A152E575700F2044A /* KRLightManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRLightManager.h; path = Classes/KRLightManager.h; sourceTree = "<group>"; };
|
||||
E461A16D152E576700F2044A /* KRLightManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRLightManager.cpp; path = Classes/KRLightManager.cpp; sourceTree = "<group>"; };
|
||||
E46C214115364BC8009CABF3 /* tinyxml2_readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tinyxml2_readme.txt; path = KREngine/Classes/tinyxml2_readme.txt; sourceTree = "<group>"; };
|
||||
E46C214215364BC8009CABF3 /* tinyxml2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tinyxml2.cpp; path = KREngine/Classes/tinyxml2.cpp; sourceTree = "<group>"; };
|
||||
E46C214315364BC8009CABF3 /* tinyxml2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tinyxml2.h; path = KREngine/Classes/tinyxml2.h; sourceTree = "<group>"; };
|
||||
E46C214915364DDB009CABF3 /* KRSceneManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = KRSceneManager.h; path = Classes/KRSceneManager.h; sourceTree = "<group>"; };
|
||||
E46C214A15364DEC009CABF3 /* KRSceneManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRSceneManager.cpp; path = Classes/KRSceneManager.cpp; sourceTree = "<group>"; };
|
||||
E46DBE7D1512AD4900D59F86 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/OpenGL.framework; sourceTree = DEVELOPER_DIR; };
|
||||
E46DBE841512B9E200D59F86 /* KREngine-common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "KREngine-common.h"; path = "Classes/KREngine-common.h"; sourceTree = "<group>"; };
|
||||
E47C25A113F4F65A00FF4370 /* KRShaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRShaderManager.h; path = Classes/KRShaderManager.h; sourceTree = "<group>"; };
|
||||
@@ -176,6 +204,8 @@
|
||||
E4BBBB981512A47500F43B5B /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/CoreData.framework; sourceTree = DEVELOPER_DIR; };
|
||||
E4BBBB9A1512A48200F43B5B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||
E4F711A41512BB56007EE923 /* libfbxsdk-2012.2-static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libfbxsdk-2012.2-static.a"; path = "../../../../../../../../Applications/Autodesk/FBXSDK20122/lib/gcc4/ub/libfbxsdk-2012.2-static.a"; sourceTree = "<group>"; };
|
||||
E4F975311536220900FD60B2 /* KRNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KRNode.h; path = Classes/KRNode.h; sourceTree = "<group>"; };
|
||||
E4F975351536221C00FD60B2 /* KRNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = KRNode.cpp; path = Classes/KRNode.cpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -222,9 +252,9 @@
|
||||
E461A170152E598200F2044A /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E4F9755615363AA500FD60B2 /* Scene */,
|
||||
E461A174152E5A1300F2044A /* Models */,
|
||||
E461A172152E59BC00F2044A /* Materials */,
|
||||
E461A171152E599E00F2044A /* Lights */,
|
||||
E497B949151BCEE900D3DC67 /* KRResource.h */,
|
||||
E497B94C151BCF2500D3DC67 /* KRResource.cpp */,
|
||||
E497B94F151BD2CE00D3DC67 /* KRResource+obj.cpp */,
|
||||
@@ -281,6 +311,16 @@
|
||||
name = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E46C214015364BB8009CABF3 /* tinyxml2 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E46C214115364BC8009CABF3 /* tinyxml2_readme.txt */,
|
||||
E46C214215364BC8009CABF3 /* tinyxml2.cpp */,
|
||||
E46C214315364BC8009CABF3 /* tinyxml2.h */,
|
||||
);
|
||||
name = tinyxml2;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E491015613C99B9D0098455B = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -331,6 +371,7 @@
|
||||
E491016E13C99BAE0098455B /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E4F9753815362A5200FD60B2 /* 3rdparty */,
|
||||
E461A173152E59DF00F2044A /* Math */,
|
||||
E461A170152E598200F2044A /* Resources */,
|
||||
E491016F13C99BDC0098455B /* KREngine.mm */,
|
||||
@@ -349,15 +390,11 @@
|
||||
E47C25A413F4F66F00FF4370 /* KRShader.h */,
|
||||
E47C25A613F4F6AB00FF4370 /* KRShaderManager.cpp */,
|
||||
E47C25A813F4F6DD00FF4370 /* KRShader.cpp */,
|
||||
E414BAE11435557300A668C4 /* KRInstance.h */,
|
||||
E414BAE41435558800A668C4 /* KRInstance.cpp */,
|
||||
E414BAE6143557D200A668C4 /* KRScene.h */,
|
||||
E414BAE81435585A00A668C4 /* KRScene.cpp */,
|
||||
E48B3CBC14393DF5000C50E2 /* KRCamera.h */,
|
||||
E48B3CBF14393E2F000C50E2 /* KRCamera.cpp */,
|
||||
E46DBE841512B9E200D59F86 /* KREngine-common.h */,
|
||||
E461A16A152E575700F2044A /* KRLightManager.h */,
|
||||
E461A16D152E576700F2044A /* KRLightManager.cpp */,
|
||||
E46C214915364DDB009CABF3 /* KRSceneManager.h */,
|
||||
E46C214A15364DEC009CABF3 /* KRSceneManager.cpp */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
@@ -397,6 +434,29 @@
|
||||
name = "OSX Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E4F9753815362A5200FD60B2 /* 3rdparty */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E46C214015364BB8009CABF3 /* tinyxml2 */,
|
||||
);
|
||||
name = 3rdparty;
|
||||
path = ..;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E4F9755615363AA500FD60B2 /* Scene */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E414BAE11435557300A668C4 /* KRInstance.h */,
|
||||
E414BAE41435558800A668C4 /* KRInstance.cpp */,
|
||||
E461A171152E599E00F2044A /* Lights */,
|
||||
E4F975311536220900FD60B2 /* KRNode.h */,
|
||||
E4F975351536221C00FD60B2 /* KRNode.cpp */,
|
||||
E414BAE6143557D200A668C4 /* KRScene.h */,
|
||||
E414BAE81435585A00A668C4 /* KRScene.cpp */,
|
||||
);
|
||||
name = Scene;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
@@ -423,7 +483,8 @@
|
||||
E461A152152E54B500F2044A /* KRLight.h in Headers */,
|
||||
E461A15C152E563100F2044A /* KRDirectionalLight.h in Headers */,
|
||||
E461A168152E570700F2044A /* KRSpotLight.h in Headers */,
|
||||
E461A16B152E575800F2044A /* KRLightManager.h in Headers */,
|
||||
E4F975321536220900FD60B2 /* KRNode.h in Headers */,
|
||||
E46C214715364BC8009CABF3 /* tinyxml2.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -434,15 +495,26 @@
|
||||
E497B948151BB89D00D3DC67 /* KRVector2.h in Headers */,
|
||||
E4D0683F1512A790005FFBEB /* KRVector3.h in Headers */,
|
||||
E461A177152E5C6600F2044A /* KRMat4.h in Headers */,
|
||||
E4F9754415362D2900FD60B2 /* KRBoundingVolume.h in Headers */,
|
||||
E4F975461536327C00FD60B2 /* KRModelManager.h in Headers */,
|
||||
E497B94B151BCEE900D3DC67 /* KRResource.h in Headers */,
|
||||
E4F975331536220900FD60B2 /* KRNode.h in Headers */,
|
||||
E4B2A4391523B027004CB0EC /* KRMaterial.h in Headers */,
|
||||
E46DBE811512AFE600D59F86 /* KRMesh.h in Headers */,
|
||||
E4F9754115362CD900FD60B2 /* KRScene.h in Headers */,
|
||||
E4F9754A153632AA00FD60B2 /* KRModelManager.cpp in Headers */,
|
||||
E4F9754215362D0D00FD60B2 /* KRInstance.h in Headers */,
|
||||
E4F975491536329E00FD60B2 /* KRTextureManager.h in Headers */,
|
||||
E46DBE851512B9FA00D59F86 /* KREngine-common.h in Headers */,
|
||||
E4F9754C153632F000FD60B2 /* KRCamera.h in Headers */,
|
||||
E4F975501536333500FD60B2 /* KRModel.h in Headers */,
|
||||
E461A153152E54B500F2044A /* KRLight.h in Headers */,
|
||||
E4F97552153633EF00FD60B2 /* KRMaterialManager.h in Headers */,
|
||||
E461A176152E5C5600F2044A /* KRPointLight.h in Headers */,
|
||||
E4F975541536340400FD60B2 /* KRTexture.h in Headers */,
|
||||
E461A15D152E563100F2044A /* KRDirectionalLight.h in Headers */,
|
||||
E461A169152E570700F2044A /* KRSpotLight.h in Headers */,
|
||||
E461A16C152E575800F2044A /* KRLightManager.h in Headers */,
|
||||
E46C214815364BC8009CABF3 /* tinyxml2.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -518,6 +590,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
E4BBBB8A1512A40300F43B5B /* InfoPlist.strings in Resources */,
|
||||
E46C214415364BC8009CABF3 /* tinyxml2_readme.txt in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -551,7 +624,9 @@
|
||||
E461A159152E557E00F2044A /* KRPointLight.cpp in Sources */,
|
||||
E461A15F152E565700F2044A /* KRDirectionalLight.cpp in Sources */,
|
||||
E461A165152E56C000F2044A /* KRSpotLight.cpp in Sources */,
|
||||
E461A16E152E576700F2044A /* KRLightManager.cpp in Sources */,
|
||||
E4F975361536221C00FD60B2 /* KRNode.cpp in Sources */,
|
||||
E46C214515364BC8009CABF3 /* tinyxml2.cpp in Sources */,
|
||||
E46C214B15364DEC009CABF3 /* KRSceneManager.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -569,10 +644,20 @@
|
||||
E497B94E151BCF2500D3DC67 /* KRResource.cpp in Sources */,
|
||||
E497B951151BD2CE00D3DC67 /* KRResource+obj.cpp in Sources */,
|
||||
E497B954151BEDA600D3DC67 /* KRResource+fbx.cpp in Sources */,
|
||||
E4F97551153633E200FD60B2 /* KRMaterialManager.cpp in Sources */,
|
||||
E461A15A152E557E00F2044A /* KRPointLight.cpp in Sources */,
|
||||
E4F9754F1536333200FD60B2 /* KRModel.cpp in Sources */,
|
||||
E4F9754B153632D800FD60B2 /* KRModelManager.cpp in Sources */,
|
||||
E461A160152E565700F2044A /* KRDirectionalLight.cpp in Sources */,
|
||||
E4F9754515362D2C00FD60B2 /* KRBoundingVolume.cpp in Sources */,
|
||||
E4F975531536340000FD60B2 /* KRTexture.cpp in Sources */,
|
||||
E4F9754015362CD400FD60B2 /* KRScene.cpp in Sources */,
|
||||
E461A166152E56C000F2044A /* KRSpotLight.cpp in Sources */,
|
||||
E461A16F152E576700F2044A /* KRLightManager.cpp in Sources */,
|
||||
E4F9754315362D0F00FD60B2 /* KRInstance.cpp in Sources */,
|
||||
E4F975371536221C00FD60B2 /* KRNode.cpp in Sources */,
|
||||
E4F9754E1536331D00FD60B2 /* KRTextureManager.cpp in Sources */,
|
||||
E46C214615364BC8009CABF3 /* tinyxml2.cpp in Sources */,
|
||||
E46C214C15364DEC009CABF3 /* KRSceneManager.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -193,8 +193,8 @@ bool KRBoundingVolume::test_intersect(const KRBoundingVolume &p) const {
|
||||
}
|
||||
|
||||
|
||||
KRMat4 KRBoundingVolume::calcShadowProj(KRScene *pScene, GLfloat sun_yaw, GLfloat sun_pitch) const {
|
||||
KRBoundingVolume sceneVolume = pScene->getExtents();
|
||||
KRMat4 KRBoundingVolume::calcShadowProj(KRScene *pScene, KRModelManager *pModelManager, GLfloat sun_yaw, GLfloat sun_pitch) const {
|
||||
KRBoundingVolume sceneVolume = pScene->getExtents(pModelManager);
|
||||
|
||||
KRMat4 shadowvp;
|
||||
shadowvp.rotate(sun_pitch, X_AXIS);
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#import "KRVector3.h"
|
||||
#import "KRMat4.h"
|
||||
#import "KRScene.h"
|
||||
#import "KRModelManager.h"
|
||||
|
||||
class KRScene;
|
||||
|
||||
@@ -54,7 +55,7 @@ public:
|
||||
KRBoundingVolume get_union(const KRBoundingVolume &p) const;
|
||||
bool test_intersect(const KRBoundingVolume &p) const;
|
||||
|
||||
KRMat4 calcShadowProj(KRScene *pScene, GLfloat sun_yaw, GLfloat sun_pitch) const;
|
||||
KRMat4 calcShadowProj(KRScene *pScene, KRModelManager *pModelManager, GLfloat sun_yaw, GLfloat sun_pitch) const;
|
||||
private:
|
||||
KRVector3 m_vertices[8];
|
||||
};
|
||||
|
||||
@@ -20,7 +20,6 @@ KRDirectionalLight::~KRDirectionalLight()
|
||||
|
||||
}
|
||||
|
||||
bool KRDirectionalLight::save(const std::string& path)
|
||||
{
|
||||
return true;
|
||||
std::string KRDirectionalLight::getElementName() {
|
||||
return "directional_light";
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ class KRDirectionalLight : public KRLight {
|
||||
|
||||
public:
|
||||
KRDirectionalLight(std::string name);
|
||||
~KRDirectionalLight();
|
||||
virtual ~KRDirectionalLight();
|
||||
|
||||
virtual bool save(const std::string& path);
|
||||
virtual std::string getElementName();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#import "KRMaterialManager.h"
|
||||
#import "KRShaderManager.h"
|
||||
#import "KRModelManager.h"
|
||||
#import "KRLightManager.h"
|
||||
#import "KRSceneManager.h"
|
||||
#import "KRCamera.h"
|
||||
|
||||
#import "KREngine-common.h"
|
||||
@@ -81,11 +81,11 @@ typedef enum KREngineParameterType {KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_F
|
||||
GLuint m_postShaderProgram;
|
||||
GLuint m_shadowShaderProgram;
|
||||
|
||||
KRSceneManager *m_pSceneManager;
|
||||
KRTextureManager *m_pTextureManager;
|
||||
KRMaterialManager *m_pMaterialManager;
|
||||
KRShaderManager *m_pShaderManager;
|
||||
KRModelManager *m_pModelManager;
|
||||
KRLightManager *m_pLightManager;
|
||||
|
||||
int m_iFrame;
|
||||
|
||||
@@ -103,6 +103,7 @@ typedef enum KREngineParameterType {KRENGINE_PARAMETER_INT, KRENGINE_PARAMETER_F
|
||||
- (void)renderShadowBufferNumber: (int)iShadow ForScene: (KRScene *)pScene;
|
||||
- (void)renderScene: (KRScene *)pScene WithViewMatrix: (KRMat4)viewMatrix LightDirection: (KRVector3)lightDirection CameraPosition: (KRVector3)cameraPosition;
|
||||
- (KRModelManager *)getModelManager;
|
||||
- (KRSceneManager *)getSceneManager;
|
||||
- (void)invalidateShadowBuffers;
|
||||
- (void)allocateShadowBuffers;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#import "KREngine.h"
|
||||
#import "KRVector3.h"
|
||||
#import "KRScene.h"
|
||||
#import "KRSceneManager.h"
|
||||
|
||||
#import <string>
|
||||
#import <sstream>
|
||||
@@ -82,7 +83,7 @@ double const PI = 3.141592653589793f;
|
||||
m_pTextureManager = new KRTextureManager();
|
||||
m_pMaterialManager = new KRMaterialManager(m_pTextureManager, m_pShaderManager);
|
||||
m_pModelManager = new KRModelManager(m_pMaterialManager);
|
||||
m_pLightManager = new KRLightManager();
|
||||
m_pSceneManager = new KRSceneManager();
|
||||
|
||||
if (![self createBuffers] || ![self loadShaders] /*|| ![self loadObjects]*/ )
|
||||
{
|
||||
@@ -225,12 +226,12 @@ double const PI = 3.141592653589793f;
|
||||
|
||||
KRMat4 newShadowMVP;
|
||||
if(shadowMaxDepths[m_cShadowBuffers - 1][iShadow] == 0.0) {
|
||||
KRBoundingVolume ext = KRBoundingVolume(pScene->getExtents());
|
||||
KRBoundingVolume ext = KRBoundingVolume(pScene->getExtents(m_pModelManager));
|
||||
|
||||
newShadowMVP = ext.calcShadowProj(pScene, sun_yaw, sun_pitch);
|
||||
newShadowMVP = ext.calcShadowProj(pScene, m_pModelManager, sun_yaw, sun_pitch);
|
||||
} else {
|
||||
KRBoundingVolume frustrumSliceVolume = KRBoundingVolume(viewMatrix, m_camera.perspective_fov, m_camera.perspective_aspect, m_camera.perspective_nearz + (m_camera.perspective_farz - m_camera.perspective_nearz) * shadowMinDepths[m_cShadowBuffers - 1][iShadow], m_camera.perspective_nearz + (m_camera.perspective_farz - m_camera.perspective_nearz) * shadowMaxDepths[m_cShadowBuffers - 1][iShadow]);
|
||||
newShadowMVP = frustrumSliceVolume.calcShadowProj(pScene, sun_yaw, sun_pitch);
|
||||
newShadowMVP = frustrumSliceVolume.calcShadowProj(pScene, m_pModelManager, sun_yaw, sun_pitch);
|
||||
}
|
||||
|
||||
if(!(shadowmvpmatrix[iShadow] == newShadowMVP)) {
|
||||
@@ -330,7 +331,7 @@ double const PI = 3.141592653589793f;
|
||||
KRVector3 cameraPosition;
|
||||
KRVector3 lightDirection;
|
||||
KRBoundingVolume shadowVolume = KRBoundingVolume(vertices);
|
||||
pScene->render(&m_camera, shadowVolume, m_pMaterialManager, true, shadowmvpmatrix[iShadow], cameraPosition, lightDirection, shadowmvpmatrix, NULL, 0, m_pShaderManager, m_pTextureManager);
|
||||
pScene->render(&m_camera, m_pModelManager, shadowVolume, m_pMaterialManager, true, shadowmvpmatrix[iShadow], cameraPosition, lightDirection, shadowmvpmatrix, NULL, 0, m_pShaderManager, m_pTextureManager);
|
||||
|
||||
glViewport(0, 0, 768, 1024);
|
||||
}
|
||||
@@ -356,7 +357,7 @@ double const PI = 3.141592653589793f;
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
KRBoundingVolume frustrumVolume = KRBoundingVolume(viewMatrix, m_camera.perspective_fov, m_camera.perspective_aspect, m_camera.perspective_nearz, m_camera.perspective_farz);
|
||||
pScene -> render(&m_camera, frustrumVolume, m_pMaterialManager, false, viewMatrix, cameraPosition, lightDirection, shadowmvpmatrix, shadowDepthTexture, m_cShadowBuffers, m_pShaderManager, m_pTextureManager);
|
||||
pScene -> render(&m_camera, m_pModelManager, frustrumVolume, m_pMaterialManager, false, viewMatrix, cameraPosition, lightDirection, shadowmvpmatrix, shadowDepthTexture, m_cShadowBuffers, m_pShaderManager, m_pTextureManager);
|
||||
}
|
||||
|
||||
- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type file:(NSString *)file withOptions: (NSString *)options
|
||||
@@ -543,21 +544,27 @@ double const PI = 3.141592653589793f;
|
||||
if([path hasSuffix: @".krobject"]) {
|
||||
NSLog(@"object: %@", path);
|
||||
m_pModelManager->loadModel([name UTF8String], [path UTF8String]);
|
||||
} else if([path hasSuffix: @".krscene"]) {
|
||||
NSLog(@"scene: %@", path);
|
||||
m_pSceneManager->loadScene([name UTF8String], [path UTF8String]);
|
||||
} else if([path hasSuffix: @".pvr"]) {
|
||||
NSLog(@"texture: %@", path);
|
||||
m_pTextureManager->loadTexture([name UTF8String], [path UTF8String]);
|
||||
} else if([path hasSuffix: @".mtl"]) {
|
||||
NSLog(@"material: %@", path);
|
||||
m_pMaterialManager->loadFile([path UTF8String]);
|
||||
} else if([path hasSuffix: @".krlight"]) {
|
||||
m_pLightManager->loadFile([path UTF8String]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
{
|
||||
if(m_pSceneManager) {
|
||||
delete m_pSceneManager;
|
||||
m_pSceneManager = NULL;
|
||||
}
|
||||
|
||||
if(m_pModelManager) {
|
||||
delete m_pModelManager;
|
||||
m_pModelManager = NULL;
|
||||
@@ -578,11 +585,6 @@ double const PI = 3.141592653589793f;
|
||||
m_pShaderManager = NULL;
|
||||
}
|
||||
|
||||
if(m_pLightManager) {
|
||||
delete m_pLightManager;
|
||||
m_pLightManager = NULL;
|
||||
}
|
||||
|
||||
[self invalidatePostShader];
|
||||
[self destroyBuffers];
|
||||
[super dealloc];
|
||||
@@ -1114,6 +1116,10 @@ double const PI = 3.141592653589793f;
|
||||
return m_pModelManager;
|
||||
}
|
||||
|
||||
- (KRSceneManager *)getSceneManager {
|
||||
return m_pSceneManager;
|
||||
}
|
||||
|
||||
- (void)invalidateShadowBuffers {
|
||||
for(int i=0; i < m_cShadowBuffers; i++) {
|
||||
shadowValid[i] = false;
|
||||
|
||||
@@ -31,57 +31,85 @@
|
||||
|
||||
#include <iostream>
|
||||
#import "KRInstance.h"
|
||||
#include <assert.h>
|
||||
|
||||
KRInstance::KRInstance(KRModel *pModel, const KRMat4 modelMatrix, std::string shadow_map) {
|
||||
m_pModel = pModel;
|
||||
KRInstance::KRInstance(std::string instance_name, std::string model_name, const KRMat4 modelMatrix, std::string shadow_map) : KRNode(instance_name) {
|
||||
m_modelMatrix = modelMatrix;
|
||||
m_shadowMap = shadow_map;
|
||||
m_pShadowMap = NULL;
|
||||
m_pModel = NULL;
|
||||
m_model_name = model_name;
|
||||
}
|
||||
|
||||
KRInstance::~KRInstance() {
|
||||
|
||||
}
|
||||
|
||||
std::string KRInstance::getElementName() {
|
||||
return "mesh";
|
||||
}
|
||||
|
||||
tinyxml2::XMLElement *KRInstance::saveXML( tinyxml2::XMLNode *parent)
|
||||
{
|
||||
tinyxml2::XMLElement *e = KRNode::saveXML(parent);
|
||||
e->SetAttribute("lightmap", m_shadowMap.c_str());
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
KRMat4 &KRInstance::getModelMatrix() {
|
||||
return m_modelMatrix;
|
||||
}
|
||||
KRModel *KRInstance::getModel() {
|
||||
return m_pModel;
|
||||
}
|
||||
|
||||
void KRInstance::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager) {
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
void KRInstance::render(KRCamera *pCamera, KRModelManager *pModelManager, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager) {
|
||||
|
||||
if(m_pShadowMap == NULL && m_shadowMap.size()) {
|
||||
m_pShadowMap = pTextureManager->getTexture(m_shadowMap.c_str());
|
||||
if(m_pModel == NULL) {
|
||||
m_pModel = pModelManager->getModel(m_model_name.c_str());
|
||||
}
|
||||
|
||||
if(cShadowBuffers == 0 && m_pShadowMap && pCamera->bEnableShadowMap && !bRenderShadowMap) {
|
||||
int iTextureName = m_pShadowMap->getName();
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, iTextureName);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
if(m_pModel != NULL) {
|
||||
|
||||
if(m_pShadowMap == NULL && m_shadowMap.size()) {
|
||||
m_pShadowMap = pTextureManager->getTexture(m_shadowMap.c_str());
|
||||
}
|
||||
|
||||
if(cShadowBuffers == 0 && m_pShadowMap && pCamera->bEnableShadowMap && !bRenderShadowMap) {
|
||||
int iTextureName = m_pShadowMap->getName();
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, iTextureName);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
}
|
||||
|
||||
KRMat4 projectionMatrix;
|
||||
if(!bRenderShadowMap) {
|
||||
projectionMatrix = pCamera->getProjectionMatrix();
|
||||
}
|
||||
KRMat4 mvpmatrix = m_modelMatrix * viewMatrix * projectionMatrix;
|
||||
|
||||
// Transform location of camera to object space for calculation of specular halfVec
|
||||
KRMat4 inverseModelMatrix = m_modelMatrix;
|
||||
inverseModelMatrix.invert();
|
||||
KRVector3 cameraPosObject = inverseModelMatrix.dot(cameraPosition);
|
||||
KRVector3 lightDirObject = inverseModelMatrix.dot(lightDirection);
|
||||
|
||||
m_pModel->render(pCamera, pMaterialManager, bRenderShadowMap, mvpmatrix, cameraPosObject, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, pShaderManager, pTextureManager, m_pShadowMap);
|
||||
|
||||
}
|
||||
|
||||
KRMat4 projectionMatrix;
|
||||
if(!bRenderShadowMap) {
|
||||
projectionMatrix = pCamera->getProjectionMatrix();
|
||||
}
|
||||
KRMat4 mvpmatrix = m_modelMatrix * viewMatrix * projectionMatrix;
|
||||
|
||||
// Transform location of camera to object space for calculation of specular halfVec
|
||||
KRMat4 inverseModelMatrix = m_modelMatrix;
|
||||
inverseModelMatrix.invert();
|
||||
KRVector3 cameraPosObject = inverseModelMatrix.dot(cameraPosition);
|
||||
KRVector3 lightDirObject = inverseModelMatrix.dot(lightDirection);
|
||||
|
||||
m_pModel->render(pCamera, pMaterialManager, bRenderShadowMap, mvpmatrix, cameraPosObject, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, pShaderManager, pTextureManager, m_pShadowMap);
|
||||
|
||||
}
|
||||
|
||||
KRBoundingVolume KRInstance::getExtents() {
|
||||
#endif
|
||||
|
||||
KRBoundingVolume KRInstance::getExtents(KRModelManager *pModelManager) {
|
||||
if(m_pModel == NULL) {
|
||||
m_pModel = pModelManager->getModel(m_model_name.c_str());
|
||||
}
|
||||
assert(m_pModel != NULL);
|
||||
|
||||
KRMesh *pMesh = m_pModel->getMesh();
|
||||
return KRBoundingVolume(KRVector3(pMesh->getMinX(), pMesh->getMinY(), pMesh->getMinZ()), KRVector3(pMesh->getMaxX(), pMesh->getMaxY(), pMesh->getMaxZ()), m_modelMatrix);
|
||||
}
|
||||
@@ -29,37 +29,49 @@
|
||||
// or implied, of Kearwood Gilbert.
|
||||
//
|
||||
|
||||
#import "KRModel.h"
|
||||
#import "KRMat4.h"
|
||||
#import "KRVector3.h"
|
||||
#import "KRBoundingVolume.h"
|
||||
#import "KRInstance.h"
|
||||
#import "KRCamera.h"
|
||||
|
||||
|
||||
#import "KREngine-common.h"
|
||||
|
||||
#ifndef KRINSTANCE_H
|
||||
#define KRINSTANCE_H
|
||||
|
||||
#import "KRModel.h"
|
||||
#import "KRMat4.h"
|
||||
#import "KRVector3.h"
|
||||
#import "KRBoundingVolume.h"
|
||||
#import "KRInstance.h"
|
||||
#import "KRCamera.h"
|
||||
#import "KRModelManager.h"
|
||||
#import "KRNode.h"
|
||||
|
||||
class KRBoundingVolume;
|
||||
|
||||
class KRInstance {
|
||||
class KRInstance : public KRNode {
|
||||
|
||||
public:
|
||||
KRInstance(KRModel *pModel, const KRMat4 modelMatrix, std::string shadow_map);
|
||||
~KRInstance();
|
||||
void render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager);
|
||||
KRInstance(std::string instance_name, std::string model_name, const KRMat4 modelMatrix, std::string shadow_map);
|
||||
virtual ~KRInstance();
|
||||
|
||||
KRBoundingVolume getExtents();
|
||||
virtual std::string getElementName();
|
||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
void render(KRCamera *pCamera, KRModelManager *pModelManager, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager);
|
||||
|
||||
#endif
|
||||
|
||||
KRBoundingVolume getExtents(KRModelManager *pModelManager);
|
||||
|
||||
KRMat4 &getModelMatrix();
|
||||
KRModel *getModel();
|
||||
|
||||
private:
|
||||
KRModel *m_pModel;
|
||||
KRMat4 m_modelMatrix;
|
||||
KRTexture *m_pShadowMap;
|
||||
std::string m_shadowMap;
|
||||
std::string m_model_name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
#import "KRLight.h"
|
||||
|
||||
KRLight::KRLight(std::string name) : KRResource(name)
|
||||
KRLight::KRLight(std::string name) : KRNode(name)
|
||||
{
|
||||
|
||||
m_intensity = 1.0f;
|
||||
}
|
||||
|
||||
KRLight::~KRLight()
|
||||
@@ -20,7 +20,36 @@ KRLight::~KRLight()
|
||||
|
||||
}
|
||||
|
||||
std::string KRLight::getExtension()
|
||||
tinyxml2::XMLElement *KRLight::saveXML( tinyxml2::XMLNode *parent)
|
||||
{
|
||||
return "krlight";
|
||||
}
|
||||
tinyxml2::XMLElement *e = KRNode::saveXML(parent);
|
||||
e->SetAttribute("intensity", m_intensity);
|
||||
e->SetAttribute("color_r", m_color.x);
|
||||
e->SetAttribute("color_g", m_color.y);
|
||||
e->SetAttribute("color_b", m_color.z);
|
||||
e->SetAttribute("decay_start", m_decayStart);
|
||||
return e;
|
||||
}
|
||||
|
||||
void KRLight::setIntensity(float intensity) {
|
||||
m_intensity = intensity;
|
||||
}
|
||||
float KRLight::getIntensity() {
|
||||
return m_intensity;
|
||||
}
|
||||
|
||||
const KRVector3 &KRLight::getColor() {
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void KRLight::setColor(const KRVector3 &color) {
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
void KRLight::setDecayStart(float decayStart) {
|
||||
m_decayStart = decayStart;
|
||||
}
|
||||
|
||||
float KRLight::getDecayStart() {
|
||||
return m_decayStart;
|
||||
}
|
||||
|
||||
@@ -10,15 +10,27 @@
|
||||
#define KREngine_KRLight_h
|
||||
|
||||
#import "KRResource.h"
|
||||
#import "KRNode.h"
|
||||
|
||||
class KRLight : public KRResource {
|
||||
class KRLight : public KRNode {
|
||||
public:
|
||||
~KRLight();
|
||||
virtual ~KRLight();
|
||||
virtual std::string getElementName() = 0;
|
||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||
|
||||
void setIntensity(float intensity);
|
||||
float getIntensity();
|
||||
void setDecayStart(float decayStart);
|
||||
float getDecayStart();
|
||||
const KRVector3 &getColor();
|
||||
void setColor(const KRVector3 &color);
|
||||
|
||||
virtual std::string getExtension();
|
||||
virtual bool save(const std::string& path) = 0;
|
||||
protected:
|
||||
KRLight(std::string name);
|
||||
|
||||
float m_intensity;
|
||||
float m_decayStart;
|
||||
KRVector3 m_color;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
//
|
||||
// KRLightManager.cpp
|
||||
// KREngine
|
||||
//
|
||||
// Created by Kearwood Gilbert on 12-04-05.
|
||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "KRLightManager.h"
|
||||
|
||||
KRLightManager::KRLightManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
KRLightManager::~KRLightManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool KRLightManager::loadFile(const char *szPath)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
//
|
||||
// KRLightManager.h
|
||||
// KREngine
|
||||
//
|
||||
// Created by Kearwood Gilbert on 12-04-05.
|
||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef KREngine_KRLightManager_h
|
||||
#define KREngine_KRLightManager_h
|
||||
|
||||
class KRLightManager {
|
||||
public:
|
||||
KRLightManager();
|
||||
~KRLightManager();
|
||||
|
||||
bool loadFile(const char *szPath);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -37,9 +37,6 @@
|
||||
|
||||
using std::list;
|
||||
|
||||
#ifndef KRMATERIAL_H
|
||||
#define KRMATRIAL_H
|
||||
|
||||
#import "KRTexture.h"
|
||||
#import "KRShaderManager.h"
|
||||
#import "KRShader.h"
|
||||
@@ -47,6 +44,11 @@ using std::list;
|
||||
#import "KRResource.h"
|
||||
#import "KRVector2.h"
|
||||
|
||||
#ifndef KRMATERIAL_H
|
||||
#define KRMATERIAL_H
|
||||
|
||||
|
||||
|
||||
class KRTextureManager;
|
||||
|
||||
class KRMaterial : public KRResource {
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
#import "KRShaderManager.h"
|
||||
|
||||
|
||||
KRModel::KRModel(std::string path, KRMaterialManager *pMaterialManager) {
|
||||
KRModel::KRModel(std::string name, std::string path, KRMaterialManager *pMaterialManager) {
|
||||
m_name = name;
|
||||
loadPack(path, pMaterialManager);
|
||||
}
|
||||
|
||||
@@ -63,9 +64,14 @@ void KRModel::loadPack(std::string path, KRMaterialManager *pMaterialManager) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string KRModel::getName() {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
KRModel::~KRModel() {
|
||||
|
||||
}
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
void KRModel::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager, KRTexture *pShadowMap) {
|
||||
KRMaterial *pPrevBoundMaterial = NULL;
|
||||
@@ -102,6 +108,8 @@ void KRModel::render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, boo
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
KRMesh *KRModel::getMesh() {
|
||||
return m_pMesh;
|
||||
}
|
||||
|
||||
@@ -49,12 +49,17 @@ using std::set;
|
||||
class KRModel {
|
||||
|
||||
public:
|
||||
KRModel(std::string path, KRMaterialManager *pMaterialManager);
|
||||
KRModel(std::string name, std::string path, KRMaterialManager *pMaterialManager);
|
||||
~KRModel();
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
void render(KRCamera *pCamera, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &mvpMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager, KRTexture *pShadowMap);
|
||||
|
||||
#endif
|
||||
|
||||
KRMesh *getMesh();
|
||||
std::string getName();
|
||||
|
||||
private:
|
||||
void loadPack(std::string path, KRMaterialManager *pMaterialManager);
|
||||
@@ -62,6 +67,7 @@ private:
|
||||
vector<KRMaterial *> m_materials;
|
||||
set<KRMaterial *> m_uniqueMaterials;
|
||||
KRMesh *m_pMesh;
|
||||
std::string m_name;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ KRModelManager::~KRModelManager() {
|
||||
}
|
||||
|
||||
KRModel *KRModelManager::loadModel(const char *szName, const char *szPath) {
|
||||
KRModel *pModel = new KRModel(szPath, m_pMaterialManager);
|
||||
KRModel *pModel = new KRModel(szName, szPath, m_pMaterialManager);
|
||||
m_models[szName] = pModel;
|
||||
return pModel;
|
||||
}
|
||||
|
||||
77
KREngine/KREngine/Classes/KRNode.cpp
Normal file
77
KREngine/KREngine/Classes/KRNode.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// KRNode.cpp
|
||||
// KREngine
|
||||
//
|
||||
// Created by Kearwood Gilbert on 12-04-11.
|
||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#import "KRNode.h"
|
||||
|
||||
|
||||
KRNode::KRNode(std::string name)
|
||||
{
|
||||
m_name = name;
|
||||
m_localScale = KRVector3(1.0f, 1.0f, 1.0f);
|
||||
m_localRotation = KRVector3(0.0f, 0.0f, 0.0f);
|
||||
m_localTranslation = KRVector3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
KRNode::~KRNode() {
|
||||
for(std::vector<KRNode *>::iterator itr=m_childNodes.begin(); itr < m_childNodes.end(); ++itr) {
|
||||
delete *itr;
|
||||
}
|
||||
m_childNodes.clear();
|
||||
}
|
||||
|
||||
void KRNode::addChild(KRNode *child) {
|
||||
m_childNodes.push_back(child);
|
||||
}
|
||||
|
||||
tinyxml2::XMLElement *KRNode::saveXML(tinyxml2::XMLNode *parent) {
|
||||
tinyxml2::XMLDocument *doc = parent->GetDocument();
|
||||
tinyxml2::XMLElement *e = doc->NewElement(getElementName().c_str());
|
||||
tinyxml2::XMLNode *n = parent->InsertEndChild(e);
|
||||
e->SetAttribute("name", m_name.c_str());
|
||||
e->SetAttribute("translate_x", m_localTranslation.x);
|
||||
e->SetAttribute("translate_y", m_localTranslation.y);
|
||||
e->SetAttribute("translate_z", m_localTranslation.z);
|
||||
e->SetAttribute("scale_x", m_localScale.x);
|
||||
e->SetAttribute("scale_y", m_localScale.y);
|
||||
e->SetAttribute("scale_z", m_localScale.z);
|
||||
e->SetAttribute("rotate_x", m_localRotation.x);
|
||||
e->SetAttribute("rotate_y", m_localRotation.y);
|
||||
e->SetAttribute("rotate_z", m_localRotation.z);
|
||||
for(std::vector<KRNode *>::iterator itr=m_childNodes.begin(); itr < m_childNodes.end(); ++itr) {
|
||||
KRNode *child = (*itr);
|
||||
child->saveXML(n);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
void KRNode::setLocalTranslation(const KRVector3 &v) {
|
||||
m_localTranslation = v;
|
||||
}
|
||||
void KRNode::setLocalScale(const KRVector3 &v) {
|
||||
m_localScale = v;
|
||||
}
|
||||
void KRNode::setLocalRotation(const KRVector3 &v) {
|
||||
m_localRotation = v;
|
||||
}
|
||||
|
||||
const KRVector3 &KRNode::getLocalTranslation() {
|
||||
return m_localTranslation;
|
||||
}
|
||||
const KRVector3 &KRNode::getLocalScale() {
|
||||
return m_localScale;
|
||||
}
|
||||
const KRVector3 &KRNode::getLocalRotation() {
|
||||
return m_localRotation;
|
||||
}
|
||||
|
||||
std::string KRNode::getElementName() {
|
||||
return "node";
|
||||
}
|
||||
|
||||
46
KREngine/KREngine/Classes/KRNode.h
Normal file
46
KREngine/KREngine/Classes/KRNode.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// KRNode.h
|
||||
// KREngine
|
||||
//
|
||||
// Created by Kearwood Gilbert on 12-04-11.
|
||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef KREngine_KRNode_h
|
||||
#define KREngine_KRNode_h
|
||||
|
||||
#import "KRResource.h"
|
||||
#import "KRVector3.h"
|
||||
#import "tinyxml2.h"
|
||||
|
||||
class KRNode
|
||||
{
|
||||
public:
|
||||
KRNode(std::string name);
|
||||
virtual ~KRNode();
|
||||
|
||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||
virtual std::string getElementName();
|
||||
|
||||
void addChild(KRNode *child);
|
||||
|
||||
void setLocalTranslation(const KRVector3 &v);
|
||||
void setLocalScale(const KRVector3 &v);
|
||||
void setLocalRotation(const KRVector3 &v);
|
||||
|
||||
const KRVector3 &getLocalTranslation();
|
||||
const KRVector3 &getLocalScale();
|
||||
const KRVector3 &getLocalRotation();
|
||||
|
||||
private:
|
||||
KRVector3 m_localTranslation;
|
||||
KRVector3 m_localScale;
|
||||
KRVector3 m_localRotation;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
std::vector<KRNode *> m_childNodes;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -20,7 +20,6 @@ KRPointLight::~KRPointLight()
|
||||
|
||||
}
|
||||
|
||||
bool KRPointLight::save(const std::string& path)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::string KRPointLight::getElementName() {
|
||||
return "point_light";
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ class KRPointLight : public KRLight {
|
||||
|
||||
public:
|
||||
KRPointLight(std::string name);
|
||||
~KRPointLight();
|
||||
virtual ~KRPointLight();
|
||||
|
||||
virtual bool save(const std::string& path);
|
||||
virtual std::string getElementName();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "KRPointLight.h"
|
||||
#include "KRDirectionalLight.h"
|
||||
#include "KRSpotLight.h"
|
||||
#include "KRNode.h"
|
||||
#include "KRScene.h"
|
||||
|
||||
#ifdef IOS_REF
|
||||
#undef IOS_REF
|
||||
@@ -37,41 +39,44 @@
|
||||
void InitializeSdkObjects(KFbxSdkManager*& pSdkManager, KFbxScene*& pScene);
|
||||
void DestroySdkObjects(KFbxSdkManager* pSdkManager);
|
||||
bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename);
|
||||
void LoadNode(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
||||
void LoadMesh(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
||||
void LoadLight(std::vector<KRResource *> &resources, KFbxNode* pNode);
|
||||
void LoadNode(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
||||
void LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode);
|
||||
void LoadLight(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxNode* pNode);
|
||||
|
||||
|
||||
std::vector<KRResource *> KRResource::LoadFbx(const std::string& path)
|
||||
{
|
||||
std::vector<KRResource *> resources;
|
||||
KRScene *pScene = new KRScene(KRResource::GetFileBase(path));
|
||||
resources.push_back(pScene);
|
||||
|
||||
|
||||
|
||||
KFbxSdkManager* lSdkManager = NULL;
|
||||
KFbxScene* pScene = NULL;
|
||||
KFbxScene* pFbxScene = NULL;
|
||||
bool lResult;
|
||||
KFbxGeometryConverter *pGeometryConverter = NULL;
|
||||
|
||||
// Prepare the FBX SDK.
|
||||
InitializeSdkObjects(lSdkManager, pScene);
|
||||
InitializeSdkObjects(lSdkManager, pFbxScene);
|
||||
|
||||
// Initialize Geometry Converter
|
||||
pGeometryConverter = new KFbxGeometryConverter(lSdkManager);
|
||||
|
||||
// Load the scene.
|
||||
lResult = LoadScene(lSdkManager, pScene, path.c_str());
|
||||
lResult = LoadScene(lSdkManager, pFbxScene, path.c_str());
|
||||
|
||||
|
||||
// ----====---- Walk Through Scene ----====----
|
||||
|
||||
int i;
|
||||
KFbxNode* pNode = pScene->GetRootNode();
|
||||
KFbxNode* pNode = pFbxScene->GetRootNode();
|
||||
|
||||
if(pNode)
|
||||
{
|
||||
for(i = 0; i < pNode->GetChildCount(); i++)
|
||||
{
|
||||
LoadNode(resources, pGeometryConverter, pNode->GetChild(i));
|
||||
LoadNode(pScene->getRootNode(), resources, pGeometryConverter, pNode->GetChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +237,7 @@ bool LoadScene(KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pF
|
||||
return lStatus;
|
||||
}
|
||||
|
||||
void LoadNode(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
||||
void LoadNode(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
||||
KFbxVector4 lTmpVector;
|
||||
|
||||
/*
|
||||
@@ -247,10 +252,10 @@ void LoadNode(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeom
|
||||
KFbxNodeAttribute::EAttributeType attribute_type = (pNode->GetNodeAttribute()->GetAttributeType());
|
||||
switch(attribute_type) {
|
||||
case KFbxNodeAttribute::eMESH:
|
||||
LoadMesh(resources, pGeometryConverter, pNode);
|
||||
LoadMesh(parent_node, resources, pGeometryConverter, pNode);
|
||||
break;
|
||||
case KFbxNodeAttribute::eLIGHT:
|
||||
LoadLight(resources, pNode);
|
||||
LoadLight(parent_node, resources, pNode);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -258,11 +263,24 @@ void LoadNode(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeom
|
||||
// Load child nodes
|
||||
for(int i = 0; i < pNode->GetChildCount(); i++)
|
||||
{
|
||||
LoadNode(resources, pGeometryConverter, pNode->GetChild(i));
|
||||
LoadNode(parent_node, resources, pGeometryConverter, pNode->GetChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
void LoadMesh(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
||||
void LoadMesh(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeometryConverter, KFbxNode* pNode) {
|
||||
std::string shadow_map = pNode->GetName();
|
||||
shadow_map.append("_lightmap");
|
||||
|
||||
KRInstance *new_instance = new KRInstance(pNode->GetName(), pNode->GetName(), KRMat4(), shadow_map);
|
||||
fbxDouble3 local_rotation = pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET);
|
||||
fbxDouble3 local_translation = pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET);
|
||||
fbxDouble3 local_scale = pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET);
|
||||
new_instance->setLocalRotation(KRVector3(local_rotation[0], local_rotation[1], local_rotation[2]));
|
||||
new_instance->setLocalTranslation(KRVector3(local_translation[0], local_translation[1], local_translation[2]));
|
||||
new_instance->setLocalScale(KRVector3(local_scale[0], local_scale[1], local_scale[2]));
|
||||
parent_node->addChild(new_instance);
|
||||
|
||||
|
||||
printf("Mesh: %s\n", pNode->GetName());
|
||||
KFbxMesh* pSourceMesh = (KFbxMesh*) pNode->GetNodeAttribute();
|
||||
KFbxMesh* pMesh = pGeometryConverter->TriangulateMesh(pSourceMesh);
|
||||
@@ -558,7 +576,10 @@ void LoadMesh(std::vector<KRResource *> &resources, KFbxGeometryConverter *pGeom
|
||||
|
||||
}
|
||||
|
||||
void LoadLight(std::vector<KRResource *> &resources, KFbxNode* pNode) {
|
||||
void LoadLight(KRNode *parent_node, std::vector<KRResource *> &resources, KFbxNode* pNode) {
|
||||
const GLfloat PI = 3.14159265;
|
||||
const GLfloat d2r = PI * 2 / 360;
|
||||
|
||||
KFbxLight* pLight = (KFbxLight*) pNode->GetNodeAttribute();
|
||||
const char *szName = pNode->GetName();
|
||||
|
||||
@@ -575,19 +596,55 @@ void LoadLight(std::vector<KRResource *> &resources, KFbxNode* pNode) {
|
||||
// KFbxLight::eQUADRATIC - attenuation of 1/d^2
|
||||
// KFbxLight::eCUBIC - attenuation of
|
||||
|
||||
KFbxVector4 light_translation = pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET);
|
||||
KFbxVector4 light_rotation = pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET);
|
||||
KFbxVector4 light_scaling = pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET);
|
||||
|
||||
|
||||
KRVector3 translation = KRVector3(light_translation[0], light_translation[1], light_translation[2]);
|
||||
|
||||
KRLight *new_light = NULL;
|
||||
|
||||
switch(pLight->LightType.Get()) {
|
||||
case KFbxLight::ePOINT:
|
||||
resources.push_back(new KRPointLight(szName));
|
||||
{
|
||||
KRPointLight *l = new KRPointLight(szName);
|
||||
new_light = l;
|
||||
|
||||
}
|
||||
break;
|
||||
case KFbxLight::eDIRECTIONAL:
|
||||
resources.push_back(new KRDirectionalLight(szName));
|
||||
{
|
||||
KRDirectionalLight *l = new KRDirectionalLight(szName);
|
||||
new_light = l;
|
||||
}
|
||||
break;
|
||||
case KFbxLight::eSPOT:
|
||||
resources.push_back(new KRSpotLight(szName));
|
||||
{
|
||||
KRSpotLight *l = new KRSpotLight(szName);
|
||||
l->setInnerAngle(light_hotspot * d2r);
|
||||
l->setOuterAngle(light_coneangle * d2r);
|
||||
new_light = l;
|
||||
}
|
||||
break;
|
||||
case KFbxLight::eAREA:
|
||||
// Not supported yet
|
||||
break;
|
||||
}
|
||||
|
||||
if(new_light) {
|
||||
fbxDouble3 local_rotation = pNode->GetGeometricRotation(KFbxNode::eSOURCE_SET);
|
||||
fbxDouble3 local_translation = pNode->GetGeometricTranslation(KFbxNode::eSOURCE_SET);
|
||||
fbxDouble3 local_scale = pNode->GetGeometricScaling(KFbxNode::eSOURCE_SET);
|
||||
new_light->setLocalRotation(KRVector3(local_rotation[0], local_rotation[1], local_rotation[2]));
|
||||
new_light->setLocalTranslation(KRVector3(local_translation[0], local_translation[1], local_translation[2]));
|
||||
new_light->setLocalScale(KRVector3(local_scale[0], local_scale[1], local_scale[2]));
|
||||
new_light->setColor(KRVector3(light_color[0], light_color[1], light_color[2]));
|
||||
new_light->setIntensity(light_intensity);
|
||||
new_light->setDecayStart(light_decaystart);
|
||||
|
||||
parent_node->addChild(new_light);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ class KRResource
|
||||
public:
|
||||
std::string getName();
|
||||
virtual std::string getExtension() = 0;
|
||||
virtual bool save(const std::string& path) = 0;
|
||||
|
||||
static std::string GetFileExtension(const std::string& name);
|
||||
static std::string GetFileBase(const std::string& name);
|
||||
@@ -29,7 +30,7 @@ public:
|
||||
static std::vector<KRResource *> Load(const std::string& path);
|
||||
|
||||
virtual ~KRResource();
|
||||
virtual bool save(const std::string& path) = 0;
|
||||
|
||||
protected:
|
||||
KRResource(std::string name);
|
||||
|
||||
|
||||
@@ -33,26 +33,35 @@
|
||||
|
||||
#import "KRVector3.h"
|
||||
#import "KRMat4.h"
|
||||
#import "tinyxml2.h"
|
||||
|
||||
#import "KRScene.h"
|
||||
|
||||
KRScene::KRScene() {
|
||||
KRScene::KRScene(std::string name) : KRResource(name) {
|
||||
m_pExtents = NULL;
|
||||
m_pRootNode = new KRNode("scene_root");
|
||||
}
|
||||
KRScene::~KRScene() {
|
||||
for(vector<KRInstance *>::iterator itr = m_instances.begin(); itr != m_instances.end(); ++itr){
|
||||
delete *itr;
|
||||
}
|
||||
m_instances.empty();
|
||||
|
||||
delete m_pRootNode;
|
||||
m_pRootNode = NULL;
|
||||
|
||||
clearExtents();
|
||||
}
|
||||
KRInstance *KRScene::addInstance(KRModel *pModel, KRMat4 modelMatrix, std::string shadow_map) {
|
||||
KRInstance *KRScene::addInstance(std::string instance_name, std::string model_name, KRMat4 modelMatrix, std::string shadow_map) {
|
||||
clearExtents();
|
||||
KRInstance *pInstance = new KRInstance(pModel, modelMatrix, shadow_map);
|
||||
KRInstance *pInstance = new KRInstance(instance_name, model_name, modelMatrix, shadow_map);
|
||||
m_instances.push_back(pInstance);
|
||||
return pInstance;
|
||||
}
|
||||
void KRScene::render(KRCamera *pCamera, KRBoundingVolume &frustrumVolume, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager) {
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
void KRScene::render(KRCamera *pCamera, KRModelManager *pModelManager, KRBoundingVolume &frustrumVolume, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager) {
|
||||
|
||||
if(cShadowBuffers > 0 && !bRenderShadowMap) {
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
@@ -85,27 +94,29 @@ void KRScene::render(KRCamera *pCamera, KRBoundingVolume &frustrumVolume, KRMate
|
||||
for(vector<KRInstance *>::iterator itr = m_instances.begin(); itr != m_instances.end(); ++itr){
|
||||
KRInstance *pInstance = *itr;
|
||||
|
||||
if(pInstance->getExtents().test_intersect(frustrumVolume) || bRenderShadowMap) {
|
||||
pInstance->render(pCamera, pMaterialManager, bRenderShadowMap, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, pShaderManager, pTextureManager);
|
||||
if(pInstance->getExtents(pModelManager).test_intersect(frustrumVolume) || bRenderShadowMap) {
|
||||
pInstance->render(pCamera, pModelManager, pMaterialManager, bRenderShadowMap, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, pShaderManager, pTextureManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KRScene::calcExtents() {
|
||||
#endif
|
||||
|
||||
void KRScene::calcExtents(KRModelManager *pModelManager) {
|
||||
clearExtents();
|
||||
for(vector<KRInstance *>::iterator itr = m_instances.begin(); itr != m_instances.end(); ++itr){
|
||||
KRInstance *pInstance = *itr;
|
||||
if(m_pExtents) {
|
||||
*m_pExtents = m_pExtents->get_union(pInstance->getExtents());
|
||||
*m_pExtents = m_pExtents->get_union(pInstance->getExtents(pModelManager));
|
||||
} else {
|
||||
m_pExtents = new KRBoundingVolume(pInstance->getExtents());
|
||||
m_pExtents = new KRBoundingVolume(pInstance->getExtents(pModelManager));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KRBoundingVolume KRScene::getExtents() {
|
||||
KRBoundingVolume KRScene::getExtents(KRModelManager *pModelManager) {
|
||||
if(!m_pExtents) {
|
||||
calcExtents();
|
||||
calcExtents(pModelManager);
|
||||
}
|
||||
return *m_pExtents;
|
||||
}
|
||||
@@ -116,3 +127,30 @@ void KRScene::clearExtents() {
|
||||
m_pExtents = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string KRScene::getExtension() {
|
||||
return "krscene";
|
||||
}
|
||||
|
||||
KRNode *KRScene::getRootNode() {
|
||||
return m_pRootNode;
|
||||
}
|
||||
|
||||
bool KRScene::save(const std::string& path) {
|
||||
tinyxml2::XMLDocument doc;
|
||||
tinyxml2::XMLNode *scene_node = doc.InsertEndChild( doc.NewElement( "scene" ));
|
||||
m_pRootNode->saveXML(scene_node);
|
||||
doc.SaveFile(path.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
KRScene *KRScene::LoadXML(const std::string& path)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
doc.LoadFile(path.c_str());
|
||||
KRScene *new_scene = new KRScene(KRResource::GetFileBase(path));
|
||||
|
||||
return new_scene;
|
||||
}
|
||||
|
||||
@@ -40,24 +40,41 @@
|
||||
#import "KRMat4.h"
|
||||
#import "KRModel.h"
|
||||
#import "KRCamera.h"
|
||||
|
||||
#import "KRModelManager.h"
|
||||
#import "KRNode.h"
|
||||
class KRBoundingVolume;
|
||||
class KRInstance;
|
||||
|
||||
using std::vector;
|
||||
|
||||
class KRScene {
|
||||
class KRScene : public KRResource {
|
||||
public:
|
||||
KRScene();
|
||||
KRScene(std::string name);
|
||||
~KRScene();
|
||||
KRInstance *addInstance(KRModel *pModel, KRMat4 modelMatrix, std::string shadow_map);
|
||||
void render(KRCamera *pCamera, KRBoundingVolume &frustrumVolume, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager);
|
||||
KRBoundingVolume getExtents();
|
||||
|
||||
virtual std::string getExtension();
|
||||
virtual bool save(const std::string& path);
|
||||
|
||||
static KRScene *LoadXML(const std::string& path);
|
||||
|
||||
KRInstance *addInstance(std::string instance_name, std::string model_name, KRMat4 modelMatrix, std::string shadow_map);
|
||||
KRNode *getRootNode();
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
void render(KRCamera *pCamera, KRModelManager *pModelManager, KRBoundingVolume &frustrumVolume, KRMaterialManager *pMaterialManager, bool bRenderShadowMap, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRShaderManager *pShaderManager, KRTextureManager *pTextureManager);
|
||||
|
||||
#endif
|
||||
|
||||
KRBoundingVolume getExtents(KRModelManager *pModelManager);
|
||||
private:
|
||||
vector<KRInstance *> m_instances;
|
||||
KRNode *m_pRootNode;
|
||||
|
||||
|
||||
KRBoundingVolume *m_pExtents;
|
||||
|
||||
void calcExtents();
|
||||
void calcExtents(KRModelManager *pModelManager);
|
||||
void clearExtents();
|
||||
};
|
||||
|
||||
|
||||
62
KREngine/KREngine/Classes/KRSceneManager.cpp
Normal file
62
KREngine/KREngine/Classes/KRSceneManager.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// KRSceneManager.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 "KRSceneManager.h"
|
||||
|
||||
KRSceneManager::KRSceneManager() {
|
||||
}
|
||||
|
||||
KRSceneManager::~KRSceneManager() {
|
||||
for(map<std::string, KRScene *>::iterator itr = m_scenes.begin(); itr != m_scenes.end(); ++itr){
|
||||
delete (*itr).second;
|
||||
}
|
||||
m_scenes.empty();
|
||||
}
|
||||
|
||||
KRScene *KRSceneManager::loadScene(const char *szName, const char *szPath) {
|
||||
KRScene *pScene = KRScene::LoadXML(szName);
|
||||
m_scenes[szName] = pScene;
|
||||
return pScene;
|
||||
}
|
||||
|
||||
KRScene *KRSceneManager::getScene(const char *szName) {
|
||||
return m_scenes[szName];
|
||||
}
|
||||
|
||||
KRScene *KRSceneManager::getFirstScene() {
|
||||
static std::map<std::string, KRScene *>::iterator Scene_itr = m_scenes.begin();
|
||||
return (*Scene_itr).second;
|
||||
}
|
||||
|
||||
std::map<std::string, KRScene *> KRSceneManager::getScenes() {
|
||||
return m_scenes;
|
||||
}
|
||||
|
||||
63
KREngine/KREngine/Classes/KRSceneManager.h
Normal file
63
KREngine/KREngine/Classes/KRSceneManager.h
Normal file
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// KRSceneManager.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 KRENGINE_KRSCENEMANAGER_H
|
||||
#define KRENGINE_KRSCENEMANAGER_H
|
||||
|
||||
#import "KREngine-common.h"
|
||||
|
||||
#include "KRScene.h"
|
||||
|
||||
#include <map>
|
||||
#import <string>
|
||||
using std::map;
|
||||
|
||||
|
||||
class KRSceneManager {
|
||||
public:
|
||||
KRSceneManager();
|
||||
~KRSceneManager();
|
||||
|
||||
KRScene *loadScene(const char *szName, const char *szPath);
|
||||
|
||||
KRScene *getScene(const char *szName);
|
||||
KRScene *getFirstScene();
|
||||
|
||||
std::vector<std::string> getSceneNames();
|
||||
std::map<std::string, KRScene *> getScenes();
|
||||
|
||||
|
||||
private:
|
||||
std::map<std::string, KRScene *> m_scenes;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -19,7 +19,28 @@ KRSpotLight::~KRSpotLight()
|
||||
|
||||
}
|
||||
|
||||
bool KRSpotLight::save(const std::string& path)
|
||||
{
|
||||
return true;
|
||||
std::string KRSpotLight::getElementName() {
|
||||
return "spot_light";
|
||||
}
|
||||
|
||||
tinyxml2::XMLElement *KRSpotLight::saveXML( tinyxml2::XMLNode *parent)
|
||||
{
|
||||
tinyxml2::XMLElement *e = KRLight::saveXML(parent);
|
||||
e->SetAttribute("inner_angle", m_innerAngle);
|
||||
e->SetAttribute("outer_angle", m_outerAngle);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
float KRSpotLight::getInnerAngle() {
|
||||
return m_innerAngle;
|
||||
}
|
||||
float KRSpotLight::getOuterAngle() {
|
||||
return m_outerAngle;
|
||||
}
|
||||
void KRSpotLight::setInnerAngle(float innerAngle) {
|
||||
m_innerAngle = innerAngle;
|
||||
}
|
||||
void KRSpotLight::setOuterAngle(float outerAngle) {
|
||||
m_outerAngle = outerAngle;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,19 @@
|
||||
class KRSpotLight : public KRLight {
|
||||
public:
|
||||
KRSpotLight(std::string name);
|
||||
~KRSpotLight();
|
||||
virtual ~KRSpotLight();
|
||||
|
||||
virtual bool save(const std::string& path);
|
||||
virtual std::string getElementName();
|
||||
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
||||
|
||||
float getInnerAngle();
|
||||
float getOuterAngle();
|
||||
void setInnerAngle(float innerAngle);
|
||||
void setOuterAngle(float outerAngle);
|
||||
|
||||
private:
|
||||
float m_innerAngle; // Inner angle of the cone, in radians. Inside this radius, the light will be at full brightness
|
||||
float m_outerAngle; // Outer angle of the cone, in radians. Outside this radius, the light will be completely attenuated
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ KRTexture::~KRTexture() {
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
bool KRTexture::loadFromFile(const char *szFile) {
|
||||
struct stat statbuf;
|
||||
m_fdFile = open(szFile, O_RDONLY);
|
||||
@@ -179,6 +181,8 @@ bool KRTexture::loadFromFile(const char *szFile) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool KRTexture::createGLTexture() {
|
||||
int width = m_iWidth;
|
||||
int height = m_iHeight;
|
||||
|
||||
@@ -45,7 +45,11 @@ public:
|
||||
KRTexture();
|
||||
~KRTexture();
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
bool loadFromFile(const char *szFile);
|
||||
|
||||
#endif
|
||||
bool createGLTexture();
|
||||
GLuint getName();
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ KRTextureManager::~KRTextureManager() {
|
||||
}
|
||||
}
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
KRTexture *KRTextureManager::loadTexture(const char *szName, const char *szPath) {
|
||||
KRTexture *pTexture = new KRTexture();
|
||||
if(!pTexture->loadFromFile(szPath)) {
|
||||
@@ -64,6 +66,8 @@ KRTexture *KRTextureManager::loadTexture(const char *szName, const char *szPath)
|
||||
return pTexture;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
GLuint KRTextureManager::getTextureName(const char *szName) {
|
||||
KRTexture *pTexture = getTexture(szName);
|
||||
if(pTexture) {
|
||||
|
||||
@@ -44,7 +44,12 @@ public:
|
||||
KRTextureManager();
|
||||
~KRTextureManager();
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
|
||||
KRTexture *loadTexture(const char *szName, const char *szPath);
|
||||
|
||||
#endif
|
||||
|
||||
GLuint getTextureName(const char *szName);
|
||||
KRTexture *getTexture(const char *szFile);
|
||||
|
||||
|
||||
1816
KREngine/KREngine/Classes/tinyxml2.cpp
Normal file
1816
KREngine/KREngine/Classes/tinyxml2.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1389
KREngine/KREngine/Classes/tinyxml2.h
Normal file
1389
KREngine/KREngine/Classes/tinyxml2.h
Normal file
File diff suppressed because it is too large
Load Diff
289
KREngine/KREngine/Classes/tinyxml2_readme.txt
Executable file
289
KREngine/KREngine/Classes/tinyxml2_readme.txt
Executable file
@@ -0,0 +1,289 @@
|
||||
/** @mainpage
|
||||
|
||||
<h1> TinyXML-2 </h1>
|
||||
|
||||
TinyXML is a simple, small, efficient, C++ XML parser that can be
|
||||
easily integrated into other programs.
|
||||
|
||||
The master is hosted on github:
|
||||
github.com/leethomason/tinyxml2
|
||||
|
||||
The online HTML version of these docs:
|
||||
http://grinninglizard.com/tinyxml2docs/index.html
|
||||
|
||||
Examples are in the "related pages" tab of the HTML docs.
|
||||
|
||||
<h2> What it does. </h2>
|
||||
|
||||
In brief, TinyXML parses an XML document, and builds from that a
|
||||
Document Object Model (DOM) that can be read, modified, and saved.
|
||||
|
||||
XML stands for "eXtensible Markup Language." It is a general purpose
|
||||
human and machine readable markup language to describe arbitrary data.
|
||||
All those random file formats created to store application data can
|
||||
all be replaced with XML. One parser for everything.
|
||||
|
||||
http://en.wikipedia.org/wiki/XML
|
||||
|
||||
There are different ways to access and interact with XML data.
|
||||
TinyXML-2 uses a Document Object Model (DOM), meaning the XML data is parsed
|
||||
into a C++ objects that can be browsed and manipulated, and then
|
||||
written to disk or another output stream. You can also construct an XML document
|
||||
from scratch with C++ objects and write this to disk or another output
|
||||
stream. You can even use TinyXML-2 to stream XML programmatically from
|
||||
code without creating a document first.
|
||||
|
||||
TinyXML-2 is designed to be easy and fast to learn. It is one header and
|
||||
one cpp file. Simply add these to your project and off you go.
|
||||
There is an example file - xmltest.cpp - to get you started.
|
||||
|
||||
TinyXML-2 is released under the ZLib license,
|
||||
so you can use it in open source or commercial code. The details
|
||||
of the license are at the top of every source file.
|
||||
|
||||
TinyXML-2 attempts to be a flexible parser, but with truly correct and
|
||||
compliant XML output. TinyXML-2 should compile on any reasonably C++
|
||||
compliant system. It does not rely on exceptions, RTTI, or the STL.
|
||||
|
||||
<h2> What it doesn't do. </h2>
|
||||
|
||||
TinyXML-2 doesn't parse or use DTDs (Document Type Definitions) or XSLs
|
||||
(eXtensible Stylesheet Language.) There are other parsers out there
|
||||
that are much more fully
|
||||
featured. But they are also much bigger, take longer to set up in
|
||||
your project, have a higher learning curve, and often have a more
|
||||
restrictive license. If you are working with browsers or have more
|
||||
complete XML needs, TinyXML-2 is not the parser for you.
|
||||
|
||||
<h2> TinyXML-1 vs. TinyXML-2 </h2>
|
||||
|
||||
Which should you use? TinyXML-2 uses a similar API to TinyXML-1 and the same
|
||||
rich test cases. But the implementation of the parser is completely re-written
|
||||
to make it more appropriate for use in a game. It uses less memory, is faster,
|
||||
and uses far few memory allocations.
|
||||
|
||||
TinyXML-2 has no requirement for STL, but has also dropped all STL support. All
|
||||
strings are query and set as 'const char*'. This allows the use of internal
|
||||
allocators, and keeps the code much simpler.
|
||||
|
||||
Both parsers:
|
||||
<ol>
|
||||
<li>Simple to use with similar APIs.</li>
|
||||
<li>DOM based parser.</li>
|
||||
<li>UTF-8 Unicode support. http://en.wikipedia.org/wiki/UTF-8 </li>
|
||||
</ol>
|
||||
|
||||
Advantages of TinyXML-2
|
||||
<ol>
|
||||
<li>The focus of all future dev.</li>
|
||||
<li>Many fewer memory allocation (1/10th to 1/100th), uses less memory (about 40% of TinyXML-1), and faster.</li>
|
||||
<li>No STL requirement.</li>
|
||||
<li>More modern C++, including a proper namespace.</li>
|
||||
<li>Proper and useful handling of whitespace</li>
|
||||
</ol>
|
||||
|
||||
Advantages of TinyXML-1
|
||||
<ol>
|
||||
<li>Can report the location of parsing errors.</li>
|
||||
<li>Support for some C++ STL conventions: streams and strings</li>
|
||||
<li>Very mature and well debugged code base.</li>
|
||||
</ol>
|
||||
|
||||
<h2> Features </h2>
|
||||
|
||||
<h3> Memory Model </h3>
|
||||
|
||||
An XMLDocument is a C++ object like any other, that can be on the stack, or
|
||||
new'd and deleted on the heap.
|
||||
|
||||
However, any sub-node of the Document, XMLElement, XMLText, etc, can only
|
||||
be created by calling the appropriate XMLDocument::NewElement, NewText, etc.
|
||||
method. Although you have pointers to these objects, they are still owned
|
||||
by the Document. When the Document is deleted, so are all the nodes it contains.
|
||||
|
||||
<h3> White Space </h3>
|
||||
|
||||
Microsoft has an excellent article on white space: http://msdn.microsoft.com/en-us/library/ms256097.aspx
|
||||
|
||||
TinyXML-2 preserves white space in a (hopefully) sane way that is almost complient with the
|
||||
spec.(TinyXML-1 used a completely outdated model.)
|
||||
|
||||
As a first step, all newlines / carriage-returns / line-feeds are normalized to a
|
||||
line-feed character, as required by the XML spec.
|
||||
|
||||
White space in text is preserved. For example:
|
||||
|
||||
<element> Hello, World</element>
|
||||
|
||||
The leading space before the "Hello" and the double space after the comma are
|
||||
preserved. Line-feeds are preserved, as in this example:
|
||||
|
||||
<element> Hello again,
|
||||
World</element>
|
||||
|
||||
However, white space between elements is *not* preserved. Although not strictly
|
||||
compliant, tracking and reporting inter-element space is awkward, and not normally
|
||||
valuable. TinyXML-2 sees these as the same XML:
|
||||
|
||||
<document>
|
||||
<data>1</data>
|
||||
<data>2</data>
|
||||
<data>3</data>
|
||||
</document>
|
||||
|
||||
<document><data>1</data><data>2</data><data>3</data></document>
|
||||
|
||||
<h3> Entities </h3>
|
||||
TinyXML-2 recognizes the pre-defined "character entities", meaning special
|
||||
characters. Namely:
|
||||
|
||||
& &
|
||||
< <
|
||||
> >
|
||||
" "
|
||||
' '
|
||||
|
||||
These are recognized when the XML document is read, and translated to there
|
||||
UTF-8 equivalents. For instance, text with the XML of:
|
||||
|
||||
Far & Away
|
||||
|
||||
will have the Value() of "Far & Away" when queried from the XMLText object,
|
||||
and will be written back to the XML stream/file as an ampersand.
|
||||
|
||||
Additionally, any character can be specified by its Unicode code point:
|
||||
The syntax " " or " " are both to the non-breaking space characher.
|
||||
This is called a 'numeric character reference'. Any numeric character reference
|
||||
that isn't one of the special entities above, will be read, but written as a
|
||||
regular code point. The output is correct, but the entity syntax isn't preserved.
|
||||
|
||||
<h3> Printing </h3>
|
||||
|
||||
<h4> Print to file </h4>
|
||||
You can directly use the convenience function:
|
||||
|
||||
XMLDocument doc;
|
||||
...
|
||||
doc.Save( "foo.xml" );
|
||||
|
||||
Or the XMLPrinter class:
|
||||
|
||||
XMLPrinter printer( fp );
|
||||
doc.Print( &printer );
|
||||
|
||||
<h4> Print to memory </h4>
|
||||
Printing to memory is supported by the XMLPrinter.
|
||||
|
||||
XMLPrinter printer;
|
||||
doc->Print( &printer );
|
||||
// printer.CStr() has a const char* to the XML
|
||||
|
||||
<h4> Print without an XMLDocument </h4>
|
||||
|
||||
When loading, an XML parser is very useful. However, sometimes
|
||||
when saving, it just gets in the way. The code is often set up
|
||||
for streaming, and constructing the DOM is just overhead.
|
||||
|
||||
The Printer supports the streaming case. The following code
|
||||
prints out a trivially simple XML file without ever creating
|
||||
an XML document.
|
||||
|
||||
XMLPrinter printer( fp );
|
||||
printer.OpenElement( "foo" );
|
||||
printer.PushAttribute( "foo", "bar" );
|
||||
printer.CloseElement();
|
||||
|
||||
<h2> Examples </h2>
|
||||
|
||||
<h4> Load and parse an XML file. </h4>
|
||||
@verbatim
|
||||
/* ------ Example 1: Load and parse an XML file. ---- */
|
||||
{
|
||||
XMLDocument doc;
|
||||
doc.LoadFile( "dream.xml" );
|
||||
}
|
||||
@endverbatim
|
||||
|
||||
<h4> Lookup information. </h4>
|
||||
@verbatim
|
||||
/* ------ Example 2: Lookup information. ---- */
|
||||
{
|
||||
XMLDocument doc;
|
||||
doc.LoadFile( "dream.xml" );
|
||||
|
||||
// Structure of the XML file:
|
||||
// - Element "PLAY" the root Element, which is the
|
||||
// FirstChildElement of the Document
|
||||
// - - Element "TITLE" child of the root PLAY Element
|
||||
// - - - Text child of the TITLE Element
|
||||
|
||||
// Navigate to the title, using the convenience function,
|
||||
// with a dangerous lack of error checking.
|
||||
const char* title = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->GetText();
|
||||
printf( "Name of play (1): %s\n", title );
|
||||
|
||||
// Text is just another Node to TinyXML-2. The more
|
||||
// general way to get to the XMLText:
|
||||
XMLText* textNode = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->FirstChild()->ToText();
|
||||
title = textNode->Value();
|
||||
printf( "Name of play (2): %s\n", title );
|
||||
}
|
||||
@endverbatim
|
||||
|
||||
<h2> Using and Installing </h2>
|
||||
|
||||
There are 2 files in TinyXML-2:
|
||||
<ol>
|
||||
<li>tinyxml2.cpp</li>
|
||||
<li>tinyxml2.h</li>
|
||||
</ol>
|
||||
And additionally a test file:
|
||||
<ol>
|
||||
<li>xmltest.cpp</li>
|
||||
</ol>
|
||||
|
||||
Simply compile and run. There is a visual studio 2010 project included, a simple Makefile,
|
||||
an XCode project, and a cmake CMakeLists.txt included to help you. The top of tinyxml.h
|
||||
even has a simple g++ command line if you are are *nix and don't want to use a build system.
|
||||
|
||||
<h2> Documentation </h2>
|
||||
|
||||
The documentation is build with Doxygen, using the 'dox'
|
||||
configuration file.
|
||||
|
||||
<h2> License </h2>
|
||||
|
||||
TinyXML-2 is released under the zlib license:
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
<h2> Contributors </h2>
|
||||
|
||||
Thanks very much to everyone who sends suggestions, bugs, ideas, and
|
||||
encouragement. It all helps, and makes this project fun.
|
||||
|
||||
The original TinyXML-1 has many contributors, who all deserve thanks
|
||||
in shaping what is a very successful library. Extra thanks to Yves
|
||||
Berquin and Andrew Ellerton who were key contributors.
|
||||
|
||||
TinyXML-2 grew from that effort. Lee Thomason is the original author
|
||||
of TinyXML-2 (and TinyXML-1) but hopefully TinyXML-2 will be improved
|
||||
by many contributors.
|
||||
*/
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
KREngine *renderEngine;
|
||||
|
||||
KRScene m_scene;
|
||||
KRScene *m_pScene;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,10 @@
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if(m_pScene) {
|
||||
delete m_pScene;
|
||||
m_pScene = NULL;
|
||||
}
|
||||
if(renderEngine) {
|
||||
[renderEngine release];
|
||||
renderEngine = nil;
|
||||
@@ -99,9 +103,18 @@
|
||||
|
||||
- (BOOL)loadObjects
|
||||
{
|
||||
m_pScene = new KRScene("default");
|
||||
|
||||
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
|
||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||
|
||||
for (NSString* fileName in [fileManager contentsOfDirectoryAtPath: documentsDirectory error:nil]) {
|
||||
if([fileName hasSuffix: @".scene"]) {
|
||||
NSString* path = [NSString stringWithFormat:@"%@/%@", documentsDirectory, fileName];
|
||||
[renderEngine loadResource: path];
|
||||
}
|
||||
}
|
||||
|
||||
for (NSString* fileName in [fileManager contentsOfDirectoryAtPath: documentsDirectory error:nil]) {
|
||||
if([fileName hasSuffix: @".pvr"]) {
|
||||
NSString* path = [NSString stringWithFormat:@"%@/%@", documentsDirectory, fileName];
|
||||
@@ -134,7 +147,7 @@
|
||||
for(std::map<std::string, KRModel *>::iterator itr=models.begin(); itr != models.end(); itr++) {
|
||||
std::string lightmap = (*itr).first;
|
||||
lightmap.append("_lightmap");
|
||||
m_scene.addInstance((*itr).second, KRMat4(), lightmap);
|
||||
m_pScene->addInstance((*itr).second->getName(), (*itr).second->getName(), KRMat4(), lightmap);
|
||||
|
||||
}
|
||||
|
||||
@@ -242,7 +255,7 @@
|
||||
|
||||
- (KRScene *)getScene;
|
||||
{
|
||||
return &m_scene;
|
||||
return m_pScene;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
pos.rotate((double)rand() / (double)RAND_MAX * 6.282, Y_AXIS);
|
||||
pos.translate((double)rand() / (double)RAND_MAX * 10000 - 5000, 0.0, (double)rand() / (double)RAND_MAX * 10000 - 5000);
|
||||
|
||||
scene->addInstance(pModelManager->getModel(szName), pos, "");
|
||||
scene->addInstance(szName, szName, pos, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user