diff --git a/src/Common/Common.pro b/src/Common/Common.pro index 80c07e1c..52d2ad74 100644 --- a/src/Common/Common.pro +++ b/src/Common/Common.pro @@ -6,6 +6,7 @@ QT -= core gui QMAKE_CXXFLAGS += /WX +DEFINES += PWE_COMMON CONFIG += staticlib TEMPLATE = lib @@ -22,7 +23,12 @@ CONFIG (debug, debug|release) { TARGET = Commond # Debug Libs - LIBS += -L$$PWD/../../externals/FileIO/lib/ -lFileIOd + LIBS += -L$$PWD/../../build/FileIO/ -lFileIOd + + # Debug Target Dependencies + win32 { + PRE_TARGETDEPS += $$PWD/../../build/FileIO/FileIOd.lib + } } CONFIG (release, debug|release) { @@ -31,21 +37,24 @@ CONFIG (release, debug|release) { TARGET = Common # Release Libs - LIBS += -L$$PWD/../../externals/FileIO/lib/ -lFileIO + LIBS += -L$$PWD/../../build/FileIO/ -lFileIO + + # Release Target Dependencies + win32 { + PRE_TARGETDEPS += $$PWD/../../build/FileIO/FileIO.lib + } } # Debug/Release Libs LIBS += -L$$PWD/../../externals/lzo-2.08/lib -llzo-2.08 \ - -L$$PWD/../../externals/zlib/lib -lzdll \ + -L$$PWD/../../externals/zlib/lib -lzdll # Include Paths INCLUDEPATH += $$PWD/.. \ - $$PWD/../../externals/FileIO/include \ - $$PWD/../../externals/glm/glm \ $$PWD/../../externals/lzo-2.08/include \ $$PWD/../../externals/zlib/include -# Source Files +# Header Files HEADERS += \ AnimUtil.h \ CColor.h \ @@ -59,20 +68,9 @@ HEADERS += \ EnumUtil.h \ ETransformSpace.h \ TString.h \ - types.h \ - Math/CAABox.h \ - Math/CFrustumPlanes.h \ - Math/CMatrix4f.h \ - Math/CPlane.h \ - Math/CQuaternion.h \ - Math/CRay.h \ - Math/CTransform4f.h \ - Math/CVector2f.h \ - Math/CVector2i.h \ - Math/CVector3f.h \ - Math/CVector4f.h \ - Math/Math.h + types.h +# Source Files SOURCES += \ AnimUtil.cpp \ CColor.cpp \ @@ -81,16 +79,4 @@ SOURCES += \ CompressionUtil.cpp \ CTimer.cpp \ CUniqueID.cpp \ - TString.cpp \ - Math/CAABox.cpp \ - Math/CFrustumPlanes.cpp \ - Math/CMatrix4f.cpp \ - Math/CPlane.cpp \ - Math/CQuaternion.cpp \ - Math/CRay.cpp \ - Math/CTransform4f.cpp \ - Math/CVector2f.cpp \ - Math/CVector2i.cpp \ - Math/CVector3f.cpp \ - Math/CVector4f.cpp \ - Math/Math.cpp + TString.cpp diff --git a/src/Core/CRayCollisionTester.h b/src/Core/CRayCollisionTester.h index 3dc547ff..ef62a17a 100644 --- a/src/Core/CRayCollisionTester.h +++ b/src/Core/CRayCollisionTester.h @@ -4,10 +4,10 @@ #include "SRayIntersection.h" #include "Core/Render/SViewInfo.h" #include "Core/Resource/Model/CBasicModel.h" -#include -#include -#include #include +#include +#include +#include #include diff --git a/src/Core/Core.pro b/src/Core/Core.pro index ef32c13a..c4640929 100644 --- a/src/Core/Core.pro +++ b/src/Core/Core.pro @@ -6,6 +6,7 @@ QT -= core gui QMAKE_CXXFLAGS += /WX +DEFINES += PWE_CORE CONFIG += staticlib TEMPLATE = lib @@ -23,14 +24,18 @@ CONFIG (debug, debug|release) { TARGET = Cored # Debug Libs - LIBS += -L$$PWD/../../build/Common/ -lCommond \ + LIBS += -L$$PWD/../../build/FileIO/ -lFileIOd \ + -L$$PWD/../../build/Common/ -lCommond \ + -L$$PWD/../../build/Math/ -lMathd \ -L$$PWD/../../externals/assimp/lib/ -lassimp-vc120-mtd \ -L$$PWD/../../externals/boost_1_56_0/lib32-msvc-12.0 -llibboost_filesystem-vc120-mt-gd-1_56 \ - -L$$PWD/../../externals/FileIO/lib/ -lFileIOd \ -L$$PWD/../../externals/tinyxml2/lib/ -ltinyxml2d + # Debug Target Dependencies win32 { - PRE_TARGETDEPS += $$PWD/../../build/Common/Commond.lib + PRE_TARGETDEPS += $$PWD/../../build/FileIO/FileIOd.lib \ + $$PWD/../../build/Common/Commond.lib \ + $$PWD/../../build/Math/Mathd.lib } } @@ -40,14 +45,18 @@ CONFIG (release, debug|release) { TARGET = Core # Release Libs - LIBS += -L$$PWD/../../build/Common/ -lCommon \ + LIBS += -L$$PWD/../../build/FileIO/ -lFileIO \ + -L$$PWD/../../build/Common/ -lCommon \ + -L$$PWD/../../build/Math/ -lMath \ -L$$PWD/../../externals/assimp/lib/ -lassimp-vc120-mt \ -L$$PWD/../../externals/boost_1_56_0/lib32-msvc-12.0 -llibboost_filesystem-vc120-mt-1_56 \ - -L$$PWD/../../externals/FileIO/lib/ -lFileIO \ -L$$PWD/../../externals/tinyxml2/lib/ -ltinyxml2 + # Release Target Dependencies win32 { - PRE_TARGETDEPS += -L$$PWD/../../build/Common/Common.lib + PRE_TARGETDEPS += $$PWD/../../build/FileIO/FileIO.lib \ + $$PWD/../../build/Common/Common.lib \ + $$PWD/../../build/Math/Math.lib } } @@ -60,14 +69,13 @@ LIBS += -L$$PWD/../../externals/glew-1.9.0/lib/ -lglew32s \ INCLUDEPATH += $$PWD/../ \ $$PWD/../../externals/assimp/include \ $$PWD/../../externals/boost_1_56_0 \ - $$PWD/../../externals/FileIO/include \ $$PWD/../../externals/glew-1.9.0/include \ $$PWD/../../externals/glm/glm \ $$PWD/../../externals/lzo-2.08/include \ $$PWD/../../externals/tinyxml2/include \ $$PWD/../../externals/zlib/include -# Source Files +# Header Files HEADERS += \ Render/CCamera.h \ Render/CDrawUtil.h \ @@ -171,6 +179,7 @@ HEADERS += \ OpenGL/CVertexBuffer.h \ OpenGL/GLCommon.h +# Source Files SOURCES += \ Render/CCamera.cpp \ Render/CDrawUtil.cpp \ diff --git a/src/Core/OpenGL/CDynamicVertexBuffer.h b/src/Core/OpenGL/CDynamicVertexBuffer.h index e2969fef..0bb280b0 100644 --- a/src/Core/OpenGL/CDynamicVertexBuffer.h +++ b/src/Core/OpenGL/CDynamicVertexBuffer.h @@ -3,8 +3,8 @@ #include "Core/Resource/Model/EVertexDescription.h" #include -#include -#include +#include +#include #include #include diff --git a/src/Core/OpenGL/CIndexBuffer.h b/src/Core/OpenGL/CIndexBuffer.h index 79737a8b..f0a2d87d 100644 --- a/src/Core/OpenGL/CIndexBuffer.h +++ b/src/Core/OpenGL/CIndexBuffer.h @@ -2,7 +2,7 @@ #define CINDEXBUFFER_H #include -#include +#include #include class CIndexBuffer diff --git a/src/Core/Render/CCamera.cpp b/src/Core/Render/CCamera.cpp index a970a767..880010ec 100644 --- a/src/Core/Render/CCamera.cpp +++ b/src/Core/Render/CCamera.cpp @@ -1,7 +1,7 @@ #include "CCamera.h" #include "CGraphics.h" -#include -#include +#include +#include #include CCamera::CCamera() diff --git a/src/Core/Render/CCamera.h b/src/Core/Render/CCamera.h index fac736f4..6e918d03 100644 --- a/src/Core/Render/CCamera.h +++ b/src/Core/Render/CCamera.h @@ -1,15 +1,15 @@ #ifndef CCAMERA_H #define CCAMERA_H -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include enum ECameraMoveMode { diff --git a/src/Core/Render/CDrawUtil.cpp b/src/Core/Render/CDrawUtil.cpp index 3b711d10..1ca2afb3 100644 --- a/src/Core/Render/CDrawUtil.cpp +++ b/src/Core/Render/CDrawUtil.cpp @@ -2,7 +2,7 @@ #include "CGraphics.h" #include "Core/Resource/CResCache.h" #include "Core/Log.h" -#include +#include #include // ************ MEMBER INITIALIZATION ************ diff --git a/src/Core/Render/CGraphics.h b/src/Core/Render/CGraphics.h index 4befa2a0..09ab9b0c 100644 --- a/src/Core/Render/CGraphics.h +++ b/src/Core/Render/CGraphics.h @@ -5,9 +5,9 @@ #include "Core/OpenGL/CVertexArrayManager.h" #include "Core/Resource/CLight.h" #include -#include -#include -#include +#include +#include +#include #include /** diff --git a/src/Core/Render/CRenderer.cpp b/src/Core/Render/CRenderer.cpp index 121f6c6c..666faf86 100644 --- a/src/Core/Render/CRenderer.cpp +++ b/src/Core/Render/CRenderer.cpp @@ -4,8 +4,8 @@ #include "CGraphics.h" #include "Core/Resource/CResCache.h" #include "Core/Resource/Factory/CTextureDecoder.h" +#include #include -#include #include #include diff --git a/src/Core/Render/CRenderer.h b/src/Core/Render/CRenderer.h index 2bfd41d5..57c59289 100644 --- a/src/Core/Render/CRenderer.h +++ b/src/Core/Render/CRenderer.h @@ -14,9 +14,9 @@ #include "Core/Resource/CTexture.h" #include "Core/Scene/CSceneNode.h" -#include -#include #include +#include +#include #include diff --git a/src/Core/Render/SRenderablePtr.h b/src/Core/Render/SRenderablePtr.h index 5c7ede86..fdbeb037 100644 --- a/src/Core/Render/SRenderablePtr.h +++ b/src/Core/Render/SRenderablePtr.h @@ -4,8 +4,8 @@ #include "ERenderCommand.h" #include "Core/Resource/CMaterial.h" #include "Core/Scene/CSceneNode.h" -#include #include +#include struct SRenderablePtr { diff --git a/src/Core/Render/SViewInfo.h b/src/Core/Render/SViewInfo.h index c148494e..119643d0 100644 --- a/src/Core/Render/SViewInfo.h +++ b/src/Core/Render/SViewInfo.h @@ -1,9 +1,9 @@ #ifndef SVIEWINFO #define SVIEWINFO -#include -#include -#include +#include +#include +#include struct SViewInfo { diff --git a/src/Core/Resource/CCollisionMesh.h b/src/Core/Resource/CCollisionMesh.h index 91233587..bcaf0aab 100644 --- a/src/Core/Resource/CCollisionMesh.h +++ b/src/Core/Resource/CCollisionMesh.h @@ -4,7 +4,7 @@ #include "CResource.h" #include "Core/OpenGL/CVertexBuffer.h" #include "Core/OpenGL/CIndexBuffer.h" -#include +#include class CCollisionMesh { diff --git a/src/Core/Resource/CGameArea.h b/src/Core/Resource/CGameArea.h index 9ac0c3c0..6ea0b5e9 100644 --- a/src/Core/Resource/CGameArea.h +++ b/src/Core/Resource/CGameArea.h @@ -8,7 +8,7 @@ #include "Core/Resource/Model/CModel.h" #include "Core/Resource/Model/CStaticModel.h" #include -#include +#include #include diff --git a/src/Core/Resource/CLight.h b/src/Core/Resource/CLight.h index 2c43dccc..dc9a7006 100644 --- a/src/Core/Resource/CLight.h +++ b/src/Core/Resource/CLight.h @@ -3,7 +3,7 @@ #include #include -#include +#include /* CLight is currently heavily based on the lights system from Metroid Prime, * including code reverse engineered from the game's executable. Not yet sure diff --git a/src/Core/Resource/CTexture.h b/src/Core/Resource/CTexture.h index 8a0076ab..dc3f2574 100644 --- a/src/Core/Resource/CTexture.h +++ b/src/Core/Resource/CTexture.h @@ -3,9 +3,9 @@ #include "CResource.h" #include "ETexelFormat.h" -#include -#include #include +#include +#include #include diff --git a/src/Core/Resource/CWorld.h b/src/Core/Resource/CWorld.h index d20df61b..cad2110b 100644 --- a/src/Core/Resource/CWorld.h +++ b/src/Core/Resource/CWorld.h @@ -6,7 +6,7 @@ #include "CStringTable.h" #include "SDependency.h" #include "Core/Resource/Model/CModel.h" -#include +#include class CWorld : public CResource { diff --git a/src/Core/Resource/Model/CBasicModel.h b/src/Core/Resource/Model/CBasicModel.h index b2a2ecb7..b5722c9e 100644 --- a/src/Core/Resource/Model/CBasicModel.h +++ b/src/Core/Resource/Model/CBasicModel.h @@ -4,7 +4,7 @@ #include "SSurface.h" #include "Core/Resource/CResource.h" #include "Core/OpenGL/CVertexBuffer.h" -#include +#include class CBasicModel : public CResource { diff --git a/src/Core/Resource/Model/CVertex.h b/src/Core/Resource/Model/CVertex.h index 682a8bb1..363e33db 100644 --- a/src/Core/Resource/Model/CVertex.h +++ b/src/Core/Resource/Model/CVertex.h @@ -1,9 +1,9 @@ #ifndef CVERTEX_H #define CVERTEX_H -#include -#include #include +#include +#include class CVertex { diff --git a/src/Core/Resource/Model/SSurface.cpp b/src/Core/Resource/Model/SSurface.cpp index bcbd6b78..6b38f509 100644 --- a/src/Core/Resource/Model/SSurface.cpp +++ b/src/Core/Resource/Model/SSurface.cpp @@ -1,7 +1,7 @@ #include "SSurface.h" #include "Core/Render/CDrawUtil.h" #include "Core/CRayCollisionTester.h" -#include +#include std::pair SSurface::IntersectsRay(const CRay& Ray, bool allowBackfaces, float LineThreshold) { diff --git a/src/Core/Resource/Model/SSurface.h b/src/Core/Resource/Model/SSurface.h index d61b1e9e..d3770a8f 100644 --- a/src/Core/Resource/Model/SSurface.h +++ b/src/Core/Resource/Model/SSurface.h @@ -6,10 +6,10 @@ #include "Core/OpenGL/GLCommon.h" #include "Core/SRayIntersection.h" #include -#include -#include -#include -#include +#include +#include +#include +#include #include struct SSurface diff --git a/src/Core/Resource/Script/CProperty.h b/src/Core/Resource/Script/CProperty.h index 1b50737d..fe794749 100644 --- a/src/Core/Resource/Script/CProperty.h +++ b/src/Core/Resource/Script/CProperty.h @@ -9,9 +9,9 @@ #include "Core/Resource/CResource.h" #include "Core/Resource/TResPtr.h" #include "Core/Resource/CAnimationParameters.h" -#include #include #include +#include #include class CScriptTemplate; diff --git a/src/Core/Scene/CLightNode.cpp b/src/Core/Scene/CLightNode.cpp index b10aa656..4dea6d14 100644 --- a/src/Core/Scene/CLightNode.cpp +++ b/src/Core/Scene/CLightNode.cpp @@ -2,7 +2,7 @@ #include "Core/Render/CDrawUtil.h" #include "Core/Render/CGraphics.h" #include "Core/Render/CRenderer.h" -#include +#include CLightNode::CLightNode(CSceneManager *pScene, CSceneNode *pParent, CLight *Light) : CSceneNode(pScene, pParent) diff --git a/src/Core/Scene/CModelNode.cpp b/src/Core/Scene/CModelNode.cpp index 62504626..63923fcd 100644 --- a/src/Core/Scene/CModelNode.cpp +++ b/src/Core/Scene/CModelNode.cpp @@ -2,7 +2,7 @@ #include "Core/Render/CDrawUtil.h" #include "Core/Render/CRenderer.h" #include "Core/Render/CGraphics.h" -#include +#include CModelNode::CModelNode(CSceneManager *pScene, CSceneNode *pParent, CModel *pModel) : CSceneNode(pScene, pParent) { diff --git a/src/Core/Scene/CSceneManager.cpp b/src/Core/Scene/CSceneManager.cpp index 1efe80e6..fa6b1b97 100644 --- a/src/Core/Scene/CSceneManager.cpp +++ b/src/Core/Scene/CSceneManager.cpp @@ -4,9 +4,9 @@ #include "Core/Resource/Script/CScriptLayer.h" #include "Core/CRayCollisionTester.h" -#include -#include #include +#include +#include #include #include diff --git a/src/Core/Scene/CSceneNode.cpp b/src/Core/Scene/CSceneNode.cpp index 8783f5e9..06514fe0 100644 --- a/src/Core/Scene/CSceneNode.cpp +++ b/src/Core/Scene/CSceneNode.cpp @@ -4,7 +4,7 @@ #include "Core/Render/CDrawUtil.h" #include "Core/Resource/CGameArea.h" #include -#include +#include #include #include diff --git a/src/Core/Scene/CSceneNode.h b/src/Core/Scene/CSceneNode.h index ffd6c4b3..4ff68648 100644 --- a/src/Core/Scene/CSceneNode.h +++ b/src/Core/Scene/CSceneNode.h @@ -7,13 +7,13 @@ #include "Core/Resource/CLight.h" #include "Core/Resource/CGameArea.h" #include "Core/CRayCollisionTester.h" -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include class CRenderer; class CSceneManager; diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index 1ce3757b..2f24cb47 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -8,7 +8,7 @@ #include "Core/Resource/Script/CScriptLayer.h" #include "Core/ScriptExtra/CScriptExtra.h" #include -#include +#include CScriptNode::CScriptNode(CSceneManager *pScene, CSceneNode *pParent, CScriptObject *pObject) : CSceneNode(pScene, pParent) diff --git a/src/Core/Scene/CStaticNode.cpp b/src/Core/Scene/CStaticNode.cpp index aa97f77c..962abe90 100644 --- a/src/Core/Scene/CStaticNode.cpp +++ b/src/Core/Scene/CStaticNode.cpp @@ -3,7 +3,7 @@ #include "Core/Render/CDrawUtil.h" #include "Core/Render/CRenderer.h" #include -#include +#include CStaticNode::CStaticNode(CSceneManager *pScene, CSceneNode *pParent, CStaticModel *pModel) : CSceneNode(pScene, pParent) diff --git a/src/Editor/CBasicViewport.cpp b/src/Editor/CBasicViewport.cpp index b7476713..8ded6eaa 100644 --- a/src/Editor/CBasicViewport.cpp +++ b/src/Editor/CBasicViewport.cpp @@ -1,7 +1,7 @@ #include "CBasicViewport.h" +#include #include #include -#include #include diff --git a/src/Editor/CBasicViewport.h b/src/Editor/CBasicViewport.h index fd3d4f36..ab2e72c4 100644 --- a/src/Editor/CBasicViewport.h +++ b/src/Editor/CBasicViewport.h @@ -1,12 +1,12 @@ #ifndef CEDITORGLWIDGET_H #define CEDITORGLWIDGET_H +#include +#include +#include +#include #include #include -#include -#include -#include -#include #include #include diff --git a/src/Editor/CGizmo.cpp b/src/Editor/CGizmo.cpp index d9e704e0..84c46611 100644 --- a/src/Editor/CGizmo.cpp +++ b/src/Editor/CGizmo.cpp @@ -1,5 +1,5 @@ #include "CGizmo.h" -#include +#include #include #include #include diff --git a/src/Editor/CGizmo.h b/src/Editor/CGizmo.h index a736047a..29fc3909 100644 --- a/src/Editor/CGizmo.h +++ b/src/Editor/CGizmo.h @@ -1,11 +1,11 @@ #ifndef CGIZMO_H #define CGIZMO_H -#include -#include -#include -#include #include +#include +#include +#include +#include #include #include #include diff --git a/src/Editor/Editor.pro b/src/Editor/Editor.pro index e1705943..ede8ad50 100644 --- a/src/Editor/Editor.pro +++ b/src/Editor/Editor.pro @@ -6,6 +6,7 @@ QT += core gui opengl widgets QMAKE_CXXFLAGS += /WX +DEFINES += PWE_EDITOR RESOURCES += Icons.qrc CONFIG += console @@ -22,14 +23,18 @@ CONFIG(debug, debug|release) { TARGET = PrimeWorldEditor-debug # Debug Libs - LIBS += -L$$PWD/../../build/Common/ -lCommond \ + LIBS += -L$$PWD/../../build/FileIO/ -lFileIOd \ + -L$$PWD/../../build/Common/ -lCommond \ + -L$$PWD/../../build/Math/ -lMathd \ -L$$PWD/../../build/Core/ -lCored \ -L$$PWD/../../externals/assimp/lib/ -lassimp-vc120-mtd \ - -L$$PWD/../../externals/FileIO/lib/ -lFileIOd \ -L$$PWD/../../externals/tinyxml2/lib/ -ltinyxml2d + # Debug Target Dependencies win32 { - PRE_TARGETDEPS += $$PWD/../../build/Common/Commond.lib \ + PRE_TARGETDEPS += $$PWD/../../build/FileIO/FileIOd.lib \ + $$PWD/../../build/Common/Commond.lib \ + $$PWD/../../build/Math/Mathd.lib \ $$PWD/../../build/Core/Cored.lib } } @@ -42,15 +47,19 @@ CONFIG(release, debug|release) { TARGET = PrimeWorldEditor # Release Libs - LIBS += -L$$PWD/../../build/Common/ -lCommon \ + LIBS += -L$$PWD/../../build/FileIO/ -lFileIO \ + -L$$PWD/../../build/Common/ -lCommon \ + -L$$PWD/../../build/Math/ -lMath \ -L$$PWD/../../build/Core/ -lCore \ -L$$PWD/../../externals/assimp/lib/ -lassimp-vc120-mt \ - -L$$PWD/../../externals/FileIO/lib/ -lFileIO \ -L$$PWD/../../externals/tinyxml2/lib/ -ltinyxml2 + # Release Target Dependencies win32 { - PRE_TARGETDEPS += -L$$PWD/../../build/Common/ -lCommon \ - -L$$PWD/../../build/Core/ -lCore + PRE_TARGETDEPS += $$PWD/../../build/FileIO/FileIO.lib \ + $$PWD/../../build/Common/Common.lib \ + $$PWD/../../build/Math/Math.lib \ + $$PWD/../../build/Core/Core.lib } } @@ -63,14 +72,13 @@ LIBS += -L$$PWD/../../externals/glew-1.9.0/lib/ -lglew32s \ INCLUDEPATH += $$PWD/../ \ $$PWD/../../externals/assimp/include \ $$PWD/../../externals/boost_1_56_0 \ - $$PWD/../../externals/FileIO/include \ $$PWD/../../externals/glew-1.9.0/include \ $$PWD/../../externals/glm/glm \ $$PWD/../../externals/lzo-2.08/include \ $$PWD/../../externals/tinyxml2/include \ $$PWD/../../externals/zlib/include -# Source Files +# Header Files HEADERS += \ ModelEditor/CModelEditorViewport.h \ ModelEditor/CModelEditorWindow.h \ @@ -116,6 +124,7 @@ HEADERS += \ TestDialog.h \ UICommon.h +# Source Files SOURCES += \ ModelEditor/CModelEditorViewport.cpp \ ModelEditor/CModelEditorWindow.cpp \ @@ -160,6 +169,7 @@ SOURCES += \ TestDialog.cpp \ UICommon.cpp +# UI Files FORMS += \ CStartWindow.ui \ TestDialog.ui \ diff --git a/src/Editor/INodeEditor.h b/src/Editor/INodeEditor.h index 26c21dc1..d0544ab3 100644 --- a/src/Editor/INodeEditor.h +++ b/src/Editor/INodeEditor.h @@ -2,7 +2,7 @@ #define INODEEDITOR_H #include "CGizmo.h" -#include +#include #include #include diff --git a/src/Editor/Widgets/WTextureGLWidget.cpp b/src/Editor/Widgets/WTextureGLWidget.cpp index f5f3f285..d6f38b64 100644 --- a/src/Editor/Widgets/WTextureGLWidget.cpp +++ b/src/Editor/Widgets/WTextureGLWidget.cpp @@ -1,9 +1,9 @@ #include "WTextureGLWidget.h" +#include +#include #include #include #include -#include -#include #include #include diff --git a/src/Editor/Widgets/WTextureGLWidget.h b/src/Editor/Widgets/WTextureGLWidget.h index b11c9cf9..8b3e7178 100644 --- a/src/Editor/Widgets/WTextureGLWidget.h +++ b/src/Editor/Widgets/WTextureGLWidget.h @@ -1,8 +1,8 @@ #ifndef WTEXTUREGLWIDGET_H #define WTEXTUREGLWIDGET_H -#include -#include +#include +#include #include #include diff --git a/src/Editor/Widgets/WVectorEditor.h b/src/Editor/Widgets/WVectorEditor.h index 59804d44..c51bf0e2 100644 --- a/src/Editor/Widgets/WVectorEditor.h +++ b/src/Editor/Widgets/WVectorEditor.h @@ -2,7 +2,7 @@ #define WVECTOREDITOR_H #include "WDraggableSpinBox.h" -#include +#include #include #include diff --git a/src/Editor/WorldEditor/CWorldEditor.h b/src/Editor/WorldEditor/CWorldEditor.h index 80d500ad..770e0586 100644 --- a/src/Editor/WorldEditor/CWorldEditor.h +++ b/src/Editor/WorldEditor/CWorldEditor.h @@ -4,10 +4,10 @@ #include "Editor/INodeEditor.h" #include "Editor/CGizmo.h" -#include -#include #include #include +#include +#include #include #include #include diff --git a/src/FileIO/CFileInStream.cpp b/src/FileIO/CFileInStream.cpp new file mode 100644 index 00000000..398e1af0 --- /dev/null +++ b/src/FileIO/CFileInStream.cpp @@ -0,0 +1,112 @@ +#include "CFileInStream.h" + +CFileInStream::CFileInStream() +{ + mFStream = nullptr; +} + +CFileInStream::CFileInStream(std::string File) +{ + mFStream = nullptr; + Open(File, IOUtil::BigEndian); +} + +CFileInStream::CFileInStream(std::string File, IOUtil::EEndianness FileEndianness) +{ + mFStream = nullptr; + Open(File, FileEndianness); +} + +CFileInStream::CFileInStream(CFileInStream& src) +{ + mFStream = nullptr; + Open(src.mName, src.mDataEndianness); + + if (src.IsValid()) + Seek(src.Tell(), SEEK_SET); +} + +CFileInStream::~CFileInStream() +{ + if (IsValid()) + Close(); +} + +void CFileInStream::Open(std::string File, IOUtil::EEndianness FileEndianness) +{ + if (IsValid()) + Close(); + + fopen_s(&mFStream, File.c_str(), "rb"); + mName = File; + mDataEndianness = FileEndianness; + + if (IsValid()) + { + Seek(0x0, SEEK_END); + mFileSize = Tell(); + Seek(0x0, SEEK_SET); + } + else + mFileSize = 0; + + size_t EndPath = File.find_last_of("\\/"); + SetSourceString(File.substr(EndPath + 1, File.length() - EndPath)); +} + +void CFileInStream::Close() +{ + if (IsValid()) + fclose(mFStream); + mFStream = nullptr; +} + +void CFileInStream::ReadBytes(void *dst, unsigned long Count) +{ + if (!IsValid()) return; + fread(dst, 1, Count, mFStream); +} + +bool CFileInStream::Seek(long Offset, long Origin) +{ + if (!IsValid()) return false; + return (fseek(mFStream, Offset, Origin) != 0); +} + +bool CFileInStream::Seek64(long long Offset, long Origin) +{ + if (!IsValid()) return false; + return (_fseeki64(mFStream, Offset, Origin) != 0); +} + +long CFileInStream::Tell() const +{ + if (!IsValid()) return 0; + return ftell(mFStream); +} + +long long CFileInStream::Tell64() const +{ + if (!IsValid()) return 0; + return _ftelli64(mFStream); +} + +bool CFileInStream::EoF() const +{ + return (Tell() >= mFileSize); +} + +bool CFileInStream::IsValid() const +{ + return (mFStream != 0); +} + +long CFileInStream::Size() const +{ + return mFileSize; +} + +std::string CFileInStream::FileName() const +{ + return mName; +} diff --git a/src/FileIO/CFileInStream.h b/src/FileIO/CFileInStream.h new file mode 100644 index 00000000..41e2eed3 --- /dev/null +++ b/src/FileIO/CFileInStream.h @@ -0,0 +1,34 @@ +#ifndef CFILEINSTREAM_H +#define CFILEINSTREAM_H + +#include "CInputStream.h" +#include "IOUtil.h" + +class CFileInStream : public CInputStream +{ +private: + FILE *mFStream; + std::string mName; + long mFileSize; + +public: + CFileInStream(); + CFileInStream(std::string file); + CFileInStream(std::string file, IOUtil::EEndianness FileEndianness); + CFileInStream(CFileInStream& src); + ~CFileInStream(); + void Open(std::string file, IOUtil::EEndianness FileEndianness); + void Close(); + + void ReadBytes(void *dst, unsigned long count); + bool Seek(long offset, long origin); + bool Seek64(long long offset, long origin); + long Tell() const; + long long Tell64() const; + bool EoF() const; + bool IsValid() const; + long Size() const; + std::string FileName() const; +}; + +#endif // CFILEINSTREAM_H diff --git a/src/FileIO/CFileOutStream.cpp b/src/FileIO/CFileOutStream.cpp new file mode 100644 index 00000000..71d806a0 --- /dev/null +++ b/src/FileIO/CFileOutStream.cpp @@ -0,0 +1,118 @@ +#include "CFileOutStream.h" + +CFileOutStream::CFileOutStream() +{ + mFStream = nullptr; + mSize = 0; +} + +CFileOutStream::CFileOutStream(std::string File) +{ + mFStream = nullptr; + Open(File, IOUtil::BigEndian); +} + +CFileOutStream::CFileOutStream(std::string File, IOUtil::EEndianness FileEndianness) +{ + mFStream = nullptr; + Open(File, FileEndianness); +} + +CFileOutStream::CFileOutStream(CFileOutStream& src) +{ + mFStream = nullptr; + Open(src.mName, src.mDataEndianness); + + if (src.IsValid()) + Seek(src.Tell(), SEEK_SET); +} + +CFileOutStream::~CFileOutStream() +{ + if (IsValid()) + Close(); +} + +void CFileOutStream::Open(std::string File, IOUtil::EEndianness FileEndianness) +{ + if (IsValid()) + Close(); + + fopen_s(&mFStream, File.c_str(), "wb"); + mName = File; + mDataEndianness = FileEndianness; + mSize = 0; +} + +void CFileOutStream::Update(std::string File, IOUtil::EEndianness FileEndianness) +{ + if (IsValid()) + Close(); + + fopen_s(&mFStream, File.c_str(), "rb+"); + mName = File; + mDataEndianness = FileEndianness; + Seek(0x0, SEEK_END); + mSize = Tell(); + Seek(0x0, SEEK_SET); +} + +void CFileOutStream::Close() +{ + if (IsValid()) + fclose(mFStream); + mFStream = nullptr; + mSize = 0; +} + +void CFileOutStream::WriteBytes(void *src, unsigned long Count) +{ + if (!IsValid()) return; + fwrite(src, 1, Count, mFStream); + if ((unsigned long) Tell() > mSize) mSize = Tell(); +} + +bool CFileOutStream::Seek(long Offset, long Origin) +{ + if (!IsValid()) return false; + return (fseek(mFStream, Offset, Origin) != 0); +} + +bool CFileOutStream::Seek64(long long Offset, long Origin) +{ + if (!IsValid()) return false; + return (_fseeki64(mFStream, Offset, Origin) != 0); +} + +long CFileOutStream::Tell() const +{ + if (!IsValid()) return 0; + return ftell(mFStream); +} + +long long CFileOutStream::Tell64() const +{ + if (!IsValid()) return 0; + return _ftelli64(mFStream); +} + +bool CFileOutStream::EoF() const +{ + return (Tell() == Size()); +} + +bool CFileOutStream::IsValid() const +{ + return (mFStream != 0); +} + +long CFileOutStream::Size() const +{ + if (!IsValid()) return 0; + return mSize; +} + +std::string CFileOutStream::FileName() const +{ + return mName; +} diff --git a/src/FileIO/CFileOutStream.h b/src/FileIO/CFileOutStream.h new file mode 100644 index 00000000..8014cf04 --- /dev/null +++ b/src/FileIO/CFileOutStream.h @@ -0,0 +1,35 @@ +#ifndef CFILEOUTSTREAM_H +#define CFILEOUTSTREAM_H + +#include "COutputStream.h" +#include "IOUtil.h" + +class CFileOutStream : public COutputStream +{ +private: + FILE *mFStream; + std::string mName; + unsigned long mSize; + +public: + CFileOutStream(); + CFileOutStream(std::string file); + CFileOutStream(std::string file, IOUtil::EEndianness FileEndianness); + CFileOutStream(CFileOutStream& src); + ~CFileOutStream(); + void Open(std::string file, IOUtil::EEndianness); + void Update(std::string file, IOUtil::EEndianness FileEndianness); + void Close(); + + void WriteBytes(void *src, unsigned long count); + bool Seek(long offset, long origin); + bool Seek64(long long offset, long origin); + long Tell() const; + long long Tell64() const; + bool EoF() const; + bool IsValid() const; + long Size() const; + std::string FileName() const; +}; + +#endif // CFILEOUTSTREAM_H diff --git a/src/FileIO/CInputStream.cpp b/src/FileIO/CInputStream.cpp new file mode 100644 index 00000000..ef743587 --- /dev/null +++ b/src/FileIO/CInputStream.cpp @@ -0,0 +1,180 @@ +#include "CInputStream.h" + +CInputStream::~CInputStream() +{ +} + +char CInputStream::ReadByte() +{ + char Val; + ReadBytes(&Val, 1); + return Val; +} + +short CInputStream::ReadShort() +{ + short Val; + ReadBytes(&Val, 2); + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + return Val; +} + +long CInputStream::ReadLong() +{ + long Val; + ReadBytes(&Val, 4); + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + return Val; +} + +long long CInputStream::ReadLongLong() +{ + long long Val; + ReadBytes(&Val, 8); + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + return Val; +} + +float CInputStream::ReadFloat() +{ + float Val; + ReadBytes(&Val, 4); + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + return Val; +} + +double CInputStream::ReadDouble() +{ + double Val; + ReadBytes(&Val, 8); + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + return Val; +} + +std::string CInputStream::ReadString() +{ + std::string Str; + char c = 1; + + while ((c != 0) && (!EoF())) + { + c = ReadByte(); + if (c != 0) Str.push_back(c); + } + + return Str; +} + +std::string CInputStream::ReadString(unsigned long Count) +{ + std::string Str(Count, 0); + + for (unsigned long c = 0; c < Count; c++) + Str[c] = ReadByte(); + + return Str; +} + +std::wstring CInputStream::ReadWString() +{ + std::wstring WStr; + short c = 1; + + while (c != 0) + { + c = ReadShort(); + if (c != 0) WStr.push_back(c); + } + + return WStr; +} + +std::wstring CInputStream::ReadWString(unsigned long Count) +{ + std::wstring WStr(Count, 0); + + for (unsigned long c = 0; c < Count; c++) + WStr[c] = ReadShort(); + + return WStr; +} + + +char CInputStream::PeekByte() +{ + char Val = ReadByte(); + Seek(-1, SEEK_CUR); + return Val; +} + +short CInputStream::PeekShort() +{ + short Val = ReadShort(); + Seek(-2, SEEK_CUR); + return Val; +} + +long CInputStream::PeekLong() +{ + long Val = ReadLong(); + Seek(-4, SEEK_CUR); + return Val; +} + +long long CInputStream::PeekLongLong() +{ + long long Val = ReadLongLong(); + Seek(-8, SEEK_CUR); + return Val; +} + +float CInputStream::PeekFloat() +{ + float Val = ReadFloat(); + Seek(-4, SEEK_CUR); + return Val; +} + +double CInputStream::PeekDouble() +{ + double Val = ReadDouble(); + Seek(-8, SEEK_CUR); + return Val; +} + +void CInputStream::SeekToBoundary(unsigned long Boundary) +{ + long Num = Boundary - (Tell() % Boundary); + if (Num == Boundary) return; + else Seek(Num, SEEK_CUR); +} + +void CInputStream::SetEndianness(IOUtil::EEndianness Endianness) +{ + mDataEndianness = Endianness; +} + +void CInputStream::SetSourceString(const std::string& source) +{ + mDataSource = source; +} + +IOUtil::EEndianness CInputStream::GetEndianness() const +{ + return mDataEndianness; +} + +std::string CInputStream::GetSourceString() const +{ + return mDataSource; +} + +bool CInputStream::Seek64(long long Offset, long Origin) +{ + return Seek((long) Offset, Origin); +} + +long long CInputStream::Tell64() const +{ + return (long long) Tell(); +} diff --git a/src/FileIO/CInputStream.h b/src/FileIO/CInputStream.h new file mode 100644 index 00000000..ee89b343 --- /dev/null +++ b/src/FileIO/CInputStream.h @@ -0,0 +1,50 @@ +#ifndef CINPUTSTREAM_H +#define CINPUTSTREAM_H + +#include "IOUtil.h" +#include +#include + +class CInputStream +{ +protected: + IOUtil::EEndianness mDataEndianness; + std::string mDataSource; + +public: + char ReadByte(); + short ReadShort(); + long ReadLong(); + long long ReadLongLong(); + float ReadFloat(); + double ReadDouble(); + std::string ReadString(); + std::string ReadString(unsigned long count); + std::wstring ReadWString(); + std::wstring ReadWString(unsigned long count); + + char PeekByte(); + short PeekShort(); + long PeekLong(); + long long PeekLongLong(); + float PeekFloat(); + double PeekDouble(); + + void SeekToBoundary(unsigned long boundary); + void SetEndianness(IOUtil::EEndianness endianness); + void SetSourceString(const std::string& source); + IOUtil::EEndianness GetEndianness() const; + std::string GetSourceString() const; + + virtual ~CInputStream(); + virtual void ReadBytes(void *dst, unsigned long count) = 0; + virtual bool Seek(long offset, long origin) = 0; + virtual bool Seek64(long long offset, long origin); + virtual long Tell() const = 0; + virtual long long Tell64() const; + virtual bool EoF() const = 0; + virtual bool IsValid() const = 0; + virtual long Size() const = 0; +}; + +#endif // CINPUTSTREAM_H diff --git a/src/FileIO/CMemoryInStream.cpp b/src/FileIO/CMemoryInStream.cpp new file mode 100644 index 00000000..0b10408e --- /dev/null +++ b/src/FileIO/CMemoryInStream.cpp @@ -0,0 +1,102 @@ +#include "CMemoryInStream.h" + +CMemoryInStream::CMemoryInStream() +{ + mDataStart = nullptr; + mDataSize = 0; + mPos = 0; +} +CMemoryInStream::CMemoryInStream(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness) +{ + SetData(Data, Size, DataEndianness); +} + +CMemoryInStream::~CMemoryInStream() +{ +} + +void CMemoryInStream::SetData(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness) +{ + mDataStart = static_cast(Data); + mDataSize = Size; + mPos = 0; + mDataEndianness = DataEndianness; +} + +void CMemoryInStream::ReadBytes(void *dst, unsigned long Count) +{ + if (!IsValid()) return; + memcpy(dst, mDataStart + mPos, Count); + mPos += Count; +} + +bool CMemoryInStream::Seek(long Offset, long Origin) +{ + if (!IsValid()) return false; + switch (Origin) + { + case SEEK_SET: + mPos = Offset; + break; + + case SEEK_CUR: + mPos += Offset; + break; + + case SEEK_END: + mPos = mDataSize - Offset; + break; + + default: + return false; + } + + if (mPos < 0) { + mPos = 0; + return false; + } + + if (mPos > mDataSize) { + mPos = mDataSize; + return false; + } + + return true; +} + +long CMemoryInStream::Tell() const +{ + return mPos; +} + +bool CMemoryInStream::EoF() const +{ + return (mPos >= mDataSize); +} + +bool CMemoryInStream::IsValid() const +{ + return (mDataStart != nullptr); +} + +long CMemoryInStream::Size() const +{ + return mDataSize; +} + +void CMemoryInStream::SetSize(unsigned long Size) +{ + mDataSize = Size; + if (mPos > mDataSize) + mPos = mDataSize; +} + +void* CMemoryInStream::Data() const +{ + return mDataStart; +} + +void* CMemoryInStream::DataAtPosition() const +{ + return mDataStart + mPos; +} diff --git a/src/FileIO/CMemoryInStream.h b/src/FileIO/CMemoryInStream.h new file mode 100644 index 00000000..1eda1054 --- /dev/null +++ b/src/FileIO/CMemoryInStream.h @@ -0,0 +1,30 @@ +#ifndef CMEMORYINSTREAM_H +#define CMEMORYINSTREAM_H + +#include "CInputStream.h" +#include "IOUtil.h" + +class CMemoryInStream : public CInputStream +{ + char *mDataStart; + long mDataSize; + long mPos; + +public: + CMemoryInStream(); + CMemoryInStream(void *Data, unsigned long Size, IOUtil::EEndianness dataEndianness); + ~CMemoryInStream(); + void SetData(void *Data, unsigned long Size, IOUtil::EEndianness dataEndianness); + + void ReadBytes(void *dst, unsigned long Count); + bool Seek(long offset, long Origin); + long Tell() const; + bool EoF() const; + bool IsValid() const; + long Size() const; + void SetSize(unsigned long Size); + void* Data() const; + void* DataAtPosition() const; +}; + +#endif // CMEMORYINSTREAM_H diff --git a/src/FileIO/CMemoryOutStream.cpp b/src/FileIO/CMemoryOutStream.cpp new file mode 100644 index 00000000..1c0dcc1d --- /dev/null +++ b/src/FileIO/CMemoryOutStream.cpp @@ -0,0 +1,113 @@ +#include "CMemoryOutStream.h" + +CMemoryOutStream::CMemoryOutStream() +{ + mDataStart = nullptr; + mDataSize = 0; + mPos = 0; + mUsed = 0; +} + +CMemoryOutStream::CMemoryOutStream(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness) +{ + SetData(Data, Size, DataEndianness); +} + +CMemoryOutStream::~CMemoryOutStream() +{ +} + +void CMemoryOutStream::SetData(void *Data, unsigned long Size, IOUtil::EEndianness DataEndianness) +{ + mDataStart = static_cast(Data); + mDataSize = Size; + mPos = 0; + mUsed = 0; + mDataEndianness = DataEndianness; +} + +void CMemoryOutStream::WriteBytes(void *src, unsigned long Count) +{ + if (!IsValid()) return; + + memcpy(mDataStart + mPos, src, Count); + mPos += Count; + if (mPos > mUsed) mUsed = mPos; +} + +bool CMemoryOutStream::Seek(long Offset, long Origin) +{ + if (!IsValid()) return false; + + switch (Origin) + { + case SEEK_SET: + mPos = Offset; + break; + + case SEEK_CUR: + mPos += Offset; + break; + + case SEEK_END: + mPos = mDataSize - Offset; + break; + + default: + return false; + } + + if (mPos < 0) { + mPos = 0; + return false; + } + + if (mPos > mDataSize) { + mPos = mDataSize; + return false; + } + + return true; +} + +long CMemoryOutStream::Tell() const +{ + return mPos; +} + +bool CMemoryOutStream::EoF() const +{ + return (mPos >= mDataSize); +} + +bool CMemoryOutStream::IsValid() const +{ + return (mDataStart != nullptr); +} + +long CMemoryOutStream::Size() const +{ + return mDataSize; +} + +long CMemoryOutStream::SpaceUsed() const +{ + return mUsed; +} + +void CMemoryOutStream::SetSize(unsigned long Size) +{ + mDataSize = Size; + if (mPos > mDataSize) + mPos = mDataSize; +} + +void* CMemoryOutStream::Data() const +{ + return mDataStart; +} + +void* CMemoryOutStream::DataAtPosition() const +{ + return mDataStart + mPos; +} diff --git a/src/FileIO/CMemoryOutStream.h b/src/FileIO/CMemoryOutStream.h new file mode 100644 index 00000000..fb5841f2 --- /dev/null +++ b/src/FileIO/CMemoryOutStream.h @@ -0,0 +1,31 @@ +#ifndef CMEMORYOUTSTREAM_H +#define CMEMORYOUTSTREAM_H + +#include "COutputStream.h" + +class CMemoryOutStream : public COutputStream +{ + char *mDataStart; + long mDataSize; + long mPos; + long mUsed; + +public: + CMemoryOutStream(); + CMemoryOutStream(void *Data, unsigned long Size, IOUtil::EEndianness mDataEndianness); + ~CMemoryOutStream(); + void SetData(void *Data, unsigned long Size, IOUtil::EEndianness mDataEndianness); + + void WriteBytes(void *src, unsigned long count); + bool Seek(long offset, long origin); + long Tell() const; + bool EoF() const; + bool IsValid() const; + long Size() const; + long SpaceUsed() const; + void SetSize(unsigned long Size); + void* Data() const; + void* DataAtPosition() const; +}; + +#endif // CMEMORYOUTSTREAM_H diff --git a/src/FileIO/COutputStream.cpp b/src/FileIO/COutputStream.cpp new file mode 100644 index 00000000..b84099bf --- /dev/null +++ b/src/FileIO/COutputStream.cpp @@ -0,0 +1,114 @@ +#include "COutputStream.h" + +COutputStream::~COutputStream() +{ +} + +void COutputStream::WriteByte(char Val) +{ + WriteBytes(&Val, 1); +} + +void COutputStream::WriteShort(short Val) +{ + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + WriteBytes(&Val, 2); +} + +void COutputStream::WriteLong(long Val) +{ + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + WriteBytes(&Val, 4); +} + +void COutputStream::WriteLongLong(long long Val) +{ + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + WriteBytes(&Val, 8); +} + +void COutputStream::WriteFloat(float Val) +{ + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + WriteBytes(&Val, 4); +} + +void COutputStream::WriteDouble(double Val) +{ + if (mDataEndianness != IOUtil::SystemEndianness) IOUtil::SwapBytes(Val); + WriteBytes(&Val, 8); +} + +void COutputStream::WriteString(std::string Val) +{ + for (unsigned int i = 0; i < Val.size(); i++) + WriteByte(Val[i]); + + if ((Val.empty()) || (Val.back() != '\0')) + WriteByte(0); +} + +void COutputStream::WriteString(std::string Val, unsigned long Count, bool Terminate) +{ + for (unsigned int i = 0; i < Count; i++) + WriteByte(Val[i]); + + if (Terminate && (Val[Count-1] != '\0')) + WriteByte(0); +} + +void COutputStream::WriteWString(std::wstring Val) +{ + for (unsigned int i = 0; i < Val.size(); i++) + WriteShort(Val[i]); + + if ((!Val.empty()) && (Val.back() != '\0')) + WriteShort(0); +} + +void COutputStream::WriteWString(std::wstring Val, unsigned long Count, bool Terminate) +{ + for (unsigned int i = 0; i < Count; i++) + WriteShort(Val[i]); + + if (Terminate && (Val[Count-1] != 0)) + WriteShort(0); +} + +void COutputStream::WriteToBoundary(unsigned long Boundary, char Fill) +{ + long Num = Boundary - (Tell() % Boundary); + if (Num == Boundary) return; + for (int i = 0; i < Num; i++) + WriteByte(Fill); +} + +void COutputStream::SetEndianness(IOUtil::EEndianness Endianness) +{ + mDataEndianness = Endianness; +} + +void COutputStream::SetDestString(const std::string &Dest) +{ + mDataDest = Dest; +} + +IOUtil::EEndianness COutputStream::GetEndianness() const +{ + return mDataEndianness; +} + +std::string COutputStream::GetDestString() const +{ + return mDataDest; +} + +bool COutputStream::Seek64(long long Offset, long Origin) +{ + return Seek((long) Offset, Origin); +} + +long long COutputStream::Tell64() const +{ + return (long long) (Tell()); +} diff --git a/src/FileIO/COutputStream.h b/src/FileIO/COutputStream.h new file mode 100644 index 00000000..38db38c5 --- /dev/null +++ b/src/FileIO/COutputStream.h @@ -0,0 +1,41 @@ +#ifndef COUTPUTSTREAM_H +#define COUTPUTSTREAM_H + +#include "IOUtil.h" +#include + +class COutputStream +{ +protected: + IOUtil::EEndianness mDataEndianness; + std::string mDataDest; + +public: + void WriteByte(char Val); + void WriteShort(short Val); + void WriteLong(long Val); + void WriteLongLong(long long Val); + void WriteFloat(float Val); + void WriteDouble(double Val); + void WriteString(std::string Val); + void WriteString(std::string Val, unsigned long Count, bool Terminate = false); + void WriteWString(std::wstring Val); + void WriteWString(std::wstring Val, unsigned long Count, bool Terminate = false); + + void WriteToBoundary(unsigned long Boundary, char Fill); + void SetEndianness(IOUtil::EEndianness Endianness); + void SetDestString(const std::string& Dest); + IOUtil::EEndianness GetEndianness() const; + std::string GetDestString() const; + + virtual ~COutputStream(); + virtual void WriteBytes(void *src, unsigned long Count) = 0; + virtual bool Seek(long Offset, long Origin) = 0; + virtual bool Seek64(long long Offset, long Origin); + virtual long Tell() const = 0; + virtual long long Tell64() const; + virtual bool EoF() const = 0; + virtual bool IsValid() const = 0; + virtual long Size() const = 0; +}; +#endif // COUTPUTSTREAM_H diff --git a/src/FileIO/CTextInStream.cpp b/src/FileIO/CTextInStream.cpp new file mode 100644 index 00000000..6a9912ce --- /dev/null +++ b/src/FileIO/CTextInStream.cpp @@ -0,0 +1,100 @@ +#include "CTextInStream.h" +#include +#include + +CTextInStream::CTextInStream(std::string File) +{ + mFStream = nullptr; + Open(File); +} + +CTextInStream::CTextInStream(CTextInStream& src) +{ + mFStream = nullptr; + Open(src.mFileName); + + if (src.IsValid()) + Seek(src.Tell(), SEEK_SET); +} + +CTextInStream::~CTextInStream() +{ + if (IsValid()) + Close(); +} + +void CTextInStream::Open(std::string File) +{ + if (IsValid()) + Close(); + + fopen_s(&mFStream, File.c_str(), "r"); + mFileName = File; + + if (IsValid()) + { + Seek(0x0, SEEK_END); + mFileSize = Tell(); + Seek(0x0, SEEK_SET); + } + else + mFileSize = 0; +} + +void CTextInStream::Close() +{ + if (IsValid()) + fclose(mFStream); + mFStream = nullptr; +} + +void CTextInStream::Scan(const char *Format, ... ) +{ + if (!IsValid()) return; + + va_list Args; + va_start(Args, Format); + vfscanf(mFStream, Format, Args); +} + +char CTextInStream::GetChar() +{ + if (!IsValid()) return 0; + return (char) fgetc(mFStream); +} + +std::string CTextInStream::GetString() +{ + if (!IsValid()) return ""; + + char Buf[0x1000]; + fgets(Buf, 0x1000, mFStream); + return std::string(Buf); +} + +long CTextInStream::Seek(long Offset, long Origin) +{ + if (!IsValid()) return 1; + return fseek(mFStream, Offset, Origin); +} + +long CTextInStream::Tell() const +{ + if (!IsValid()) return 0; + return ftell(mFStream); +} + +bool CTextInStream::EoF() const +{ + return (Tell() == mFileSize); +} + +bool CTextInStream::IsValid() const +{ + return (mFStream != 0); +} + +long CTextInStream::Size() const +{ + return mFileSize; +} diff --git a/src/FileIO/CTextInStream.h b/src/FileIO/CTextInStream.h new file mode 100644 index 00000000..7d6cdd24 --- /dev/null +++ b/src/FileIO/CTextInStream.h @@ -0,0 +1,32 @@ +#ifndef CTEXTINSTREAM_H +#define CTEXTINSTREAM_H + +#include +#include + +class CTextInStream +{ + FILE *mFStream; + std::string mFileName; + long mFileSize; + +public: + CTextInStream(); + CTextInStream(std::string File); + CTextInStream(CTextInStream& src); + ~CTextInStream(); + void Open(std::string File); + void Close(); + + void Scan(const char *Format, ... ); + char GetChar(); + std::string GetString(); + + long Seek(long Offset, long Origin); + long Tell() const; + bool EoF() const; + bool IsValid() const; + long Size() const; +}; + +#endif // CTEXTINSTREAM_H diff --git a/src/FileIO/CTextOutStream.cpp b/src/FileIO/CTextOutStream.cpp new file mode 100644 index 00000000..30af452a --- /dev/null +++ b/src/FileIO/CTextOutStream.cpp @@ -0,0 +1,94 @@ +#include "CTextOutStream.h" +#include + +CTextOutStream::CTextOutStream() +{ + mFStream = nullptr; + mSize = 0; +} + +CTextOutStream::CTextOutStream(std::string File) +{ + mFStream = nullptr; + Open(File.c_str()); +} + +CTextOutStream::CTextOutStream(CTextOutStream& src) +{ + mFStream = nullptr; + Open(src.mFileName); + + if (src.IsValid()) + Seek(src.Tell(), SEEK_SET); +} + +CTextOutStream::~CTextOutStream() +{ + if (IsValid()) + Close(); +} + +void CTextOutStream::Open(std::string File) +{ + fopen_s(&mFStream, File.c_str(), "w"); + mFileName = File; + mSize = 0; +} + +void CTextOutStream::Close() +{ + if (IsValid()) + fclose(mFStream); + mFStream = nullptr; + mSize = 0; +} + +void CTextOutStream::Print(const char *Format, ... ) +{ + if (!IsValid()) return; + + va_list Args; + va_start(Args, Format); + vfprintf(mFStream, Format, Args); +} + +void CTextOutStream::WriteChar(char c) +{ + if (!IsValid()) return; + fputc(c, mFStream); + if ((unsigned long) Tell() > mSize) mSize = Tell(); +} + +void CTextOutStream::WriteString(std::string Str) +{ + if (!IsValid()) return; + fputs(Str.c_str(), mFStream); + if ((unsigned long) Tell() > mSize) mSize = Tell(); +} + +bool CTextOutStream::Seek(long Offset, long Origin) +{ + if (!IsValid()) return false; + return (fseek(mFStream, Offset, Origin) != 0); +} + +long CTextOutStream::Tell() const +{ + if (!IsValid()) return 0; + return ftell(mFStream); +} + +bool CTextOutStream::EoF() const +{ + return (Tell() == mSize); +} + +bool CTextOutStream::IsValid() const +{ + return (mFStream != 0); +} + +long CTextOutStream::Size() const +{ + return mSize; +} diff --git a/src/FileIO/CTextOutStream.h b/src/FileIO/CTextOutStream.h new file mode 100644 index 00000000..4371a0ec --- /dev/null +++ b/src/FileIO/CTextOutStream.h @@ -0,0 +1,31 @@ +#ifndef CTEXTOUTSTREAM_H +#define CTEXTOUTSTREAM_H + +#include + +class CTextOutStream +{ + FILE *mFStream; + std::string mFileName; + unsigned long mSize; + +public: + CTextOutStream(); + CTextOutStream(std::string File); + CTextOutStream(CTextOutStream& src); + ~CTextOutStream(); + void Open(std::string file); + void Close(); + + void Print(const char *Format, ... ); + void WriteChar(char c); + void WriteString(std::string Str); + + bool Seek(long Offset, long Origin); + long Tell() const; + bool EoF() const; + bool IsValid() const; + long Size() const; +}; + +#endif // CTEXTOUTSTREAM_H diff --git a/src/FileIO/CVectorOutStream.cpp b/src/FileIO/CVectorOutStream.cpp new file mode 100644 index 00000000..787b9d43 --- /dev/null +++ b/src/FileIO/CVectorOutStream.cpp @@ -0,0 +1,132 @@ +#include "CVectorOutStream.h" + +CVectorOutStream::CVectorOutStream() +{ + mDataEndianness = IOUtil::BigEndian; + mPos = 0; + mUsed = 0; +} + +CVectorOutStream::CVectorOutStream(IOUtil::EEndianness DataEndianness) +{ + mDataEndianness = DataEndianness; + mPos = 0; + mUsed = 0; +} + +CVectorOutStream::CVectorOutStream(unsigned long InitialSize, IOUtil::EEndianness DataEndianness) +{ + mDataEndianness = DataEndianness; + mVector.resize(InitialSize); + mPos = 0; + mUsed = 0; +} + +CVectorOutStream::~CVectorOutStream() +{ +} + +void CVectorOutStream::WriteBytes(void *src, unsigned long Count) +{ + if (!IsValid()) return; + + if ((mPos + Count) > mVector.size()) + mVector.resize(mPos + Count); + + memcpy(mVector.data() + mPos, src, Count); + mPos += Count; + if (mPos > mUsed) mUsed = mPos; +} + +bool CVectorOutStream::Seek(long Offset, long Origin) +{ + if (!IsValid()) return false; + + switch (Origin) + { + case SEEK_SET: + mPos = Offset; + break; + + case SEEK_CUR: + mPos += Offset; + break; + + case SEEK_END: + mPos = mUsed - Offset; + break; + + default: + return false; + } + + if (mPos < 0) { + mPos = 0; + return false; + } + + if (mPos > mUsed) + mUsed = mPos; + + if (mPos > (signed long) mVector.size()) + mVector.resize(mPos); + + return true; +} + +long CVectorOutStream::Tell() const +{ + return mPos; +} + +bool CVectorOutStream::EoF() const +{ + return false; +} + +bool CVectorOutStream::IsValid() const +{ + return true; +} + +long CVectorOutStream::Size() const +{ + return mUsed; +} + +long CVectorOutStream::SizeRemaining() const +{ + return mVector.size() - mPos; +} + +void* CVectorOutStream::Data() +{ + return mVector.data(); +} + +void* CVectorOutStream::DataAtPosition() +{ + return mVector.data() + mPos; +} + +void CVectorOutStream::Expand(unsigned long Amount) +{ + mVector.resize(mVector.size() + Amount); +} + +void CVectorOutStream::Contract() +{ + mVector.resize(mUsed); +} + +void CVectorOutStream::Reset() +{ + mPos = 0; + mUsed = 0; +} + +void CVectorOutStream::Clear() +{ + mVector.clear(); + Reset(); +} diff --git a/src/FileIO/CVectorOutStream.h b/src/FileIO/CVectorOutStream.h new file mode 100644 index 00000000..0d3a7af5 --- /dev/null +++ b/src/FileIO/CVectorOutStream.h @@ -0,0 +1,34 @@ +#ifndef CVECTOROUTSTREAM_H +#define CVECTOROUTSTREAM_H + +#include "COutputStream.h" +#include + +class CVectorOutStream : public COutputStream +{ + std::vector mVector; + long mPos; + long mUsed; + +public: + CVectorOutStream(); + CVectorOutStream(IOUtil::EEndianness DataEndianness); + CVectorOutStream(unsigned long InitialSize, IOUtil::EEndianness DataEndianness); + ~CVectorOutStream(); + + void WriteBytes(void *src, unsigned long Count); + bool Seek(long Offset, long Origin); + long Tell() const; + bool EoF() const; + bool IsValid() const; + long Size() const; + long SizeRemaining() const; + void *Data(); + void *DataAtPosition(); + void Expand(unsigned long Amount); + void Contract(); + void Reset(); + void Clear(); +}; + +#endif // CVECTOROUTSTREAM_H diff --git a/src/FileIO/FileIO.h b/src/FileIO/FileIO.h new file mode 100644 index 00000000..28f314b7 --- /dev/null +++ b/src/FileIO/FileIO.h @@ -0,0 +1,17 @@ +#ifndef FILEIO_H +#define FILEIO_H + +#include "IOUtil.h" + +#include "CInputStream.h" +#include "CFileInStream.h" +#include "CMemoryInStream.h" +#include "CTextInStream.h" + +#include "COutputStream.h" +#include "CFileOutStream.h" +#include "CMemoryOutStream.h" +#include "CVectorOutStream.h" +#include "CTextOutStream.h" + +#endif // FILEIO diff --git a/src/FileIO/FileIO.pro b/src/FileIO/FileIO.pro new file mode 100644 index 00000000..97d5e375 --- /dev/null +++ b/src/FileIO/FileIO.pro @@ -0,0 +1,56 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-12-16T12:35:06 +# +#------------------------------------------------- + +QT -= core gui +QMAKE_CXXFLAGS += /WX + +CONFIG += staticlib +TEMPLATE = lib +DESTDIR = $$PWD/../../build/FileIO + +unix { + target.path = /usr/lib + INSTALLS += target +} + +CONFIG (debug, debug|release) { + # Debug Config + OBJECTS_DIR = $$PWD/../../build/FileIO/debug + TARGET = FileIOd +} + +CONFIG (release, debug|release) { + # Release Config + OBJECTS_DIR = $$PWD/../../build/FileIO/release + TARGET = FileIO +} + +# Header Files +HEADERS += \ + CFileInStream.h \ + CFileOutStream.h \ + CInputStream.h \ + CMemoryInStream.h \ + CMemoryOutStream.h \ + COutputStream.h \ + CTextInStream.h \ + CTextOutStream.h \ + CVectorOutStream.h \ + FileIO.h \ + IOUtil.h + +# Source Files +SOURCES += \ + CFileInStream.cpp \ + CFileOutStream.cpp \ + CInputStream.cpp \ + CMemoryInStream.cpp \ + CMemoryOutStream.cpp \ + COutputStream.cpp \ + CTextInStream.cpp \ + CTextOutStream.cpp \ + CVectorOutStream.cpp \ + IOUtil.cpp diff --git a/src/FileIO/IOUtil.cpp b/src/FileIO/IOUtil.cpp new file mode 100644 index 00000000..51ecc043 --- /dev/null +++ b/src/FileIO/IOUtil.cpp @@ -0,0 +1,79 @@ +#include "IOUtil.h" + +namespace IOUtil +{ + EEndianness FindSystemEndianness() + { + // Memory layout for a 32-bit value of 1: + // 0x01000000 - Little Endian + // 0x00000001 - Big Endian + long EndianTest = 1; + if (*(char*)&EndianTest == 1) return LittleEndian; + else return BigEndian; + } + const EEndianness SystemEndianness = FindSystemEndianness(); + + void SwapBytes(short& Val) + { + Val = (((Val & 0x00FF) << 8) | + ((Val & 0xFF00) >> 8)); + } + + void SwapBytes(unsigned short& Val) + { + Val = (((Val & 0x00FF) << 8) | + ((Val & 0xFF00) >> 8)); + } + + void SwapBytes(long& Val) + { + Val = (((Val & 0x000000FF) << 24) | + ((Val & 0x0000FF00) << 8) | + ((Val & 0x00FF0000) >> 8) | + ((Val & 0xFF000000) >> 24)); + } + + void SwapBytes(unsigned long& Val) + { + Val = (((Val & 0x000000FF) << 24) | + ((Val & 0x0000FF00) << 8) | + ((Val & 0x00FF0000) >> 8) | + ((Val & 0xFF000000) >> 24)); + } + + void SwapBytes(long long& Val) + { + Val = (((Val & 0x00000000000000FF) << 56) | + ((Val & 0x000000000000FF00) << 40) | + ((Val & 0x0000000000FF0000) << 24) | + ((Val & 0x00000000FF000000) << 8) | + ((Val & 0x000000FF00000000) >> 8) | + ((Val & 0x0000FF0000000000) >> 24) | + ((Val & 0x00FF000000000000) >> 40) | + ((Val & 0xFF00000000000000) >> 56)); + } + + void SwapBytes(unsigned long long &Val) + { + Val = (((Val & 0x00000000000000FF) << 56) | + ((Val & 0x000000000000FF00) << 40) | + ((Val & 0x0000000000FF0000) << 24) | + ((Val & 0x00000000FF000000) << 8) | + ((Val & 0x000000FF00000000) >> 8) | + ((Val & 0x0000FF0000000000) >> 24) | + ((Val & 0x00FF000000000000) >> 40) | + ((Val & 0xFF00000000000000) >> 56)); + } + + void SwapBytes(float& Val) + { + long* ptr = (long*) &Val; + SwapBytes(*ptr); + } + + void SwapBytes(double& Val) + { + long long* ptr = (long long*) &Val; + SwapBytes(*ptr); + } +} diff --git a/src/FileIO/IOUtil.h b/src/FileIO/IOUtil.h new file mode 100644 index 00000000..106dac99 --- /dev/null +++ b/src/FileIO/IOUtil.h @@ -0,0 +1,22 @@ +#ifndef IOUTIL_H +#define IOUTIL_H + +namespace IOUtil +{ + enum EEndianness { + LittleEndian, + BigEndian + }; + extern const EEndianness SystemEndianness; + + void SwapBytes(short& Val); + void SwapBytes(unsigned short& Val); + void SwapBytes(long& Val); + void SwapBytes(unsigned long& Val); + void SwapBytes(long long& Val); + void SwapBytes(unsigned long long& Val); + void SwapBytes(float& Val); + void SwapBytes(double& Val); +} + +#endif // IOUTIL_H diff --git a/src/Common/Math/CAABox.cpp b/src/Math/CAABox.cpp similarity index 99% rename from src/Common/Math/CAABox.cpp rename to src/Math/CAABox.cpp index db211a52..b24072f4 100644 --- a/src/Common/Math/CAABox.cpp +++ b/src/Math/CAABox.cpp @@ -1,7 +1,7 @@ #include "CAABox.h" -#include "CTransform4f.h" -#include "Math.h" #include "CRay.h" +#include "CTransform4f.h" +#include "MathUtil.h" #include CAABox::CAABox() diff --git a/src/Common/Math/CAABox.h b/src/Math/CAABox.h similarity index 100% rename from src/Common/Math/CAABox.h rename to src/Math/CAABox.h diff --git a/src/Common/Math/CFrustumPlanes.cpp b/src/Math/CFrustumPlanes.cpp similarity index 99% rename from src/Common/Math/CFrustumPlanes.cpp rename to src/Math/CFrustumPlanes.cpp index 8b3972c7..ffe64079 100644 --- a/src/Common/Math/CFrustumPlanes.cpp +++ b/src/Math/CFrustumPlanes.cpp @@ -1,5 +1,5 @@ #include "CFrustumPlanes.h" -#include "Math.h" +#include "MathUtil.h" #include "Common/types.h" CFrustumPlanes::CFrustumPlanes() diff --git a/src/Common/Math/CFrustumPlanes.h b/src/Math/CFrustumPlanes.h similarity index 100% rename from src/Common/Math/CFrustumPlanes.h rename to src/Math/CFrustumPlanes.h diff --git a/src/Common/Math/CMatrix4f.cpp b/src/Math/CMatrix4f.cpp similarity index 100% rename from src/Common/Math/CMatrix4f.cpp rename to src/Math/CMatrix4f.cpp diff --git a/src/Common/Math/CMatrix4f.h b/src/Math/CMatrix4f.h similarity index 100% rename from src/Common/Math/CMatrix4f.h rename to src/Math/CMatrix4f.h diff --git a/src/Common/Math/CPlane.cpp b/src/Math/CPlane.cpp similarity index 100% rename from src/Common/Math/CPlane.cpp rename to src/Math/CPlane.cpp diff --git a/src/Common/Math/CPlane.h b/src/Math/CPlane.h similarity index 100% rename from src/Common/Math/CPlane.h rename to src/Math/CPlane.h diff --git a/src/Common/Math/CQuaternion.cpp b/src/Math/CQuaternion.cpp similarity index 99% rename from src/Common/Math/CQuaternion.cpp rename to src/Math/CQuaternion.cpp index fefb64b7..6de625eb 100644 --- a/src/Common/Math/CQuaternion.cpp +++ b/src/Math/CQuaternion.cpp @@ -1,6 +1,6 @@ #include "CQuaternion.h" #include "CMatrix4f.h" -#include "Math.h" +#include "MathUtil.h" #include #include diff --git a/src/Common/Math/CQuaternion.h b/src/Math/CQuaternion.h similarity index 100% rename from src/Common/Math/CQuaternion.h rename to src/Math/CQuaternion.h diff --git a/src/Common/Math/CRay.cpp b/src/Math/CRay.cpp similarity index 100% rename from src/Common/Math/CRay.cpp rename to src/Math/CRay.cpp diff --git a/src/Common/Math/CRay.h b/src/Math/CRay.h similarity index 100% rename from src/Common/Math/CRay.h rename to src/Math/CRay.h diff --git a/src/Common/Math/CTransform4f.cpp b/src/Math/CTransform4f.cpp similarity index 100% rename from src/Common/Math/CTransform4f.cpp rename to src/Math/CTransform4f.cpp diff --git a/src/Common/Math/CTransform4f.h b/src/Math/CTransform4f.h similarity index 100% rename from src/Common/Math/CTransform4f.h rename to src/Math/CTransform4f.h diff --git a/src/Common/Math/CVector2f.cpp b/src/Math/CVector2f.cpp similarity index 98% rename from src/Common/Math/CVector2f.cpp rename to src/Math/CVector2f.cpp index fe35161a..428a86d7 100644 --- a/src/Common/Math/CVector2f.cpp +++ b/src/Math/CVector2f.cpp @@ -1,4 +1,4 @@ -#include "Common/Math/CVector2f.h" +#include "CVector2f.h" CVector2f::CVector2f() { diff --git a/src/Common/Math/CVector2f.h b/src/Math/CVector2f.h similarity index 100% rename from src/Common/Math/CVector2f.h rename to src/Math/CVector2f.h diff --git a/src/Common/Math/CVector2i.cpp b/src/Math/CVector2i.cpp similarity index 100% rename from src/Common/Math/CVector2i.cpp rename to src/Math/CVector2i.cpp diff --git a/src/Common/Math/CVector2i.h b/src/Math/CVector2i.h similarity index 100% rename from src/Common/Math/CVector2i.h rename to src/Math/CVector2i.h diff --git a/src/Common/Math/CVector3f.cpp b/src/Math/CVector3f.cpp similarity index 100% rename from src/Common/Math/CVector3f.cpp rename to src/Math/CVector3f.cpp diff --git a/src/Common/Math/CVector3f.h b/src/Math/CVector3f.h similarity index 97% rename from src/Common/Math/CVector3f.h rename to src/Math/CVector3f.h index b8ebe05b..9b06c046 100644 --- a/src/Common/Math/CVector3f.h +++ b/src/Math/CVector3f.h @@ -1,5 +1,5 @@ -#ifndef CVECTOR3F -#define CVECTOR3F +#ifndef CVECTOR3F_H +#define CVECTOR3F_H #include #include @@ -89,4 +89,4 @@ public: friend std::ostream& operator<<(std::ostream& o, const CVector3f& Vector); }; -#endif // CVECTOR3F +#endif // CVECTOR3F_H diff --git a/src/Common/Math/CVector4f.cpp b/src/Math/CVector4f.cpp similarity index 100% rename from src/Common/Math/CVector4f.cpp rename to src/Math/CVector4f.cpp diff --git a/src/Common/Math/CVector4f.h b/src/Math/CVector4f.h similarity index 100% rename from src/Common/Math/CVector4f.h rename to src/Math/CVector4f.h diff --git a/src/Common/Math/ETransformSpace.h b/src/Math/ETransformSpace.h similarity index 100% rename from src/Common/Math/ETransformSpace.h rename to src/Math/ETransformSpace.h diff --git a/src/Math/Math.pro b/src/Math/Math.pro new file mode 100644 index 00000000..aaa3ba76 --- /dev/null +++ b/src/Math/Math.pro @@ -0,0 +1,91 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2015-12-16T12:35:34 +# +#------------------------------------------------- + +QT -= core gui +QMAKE_CXXFLAGS += /WX +DEFINES += PWE_MATH + +CONFIG += staticlib +TEMPLATE = lib +DESTDIR = $$PWD/../../build/Math + +unix { + target.path = /usr/lib + INSTALLS += target +} + +CONFIG (debug, debug|release) { + # Debug Config + OBJECTS_DIR = $$PWD/../../build/Math/debug + TARGET = Mathd + + # Debug Libs + LIBS += -L$$PWD/../../build/FileIO/ -lFileIOd \ + -L$$PWD/../../build/Common/ -lCommond + + # Debug Target Dependencies + win32 { + PRE_TARGETDEPS += $$PWD/../../build/FileIO/FileIOd.lib \ + $$PWD/../../build/Common/Commond.lib + } +} + +CONFIG (release, debug|release) { + # Release Config + OBJECTS_DIR = $$PWD/../../build/Math/release + TARGET = Math + + # Release Libs + LIBS += -L$$PWD/../../build/FileIO/ -lFileIO \ + -L$$PWD/../../build/Common/ -lCommon + + # Release Target Dependencies + win32 { + PRE_TARGETDEPS += $$PWD/../../build/FileIO/FileIO.lib \ + $$PWD/../../build/Common/Common.lib + } +} + +# Debug/Release Libs +LIBS += -L$$PWD/../../externals/lzo-2.08/lib -llzo-2.08 \ + -L$$PWD/../../externals/zlib/lib -lzdll + +# Include Paths +INCLUDEPATH += $$PWD/../ \ + $$PWD/../../externals/glm/glm \ + $$PWD/../../externals/lzo-2.08/include \ + $$PWD/../../externals/zlib/include + +# Header Files +HEADERS += \ + CAABox.h \ + CFrustumPlanes.h \ + CMatrix4f.h \ + CPlane.h \ + CQuaternion.h \ + CRay.h \ + CTransform4f.h \ + CVector2f.h \ + CVector2i.h \ + CVector3f.h \ + CVector4f.h \ + ETransformSpace.h \ + MathUtil.h + +# Source Files +SOURCES += \ + CAABox.cpp \ + CFrustumPlanes.cpp \ + CMatrix4f.cpp \ + CPlane.cpp \ + CQuaternion.cpp \ + CRay.cpp \ + CTransform4f.cpp \ + CVector2f.cpp \ + CVector2i.cpp \ + CVector3f.cpp \ + CVector4f.cpp \ + MathUtil.cpp diff --git a/src/Common/Math/Math.cpp b/src/Math/MathUtil.cpp similarity index 99% rename from src/Common/Math/Math.cpp rename to src/Math/MathUtil.cpp index bf16f2ba..6587c96a 100644 --- a/src/Common/Math/Math.cpp +++ b/src/Math/MathUtil.cpp @@ -1,4 +1,4 @@ -#include "Math.h" +#include "MathUtil.h" #include "CMatrix4f.h" #include diff --git a/src/Common/Math/Math.h b/src/Math/MathUtil.h similarity index 100% rename from src/Common/Math/Math.h rename to src/Math/MathUtil.h diff --git a/src/PrimeWorldEditor.pro b/src/PrimeWorldEditor.pro index f1488908..b49ce7cd 100644 --- a/src/PrimeWorldEditor.pro +++ b/src/PrimeWorldEditor.pro @@ -8,7 +8,9 @@ QMAKE_CXXFLAGS += /WX TEMPLATE = subdirs SUBDIRS += \ + FileIO \ Common \ + Math \ Core \ Editor