port 2A step 2: copy the 40250 header closure into the port mirror
76 closure headers (EterBase, EterLocale, EterPack, EterLib, GameLib, MilesLib, EffectLib, SphereLib, EterImageLib) copied by the new port_copy.py (CP949->UTF-8, LF, include-path case only); platform-class headers go to the mirror path too, as the interface platform/ implements. Six manual `// PORT:` edits (Random, Singleton, Pool, Stl, Utils, FlyTarget). - common/D3D8Types.h: D3D8 value types with SDK values/layout, opaque COM interfaces - common/shim/sdk (d3d8/d3dx8/mss) on every platform, common/shim/win32 off Windows - Win32Types/Win32Crt: HRESULT, GUID, LARGE_INTEGER, LOGFONT/TEXTMETRIC, _atoi64, CRITICAL_SECTION on std::recursive_mutex - header gate prepends each library's StdAfx.h (40250's precompiled header) port_gate: macOS, Android, iOS, Windows (mingw) PASS; Linux BLOCKED (no toolchain). ScriptLib/EterPythonLib/UserInterface wait for 2P (their StdAfx includes Python). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "Ref.h"
|
||||
#include "CollisionData.h"
|
||||
|
||||
typedef struct SHeightData
|
||||
{
|
||||
char szName[32+1];
|
||||
std::vector<D3DXVECTOR3> v3VertexVector;
|
||||
} THeightData;
|
||||
|
||||
typedef std::vector<THeightData> THeightDataVector;
|
||||
|
||||
class CAttributeData : public CResource
|
||||
{
|
||||
public:
|
||||
typedef CRef<CAttributeData> TRef;
|
||||
|
||||
/*
|
||||
enum ECollisionType
|
||||
{
|
||||
COLLISION_TYPE_PLANE,
|
||||
COLLISION_TYPE_BOX,
|
||||
COLLISION_TYPE_SPHERE,
|
||||
COLLISION_TYPE_CYLINDER,
|
||||
};
|
||||
|
||||
typedef struct SCollisionData
|
||||
{
|
||||
DWORD dwType;
|
||||
char szName[32+1];
|
||||
|
||||
D3DXVECTOR3 v3Position;
|
||||
float fDimensions[3];
|
||||
D3DXQUATERNION quatRotation;
|
||||
} TCollisionData;*/
|
||||
|
||||
public:
|
||||
static TType Type();
|
||||
|
||||
public:
|
||||
CAttributeData(const char * c_szFileName);
|
||||
virtual ~CAttributeData();
|
||||
|
||||
//DWORD GetCollisionDataCount() const;
|
||||
//BOOL GetCollisionDataPointer(DWORD dwIndex, const TCollisionData ** c_ppCollisionData) const;
|
||||
const CStaticCollisionDataVector & GetCollisionDataVector() const;
|
||||
const THeightDataVector & GetHeightDataVector() const;
|
||||
|
||||
size_t AddCollisionData(const CStaticCollisionData& collisionData); // return m_StaticCollisionDataVector.size();
|
||||
|
||||
DWORD GetHeightDataCount() const;
|
||||
BOOL GetHeightDataPointer(DWORD dwIndex, const THeightData ** c_ppHeightData) const;
|
||||
|
||||
float GetMaximizeRadius();
|
||||
|
||||
protected:
|
||||
bool OnLoad(int iSize, const void * c_pvBuf);
|
||||
void OnClear();
|
||||
bool OnIsEmpty() const;
|
||||
bool OnIsType(TType type);
|
||||
void OnSelfDestruct();
|
||||
|
||||
protected:
|
||||
float m_fMaximizeRadius;
|
||||
|
||||
//std::vector<TCollisionData> m_CollisionDataVector;
|
||||
CStaticCollisionDataVector m_StaticCollisionDataVector;
|
||||
THeightDataVector m_HeightDataVector;
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "AttributeData.h"
|
||||
#include "Pool.h"
|
||||
|
||||
class CAttributeInstance
|
||||
{
|
||||
public:
|
||||
CAttributeInstance();
|
||||
virtual ~CAttributeInstance();
|
||||
|
||||
void Clear();
|
||||
BOOL IsEmpty() const;
|
||||
|
||||
const char * GetDataFileName() const;
|
||||
|
||||
// NOTE : Object 전용
|
||||
void SetObjectPointer(CAttributeData * pAttributeData);
|
||||
void RefreshObject(const D3DXMATRIX & c_rmatGlobal);
|
||||
CAttributeData * GetObjectPointer() const;
|
||||
|
||||
bool Picking(const D3DXVECTOR3 & v, const D3DXVECTOR3 & dir, float & out_x, float & out_y);
|
||||
|
||||
BOOL IsInHeight(float fx, float fy);
|
||||
BOOL GetHeight(float fx, float fy, float * pfHeight);
|
||||
|
||||
BOOL IsHeightData() const;
|
||||
|
||||
protected:
|
||||
void SetGlobalMatrix(const D3DXMATRIX & c_rmatGlobal);
|
||||
void SetGlobalPosition(const D3DXVECTOR3 & c_rv3Position);
|
||||
|
||||
protected:
|
||||
float m_fCollisionRadius;
|
||||
float m_fHeightRadius;
|
||||
|
||||
D3DXMATRIX m_matGlobal;
|
||||
|
||||
std::vector< std::vector<D3DXVECTOR3> > m_v3HeightDataVector;
|
||||
|
||||
CAttributeData::TRef m_roAttributeData;
|
||||
|
||||
/*
|
||||
BOOL m_isHeightCached;
|
||||
struct SHeightCacheData
|
||||
{
|
||||
float fxMin;
|
||||
float fyMin;
|
||||
float fxMax;
|
||||
float fyMax;
|
||||
DWORD dwxStep;
|
||||
DWORD dwyStep;
|
||||
std::vector<float> kVec_fHeight;
|
||||
} m_kHeightCacheData;
|
||||
*/
|
||||
|
||||
public:
|
||||
static void CreateSystem(UINT uCapacity);
|
||||
static void DestroySystem();
|
||||
|
||||
static CAttributeInstance* New();
|
||||
static void Delete(CAttributeInstance* pkInst);
|
||||
|
||||
static CDynamicPool<CAttributeInstance> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,285 @@
|
||||
// Camera.h: interface for the CCamera class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_CAMERA_H__C5D086BE_7A03_4246_9145_336747C47D9E__INCLUDED_)
|
||||
#define AFX_CAMERA_H__C5D086BE_7A03_4246_9145_336747C47D9E__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "../EterBase/Singleton.h"
|
||||
#include "Ray.h"
|
||||
|
||||
const float CAMERA_TARGET_STANDARD = 100.0f;
|
||||
const float CAMERA_TARGET_FACE = 150.0f;
|
||||
|
||||
|
||||
typedef enum _eCameraState_
|
||||
{
|
||||
CAMERA_STATE_NORMAL,
|
||||
CAMERA_STATE_CANTGODOWN,
|
||||
CAMERA_STATE_CANTGORIGHT,
|
||||
CAMERA_STATE_CANTGOLEFT,
|
||||
CAMERA_STATE_SCREEN_BY_BUILDING,
|
||||
CAMERA_STATE_SCREEN_BY_BUILDING_AND_TOOCLOSE,
|
||||
} eCameraState;
|
||||
|
||||
class CCamera
|
||||
{
|
||||
public:
|
||||
CCamera();
|
||||
virtual ~CCamera();
|
||||
|
||||
static void SetCameraMaxDistance(float fMax);
|
||||
|
||||
void Lock();
|
||||
void Unlock();
|
||||
bool IsLock();
|
||||
|
||||
void Wheel(int nWheelLen);
|
||||
bool Drag(int nMouseX, int nMouseY, LPPOINT lpReturnPoint);
|
||||
|
||||
bool EndDrag();
|
||||
void BeginDrag(int nMouseX, int nMouseY);
|
||||
|
||||
bool IsDraging();
|
||||
|
||||
void SetResistance(float fResistance);
|
||||
|
||||
private:
|
||||
const CCamera & operator = (const CCamera &) ; // 지원하지 않음
|
||||
CCamera (const CCamera & ) ; //지원하지 않음
|
||||
|
||||
// Camera Update
|
||||
eCameraState m_eCameraState;
|
||||
eCameraState m_eCameraStatePrev;
|
||||
float m_fPitchBackup;
|
||||
float m_fRollBackup;
|
||||
float m_fDistanceBackup;
|
||||
float m_fTargetZBackUp;
|
||||
|
||||
D3DXVECTOR3 m_v3EyeBackup;
|
||||
|
||||
unsigned long m_ulNumScreenBuilding;
|
||||
|
||||
// protected:
|
||||
|
||||
bool m_isLock;
|
||||
|
||||
// Attributes for view matrix
|
||||
D3DXVECTOR3 m_v3Eye;
|
||||
D3DXVECTOR3 m_v3Target;
|
||||
D3DXVECTOR3 m_v3Up;
|
||||
|
||||
// m_v3View = m_v3Target - m_v3Eye
|
||||
D3DXVECTOR3 m_v3View;
|
||||
// m_v3Cross = Cross(m_v3Up, m_v3View)
|
||||
D3DXVECTOR3 m_v3Cross;
|
||||
|
||||
//ViewMatrixes
|
||||
D3DXMATRIX m_matView;
|
||||
D3DXMATRIX m_matInverseView;
|
||||
D3DXMATRIX m_matBillboard; // Special matrix for billboarding effects
|
||||
|
||||
//추가분
|
||||
float m_fPitch;
|
||||
float m_fRoll;
|
||||
float m_fDistance;
|
||||
|
||||
// 카메라 AI를 위한 Ray 들
|
||||
|
||||
// 카메라를 둘러싼 Ray
|
||||
CRay m_kCameraBottomToTerrainRay;
|
||||
CRay m_kCameraFrontToTerrainRay;
|
||||
CRay m_kCameraBackToTerrainRay;
|
||||
CRay m_kCameraLeftToTerrainRay;
|
||||
CRay m_kCameraRightToTerrainRay;
|
||||
|
||||
CRay m_kTargetToCameraBottomRay;
|
||||
|
||||
CRay m_ViewRay;
|
||||
CRay m_kLeftObjectCollisionRay;
|
||||
CRay m_kTopObjectCollisionRay;
|
||||
CRay m_kRightObjectCollisionRay;
|
||||
CRay m_kBottomObjectCollisionRay;
|
||||
|
||||
float m_fTerrainCollisionRadius;
|
||||
float m_fObjectCollisionRadius;
|
||||
|
||||
// protected:
|
||||
float m_fTarget_;
|
||||
|
||||
float m_fEyeGroundHeightRatio;
|
||||
float m_fTargetHeightLimitRatio;
|
||||
float m_fPitchSum;
|
||||
float m_fRollSum;
|
||||
|
||||
long m_lMousePosX;
|
||||
long m_lMousePosY;
|
||||
|
||||
bool m_bDrag;
|
||||
|
||||
// protected:
|
||||
// 물리
|
||||
D3DXVECTOR3 m_v3AngularAcceleration;
|
||||
D3DXVECTOR3 m_v3AngularVelocity;
|
||||
|
||||
float m_fResistance;
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 물리
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetAngularAcceleration(D3DXVECTOR3 v3AngularAcceleration) { m_v3AngularAcceleration = v3AngularAcceleration; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AI
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void SetTerrainCollisionRadius(float fTerrainCollisionRadius) { m_fTerrainCollisionRadius = fTerrainCollisionRadius; }
|
||||
void SetObjectCollisionRadius(float fObjectCollisionRadius) { m_fObjectCollisionRadius = fObjectCollisionRadius; }
|
||||
|
||||
CRay & GetViewRay() { return m_ViewRay; }
|
||||
CRay & GetLeftObjectCollisionRay() { return m_kLeftObjectCollisionRay; }
|
||||
CRay & GetRightObjectCollisionRay() { return m_kRightObjectCollisionRay; }
|
||||
CRay & GetTopObjectCollisionRay() { return m_kTopObjectCollisionRay; }
|
||||
CRay & GetBottomObjectCollisionRay() { return m_kBottomObjectCollisionRay; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Update
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Update();
|
||||
eCameraState GetCameraState() {return m_eCameraState;}
|
||||
void SetCameraState(eCameraState eNewCameraState);
|
||||
void IncreaseNumSrcreenBuilding();
|
||||
void ResetNumScreenBuilding();
|
||||
unsigned long & GetNumScreenBuilding() { return m_ulNumScreenBuilding; }
|
||||
|
||||
const float & GetPitchBackUp() { return m_fPitchBackup; }
|
||||
const float & GetRollBackUp() { return m_fRollBackup; }
|
||||
const float & GetDistanceBackUp() { return m_fDistanceBackup; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// properties
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const D3DXVECTOR3 & GetEye() const { return m_v3Eye; }
|
||||
const D3DXVECTOR3 & GetTarget() const { return m_v3Target; }
|
||||
const D3DXVECTOR3 & GetUp() const { return m_v3Up; }
|
||||
const D3DXVECTOR3 & GetView() const { return m_v3View; }
|
||||
const D3DXVECTOR3 & GetCross() const { return m_v3Cross; }
|
||||
|
||||
const D3DXMATRIX & GetViewMatrix() const { return m_matView; }
|
||||
const D3DXMATRIX & GetInverseViewMatrix() const { return m_matInverseView; }
|
||||
const D3DXMATRIX & GetBillboardMatrix()const { return m_matBillboard; }
|
||||
|
||||
void SetViewParams(const D3DXVECTOR3 & v3Eye, const D3DXVECTOR3& v3Target, const D3DXVECTOR3& v3Up );
|
||||
|
||||
void SetEye(const D3DXVECTOR3 & v3Eye);
|
||||
void SetTarget(const D3DXVECTOR3 & v3Target);
|
||||
void SetUp(const D3DXVECTOR3 & v3Up);
|
||||
|
||||
float GetPitch() const { return m_fPitch; }
|
||||
float GetRoll() const { return m_fRoll; }
|
||||
float GetDistance() const { return m_fDistance; }
|
||||
|
||||
void Pitch(const float fPitchDelta); //돌아가는 각도를 넣는다.
|
||||
void Roll(const float fRollDelta);
|
||||
void SetDistance(const float fdistance);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// camera movement
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 말그대로 이동... 카메라 위치와 타겟 위치가 모두 달라진다.
|
||||
void Move(const D3DXVECTOR3 & v3Displacement);
|
||||
// 줌.. 카메라 위치만 이동.. 타겟 위치는 고정...
|
||||
void Zoom(float fRatio);
|
||||
|
||||
// 뷰 방향으로 이동.. 타겟위치가 달라지므로 줌과는 다르다...
|
||||
void MoveAlongView(float fDistance);
|
||||
// 카메라 옆 방향으로 이동..
|
||||
void MoveAlongCross(float fDistance);
|
||||
// 카메라 업벡터 방향으로 이동...
|
||||
void MoveAlongUp(float fDistance);
|
||||
|
||||
// 카메라 옆 방향으로 이동... MoveAlongCross과 동일..
|
||||
void MoveLateral(float fDistance);
|
||||
// 뷰 방향의 Z 성분을 무시한 XY평면 방향으로 이동..
|
||||
void MoveFront(float fDistance);
|
||||
// Z방향(연직 방향)으로 이동...
|
||||
void MoveVertical(float fDistance);
|
||||
|
||||
// //카메라 위치는 고정시키고 머리만 든다. 타겟이 달라지겠죠?
|
||||
// //회전각을 라디안이 아닌 "도(Degree)"로 넣는다.
|
||||
// void RotateUpper(float fDegree);
|
||||
|
||||
// 타겟 중심으로 돈다. Eterlib의 SetAroundCamera의 기능과 유사...
|
||||
// fPitchDegree는 수평(0도)로부터 아랫쪽으로 꺽어지는 각도...
|
||||
// fRollDegree는 타겟 중심으로 시계방향으로 도는 각도...
|
||||
void RotateEyeAroundTarget(float fPitchDegree, float fRollDegree);
|
||||
|
||||
// 도는 중심점을 따로 지정 그 점을 중심으로 돈다. 타겟 점도 달라지겠죠?
|
||||
void RotateEyeAroundPoint(const D3DXVECTOR3 & v3Point, float fPitchDegree, float fRollDegree);
|
||||
|
||||
protected:
|
||||
void SetViewMatrix();
|
||||
void CalculateRoll();
|
||||
|
||||
public:
|
||||
float GetTargetHeight();
|
||||
void SetTargetHeight(float fTarget);
|
||||
bool isTerrainCollisionEnable() { return m_bProcessTerrainCollision; }
|
||||
void SetTerrainCollision(bool bEnable) { m_bProcessTerrainCollision = bEnable; }
|
||||
|
||||
private:
|
||||
void ProcessTerrainCollision();
|
||||
void ProcessBuildingCollision();
|
||||
|
||||
private:
|
||||
bool m_bProcessTerrainCollision;
|
||||
|
||||
static float CAMERA_MIN_DISTANCE;
|
||||
static float CAMERA_MAX_DISTANCE;
|
||||
};
|
||||
|
||||
typedef std::map<BYTE, CCamera *> TCameraMap;
|
||||
|
||||
class CCameraManager : public CSingleton<CCameraManager>
|
||||
{
|
||||
public:
|
||||
enum ECameraNum
|
||||
{
|
||||
NO_CURRENT_CAMERA,
|
||||
DEFAULT_PERSPECTIVE_CAMERA,
|
||||
DEFAULT_ORTHO_CAMERA,
|
||||
CAMERA_MAX = 255
|
||||
};
|
||||
|
||||
CCameraManager();
|
||||
virtual ~CCameraManager();
|
||||
|
||||
bool AddCamera(unsigned char ucCameraNum);
|
||||
bool RemoveCamera(unsigned char ucCameraNum);
|
||||
|
||||
CCamera * GetCurrentCamera();
|
||||
void SetCurrentCamera(unsigned char ucCameraNum);
|
||||
void ResetToPreviousCamera();
|
||||
|
||||
bool isCurrentCamera(unsigned char ucCameraNum);
|
||||
|
||||
unsigned char GetCurrentCameraNum();
|
||||
|
||||
bool isTerrainCollisionEnable();
|
||||
void SetTerrainCollision(bool bEnable);
|
||||
|
||||
private:
|
||||
TCameraMap m_CameraMap;
|
||||
CCamera * m_pCurrentCamera;
|
||||
CCamera * m_pPreviousCamera;
|
||||
};
|
||||
|
||||
|
||||
#endif // !defined(AFX_CAMERA_H__C5D086BE_7A03_4246_9145_336747C47D9E__INCLUDED_)
|
||||
@@ -0,0 +1,206 @@
|
||||
#pragma once
|
||||
|
||||
// Collision Detection
|
||||
typedef struct SSphereData
|
||||
{
|
||||
D3DXVECTOR3 v3Position;
|
||||
float fRadius;
|
||||
} TSphereData;
|
||||
|
||||
typedef struct SPlaneData
|
||||
{
|
||||
D3DXVECTOR3 v3Position;
|
||||
D3DXVECTOR3 v3Normal;
|
||||
|
||||
D3DXVECTOR3 v3QuadPosition[4];
|
||||
D3DXVECTOR3 v3InsideVector[4];
|
||||
} TPlaneData;
|
||||
|
||||
typedef struct SAABBData
|
||||
{
|
||||
D3DXVECTOR3 v3Min;
|
||||
D3DXVECTOR3 v3Max;
|
||||
|
||||
} TAABBData;
|
||||
|
||||
typedef struct SOBBData
|
||||
{
|
||||
D3DXVECTOR3 v3Min;
|
||||
D3DXVECTOR3 v3Max;
|
||||
D3DXMATRIX matRot;
|
||||
|
||||
} TOBBData;
|
||||
|
||||
typedef struct SCylinderData
|
||||
{
|
||||
D3DXVECTOR3 v3Position;
|
||||
float fRadius;
|
||||
float fHeight;
|
||||
} TCylinderData;
|
||||
|
||||
enum ECollisionType
|
||||
{
|
||||
COLLISION_TYPE_PLANE,
|
||||
COLLISION_TYPE_BOX,
|
||||
COLLISION_TYPE_SPHERE,
|
||||
COLLISION_TYPE_CYLINDER,
|
||||
COLLISION_TYPE_AABB,
|
||||
COLLISION_TYPE_OBB,
|
||||
};
|
||||
|
||||
struct CDynamicSphereInstance
|
||||
{
|
||||
D3DXVECTOR3 v3Position;
|
||||
D3DXVECTOR3 v3LastPosition;
|
||||
|
||||
float fRadius;
|
||||
};
|
||||
|
||||
class CStaticCollisionData
|
||||
{
|
||||
public:
|
||||
DWORD dwType;
|
||||
char szName[32+1];
|
||||
|
||||
D3DXVECTOR3 v3Position;
|
||||
float fDimensions[3];
|
||||
D3DXQUATERNION quatRotation;
|
||||
};
|
||||
|
||||
void DestroyCollisionInstanceSystem();
|
||||
|
||||
typedef std::vector<CStaticCollisionData> CStaticCollisionDataVector;
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Base
|
||||
class CBaseCollisionInstance
|
||||
{
|
||||
public:
|
||||
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID) = 0;
|
||||
|
||||
bool MovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const
|
||||
{
|
||||
return OnMovementCollisionDynamicSphere(s);
|
||||
}
|
||||
bool CollisionDynamicSphere(const CDynamicSphereInstance & s) const
|
||||
{
|
||||
return OnCollisionDynamicSphere(s);
|
||||
}
|
||||
|
||||
|
||||
D3DXVECTOR3 GetCollisionMovementAdjust(const CDynamicSphereInstance & s) const
|
||||
{
|
||||
return OnGetCollisionMovementAdjust(s);
|
||||
}
|
||||
|
||||
void Destroy();
|
||||
|
||||
static CBaseCollisionInstance * BuildCollisionInstance(const CStaticCollisionData * c_pCollisionData, const D3DXMATRIX * pMat);
|
||||
|
||||
protected:
|
||||
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const = 0;
|
||||
virtual bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const = 0;
|
||||
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const = 0;
|
||||
virtual void OnDestroy() = 0;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Sphere
|
||||
class CSphereCollisionInstance : public CBaseCollisionInstance
|
||||
{
|
||||
public:
|
||||
TSphereData & GetAttribute();
|
||||
const TSphereData & GetAttribute() const;
|
||||
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||
|
||||
protected:
|
||||
void OnDestroy();
|
||||
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||
|
||||
protected:
|
||||
TSphereData m_attribute;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Plane
|
||||
class CPlaneCollisionInstance : public CBaseCollisionInstance
|
||||
{
|
||||
public:
|
||||
TPlaneData & GetAttribute();
|
||||
const TPlaneData & GetAttribute() const;
|
||||
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||
|
||||
protected:
|
||||
void OnDestroy();
|
||||
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||
|
||||
protected:
|
||||
TPlaneData m_attribute;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// AABB (Aligned Axis Bounding Box)
|
||||
class CAABBCollisionInstance : public CBaseCollisionInstance
|
||||
{
|
||||
public:
|
||||
TAABBData & GetAttribute();
|
||||
const TAABBData & GetAttribute() const;
|
||||
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||
|
||||
protected:
|
||||
void OnDestroy();
|
||||
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||
|
||||
protected:
|
||||
TAABBData m_attribute;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// OBB
|
||||
class COBBCollisionInstance : public CBaseCollisionInstance
|
||||
{
|
||||
public:
|
||||
TOBBData & GetAttribute();
|
||||
const TOBBData & GetAttribute() const;
|
||||
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||
|
||||
protected:
|
||||
void OnDestroy();
|
||||
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||
|
||||
protected:
|
||||
TOBBData m_attribute;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Cylinder
|
||||
class CCylinderCollisionInstance : public CBaseCollisionInstance
|
||||
{
|
||||
public:
|
||||
TCylinderData & GetAttribute();
|
||||
const TCylinderData & GetAttribute() const;
|
||||
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||
|
||||
protected:
|
||||
void OnDestroy();
|
||||
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||
|
||||
bool CollideCylinderVSDynamicSphere(const TCylinderData & c_rattribute, const CDynamicSphereInstance & s) const;
|
||||
|
||||
protected:
|
||||
TCylinderData m_attribute;
|
||||
};
|
||||
|
||||
typedef std::vector<CSphereCollisionInstance> CSphereCollisionInstanceVector;
|
||||
typedef std::vector<CDynamicSphereInstance> CDynamicSphereInstanceVector;
|
||||
typedef std::vector<CBaseCollisionInstance*> CCollisionInstanceVector;
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
class CColorTransitionHelper
|
||||
{
|
||||
public:
|
||||
CColorTransitionHelper();
|
||||
~CColorTransitionHelper();
|
||||
|
||||
void Clear(const float & c_rfRed,
|
||||
const float & c_rfGreen,
|
||||
const float & c_rfBlue,
|
||||
const float & c_rfAlpha);
|
||||
void SetSrcColor(const float & c_rfRed,
|
||||
const float & c_rfGreen,
|
||||
const float & c_rfBlue,
|
||||
const float & c_rfAlpha);
|
||||
void SetTransition(const float & c_rfRed,
|
||||
const float & c_rfGreen,
|
||||
const float & c_rfBlue,
|
||||
const float & c_rfAlpha,
|
||||
const DWORD & dwDuration);
|
||||
const D3DCOLOR & GetCurColor();// { return m_dwCurColor; }
|
||||
|
||||
void StartTransition();
|
||||
bool Update();
|
||||
|
||||
bool isTransitionStarted() { return m_bTransitionStarted; }
|
||||
|
||||
private:
|
||||
D3DCOLOR m_dwCurColor; // 현재 색
|
||||
|
||||
DWORD m_dwStartTime; // 바뀌기 시작하는 시간
|
||||
DWORD m_dwDuration; // 얼마 동안에 바뀌는가?
|
||||
|
||||
bool m_bTransitionStarted;
|
||||
|
||||
float m_fSrcRed, m_fSrcGreen, m_fSrcBlue, m_fSrcAlpha;
|
||||
float m_fDstRed, m_fDstGreen, m_fDstBlue, m_fDstAlpha;
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
template<typename T>
|
||||
class CFuncObject
|
||||
{
|
||||
public:
|
||||
CFuncObject()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
virtual ~CFuncObject()
|
||||
{
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_pSelfObject = NULL;
|
||||
m_pFuncObject = NULL;
|
||||
}
|
||||
|
||||
void Set(T* pSelfObject, void (T::*pFuncObject)())
|
||||
{
|
||||
m_pSelfObject = pSelfObject;
|
||||
m_pFuncObject = pFuncObject;
|
||||
}
|
||||
|
||||
bool IsEmpty()
|
||||
{
|
||||
if (m_pSelfObject != NULL)
|
||||
return false;
|
||||
|
||||
if (m_pFuncObject != NULL)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Run()
|
||||
{
|
||||
if (m_pSelfObject)
|
||||
if (m_pFuncObject)
|
||||
(m_pSelfObject->*m_pFuncObject)();
|
||||
}
|
||||
|
||||
protected:
|
||||
T * m_pSelfObject;
|
||||
void (T::*m_pFuncObject) ();
|
||||
};
|
||||
@@ -0,0 +1,312 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpDetector.h"
|
||||
#include "Ray.h"
|
||||
#include <vector>
|
||||
|
||||
void PixelPositionToD3DXVECTOR3(const D3DXVECTOR3& c_rkPPosSrc, D3DXVECTOR3* pv3Dst);
|
||||
void D3DXVECTOR3ToPixelPosition(const D3DXVECTOR3& c_rv3Src, D3DXVECTOR3* pv3Dst);
|
||||
|
||||
class CGraphicTexture;
|
||||
|
||||
typedef WORD TIndex;
|
||||
|
||||
typedef struct SFace
|
||||
{
|
||||
TIndex indices[3];
|
||||
} TFace;
|
||||
|
||||
typedef D3DXVECTOR3 TPosition;
|
||||
|
||||
typedef D3DXVECTOR3 TNormal;
|
||||
|
||||
typedef D3DXVECTOR2 TTextureCoordinate;
|
||||
|
||||
typedef DWORD TDiffuse;
|
||||
typedef DWORD TAmbient;
|
||||
typedef DWORD TSpecular;
|
||||
|
||||
typedef union UDepth
|
||||
{
|
||||
float f;
|
||||
long l;
|
||||
DWORD dw;
|
||||
} TDepth;
|
||||
|
||||
typedef struct SVertex
|
||||
{
|
||||
float x, y, z;
|
||||
DWORD color;
|
||||
float u, v;
|
||||
} TVertex;
|
||||
|
||||
struct STVertex
|
||||
{
|
||||
float x, y, z, rhw;
|
||||
};
|
||||
|
||||
struct SPVertex
|
||||
{
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
typedef struct SPDVertex
|
||||
{
|
||||
float x, y, z;
|
||||
DWORD color;
|
||||
} TPDVertex;
|
||||
|
||||
struct SPDTVertexRaw
|
||||
{
|
||||
float px, py, pz;
|
||||
DWORD diffuse;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
typedef struct SPTVertex
|
||||
{
|
||||
TPosition position;
|
||||
TTextureCoordinate texCoord;
|
||||
} TPTVertex;
|
||||
|
||||
typedef struct SPDTVertex
|
||||
{
|
||||
TPosition position;
|
||||
TDiffuse diffuse;
|
||||
TTextureCoordinate texCoord;
|
||||
} TPDTVertex;
|
||||
|
||||
typedef struct SPNTVertex
|
||||
{
|
||||
TPosition position;
|
||||
TNormal normal;
|
||||
TTextureCoordinate texCoord;
|
||||
} TPNTVertex;
|
||||
|
||||
typedef struct SPNT2Vertex
|
||||
{
|
||||
TPosition position;
|
||||
TNormal normal;
|
||||
TTextureCoordinate texCoord;
|
||||
TTextureCoordinate texCoord2;
|
||||
} TPNT2Vertex;
|
||||
|
||||
typedef struct SPDT2Vertex
|
||||
{
|
||||
TPosition position;
|
||||
DWORD diffuse;
|
||||
TTextureCoordinate texCoord;
|
||||
TTextureCoordinate texCoord2;
|
||||
} TPDT2Vertex;
|
||||
|
||||
typedef struct SNameInfo
|
||||
{
|
||||
DWORD name;
|
||||
TDepth depth;
|
||||
} TNameInfo;
|
||||
|
||||
typedef struct SBoundBox
|
||||
{
|
||||
float sx, sy, sz;
|
||||
float ex, ey, ez;
|
||||
int meshIndex;
|
||||
int boneIndex;
|
||||
} TBoundBox;
|
||||
|
||||
const WORD c_FillRectIndices[6] = { 0, 2, 1, 2, 3, 1 };
|
||||
|
||||
/*
|
||||
enum EIndexCount
|
||||
{
|
||||
LINE_INDEX_COUNT = 2,
|
||||
TRIANGLE_INDEX_COUNT = 2*3,
|
||||
RECTANGLE_INDEX_COUNT = 2*4,
|
||||
CUBE_INDEX_COUNT = 2*4*3,
|
||||
FILLED_TRIANGLE_INDEX_COUNT = 3,
|
||||
FILLED_RECTANGLE_INDEX_COUNT = 3*2,
|
||||
FILLED_CUBE_INDEX_COUNT = 3*2*6,
|
||||
};
|
||||
*/
|
||||
|
||||
class CGraphicBase
|
||||
{
|
||||
public:
|
||||
static DWORD GetAvailableTextureMemory();
|
||||
static const D3DXMATRIX& GetViewMatrix();
|
||||
static const D3DXMATRIX & GetIdentityMatrix();
|
||||
|
||||
enum
|
||||
{
|
||||
DEFAULT_IB_LINE,
|
||||
DEFAULT_IB_LINE_TRI,
|
||||
DEFAULT_IB_LINE_RECT,
|
||||
DEFAULT_IB_LINE_CUBE,
|
||||
DEFAULT_IB_FILL_TRI,
|
||||
DEFAULT_IB_FILL_RECT,
|
||||
DEFAULT_IB_FILL_CUBE,
|
||||
DEFAULT_IB_NUM,
|
||||
};
|
||||
|
||||
public:
|
||||
CGraphicBase();
|
||||
virtual ~CGraphicBase();
|
||||
|
||||
void SetSimpleCamera(float x, float y, float z, float pitch, float roll);
|
||||
void SetEyeCamera(float xEye, float yEye, float zEye, float xCenter, float yCenter, float zCenter, float xUp, float yUp, float zUp);
|
||||
void SetAroundCamera(float distance, float pitch, float roll, float lookAtZ = 0.0f);
|
||||
void SetPositionCamera(float fx, float fy, float fz, float fDistance, float fPitch, float fRotation);
|
||||
void MoveCamera(float fdeltax, float fdeltay, float fdeltaz);
|
||||
|
||||
void GetTargetPosition(float * px, float * py, float * pz);
|
||||
void GetCameraPosition(float * px, float * py, float * pz);
|
||||
void SetOrtho2D(float hres, float vres, float zres);
|
||||
void SetOrtho3D(float hres, float vres, float zmin, float zmax);
|
||||
void SetPerspective(float fov, float aspect, float nearz, float farz);
|
||||
float GetFOV();
|
||||
void GetClipPlane(float * fNearY, float * fFarY)
|
||||
{
|
||||
*fNearY = ms_fNearY;
|
||||
*fFarY = ms_fFarY;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void PushMatrix();
|
||||
|
||||
void MultMatrix( const D3DXMATRIX* pMat );
|
||||
void MultMatrixLocal( const D3DXMATRIX* pMat );
|
||||
|
||||
void Translate(float x, float y, float z);
|
||||
void Rotate(float degree, float x, float y, float z);
|
||||
void RotateLocal(float degree, float x, float y, float z);
|
||||
void RotateYawPitchRollLocal(float fYaw, float fPitch, float fRoll);
|
||||
void Scale(float x, float y, float z);
|
||||
void PopMatrix();
|
||||
void LoadMatrix(const D3DXMATRIX & c_rSrcMatrix);
|
||||
void GetMatrix(D3DXMATRIX * pRetMatrix) const;
|
||||
const D3DXMATRIX * GetMatrixPointer() const;
|
||||
|
||||
// Special Routine
|
||||
void GetSphereMatrix(D3DXMATRIX * pMatrix, float fValue = 0.1f);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void InitScreenEffect();
|
||||
void SetScreenEffectWaving(float fDuringTime, int iPower);
|
||||
void SetScreenEffectFlashing(float fDuringTime, const D3DXCOLOR & c_rColor);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
DWORD GetColor(float r, float g, float b, float a = 1.0f);
|
||||
|
||||
DWORD GetFaceCount();
|
||||
void ResetFaceCount();
|
||||
HRESULT GetLastResult();
|
||||
|
||||
void UpdateProjMatrix();
|
||||
void UpdateViewMatrix();
|
||||
|
||||
void SetViewport(DWORD dwX, DWORD dwY, DWORD dwWidth, DWORD dwHeight, float fMinZ, float fMaxZ);
|
||||
static void GetBackBufferSize(UINT* puWidth, UINT* puHeight);
|
||||
static bool IsTLVertexClipping();
|
||||
static bool IsFastTNL();
|
||||
static bool IsLowTextureMemory();
|
||||
static bool IsHighTextureMemory();
|
||||
|
||||
static void SetDefaultIndexBuffer(UINT eDefIB);
|
||||
static bool SetPDTStream(SPDTVertexRaw* pVertices, UINT uVtxCount);
|
||||
static bool SetPDTStream(SPDTVertex* pVertices, UINT uVtxCount);
|
||||
|
||||
protected:
|
||||
static D3DXMATRIX ms_matIdentity;
|
||||
|
||||
static D3DXMATRIX ms_matView;
|
||||
static D3DXMATRIX ms_matProj;
|
||||
static D3DXMATRIX ms_matInverseView;
|
||||
static D3DXMATRIX ms_matInverseViewYAxis;
|
||||
|
||||
static D3DXMATRIX ms_matWorld;
|
||||
static D3DXMATRIX ms_matWorldView;
|
||||
|
||||
protected:
|
||||
//void UpdatePrePipeLineMatrix();
|
||||
void UpdatePipeLineMatrix();
|
||||
|
||||
protected:
|
||||
// 각종 D3DX Mesh 들 (컬루젼 데이터 등을 표시활 때 쓴다)
|
||||
static LPD3DXMESH ms_lpSphereMesh;
|
||||
static LPD3DXMESH ms_lpCylinderMesh;
|
||||
|
||||
protected:
|
||||
static HRESULT ms_hLastResult;
|
||||
|
||||
static int ms_iWidth;
|
||||
static int ms_iHeight;
|
||||
|
||||
static UINT ms_iD3DAdapterInfo;
|
||||
static UINT ms_iD3DDevInfo;
|
||||
static UINT ms_iD3DModeInfo;
|
||||
static D3D_CDisplayModeAutoDetector ms_kD3DDetector;
|
||||
|
||||
static HWND ms_hWnd;
|
||||
static HDC ms_hDC;
|
||||
static LPDIRECT3D8 ms_lpd3d;
|
||||
static LPDIRECT3DDEVICE8 ms_lpd3dDevice;
|
||||
static ID3DXMatrixStack* ms_lpd3dMatStack;
|
||||
static D3DVIEWPORT8 ms_Viewport;
|
||||
|
||||
static DWORD ms_faceCount;
|
||||
static D3DCAPS8 ms_d3dCaps;
|
||||
static D3DPRESENT_PARAMETERS ms_d3dPresentParameter;
|
||||
|
||||
static DWORD ms_dwD3DBehavior;
|
||||
static DWORD ms_ptVS;
|
||||
static DWORD ms_pntVS;
|
||||
static DWORD ms_pnt2VS;
|
||||
|
||||
static D3DXMATRIX ms_matScreen0;
|
||||
static D3DXMATRIX ms_matScreen1;
|
||||
static D3DXMATRIX ms_matScreen2;
|
||||
//static D3DXMATRIX ms_matPrePipeLine;
|
||||
|
||||
static D3DXVECTOR3 ms_vtPickRayOrig;
|
||||
static D3DXVECTOR3 ms_vtPickRayDir;
|
||||
|
||||
static float ms_fFieldOfView;
|
||||
static float ms_fAspect;
|
||||
static float ms_fNearY;
|
||||
static float ms_fFarY;
|
||||
|
||||
// 2004.11.18.myevan.DynamicVertexBuffer로 교체
|
||||
/*
|
||||
static std::vector<TIndex> ms_lineIdxVector;
|
||||
static std::vector<TIndex> ms_lineTriIdxVector;
|
||||
static std::vector<TIndex> ms_lineRectIdxVector;
|
||||
static std::vector<TIndex> ms_lineCubeIdxVector;
|
||||
|
||||
static std::vector<TIndex> ms_fillTriIdxVector;
|
||||
static std::vector<TIndex> ms_fillRectIdxVector;
|
||||
static std::vector<TIndex> ms_fillCubeIdxVector;
|
||||
*/
|
||||
|
||||
// Screen Effect - Waving, Flashing and so on..
|
||||
static DWORD ms_dwWavingEndTime;
|
||||
static int ms_iWavingPower;
|
||||
static DWORD ms_dwFlashingEndTime;
|
||||
static D3DXCOLOR ms_FlashingColor;
|
||||
|
||||
// Terrain picking용 Ray... CCamera 이용하는 버전.. 기존의 Ray와 통합 필요...
|
||||
static CRay ms_Ray;
|
||||
|
||||
//
|
||||
static bool ms_bSupportDXT;
|
||||
static bool ms_isLowTextureMemory;
|
||||
static bool ms_isHighTextureMemory;
|
||||
|
||||
enum
|
||||
{
|
||||
PDT_VERTEX_NUM = 16,
|
||||
PDT_VERTEXBUFFER_NUM = 100,
|
||||
};
|
||||
|
||||
|
||||
static LPDIRECT3DVERTEXBUFFER8 ms_alpd3dPDTVB[PDT_VERTEXBUFFER_NUM];
|
||||
static LPDIRECT3DINDEXBUFFER8 ms_alpd3dDefIB[DEFAULT_IB_NUM];
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpBase.h"
|
||||
|
||||
class CGraphicCollisionObject : public CGraphicBase
|
||||
{
|
||||
public:
|
||||
CGraphicCollisionObject();
|
||||
virtual ~CGraphicCollisionObject();
|
||||
|
||||
protected:
|
||||
bool IntersectTriangle(const D3DXVECTOR3& c_orig, const D3DXVECTOR3& c_dir, const D3DXVECTOR3& c_v0, const D3DXVECTOR3& c_v1, const D3DXVECTOR3& c_v2, float* pu, float* pv, float* pt);
|
||||
bool IntersectBoundBox(const D3DXMATRIX* c_pmatWorld, const TBoundBox& c_rboundBox, float* pu, float* pv, float* pt);
|
||||
bool IntersectCube(const D3DXMATRIX* c_pmatWorld, float sx, float sy, float sz, float ex, float ey, float ez, D3DXVECTOR3 & RayOriginal, D3DXVECTOR3 & RayDirection, float* pu, float* pv, float* pt);
|
||||
bool IntersectIndexedMesh(const D3DXMATRIX* c_pmatWorld, const void* vertices, int step, int vtxCount, const void* indices, int idxCount, D3DXVECTOR3 & RayOriginal, D3DXVECTOR3 & RayDirection, float* pu, float* pv, float* pt);
|
||||
bool IntersectMesh(const D3DXMATRIX * c_pmatWorld, const void * vertices, DWORD dwStep, DWORD dwvtxCount, D3DXVECTOR3 & RayOriginal, D3DXVECTOR3 & RayDirection, float* pu, float* pv, float* pt);
|
||||
|
||||
bool IntersectSphere(const D3DXVECTOR3 & c_rv3Position, float fRadius, const D3DXVECTOR3 & c_rv3RayOriginal, const D3DXVECTOR3 & c_rv3RayDirection);
|
||||
bool IntersectCylinder(const D3DXVECTOR3 & c_rv3Position, float fRadius, float fHeight, const D3DXVECTOR3 & c_rv3RayOriginal, const D3DXVECTOR3 & c_rv3RayDirection);
|
||||
|
||||
// NOTE : ms_vtPickRayOrig와 ms_vtPickRayDir를 CGraphicBGase가 가지고 있는데
|
||||
// 굳이 인자로 넣어줘야 하는 이유가 있는가? Customize를 위해서? - [levites]
|
||||
bool IntersectSphere(const D3DXVECTOR3 & c_rv3Position, float fRadius);
|
||||
bool IntersectCylinder(const D3DXVECTOR3 & c_rv3Position, float fRadius, float fHeight);
|
||||
};
|
||||
@@ -0,0 +1,166 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <string>
|
||||
typedef BOOL (*PFNCONFIRMDEVICE) (D3DCAPS8& rkD3DCaps, UINT uBehavior, D3DFORMAT eD3DFmt);
|
||||
|
||||
enum
|
||||
{
|
||||
D3DDEVICETYPE_HAL,
|
||||
D3DDEVICETYPE_REF,
|
||||
D3DDEVICETYPE_NUM,
|
||||
};
|
||||
|
||||
struct D3D_SModeInfo
|
||||
{
|
||||
UINT m_uScrWidth;
|
||||
UINT m_uScrHeight;
|
||||
UINT m_uScrDepthBit;
|
||||
UINT m_dwD3DBehavior;
|
||||
D3DFORMAT m_eD3DFmtPixel;
|
||||
D3DFORMAT m_eD3DFmtDepthStencil;
|
||||
|
||||
VOID GetString(std::string* pstEnumList);
|
||||
};
|
||||
|
||||
class D3D_CAdapterDisplayModeList
|
||||
{
|
||||
public:
|
||||
D3D_CAdapterDisplayModeList() {}
|
||||
~D3D_CAdapterDisplayModeList() {}
|
||||
VOID Build(IDirect3D8& rkD3D, D3DFORMAT eD3DFmtDefault, UINT iAdapter);
|
||||
|
||||
UINT GetDisplayModeNum();
|
||||
UINT GetPixelFormatNum();
|
||||
|
||||
const D3DDISPLAYMODE& GetDisplayModer(UINT iD3DDM);
|
||||
const D3DFORMAT& GetPixelFormatr(UINT iD3DFmt);
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
D3DDISPLAYMODE_MAX = 100,
|
||||
D3DFORMAT_MAX = 20,
|
||||
|
||||
FILTEROUT_LOWRESOLUTION_WIDTH = 640,
|
||||
FILTEROUT_LOWRESOLUTION_HEIGHT = 480,
|
||||
};
|
||||
|
||||
protected:
|
||||
D3DDISPLAYMODE m_akD3DDM[D3DDISPLAYMODE_MAX];
|
||||
D3DFORMAT m_aeD3DFmt[D3DFORMAT_MAX];
|
||||
|
||||
UINT m_uD3DDMNum;
|
||||
UINT m_uD3DFmtNum;
|
||||
|
||||
};
|
||||
|
||||
class D3D_CDeviceInfo
|
||||
{
|
||||
public:
|
||||
D3D_CDeviceInfo() {}
|
||||
~D3D_CDeviceInfo() {}
|
||||
BOOL Build(IDirect3D8& rkD3D, UINT iAdapter, UINT iDevType, D3D_CAdapterDisplayModeList& rkD3DADMList, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo);
|
||||
|
||||
UINT GetD3DModeInfoNum();
|
||||
|
||||
VOID GetString(std::string* pstEnumList);
|
||||
|
||||
BOOL FindDepthStencilFormat(IDirect3D8& rkD3D, UINT iAdapter, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT* pDepthStencilFormat);
|
||||
|
||||
D3D_SModeInfo& GetD3DModeInfor(UINT iD3DModeInfo);
|
||||
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DModeInfo);
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
D3DMODEINFO_NUM = 150,
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
const TCHAR* m_szDevDesc;
|
||||
|
||||
D3DDEVTYPE m_eD3DDevType;
|
||||
D3DCAPS8 m_kD3DCaps;
|
||||
BOOL m_canDoWindowed;
|
||||
|
||||
UINT m_iCurD3DModeInfo;
|
||||
UINT m_uD3DModeInfoNum;
|
||||
D3D_SModeInfo m_akD3DModeInfo[D3DMODEINFO_NUM];
|
||||
|
||||
|
||||
BOOL m_isWindowed;
|
||||
|
||||
D3DMULTISAMPLE_TYPE m_eD3DMSTWindowed;
|
||||
D3DMULTISAMPLE_TYPE m_eD3DMSTFullscreen;
|
||||
|
||||
|
||||
protected:
|
||||
static const CHAR* msc_aszD3DDevDesc[D3DDEVICETYPE_NUM];
|
||||
static const D3DDEVTYPE msc_aeD3DDevType[D3DDEVICETYPE_NUM];
|
||||
};
|
||||
|
||||
class D3D_CAdapterInfo
|
||||
{
|
||||
public:
|
||||
D3D_CAdapterInfo() {}
|
||||
~D3D_CAdapterInfo() {}
|
||||
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo, UINT* piD3DDevInfo);
|
||||
|
||||
BOOL Build(IDirect3D8& rkD3D, UINT iAdapter, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||
VOID GetString(std::string* pstEnumList);
|
||||
|
||||
D3DADAPTER_IDENTIFIER8& GetIdentifier()
|
||||
{
|
||||
return m_kD3DAdapterIdentifier;
|
||||
}
|
||||
|
||||
D3DDISPLAYMODE& GetDesktopD3DDisplayModer();
|
||||
D3DDISPLAYMODE* GetDesktopD3DDisplayModep();
|
||||
|
||||
D3D_CDeviceInfo* GetD3DDeviceInfop(UINT iD3DDevInfo);
|
||||
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DDevInfo, UINT iD3DModeInfo);
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
D3DDEVICEINFO_NUM = 5,
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
D3DADAPTER_IDENTIFIER8 m_kD3DAdapterIdentifier;
|
||||
D3DDISPLAYMODE m_kD3DDMDesktop;
|
||||
|
||||
UINT m_iCurD3DDevInfo;
|
||||
UINT m_uD3DDevInfoNum;
|
||||
D3D_CDeviceInfo m_akD3DDevInfo[D3DDEVICEINFO_NUM];
|
||||
|
||||
};
|
||||
|
||||
class D3D_CDisplayModeAutoDetector
|
||||
{
|
||||
public:
|
||||
D3D_CDisplayModeAutoDetector();
|
||||
~D3D_CDisplayModeAutoDetector();
|
||||
|
||||
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo, UINT* piD3DDevInfo, UINT* piD3DAdapterInfo);
|
||||
BOOL Build(IDirect3D8& rkD3D, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||
|
||||
D3D_CAdapterInfo* GetD3DAdapterInfop(UINT iD3DAdapterInfo);
|
||||
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DAdapterInfo, UINT iD3DDevInfo, UINT iD3DModeInfo);
|
||||
|
||||
VOID GetString(std::string* pstEnumList);
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
D3DADAPTERINFO_NUM = 10,
|
||||
};
|
||||
|
||||
protected:
|
||||
D3D_CAdapterInfo m_akD3DAdapterInfo[D3DADAPTERINFO_NUM];
|
||||
UINT m_uD3DAdapterInfoCount;
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef __INC_GRPIMAGE_H__
|
||||
#define __INC_GRPIMAGE_H__
|
||||
|
||||
#include "Ref.h"
|
||||
#include "Resource.h"
|
||||
#include "GrpImageTexture.h"
|
||||
|
||||
class CGraphicImage : public CResource
|
||||
{
|
||||
public:
|
||||
typedef CRef<CGraphicImage> TRef;
|
||||
|
||||
public:
|
||||
static TType Type();
|
||||
|
||||
public:
|
||||
CGraphicImage(const char* c_szFileName, DWORD dwFilter = D3DX_FILTER_LINEAR);
|
||||
virtual ~CGraphicImage();
|
||||
|
||||
virtual bool CreateDeviceObjects();
|
||||
virtual void DestroyDeviceObjects();
|
||||
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
|
||||
const RECT & GetRectReference() const;
|
||||
|
||||
const CGraphicTexture & GetTextureReference() const;
|
||||
CGraphicTexture * GetTexturePointer();
|
||||
|
||||
protected:
|
||||
bool OnLoad(int iSize, const void * c_pvBuf);
|
||||
|
||||
void OnClear();
|
||||
bool OnIsEmpty() const;
|
||||
bool OnIsType(TType type);
|
||||
|
||||
protected:
|
||||
CGraphicImageTexture m_imageTexture;
|
||||
RECT m_rect;
|
||||
DWORD m_dwFilter;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpImage.h"
|
||||
#include "GrpIndexBuffer.h"
|
||||
#include "GrpVertexBufferDynamic.h"
|
||||
#include "Pool.h"
|
||||
|
||||
class CGraphicImageInstance
|
||||
{
|
||||
public:
|
||||
static DWORD Type();
|
||||
BOOL IsType(DWORD dwType);
|
||||
|
||||
public:
|
||||
CGraphicImageInstance();
|
||||
virtual ~CGraphicImageInstance();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void Render();
|
||||
|
||||
void SetDiffuseColor(float fr, float fg, float fb, float fa);
|
||||
void SetPosition(float fx, float fy);
|
||||
|
||||
void SetImagePointer(CGraphicImage* pImage);
|
||||
void ReloadImagePointer(CGraphicImage* pImage);
|
||||
bool IsEmpty() const;
|
||||
|
||||
int GetWidth();
|
||||
int GetHeight();
|
||||
|
||||
CGraphicTexture * GetTexturePointer();
|
||||
const CGraphicTexture & GetTextureReference() const;
|
||||
CGraphicImage * GetGraphicImagePointer();
|
||||
|
||||
bool operator == (const CGraphicImageInstance & rhs) const;
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
virtual void OnRender();
|
||||
virtual void OnSetImagePointer();
|
||||
|
||||
virtual BOOL OnIsType(DWORD dwType);
|
||||
|
||||
protected:
|
||||
D3DXCOLOR m_DiffuseColor;
|
||||
D3DXVECTOR2 m_v2Position;
|
||||
|
||||
CGraphicImage::TRef m_roImage;
|
||||
|
||||
public:
|
||||
static void CreateSystem(UINT uCapacity);
|
||||
static void DestroySystem();
|
||||
|
||||
static CGraphicImageInstance* New();
|
||||
static void Delete(CGraphicImageInstance* pkImgInst);
|
||||
|
||||
static CDynamicPool<CGraphicImageInstance> ms_kPool;
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpTexture.h"
|
||||
#include "../EterImageLib/DXTCImage.h"
|
||||
|
||||
class CGraphicImageTexture : public CGraphicTexture
|
||||
{
|
||||
public:
|
||||
CGraphicImageTexture();
|
||||
virtual ~CGraphicImageTexture();
|
||||
|
||||
void Destroy();
|
||||
|
||||
bool Create(UINT width, UINT height, D3DFORMAT d3dFmt, DWORD dwFilter = D3DX_FILTER_LINEAR);
|
||||
bool CreateDeviceObjects();
|
||||
|
||||
void CreateFromTexturePointer(const CGraphicTexture* c_pSrcTexture);
|
||||
bool CreateFromDiskFile(const char* c_szFileName, D3DFORMAT d3dFmt, DWORD dwFilter = D3DX_FILTER_LINEAR);
|
||||
bool CreateFromMemoryFile(UINT bufSize, const void* c_pvBuf, D3DFORMAT d3dFmt, DWORD dwFilter = D3DX_FILTER_LINEAR);
|
||||
bool CreateDDSTexture(CDXTCImage & image, const BYTE * c_pbBuf);
|
||||
|
||||
void SetFileName(const char * c_szFileName);
|
||||
|
||||
bool Lock(int* pRetPitch, void** ppRetPixels, int level=0);
|
||||
void Unlock(int level=0);
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
D3DFORMAT m_d3dFmt;
|
||||
DWORD m_dwFilter;
|
||||
|
||||
std::string m_stFileName;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpBase.h"
|
||||
|
||||
class CGraphicIndexBuffer : public CGraphicBase
|
||||
{
|
||||
public:
|
||||
CGraphicIndexBuffer();
|
||||
virtual ~CGraphicIndexBuffer();
|
||||
|
||||
void Destroy();
|
||||
bool Create(int idxCount, D3DFORMAT d3dFmt);
|
||||
bool Create(int faceCount, TFace* faces);
|
||||
|
||||
bool CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
bool Copy(int bufSize, const void* srcIndices);
|
||||
|
||||
bool Lock(void** pretIndices) const;
|
||||
void Unlock() const;
|
||||
|
||||
bool Lock(void** pretIndices);
|
||||
void Unlock();
|
||||
|
||||
void SetIndices(int startIndex=0) const;
|
||||
|
||||
LPDIRECT3DINDEXBUFFER8 GetD3DIndexBuffer() const;
|
||||
|
||||
int GetIndexCount() const {return m_iidxCount;}
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
LPDIRECT3DINDEXBUFFER8 m_lpd3dIdxBuf;
|
||||
DWORD m_dwBufferSize;
|
||||
D3DFORMAT m_d3dFmt;
|
||||
int m_iidxCount;
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpCollisionObject.h"
|
||||
#include "../SphereLib/frustum.h"
|
||||
|
||||
|
||||
class CScreen : public CGraphicCollisionObject
|
||||
{
|
||||
public:
|
||||
CScreen();
|
||||
virtual ~CScreen();
|
||||
|
||||
void ClearDepthBuffer();
|
||||
void Clear();
|
||||
bool Begin();
|
||||
void End();
|
||||
void Show(HWND hWnd = NULL);
|
||||
void Show(RECT * pSrcRect);
|
||||
void Show(RECT * pSrcRect, HWND hWnd);
|
||||
|
||||
void RenderLine2d(float sx, float sy, float ex, float ey, float z=0.0f);
|
||||
void RenderBox2d(float sx, float sy, float ex, float ey, float z=0.0f);
|
||||
void RenderBar2d(float sx, float sy, float ex, float ey, float z=0.0f);
|
||||
void RenderGradationBar2d(float sx, float sy, float ex, float ey, DWORD dwStartColor, DWORD dwEndColor, float ez=0.0f);
|
||||
void RenderCircle2d(float fx, float fy, float fz, float fRadius, int iStep = 50);
|
||||
void RenderCircle3d(float fx, float fy, float fz, float fRadius, int iStep = 50);
|
||||
|
||||
void RenderLine3d(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||
void RenderBox3d(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||
void RenderBar3d(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||
void RenderBar3d(const D3DXVECTOR3 * c_pv3Positions);
|
||||
void RenderGradationBar3d(float sx, float sy, float sz, float ex, float ey, float ez, DWORD dwStartColor, DWORD dwEndColor);
|
||||
|
||||
void RenderLineCube(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||
void RenderCube(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||
void RenderCube(float sx, float sy, float sz, float ex, float ey, float ez, D3DXMATRIX matRotation);
|
||||
void RenderTextureBox(float sx, float sy, float ex, float ey, float z=0.0f, float su=0.0f, float sv=0.0f, float eu=1.0f, float ev=1.0f);
|
||||
void RenderBillboard(D3DXVECTOR3 * Position, D3DXCOLOR & Color);
|
||||
|
||||
void DrawMinorGrid(float xMin, float yMin, float xMax, float yMax, float xminorStep, float yminorStep, float zPos=0);
|
||||
void DrawGrid(float xMin, float yMin, float xMax, float yMax, float xmajorStep, float ymajorStep, float xminorStep, float yminorStep, float zPos=0);
|
||||
|
||||
void RenderD3DXMesh(LPD3DXMESH lpMesh, const D3DXMATRIX * c_pmatWorld, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode);
|
||||
void RenderSphere(const D3DXMATRIX * c_pmatWorld, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||
void RenderCylinder(const D3DXMATRIX * c_pmatWorld, float fx, float fy, float fz, float fRadius, float fLength, D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||
|
||||
void SetColorOperation();
|
||||
void SetDiffuseOperation();
|
||||
void SetBlendOperation();
|
||||
void SetOneColorOperation(D3DXCOLOR & rColor);
|
||||
void SetAddColorOperation(D3DXCOLOR & rColor);
|
||||
void SetDiffuseColor(DWORD diffuseColor);
|
||||
void SetDiffuseColor(float r, float g, float b, float a=1.0f);
|
||||
void SetClearColor(float r, float g, float b, float a=1.0f);
|
||||
void SetClearDepth(float depth);
|
||||
void SetClearStencil(DWORD stencil);
|
||||
|
||||
void SetCursorPosition(int x, int y, int hres, int vres); // creates picking ray
|
||||
bool GetCursorPosition(float* px, float* py, float* pz);
|
||||
bool GetCursorXYPosition(float* px, float* py);
|
||||
bool GetCursorZPosition(float* pz);
|
||||
void GetPickingPosition(float t, float* x, float* y, float* z);
|
||||
void ProjectPosition(float x, float y, float z, float * pfX, float * pfY);
|
||||
void ProjectPosition(float x, float y, float z, float * pfX, float * pfY, float * pfZ);
|
||||
void UnprojectPosition(float x, float y, float z, float * pfX, float * pfY, float * pfZ);
|
||||
|
||||
BOOL IsLostDevice();
|
||||
BOOL RestoreDevice();
|
||||
|
||||
void BuildViewFrustum();
|
||||
|
||||
static void Identity();
|
||||
static Frustum & GetFrustum() { return ms_frustum; }
|
||||
|
||||
protected:
|
||||
static DWORD ms_diffuseColor;
|
||||
static DWORD ms_clearColor;
|
||||
static DWORD ms_clearStencil;
|
||||
static float ms_clearDepth;
|
||||
|
||||
static Frustum ms_frustum;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpBase.h"
|
||||
|
||||
class CGraphicTexture : public CGraphicBase
|
||||
{
|
||||
public:
|
||||
virtual bool IsEmpty() const;
|
||||
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
|
||||
void SetTextureStage(int stage) const;
|
||||
LPDIRECT3DTEXTURE8 GetD3DTexture() const;
|
||||
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
protected:
|
||||
CGraphicTexture();
|
||||
virtual ~CGraphicTexture();
|
||||
|
||||
void Destroy();
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
bool m_bEmpty;
|
||||
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
LPDIRECT3DTEXTURE8 m_lpd3dTexture;
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpBase.h"
|
||||
|
||||
class CGraphicVertexBuffer : public CGraphicBase
|
||||
{
|
||||
public:
|
||||
CGraphicVertexBuffer();
|
||||
virtual ~CGraphicVertexBuffer();
|
||||
|
||||
void Destroy();
|
||||
virtual bool Create(int vtxCount, DWORD fvf, DWORD usage, D3DPOOL d3dPool);
|
||||
|
||||
bool CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
bool Copy(int bufSize, const void* srcVertices);
|
||||
|
||||
bool LockRange(unsigned count, void** pretVertices) const;
|
||||
bool Lock(void** pretVertices) const;
|
||||
bool Unlock() const;
|
||||
|
||||
bool LockDynamic(void** pretVertices);
|
||||
virtual bool Lock(void** pretVertices);
|
||||
bool Unlock();
|
||||
|
||||
void SetStream(int stride, int layer=0) const;
|
||||
|
||||
int GetVertexCount() const;
|
||||
int GetVertexStride() const;
|
||||
DWORD GetFlexibleVertexFormat() const;
|
||||
|
||||
inline LPDIRECT3DVERTEXBUFFER8 GetD3DVertexBuffer() const { return m_lpd3dVB; }
|
||||
inline DWORD GetBufferSize() const { return m_dwBufferSize; }
|
||||
|
||||
bool IsEmpty() const;
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpd3dVB;
|
||||
|
||||
DWORD m_dwBufferSize;
|
||||
DWORD m_dwFVF;
|
||||
DWORD m_dwUsage;
|
||||
D3DPOOL m_d3dPool;
|
||||
int m_vtxCount;
|
||||
DWORD m_dwLockFlag;
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "GrpVertexBuffer.h"
|
||||
|
||||
class CDynamicVertexBuffer : public CGraphicVertexBuffer
|
||||
{
|
||||
public:
|
||||
CDynamicVertexBuffer();
|
||||
virtual ~CDynamicVertexBuffer();
|
||||
|
||||
bool Create(int vtxCount, int fvf);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
int m_vtxCount;
|
||||
int m_fvf;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef __INC_ETERLIB_MUTEX_H__
|
||||
#define __INC_ETERLIB_MUTEX_H__
|
||||
|
||||
class Mutex
|
||||
{
|
||||
public:
|
||||
Mutex();
|
||||
~Mutex();
|
||||
|
||||
void Lock();
|
||||
void Unlock();
|
||||
bool Trylock();
|
||||
|
||||
private:
|
||||
CRITICAL_SECTION lock;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef VC_EXTRALEAN
|
||||
|
||||
class CNetworkAddress
|
||||
{
|
||||
public:
|
||||
static bool GetHostName(char* szName, int size);
|
||||
|
||||
public:
|
||||
CNetworkAddress();
|
||||
~CNetworkAddress();
|
||||
|
||||
void Clear();
|
||||
|
||||
bool Set(const char* c_szAddr, int port);
|
||||
|
||||
void SetLocalIP();
|
||||
void SetIP(DWORD ip);
|
||||
void SetIP(const char* c_szIP);
|
||||
bool SetDNS(const char* c_szDNS);
|
||||
|
||||
void SetPort(int port);
|
||||
|
||||
int GetPort();
|
||||
int GetSize();
|
||||
|
||||
void GetIP(char* szIP, int len);
|
||||
|
||||
DWORD GetIP();
|
||||
|
||||
operator const SOCKADDR_IN&() const;
|
||||
|
||||
|
||||
private:
|
||||
bool IsIP(const char* c_szAddr);
|
||||
|
||||
private:
|
||||
SOCKADDR_IN m_sockAddrIn;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
class CNetworkDevice
|
||||
{
|
||||
public:
|
||||
CNetworkDevice();
|
||||
virtual ~CNetworkDevice();
|
||||
|
||||
void Destroy();
|
||||
bool Create();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
bool m_isWSA;
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
class CNetworkPacketHeaderMap
|
||||
{
|
||||
public:
|
||||
typedef struct SPacketType
|
||||
{
|
||||
SPacketType(int iSize = 0, bool bFlag = false)
|
||||
{
|
||||
iPacketSize = iSize;
|
||||
isDynamicSizePacket = bFlag;
|
||||
}
|
||||
|
||||
int iPacketSize;
|
||||
bool isDynamicSizePacket;
|
||||
} TPacketType;
|
||||
|
||||
public:
|
||||
CNetworkPacketHeaderMap();
|
||||
virtual ~CNetworkPacketHeaderMap();
|
||||
|
||||
void Set(int header, TPacketType rPacketType);
|
||||
bool Get(int header, TPacketType * pPacketType);
|
||||
|
||||
protected:
|
||||
std::map<int, TPacketType> m_headerMap;
|
||||
};
|
||||
@@ -0,0 +1,684 @@
|
||||
#pragma once
|
||||
|
||||
#include "../EterBase/Debug.h"
|
||||
|
||||
//#define DYNAMIC_POOL_STRICT
|
||||
|
||||
template<typename T>
|
||||
class CDynamicPool
|
||||
{
|
||||
public:
|
||||
CDynamicPool()
|
||||
{
|
||||
//Tracen(typeid(T).name());
|
||||
m_uInitCapacity=0;
|
||||
m_uUsedCapacity=0;
|
||||
}
|
||||
virtual ~CDynamicPool()
|
||||
{
|
||||
assert(m_kVct_pkData.empty());
|
||||
//#ifdef _DEBUG
|
||||
// char szText[256];
|
||||
// sprintf(szText, "--------------------------------------------------------------------- %s Pool Capacity %d\n", typeid(T).name(), m_uUsedCapacity);
|
||||
// OutputDebugString(szText);
|
||||
// printf(szText);
|
||||
//#endif
|
||||
}
|
||||
|
||||
void SetName(const char* c_szName)
|
||||
{
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void Destroy()
|
||||
{
|
||||
/*
|
||||
#ifdef _DEBUG
|
||||
if (!m_kVct_pkData.empty())
|
||||
{
|
||||
char szText[256];
|
||||
sprintf(szText, "--------------------------------------------------------------------- %s Pool Destroy\n", typeid(T).name());
|
||||
OutputDebugString(szText);
|
||||
printf(szText);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
for (auto v : m_kVct_pkData)
|
||||
Delete(v);
|
||||
m_kVct_pkData.clear();
|
||||
m_kVct_pkFree.clear();
|
||||
}
|
||||
|
||||
void Create(UINT uCapacity)
|
||||
{
|
||||
m_uInitCapacity=uCapacity;
|
||||
m_kVct_pkData.reserve(uCapacity);
|
||||
m_kVct_pkFree.reserve(uCapacity);
|
||||
}
|
||||
T* Alloc()
|
||||
{
|
||||
if (m_kVct_pkFree.empty())
|
||||
{
|
||||
T* pkNewData=new T;
|
||||
m_kVct_pkData.push_back(pkNewData);
|
||||
++m_uUsedCapacity;
|
||||
return pkNewData;
|
||||
}
|
||||
|
||||
T* pkFreeData=m_kVct_pkFree.back();
|
||||
m_kVct_pkFree.pop_back();
|
||||
return pkFreeData;
|
||||
}
|
||||
void Free(T* pkData)
|
||||
{
|
||||
#ifdef DYNAMIC_POOL_STRICT
|
||||
assert(__IsValidData(pkData));
|
||||
assert(!__IsFreeData(pkData));
|
||||
#endif
|
||||
m_kVct_pkFree.push_back(pkData);
|
||||
}
|
||||
void FreeAll()
|
||||
{
|
||||
m_kVct_pkFree=m_kVct_pkData;
|
||||
}
|
||||
|
||||
DWORD GetCapacity()
|
||||
{
|
||||
return m_kVct_pkData.size();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool __IsValidData(T* pkData)
|
||||
{
|
||||
if (m_kVct_pkData.end()==std::find(m_kVct_pkData.begin(), m_kVct_pkData.end(), pkData))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool __IsFreeData(T* pkData)
|
||||
{
|
||||
if (m_kVct_pkFree.end()==std::find(m_kVct_pkFree.begin(), m_kVct_pkFree.end(), pkData))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Delete(T* pkData)
|
||||
{
|
||||
delete pkData;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<T*> m_kVct_pkData;
|
||||
std::vector<T*> m_kVct_pkFree;
|
||||
|
||||
UINT m_uInitCapacity;
|
||||
UINT m_uUsedCapacity;
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class CDynamicPoolEx
|
||||
{
|
||||
public:
|
||||
CDynamicPoolEx()
|
||||
{
|
||||
m_uInitCapacity=0;
|
||||
m_uUsedCapacity=0;
|
||||
}
|
||||
virtual ~CDynamicPoolEx()
|
||||
{
|
||||
assert(m_kVct_pkFree.size()==m_kVct_pkData.size());
|
||||
Destroy();
|
||||
|
||||
#ifdef _DEBUG
|
||||
char szText[256];
|
||||
sprintf(szText, "--------------------------------------------------------------------- %s Pool Capacity %d\n", typeid(T).name(), m_uUsedCapacity);
|
||||
OutputDebugString(szText);
|
||||
printf(szText);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void Destroy()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (!m_kVct_pkData.empty())
|
||||
{
|
||||
char szText[256];
|
||||
sprintf(szText, "--------------------------------------------------------------------- %s Pool Destroy\n", typeid(T).name());
|
||||
OutputDebugString(szText);
|
||||
printf(szText);
|
||||
}
|
||||
#endif
|
||||
for (auto v : m_kVct_pkData)
|
||||
Delete(v);
|
||||
m_kVct_pkData.clear();
|
||||
m_kVct_pkFree.clear();
|
||||
}
|
||||
|
||||
void Create(UINT uCapacity)
|
||||
{
|
||||
m_uInitCapacity=uCapacity;
|
||||
m_kVct_pkData.reserve(uCapacity);
|
||||
m_kVct_pkFree.reserve(uCapacity);
|
||||
}
|
||||
T* Alloc()
|
||||
{
|
||||
if (m_kVct_pkFree.empty())
|
||||
{
|
||||
T* pkNewData=New();
|
||||
m_kVct_pkData.push_back(pkNewData);
|
||||
++m_uUsedCapacity;
|
||||
return pkNewData;
|
||||
}
|
||||
|
||||
T* pkFreeData=m_kVct_pkFree.back();
|
||||
m_kVct_pkFree.pop_back();
|
||||
return pkFreeData;
|
||||
}
|
||||
void Free(T* pkData)
|
||||
{
|
||||
#ifdef DYNAMIC_POOL_STRICT
|
||||
assert(__IsValidData(pkData));
|
||||
assert(!__IsFreeData(pkData));
|
||||
#endif
|
||||
m_kVct_pkFree.push_back(pkData);
|
||||
}
|
||||
void FreeAll()
|
||||
{
|
||||
m_kVct_pkFree=m_kVct_pkData;
|
||||
}
|
||||
|
||||
DWORD GetCapacity()
|
||||
{
|
||||
return m_kVct_pkData.size();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool __IsValidData(T* pkData)
|
||||
{
|
||||
if (m_kVct_pkData.end()==std::find(m_kVct_pkData.begin(), m_kVct_pkData.end(), pkData))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
bool __IsFreeData(T* pkData)
|
||||
{
|
||||
if (m_kVct_pkFree.end()==std::find(m_kVct_pkFree.begin(), m_kVct_pkFree.end(), pkData))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static T* New()
|
||||
{
|
||||
return (T*)::operator new(sizeof(T));
|
||||
}
|
||||
static void Delete(T* pkData)
|
||||
{
|
||||
::operator delete(pkData);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<T*> m_kVct_pkData;
|
||||
std::vector<T*> m_kVct_pkFree;
|
||||
|
||||
UINT m_uInitCapacity;
|
||||
UINT m_uUsedCapacity;
|
||||
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class CPooledObject
|
||||
{
|
||||
public:
|
||||
CPooledObject()
|
||||
{
|
||||
}
|
||||
virtual ~CPooledObject()
|
||||
{
|
||||
}
|
||||
|
||||
void * operator new(size_t /*mem_size*/) // PORT: was unsigned int (size_t on ILP32 Win32)
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void operator delete(void* pT)
|
||||
{
|
||||
ms_kPool.Free((T*)pT);
|
||||
}
|
||||
|
||||
|
||||
static void DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
static void DeleteAll()
|
||||
{
|
||||
ms_kPool.FreeAll();
|
||||
}
|
||||
|
||||
protected:
|
||||
static CDynamicPoolEx<T> ms_kPool;
|
||||
};
|
||||
|
||||
template <class T> CDynamicPoolEx<T> CPooledObject<T>::ms_kPool;
|
||||
|
||||
/*
|
||||
|
||||
template <class T>
|
||||
class CDynamicSizePool
|
||||
{
|
||||
#define GETPREVP(p) *(T**)((char*)p+sizeof(T))
|
||||
#define GETNEXTP(p) *(T**)((char*)p+sizeof(T)+sizeof(T*))
|
||||
public:
|
||||
CDynamicSizePool()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
virtual ~CDynamicSizePool()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
m_nodes = NULL;
|
||||
m_nodeCount = 0;
|
||||
|
||||
m_pFreeList = NULL;
|
||||
m_pUsedList = NULL;
|
||||
}
|
||||
|
||||
void SetName(const char* c_szName)
|
||||
{
|
||||
m_stName = c_szName;
|
||||
}
|
||||
|
||||
T* Alloc()
|
||||
{
|
||||
void* pnewNode;
|
||||
|
||||
if (m_pFreeList)
|
||||
{
|
||||
pnewNode = m_pFreeList;
|
||||
m_pFreeList = GETNEXTP(m_pFreeList);
|
||||
}
|
||||
else
|
||||
{
|
||||
pnewNode = AllocNode();
|
||||
}
|
||||
|
||||
if (!pnewNode)
|
||||
return NULL;
|
||||
|
||||
if (!m_pUsedList)
|
||||
{
|
||||
m_pUsedList = pnewNode;
|
||||
GETPREVP(m_pUsedList) = NULL;
|
||||
GETNEXTP(m_pUsedList) = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
GETPREVP(m_pUsedList) = (T*) pnewNode;
|
||||
GETNEXTP(pnewNode) = (T*) m_pUsedList;
|
||||
GETPREVP(pnewNode) = NULL;
|
||||
m_pUsedList = pnewNode;
|
||||
}
|
||||
//Tracef("%s Pool Alloc %p\n", m_stName.c_str(), pnewNode);
|
||||
return (T*) pnewNode;
|
||||
}
|
||||
|
||||
void Free(T * pdata)
|
||||
{
|
||||
void* pfreeNode = (void*) pdata;
|
||||
|
||||
if (pfreeNode == m_pUsedList)
|
||||
{
|
||||
if (NULL != (m_pUsedList = GETNEXTP(m_pUsedList)))
|
||||
GETPREVP(m_pUsedList) = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GETNEXTP(pfreeNode))
|
||||
GETPREVP(GETNEXTP(pfreeNode)) = GETPREVP(pfreeNode);
|
||||
|
||||
if (GETPREVP(pfreeNode))
|
||||
GETNEXTP(GETPREVP(pfreeNode)) = GETNEXTP(pfreeNode);
|
||||
}
|
||||
|
||||
GETPREVP(pfreeNode) = NULL;
|
||||
GETNEXTP(pfreeNode) = (T*)m_pFreeList;
|
||||
m_pFreeList = pfreeNode;
|
||||
//Tracef("%s Pool Free\n", m_stName.c_str());
|
||||
}
|
||||
|
||||
void FreeAll()
|
||||
{
|
||||
void * pcurNode;
|
||||
void * pnextNode;
|
||||
|
||||
pcurNode = m_pUsedList;
|
||||
|
||||
while (pcurNode)
|
||||
{
|
||||
pnextNode = GETNEXTP(pcurNode);
|
||||
Free(pcurNode);
|
||||
pcurNode = pnextNode;
|
||||
}
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
void* pcurNode;
|
||||
void* pnextNode;
|
||||
int count = 0;
|
||||
|
||||
pcurNode = m_pFreeList;
|
||||
while (pcurNode)
|
||||
{
|
||||
pnextNode = GETNEXTP(pcurNode);
|
||||
((T*)pcurNode)->~T();
|
||||
::operator delete(pcurNode);
|
||||
pcurNode = pnextNode;
|
||||
++count;
|
||||
}
|
||||
m_pFreeList = NULL;
|
||||
|
||||
pcurNode = m_pUsedList;
|
||||
while (pcurNode)
|
||||
{
|
||||
pnextNode = GETNEXTP(pcurNode);
|
||||
((T*)pcurNode)->~T();
|
||||
::operator delete(pcurNode);
|
||||
pcurNode = pnextNode;
|
||||
++count;
|
||||
}
|
||||
m_pUsedList = NULL;
|
||||
//Tracef("%s Pool Clear %d\n", m_stName.c_str(), count);
|
||||
}
|
||||
|
||||
protected:
|
||||
void* AllocNode()
|
||||
{
|
||||
return ::operator new(sizeof(T)+sizeof(T*)*2);
|
||||
}
|
||||
|
||||
protected:
|
||||
void * m_nodes;
|
||||
void * m_pFreeList;
|
||||
void * m_pUsedList;
|
||||
|
||||
int m_nodeCount;
|
||||
std::string m_stName;
|
||||
#undef GETNEXTP
|
||||
#undef GETPREVP
|
||||
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class CPooledObject
|
||||
{
|
||||
public:
|
||||
CPooledObject()
|
||||
{
|
||||
}
|
||||
virtual ~CPooledObject()
|
||||
{
|
||||
}
|
||||
|
||||
void * operator new(unsigned int mem_size)
|
||||
{
|
||||
return ms_DynamicSizePool.Alloc();
|
||||
}
|
||||
|
||||
void operator delete(void* pT)
|
||||
{
|
||||
ms_DynamicSizePool.Free((T*)pT);
|
||||
}
|
||||
|
||||
static void SetPoolName(const char* szPoolName)
|
||||
{
|
||||
ms_DynamicSizePool.SetName(szPoolName);
|
||||
}
|
||||
|
||||
static void ClearPool()
|
||||
{
|
||||
ms_DynamicSizePool.Clear();
|
||||
}
|
||||
|
||||
static void FreePool()
|
||||
{
|
||||
ms_DynamicSizePool.FreeAll();
|
||||
}
|
||||
|
||||
protected:
|
||||
static CDynamicSizePool<T> ms_DynamicSizePool;
|
||||
};
|
||||
|
||||
template <class T> CDynamicSizePool<T> CPooledObject<T>::ms_DynamicSizePool;
|
||||
*/
|
||||
|
||||
/*
|
||||
template<typename T>
|
||||
class CPoolNode : public T
|
||||
{
|
||||
public:
|
||||
CPoolNode()
|
||||
{
|
||||
m_pNext = NULL;
|
||||
m_pPrev = NULL;
|
||||
}
|
||||
|
||||
virtual ~CPoolNode()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
CPoolNode<T> * m_pNext;
|
||||
CPoolNode<T> * m_pPrev;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class CDynamicPool
|
||||
{
|
||||
public:
|
||||
typedef CPoolNode<T> TNode;
|
||||
|
||||
public:
|
||||
CDynamicPool()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
virtual ~CDynamicPool()
|
||||
{
|
||||
assert(m_pFreeList==NULL && "CDynamicPool::~CDynamicPool() - NOT Clear");
|
||||
assert(m_pUsedList==NULL && "CDynamicPool::~CDynamicPool() - NOT Clear");
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
m_nodes = NULL;
|
||||
m_nodeCount = 0;
|
||||
|
||||
m_pFreeList = NULL;
|
||||
m_pUsedList = NULL;
|
||||
}
|
||||
|
||||
void SetName(const char* c_szName)
|
||||
{
|
||||
m_stName = c_szName;
|
||||
}
|
||||
|
||||
DWORD GetCapacity()
|
||||
{
|
||||
return m_nodeCount;
|
||||
}
|
||||
|
||||
T* Alloc()
|
||||
{
|
||||
TNode* pnewNode;
|
||||
|
||||
if (m_pFreeList)
|
||||
{
|
||||
pnewNode = m_pFreeList;
|
||||
m_pFreeList = m_pFreeList->m_pNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
pnewNode = AllocNode();
|
||||
}
|
||||
|
||||
if (!pnewNode)
|
||||
return NULL;
|
||||
|
||||
if (!m_pUsedList)
|
||||
{
|
||||
m_pUsedList = pnewNode;
|
||||
m_pUsedList->m_pPrev = m_pUsedList->m_pNext = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pUsedList->m_pPrev = pnewNode;
|
||||
pnewNode->m_pNext = m_pUsedList;
|
||||
pnewNode->m_pPrev = NULL;
|
||||
m_pUsedList = pnewNode;
|
||||
}
|
||||
//Tracef("%s Pool Alloc %p\n", m_stName.c_str(), pnewNode);
|
||||
return (T*) pnewNode;
|
||||
}
|
||||
|
||||
bool IsUsedData(T* pdata)
|
||||
{
|
||||
TNode* pchkNode=(TNode*)pdata;
|
||||
TNode* pcurNode = m_pUsedList;
|
||||
while (pcurNode)
|
||||
{
|
||||
if (pcurNode==pdata)
|
||||
return true;
|
||||
|
||||
pcurNode = pcurNode->m_pNext;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsFreeData(T* pdata)
|
||||
{
|
||||
TNode* pchkNode=(TNode*)pdata;
|
||||
TNode* pcurNode = m_pFreeList;
|
||||
while (pcurNode)
|
||||
{
|
||||
if (pcurNode==pdata)
|
||||
return true;
|
||||
|
||||
pcurNode = pcurNode->m_pNext;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Free(T * pdata)
|
||||
{
|
||||
assert(IsUsedData(pdata));
|
||||
assert(!IsFreeData(pdata));
|
||||
|
||||
TNode* pfreeNode = (TNode*) pdata;
|
||||
|
||||
if (pfreeNode == m_pUsedList)
|
||||
{
|
||||
m_pUsedList = m_pUsedList->m_pNext;
|
||||
if (NULL != m_pUsedList)
|
||||
m_pUsedList->m_pPrev = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pfreeNode->m_pNext)
|
||||
pfreeNode->m_pNext->m_pPrev = pfreeNode->m_pPrev;
|
||||
|
||||
if (pfreeNode->m_pPrev)
|
||||
pfreeNode->m_pPrev->m_pNext = pfreeNode->m_pNext;
|
||||
}
|
||||
|
||||
pfreeNode->m_pPrev = NULL;
|
||||
pfreeNode->m_pNext = m_pFreeList;
|
||||
m_pFreeList = pfreeNode;
|
||||
//Tracef("%s Pool Free\n", m_stName.c_str());
|
||||
}
|
||||
|
||||
void FreeAll()
|
||||
{
|
||||
TNode * pcurNode;
|
||||
TNode * pnextNode;
|
||||
|
||||
pcurNode = m_pUsedList;
|
||||
|
||||
while (pcurNode)
|
||||
{
|
||||
pnextNode = pcurNode->m_pNext;
|
||||
Free(pcurNode);
|
||||
pcurNode = pnextNode;
|
||||
}
|
||||
|
||||
assert(NULL==m_pUsedList);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
TNode* pcurNode;
|
||||
TNode* pnextNode;
|
||||
|
||||
DWORD count = 0;
|
||||
|
||||
pcurNode = m_pFreeList;
|
||||
while (pcurNode)
|
||||
{
|
||||
pnextNode = pcurNode->m_pNext;
|
||||
delete pcurNode;
|
||||
pcurNode = pnextNode;
|
||||
++count;
|
||||
}
|
||||
m_pFreeList = NULL;
|
||||
|
||||
pcurNode = m_pUsedList;
|
||||
while (pcurNode)
|
||||
{
|
||||
pnextNode = pcurNode->m_pNext;
|
||||
delete pcurNode;
|
||||
pcurNode = pnextNode;
|
||||
++count;
|
||||
}
|
||||
|
||||
m_pUsedList = NULL;
|
||||
|
||||
assert(count==m_nodeCount && "CDynamicPool::Clear()");
|
||||
|
||||
m_nodeCount=0;
|
||||
}
|
||||
|
||||
protected:
|
||||
TNode* AllocNode()
|
||||
{
|
||||
++m_nodeCount;
|
||||
return new TNode;
|
||||
}
|
||||
|
||||
protected:
|
||||
TNode * m_nodes;
|
||||
TNode * m_pFreeList;
|
||||
TNode * m_pUsedList;
|
||||
|
||||
DWORD m_nodeCount;
|
||||
std::string m_stName;
|
||||
};
|
||||
*/
|
||||
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3dx8.h>
|
||||
|
||||
class CRay
|
||||
{
|
||||
public:
|
||||
CRay(const D3DXVECTOR3 & v3Start, const D3DXVECTOR3 & v3Dir, float fRayRange) : m_v3Start(v3Start), m_v3Direction(v3Dir)
|
||||
{
|
||||
assert(fRayRange >= 0);
|
||||
m_fRayRange = fRayRange;
|
||||
D3DXVec3Normalize(&m_v3Direction, &m_v3Direction);
|
||||
m_v3End = m_v3Start + fRayRange * m_v3Direction;
|
||||
}
|
||||
|
||||
CRay()
|
||||
{
|
||||
}
|
||||
|
||||
void SetStartPoint(const D3DXVECTOR3 & v3Start)
|
||||
{
|
||||
m_v3Start = v3Start;
|
||||
}
|
||||
|
||||
void SetDirection(const D3DXVECTOR3 & v3Dir, float fRayRange)
|
||||
{
|
||||
assert(fRayRange >= 0);
|
||||
m_v3Direction = v3Dir;
|
||||
D3DXVec3Normalize(&m_v3Direction, &m_v3Direction);
|
||||
m_fRayRange = fRayRange;
|
||||
m_v3End = m_v3Start + m_fRayRange * m_v3Direction;
|
||||
}
|
||||
|
||||
void GetStartPoint(D3DXVECTOR3 * pv3Start) const
|
||||
{
|
||||
*pv3Start = m_v3Start;
|
||||
}
|
||||
|
||||
void GetDirection(D3DXVECTOR3 * pv3Dir, float * pfRayRange) const
|
||||
{
|
||||
*pv3Dir = m_v3Direction;
|
||||
*pfRayRange = m_fRayRange;
|
||||
}
|
||||
|
||||
void GetEndPoint(D3DXVECTOR3 * pv3End) const
|
||||
{
|
||||
*pv3End = m_v3End;
|
||||
}
|
||||
|
||||
const CRay & operator = (const CRay & rhs)
|
||||
{
|
||||
assert(rhs.m_fRayRange >= 0);
|
||||
m_v3Start = rhs.m_v3Start;
|
||||
m_v3Direction = rhs.m_v3Direction;
|
||||
m_fRayRange = rhs.m_fRayRange;
|
||||
D3DXVec3Normalize(&m_v3Direction, &m_v3Direction);
|
||||
m_v3End = m_v3Start + m_fRayRange * m_v3Direction;
|
||||
}
|
||||
|
||||
private:
|
||||
D3DXVECTOR3 m_v3Start;
|
||||
D3DXVECTOR3 m_v3End;
|
||||
D3DXVECTOR3 m_v3Direction;
|
||||
float m_fRayRange;
|
||||
};
|
||||
@@ -0,0 +1,104 @@
|
||||
#ifndef __INC_REF_H__
|
||||
#define __INC_REF_H__
|
||||
|
||||
#include "ReferenceObject.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
template<typename T> class CRef
|
||||
{
|
||||
public:
|
||||
struct FClear
|
||||
{
|
||||
void operator() (CRef<T>& rRef)
|
||||
{
|
||||
rRef.Clear();
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
CRef() : m_pObject(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CRef(CReferenceObject* pObject)
|
||||
{
|
||||
m_pObject = NULL;
|
||||
Initialize(pObject);
|
||||
}
|
||||
|
||||
CRef(const CRef& c_rRef)
|
||||
{
|
||||
m_pObject = NULL;
|
||||
Initialize(c_rRef.m_pObject);
|
||||
}
|
||||
|
||||
~CRef()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void operator = (CReferenceObject* pObject)
|
||||
{
|
||||
SetPointer(pObject);
|
||||
}
|
||||
|
||||
void operator = (const CRef& c_rRef)
|
||||
{
|
||||
SetPointer(c_rRef.m_pObject);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
if (m_pObject)
|
||||
{
|
||||
m_pObject->Release();
|
||||
m_pObject = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNull() const
|
||||
{
|
||||
return m_pObject == NULL ? true : false;
|
||||
}
|
||||
|
||||
void SetPointer(CReferenceObject* pObject)
|
||||
{
|
||||
CReferenceObject* pOldObject = m_pObject;
|
||||
|
||||
m_pObject = pObject;
|
||||
|
||||
if (m_pObject)
|
||||
m_pObject->AddReference();
|
||||
|
||||
if (pOldObject)
|
||||
pOldObject->Release();
|
||||
}
|
||||
|
||||
T* GetPointer() const
|
||||
{
|
||||
return static_cast<T*>(m_pObject);
|
||||
}
|
||||
|
||||
T* operator->() const
|
||||
{
|
||||
assert(m_pObject != NULL);
|
||||
return static_cast<T*>(m_pObject);
|
||||
}
|
||||
|
||||
private:
|
||||
void Initialize(CReferenceObject* pObject)
|
||||
{
|
||||
assert(m_pObject == NULL);
|
||||
|
||||
m_pObject = pObject;
|
||||
|
||||
if (m_pObject)
|
||||
m_pObject->AddReference();
|
||||
}
|
||||
|
||||
private:
|
||||
CReferenceObject* m_pObject;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
class CReferenceObject
|
||||
{
|
||||
public:
|
||||
CReferenceObject();
|
||||
virtual ~CReferenceObject();
|
||||
|
||||
void AddReference();
|
||||
void AddReferenceOnly();
|
||||
void Release();
|
||||
|
||||
int GetReferenceCount();
|
||||
|
||||
bool canDestroy();
|
||||
|
||||
protected:
|
||||
virtual void OnConstruct();
|
||||
virtual void OnSelfDestruct();
|
||||
|
||||
private:
|
||||
int m_refCount;
|
||||
bool m_destructed;
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include "ReferenceObject.h"
|
||||
#include <string>
|
||||
|
||||
class CResource : public CReferenceObject
|
||||
{
|
||||
public:
|
||||
typedef DWORD TType;
|
||||
|
||||
enum EState
|
||||
{
|
||||
STATE_EMPTY,
|
||||
STATE_ERROR,
|
||||
STATE_EXIST,
|
||||
STATE_LOAD,
|
||||
STATE_FREE
|
||||
};
|
||||
|
||||
public:
|
||||
void Clear();
|
||||
|
||||
static TType StringToType(const char* c_szType);
|
||||
static TType Type();
|
||||
|
||||
void Load();
|
||||
void Reload();
|
||||
int ConvertPathName(const char * c_szPathName, char * pszRetPathName, int retLen);
|
||||
|
||||
virtual bool CreateDeviceObjects();
|
||||
virtual void DestroyDeviceObjects();
|
||||
|
||||
public:
|
||||
CResource(const char* c_szFileName);
|
||||
virtual ~CResource();
|
||||
|
||||
static void SetDeleteImmediately(bool isSet = false);
|
||||
|
||||
// is loaded?
|
||||
bool IsData() const;
|
||||
bool IsEmpty() const;
|
||||
bool IsType(TType type);
|
||||
|
||||
DWORD GetLoadCostMilliSecond() { return m_dwLoadCostMiliiSecond; }
|
||||
//const char * GetFileName() const { return m_pszFileName; }
|
||||
const char * GetFileName() const { return m_stFileName.c_str(); }
|
||||
const std::string& GetFileNameString() const { return m_stFileName; }
|
||||
|
||||
virtual bool OnLoad(int iSize, const void * c_pvBuf) = 0;
|
||||
|
||||
protected:
|
||||
void SetFileName(const char* c_szFileName);
|
||||
|
||||
virtual void OnClear() = 0;
|
||||
virtual bool OnIsEmpty() const = 0;
|
||||
virtual bool OnIsType(TType type) = 0;
|
||||
|
||||
virtual void OnConstruct();
|
||||
virtual void OnSelfDestruct();
|
||||
|
||||
protected:
|
||||
std::string m_stFileName;
|
||||
//char * m_pszFileName;
|
||||
DWORD m_dwLoadCostMiliiSecond;
|
||||
EState me_state;
|
||||
|
||||
protected:
|
||||
static bool ms_bDeleteImmediately;
|
||||
};
|
||||
@@ -0,0 +1,188 @@
|
||||
// SkyBox.h: interface for the CSkyBox class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SKYBOX_H__AB5049E1_8F1C_4C35_9406_45EC7EF4AD1B__INCLUDED_)
|
||||
#define AFX_SKYBOX_H__AB5049E1_8F1C_4C35_9406_45EC7EF4AD1B__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "GrpBase.h"
|
||||
#include "GrpScreen.h"
|
||||
#include "GrpImageInstance.h"
|
||||
#include "ColorTransitionHelper.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
typedef struct SColor
|
||||
{
|
||||
SColor(float _r = 0.0f, float _g = 0.0f, float _b = 0.0f, float _a = 0.0f) : r(_r), g(_g), b(_b), a(_a){}
|
||||
float r, g, b, a;
|
||||
} TColor;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TColor m_FirstColor;
|
||||
TColor m_SecondColor;
|
||||
}TGradientColor;
|
||||
|
||||
typedef std::vector<TGradientColor> TVectorGradientColor;
|
||||
typedef TVectorGradientColor::iterator TVectorGradientIterator;
|
||||
|
||||
class CSkyObjectQuad
|
||||
{
|
||||
public:
|
||||
CSkyObjectQuad();
|
||||
virtual ~CSkyObjectQuad();
|
||||
|
||||
void Clear(const unsigned char & c_rucNumVertex,
|
||||
const float & c_rfRed,
|
||||
const float & c_rfGreen,
|
||||
const float & c_rfBlue,
|
||||
const float & c_rfAlpha);
|
||||
void SetSrcColor(const unsigned char & c_rucNumVertex,
|
||||
const float & c_rfRed,
|
||||
const float & c_rfGreen,
|
||||
const float & c_rfBlue,
|
||||
const float & c_rfAlpha);
|
||||
void SetTransition(const unsigned char & c_rucNumVertex,
|
||||
const float & c_rfRed,
|
||||
const float & c_rfGreen,
|
||||
const float & c_rfBlue,
|
||||
const float & c_rfAlpha,
|
||||
DWORD dwDuration);
|
||||
|
||||
void SetVertex(const unsigned char & c_rucNumVertex, const TPDTVertex & c_rPDTVertex);
|
||||
|
||||
void StartTransition();
|
||||
bool Update();
|
||||
void Render();
|
||||
|
||||
private:
|
||||
TPDTVertex m_Vertex[4];
|
||||
TIndex m_Indices[4]; // 인덱스 버퍼...
|
||||
CColorTransitionHelper m_Helper[4];
|
||||
};
|
||||
|
||||
class CSkyObject : public CScreen
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
SKY_RENDER_MODE_DEFAULT, // = SKY_RENDER_MODE_TEXTURE
|
||||
SKY_RENDER_MODE_DIFFUSE,
|
||||
SKY_RENDER_MODE_TEXTURE,
|
||||
SKY_RENDER_MODE_MODULATE,
|
||||
SKY_RENDER_MODE_MODULATE2X,
|
||||
SKY_RENDER_MODE_MODULATE4X,
|
||||
};
|
||||
|
||||
CSkyObject();
|
||||
virtual ~CSkyObject();
|
||||
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
virtual void Render() = 0;
|
||||
virtual void Update() = 0;
|
||||
virtual void StartTransition();
|
||||
|
||||
void SetRenderMode(unsigned char ucRenderMode) { m_ucRenderMode = ucRenderMode; }
|
||||
|
||||
const bool & isTransitionStarted() { return m_bTransitionStarted; }
|
||||
|
||||
protected:
|
||||
CGraphicImageInstance * GenerateTexture(const char * szfilename);
|
||||
void DeleteTexture(CGraphicImageInstance * pGraphicImageInstance);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 타입 정의
|
||||
|
||||
typedef std::vector<CSkyObjectQuad> TSkyObjectQuadVector;
|
||||
typedef TSkyObjectQuadVector::iterator TSkyObjectQuadIterator;
|
||||
|
||||
typedef struct CSkyBox
|
||||
{
|
||||
void StartTransition();
|
||||
bool Update();
|
||||
void Render();
|
||||
std::string m_strfacename;
|
||||
std::string m_strFaceTextureFileName;
|
||||
TSkyObjectQuadVector m_SkyObjectQuadVector;
|
||||
}TSkyObjectFace;
|
||||
|
||||
typedef std::map <std::string, CGraphicImageInstance*> TGraphicImageInstanceMap;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 구름...
|
||||
TSkyObjectFace m_FaceCloud; // 구름 일단 한장...
|
||||
D3DXMATRIX m_matWorldCloud, m_matTranslationCloud, m_matTextureCloud;
|
||||
D3DXVECTOR3 m_v3PositionCloud;
|
||||
float m_fCloudScaleX, m_fCloudScaleY, m_fCloudHeight;
|
||||
float m_fCloudTextureScaleX, m_fCloudTextureScaleY;
|
||||
float m_fCloudScrollSpeedU, m_fCloudScrollSpeedV;
|
||||
float m_fCloudPositionU, m_fCloudPositionV;
|
||||
|
||||
DWORD m_dwlastTime;
|
||||
|
||||
// 스카이 박스 이미지...
|
||||
TGraphicImageInstanceMap m_GraphicImageInstanceMap;
|
||||
|
||||
// Transform...
|
||||
D3DXMATRIX m_matWorld, m_matTranslation;
|
||||
D3DXVECTOR3 m_v3Position;
|
||||
float m_fScaleX, m_fScaleY, m_fScaleZ;
|
||||
|
||||
// 랜더링 관련... 임시 변수..
|
||||
unsigned char m_ucRenderMode;
|
||||
|
||||
std::string m_strCurTime;
|
||||
bool m_bTransitionStarted;
|
||||
bool m_bSkyMatrixUpdated;
|
||||
|
||||
CGraphicImageInstance m_CloudAlphaImageInstance;
|
||||
};
|
||||
|
||||
class CSkyBox : public CSkyObject
|
||||
{
|
||||
public:
|
||||
CSkyBox();
|
||||
virtual ~CSkyBox();
|
||||
|
||||
void Update();
|
||||
void Render();
|
||||
void RenderCloud();
|
||||
|
||||
void Destroy();
|
||||
void Unload();
|
||||
|
||||
void SetSkyBoxScale(const D3DXVECTOR3 & c_rv3Scale);
|
||||
void SetGradientLevel(BYTE byUpper, BYTE byLower);
|
||||
void SetFaceTexture( const char* c_szFileName, int iFaceIndex );
|
||||
void SetCloudTexture(const char * c_szFileName);
|
||||
void SetCloudScale(const D3DXVECTOR2 & c_rv2CloudScale);
|
||||
void SetCloudHeight(float fHeight);
|
||||
void SetCloudTextureScale(const D3DXVECTOR2 & c_rv2CloudTextureScale);
|
||||
void SetCloudScrollSpeed(const D3DXVECTOR2 & c_rv2CloudScrollSpeed);
|
||||
void SetCloudColor(const TGradientColor & c_rColor, const TGradientColor & c_rNextColor, const DWORD & dwTransitionTime);
|
||||
void Refresh();
|
||||
void SetSkyColor(const TVectorGradientColor & c_rColorVector, const TVectorGradientColor & c_rNextColorVector, long lTransitionTime);
|
||||
void StartTransition();
|
||||
|
||||
protected:
|
||||
void SetSkyObjectQuadVertical(TSkyObjectQuadVector * pSkyObjectQuadVector, const D3DXVECTOR2 * c_pv2QuadPoints);
|
||||
void SetSkyObjectQuadHorizon(TSkyObjectQuadVector * pSkyObjectQuadVector, const D3DXVECTOR3 * c_pv3QuadPoints);
|
||||
|
||||
//void UpdateSkyFaceQuadTransform(D3DXVECTOR3 * c_pv3QuadPoints);
|
||||
|
||||
protected:
|
||||
unsigned char m_ucVirticalGradientLevelUpper;
|
||||
unsigned char m_ucVirticalGradientLevelLower;
|
||||
TSkyObjectFace m_Faces[6];
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SKYBOX_H__AB5049E1_8F1C_4C35_9406_45EC7EF4AD1B__INCLUDED_)
|
||||
@@ -0,0 +1,142 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#define _WIN32_DCOM
|
||||
|
||||
#pragma warning(disable:4710) // not inlined
|
||||
#pragma warning(disable:4786) // character 255 넘어가는거 끄기
|
||||
#pragma warning(disable:4244) // type conversion possible lose of data
|
||||
|
||||
#pragma warning(disable:4018)
|
||||
#pragma warning(disable:4245)
|
||||
#pragma warning(disable:4512)
|
||||
#pragma warning(disable:4201)
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#pragma warning(disable:4201 4512 4238 4239)
|
||||
#endif
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
|
||||
#include <dinput.h>
|
||||
|
||||
#pragma warning ( disable : 4201 )
|
||||
#include <mmsystem.h>
|
||||
#pragma warning ( default : 4201 )
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <direct.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
#pragma comment(lib, "d3d8.lib")
|
||||
#pragma comment(lib, "d3dx8.lib")
|
||||
|
||||
#include "../EterBase/StdAfx.h"
|
||||
#include "../EterBase/Debug.h"
|
||||
#include "../EterLocale/CodePageId.h"
|
||||
|
||||
#ifndef VC_EXTRALEAN
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
#include "Pool.h"
|
||||
#include "Dynamic.h"
|
||||
#include "Event.h"
|
||||
#include "FuncObject.h"
|
||||
#include "ReferenceObject.h"
|
||||
#include "Ref.h"
|
||||
|
||||
#include "Util.h"
|
||||
#include "TextFileLoader.h"
|
||||
#include "parser.h"
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include "MSWindow.h"
|
||||
#include "MSApplication.h"
|
||||
#include "Mutex.h"
|
||||
#include "Thread.h"
|
||||
|
||||
#include "GrpBase.h"
|
||||
|
||||
#include "GrpDIB.h"
|
||||
#include "GrpMath.h"
|
||||
#include "GrpDevice.h"
|
||||
|
||||
#include "CollisionData.h"
|
||||
#include "GrpCollisionObject.h"
|
||||
#include "GrpScreen.h"
|
||||
#include "CullingManager.h"
|
||||
|
||||
// Attribute
|
||||
#include "AttributeData.h"
|
||||
#include "AttributeInstance.h"
|
||||
|
||||
#include "GrpObjectInstance.h"
|
||||
#include "GrpRatioInstance.h"
|
||||
|
||||
#include "GrpD3DXBuffer.h"
|
||||
|
||||
#include "GrpTexture.h"
|
||||
#include "GrpImageTexture.h"
|
||||
#include "GrpFontTexture.h"
|
||||
|
||||
#include "GrpText.h"
|
||||
#include "GrpImage.h"
|
||||
#include "GrpSubImage.h"
|
||||
|
||||
#include "GrpIndexBuffer.h"
|
||||
#include "GrpVertexBuffer.h"
|
||||
#include "GrpVertexBufferStatic.h"
|
||||
#include "GrpVertexBufferDynamic.h"
|
||||
#include "GrpVertexShader.h"
|
||||
#include "GrpPixelShader.h"
|
||||
|
||||
|
||||
#include "GrpShadowTexture.h"
|
||||
#include "GrpImageInstance.h"
|
||||
#include "GrpExpandedImageInstance.h"
|
||||
#include "GrpTextInstance.h"
|
||||
#include "GrpLightManager.h"
|
||||
|
||||
#include "TargaResource.h"
|
||||
|
||||
#include "NetDevice.h"
|
||||
#include "NetAddress.h"
|
||||
// #include "NetStream.h"
|
||||
#include "NetPacketHeaderMap.h"
|
||||
#include "NetDatagramSender.h"
|
||||
#include "NetDatagramReceiver.h"
|
||||
|
||||
#include "Input.h"
|
||||
#include "IME.h"
|
||||
|
||||
#include "PathStack.h"
|
||||
//#include "Property.h"
|
||||
|
||||
#include "Profiler.h"
|
||||
|
||||
#include "StateManager.h"
|
||||
|
||||
#include "ColorTransitionHelper.h"
|
||||
#include "LensFlare.h"
|
||||
#include "ScreenFilter.h"
|
||||
#include "EnvironmentMap.h"
|
||||
|
||||
#include "lineintersect_utils.h"
|
||||
|
||||
#include "Decal.h"
|
||||
*/
|
||||
@@ -0,0 +1,132 @@
|
||||
#ifndef __INC_METIN_II_TEXTFILELOADER_H__
|
||||
#define __INC_METIN_II_TEXTFILELOADER_H__
|
||||
|
||||
#include "../EterBase/FileLoader.h"
|
||||
#include "../EterBase/MappedFile.h"
|
||||
#include "../EterLib/Util.h"
|
||||
#include "../EterLib/Pool.h"
|
||||
|
||||
class CTextFileLoader
|
||||
{
|
||||
public:
|
||||
typedef struct SGroupNode
|
||||
{
|
||||
static DWORD GenNameKey(const char* c_szGroupName, UINT uGroupNameLen);
|
||||
|
||||
void SetGroupName(const std::string& c_rstGroupName);
|
||||
bool IsGroupNameKey(DWORD dwGroupNameKey);
|
||||
|
||||
const std::string& GetGroupName();
|
||||
|
||||
CTokenVector* GetTokenVector(const std::string& c_rstGroupName);
|
||||
bool IsExistTokenVector(const std::string& c_rstGroupName);
|
||||
void InsertTokenVector(const std::string& c_rstGroupName, const CTokenVector& c_rkVct_stToken);
|
||||
|
||||
DWORD m_dwGroupNameKey;
|
||||
std::string m_strGroupName;
|
||||
|
||||
std::map<DWORD, CTokenVector> m_kMap_dwKey_kVct_stToken;
|
||||
|
||||
SGroupNode * pParentNode;
|
||||
std::vector<SGroupNode*> ChildNodeVector;
|
||||
|
||||
static SGroupNode* New();
|
||||
static void Delete(SGroupNode* pkNode);
|
||||
|
||||
static void DestroySystem();
|
||||
static CDynamicPool<SGroupNode> ms_kPool;
|
||||
} TGroupNode;
|
||||
|
||||
typedef std::vector<TGroupNode*> TGroupNodeVector;
|
||||
|
||||
class CGotoChild
|
||||
{
|
||||
public:
|
||||
CGotoChild(CTextFileLoader * pOwner, const char * c_szKey) : m_pOwner(pOwner)
|
||||
{
|
||||
m_pOwner->SetChildNode(c_szKey);
|
||||
}
|
||||
CGotoChild(CTextFileLoader * pOwner, DWORD dwIndex) : m_pOwner(pOwner)
|
||||
{
|
||||
m_pOwner->SetChildNode(dwIndex);
|
||||
}
|
||||
~CGotoChild()
|
||||
{
|
||||
m_pOwner->SetParentNode();
|
||||
}
|
||||
|
||||
CTextFileLoader * m_pOwner;
|
||||
};
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static void SetCacheMode();
|
||||
|
||||
static CTextFileLoader* Cache(const char* c_szFileName);
|
||||
|
||||
public:
|
||||
CTextFileLoader();
|
||||
virtual ~CTextFileLoader();
|
||||
|
||||
void Destroy();
|
||||
|
||||
bool Load(const char * c_szFileName);
|
||||
const char * GetFileName();
|
||||
|
||||
bool IsEmpty();
|
||||
|
||||
void SetTop();
|
||||
DWORD GetChildNodeCount();
|
||||
BOOL SetChildNode(const char * c_szKey);
|
||||
BOOL SetChildNode(const std::string & c_rstrKeyHead, DWORD dwIndex);
|
||||
BOOL SetChildNode(DWORD dwIndex);
|
||||
BOOL SetParentNode();
|
||||
BOOL GetCurrentNodeName(std::string * pstrName);
|
||||
|
||||
BOOL IsToken(const std::string & c_rstrKey);
|
||||
BOOL GetTokenVector(const std::string & c_rstrKey, CTokenVector ** ppTokenVector);
|
||||
BOOL GetTokenBoolean(const std::string & c_rstrKey, BOOL * pData);
|
||||
BOOL GetTokenByte(const std::string & c_rstrKey, BYTE * pData);
|
||||
BOOL GetTokenWord(const std::string & c_rstrKey, WORD * pData);
|
||||
BOOL GetTokenInteger(const std::string & c_rstrKey, int * pData);
|
||||
BOOL GetTokenDoubleWord(const std::string & c_rstrKey, DWORD * pData);
|
||||
BOOL GetTokenFloat(const std::string & c_rstrKey, float * pData);
|
||||
BOOL GetTokenVector2(const std::string & c_rstrKey, D3DXVECTOR2 * pVector2);
|
||||
BOOL GetTokenVector3(const std::string & c_rstrKey, D3DXVECTOR3 * pVector3);
|
||||
BOOL GetTokenVector4(const std::string & c_rstrKey, D3DXVECTOR4 * pVector4);
|
||||
|
||||
BOOL GetTokenPosition(const std::string & c_rstrKey, D3DXVECTOR3 * pVector);
|
||||
BOOL GetTokenQuaternion(const std::string & c_rstrKey, D3DXQUATERNION * pQ);
|
||||
BOOL GetTokenDirection(const std::string & c_rstrKey, D3DVECTOR * pVector);
|
||||
BOOL GetTokenColor(const std::string & c_rstrKey, D3DXCOLOR * pColor);
|
||||
BOOL GetTokenColor(const std::string & c_rstrKey, D3DCOLORVALUE * pColor);
|
||||
BOOL GetTokenString(const std::string & c_rstrKey, std::string * pString);
|
||||
|
||||
protected:
|
||||
void __DestroyGroupNodeVector();
|
||||
|
||||
bool LoadGroup(TGroupNode * pGroupNode);
|
||||
|
||||
protected:
|
||||
std::string m_strFileName;
|
||||
|
||||
char* m_acBufData;
|
||||
DWORD m_dwBufSize;
|
||||
DWORD m_dwBufCapacity;
|
||||
|
||||
DWORD m_dwcurLineIndex;
|
||||
|
||||
CMemoryTextFileLoader m_textFileLoader;
|
||||
|
||||
TGroupNode m_GlobalNode;
|
||||
TGroupNode * m_pcurNode;
|
||||
|
||||
std::vector<SGroupNode*> m_kVct_pkNode;
|
||||
|
||||
protected:
|
||||
static std::map<DWORD, CTextFileLoader*> ms_kMap_dwNameKey_pkTextFileLoader;
|
||||
static bool ms_isCacheMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,113 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../EterBase/FileLoader.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include <d3dx8.h>
|
||||
|
||||
template<typename T>
|
||||
class CTransitor
|
||||
{
|
||||
public:
|
||||
CTransitor() {}
|
||||
~CTransitor() {}
|
||||
|
||||
void SetActive(BOOL bActive = TRUE)
|
||||
{
|
||||
m_bActivated = bActive;
|
||||
}
|
||||
|
||||
BOOL isActive()
|
||||
{
|
||||
return m_bActivated;
|
||||
}
|
||||
|
||||
BOOL isActiveTime(float fcurTime)
|
||||
{
|
||||
if (fcurTime >= m_fEndTime)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD GetID()
|
||||
{
|
||||
return m_dwID;
|
||||
}
|
||||
|
||||
void SetID(DWORD dwID)
|
||||
{
|
||||
m_dwID = dwID;
|
||||
}
|
||||
|
||||
void SetSourceValue(const T & c_rSourceValue)
|
||||
{
|
||||
m_SourceValue = c_rSourceValue;
|
||||
}
|
||||
|
||||
void SetTransition(const T & c_rSourceValue, const T & c_rTargetValue, float fStartTime, float fBlendTime)
|
||||
{
|
||||
m_SourceValue = c_rSourceValue;
|
||||
m_TargetValue = c_rTargetValue;
|
||||
m_fStartTime = fStartTime;
|
||||
m_fEndTime = fStartTime + fBlendTime;
|
||||
}
|
||||
|
||||
BOOL GetValue(float fcurTime, T * pValue)
|
||||
{
|
||||
if (fcurTime <= m_fStartTime)
|
||||
return FALSE;
|
||||
|
||||
float fPercentage = (fcurTime - m_fStartTime) / (m_fEndTime - m_fStartTime);
|
||||
*pValue = m_SourceValue + (m_TargetValue - m_SourceValue) * fPercentage;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
protected:
|
||||
DWORD m_dwID; // Public Transitor ID
|
||||
|
||||
BOOL m_bActivated; // Have been started to blend?
|
||||
float m_fStartTime;
|
||||
float m_fEndTime;
|
||||
|
||||
T m_SourceValue;
|
||||
T m_TargetValue;
|
||||
};
|
||||
|
||||
typedef CTransitor<float> TTransitorFloat;
|
||||
typedef CTransitor<D3DXVECTOR3> TTransitorVector3;
|
||||
typedef CTransitor<D3DXCOLOR> TTransitorColor;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void PrintfTabs(FILE * File, int iTabCount, const char * c_szString, ...);
|
||||
|
||||
|
||||
//typedef CTokenVector TTokenVector;
|
||||
|
||||
extern bool LoadTextData(const char * c_szFileName, CTokenMap & rstTokenMap);
|
||||
extern bool LoadMultipleTextData(const char * c_szFileName, CTokenVectorMap & rstTokenVectorMap);
|
||||
|
||||
extern D3DXVECTOR3 TokenToVector(CTokenVector & rVector);
|
||||
extern D3DXCOLOR TokenToColor(CTokenVector & rVector);
|
||||
|
||||
#define GOTO_CHILD_NODE(TextFileLoader, Index) CTextFileLoader::CGotoChild Child(TextFileLoader, Index);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern int CALLBACK EnumFontFamExProc(CONST LOGFONT* plogFont, CONST TEXTMETRIC* textMetric, DWORD dwWord, LPARAM lParam);
|
||||
extern int GetCharsetFromCodePage(WORD codePage);
|
||||
extern const char* GetFontFaceFromCodePageNT(WORD codePage);
|
||||
extern const char* GetFontFaceFromCodePage9x(WORD codePage);
|
||||
extern DWORD GetDefaultCodePage();
|
||||
extern const char * GetDefaultFontFace();
|
||||
extern const char* GetFontFaceFromCodePage(WORD codePage);
|
||||
extern void SetDefaultFontFace(const char* fontFace);
|
||||
extern bool SetDefaultCodePage(DWORD codePage);
|
||||
extern void base64_decode(const char * str,char * resultStr);
|
||||
|
||||
extern DWORD GetMaxTextureWidth();
|
||||
extern DWORD GetMaxTextureHeight();
|
||||
@@ -0,0 +1,94 @@
|
||||
#ifndef __INC_SCRIPT_PARSER_H__
|
||||
#define __INC_SCRIPT_PARSER_H__
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
namespace script
|
||||
{
|
||||
typedef struct SArgumet
|
||||
{
|
||||
SArgumet(const std::string& c_stName, const std::string& c_stValue)
|
||||
{
|
||||
strName = c_stName;
|
||||
strValue = c_stValue;
|
||||
}
|
||||
SArgumet(const SArgumet& c_arg)
|
||||
{
|
||||
strName = c_arg.strName;
|
||||
strValue = c_arg.strValue;
|
||||
}
|
||||
void operator=(const SArgumet& c_arg)
|
||||
{
|
||||
strName = c_arg.strName;
|
||||
strValue = c_arg.strValue;
|
||||
}
|
||||
std::string strName;
|
||||
std::string strValue;
|
||||
} TArg;
|
||||
|
||||
typedef std::list<TArg> TArgList;
|
||||
|
||||
typedef struct SCmd
|
||||
{
|
||||
std::string name;
|
||||
TArgList argList;
|
||||
|
||||
SCmd()
|
||||
{}
|
||||
SCmd(const SCmd& c_cmd)
|
||||
{
|
||||
name = c_cmd.name;
|
||||
argList = c_cmd.argList;
|
||||
}
|
||||
void operator=(const SCmd& c_cmd)
|
||||
{
|
||||
name = c_cmd.name;
|
||||
argList = c_cmd.argList;
|
||||
}
|
||||
} TCmd;
|
||||
|
||||
class Group
|
||||
{
|
||||
public:
|
||||
Group();
|
||||
~Group();
|
||||
|
||||
public:
|
||||
/** 스트링으로 부터 스크립트 그룹을 만든다.
|
||||
*
|
||||
* 실패하면 GetError 메소드로 확인할 수 있다.
|
||||
*
|
||||
* @param stSource 이 스트링으로 부터 그룹이 만들어 진다.
|
||||
* @return 성공시 true, 실패하면 false
|
||||
*/
|
||||
bool Create(const std::string & stSource);
|
||||
|
||||
/** 명령어를 받는 메소드
|
||||
*
|
||||
* @param cmd 성공시에 이 구조체로 명령어가 복사 된다.
|
||||
* @return 명령어가 남아 있다면 true, 없다면 false
|
||||
*/
|
||||
bool GetCmd(TCmd & cmd);
|
||||
|
||||
/*
|
||||
명령어를 가져오되 꺼내지는 않는다.
|
||||
*/
|
||||
bool ReadCmd(TCmd & cmd);
|
||||
|
||||
/** 에러를 출력 받는 메소드
|
||||
*
|
||||
* @return stError 이 곳으로 에러가 출력 된다.
|
||||
*/
|
||||
std::string & GetError();
|
||||
|
||||
private:
|
||||
void SetError(const char *str);
|
||||
bool GetArg(const char * c_atr_base, int arg_len, TArgList & argList);
|
||||
|
||||
std::string m_stError;
|
||||
std::list<TCmd> m_cmdList;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user