Splitting Math into a separate subproject and adding FileIO as a PWE subproject
This commit is contained in:
parent
610c1c11a5
commit
2db8d23516
|
@ -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
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#include "SRayIntersection.h"
|
||||
#include "Core/Render/SViewInfo.h"
|
||||
#include "Core/Resource/Model/CBasicModel.h"
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Common/types.h>
|
||||
#include <Math/CAABox.h>
|
||||
#include <Math/CRay.h>
|
||||
#include <Math/CVector3f.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include "Core/Resource/Model/EVertexDescription.h"
|
||||
#include <Common/types.h>
|
||||
#include <Common/Math/CVector2f.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Math/CVector2f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
|
||||
#include <vector>
|
||||
#include <GL/glew.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define CINDEXBUFFER_H
|
||||
|
||||
#include <Common/types.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
class CIndexBuffer
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "CCamera.h"
|
||||
#include "CGraphics.h"
|
||||
#include <Common/Math/CQuaternion.h>
|
||||
#include <Common/Math/Math.h>
|
||||
#include <Math/CQuaternion.h>
|
||||
#include <Math/MathUtil.h>
|
||||
#include <gtc/matrix_transform.hpp>
|
||||
|
||||
CCamera::CCamera()
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#ifndef CCAMERA_H
|
||||
#define CCAMERA_H
|
||||
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Common/Math/CFrustumPlanes.h>
|
||||
#include <Common/Math/CMatrix4f.h>
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Common/Math/CVector2i.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Common/types.h>
|
||||
#include <Common/EKeyInputs.h>
|
||||
#include <Common/EMouseInputs.h>
|
||||
#include <Math/CAABox.h>
|
||||
#include <Math/CFrustumPlanes.h>
|
||||
#include <Math/CMatrix4f.h>
|
||||
#include <Math/CRay.h>
|
||||
#include <Math/CVector2i.h>
|
||||
#include <Math/CVector3f.h>
|
||||
|
||||
enum ECameraMoveMode
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "CGraphics.h"
|
||||
#include "Core/Resource/CResCache.h"
|
||||
#include "Core/Log.h"
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
#include <iostream>
|
||||
|
||||
// ************ MEMBER INITIALIZATION ************
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#include "Core/OpenGL/CVertexArrayManager.h"
|
||||
#include "Core/Resource/CLight.h"
|
||||
#include <Common/CColor.h>
|
||||
#include <Common/Math/CMatrix4f.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Common/Math/CVector4f.h>
|
||||
#include <Math/CMatrix4f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <Math/CVector4f.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "CGraphics.h"
|
||||
#include "Core/Resource/CResCache.h"
|
||||
#include "Core/Resource/Factory/CTextureDecoder.h"
|
||||
#include <Math/CTransform4f.h>
|
||||
#include <Common/AnimUtil.h>
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
#include "Core/Resource/CTexture.h"
|
||||
#include "Core/Scene/CSceneNode.h"
|
||||
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Common/Math/CMatrix4f.h>
|
||||
#include <Common/CColor.h>
|
||||
#include <Math/CAABox.h>
|
||||
#include <Math/CMatrix4f.h>
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "ERenderCommand.h"
|
||||
#include "Core/Resource/CMaterial.h"
|
||||
#include "Core/Scene/CSceneNode.h"
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Common/types.h>
|
||||
#include <Math/CAABox.h>
|
||||
|
||||
struct SRenderablePtr
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SVIEWINFO
|
||||
#define SVIEWINFO
|
||||
|
||||
#include <Common/Math/CFrustumPlanes.h>
|
||||
#include <Common/Math/CMatrix4f.h>
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Math/CFrustumPlanes.h>
|
||||
#include <Math/CMatrix4f.h>
|
||||
#include <Math/CRay.h>
|
||||
|
||||
struct SViewInfo
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "CResource.h"
|
||||
#include "Core/OpenGL/CVertexBuffer.h"
|
||||
#include "Core/OpenGL/CIndexBuffer.h"
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Math/CAABox.h>
|
||||
|
||||
class CCollisionMesh
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "Core/Resource/Model/CModel.h"
|
||||
#include "Core/Resource/Model/CStaticModel.h"
|
||||
#include <Common/types.h>
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <FileIO/CInputStream.h>
|
||||
#include <Common/CColor.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
|
||||
/* CLight is currently heavily based on the lights system from Metroid Prime,
|
||||
* including code reverse engineered from the game's executable. Not yet sure
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include "CResource.h"
|
||||
#include "ETexelFormat.h"
|
||||
#include <Common/types.h>
|
||||
#include <Common/Math/CVector2f.h>
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <Common/types.h>
|
||||
#include <Math/CVector2f.h>
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "CStringTable.h"
|
||||
#include "SDependency.h"
|
||||
#include "Core/Resource/Model/CModel.h"
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
|
||||
class CWorld : public CResource
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "SSurface.h"
|
||||
#include "Core/Resource/CResource.h"
|
||||
#include "Core/OpenGL/CVertexBuffer.h"
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Math/CAABox.h>
|
||||
|
||||
class CBasicModel : public CResource
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef CVERTEX_H
|
||||
#define CVERTEX_H
|
||||
|
||||
#include <Common/Math/CVector2f.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Common/CColor.h>
|
||||
#include <Math/CVector2f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
|
||||
class CVertex
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "SSurface.h"
|
||||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/CRayCollisionTester.h"
|
||||
#include <Common/Math/Math.h>
|
||||
#include <Math/MathUtil.h>
|
||||
|
||||
std::pair<bool,float> SSurface::IntersectsRay(const CRay& Ray, bool allowBackfaces, float LineThreshold)
|
||||
{
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
#include "Core/OpenGL/GLCommon.h"
|
||||
#include "Core/SRayIntersection.h"
|
||||
#include <Common/types.h>
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Math/CAABox.h>
|
||||
#include <Math/CRay.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <vector>
|
||||
|
||||
struct SSurface
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
#include "Core/Resource/CResource.h"
|
||||
#include "Core/Resource/TResPtr.h"
|
||||
#include "Core/Resource/CAnimationParameters.h"
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Common/CColor.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <list>
|
||||
|
||||
class CScriptTemplate;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/Render/CGraphics.h"
|
||||
#include "Core/Render/CRenderer.h"
|
||||
#include <Common/Math/Math.h>
|
||||
#include <Math/MathUtil.h>
|
||||
|
||||
CLightNode::CLightNode(CSceneManager *pScene, CSceneNode *pParent, CLight *Light)
|
||||
: CSceneNode(pScene, pParent)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/Render/CRenderer.h"
|
||||
#include "Core/Render/CGraphics.h"
|
||||
#include <Common/Math/Math.h>
|
||||
#include <Math/MathUtil.h>
|
||||
|
||||
CModelNode::CModelNode(CSceneManager *pScene, CSceneNode *pParent, CModel *pModel) : CSceneNode(pScene, pParent)
|
||||
{
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include "Core/Resource/Script/CScriptLayer.h"
|
||||
#include "Core/CRayCollisionTester.h"
|
||||
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Common/TString.h>
|
||||
#include <FileIO/CFileInStream.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Math/CRay.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/Resource/CGameArea.h"
|
||||
#include <Common/AnimUtil.h>
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <gtc/quaternion.hpp>
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
#include "Core/Resource/CLight.h"
|
||||
#include "Core/Resource/CGameArea.h"
|
||||
#include "Core/CRayCollisionTester.h"
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Common/Math/CQuaternion.h>
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Common/Math/ETransformSpace.h>
|
||||
#include <Common/types.h>
|
||||
#include <Math/CAABox.h>
|
||||
#include <Math/CQuaternion.h>
|
||||
#include <Math/CRay.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <Math/ETransformSpace.h>
|
||||
|
||||
class CRenderer;
|
||||
class CSceneManager;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "Core/Resource/Script/CScriptLayer.h"
|
||||
#include "Core/ScriptExtra/CScriptExtra.h"
|
||||
#include <Common/AnimUtil.h>
|
||||
#include <Common/Math/Math.h>
|
||||
#include <Math/MathUtil.h>
|
||||
|
||||
CScriptNode::CScriptNode(CSceneManager *pScene, CSceneNode *pParent, CScriptObject *pObject)
|
||||
: CSceneNode(pScene, pParent)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/Render/CRenderer.h"
|
||||
#include <Common/AnimUtil.h>
|
||||
#include <Common/Math/Math.h>
|
||||
#include <Math/MathUtil.h>
|
||||
|
||||
CStaticNode::CStaticNode(CSceneManager *pScene, CSceneNode *pParent, CStaticModel *pModel)
|
||||
: CSceneNode(pScene, pParent)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "CBasicViewport.h"
|
||||
#include <Math/MathUtil.h>
|
||||
#include <Core/Render/CDrawUtil.h>
|
||||
#include <Core/Render/CGraphics.h>
|
||||
#include <Common/Math/Math.h>
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef CEDITORGLWIDGET_H
|
||||
#define CEDITORGLWIDGET_H
|
||||
|
||||
#include <Common/CTimer.h>
|
||||
#include <Math/CRay.h>
|
||||
#include <Math/CVector2i.h>
|
||||
#include <Math/CVector2f.h>
|
||||
#include <Core/Render/CRenderer.h>
|
||||
#include <Core/Render/SViewInfo.h>
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Common/Math/CVector2i.h>
|
||||
#include <Common/Math/CVector2f.h>
|
||||
#include <Common/CTimer.h>
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
#include <QMouseEvent>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "CGizmo.h"
|
||||
#include <Common/Math/Math.h>
|
||||
#include <Math/MathUtil.h>
|
||||
#include <Core/Render/CDrawUtil.h>
|
||||
#include <Core/Render/CRenderer.h>
|
||||
#include <Core/Resource/CResCache.h>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef CGIZMO_H
|
||||
#define CGIZMO_H
|
||||
|
||||
#include <Common/Math/CPlane.h>
|
||||
#include <Common/Math/CQuaternion.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Common/Math/ETransformSpace.h>
|
||||
#include <Common/EnumUtil.h>
|
||||
#include <Math/CPlane.h>
|
||||
#include <Math/CQuaternion.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <Math/ETransformSpace.h>
|
||||
#include <Core/Render/CCamera.h>
|
||||
#include <Core/Render/IRenderable.h>
|
||||
#include <Core/Resource/Model/CModel.h>
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define INODEEDITOR_H
|
||||
|
||||
#include "CGizmo.h"
|
||||
#include <Common/Math/ETransformSpace.h>
|
||||
#include <Math/ETransformSpace.h>
|
||||
#include <Core/Scene/CSceneManager.h>
|
||||
|
||||
#include <QMainWindow>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "WTextureGLWidget.h"
|
||||
#include <Common/AnimUtil.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
#include <Core/Render/CDrawUtil.h>
|
||||
#include <Core/Render/CGraphics.h>
|
||||
#include <Core/Resource/CResCache.h>
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Common/AnimUtil.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef WTEXTUREGLWIDGET_H
|
||||
#define WTEXTUREGLWIDGET_H
|
||||
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Common/Math/CVector2f.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
#include <Math/CVector2f.h>
|
||||
#include <Core/Resource/TResPtr.h>
|
||||
#include <Core/Resource/CTexture.h>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define WVECTOREDITOR_H
|
||||
|
||||
#include "WDraggableSpinBox.h"
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#include "Editor/INodeEditor.h"
|
||||
#include "Editor/CGizmo.h"
|
||||
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Common/Math/ETransformSpace.h>
|
||||
#include <Common/CTimer.h>
|
||||
#include <Common/EKeyInputs.h>
|
||||
#include <Math/CRay.h>
|
||||
#include <Math/ETransformSpace.h>
|
||||
#include <Core/Render/CRenderer.h>
|
||||
#include <Core/Resource/CGameArea.h>
|
||||
#include <Core/Resource/CWorld.h>
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
}
|
|
@ -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
|
|
@ -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();
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
#ifndef CINPUTSTREAM_H
|
||||
#define CINPUTSTREAM_H
|
||||
|
||||
#include "IOUtil.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
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
|
|
@ -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<char*>(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;
|
||||
}
|
|
@ -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
|
|
@ -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<char*>(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;
|
||||
}
|
|
@ -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
|
|
@ -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());
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef COUTPUTSTREAM_H
|
||||
#define COUTPUTSTREAM_H
|
||||
|
||||
#include "IOUtil.h"
|
||||
#include <string>
|
||||
|
||||
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
|
|
@ -0,0 +1,100 @@
|
|||
#include "CTextInStream.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef CTEXTINSTREAM_H
|
||||
#define CTEXTINSTREAM_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
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
|
|
@ -0,0 +1,94 @@
|
|||
#include "CTextOutStream.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef CTEXTOUTSTREAM_H
|
||||
#define CTEXTOUTSTREAM_H
|
||||
|
||||
#include <string>
|
||||
|
||||
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
|
|
@ -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();
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef CVECTOROUTSTREAM_H
|
||||
#define CVECTOROUTSTREAM_H
|
||||
|
||||
#include "COutputStream.h"
|
||||
#include <vector>
|
||||
|
||||
class CVectorOutStream : public COutputStream
|
||||
{
|
||||
std::vector<char> 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
|
|
@ -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
|
|
@ -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
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||
#include "CAABox.h"
|
||||
#include "CTransform4f.h"
|
||||
#include "Math.h"
|
||||
#include "CRay.h"
|
||||
#include "CTransform4f.h"
|
||||
#include "MathUtil.h"
|
||||
#include <float.h>
|
||||
|
||||
CAABox::CAABox()
|
|
@ -1,5 +1,5 @@
|
|||
#include "CFrustumPlanes.h"
|
||||
#include "Math.h"
|
||||
#include "MathUtil.h"
|
||||
#include "Common/types.h"
|
||||
|
||||
CFrustumPlanes::CFrustumPlanes()
|
|
@ -1,6 +1,6 @@
|
|||
#include "CQuaternion.h"
|
||||
#include "CMatrix4f.h"
|
||||
#include "Math.h"
|
||||
#include "MathUtil.h"
|
||||
#include <cmath>
|
||||
#include <math.h>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "Common/Math/CVector2f.h"
|
||||
#include "CVector2f.h"
|
||||
|
||||
CVector2f::CVector2f()
|
||||
{
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef CVECTOR3F
|
||||
#define CVECTOR3F
|
||||
#ifndef CVECTOR3F_H
|
||||
#define CVECTOR3F_H
|
||||
|
||||
#include <FileIO/CInputStream.h>
|
||||
#include <FileIO/COutputStream.h>
|
||||
|
@ -89,4 +89,4 @@ public:
|
|||
friend std::ostream& operator<<(std::ostream& o, const CVector3f& Vector);
|
||||
};
|
||||
|
||||
#endif // CVECTOR3F
|
||||
#endif // CVECTOR3F_H
|
|
@ -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
|
|
@ -1,4 +1,4 @@
|
|||
#include "Math.h"
|
||||
#include "MathUtil.h"
|
||||
#include "CMatrix4f.h"
|
||||
#include <gtc/matrix_transform.hpp>
|
||||
|
|
@ -8,7 +8,9 @@ QMAKE_CXXFLAGS += /WX
|
|||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
FileIO \
|
||||
Common \
|
||||
Math \
|
||||
Core \
|
||||
Editor
|
||||
|
||||
|
|
Loading…
Reference in New Issue