Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2474
GameTools/CGemRender.cpp
Normal file
2474
GameTools/CGemRender.cpp
Normal file
File diff suppressed because it is too large
Load Diff
434
GameTools/CGemRender.h
Normal file
434
GameTools/CGemRender.h
Normal file
@@ -0,0 +1,434 @@
|
||||
#ifndef __CGEMRENDER_H__
|
||||
#define __CGEMRENDER_H__
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
|
||||
#define BUF_SIZE 256
|
||||
#define VOT 1.0f
|
||||
#define GEM_HEADER "GemDataFile\n"
|
||||
|
||||
|
||||
class CGemRender {
|
||||
public:
|
||||
void SetClearBuffer(bool b);
|
||||
bool m_bClearBuffer;
|
||||
class GemTexture {
|
||||
public:
|
||||
CTexture *m_Tex;
|
||||
int TexNum;
|
||||
GemTexture() {
|
||||
m_Tex = NULL;
|
||||
TexNum = 0;
|
||||
}
|
||||
~GemTexture() {
|
||||
if(m_Tex) {
|
||||
/* if(TexNum >1)
|
||||
delete[] m_Tex;
|
||||
else*/
|
||||
delete[] m_Tex;
|
||||
}
|
||||
}
|
||||
};
|
||||
class GemSubFace{
|
||||
public:
|
||||
int *sub;
|
||||
int *sub_mat;
|
||||
int sub_num;
|
||||
GemSubFace() {
|
||||
sub = NULL;
|
||||
sub_mat = NULL;
|
||||
sub_num = 0;
|
||||
}
|
||||
~GemSubFace() {
|
||||
delete[] sub;
|
||||
delete[] sub_mat;
|
||||
}
|
||||
};
|
||||
class GemVertex{
|
||||
public:
|
||||
float x,y,z;
|
||||
float nx,ny,nz;
|
||||
float s,t;
|
||||
GemVertex() {
|
||||
x = y = z = 0.0f;
|
||||
nx = ny = nz = 0.0f;
|
||||
s = t = 0.0f;
|
||||
}
|
||||
~GemVertex() {}
|
||||
};
|
||||
class GemRotKey {
|
||||
public:
|
||||
int frame;
|
||||
D3DXVECTOR4 rot;
|
||||
|
||||
GemRotKey() {
|
||||
frame = 0;
|
||||
rot.x = rot.y = rot.z = rot.w = 0.0f;
|
||||
}
|
||||
|
||||
~GemRotKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemPosKey{
|
||||
public:
|
||||
int frame;
|
||||
bool bez;
|
||||
D3DXVECTOR3 pos;
|
||||
D3DXVECTOR3 intan;
|
||||
D3DXVECTOR3 outtan;
|
||||
GemPosKey() {
|
||||
frame = 0;
|
||||
bez = false;
|
||||
pos.x = pos.y = pos.z = 0.0f;
|
||||
intan.x = intan.y = intan.z = 0.0f;
|
||||
outtan.x = outtan.y = outtan.z = 0.0f;
|
||||
}
|
||||
~GemPosKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemScaleKey{
|
||||
public:
|
||||
int frame;
|
||||
D3DXVECTOR3 scale;
|
||||
GemScaleKey() {
|
||||
frame = 0;
|
||||
scale.x = scale.y = scale.z= 1.0f;
|
||||
}
|
||||
~GemScaleKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemVisKey{
|
||||
public:
|
||||
int frame;
|
||||
float vis;
|
||||
GemVisKey(){
|
||||
frame = 0;
|
||||
vis = 1.0f;
|
||||
}
|
||||
~GemVisKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemObject {
|
||||
public:
|
||||
char m_Name[BUF_SIZE];
|
||||
char m_ParentName[BUF_SIZE];
|
||||
bool m_bParent;
|
||||
|
||||
D3DXMATRIX m_TmMatrix;
|
||||
|
||||
// vertex info
|
||||
D3DXVECTOR2 *m_Coord;
|
||||
D3DXVECTOR3 *m_CoordFace;
|
||||
|
||||
D3DXVECTOR3 *m_Vert;
|
||||
D3DXVECTOR4 *m_Face;
|
||||
D3DXVECTOR3 *m_Fnormal;
|
||||
D3DXVECTOR3 *m_Normal;
|
||||
int m_MatId;
|
||||
|
||||
int m_Frame;
|
||||
int m_CoordNum;
|
||||
int m_VertexNum;
|
||||
int m_FaceNum;
|
||||
// anikey info
|
||||
int m_RotKeyNum;
|
||||
int m_PosKeyNum;
|
||||
int m_ScaleKeyNum;
|
||||
int m_VisKeyNum;
|
||||
//morphing
|
||||
int m_MorphNum;
|
||||
// 추가기능
|
||||
bool m_Bil1;
|
||||
bool m_Bil2;
|
||||
bool m_Bil3;
|
||||
// multy uv ani
|
||||
bool m_Multy;
|
||||
bool m_TexAni;
|
||||
bool m_RandAni;
|
||||
bool m_RandStartTexAni; //시작 프레임이 다른 텍스쳐 애니 flag
|
||||
bool m_RandStartSetting; //start 되었는지
|
||||
bool m_Zenable;
|
||||
bool m_Opacity;
|
||||
//사용되는 texture 갯수
|
||||
int m_AniTextureNum;
|
||||
int m_CurrentAniTexture;
|
||||
int m_BeforeAniTexture;
|
||||
|
||||
int m_Red;
|
||||
int m_Green;
|
||||
int m_Blue;
|
||||
// 보간법 선택
|
||||
bool m_bH;
|
||||
// cullmode on flag
|
||||
bool m_bCull;
|
||||
|
||||
float m_AniChangeFrame;
|
||||
//tex ani start frame
|
||||
float m_StartTexAniFrame;
|
||||
|
||||
bool m_Zbuffer;
|
||||
bool m_bDecal;
|
||||
|
||||
GemObject *m_Morph;
|
||||
|
||||
|
||||
|
||||
GemVisKey *m_Vis;
|
||||
GemScaleKey *m_Scale;
|
||||
GemPosKey *m_Pos;
|
||||
GemRotKey *m_Rot;
|
||||
DWORD m_Color;
|
||||
// vertex buffer 생성시에 필요한 vert pointer
|
||||
GemVertex *m_VertexBuffer;
|
||||
bool m_bInterpol;
|
||||
|
||||
GemObject() {
|
||||
|
||||
m_Multy = false;
|
||||
m_RotKeyNum = m_PosKeyNum = m_ScaleKeyNum = m_VisKeyNum = 0;
|
||||
m_Vis = NULL;
|
||||
m_Scale = NULL;
|
||||
m_Pos = NULL;
|
||||
m_Rot = NULL;
|
||||
m_Red = m_Green = m_Blue = 255;
|
||||
m_bH = false;
|
||||
//morphing vertex
|
||||
m_Morph = NULL;
|
||||
m_MorphNum = 0;
|
||||
m_StartTexAniFrame = 0.0f;
|
||||
m_Zbuffer = false;
|
||||
m_Zenable = false;
|
||||
|
||||
m_bCull = false;
|
||||
m_Color = D3DCOLOR_ARGB(255,255,255,255);
|
||||
|
||||
m_MatId = -1;
|
||||
|
||||
m_Frame = -1;
|
||||
m_VertexNum = 0;
|
||||
m_FaceNum = 0;
|
||||
m_CoordNum =0;
|
||||
|
||||
m_Coord = NULL;
|
||||
m_CoordFace = NULL;
|
||||
|
||||
m_Vert = NULL;
|
||||
m_Face = NULL;
|
||||
m_Fnormal = NULL;
|
||||
m_Normal = NULL;
|
||||
m_bParent = false;
|
||||
m_Bil1 = m_Bil2 = m_Bil3 = false;
|
||||
m_TexAni = false;
|
||||
m_RandAni = false;
|
||||
m_RandStartTexAni = false;
|
||||
m_RandStartSetting = false;
|
||||
m_Opacity = false;
|
||||
m_AniChangeFrame = 0.0f;
|
||||
m_AniTextureNum = 0;
|
||||
m_CurrentAniTexture = 0;
|
||||
m_BeforeAniTexture = 0;
|
||||
D3DXMatrixIdentity(&m_TmMatrix);
|
||||
memset(m_Name,0,sizeof(char)*BUF_SIZE);
|
||||
memset(m_ParentName,0,sizeof(char)*BUF_SIZE);
|
||||
m_VertexBuffer = NULL;
|
||||
m_bInterpol = true;
|
||||
m_bDecal = false;
|
||||
|
||||
}
|
||||
~GemObject() {
|
||||
if(m_Scale != NULL)
|
||||
delete[] m_Scale;
|
||||
if(m_Vis != NULL)
|
||||
delete[] m_Vis;
|
||||
if(m_Vert != NULL)
|
||||
delete[] m_Vert;
|
||||
if(m_Face != NULL)
|
||||
delete[] m_Face;
|
||||
if(m_Coord != NULL)
|
||||
delete[] m_Coord;
|
||||
if(m_CoordFace != NULL)
|
||||
delete[] m_CoordFace;
|
||||
if(m_Fnormal != NULL)
|
||||
delete[] m_Fnormal;
|
||||
if(m_Normal != NULL)
|
||||
delete[] m_Normal;
|
||||
if(m_Rot)
|
||||
delete[] m_Rot;
|
||||
if(m_Pos)
|
||||
delete[] m_Pos;
|
||||
if(m_Morph)
|
||||
delete[] m_Morph;
|
||||
if(m_VertexBuffer)
|
||||
delete[] m_VertexBuffer;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class GemMaterial {
|
||||
public:
|
||||
char m_TextureName[BUF_SIZE];
|
||||
int m_SubNum;
|
||||
GemMaterial *m_Sub;
|
||||
GemMaterial() {
|
||||
memset(m_TextureName,0,BUF_SIZE);
|
||||
m_Sub = NULL;
|
||||
m_SubNum = 0;
|
||||
}
|
||||
~GemMaterial() {
|
||||
if(m_SubNum)
|
||||
delete[] m_Sub;
|
||||
}
|
||||
};
|
||||
CGemRender();
|
||||
~CGemRender();
|
||||
|
||||
void SetTransMatrix(D3DXMATRIX m) {m_TrMatrix = m;}
|
||||
bool CheckPosition(D3DXVECTOR3 center,D3DXVECTOR3 user);
|
||||
void SetXrot(float rot) { m_Xrot = rot;}
|
||||
void SetYrot(float rot) { m_Yrot = rot;}
|
||||
void SetZrot(float rot) { m_Zrot = rot;}
|
||||
|
||||
|
||||
void ScaleAni(int object_index,D3DXMATRIX &);
|
||||
void PosAni(int object_index,D3DXMATRIX &);
|
||||
void RotAni(int object_index,D3DXMATRIX &);
|
||||
|
||||
bool LoadGemFile(char *,LPDIRECT3DDEVICE8 ,bool bVisibility = true);
|
||||
bool LoadUvFile(char *);
|
||||
|
||||
bool LoadMorph(int );
|
||||
void MsgPrint(char *);
|
||||
void SetInitBuffer();
|
||||
|
||||
void SetVertexBuffer(int index);
|
||||
void SetDecalBuffer(int index); // Vertex Buffer 에 세팅
|
||||
void SetDecalBufferInit(int index); // Decal Buffer Init
|
||||
|
||||
void SetStartFrame(float s);
|
||||
|
||||
void SetCash(bool b) { m_bCash = b;}
|
||||
|
||||
void Render();
|
||||
void RenderObject(int object_index);
|
||||
|
||||
void Update();
|
||||
void Update(D3DXVECTOR3 center,D3DXVECTOR3 user);
|
||||
|
||||
void UnUpdate();
|
||||
bool VertexInterpolation(int index);
|
||||
void LoadSubFace(int object_index);
|
||||
void LoadTexture();
|
||||
// set zbuffer cullface all object
|
||||
void SetCullZbuffer(bool );
|
||||
// my effect setting
|
||||
void SetMine(bool t);
|
||||
|
||||
void LoadTexAni(int object_index);
|
||||
bool VisAni(int object_index);
|
||||
void CreateAniTm(int index,D3DXMATRIX &,D3DXMATRIX &);
|
||||
void SetChangeAniFrame(int object_index,float f);
|
||||
void SetStartTexAniFrame(int object_index,float f);
|
||||
int GetMaxFrame() {return (m_EndF / m_UnitF);}
|
||||
// effect scale setting func
|
||||
void SetScale(float x,float y,float z);
|
||||
void SetEffectPos(float x,float y,float z);
|
||||
void SetEffectPos(D3DXVECTOR3 pos);
|
||||
void SetCurrentFrame(float f);
|
||||
void SetCurrentFrame(float f,int *,DWORD *,bool *,bool update = false);
|
||||
|
||||
void SetSrcBlend(DWORD s) {m_SrcBlend = s;}
|
||||
void SetDstBlend(DWORD d) {m_DstBlend = d;}
|
||||
void SetBlend(DWORD s,DWORD d) { m_SrcBlend = s; m_DstBlend = d;}
|
||||
void SetColor(int object_index,int r,int g,int b);
|
||||
void SetNullTexture(bool b) {m_bNullTexture = b;}
|
||||
void SetPickObject(int index);
|
||||
void SetVot(float v) {m_Vot = v;}
|
||||
void SetLoop(bool b) {m_bLoop = b;}
|
||||
int GetObjectNum() {return m_ObjectNum;}
|
||||
void SetStartTexAni(bool b) {m_bTexAni = b;}
|
||||
void SetAxis(D3DXMATRIX & );
|
||||
void GetAxis(float ,float ,float ,float );
|
||||
void GetAxis(D3DXQUATERNION tmp) {m_AxisSet = true; m_Axis = tmp;}
|
||||
// ANI MESH USE
|
||||
void SetRandAni(bool b) {m_RandAni = b;}
|
||||
void SetRandAniMax(float s) {m_RandAniMax = s;}
|
||||
void SetRandAniMin(float s) {m_RandAniMin = s;}
|
||||
void SetSwitchAni(bool b) {m_SwitchAni = b;}
|
||||
void SetAniRad(float r) {m_AniRad = r;}
|
||||
// light 적용 mesh
|
||||
void SetLight(bool b) {m_bLight = b;}
|
||||
char *GetFileName() {return m_FileName;}
|
||||
|
||||
FILE *m_GemFile;
|
||||
//multy uv
|
||||
int m_bMulty;
|
||||
|
||||
int m_StartF;
|
||||
int m_EndF;
|
||||
int m_UnitF;
|
||||
int m_ObjectNum;
|
||||
int m_PickObject;
|
||||
|
||||
int m_MatNum;
|
||||
bool m_bNullTexture;
|
||||
bool m_bLoop;
|
||||
bool m_bCash;
|
||||
|
||||
bool m_bTexAni;
|
||||
bool m_Mine;
|
||||
bool m_bDecal;
|
||||
|
||||
DWORD m_SrcBlend,m_DstBlend;
|
||||
|
||||
float m_CurrentF;
|
||||
LPDIRECT3DDEVICE8 m_Device;
|
||||
D3DXMATRIX m_Scale;
|
||||
D3DXMATRIX m_TrMatrix;
|
||||
D3DXVECTOR3 m_Pos;
|
||||
D3DXQUATERNION global;
|
||||
D3DXQUATERNION m_Axis;
|
||||
bool m_AxisSet;
|
||||
//ANI MESH
|
||||
float m_Xrot,m_Yrot,m_Zrot;
|
||||
bool m_RandAni;
|
||||
float m_RandAniMax;
|
||||
float m_RandAniMin;
|
||||
float m_AniRad;
|
||||
bool m_SwitchAni;
|
||||
bool m_StartSwitch;
|
||||
GemMaterial *m_Mtl;
|
||||
|
||||
|
||||
GemObject *m_Object;
|
||||
GemSubFace *m_Sub;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_ObjectVertex;
|
||||
GemTexture *m_Texture;
|
||||
GemTexture *m_TexAni;
|
||||
|
||||
int m_TexNum;
|
||||
float m_Vot;
|
||||
|
||||
//// vertex buffer 생성시에 필요한 vert pointer
|
||||
//GemVertex *m_Vert;
|
||||
int VbufferNum;
|
||||
// multy uv ani
|
||||
CGemRender *m_Multy;
|
||||
bool m_bLight;
|
||||
char m_FileName[256];
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
955
GameTools/CHARACTERACTIONCONTROL/CCameraScript.cpp
Normal file
955
GameTools/CHARACTERACTIONCONTROL/CCameraScript.cpp
Normal file
@@ -0,0 +1,955 @@
|
||||
#include "CCameraScript.h"
|
||||
#include "SceneManager.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
|
||||
extern D3DXVECTOR3 g_vecCube[8];
|
||||
extern WORD g_vecCubeIndex[36];
|
||||
|
||||
|
||||
CCameraScript::CCameraScript() {
|
||||
|
||||
m_pDevice = CSceneManager::GetDevice();
|
||||
m_pDevice->GetTransform(D3DTS_VIEW, &m_matBeforeView);
|
||||
InitCameraScript();
|
||||
m_iFixCount = 0;
|
||||
m_bBackWord = false;
|
||||
m_bInitPos = false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
CCameraScript::~CCameraScript() {
|
||||
|
||||
m_lstEvent.clear();
|
||||
m_lstPosSpline.clear();
|
||||
m_lstLookSpline.clear();
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_VIEW, &m_matBeforeView);
|
||||
|
||||
}
|
||||
void CCameraScript::ReWindFix() {
|
||||
if(m_iFixCount > 0)
|
||||
m_iFixCount--;
|
||||
else
|
||||
m_iFixCount = (m_iEventNum - 1);
|
||||
}
|
||||
|
||||
void CCameraScript::Rewind() {
|
||||
if(m_iBeforeEvent > 0)
|
||||
m_iBeforeEvent--;
|
||||
else
|
||||
m_iBeforeEvent = (m_iEventNum - 1);
|
||||
m_fRunFrame = m_lstEvent[m_iBeforeEvent].m_fFrame;
|
||||
|
||||
}
|
||||
|
||||
void CCameraScript::FoWindFix() {
|
||||
if(m_iFixCount < (m_iEventNum - 1))
|
||||
m_iFixCount++;
|
||||
else
|
||||
m_iFixCount = 0;
|
||||
|
||||
}
|
||||
|
||||
void CCameraScript::Fowind() {
|
||||
if(m_iBeforeEvent < (m_iEventNum-1))
|
||||
m_iBeforeEvent++;
|
||||
else
|
||||
m_iBeforeEvent = 0;
|
||||
m_fRunFrame = m_lstEvent[m_iBeforeEvent].m_fFrame;
|
||||
}
|
||||
void CCameraScript::Jump(int iEvent) {
|
||||
|
||||
if((iEvent >= 0) && (iEvent < m_iEventNum)) {
|
||||
m_iBeforeEvent = iEvent;
|
||||
m_fRunFrame = m_lstEvent[m_iBeforeEvent].m_fFrame;
|
||||
}
|
||||
}
|
||||
void CCameraScript::InitFrame() {
|
||||
// m_bStart = false;
|
||||
m_dwBeforeTick = 0;
|
||||
m_fRunFrame = 0.0f;
|
||||
m_iBeforeEvent = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CCameraScript::PlayScript(int iRoll,int iLoop,bool bFixPos) {
|
||||
|
||||
int i;
|
||||
if(m_bStart == false)
|
||||
return;
|
||||
|
||||
if(m_lstEvent.empty())
|
||||
return;
|
||||
|
||||
m_dwCurrentTick = timeGetTime();
|
||||
float fSkipFrame = 0.0f;
|
||||
|
||||
if(m_dwBeforeTick == 0) { // 첫 시작 프레임
|
||||
fSkipFrame = 0;
|
||||
m_matBeforePos = *(CSceneManager::m_ViewCamera->GetMatPosition());
|
||||
m_matBeforeView2 = CSceneManager::m_ViewCamera->m_matView;
|
||||
}
|
||||
else {
|
||||
fSkipFrame = ((int)m_dwCurrentTick - (int)m_dwBeforeTick) / (float)CAMERAFRAMESTEP;
|
||||
}
|
||||
|
||||
//m_fRunFrame += fSkipFrame;
|
||||
m_fRunFrame += 0.6f;
|
||||
|
||||
if(iRoll == 0) { // Play
|
||||
|
||||
if(m_fRunFrame < m_lstEvent[m_iBeforeEvent].m_fFrame )
|
||||
{
|
||||
m_fRunFrame = m_lstEvent[m_iBeforeEvent].m_fFrame;
|
||||
}
|
||||
|
||||
i = m_iBeforeEvent + 1;
|
||||
|
||||
for( i; i < m_iEventNum; i++ ) {
|
||||
if(m_fRunFrame >= m_lstEvent[i].m_fFrame) {
|
||||
m_iBeforeEvent = i;
|
||||
}
|
||||
}
|
||||
|
||||
if((m_iEventNum - 1) == m_iBeforeEvent) { // Looping 처리
|
||||
if(iLoop == 1) {
|
||||
m_iBeforeEvent = 0;
|
||||
m_dwBeforeTick = 0;
|
||||
m_fRunFrame = 0.0f;
|
||||
|
||||
}
|
||||
else { // Looping X
|
||||
m_iBeforeEvent = m_iEventNum - 1;
|
||||
m_fRunFrame = m_lstEvent[m_iBeforeEvent].m_fFrame;
|
||||
m_bStart = false;
|
||||
InitFrame();
|
||||
if(bFixPos)
|
||||
{
|
||||
CSceneManager::m_ViewCamera->SetMatView(m_matBeforeView2);
|
||||
CSceneManager::m_ViewCamera->SetMatPosition(m_matBeforePos);
|
||||
CSceneManager::m_ViewCamera->MoveFrustum();
|
||||
CSceneManager::m_ViewCamera->SetVecPosition(vector3(m_matBeforePos._41,m_matBeforePos._42,m_matBeforePos._43));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
float fInterpol;
|
||||
if(m_iBeforeEvent == (m_iEventNum - 1))
|
||||
fInterpol = 1.0f;
|
||||
else {
|
||||
fInterpol = (float)(m_fRunFrame - m_lstEvent[m_iBeforeEvent].m_fFrame) / (m_lstEvent[m_iBeforeEvent + 1].m_fFrame - m_lstEvent[m_iBeforeEvent].m_fFrame);
|
||||
}
|
||||
m_CurrentEvent.m_fFrame = m_fRunFrame;
|
||||
|
||||
|
||||
// Interpolation에 따른 보간
|
||||
D3DXVECTOR3 vecInterpol;
|
||||
|
||||
D3DXVECTOR3 vecInterPos;
|
||||
D3DXVECTOR3 vecInterLook;
|
||||
D3DXVECTOR3 vecInterUp;
|
||||
|
||||
switch(m_lstEvent[m_iBeforeEvent].m_iInterpolation) {
|
||||
case C_LINE:
|
||||
|
||||
if(fInterpol < 0.000001f) {
|
||||
vecInterPos = m_lstEvent[m_iBeforeEvent].m_vecCameraPos;
|
||||
vecInterLook = m_lstEvent[m_iBeforeEvent].m_vecCameraLook;
|
||||
vecInterUp = m_lstEvent[m_iBeforeEvent].m_vecCameraUp;
|
||||
}
|
||||
else {
|
||||
|
||||
int PosStart = m_lstEvent[m_iBeforeEvent].m_iPosStart;
|
||||
int iInterpolNum = m_lstEvent[m_iBeforeEvent].m_iPosEnd - m_lstEvent[m_iBeforeEvent].m_iPosStart;
|
||||
iInterpolNum *= fInterpol;
|
||||
vecInterPos = m_lstPosSpline[ PosStart + iInterpolNum];
|
||||
|
||||
PosStart = m_lstEvent[m_iBeforeEvent].m_iLookStart;
|
||||
iInterpolNum = m_lstEvent[m_iBeforeEvent].m_iLookEnd - m_lstEvent[m_iBeforeEvent].m_iLookStart;
|
||||
iInterpolNum *= fInterpol;
|
||||
vecInterLook = m_lstLookSpline[ PosStart + iInterpolNum];
|
||||
|
||||
/* vecInterpol = m_lstEvent[m_iBeforeEvent + 1].m_vecCameraPos - m_lstEvent[m_iBeforeEvent].m_vecCameraPos;
|
||||
vecInterPos = m_lstEvent[m_iBeforeEvent].m_vecCameraPos + (vecInterpol * fInterpol);
|
||||
|
||||
vecInterpol = m_lstEvent[m_iBeforeEvent + 1].m_vecCameraLook - m_lstEvent[m_iBeforeEvent].m_vecCameraLook;
|
||||
vecInterLook = m_lstEvent[m_iBeforeEvent].m_vecCameraLook + (vecInterpol * fInterpol);
|
||||
*/
|
||||
vecInterpol = m_lstEvent[m_iBeforeEvent + 1].m_vecCameraUp - m_lstEvent[m_iBeforeEvent].m_vecCameraUp;
|
||||
vecInterUp = m_lstEvent[m_iBeforeEvent].m_vecCameraUp + (vecInterpol * fInterpol);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case C_BEZIER1: // 제어점 3
|
||||
if(fInterpol < 0.000001f) {
|
||||
vecInterPos = m_lstEvent[m_iBeforeEvent].m_vecCameraPos;
|
||||
vecInterLook = m_lstEvent[m_iBeforeEvent].m_vecCameraLook;
|
||||
vecInterUp = m_lstEvent[m_iBeforeEvent].m_vecCameraUp;
|
||||
}
|
||||
else {
|
||||
|
||||
int PosStart = m_lstEvent[m_iBeforeEvent].m_iPosStart;
|
||||
int iInterpolNum = m_lstEvent[m_iBeforeEvent].m_iPosEnd - m_lstEvent[m_iBeforeEvent].m_iPosStart;
|
||||
iInterpolNum *= fInterpol;
|
||||
vecInterPos = m_lstPosSpline[ PosStart + iInterpolNum];
|
||||
|
||||
PosStart = m_lstEvent[m_iBeforeEvent].m_iLookStart;
|
||||
iInterpolNum = m_lstEvent[m_iBeforeEvent].m_iLookEnd - m_lstEvent[m_iBeforeEvent].m_iLookStart;
|
||||
iInterpolNum *= fInterpol;
|
||||
vecInterLook = m_lstLookSpline[ PosStart + iInterpolNum];
|
||||
|
||||
|
||||
float fInterpol2 = fInterpol * fInterpol;
|
||||
/* vecInterPos = m_lstEvent[m_iBeforeEvent].m_vecCameraPos * ((1.0f - fInterpol) * (1.0f - fInterpol))
|
||||
+ (m_lstEvent[m_iBeforeEvent].m_vecControlPoint[0] * 2 * (1.0f - fInterpol) * fInterpol ) + (m_lstEvent[m_iBeforeEvent + 1].m_vecCameraPos * fInterpol2);
|
||||
vecInterLook = m_lstEvent[m_iBeforeEvent].m_vecCameraLook * ((1.0f - fInterpol) * (1.0f - fInterpol))
|
||||
+ (m_lstEvent[m_iBeforeEvent].m_vecControlPoint[0] * 2 * (1.0f - fInterpol) * fInterpol ) + (m_lstEvent[m_iBeforeEvent + 1].m_vecCameraLook * fInterpol2);*/
|
||||
vecInterUp = m_lstEvent[m_iBeforeEvent].m_vecCameraUp * ((1.0f - fInterpol) * (1.0f - fInterpol))
|
||||
+ (m_lstEvent[m_iBeforeEvent].m_vecControlPoint[0] * 2 * (1.0f - fInterpol) * fInterpol ) + (m_lstEvent[m_iBeforeEvent + 1].m_vecCameraUp * fInterpol2);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
/*case C_BEZIER2: // 제어점 4
|
||||
if(fInterpol < 0.000001f) {
|
||||
vecInterPos = m_lstEvent[m_iBeforeEvent].m_vecCameraPos;
|
||||
vecInterLook = m_lstEvent[m_iBeforeEvent].m_vecCameraLook;
|
||||
vecInterUp = m_lstEvent[m_iBeforeEvent].m_vecCameraUp;
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
}
|
||||
break;*/
|
||||
default:
|
||||
break;
|
||||
|
||||
};
|
||||
|
||||
m_CurrentEvent.m_vecCameraPos = vecInterPos;
|
||||
m_CurrentEvent.m_vecCameraLook = vecInterLook;
|
||||
m_CurrentEvent.m_vecCameraUp = D3DXVECTOR3(0.0f,1.0f,0.0f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
D3DXMatrixLookAtLH(&m_matCurrentFrame,
|
||||
&(m_CurrentEvent.m_vecCameraPos),&(m_CurrentEvent.m_vecCameraLook),&(m_CurrentEvent.m_vecCameraUp));
|
||||
|
||||
m_dwBeforeTick = m_dwCurrentTick = timeGetTime();
|
||||
|
||||
}
|
||||
|
||||
bool CCameraScript::SaveScript(char *strFileName) {
|
||||
|
||||
if((strFileName != NULL) && strlen(strFileName) > 1) {
|
||||
FILE *fp = fopen(strFileName,"wb");
|
||||
if(fp != NULL) {
|
||||
float fVersion = CAMERASCRIPTVERSION;
|
||||
fwrite((float *)&fVersion,sizeof(float),1,fp);
|
||||
fwrite((int *)&m_iEventNum,sizeof(int),1,fp);
|
||||
fwrite((CCameraEvent *)&(m_lstEvent[0]),sizeof(CCameraEvent),m_iEventNum,fp);
|
||||
fclose(fp);
|
||||
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool CCameraScript::LoadScript(char *strFileName) {
|
||||
|
||||
if((strFileName != NULL) && strlen(strFileName) > 1) {
|
||||
float fVersion = 0.0f;
|
||||
|
||||
char strPath[256] = {0};
|
||||
|
||||
strcpy(strPath,EFFECTSCRIPTPATH);
|
||||
strcat(strPath,strFileName);
|
||||
|
||||
|
||||
FILE *fp = fopen(strPath,"rb");
|
||||
if(fp != NULL) {
|
||||
fread((float *)&fVersion,sizeof(float),1,fp);
|
||||
if((fVersion >= 0.9f) && (fVersion <= 1.1f)) {
|
||||
int i;
|
||||
|
||||
fread((int *)&m_iEventNum,sizeof(int),1,fp);
|
||||
|
||||
for( i = 0; i < m_iEventNum; i++ ) {
|
||||
CCameraEvent EmptyNode;
|
||||
m_lstEvent.push_back(EmptyNode);
|
||||
}
|
||||
|
||||
fread((CCameraEvent *)&(m_lstEvent[0]),sizeof(CCameraEvent),m_iEventNum,fp);
|
||||
}
|
||||
fclose(fp);
|
||||
m_iInsertLook = 1;
|
||||
CreateSpline();
|
||||
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void CCameraScript::InitCameraScript(bool bInitPos,D3DXVECTOR3 vecInitPos,D3DXVECTOR3 vecInitLook) {
|
||||
m_lstEvent.clear();
|
||||
m_iEventNum = 0;
|
||||
m_iBeforeEvent = 0;
|
||||
m_fRunFrame = 0.0f;
|
||||
|
||||
m_dwBeforeTick = 0;
|
||||
m_bStart = false;
|
||||
|
||||
m_lstPosSpline.clear();
|
||||
m_bCreateSpline = false;
|
||||
|
||||
m_lstLookSpline.clear();
|
||||
m_bCreateLookSpline = false;
|
||||
m_iInsertLook = 0;
|
||||
m_iFixCount = 0;
|
||||
|
||||
m_bInitPos = bInitPos;
|
||||
m_vecCameraInitPos = vecInitPos;
|
||||
m_vecCameraInitLook = vecInitLook;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
int CCameraScript::GetFixCount(int &iIndex,float &fFrame) {
|
||||
if(m_lstEvent.size() > m_iFixCount)
|
||||
{
|
||||
iIndex = m_lstEvent[m_iFixCount].m_iIndex;
|
||||
fFrame = m_lstEvent[m_iFixCount].m_fFrame;
|
||||
}
|
||||
else
|
||||
{
|
||||
iIndex = 0;
|
||||
fFrame = 0;
|
||||
}
|
||||
|
||||
return m_iFixCount;
|
||||
|
||||
}
|
||||
void CCameraScript::FixLook(int iEvent,D3DXVECTOR3 vecLook) {
|
||||
m_lstEvent[iEvent].m_vecCameraLook = vecLook;
|
||||
|
||||
}
|
||||
void CCameraScript::InsertLookPos(D3DXVECTOR3 vecLook) {
|
||||
|
||||
if(m_iInsertLook >= m_lstEvent.size()) {
|
||||
MessageBox(NULL,"Look Pos 초과 ","error",MB_OK);
|
||||
|
||||
return;
|
||||
}
|
||||
m_lstEvent[m_iInsertLook].m_vecCameraLook = vecLook;
|
||||
m_iInsertLook++;
|
||||
|
||||
char tmp[256]= {0};
|
||||
|
||||
int iNum = m_iInsertLook - m_lstEvent.size();
|
||||
sprintf(tmp,"%d 개의 Target Point 를 더 찍을수 있습니다.",iNum);
|
||||
MessageBox(NULL,tmp,"msg",MB_OK);
|
||||
|
||||
}
|
||||
int CCameraScript::InsertEvent( D3DXVECTOR3 vecPos,D3DXVECTOR3 vecLook,D3DXVECTOR3 vecUp,float fFrame,int iInterpol ) {
|
||||
|
||||
CCameraEvent Node;
|
||||
|
||||
Node.m_iIndex = m_iEventNum;
|
||||
Node.m_iInterpolation = iInterpol;
|
||||
Node.m_vecCameraPos = vecPos;
|
||||
Node.m_vecCameraLook = vecLook;
|
||||
Node.m_vecCameraUp = vecUp;
|
||||
Node.m_fFrame = fFrame;
|
||||
|
||||
m_lstEvent.push_back(Node);
|
||||
|
||||
return m_iEventNum++;
|
||||
}
|
||||
void CCameraScript::FixEvent(int iEvent,D3DXVECTOR3 vecPos,D3DXVECTOR3 vecLook,D3DXVECTOR3 vecUp)
|
||||
{
|
||||
if((iEvent< 0) || (iEvent >= m_iEventNum) )
|
||||
return;
|
||||
m_lstEvent[iEvent].m_vecCameraPos = vecPos;
|
||||
m_lstEvent[iEvent].m_vecCameraLook = vecLook;
|
||||
m_lstEvent[iEvent].m_vecCameraUp = vecUp;
|
||||
|
||||
}
|
||||
void CCameraScript::FixEvent( int iEvent,D3DXVECTOR3 vecPos,D3DXVECTOR3 vecLook,D3DXVECTOR3 vecUp,float fFrame,int iInterpol ) {
|
||||
if((iEvent< 0) || (iEvent >= m_iEventNum) )
|
||||
return;
|
||||
m_lstEvent[iEvent].m_vecCameraPos = vecPos;
|
||||
m_lstEvent[iEvent].m_vecCameraLook = vecLook;
|
||||
m_lstEvent[iEvent].m_vecCameraUp = vecUp;
|
||||
m_lstEvent[iEvent].m_fFrame = fFrame;
|
||||
m_lstEvent[iEvent].m_iInterpolation = iInterpol;
|
||||
}
|
||||
void CCameraScript::DeleteEvent(float fFrame,int iInterpol) {
|
||||
|
||||
if(m_iEventNum <= 0)
|
||||
return;
|
||||
int i;
|
||||
|
||||
for( i = 0 ; i < m_iEventNum; i++ )
|
||||
{
|
||||
if(((m_lstEvent[i].m_fFrame - fFrame) + (float)(m_lstEvent[i].m_iInterpolation - iInterpol)) <= 0.001f) {
|
||||
m_lstEvent.erase(&(m_lstEvent[i]));
|
||||
m_iEventNum--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void CCameraScript::DeleteEvent(int iIndex) {
|
||||
|
||||
if((iIndex <= 0) || (iIndex >= m_iEventNum))
|
||||
return;
|
||||
int i;
|
||||
|
||||
for( i = 0 ; i < m_iEventNum; i++ )
|
||||
{
|
||||
if(i == iIndex) {
|
||||
m_lstEvent.erase(&(m_lstEvent[i]));
|
||||
m_iEventNum--;
|
||||
|
||||
InitFrame();
|
||||
m_iFixCount = 0;
|
||||
if(m_iInsertLook >= m_iEventNum)
|
||||
m_iInsertLook = (m_iEventNum - 1);
|
||||
m_bCreateLookSpline = false;
|
||||
m_bCreateSpline = false;
|
||||
m_bStart = false;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
void CCameraScript::BackWordEvent() // Event를 되돌린다.
|
||||
{
|
||||
int iCurrent;
|
||||
int iBackCurrent;
|
||||
|
||||
m_bBackWord = !m_bBackWord;
|
||||
|
||||
D3DXVECTOR3 vecTmpSwap;
|
||||
|
||||
|
||||
for(int i = 0; i < floor((float)m_iEventNum / 2.0f); i++ )
|
||||
{
|
||||
iCurrent = i;
|
||||
iBackCurrent = (m_iEventNum - 1) - i;
|
||||
|
||||
if(iCurrent != iBackCurrent)
|
||||
{
|
||||
vecTmpSwap = m_lstEvent[iCurrent].m_vecCameraLook;
|
||||
m_lstEvent[iCurrent].m_vecCameraLook = m_lstEvent[iBackCurrent].m_vecCameraLook;
|
||||
m_lstEvent[iBackCurrent].m_vecCameraLook = vecTmpSwap;
|
||||
|
||||
|
||||
vecTmpSwap = m_lstEvent[iCurrent].m_vecCameraPos;
|
||||
m_lstEvent[iCurrent].m_vecCameraPos = m_lstEvent[iBackCurrent].m_vecCameraPos;
|
||||
m_lstEvent[iBackCurrent].m_vecCameraPos = vecTmpSwap;
|
||||
|
||||
vecTmpSwap = m_lstEvent[iCurrent].m_vecCameraUp;
|
||||
m_lstEvent[iCurrent].m_vecCameraUp = m_lstEvent[iBackCurrent].m_vecCameraUp;
|
||||
m_lstEvent[iBackCurrent].m_vecCameraUp = vecTmpSwap;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(m_bInitPos)
|
||||
{
|
||||
D3DXVECTOR3 vecUp = D3DXVECTOR3(0.0f,1.0f,0.0f);
|
||||
FixEvent(m_iEventNum -1,m_vecCameraInitPos,m_vecCameraInitLook,vecUp);
|
||||
FixEvent(m_iEventNum -2,m_vecCameraInitPos,m_vecCameraInitLook,vecUp);
|
||||
}
|
||||
|
||||
}
|
||||
void CCameraScript::SetPlay(bool bFlag,bool bBack,bool bStartPos) {
|
||||
m_bStart = bFlag;
|
||||
if(bBack && bFlag)
|
||||
{
|
||||
if(!m_bBackWord)
|
||||
{
|
||||
BackWordEvent();
|
||||
m_iInsertLook = 1;
|
||||
CreateSpline();
|
||||
}
|
||||
}
|
||||
else if(bFlag)
|
||||
{
|
||||
if(m_bBackWord)
|
||||
{
|
||||
BackWordEvent();
|
||||
m_iInsertLook = 1;
|
||||
CreateSpline();
|
||||
}
|
||||
}
|
||||
if(bStartPos && bFlag && !bBack) // Start pos 부터 보간 시작(0 프레임 이벤트 수정)
|
||||
{
|
||||
|
||||
matrix *matPos= CSceneManager::GetCamera()->GetMatPosition();
|
||||
vector3 vecCameraToward = CSceneManager::GetCamera()->GetViewTowardVector();
|
||||
//vector3 vecCameraUp = CSceneManager::GetCamera()->GetViewUpVector();
|
||||
|
||||
D3DXVECTOR3 vecCameraSPos = D3DXVECTOR3(matPos->_41,matPos->_42,matPos->_43);
|
||||
D3DXVECTOR3 vecCameraSLook = D3DXVECTOR3(vecCameraSPos.x + vecCameraToward.x * 50.0f,vecCameraSPos.y + vecCameraToward.y* 50.0f,vecCameraSPos.z + vecCameraToward.z* 50.0f);
|
||||
//D3DXVECTOR3 vecCameraSUp = D3DXVECTOR3(vecCameraUp.x,vecCameraUp.y,vecCameraUp.z);
|
||||
|
||||
D3DXVECTOR3 vecCameraSUp = D3DXVECTOR3(0.0f,1.0f,0.0f);
|
||||
FixEvent(0,vecCameraSPos,vecCameraSLook,vecCameraSUp);
|
||||
m_iInsertLook = 1;
|
||||
CreateSpline();
|
||||
|
||||
}
|
||||
|
||||
InitFrame();
|
||||
if(bFlag == false) {
|
||||
CSceneManager::m_ViewCamera->SetMatView(m_matBeforeView2);
|
||||
CSceneManager::m_ViewCamera->SetMatPosition(m_matBeforePos);
|
||||
CSceneManager::m_ViewCamera->MoveFrustum();
|
||||
CSceneManager::m_ViewCamera->SetVecPosition(vector3(m_matBeforePos._41,m_matBeforePos._42,m_matBeforePos._43));
|
||||
|
||||
}
|
||||
}
|
||||
void CCameraScript::RenderPos_Up() {
|
||||
|
||||
int i;
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_LIGHTING,FALSE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_pDevice->SetVertexShader(D3DFVF_XYZ);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
D3DXMATRIX identity;
|
||||
D3DXMATRIX worldTm;
|
||||
|
||||
m_pDevice->GetTransform(D3DTS_WORLD,&worldTm);
|
||||
for( i = 0; i < m_iEventNum; i++ ) {
|
||||
D3DXMatrixIdentity(&identity);
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&identity);
|
||||
|
||||
identity._41 = m_lstEvent[i].m_vecCameraPos.x + m_lstEvent[i].m_vecCameraUp.x * 50.0f;
|
||||
identity._42 = m_lstEvent[i].m_vecCameraPos.y + m_lstEvent[i].m_vecCameraUp.y * 50.0f;
|
||||
identity._43 = m_lstEvent[i].m_vecCameraPos.z + m_lstEvent[i].m_vecCameraUp.z * 50.0f;
|
||||
|
||||
identity._11 = 1.0f;
|
||||
identity._22 = 1.0f;
|
||||
identity._33 = 1.0f;
|
||||
|
||||
if(i == m_iFixCount) {
|
||||
identity._11 = 9.0f;
|
||||
identity._22 = 9.0f;
|
||||
identity._33 = 9.0f;
|
||||
|
||||
}
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&identity);
|
||||
|
||||
if((i != 0) && ( i != (m_iEventNum -1)))
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xffff4444);
|
||||
else
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xffffffff);
|
||||
|
||||
|
||||
if(i == m_iFixCount) {
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xff0000ff);
|
||||
}
|
||||
|
||||
m_pDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
0,8,12,g_vecCubeIndex,D3DFMT_INDEX16,g_vecCube,sizeof(D3DXVECTOR3));
|
||||
|
||||
identity._41 = m_lstEvent[i].m_vecCameraPos.x;
|
||||
identity._42 = m_lstEvent[i].m_vecCameraPos.y;
|
||||
identity._43 = m_lstEvent[i].m_vecCameraPos.z;
|
||||
|
||||
identity._11 = 1.0f;
|
||||
identity._22 = 1.0f;
|
||||
identity._33 = 1.0f;
|
||||
|
||||
if(i == m_iFixCount) {
|
||||
identity._11 = 9.0f;
|
||||
identity._22 = 9.0f;
|
||||
identity._33 = 9.0f;
|
||||
|
||||
}
|
||||
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&identity);
|
||||
|
||||
if((i != 0) && ( i != (m_iEventNum -1)))
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xffff0000);
|
||||
else
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xffffffff);
|
||||
|
||||
if(i == m_iFixCount) {
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xff0000ff);
|
||||
}
|
||||
|
||||
m_pDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
0,8,12,g_vecCubeIndex,D3DFMT_INDEX16,g_vecCube,sizeof(D3DXVECTOR3));
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FOGENABLE,FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FOGENABLE,TRUE);
|
||||
|
||||
}
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&worldTm);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
}
|
||||
void CCameraScript::RenderLook() {
|
||||
|
||||
int i;
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_LIGHTING,FALSE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_pDevice->SetVertexShader(D3DFVF_XYZ);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
D3DXMATRIX identity;
|
||||
D3DXMATRIX worldTm;
|
||||
|
||||
m_pDevice->GetTransform(D3DTS_WORLD,&worldTm);
|
||||
for( i = 0; i < m_iEventNum; i++ ) {
|
||||
|
||||
D3DXMatrixIdentity(&identity);
|
||||
|
||||
identity._41 = m_lstEvent[i].m_vecCameraLook.x;
|
||||
identity._42 = m_lstEvent[i].m_vecCameraLook.y;
|
||||
identity._43 = m_lstEvent[i].m_vecCameraLook.z;
|
||||
|
||||
identity._11 = 10.0f;
|
||||
identity._22 = 10.0f;
|
||||
identity._33 = 10.0f;
|
||||
if(i == m_iFixCount) {
|
||||
identity._11 = 15.0f;
|
||||
identity._22 = 15.0f;
|
||||
identity._33 = 15.0f;
|
||||
|
||||
|
||||
}
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&identity);
|
||||
|
||||
if((i != 0) && ( i != (m_iEventNum -1)))
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xffffff00);
|
||||
else
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xffffffff);
|
||||
|
||||
if(i == m_iFixCount) {
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xff0000ff);
|
||||
}
|
||||
|
||||
m_pDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
0,8,12,g_vecCubeIndex,D3DFMT_INDEX16,g_vecCube,sizeof(D3DXVECTOR3));
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FOGENABLE,FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FOGENABLE,TRUE);
|
||||
|
||||
}
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&worldTm);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
}
|
||||
void CCameraScript::RenderLookSpline() {
|
||||
|
||||
if((m_lstLookSpline.size() <= 0) || (m_bCreateLookSpline == false))
|
||||
return;
|
||||
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_LIGHTING,FALSE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_pDevice->SetVertexShader(D3DFVF_XYZ);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
D3DXMATRIX identity;
|
||||
D3DXMATRIX worldTm;
|
||||
|
||||
m_pDevice->GetTransform(D3DTS_WORLD,&worldTm);
|
||||
int iSplineNum = m_lstLookSpline.size();
|
||||
|
||||
|
||||
D3DXMatrixIdentity(&identity);
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&identity);
|
||||
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xffffff00);
|
||||
|
||||
m_pDevice->DrawPrimitiveUP(D3DPT_LINESTRIP,(iSplineNum - 1),&(m_lstLookSpline[0]),sizeof(D3DXVECTOR3));
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FOGENABLE,TRUE);
|
||||
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&worldTm);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
}
|
||||
|
||||
void CCameraScript::RenderPosSpline() {
|
||||
|
||||
if((m_lstPosSpline.size() <= 0) || (m_bCreateSpline == false))
|
||||
return;
|
||||
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_LIGHTING,FALSE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_pDevice->SetVertexShader(D3DFVF_XYZ);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
D3DXMATRIX identity;
|
||||
D3DXMATRIX worldTm;
|
||||
|
||||
m_pDevice->GetTransform(D3DTS_WORLD,&worldTm);
|
||||
int iSplineNum = m_lstPosSpline.size();
|
||||
|
||||
|
||||
D3DXMatrixIdentity(&identity);
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&identity);
|
||||
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xff00ffff);
|
||||
|
||||
m_pDevice->DrawPrimitiveUP(D3DPT_LINESTRIP,(iSplineNum - 1),&(m_lstPosSpline[0]),sizeof(D3DXVECTOR3));
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FOGENABLE,TRUE);
|
||||
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&worldTm);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
}
|
||||
void CCameraScript::RenderLine() {
|
||||
|
||||
int i;
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_LIGHTING,FALSE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_pDevice->SetVertexShader(D3DFVF_XYZ);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
D3DXMATRIX identity;
|
||||
D3DXMATRIX worldTm;
|
||||
|
||||
m_pDevice->GetTransform(D3DTS_WORLD,&worldTm);
|
||||
for( i = 0; i < m_iEventNum; i++ ) {
|
||||
|
||||
D3DXVECTOR3 vecUp = D3DXVECTOR3(m_lstEvent[i].m_vecCameraPos.x + m_lstEvent[i].m_vecCameraUp.x * 50.0f,
|
||||
m_lstEvent[i].m_vecCameraPos.y + m_lstEvent[i].m_vecCameraUp.y * 50.0f,
|
||||
m_lstEvent[i].m_vecCameraPos.z + m_lstEvent[i].m_vecCameraUp.z * 50.0f);
|
||||
D3DXVECTOR3 vecPos = D3DXVECTOR3(m_lstEvent[i].m_vecCameraPos.x,
|
||||
m_lstEvent[i].m_vecCameraPos.y,
|
||||
m_lstEvent[i].m_vecCameraPos.z);
|
||||
|
||||
D3DXVECTOR3 vecLook = D3DXVECTOR3(m_lstEvent[i].m_vecCameraLook.x,
|
||||
m_lstEvent[i].m_vecCameraLook.y,
|
||||
m_lstEvent[i].m_vecCameraLook.z);
|
||||
|
||||
|
||||
D3DXVECTOR3 vecLinePos[2];
|
||||
vecLinePos[0] = vecUp;
|
||||
vecLinePos[1] = vecPos;
|
||||
/* vecLinePos[2] = vecPos;
|
||||
vecLinePos[3] = vecLook;
|
||||
*/
|
||||
|
||||
D3DXMatrixIdentity(&identity);
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&identity);
|
||||
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0xff000000);
|
||||
m_pDevice->DrawPrimitiveUP(D3DPT_LINELIST,1,vecLinePos,sizeof(D3DXVECTOR3));
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FOGENABLE,TRUE);
|
||||
|
||||
}
|
||||
|
||||
m_pDevice->SetTransform(D3DTS_WORLD,&worldTm);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
}
|
||||
void CCameraScript::CreateSpline() {
|
||||
|
||||
m_lstPosSpline.clear();
|
||||
m_lstLookSpline.clear();
|
||||
|
||||
|
||||
float fU,fU2,fU3;
|
||||
float i,j;
|
||||
|
||||
for( i = 0; i < (m_iEventNum); i++ ) {
|
||||
m_lstEvent[i].m_iPosStart = m_lstPosSpline.size();
|
||||
|
||||
for(j = 0;j < CAMERASPLINEUNIT;j++) {
|
||||
fU = (float)j / (float)CAMERASPLINEUNIT;
|
||||
fU2 = fU * fU;
|
||||
fU3 = fU2 * fU;
|
||||
D3DXVECTOR3 vecNode;
|
||||
|
||||
vecNode.x = ( (-1 * fU3 + 3 * fU2 - 3*fU + 1) *
|
||||
m_lstEvent[(i == 0) ? 0 : (i - 1)].m_vecCameraPos.x +
|
||||
(3* fU3 - 6 * fU2 + 0 * fU + 4) *
|
||||
m_lstEvent[i + 0].m_vecCameraPos.x +
|
||||
(-3* fU3 + 3 * fU2 + 3 * fU + 1) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 2)) ? i + 1 : i].m_vecCameraPos.x +
|
||||
(1* fU3 + 0 * fU2 + 0 * fU + 0) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 3)) ? i + 2 : i].m_vecCameraPos.x) / 6.0f;
|
||||
vecNode.y = ( (-1 * fU3 + 3 * fU2 - 3*fU + 1) *
|
||||
m_lstEvent[(i == 0) ? 0 : (i - 1)].m_vecCameraPos.y +
|
||||
(3* fU3 - 6 * fU2 + 0 * fU + 4) *
|
||||
m_lstEvent[i + 0].m_vecCameraPos.y +
|
||||
(-3* fU3 + 3 * fU2 + 3 * fU + 1) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 2)) ? i + 1 : i].m_vecCameraPos.y +
|
||||
(1* fU3 + 0 * fU2 + 0 * fU + 0) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 3)) ? i + 2 : i].m_vecCameraPos.y) / 6.0f;
|
||||
vecNode.z = ( (-1 * fU3 + 3 * fU2 - 3*fU + 1) *
|
||||
m_lstEvent[(i == 0) ? 0 : (i - 1)].m_vecCameraPos.z +
|
||||
(3* fU3 - 6 * fU2 + 0 * fU + 4) *
|
||||
m_lstEvent[i + 0].m_vecCameraPos.z +
|
||||
(-3* fU3 + 3 * fU2 + 3 * fU + 1) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 2)) ? i + 1 : i].m_vecCameraPos.z +
|
||||
(1* fU3 + 0 * fU2 + 0 * fU + 0) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 3)) ? i + 2 : i].m_vecCameraPos.z) / 6.0f;
|
||||
|
||||
m_lstPosSpline.push_back(vecNode);
|
||||
|
||||
}
|
||||
m_lstEvent[i].m_iPosEnd = m_lstPosSpline.size();
|
||||
}
|
||||
m_bCreateSpline = true;
|
||||
if(m_iInsertLook <= 0)
|
||||
{
|
||||
m_bCreateLookSpline = false;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
for( i = 0; i < (m_iEventNum); i++ ) {
|
||||
m_lstEvent[i].m_iLookStart = m_lstLookSpline.size();
|
||||
for(j = 0;j < CAMERASPLINEUNIT;j++) {
|
||||
fU = (float)j / (float)CAMERASPLINEUNIT;
|
||||
fU2 = fU * fU;
|
||||
fU3 = fU2 * fU;
|
||||
D3DXVECTOR3 vecNode;
|
||||
|
||||
vecNode.x = ( (-1 * fU3 + 3 * fU2 - 3*fU + 1) *
|
||||
m_lstEvent[(i == 0) ? 0 : (i - 1)].m_vecCameraLook.x +
|
||||
(3* fU3 - 6 * fU2 + 0 * fU + 4) *
|
||||
m_lstEvent[i + 0].m_vecCameraLook.x +
|
||||
(-3* fU3 + 3 * fU2 + 3 * fU + 1) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 2)) ? i + 1 : i].m_vecCameraLook.x +
|
||||
(1* fU3 + 0 * fU2 + 0 * fU + 0) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 3)) ? i + 2 : i].m_vecCameraLook.x) / 6.0f;
|
||||
vecNode.y = ( (-1 * fU3 + 3 * fU2 - 3*fU + 1) *
|
||||
m_lstEvent[(i == 0) ? 0 : (i - 1)].m_vecCameraLook.y +
|
||||
(3* fU3 - 6 * fU2 + 0 * fU + 4) *
|
||||
m_lstEvent[i + 0].m_vecCameraLook.y +
|
||||
(-3* fU3 + 3 * fU2 + 3 * fU + 1) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 2)) ? i + 1 : i].m_vecCameraLook.y +
|
||||
(1* fU3 + 0 * fU2 + 0 * fU + 0) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 3)) ? i + 2 : i].m_vecCameraLook.y) / 6.0f;
|
||||
vecNode.z = ( (-1 * fU3 + 3 * fU2 - 3*fU + 1) *
|
||||
m_lstEvent[(i == 0) ? 0 : (i - 1)].m_vecCameraLook.z +
|
||||
(3* fU3 - 6 * fU2 + 0 * fU + 4) *
|
||||
m_lstEvent[i + 0].m_vecCameraLook.z +
|
||||
(-3* fU3 + 3 * fU2 + 3 * fU + 1) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 2)) ? i + 1 : i].m_vecCameraLook.z +
|
||||
(1* fU3 + 0 * fU2 + 0 * fU + 0) *
|
||||
m_lstEvent[(i <= (m_iEventNum - 3)) ? i + 2 : i].m_vecCameraLook.z) / 6.0f;
|
||||
|
||||
m_lstLookSpline.push_back(vecNode);
|
||||
|
||||
}
|
||||
m_lstEvent[i].m_iLookEnd = m_lstLookSpline.size();
|
||||
}
|
||||
}
|
||||
m_bCreateLookSpline = true;
|
||||
|
||||
}
|
||||
147
GameTools/CHARACTERACTIONCONTROL/CCameraScript.h
Normal file
147
GameTools/CHARACTERACTIONCONTROL/CCameraScript.h
Normal file
@@ -0,0 +1,147 @@
|
||||
#ifndef __CCAMERASCRIPT_H__
|
||||
#define __CCAMERASCRIPT_H__
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum C_INTERPOLATION {
|
||||
C_LINE, // Linear
|
||||
C_BEZIER1, // Bezier (제어점 3)
|
||||
C_BEZIER2, // Bezier (제어점 4)
|
||||
C_NOTINTERPOLATION, // 보간 없음
|
||||
};
|
||||
|
||||
#define CAMERAEVENTEMPTY -1
|
||||
#define CAMERAZEROFRAME 0.0f
|
||||
#define CAMERASCRIPTVERSION 1.0f
|
||||
#define CAMERAFRAMESTEP 30.0f
|
||||
#define CAMERASPLINEUNIT 100
|
||||
class CCameraScript {
|
||||
private:
|
||||
// 시퀀스 unit
|
||||
class CCameraEvent {
|
||||
public:
|
||||
int m_iIndex; // 시퀀스 인덱스
|
||||
int m_iInterpolation; // 전 Event와의 보간 방법 선택
|
||||
float m_fFrame; // 시작으로 부터의 프레임
|
||||
D3DXVECTOR3 m_vecControlPoint[2]; // 베지어 곡선 Control Point
|
||||
D3DXVECTOR3 m_vecCameraPos;
|
||||
D3DXVECTOR3 m_vecCameraLook;
|
||||
D3DXVECTOR3 m_vecCameraUp;
|
||||
|
||||
int m_iPosStart; // Pos Spline 에서의 시작 index
|
||||
int m_iPosEnd; // Pos Spline 에서의 종료 index
|
||||
|
||||
int m_iLookStart; // Look Spline 에서의 시작 index
|
||||
int m_iLookEnd; // Look Spline 에서의 종료 index
|
||||
|
||||
CCameraEvent() {
|
||||
m_iIndex = CAMERAEVENTEMPTY;
|
||||
m_iInterpolation = C_LINE;
|
||||
m_fFrame = CAMERAZEROFRAME;
|
||||
m_vecCameraPos = D3DXVECTOR3(0.0f,0.0f,0.0f);
|
||||
m_vecCameraUp = D3DXVECTOR3(0.0f,0.0f,0.0f);
|
||||
m_vecCameraLook = D3DXVECTOR3(0.0f,0.0f,0.0f);
|
||||
m_iPosStart = CAMERAEVENTEMPTY;
|
||||
m_iPosEnd = CAMERAEVENTEMPTY;
|
||||
m_iLookStart = CAMERAEVENTEMPTY;
|
||||
m_iLookEnd = CAMERAEVENTEMPTY;
|
||||
|
||||
}
|
||||
~CCameraEvent() {}
|
||||
};
|
||||
vector<CCameraEvent> m_lstEvent;
|
||||
|
||||
|
||||
vector<D3DXVECTOR3> m_lstPosSpline;
|
||||
bool m_bCreateSpline;
|
||||
|
||||
vector<D3DXVECTOR3> m_lstLookSpline;
|
||||
bool m_bCreateLookSpline;
|
||||
int m_iInsertLook;
|
||||
|
||||
int m_iEventNum;
|
||||
int m_iBeforeEvent;
|
||||
float m_fRunFrame; // 시작한 다음의 지나간 시간 frame
|
||||
D3DXMATRIX m_matBeforeView;
|
||||
|
||||
|
||||
CCameraEvent m_CurrentEvent; // 현재 프레임에 맞는, Event Unit
|
||||
D3DXMATRIX m_matCurrentFrame; // 현재 Frame View Matrix
|
||||
LPDIRECT3DDEVICE8 m_pDevice; // Direct3D Device
|
||||
|
||||
DWORD m_dwBeforeTick;
|
||||
DWORD m_dwCurrentTick;
|
||||
bool m_bStart;
|
||||
|
||||
|
||||
matrix m_matBeforePos;
|
||||
matrix m_matBeforeView2;
|
||||
|
||||
int m_iFixCount;
|
||||
bool m_bBackWord;
|
||||
|
||||
D3DXVECTOR3 m_vecCameraInitPos;
|
||||
D3DXVECTOR3 m_vecCameraInitLook;
|
||||
bool m_bInitPos;
|
||||
|
||||
|
||||
public:
|
||||
CCameraScript();
|
||||
~CCameraScript();
|
||||
|
||||
void InitCameraScript(bool bInitPos = false,D3DXVECTOR3 vecInitPos = D3DXVECTOR3(0.0f,0.0f,0.0f),D3DXVECTOR3 vecInitLook = D3DXVECTOR3(0.0f,0.0f,0.0f));
|
||||
void InitFrame();
|
||||
|
||||
int InsertEvent(D3DXVECTOR3 vecPos,D3DXVECTOR3 vecLook,D3DXVECTOR3 vecUp,float fFrame,int iInterpol);
|
||||
void InsertLookPos(D3DXVECTOR3 vecLook);
|
||||
|
||||
void FixEvent(int iEvent,D3DXVECTOR3 vecPos,D3DXVECTOR3 vecLook,D3DXVECTOR3 vecUp);
|
||||
|
||||
void FixEvent(int iEvent,D3DXVECTOR3 vecPos,D3DXVECTOR3 vecLook,D3DXVECTOR3 vecUp,float fFrame,int iInterpol);
|
||||
void FixLook(int iEvent,D3DXVECTOR3 vecLook);
|
||||
|
||||
void DeleteEvent(float fFrame,int iInterpol);
|
||||
void DeleteEvent(int iIndex);
|
||||
|
||||
bool SaveScript(char *strFileName);
|
||||
bool LoadScript(char *strFileName);
|
||||
|
||||
void CreateSpline();
|
||||
|
||||
void PlayScript(int iRoll,int iLoop,bool bFixPos);
|
||||
void Rewind();
|
||||
void Fowind();
|
||||
void Jump(int iEvent); //iEvent로 jump
|
||||
void SetPlay(bool bFlag,bool bBack = false,bool bStartPos = false);
|
||||
|
||||
D3DXVECTOR3 GetVecPos() { return m_CurrentEvent.m_vecCameraPos; }
|
||||
D3DXVECTOR3 GetVecLook() { return m_CurrentEvent.m_vecCameraLook; }
|
||||
D3DXVECTOR3 GetVecUp() { return m_CurrentEvent.m_vecCameraUp; }
|
||||
D3DXMATRIX GetCurrentViewMat() { return m_matCurrentFrame; }
|
||||
|
||||
int GetCameraEventCnt() { return m_lstEvent.size(); }
|
||||
|
||||
void RenderPos_Up();
|
||||
void RenderLook();
|
||||
void RenderLine();
|
||||
void RenderPosSpline();
|
||||
void RenderLookSpline();
|
||||
bool ISPlay() { return m_bStart;}
|
||||
int GetExistEventNum() { return m_iEventNum;}
|
||||
int GetFixCount(int &iIndex,float &fFrame);
|
||||
void ReWindFix();
|
||||
void FoWindFix();
|
||||
void BackWordEvent();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
BIN
GameTools/CHARACTERACTIONCONTROL/CHARACTERACTIONCONTROL.zip
Normal file
BIN
GameTools/CHARACTERACTIONCONTROL/CHARACTERACTIONCONTROL.zip
Normal file
Binary file not shown.
572
GameTools/CHARACTERACTIONCONTROL/CameraControl.cpp
Normal file
572
GameTools/CHARACTERACTIONCONTROL/CameraControl.cpp
Normal file
@@ -0,0 +1,572 @@
|
||||
// CameraControl.cpp: implementation of the CCameraControl class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CameraControl.h"
|
||||
#include "SceneManager.h"
|
||||
#include "FrameTimer.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
float CCameraControl::m_fJumpRate=0.0f;
|
||||
float CCameraControl::m_fCameraShakeRateTime=-1.0f;
|
||||
float CCameraControl::m_fCameraShakeNowTime=0.0f;
|
||||
vector3 CCameraControl::m_vecCameraShakeLength=vector3(0.0f,0.0f,0.0f);
|
||||
|
||||
float CCameraControl::m_fFadeOutStart=0.0f;
|
||||
float CCameraControl::m_fFadeOutMaintenance=0.0f;
|
||||
float CCameraControl::m_fFadeOutEnd=0.0f;
|
||||
float CCameraControl::m_fFadeOutNowTime=0.0f;
|
||||
|
||||
float CCameraControl::m_fFadeInStart=0.0f;
|
||||
float CCameraControl::m_fFadeInMaintenance=0.0f;
|
||||
float CCameraControl::m_fFadeInEnd=0.0f;
|
||||
float CCameraControl::m_fFadeInNowTime=0.0f;
|
||||
|
||||
color CCameraControl::m_FadeInColor;
|
||||
|
||||
DWORD CCameraControl::m_nCameraAnimationTimer=0xffffffff;
|
||||
|
||||
|
||||
CCameraControl::CCameraControl()
|
||||
{
|
||||
m_fCameraRotX = 3.14159f / 2.0f;
|
||||
m_fCameraRotY = 0.4f;
|
||||
|
||||
m_fBattleCameraRotY = 0.3f;
|
||||
m_fBattleInterCharacterCamera = 300.0f;
|
||||
m_fMouseClickInterCharacterCamera=1000.0f;
|
||||
|
||||
m_nCameraMode=1;
|
||||
|
||||
m_FadeInColor.c=0xffffffff;
|
||||
}
|
||||
|
||||
CCameraControl::~CCameraControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CCameraControl::UpdateBattleCharacter(vector3 vecChrPos, float fDirection)
|
||||
{
|
||||
if(m_nCameraMode>=2)
|
||||
{
|
||||
UpdateControlCamera();
|
||||
return;
|
||||
}
|
||||
|
||||
vecChrPos += vector3(0.0f, 150.0f, 0.0f);
|
||||
|
||||
if(m_fBattleCameraRotY > 3.14159f/2.0f-0.3f)
|
||||
m_fBattleCameraRotY=3.14159f/2.0f-0.3f;
|
||||
if(m_fBattleCameraRotY< -3.14159f/2.0f+0.7f)
|
||||
m_fBattleCameraRotY=-3.14159f/2.0f+0.7f;
|
||||
|
||||
vector3 vecCameraInterPos;
|
||||
|
||||
if(m_fJumpRate>0.0f)
|
||||
{
|
||||
vector3 vecJumpRate=sinf(m_fJumpRate)*vector3(0.0f,10.0f,0.0f);
|
||||
vecChrPos-=vecJumpRate;
|
||||
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
m_fJumpRate+=((int)fCameraUpdate)*0.08f;
|
||||
|
||||
if(m_fJumpRate>3.14159f)
|
||||
{
|
||||
m_fJumpRate=0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
m_fCameraShakeRateTime;
|
||||
static vector3 m_vecCameraShakeLength;
|
||||
|
||||
vector3 vecCameraShake=vector3(0.0f,0.0f,0.0f);
|
||||
|
||||
if(m_fCameraShakeRateTime>0.0f)
|
||||
{
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
m_fCameraShakeNowTime+=(int)fCameraUpdate;
|
||||
if(m_fCameraShakeNowTime>m_fCameraShakeRateTime)
|
||||
{
|
||||
m_fCameraShakeRateTime=-1.0f;
|
||||
}
|
||||
|
||||
vecCameraShake=vector3( (rand()%1000)-500 , (rand()%1000)-500 , (rand()%1000)-500 );
|
||||
vecCameraShake.Normalize();
|
||||
vecCameraShake.x=vecCameraShake.x*CCameraControl::m_vecCameraShakeLength.x;
|
||||
vecCameraShake.y=vecCameraShake.y*CCameraControl::m_vecCameraShakeLength.y;
|
||||
vecCameraShake.z=vecCameraShake.z*CCameraControl::m_vecCameraShakeLength.z;
|
||||
}
|
||||
|
||||
//vecCameraInterPos+=vecCameraShake;
|
||||
|
||||
CalcCameraPosition(vecChrPos,fDirection,m_fBattleCameraRotY,m_fBattleInterCharacterCamera,vecCameraInterPos);
|
||||
|
||||
SetCamera(vecCameraInterPos, vecCameraShake, vecChrPos);
|
||||
/* matrix matView;
|
||||
matView.CameraLookAt(vecCameraInterPos+vecCameraShake, vecChrPos+vecCameraShake, vector3(0.0f, 1.0f, 0.0f));
|
||||
matrix matInv;
|
||||
matInv.Inverse(matView);
|
||||
|
||||
m_vecCameraPos=vecCameraInterPos;
|
||||
|
||||
CSceneManager::GetCamera()->SetMatPosition(matInv);
|
||||
CSceneManager::GetCamera()->SetMatView(matView);
|
||||
CSceneManager::GetCamera()->SetVecPosition(vecChrPos);
|
||||
CSceneManager::GetCamera()->MoveFrustum();
|
||||
|
||||
if(m_fFadeOutStart> 0.0f)
|
||||
{
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
|
||||
m_fFadeOutNowTime+=(int)fCameraUpdate;
|
||||
|
||||
float fSetTime;
|
||||
|
||||
if(m_fFadeOutNowTime <= m_fFadeOutStart)
|
||||
{
|
||||
fSetTime=m_fFadeOutNowTime/m_fFadeOutStart;
|
||||
}
|
||||
if( m_fFadeOutNowTime > m_fFadeOutStart &&
|
||||
m_fFadeOutNowTime < m_fFadeOutStart+m_fFadeOutMaintenance)
|
||||
{
|
||||
fSetTime=1.0f;
|
||||
}
|
||||
if( m_fFadeOutNowTime >= m_fFadeOutStart+m_fFadeOutMaintenance)
|
||||
{
|
||||
fSetTime=m_fFadeOutNowTime-(m_fFadeOutStart+m_fFadeOutMaintenance);
|
||||
fSetTime=1.0f-(fSetTime/m_fFadeOutEnd);
|
||||
}
|
||||
CSceneManager::m_WeatherManager.m_CustomWaterColor=true;
|
||||
CSceneManager::m_WeatherManager.m_CustomWaterRate=fSetTime;
|
||||
|
||||
if( m_fFadeOutNowTime >= m_fFadeOutStart+m_fFadeOutMaintenance+m_fFadeOutEnd)
|
||||
{
|
||||
CSceneManager::m_WeatherManager.m_CustomWaterColor=false;
|
||||
|
||||
m_fFadeOutStart=0.0f;
|
||||
m_fFadeOutMaintenance=0.0f;
|
||||
m_fFadeOutEnd=0.0f;
|
||||
m_fFadeOutNowTime=0.0f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(m_fFadeInStart> 0.0f)
|
||||
{
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
|
||||
m_fFadeInNowTime+=(int)fCameraUpdate;
|
||||
|
||||
float fSetTime;
|
||||
|
||||
if(m_fFadeInNowTime <= m_fFadeInStart)
|
||||
{
|
||||
fSetTime=m_fFadeInNowTime/m_fFadeInStart;
|
||||
}
|
||||
if( m_fFadeInNowTime > m_fFadeInStart &&
|
||||
m_fFadeInNowTime < m_fFadeInStart+m_fFadeInMaintenance)
|
||||
{
|
||||
fSetTime=1.0f;
|
||||
}
|
||||
if( m_fFadeInNowTime >= m_fFadeInStart+m_fFadeInMaintenance)
|
||||
{
|
||||
fSetTime=m_fFadeInNowTime-(m_fFadeInStart+m_fFadeInMaintenance);
|
||||
fSetTime=1.0f-(fSetTime/m_fFadeInEnd);
|
||||
}
|
||||
if(fSetTime<1.0f && fSetTime>0.0f)
|
||||
{
|
||||
int a=0;
|
||||
}
|
||||
color InterColor;
|
||||
color ZeroColor;
|
||||
ZeroColor.c=0x00000000;
|
||||
InterColor=color::Interpolation(ZeroColor,m_FadeInColor,fSetTime);
|
||||
CSceneManager::m_FullSceneFade=InterColor;
|
||||
//CSceneManager::m_FullSceneFade.c=0x00ff0000;
|
||||
|
||||
if( m_fFadeInNowTime >= m_fFadeInStart+m_fFadeInMaintenance+m_fFadeInEnd)
|
||||
{
|
||||
m_fFadeInStart=0.0f;
|
||||
m_fFadeInMaintenance=0.0f;
|
||||
m_fFadeInEnd=0.0f;
|
||||
m_fFadeInNowTime=0.0f;
|
||||
|
||||
CSceneManager::m_FullSceneFade.c=0x0;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void CCameraControl::UpdateClickMode(vector3 vecChrPos)
|
||||
{
|
||||
if(m_nCameraMode>=2)
|
||||
{
|
||||
UpdateControlCamera();
|
||||
return;
|
||||
}
|
||||
vecChrPos += vector3(0.0f, 150.0f, 0.0f);
|
||||
|
||||
if(m_fCameraRotY > 3.14159f/2.0f-0.3f)
|
||||
m_fCameraRotY=3.14159f/2.0f-0.3f;
|
||||
if(m_fCameraRotY< -3.14159f/2.0f+0.7f)
|
||||
m_fCameraRotY=-3.14159f/2.0f+0.7f;
|
||||
|
||||
|
||||
//CalcCameraPosition(vecChrPos,-m_fCameraRotX,vecCameraInterPos);
|
||||
|
||||
m_fCameraShakeRateTime;
|
||||
static vector3 m_vecCameraShakeLength;
|
||||
|
||||
vector3 vecCameraShake=vector3(0.0f,0.0f,0.0f);
|
||||
|
||||
if(m_fCameraShakeRateTime>0.0f)
|
||||
{
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
m_fCameraShakeNowTime+=(int)fCameraUpdate;
|
||||
if(m_fCameraShakeNowTime>m_fCameraShakeRateTime)
|
||||
{
|
||||
m_fCameraShakeRateTime=-1.0f;
|
||||
}
|
||||
|
||||
vecCameraShake=vector3( (rand()%1000)-500 , (rand()%1000)-500 , (rand()%1000)-500 );
|
||||
vecCameraShake.Normalize();
|
||||
vecCameraShake.x=vecCameraShake.x*CCameraControl::m_vecCameraShakeLength.x;
|
||||
vecCameraShake.y=vecCameraShake.y*CCameraControl::m_vecCameraShakeLength.y;
|
||||
vecCameraShake.z=vecCameraShake.z*CCameraControl::m_vecCameraShakeLength.z;
|
||||
}
|
||||
|
||||
|
||||
vector3 vecCameraInterPos;
|
||||
|
||||
CalcCameraPosition(vecChrPos,-m_fCameraRotX,m_fCameraRotY,m_fMouseClickInterCharacterCamera,vecCameraInterPos);
|
||||
|
||||
SetCamera(vecCameraInterPos, vecCameraShake, vecChrPos);
|
||||
/*
|
||||
matrix matRotation,matResult;
|
||||
|
||||
matResult.Translation(vector3(1.0f,0.0f,0.0f));
|
||||
D3DXQUATERNION qR;
|
||||
D3DXQuaternionRotationYawPitchRoll(&qR,-m_fCameraRotX,0.0f,m_fCameraRotY);
|
||||
D3DXMatrixRotationQuaternion(matRotation,&qR);
|
||||
|
||||
matResult=matResult*matRotation;
|
||||
//vector3 vecCameraPosition=matResult.GetLoc();
|
||||
vector3 vecCameraInterPos=matResult.GetLoc();
|
||||
vector3 vecResultCameraPos = (vecCameraInterPos * m_fMouseClickInterCharacterCamera) + vecChrPos;
|
||||
|
||||
|
||||
/////////////////////Terrain//////////////////
|
||||
|
||||
List<vector3> PolyList;
|
||||
CSceneManager::m_HeightField.GetLineIntersectPoly(vecChrPos,vecResultCameraPos,PolyList);
|
||||
|
||||
float fCollisionLens=m_fMouseClickInterCharacterCamera;
|
||||
|
||||
float fLens;
|
||||
vector3 vecPoly[3];
|
||||
if(PolyList.num>0)
|
||||
{
|
||||
for(int cIndices=0;cIndices<PolyList.num/3;cIndices++)
|
||||
{
|
||||
vecPoly[0]=PolyList[cIndices*3+0];
|
||||
vecPoly[1]=PolyList[cIndices*3+1];
|
||||
vecPoly[2]=PolyList[cIndices*3+2];
|
||||
|
||||
if(CIntersection::PolygonRay(vecChrPos,vecResultCameraPos,vecPoly,fLens) && fCollisionLens > fLens && fLens > 0.0f)
|
||||
{
|
||||
fCollisionLens=fLens;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float fChrInter=fCollisionLens;
|
||||
vecCameraInterPos=vecCameraInterPos*fChrInter+vecChrPos;
|
||||
|
||||
float fCameraHeight=CSceneManager::m_HeightField.GetHeight(vecCameraInterPos);
|
||||
if(vecCameraInterPos.y < fCameraHeight +30.0f)
|
||||
{
|
||||
vecCameraInterPos.y=fCameraHeight +30.0f;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CCameraControl::ModeConvertAnimation()
|
||||
{
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
//fCameraUpdate=
|
||||
}
|
||||
|
||||
void CCameraControl::UpdateControlCamera()
|
||||
{
|
||||
if(m_nCameraMode==100)
|
||||
return;
|
||||
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
m_fTime+=fCameraUpdate;
|
||||
|
||||
vector3 vecAdder=m_vecVelocity*fCameraUpdate;
|
||||
m_vecNowPosition=m_vecNowPosition+vecAdder;
|
||||
|
||||
vector3 vecForLens=m_vecEndPosition-m_vecStartPosition;
|
||||
vector3 vecNowLens=m_vecNowPosition-m_vecStartPosition;
|
||||
|
||||
static float fVelScalar=0.0f;
|
||||
|
||||
m_vecVelocity+=m_vecAccelate*fCameraUpdate;
|
||||
|
||||
if(vecForLens.GetLens() < vecNowLens.GetLens())
|
||||
{
|
||||
m_nCameraMode=m_nPrepareCameraMode;
|
||||
}
|
||||
|
||||
matrix matView;
|
||||
matView.CameraLookAt(m_vecNowPosition, m_vecTargetCameraPosition, vector3(0.0f, 1.0f, 0.0f));
|
||||
matrix matInv;
|
||||
matInv.Inverse(matView);
|
||||
|
||||
m_vecCameraPos=m_vecNowPosition;
|
||||
|
||||
CSceneManager::GetCamera()->SetMatPosition(matInv);
|
||||
CSceneManager::GetCamera()->SetMatView(matView);
|
||||
CSceneManager::GetCamera()->SetVecPosition(m_vecNowPosition);
|
||||
CSceneManager::GetCamera()->MoveFrustum();
|
||||
}
|
||||
|
||||
void CCameraControl::CalcCameraPosition(vector3 vecChrPos,float fCameraDirection,float fCameraYDirection,float fInterCamera,vector3 &vecCameraInterPos)
|
||||
{
|
||||
matrix matRotation,matResult;
|
||||
|
||||
matResult.Translation(vector3(1.0f,0.0f,0.0f));
|
||||
D3DXQUATERNION qR;
|
||||
D3DXQuaternionRotationYawPitchRoll(&qR,fCameraDirection,0.0f,fCameraYDirection);
|
||||
D3DXMatrixRotationQuaternion(matRotation,&qR);
|
||||
|
||||
matResult=matResult*matRotation;
|
||||
//vector3 vecCameraPosition=matResult.GetLoc();
|
||||
vecCameraInterPos=matResult.GetLoc();
|
||||
vector3 vecResultCameraPos = (vecCameraInterPos * fInterCamera) + vecChrPos;
|
||||
|
||||
if(CSceneManager::m_RBspSceneManager.m_pCurrentBspScene != NULL) // RBsp Ãß°¡
|
||||
{
|
||||
D3DXVECTOR3 vecBefore = D3DXVECTOR3(vecChrPos.x,vecChrPos.y,vecChrPos.z);
|
||||
D3DXVECTOR3 vecNew = D3DXVECTOR3(vecResultCameraPos.x,vecResultCameraPos.y,vecResultCameraPos.z);
|
||||
D3DXVECTOR3 vecInter;
|
||||
///
|
||||
D3DXVECTOR3 vecPos = vecBefore;
|
||||
D3DXMATRIX matTmp;
|
||||
D3DXMATRIX matInv;
|
||||
|
||||
D3DXMatrixIdentity(&matTmp);
|
||||
|
||||
matTmp._41 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.x;
|
||||
matTmp._42 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.y;
|
||||
matTmp._43 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.z;
|
||||
D3DXMatrixInverse(&matInv,NULL,&matTmp);
|
||||
D3DXMatrixIdentity(&matTmp);
|
||||
matTmp._41 = vecPos.x;
|
||||
matTmp._42 = vecPos.y;
|
||||
matTmp._43 = vecPos.z;
|
||||
D3DXMatrixMultiply(&matTmp,&matTmp,&matInv);
|
||||
vecPos.x = matTmp._41;
|
||||
vecPos.y = matTmp._42;
|
||||
vecPos.z = matTmp._43;
|
||||
vecBefore = vecPos;
|
||||
///
|
||||
vecPos = vecNew;
|
||||
D3DXMatrixIdentity(&matTmp);
|
||||
matTmp._41 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.x;
|
||||
matTmp._42 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.y;
|
||||
matTmp._43 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.z;
|
||||
|
||||
D3DXMatrixInverse(&matInv,NULL,&matTmp);
|
||||
D3DXMatrixIdentity(&matTmp);
|
||||
matTmp._41 = vecPos.x;
|
||||
matTmp._42 = vecPos.y;
|
||||
matTmp._43 = vecPos.z;
|
||||
D3DXMatrixMultiply(&matTmp,&matTmp,&matInv);
|
||||
vecPos.x = matTmp._41;
|
||||
vecPos.y = matTmp._42;
|
||||
vecPos.z = matTmp._43;
|
||||
vecNew = vecPos;
|
||||
////
|
||||
vecInter = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->CollisionPoint(vecBefore,vecNew,50.0f);
|
||||
vecPos = vecInter;
|
||||
D3DXMatrixIdentity(&matTmp);
|
||||
matTmp._41 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.x;
|
||||
matTmp._42 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.y;
|
||||
matTmp._43 = CSceneManager::m_RBspSceneManager.m_pCurrentBspScene->m_vecZeroPos.z;
|
||||
matInv = matTmp;
|
||||
D3DXMatrixIdentity(&matTmp);
|
||||
matTmp._41 = vecPos.x;
|
||||
matTmp._42 = vecPos.y;
|
||||
matTmp._43 = vecPos.z;
|
||||
D3DXMatrixMultiply(&matTmp,&matTmp,&matInv);
|
||||
vecPos.x = matTmp._41;
|
||||
vecPos.y = matTmp._42;
|
||||
vecPos.z = matTmp._43;
|
||||
vecInter = vecPos;
|
||||
vecCameraInterPos = vector3(vecInter.x,vecInter.y,vecInter.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
/////////////////////Terrain//////////////////
|
||||
|
||||
List<vector3> PolyList;
|
||||
CSceneManager::m_HeightField.GetLineIntersectPoly(vecChrPos,vecResultCameraPos,PolyList);
|
||||
|
||||
float fCollisionLens=fInterCamera;
|
||||
|
||||
float fLens;
|
||||
vector3 vecPoly[3];
|
||||
if(PolyList.num>0)
|
||||
{
|
||||
for(int cIndices=0;cIndices<PolyList.num/3;cIndices++)
|
||||
{
|
||||
vecPoly[0]=PolyList[cIndices*3+0];
|
||||
vecPoly[1]=PolyList[cIndices*3+1];
|
||||
vecPoly[2]=PolyList[cIndices*3+2];
|
||||
|
||||
if(CIntersection::PolygonRay(vecChrPos,vecResultCameraPos,vecPoly,fLens) && fCollisionLens > fLens && fLens > 0.0f)
|
||||
{
|
||||
fCollisionLens=fLens;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float fChrInter=fCollisionLens;
|
||||
vecCameraInterPos=vecCameraInterPos*fChrInter+vecChrPos;
|
||||
|
||||
float fCameraHeight=CSceneManager::m_HeightField.GetHeight(vecCameraInterPos);
|
||||
if(vecCameraInterPos.y < fCameraHeight +40.0f)
|
||||
{
|
||||
vecCameraInterPos.y=fCameraHeight +40.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCameraControl::SetFadeOut(float fStart, float fMaintenance, float fEnd)
|
||||
{
|
||||
m_fFadeOutStart=fStart;
|
||||
m_fFadeOutMaintenance=fMaintenance;
|
||||
m_fFadeOutEnd=fEnd;
|
||||
m_fFadeOutNowTime=0.0f;
|
||||
}
|
||||
|
||||
void CCameraControl::SetFadeIn(float fStart, float fMaintenance, float fEnd,color FadeColor)
|
||||
{
|
||||
m_fFadeInStart=fStart;
|
||||
m_fFadeInMaintenance=fMaintenance;
|
||||
m_fFadeInEnd=fEnd;
|
||||
m_fFadeInNowTime=0.0f;
|
||||
m_FadeInColor=FadeColor;
|
||||
}
|
||||
|
||||
void CCameraControl::SetCamera(vector3 &vecCameraInterPos, vector3 &vecCameraShake, vector3 &vecChrPos)
|
||||
{
|
||||
vector3 viewDir = vecChrPos - vecCameraInterPos+vecCameraShake;
|
||||
viewDir.Normalize();
|
||||
matrix matView;
|
||||
matView.CameraLookAt(vecCameraInterPos+vecCameraShake, vecChrPos, vector3(0.0f, 1.0f, 0.0f));
|
||||
// ¼öÁ¤ 04.07.08
|
||||
//matView.CameraLookAt(vecCameraInterPos+vecCameraShake, vecCameraInterPos+vecCameraShake + viewDir, vector3(0.0f, 1.0f, 0.0f));
|
||||
matrix matInv;
|
||||
matInv.Inverse(matView);
|
||||
|
||||
m_vecCameraPos=vecCameraInterPos;
|
||||
|
||||
CSceneManager::GetCamera()->SetMatPosition(matInv);
|
||||
CSceneManager::GetCamera()->SetMatView(matView);
|
||||
CSceneManager::GetCamera()->SetVecPosition(vecChrPos);
|
||||
//¼öÁ¤ 04.07.08
|
||||
//CSceneManager::GetCamera()->SetVecPosition(vecCameraInterPos+vecCameraShake + viewDir);
|
||||
CSceneManager::GetCamera()->MoveFrustum();
|
||||
|
||||
if(m_fFadeOutStart> 0.0f)
|
||||
{
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
|
||||
m_fFadeOutNowTime+=(int)fCameraUpdate;
|
||||
|
||||
float fSetTime;
|
||||
|
||||
if(m_fFadeOutNowTime <= m_fFadeOutStart)
|
||||
{
|
||||
fSetTime=m_fFadeOutNowTime/m_fFadeOutStart;
|
||||
}
|
||||
if( m_fFadeOutNowTime > m_fFadeOutStart &&
|
||||
m_fFadeOutNowTime < m_fFadeOutStart+m_fFadeOutMaintenance)
|
||||
{
|
||||
fSetTime=1.0f;
|
||||
}
|
||||
if( m_fFadeOutNowTime >= m_fFadeOutStart+m_fFadeOutMaintenance)
|
||||
{
|
||||
fSetTime=m_fFadeOutNowTime-(m_fFadeOutStart+m_fFadeOutMaintenance);
|
||||
fSetTime=1.0f-(fSetTime/m_fFadeOutEnd);
|
||||
//if(fSetTime<0.0f)
|
||||
// fSetTime=0.0f;
|
||||
}
|
||||
if(fSetTime>=0.0f)
|
||||
{
|
||||
CSceneManager::m_WeatherManager.m_CustomWaterColor=true;
|
||||
CSceneManager::m_WeatherManager.m_CustomWaterRate=fSetTime;
|
||||
}
|
||||
|
||||
if( m_fFadeOutNowTime >= m_fFadeOutStart+m_fFadeOutMaintenance+m_fFadeOutEnd)
|
||||
{
|
||||
CSceneManager::m_WeatherManager.m_CustomWaterColor=false;
|
||||
|
||||
m_fFadeOutStart=0.0f;
|
||||
m_fFadeOutMaintenance=0.0f;
|
||||
m_fFadeOutEnd=0.0f;
|
||||
m_fFadeOutNowTime=0.0f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(m_fFadeInStart> 0.0f)
|
||||
{
|
||||
float fCameraUpdate=CFrameTimer::GetUpdateTimer(m_nCameraAnimationTimer);
|
||||
|
||||
m_fFadeInNowTime+=(int)fCameraUpdate;
|
||||
|
||||
float fSetTime;
|
||||
|
||||
if(m_fFadeInNowTime <= m_fFadeInStart)
|
||||
{
|
||||
fSetTime=m_fFadeInNowTime/m_fFadeInStart;
|
||||
}
|
||||
if( m_fFadeInNowTime > m_fFadeInStart &&
|
||||
m_fFadeInNowTime < m_fFadeInStart+m_fFadeInMaintenance)
|
||||
{
|
||||
fSetTime=1.0f;
|
||||
}
|
||||
if( m_fFadeInNowTime >= m_fFadeInStart+m_fFadeInMaintenance)
|
||||
{
|
||||
fSetTime=m_fFadeInNowTime-(m_fFadeInStart+m_fFadeInMaintenance);
|
||||
fSetTime=1.0f-(fSetTime/m_fFadeInEnd);
|
||||
}
|
||||
if(fSetTime<1.0f && fSetTime>0.0f)
|
||||
{
|
||||
int a=0;
|
||||
}
|
||||
color InterColor;
|
||||
color ZeroColor;
|
||||
ZeroColor.c=0x00000000;
|
||||
InterColor=color::Interpolation(ZeroColor,m_FadeInColor,fSetTime);
|
||||
CSceneManager::m_FullSceneFade=InterColor;
|
||||
//CSceneManager::m_FullSceneFade.c=0x00ff0000;
|
||||
|
||||
if( m_fFadeInNowTime >= m_fFadeInStart+m_fFadeInMaintenance+m_fFadeInEnd)
|
||||
{
|
||||
m_fFadeInStart=0.0f;
|
||||
m_fFadeInMaintenance=0.0f;
|
||||
m_fFadeInEnd=0.0f;
|
||||
m_fFadeInNowTime=0.0f;
|
||||
|
||||
CSceneManager::m_FullSceneFade.c=0x0;
|
||||
}
|
||||
}
|
||||
}
|
||||
69
GameTools/CHARACTERACTIONCONTROL/CameraControl.h
Normal file
69
GameTools/CHARACTERACTIONCONTROL/CameraControl.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// CameraControl.h: interface for the CCameraControl class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_CAMERACONTROL_H__4E002D9F_8CCD_44AF_8371_3BA39A220DC0__INCLUDED_)
|
||||
#define AFX_CAMERACONTROL_H__4E002D9F_8CCD_44AF_8371_3BA39A220DC0__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "3DMath.h"
|
||||
#include <d3d8.h>
|
||||
|
||||
class CCameraControl
|
||||
{
|
||||
public:
|
||||
void SetCamera(vector3 &vecCameraInterPos, vector3 &vecCameraShake, vector3 &vecChrPos);
|
||||
static void SetFadeIn(float fStart,float fMaintenance,float fEnd,color FadeColor);
|
||||
static void SetFadeOut(float fStart,float fMaintenance,float fEnd);
|
||||
void CalcCameraPosition(vector3 vecChrPos,float fCameraDirection,float fCameraYDirection,float fInterCamera,vector3 &vecCameraInterPos);
|
||||
void UpdateControlCamera();
|
||||
void ModeConvertAnimation();
|
||||
void UpdateClickMode(vector3 vecChrPos);
|
||||
void UpdateBattleCharacter(vector3 vecChrPos,float fDirection);
|
||||
int m_nCameraMode;//0 마우스 클릭모드,1 배틀,2 프로그램제어 카메라 (쉐이크,스크립트...)
|
||||
int m_nPrepareCameraMode;
|
||||
|
||||
static float m_fJumpRate;
|
||||
static float m_fCameraShakeRateTime;
|
||||
static float m_fCameraShakeNowTime;
|
||||
static vector3 m_vecCameraShakeLength;
|
||||
|
||||
static float m_fFadeOutStart;
|
||||
static float m_fFadeOutMaintenance;
|
||||
static float m_fFadeOutEnd;
|
||||
static float m_fFadeOutNowTime;
|
||||
|
||||
static float m_fFadeInStart;
|
||||
static float m_fFadeInMaintenance;
|
||||
static float m_fFadeInEnd;
|
||||
static float m_fFadeInNowTime;
|
||||
static color m_FadeInColor;
|
||||
|
||||
|
||||
|
||||
//
|
||||
vector3 m_vecStartPosition,m_vecEndPosition;
|
||||
vector3 m_vecVelocity,m_vecAccelate;
|
||||
vector3 m_vecNowPosition;
|
||||
float m_fTotalTimeInterval;
|
||||
float m_fTime;
|
||||
//
|
||||
float m_fCameraRotX,m_fCameraRotY;//클릭모드용
|
||||
float m_fBattleCameraRotY;
|
||||
float m_fMouseClickInterCharacterCamera,m_fBattleInterCharacterCamera;
|
||||
vector3 m_vecTargetCameraPosition;
|
||||
vector3 m_vecCameraPos;
|
||||
//
|
||||
|
||||
|
||||
|
||||
static DWORD m_nCameraAnimationTimer;
|
||||
CCameraControl();
|
||||
virtual ~CCameraControl();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_CAMERACONTROL_H__4E002D9F_8CCD_44AF_8371_3BA39A220DC0__INCLUDED_)
|
||||
124
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.dsp
Normal file
124
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.dsp
Normal file
@@ -0,0 +1,124 @@
|
||||
# Microsoft Developer Studio Project File - Name="CharacterActionControl" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=CharacterActionControl - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "CharacterActionControl.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "CharacterActionControl.mak" CFG="CharacterActionControl - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "CharacterActionControl - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "CharacterActionControl - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""$/CharacterActionControl", HAEAAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "CharacterActionControl - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FAcs /YX /FD /c
|
||||
# ADD BASE RSC /l 0x412 /d "NDEBUG"
|
||||
# ADD RSC /l 0x412 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "CharacterActionControl - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x412 /d "_DEBUG"
|
||||
# ADD RSC /l 0x412 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "CharacterActionControl - Win32 Release"
|
||||
# Name "CharacterActionControl - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CameraControl.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CCameraScript.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CharacterControl.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Creature.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CameraControl.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CCameraScript.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CharacterControl.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Creature.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.dsw
Normal file
29
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "CharacterActionControl"=.\CharacterActionControl.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.opt
Normal file
BIN
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.opt
Normal file
Binary file not shown.
25
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.plg
Normal file
25
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.plg
Normal file
@@ -0,0 +1,25 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: CharacterActionControl - Win32 Release--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP221.tmp" with contents
|
||||
[
|
||||
/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FAcs /Fa"Release/" /Fp"Release/CharacterActionControl.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
|
||||
"C:\ryl\CharacterActionControl\CCameraScript.cpp"
|
||||
]
|
||||
Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP221.tmp"
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
CCameraScript.cpp
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
CCameraScript.obj - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
BIN
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.rar
Normal file
BIN
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.rar
Normal file
Binary file not shown.
215
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.vcproj
Normal file
215
GameTools/CHARACTERACTIONCONTROL/CharacterActionControl.vcproj
Normal file
@@ -0,0 +1,215 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="CharacterActionControl"
|
||||
ProjectGUID="{EB71F1DE-B4FD-4B48-959B-8FC828C73BBF}"
|
||||
SccProjectName=""$/CharacterActionControl", HAEAAAAA"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\ZALLA3D BASECLASS;..\Effect;..\CHARACTERACTIONCONTROL;..\SoundLib;..\CaldronBase;..\Zallad3D SceneClass"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Release/CharacterActionControl.pch"
|
||||
AssemblerOutput="2"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Release\CharacterActionControl.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1042"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\ZALLA3D BASECLASS;..\Effect;..\CHARACTERACTIONCONTROL;..\SoundLib;..\CaldronBase;..\Zallad3D SceneClass"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug/CharacterActionControl.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Debug\CharacterActionControl.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1042"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath="CameraControl.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CCameraScript.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CharacterControl.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Creature.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="CameraControl.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CCameraScript.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CharacterControl.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Creature.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
6387
GameTools/CHARACTERACTIONCONTROL/CharacterControl.cpp
Normal file
6387
GameTools/CHARACTERACTIONCONTROL/CharacterControl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
210
GameTools/CHARACTERACTIONCONTROL/CharacterControl.h
Normal file
210
GameTools/CHARACTERACTIONCONTROL/CharacterControl.h
Normal file
@@ -0,0 +1,210 @@
|
||||
// CharacterControl.h: interface for the CCharacterControl class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_CHARACTERCONTROL_H__E5DF7481_5D2B_4E51_B47A_951185AFB01D__INCLUDED_)
|
||||
#define AFX_CHARACTERCONTROL_H__E5DF7481_5D2B_4E51_B47A_951185AFB01D__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define CT_PC 0
|
||||
#define CT_NPC 1
|
||||
#define CT_MONSTER 2
|
||||
|
||||
#define TARGET_SELF 10001
|
||||
#define TARGET_SELECTCHAR 10000
|
||||
|
||||
#include "Creature.h"
|
||||
#include "CreatureSize.h"
|
||||
#include "List.h"
|
||||
#include "CameraControl.h"
|
||||
#include "..\\Effect\\CEffscript.h"
|
||||
#include "CCameraScript.h"
|
||||
|
||||
|
||||
extern CCameraScript *g_CameraScript;
|
||||
extern int MAXCHRLOAD;
|
||||
|
||||
class CCharacterControl
|
||||
{
|
||||
class CAttackedNode
|
||||
{
|
||||
public:
|
||||
DWORD m_dwSrcChrID, m_dwTarChrID;
|
||||
unsigned long m_dwWeaponType;
|
||||
};
|
||||
public:
|
||||
bool CheckCharacterListIn(CZ3DGeneralChrModel *pChr) { return true;}
|
||||
|
||||
char * GetCreatureName(unsigned long dwChrID);
|
||||
void InitGlobalAction(void);
|
||||
BOOL GetAttacking(void);
|
||||
BOOL CheckMonsterForward(void);
|
||||
void MakeVisualAttackInfo();
|
||||
CTexture *m_SimpleHumanTexture[4];
|
||||
void UnloadCash(CZ3DGeneralChrModel *pChrmodel);
|
||||
void GetSendCharacterChatList(List<DWORD> &SendCharacterList);
|
||||
void GetSendCharacterList(List<DWORD> &SendCharacterList);
|
||||
void MakeAttackInfo(DWORD dwEnemyChrID);
|
||||
void PlaySound(int nMethod,vector3 vecPos);
|
||||
BOOL m_bCharacterTargetNear;
|
||||
DWORD m_nSelectItem;
|
||||
void PlayerProcessOperation(BOOL bKeyAble);
|
||||
void SetDirectionforMouse(vector3 &vecDirection);
|
||||
// CEffScript *m_pCharacterSelectEff;
|
||||
// CEffScript *m_pEnemyCharacterSelectEff;
|
||||
// CEffScript *m_pEnemyAttackEff;
|
||||
bool m_bSkillAttack;
|
||||
|
||||
long m_lAutoRunCounter;
|
||||
unsigned long m_dwAutoTargetID;
|
||||
bool m_bAutoTargetAttack;
|
||||
CCreature * GetCreature(CZ3DGeneralChrModel *pChrmodel);
|
||||
void MouseClickModeSelfCharacterUpdate(BOOL bKeyAble, BOOL bEdge, int MouseX, int MouseY);
|
||||
vector3 m_vecClickPos;
|
||||
bool m_bClickMove;
|
||||
bool m_bClickAttack;
|
||||
DWORD m_dwClickModeAttackTargetID;
|
||||
void CheckCameraShakeTiming();
|
||||
void CheckAttackedTiming();
|
||||
List<CAttackedNode> m_AttackedList;
|
||||
void RegistAttacked(DWORD dwSrcChrID,DWORD dwTarChrID, unsigned long dwWeaponType = 0);
|
||||
void MakeAttacked(DWORD dwChrID, unsigned long dwWeaponType);
|
||||
bool MakeSkillAttackInfo(unsigned long dwTargetID, unsigned short wSkill = 0, unsigned char cSkillLock = 0, unsigned char cSkillLevel = 0, unsigned char cAtCount = 1);
|
||||
vector3 *GetFindChrPos(unsigned long dwChrID);
|
||||
bool m_bClientUsed;
|
||||
CCameraControl m_Camera;
|
||||
void MouseModeChange();
|
||||
////////////// Network Bind Function ///////////////
|
||||
static vector3 (*GetMonsterMinBox)(unsigned long dwChrID);
|
||||
static vector3 (*GetMonsterMaxBox)(unsigned long dwChrID);
|
||||
static bool (*IsExistToList)(unsigned short List_In, DWORD CharID_In);
|
||||
static bool (*CharAddressRequireInfo)(DWORD SenderID_In, DWORD CharID_In);
|
||||
static BOOL (*SendMovingPacket)(unsigned long dwUpperAni, unsigned long dwLowerAni, float fDir, vector3 &vecMove);
|
||||
static BOOL (*SendCharRespawn)(unsigned long dwChrID);
|
||||
static BOOL (*SendMoveUpdatePacket)(float fDir, vector3 &vecPosition);
|
||||
static BOOL (*SendCharAttack)(vector3 &vecPos, float fDir, unsigned short wType, unsigned char cSkillLock, unsigned char cSkillLevel, unsigned char cAtCount, unsigned short wDefenserNum, unsigned long dwDefenser[10]);
|
||||
static void (*PickItem)(DWORD nItemID);
|
||||
////////////////////////////////////////////////////
|
||||
//static void SetSlideValue(CEffScript *,CEffScript::CEffExt6 );
|
||||
static void (*SetChangeWeapon)(BOOL bChangeWeapon);
|
||||
static void (*SetAutoRun)(BOOL bAutoRun);
|
||||
static BOOL (*GetAutoRun)(void);
|
||||
static char *(*GetMotionSheet)(char *strWeaponName, char *strShieldName, unsigned short wClass);
|
||||
static unsigned long (*GetWeaponType)(char *strWeaponName);
|
||||
static void (*CheckTargetforSkill)(unsigned long &dwTargetID, BOOL bCheckLength);
|
||||
static BOOL (*CheckSkillStart)(BOOL bDown);
|
||||
static BOOL (*CheckStillCasting)(unsigned long &dwFunction);
|
||||
static void (*ChangeWeapon)(void);
|
||||
static void (*SetKillCounter)(long lKillCounter);
|
||||
void WrapSendCharAttack(vector3 &vecPos, float fDir, unsigned short wAtType, unsigned char cSkillLock, unsigned char cSkillLevel, unsigned char cAtCount, unsigned short wDefenserNum,unsigned long lpAtNode[10]);
|
||||
void WrapSendMoveUpdatePacket(float fDir,vector3 vecPos);
|
||||
void WrapSendCharRespawn(DWORD dwChrID);
|
||||
void WrapSendMovingPacket(DWORD dwUpperAction,DWORD dwLowerAction,float fDir,vector3 vecPos);
|
||||
CCreatureSize m_CreatureSize; // 캐릭터 사이즈
|
||||
CCreature * GetCreature(unsigned long dwChrID);
|
||||
unsigned long GetClientType(unsigned long dwChrID, BOOL bNation = FALSE);
|
||||
void UpdateMonster(unsigned long cChr, float fUpdateTime);
|
||||
void UpdatePlayer(unsigned long cChr, float fUpdateTime);
|
||||
BOOL GetIsExistChar(unsigned long dwChrID);
|
||||
void AddActionData(unsigned long dwChrID, unsigned long dwUpperAni, unsigned long dwLowerAni, float fDirection, vector3 &vecNextPosition, float fVec = 0.0f, unsigned short wAniNum = 0, unsigned long dwFrame = 0);
|
||||
void Create(void);
|
||||
class ChrCashNode
|
||||
{
|
||||
public:
|
||||
CZ3DGeneralChrModel *m_lpChrModel;
|
||||
char m_strGCMDSName[MAX_PATH];
|
||||
int m_nUsedChrID;
|
||||
};
|
||||
BOOL m_bSkillExecuted;
|
||||
unsigned long m_dwStartSkillTick;
|
||||
unsigned long m_dwCastingSkillTick;
|
||||
unsigned long m_dwCastingSkillGrade;
|
||||
bool m_bAttackMode;
|
||||
List<CCreature *> m_lstCharData; // 캐릭터 리스트
|
||||
List<ChrCashNode> m_ChrCashList; // 캐쉬 노드 리시트
|
||||
int m_nFocusCharacter; // 자신의 캐릭터
|
||||
int m_nChrAction;
|
||||
//float m_fCameraRotY, m_fCameraRotX;
|
||||
//float m_fInterCharacterCamera;
|
||||
int m_nChrCounter;
|
||||
vector3 m_vecPrePosition; // 자신의 캐릭터 어전 위치(NPC 거리 계산용)
|
||||
unsigned long m_dwMaxCombo; // 자신의 총 콤보수
|
||||
BOOL m_bAttackable;
|
||||
|
||||
CEffScript *m_lpDuelReady;
|
||||
CEffScript *m_lpButtonNormal;
|
||||
BOOL m_bComboSuccess;
|
||||
|
||||
unsigned long m_dwPreDuelTargetID;
|
||||
unsigned long m_dwDuelTargetID;
|
||||
|
||||
unsigned long m_dwRunFactorTimer;
|
||||
unsigned long m_dwNormalTargetMonsterID;
|
||||
unsigned long m_dwNormalTargetID;
|
||||
unsigned long m_dwSpecialTargetID;
|
||||
BOOL m_bAttackResult;
|
||||
|
||||
float m_fRunSpeed;
|
||||
float m_fWalkSpeed;
|
||||
|
||||
float m_fSkillLength;
|
||||
|
||||
int m_nCharMovingPacketTimerID;
|
||||
int m_nCharMoveUpdatePacketTimerID;
|
||||
int m_SkillAttackValue; //Skill 에 따라서 나오는 타격 이팩트가 바뀔지 결정하는 플레그
|
||||
|
||||
//static bool m_bSlide;
|
||||
//static CEffScript::CEffExt6 m_SlideValue;
|
||||
unsigned long m_dwSlideTick;
|
||||
//static CEffScript *m_SlideEffect;
|
||||
|
||||
static char m_WCharMotion[50];
|
||||
CEffScript *m_Effect;
|
||||
char m_TextEsf[256];
|
||||
char m_TextEsfInterface[256];
|
||||
|
||||
CCharacterControl();
|
||||
~CCharacterControl();
|
||||
|
||||
void DeleteAllCharacter(void);
|
||||
|
||||
void SetCamera(int dx = 0, int dy = 0, int dz = 0);
|
||||
void MakeShake(int nChrID);
|
||||
bool MakeAttackInfo(unsigned short wSkill = 0, unsigned char cSkillLock = 0, unsigned char cSkillLevel = 0, unsigned char cAtCount = 1, float fAttackAngle=0.0f,float fAttackRate=0.0f, BOOL bAngle = TRUE);
|
||||
|
||||
// void SetAction(int nActionType, int nAction);
|
||||
void SetShape(CZ3DGeneralChrModel* pChrmodel, char strShape[15][256]);
|
||||
|
||||
int AddCharacter(unsigned long dwChrID, const char *strName, char *strGCMDSName, vector3 vecChrPos, float fDirection);
|
||||
int AddCharacter(unsigned long dwChrID, unsigned char cNation, const char *strName, char *strGCMDSName, char *strFaceType, char *strHairStyle, vector3 vecChrPos, float fDirection, char strShape[15][256]);
|
||||
int AddCharacter(unsigned long dwChrID, vector3 vecChrPos);
|
||||
CZ3DGeneralChrModel* AllocCharacter(char *strGCMDSName, char *strFaceType, char *strHairStyle, int nChrID, char strShape[15][256]);
|
||||
void UnLoadChr(unsigned long dwUID);
|
||||
|
||||
void MouseMove(int MouseX, int MouseY);
|
||||
|
||||
unsigned long GetScreenPosChr(POINT &Point, int nMode = 0, float fLength = 0);
|
||||
|
||||
int m_MouseClickMode;
|
||||
|
||||
int m_nCameraAnimation;
|
||||
|
||||
void Update(float fUpdateTime);
|
||||
void UpdateSelfCharacter(BOOL bKeyAble = TRUE, BOOL bEdge = FALSE, int MouseX=0,int MouseY=0);
|
||||
void SelfCharacterUpdate();
|
||||
void Render(LPDIRECT3DDEVICE8 pd3dDevice);
|
||||
|
||||
/////////// Monster
|
||||
void MonsterEffectProcess(int iChracter,char *strFilename,int iEffectValue = 1);
|
||||
////////////
|
||||
|
||||
//void PlaySlide();
|
||||
//void RenderSlide(float beforex,float beforey,float beforez,float nowx,float nowy,float nowz,float unitsize);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_CHARACTERCONTROL_H__E5DF7481_5D2B_4E51_B47A_951185AFB01D__INCLUDED_)
|
||||
2966
GameTools/CHARACTERACTIONCONTROL/Creature.cpp
Normal file
2966
GameTools/CHARACTERACTIONCONTROL/Creature.cpp
Normal file
File diff suppressed because it is too large
Load Diff
415
GameTools/CHARACTERACTIONCONTROL/Creature.h
Normal file
415
GameTools/CHARACTERACTIONCONTROL/Creature.h
Normal file
@@ -0,0 +1,415 @@
|
||||
// Creature.h: interface for the CCreature class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_CREATURE_H__0C16A3E3_6308_4E72_AFF8_1CFE85324B6D__INCLUDED_)
|
||||
#define AFX_CREATURE_H__0C16A3E3_6308_4E72_AFF8_1CFE85324B6D__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Z3DGeneralChrModel.h"
|
||||
#include "List.h"
|
||||
#include "SceneManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
const unsigned long CA_WAIT = 0;
|
||||
const unsigned long CA_RUN = 1;
|
||||
const unsigned long CA_ATTACK = 2;
|
||||
const unsigned long CA_MOVEATTACK = 3;
|
||||
const unsigned long CA_WALKBACK = 4;
|
||||
const unsigned long CA_WALKLEFT = 5;
|
||||
const unsigned long CA_WALKRIGHT = 6;
|
||||
const unsigned long CA_BASH = 7;
|
||||
const unsigned long CA_WALK = 8;
|
||||
const unsigned long CA_FALLDOWN = 9;
|
||||
const unsigned long CA_REST = 10;
|
||||
const unsigned long CA_SITDOWN = 11;
|
||||
const unsigned long CA_STANDUP = 12;
|
||||
const unsigned long CA_ATTACKADVANCE = 13;
|
||||
const unsigned long CA_ATTACKLEFT = 14;
|
||||
const unsigned long CA_ATTACKRIGHT = 15;
|
||||
const unsigned long CA_ATTACKRETREAT = 16;
|
||||
const unsigned long CA_ATTACK2 = 17;
|
||||
const unsigned long CA_ATTACK3 = 18;
|
||||
const unsigned long CA_ATTACK4 = 19;
|
||||
const unsigned long CA_RESPAWN = 20;
|
||||
const unsigned long CA_JUMP = 21;
|
||||
const unsigned long CA_LEFTDASH = 22;
|
||||
const unsigned long CA_RIGHTDASH = 23;
|
||||
const unsigned long CA_CASTING = 24;
|
||||
const unsigned long CA_FIRE1 = 25;
|
||||
const unsigned long CA_FIRE2 = 26;
|
||||
const unsigned long CA_COMBINATIONBLOW = 27;
|
||||
const unsigned long CA_BACKSTAB = 28;
|
||||
const unsigned long CA_AIMEDSHOT2 = 29;
|
||||
const unsigned long CA_ATTACK5 = 30;
|
||||
const unsigned long CA_ATTACK6 = 31;
|
||||
const unsigned long CA_BACKDASH = 32;
|
||||
const unsigned long CA_AIMEDSHOT1 = 33;
|
||||
const unsigned long CA_JUMPATTACK = 34;
|
||||
const unsigned long CA_JUMPATTACK2 = 35;
|
||||
const unsigned long CA_FRONTDASH = 36;
|
||||
const unsigned long CA_LAND = 37;
|
||||
const unsigned long CA_FORWARDJUMP = 38;
|
||||
const unsigned long CA_BACKJUMP = 40;
|
||||
const unsigned long CA_SHOT = 41;
|
||||
const unsigned long CA_JUMPSHOT = 42;
|
||||
const unsigned long CA_OVERBASH1 = 43;
|
||||
const unsigned long CA_OVERBASH2 = 44;
|
||||
const unsigned long CA_OVERBASH3 = 45;
|
||||
const unsigned long CA_OVERBASH4 = 46;
|
||||
const unsigned long CA_OVERBASH5 = 47;
|
||||
const unsigned long CA_POWERDRAIN = 48;
|
||||
const unsigned long CA_TURNPUNCH1 = 49;
|
||||
const unsigned long CA_TURNPUNCH2 = 50;
|
||||
const unsigned long CA_TURNPUNCH3 = 51;
|
||||
const unsigned long CA_JUMPATTACK3 = 52;
|
||||
const unsigned long CA_AIMEDSHOT3 = 53;
|
||||
const unsigned long CA_STUN = 54;
|
||||
const unsigned long CA_ROUNDSWING = 55;
|
||||
const unsigned long CA_SWIM = 100;
|
||||
|
||||
const float RUN_INTERVAL = 255.0f;
|
||||
|
||||
const long PACKET_LIFETIME = 10000;
|
||||
|
||||
typedef struct ChrActionNode
|
||||
{
|
||||
unsigned long m_dwLowerChrAction;
|
||||
unsigned long m_dwUpperChrAction;
|
||||
float m_fDirection;
|
||||
vector3 m_vecNextPosition;
|
||||
float m_fVec;
|
||||
unsigned short m_wAniNum;
|
||||
unsigned short m_wAniNumCount;
|
||||
unsigned long m_dwFrame;
|
||||
} ChrActionNode;
|
||||
|
||||
typedef struct stDamage
|
||||
{
|
||||
short sLifeTime;
|
||||
long lValue;
|
||||
unsigned short wMode;
|
||||
float fScale;
|
||||
} stDamage;
|
||||
|
||||
class CCreature
|
||||
{
|
||||
public:
|
||||
int GetChrTitle( int nClass, int nMerits );
|
||||
void SetChantEffect(unsigned long dwChant, BOOL bToggle, BOOL bSelf);
|
||||
void SetChantEffect(unsigned long dwChant, BOOL bSelf);
|
||||
BOOL GetSkillMotion(void);
|
||||
class CCreatureArrow {
|
||||
public:
|
||||
CEffScript *m_ArrowEsf;
|
||||
char m_PivotName[256];
|
||||
CCreatureArrow() {
|
||||
m_ArrowEsf = NULL;
|
||||
memset(m_PivotName,0,sizeof(char) * 256);
|
||||
}
|
||||
~CCreatureArrow() {
|
||||
if(m_ArrowEsf != NULL) {
|
||||
if(!CSceneManager::m_EffectManager.CheckNullScript(m_ArrowEsf)) {
|
||||
CSceneManager::m_EffectManager.DeleteEndScript(m_ArrowEsf);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
class CCreatureEffect { //creature 몸에 붙는 effect class
|
||||
public:
|
||||
CEffScript *m_Effect; // esf
|
||||
bool m_bPivotRot;
|
||||
int m_PivotIndex;
|
||||
char m_PivotName[50];
|
||||
char m_EffName[50];
|
||||
bool m_EffValue;
|
||||
unsigned long m_EffId;
|
||||
|
||||
D3DXVECTOR3 m_EffPos;
|
||||
|
||||
CCreatureEffect() {
|
||||
m_Effect = NULL;
|
||||
m_bPivotRot = false;
|
||||
m_PivotIndex= -1;
|
||||
memset(m_PivotName,0,sizeof(char) * 50);
|
||||
memset(m_EffName,0,sizeof(char) * 50);
|
||||
m_EffValue = false;
|
||||
m_EffPos.x = m_EffPos.y = m_EffPos.z = 0.0f;
|
||||
m_EffId = 0;
|
||||
|
||||
}
|
||||
~CCreatureEffect() {
|
||||
if(m_Effect != NULL) {
|
||||
|
||||
if(!CSceneManager::m_EffectManager.CheckNullScript(m_Effect)) {
|
||||
m_Effect->SetAllLoopOff();
|
||||
m_Effect->SetVisibility(false);
|
||||
//CSceneManager::m_EffectManager.DeleteEndScript(m_Effect);
|
||||
m_Effect = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CWeaponEffect { //Weapon에 붙는 effect
|
||||
|
||||
public:
|
||||
int m_nWeaponEffectNum; //effect의 갯수
|
||||
int m_nWeaponPosNum; //effect의 갯수중에 현 effect 노드의 위치
|
||||
|
||||
char m_strEffect[50];
|
||||
CEffScript *m_pEffect;
|
||||
|
||||
CWeaponEffect()
|
||||
{
|
||||
m_nWeaponEffectNum = 0;
|
||||
m_nWeaponPosNum = 0;
|
||||
|
||||
memset(m_strEffect,sizeof(int),50);
|
||||
m_pEffect = NULL;
|
||||
}
|
||||
~CWeaponEffect()
|
||||
{
|
||||
if(m_pEffect != NULL) {
|
||||
if(!CSceneManager::m_EffectManager.CheckNullScript(m_pEffect)) {
|
||||
//CSceneManager::m_EffectManager.DeleteEndScript(m_pEffect);
|
||||
m_pEffect->SetAllLoopOff();
|
||||
m_pEffect->SetVisibility(false);
|
||||
|
||||
m_pEffect = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
class CWeaponLine { // Weapon Line Setting Class
|
||||
public:
|
||||
LPDIRECT3DTEXTURE8 m_lpLineTexture; // Texture
|
||||
int m_iColor[3]; // Color
|
||||
int m_iBlend; // Blend Mode
|
||||
|
||||
CWeaponLine() {
|
||||
m_lpLineTexture = NULL;
|
||||
m_iColor[0] = m_iColor[1] = m_iColor[2] = 255;
|
||||
m_iBlend = 0;
|
||||
}
|
||||
~CWeaponLine() {
|
||||
if(m_lpLineTexture != NULL) {
|
||||
m_lpLineTexture->Release();
|
||||
m_lpLineTexture = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
BOOL Casting(unsigned long dwUpperAni = 0xFFFFFFFF, unsigned long dwLowerAni = 0xFFFFFFFF);
|
||||
void CancelSkill(void);
|
||||
void InitWeapon(unsigned long dwEquip);
|
||||
DWORD m_dwLastUpdateActionTimer;
|
||||
/* char m_strWeaponType[256];
|
||||
static void LoadMotionSheet(char *strFilename);
|
||||
static char m_strWeaponMotionSheet[MAX_WEAPONTABLE][256];
|
||||
static char m_strWeapon[MAX_WEAPONTABLE][256];*/
|
||||
float m_fScale;
|
||||
void EndSkill(char *strMotion);
|
||||
void BeginCast(char *strMotion);
|
||||
BOOL Dash(int nDir);
|
||||
BOOL Jump();
|
||||
void SkillAttack(unsigned long dwUpperAni, unsigned int dwLowerAni);
|
||||
void SetShape(char strShape[15][256]);
|
||||
void Respawn(void);
|
||||
void InitChrAction(void);
|
||||
BOOL IsCancelAction(unsigned long dwPart);
|
||||
void SetMotionString(unsigned long *dwAction, char *strAction);
|
||||
void SetMotionString(unsigned long dwAction, char *strAction);
|
||||
BOOL Attack(unsigned long dwUpperAni = 0xFFFFFFFF, unsigned long dwLowerAni = 0xFFFFFFFF);
|
||||
void Dead(void);
|
||||
void Wait(void);
|
||||
BOOL SetAction(char *strUpperAction, char *strLowerAction);
|
||||
BOOL SetAction(unsigned long dwUpperAni, unsigned long dwLowerAni);
|
||||
void CrouchAndStandup(void);
|
||||
void WalkBack(void);
|
||||
void WalkRight(void);
|
||||
void WalkLeft(void);
|
||||
void Run(float fRunFactor);
|
||||
CZ3DGeneralChrModel *m_lpChrModel;
|
||||
char m_strGCMDSName[MAX_PATH];
|
||||
char m_strFaceType[MAX_PATH];
|
||||
char m_strHairStyle[MAX_PATH];
|
||||
unsigned short m_wShape[15];
|
||||
char m_strShape[15][256]; // 나중에 제거할 변수
|
||||
|
||||
unsigned char m_cSex;
|
||||
unsigned char m_cNation;
|
||||
unsigned char m_cLevel;
|
||||
unsigned short m_wClass;
|
||||
unsigned long m_dwPartyID;
|
||||
unsigned long m_dwWeaponPos;
|
||||
short m_sDamage;
|
||||
long m_sCurrHP;
|
||||
long m_sCurrMP;
|
||||
unsigned short m_wMaxHP;
|
||||
unsigned short m_wMaxMP;
|
||||
float m_fDeadTimer;
|
||||
unsigned long m_dwAttackCombo;
|
||||
unsigned long m_dwSkillComboCount;
|
||||
BOOL m_bSkillCombo;
|
||||
vector3 m_vecPos;
|
||||
float m_fDirection;
|
||||
unsigned long m_dwChrID;
|
||||
float m_fSelfChrLens;
|
||||
int m_ChrNodeID;
|
||||
float m_fRunFactor;
|
||||
char m_strName[MAX_PATH];
|
||||
BOOL m_bSitMode;
|
||||
BOOL m_bUsed;
|
||||
BOOL m_bFlying;
|
||||
BOOL m_bFlyFirstCheck;
|
||||
BOOL m_bStillCasting;
|
||||
BOOL m_bNoneComboAttackMode;
|
||||
BOOL m_bFirstPositionSend;
|
||||
vector3 m_vecJumpAttackVector;
|
||||
unsigned long m_dwChant;
|
||||
char m_strStreetStallName[32];
|
||||
bool m_bPeaceMode;
|
||||
|
||||
unsigned long m_dwSpendTime[6];
|
||||
|
||||
ChrActionNode m_ChrAction;
|
||||
|
||||
float m_fFixAngle;
|
||||
|
||||
List<ChrActionNode> m_lstActionData;
|
||||
List<stDamage> m_lstDamageNumber;
|
||||
char m_strChatMessage[MAX_PATH];
|
||||
float m_fChatTimer;
|
||||
|
||||
BOOL m_bCharDead;
|
||||
|
||||
BOOL m_bUpperAble;
|
||||
BOOL m_bLowerAble;
|
||||
unsigned long m_dwLowerChrAction;
|
||||
unsigned long m_dwUpperChrAction;
|
||||
BOOL m_bUpperAnimating;
|
||||
BOOL m_bLowerAnimating;
|
||||
|
||||
//arrow
|
||||
vector<CCreatureArrow *> m_Arrow;
|
||||
bool m_bArrowExist;
|
||||
//body effect
|
||||
vector<CCreatureEffect *> m_BodyEffect;
|
||||
bool m_bBodyEffect;
|
||||
//Weapon effect
|
||||
vector<CWeaponEffect *> m_WeaponEffect;
|
||||
bool m_bWeaponEffect;
|
||||
|
||||
// slide character 관련
|
||||
CEffScript::CEffExt6 m_SlideValue;
|
||||
bool m_bSlide;
|
||||
|
||||
CWeaponLine *m_pWeaponLine;
|
||||
bool m_bWeaponLine;
|
||||
|
||||
DWORD m_dwTargetId; // Target Id (몬스터 이팩트 관련 처리)
|
||||
|
||||
|
||||
void SetSlideValue(CEffScript::CEffExt6 );
|
||||
void PlaySlide();
|
||||
void RenderSlide(float bx,float by,float bz,float nx,float ny,float nz,float unitsize);
|
||||
//
|
||||
CCreature();
|
||||
virtual ~CCreature();
|
||||
|
||||
void ArrowUpdate();
|
||||
void ArrowUpdate(int );
|
||||
void AddArrow(char *pivot_name,D3DXQUATERNION rot,int div = 0);
|
||||
void DeleteArrow(int );
|
||||
// WeaponLine
|
||||
void SetWeaponLine(LPDIRECT3DTEXTURE8 lpTexture,int iColor[3],int iBlend);
|
||||
void DeleteWeaponLine();
|
||||
void WeaponLineUpdate();
|
||||
|
||||
///////////body effect///////////
|
||||
// 캐릭 pos 에 effect 붙일경우
|
||||
void AddBodyEffect(char *esfname,unsigned long effid = 0,bool mine = true,bool bVisibility = true);
|
||||
// pivot 중에 렌덤 하게 num 갯수 만큼 effect 붙임 (num 값이 -1이면 전 pivot 에 다 붙임)
|
||||
void AddBodyEffect(char *file = NULL,bool rot = false,unsigned long effid = 0,int num = -1);
|
||||
// pivot 하나에 effect 붙임
|
||||
void AddBodyEffect(char *file = NULL,char *pivot = NULL,bool rot = false,unsigned long effid = 0);
|
||||
void AddBodyEffect(char *file = NULL,int pivotindex = -1,bool rot = false,unsigned long effid = 0);
|
||||
//현재 body effect list안에 이 이팩트가 존재 하는지 검사
|
||||
bool CheckInBodyEffect(char *file);
|
||||
|
||||
void RenderSnap(float bx,float by,float bz,float nx,float ny,float nz,float unitsize,char *effname);
|
||||
|
||||
|
||||
void DeleteBodyEffect(); // 전 effect delete
|
||||
void DeleteBodyEffect(char *pivot); // 한 pivot에 붙은 effect delete
|
||||
void DeleteBodyEffectName(char *effectname); //effect script 이름에 따라 delete
|
||||
void DeleteBodyEffect(unsigned long id); //effect id로 delete
|
||||
|
||||
void BodyEffectUpdate(int index);
|
||||
void BodyEffectUpdate();
|
||||
void SetEffect(); // monster 관련 GCMDS에서 effect 불러 붙이는 코드
|
||||
|
||||
//////////Weapon Effect////////
|
||||
|
||||
void AddWeaponEffect(char *esfname,int effectnum);
|
||||
|
||||
void DeleteWeaponEffect(); //전 weapon effect delete
|
||||
void DeleteWeaponEffect(char *esfname,int iEffNum); //esfname을 가지는 effect delete
|
||||
|
||||
void WeaponEffectUpdate();
|
||||
|
||||
////////////////////////////////
|
||||
// Visibility 관련 //
|
||||
////////////////////////////////
|
||||
void SetEffectVisibility(bool vis);
|
||||
|
||||
|
||||
void SetPosition(float fPosX, float fPosY, float fPosZ)
|
||||
{
|
||||
m_vecPos.x = fPosX; m_vecPos.y = fPosY; m_vecPos.z = fPosZ;
|
||||
if(m_lpChrModel)
|
||||
m_lpChrModel->SetPosition(m_vecPos.x, m_vecPos.y, m_vecPos.z);
|
||||
}
|
||||
void SetPosition(vector3 &vecPos)
|
||||
{
|
||||
m_vecPos = vecPos;
|
||||
if(m_lpChrModel)
|
||||
m_lpChrModel->SetPosition(m_vecPos.x, m_vecPos.y, m_vecPos.z);
|
||||
}
|
||||
vector3 *GetPosition(void)
|
||||
{
|
||||
if(m_lpChrModel)
|
||||
m_lpChrModel->GetPosition(m_vecPos);
|
||||
return &m_vecPos;
|
||||
}
|
||||
void SetDirection(float fDirection)
|
||||
{
|
||||
m_fDirection=fDirection;
|
||||
if(m_lpChrModel)
|
||||
m_lpChrModel->SetDirection(fDirection);
|
||||
}
|
||||
float GetDirection(void)
|
||||
{
|
||||
if(m_lpChrModel)
|
||||
m_fDirection=m_lpChrModel->GetDirection();
|
||||
return m_fDirection;
|
||||
}
|
||||
void SetAlphaLevel(float fAlphaFactor) { m_lpChrModel->SetAlphaLevel(fAlphaFactor); }
|
||||
BOOL GetChantFlag(unsigned long dwChantKind)
|
||||
{
|
||||
if(0 < dwChantKind && dwChantKind < 33)
|
||||
{
|
||||
if(m_dwChant & (0x00000001 << (dwChantKind - 1))) return TRUE; else return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_CREATURE_H__0C16A3E3_6308_4E72_AFF8_1CFE85324B6D__INCLUDED_)
|
||||
19
GameTools/CHARACTERACTIONCONTROL/CreatureSize.cpp
Normal file
19
GameTools/CHARACTERACTIONCONTROL/CreatureSize.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
// CreatureSize.cpp: implementation of the CCreatureSize class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CreatureSize.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CCreatureSize::CCreatureSize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CCreatureSize::~CCreatureSize()
|
||||
{
|
||||
|
||||
}
|
||||
503
GameTools/CHARACTERACTIONCONTROL/CreatureSize.h
Normal file
503
GameTools/CHARACTERACTIONCONTROL/CreatureSize.h
Normal file
@@ -0,0 +1,503 @@
|
||||
// CreatureSize.h: interface for the CCreatureSize class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_CREATURESIZE_H__BBEA8409_2ADF_4341_B6EB_3D7628A334F9__INCLUDED_)
|
||||
#define AFX_CREATURESIZE_H__BBEA8409_2ADF_4341_B6EB_3D7628A334F9__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class CCreatureSize
|
||||
{
|
||||
public:
|
||||
vector3 vecMonsterMinBox[200];
|
||||
vector3 vecMonsterMaxBox[200];
|
||||
|
||||
CCreatureSize()
|
||||
{
|
||||
|
||||
vecMonsterMinBox[1]=vector3(-35.0f, 0.0f, -55.0f);
|
||||
vecMonsterMaxBox[1]=vector3(35.0f, 0.0f, 65.0f);
|
||||
|
||||
vecMonsterMinBox[2]=vector3(-42.0f, 0.0f, -66.0f);
|
||||
vecMonsterMaxBox[2]=vector3(42.0f, 0.0f, 78.0f);
|
||||
|
||||
vecMonsterMinBox[3]=vector3(-49.0f, 0.0f, -77.0f);
|
||||
vecMonsterMaxBox[3]=vector3(49.0f, 0.0f, 91.0f);
|
||||
|
||||
vecMonsterMinBox[4]=vector3(-49.0f, 0.0f, -77.0f);
|
||||
vecMonsterMaxBox[4]=vector3(49.0f, 0.0f, 91.0f);
|
||||
|
||||
vecMonsterMinBox[5]=vector3(-49.0f, 0.0f, -77.0f);
|
||||
vecMonsterMaxBox[5]=vector3(49.0f, 0.0f, 91.0f);
|
||||
|
||||
vecMonsterMinBox[6]=vector3(-49.0f, 0.0f, -77.0f);
|
||||
vecMonsterMaxBox[6]=vector3(49.0f, 0.0f, 91.0f);
|
||||
|
||||
vecMonsterMinBox[7]=vector3(-56.0f, 0.0f, -88.0f);
|
||||
vecMonsterMaxBox[7]=vector3(56.0f, 0.0f, 104.0f);
|
||||
|
||||
vecMonsterMinBox[8]=vector3(-56.0f, 0.0f, -88.0f);
|
||||
vecMonsterMaxBox[8]=vector3(56.0f, 0.0f, 104.0f);
|
||||
|
||||
vecMonsterMinBox[9]=vector3(-32.0f, 0.0f, -40.0f);
|
||||
vecMonsterMaxBox[9]=vector3(32.0f, 0.0f, 40.0f);
|
||||
|
||||
vecMonsterMinBox[10]=vector3(-45.0f, 0.0f, -35.0f);
|
||||
vecMonsterMaxBox[10]=vector3(35.0f, 0.0f, 55.0f);
|
||||
|
||||
vecMonsterMinBox[11]=vector3(-40.0f, 0.0f, -25.0f);
|
||||
vecMonsterMaxBox[11]=vector3(40.0f, 0.0f, 25.0f);
|
||||
|
||||
vecMonsterMinBox[12]=vector3(-40.0f, 0.0f, -55.0f);
|
||||
vecMonsterMaxBox[12]=vector3(30.0f, 0.0f, 20.0f);
|
||||
|
||||
vecMonsterMinBox[13]=vector3(-40.0f, 0.0f, -55.0f);
|
||||
vecMonsterMaxBox[13]=vector3(30.0f, 0.0f, 20.0f);
|
||||
|
||||
vecMonsterMinBox[14]=vector3(-49.5f, 0.0f, -38.5f);
|
||||
vecMonsterMaxBox[14]=vector3(38.5f, 0.0f, 60.5f);
|
||||
|
||||
vecMonsterMinBox[15]=vector3(-44.0f, 0.0f, -27.5f);
|
||||
vecMonsterMaxBox[15]=vector3(44.0f, 0.0f, 27.5f);
|
||||
|
||||
vecMonsterMinBox[16]=vector3(-44.0f, 0.0f, -60.5f);
|
||||
vecMonsterMaxBox[16]=vector3(33.0f, 0.0f, 22.0f);
|
||||
|
||||
vecMonsterMinBox[17]=vector3(-44.0f, 0.0f, -60.5f);
|
||||
vecMonsterMaxBox[17]=vector3(33.0f, 0.0f, 22.0f);
|
||||
|
||||
vecMonsterMinBox[18]=vector3(-54.0f, 0.0f, -42.0f);
|
||||
vecMonsterMaxBox[18]=vector3(42.0f, 0.0f, 66.0f);
|
||||
|
||||
vecMonsterMinBox[19]=vector3(-48.0f, 0.0f, -30.0f);
|
||||
vecMonsterMaxBox[19]=vector3(48.0f, 0.0f, 30.0f);
|
||||
|
||||
vecMonsterMinBox[20]=vector3(-50.0f, 0.0f, -25.0f);
|
||||
vecMonsterMaxBox[20]=vector3(65.0f, 0.0f, 155.0f);
|
||||
|
||||
vecMonsterMinBox[21]=vector3(-48.0f, 0.0f, -66.0f);
|
||||
vecMonsterMaxBox[21]=vector3(36.0f, 0.0f, 24.0f);
|
||||
|
||||
vecMonsterMinBox[22]=vector3(-48.0f, 0.0f, -66.0f);
|
||||
vecMonsterMaxBox[22]=vector3(36.0f, 0.0f, 24.0f);
|
||||
|
||||
vecMonsterMinBox[23]=vector3(-30.0f, 0.0f, -15.0f);
|
||||
vecMonsterMaxBox[23]=vector3(35.0f, 0.0f, 150.0f);
|
||||
|
||||
vecMonsterMinBox[24]=vector3(-25.0f, 0.0f, -20.0f);
|
||||
vecMonsterMaxBox[24]=vector3(25.0f, 0.0f, 35.0f);
|
||||
|
||||
vecMonsterMinBox[25]=vector3(-20.0f, 0.0f, -70.0f);
|
||||
vecMonsterMaxBox[25]=vector3(15.0f, 0.0f, 55.0f);
|
||||
|
||||
vecMonsterMinBox[26]=vector3(-95.0f, 0.0f, -80.0f);
|
||||
vecMonsterMaxBox[26]=vector3(95.0f, 0.0f, 100.0f);
|
||||
|
||||
vecMonsterMinBox[27]=vector3(-36.0f, 0.0f, -18.0f);
|
||||
vecMonsterMaxBox[27]=vector3(42.0f, 0.0f, 180.0f);
|
||||
|
||||
vecMonsterMinBox[28]=vector3(-35.0f, 0.0f, -17.5f);
|
||||
vecMonsterMaxBox[28]=vector3(24.5f, 0.0f, 45.5f);
|
||||
|
||||
vecMonsterMinBox[29]=vector3(-30.0f, 0.0f, -24.0f);
|
||||
vecMonsterMaxBox[29]=vector3(30.0f, 0.0f, 42.0f);
|
||||
|
||||
vecMonsterMinBox[30]=vector3(-24.0f, 0.0f, -84.0f);
|
||||
vecMonsterMaxBox[30]=vector3(18.0f, 0.0f, 66.0f);
|
||||
|
||||
vecMonsterMinBox[31]=vector3(-142.5f, 0.0f, -120.0f);
|
||||
vecMonsterMaxBox[31]=vector3(142.5f, 0.0f, 150.0f);
|
||||
|
||||
vecMonsterMinBox[32]=vector3(-50.0f, 0.0f, -25.0f);
|
||||
vecMonsterMaxBox[32]=vector3(35.0f, 0.0f, 65.0f);
|
||||
|
||||
vecMonsterMinBox[33]=vector3(-190.0f, 0.0f, -160.0f);
|
||||
vecMonsterMaxBox[33]=vector3(190.0f, 0.0f, 200.0f);
|
||||
|
||||
vecMonsterMinBox[34]=vector3(-60.0f, 0.0f, -30.0f);
|
||||
vecMonsterMaxBox[34]=vector3(42.0f, 0.0f, 78.0f);
|
||||
|
||||
vecMonsterMinBox[35]=vector3(-120.0f, 0.0f, -115.0f);
|
||||
vecMonsterMaxBox[35]=vector3(95.0f, 0.0f, 120.0f);
|
||||
|
||||
vecMonsterMinBox[36]=vector3(-90.0f, 0.0f, -120.0f);
|
||||
vecMonsterMaxBox[36]=vector3(90.0f, 0.0f, 80.0f);
|
||||
|
||||
vecMonsterMinBox[37]=vector3(-45.0f, 0.0f, -165.0f);
|
||||
vecMonsterMaxBox[37]=vector3(55.0f, 0.0f, 80.0f);
|
||||
|
||||
vecMonsterMinBox[38]=vector3(-45.0f, 0.0f, -180.0f);
|
||||
vecMonsterMaxBox[38]=vector3(50.0f, 0.0f, 90.0f);
|
||||
|
||||
vecMonsterMinBox[39]=vector3(-45.0f, 0.0f, -180.0f);
|
||||
vecMonsterMaxBox[39]=vector3(50.0f, 0.0f, 90.0f);
|
||||
|
||||
vecMonsterMinBox[40]=vector3(-35.0f, 0.0f, -28.0f);
|
||||
vecMonsterMaxBox[40]=vector3(35.0f, 0.0f, 49.0f);
|
||||
|
||||
vecMonsterMinBox[41]=vector3(-60.0f, 0.0f, -30.0f);
|
||||
vecMonsterMaxBox[41]=vector3(42.0f, 0.0f, 78.0f);
|
||||
|
||||
vecMonsterMinBox[42]=vector3(-44.0f, 0.0f, -55.0f);
|
||||
vecMonsterMaxBox[42]=vector3(44.0f, 0.0f, 55.0f);
|
||||
|
||||
vecMonsterMinBox[43]=vector3(-78.0f, 0.0f, -72.0f);
|
||||
vecMonsterMaxBox[43]=vector3(60.0f, 0.0f, 78.0f);
|
||||
|
||||
vecMonsterMinBox[44]=vector3(-108.0f, 0.0f, -144.0f);
|
||||
vecMonsterMaxBox[44]=vector3(108.0f, 0.0f, 96.0f);
|
||||
|
||||
vecMonsterMinBox[45]=vector3(-54.0f, 0.0f, -198.0f);
|
||||
vecMonsterMaxBox[45]=vector3(66.0f, 0.0f, 96.0f);
|
||||
|
||||
vecMonsterMinBox[46]=vector3(-54.0f, 0.0f, -216.0f);
|
||||
vecMonsterMaxBox[46]=vector3(60.0f, 0.0f, 108.0f);
|
||||
|
||||
vecMonsterMinBox[47]=vector3(-54.0f, 0.0f, -216.0f);
|
||||
vecMonsterMaxBox[47]=vector3(60.0f, 0.0f, 108.0f);
|
||||
|
||||
vecMonsterMinBox[48]=vector3(-70.0f, 0.0f, -35.0f);
|
||||
vecMonsterMaxBox[48]=vector3(49.0f, 0.0f, 91.0f);
|
||||
|
||||
vecMonsterMinBox[49]=vector3(-168.0f, 0.0f, -161.0f);
|
||||
vecMonsterMaxBox[49]=vector3(133.0f, 0.0f, 168.0f);
|
||||
|
||||
vecMonsterMinBox[50]=vector3(-20.0f, 0.0f, -45.0f);
|
||||
vecMonsterMaxBox[50]=vector3(20.0f, 0.0f, 140.0f);
|
||||
|
||||
vecMonsterMinBox[51]=vector3(-55.0f, 0.0f, -200.0f);
|
||||
vecMonsterMaxBox[51]=vector3(45.0f, 0.0f, 60.0f);
|
||||
|
||||
vecMonsterMinBox[52]=vector3(-55.0f, 0.0f, -200.0f);
|
||||
vecMonsterMaxBox[52]=vector3(45.0f, 0.0f, 60.0f);
|
||||
|
||||
vecMonsterMinBox[53]=vector3(-55.0f, 0.0f, -200.0f);
|
||||
vecMonsterMaxBox[53]=vector3(45.0f, 0.0f, 60.0f);
|
||||
|
||||
vecMonsterMinBox[54]=vector3(-20.0f, 0.0f, -45.0f);
|
||||
vecMonsterMaxBox[54]=vector3(20.0f, 0.0f, 140.0f);
|
||||
|
||||
vecMonsterMinBox[55]=vector3(-96.0f, 0.0f, -90.0f);
|
||||
vecMonsterMaxBox[55]=vector3(96.0f, 0.0f, 108.0f);
|
||||
|
||||
vecMonsterMinBox[56]=vector3(-55.0f, 0.0f, -200.0f);
|
||||
vecMonsterMaxBox[56]=vector3(45.0f, 0.0f, 60.0f);
|
||||
|
||||
vecMonsterMinBox[57]=vector3(-55.0f, 0.0f, -200.0f);
|
||||
vecMonsterMaxBox[57]=vector3(45.0f, 0.0f, 60.0f);
|
||||
|
||||
vecMonsterMinBox[58]=vector3(-55.0f, 0.0f, -200.0f);
|
||||
vecMonsterMaxBox[58]=vector3(45.0f, 0.0f, 60.0f);
|
||||
|
||||
vecMonsterMinBox[59]=vector3(-20.0f, 0.0f, -45.0f);
|
||||
vecMonsterMaxBox[59]=vector3(20.0f, 0.0f, 145.0f);
|
||||
|
||||
vecMonsterMinBox[60]=vector3(-28.0f, 0.0f, -63.0f);
|
||||
vecMonsterMaxBox[60]=vector3(28.0f, 0.0f, 203.0f);
|
||||
|
||||
vecMonsterMinBox[61]=vector3(-60.0f, 0.0f, -75.0f);
|
||||
vecMonsterMaxBox[61]=vector3(60.0f, 0.0f, 75.0f);
|
||||
|
||||
vecMonsterMinBox[62]=vector3(-126.0f, 0.0f, -168.0f);
|
||||
vecMonsterMaxBox[62]=vector3(126.0f, 0.0f, 112.0f);
|
||||
|
||||
vecMonsterMinBox[63]=vector3(-63.0f, 0.0f, -231.0f);
|
||||
vecMonsterMaxBox[63]=vector3(77.0f, 0.0f, 112.0f);
|
||||
|
||||
vecMonsterMinBox[64]=vector3(-63.0f, 0.0f, -252.0f);
|
||||
vecMonsterMaxBox[64]=vector3(70.0f, 0.0f, 126.0f);
|
||||
|
||||
vecMonsterMinBox[65]=vector3(-63.0f,0.0f, -252.0f);
|
||||
vecMonsterMaxBox[65]=vector3(70.0f, 0.0f, 126.0f);
|
||||
|
||||
vecMonsterMinBox[66]=vector3(-70.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[66]=vector3(70.0f, 0.0f, 70.0f);
|
||||
|
||||
vecMonsterMinBox[67]=vector3(-70.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[67]=vector3(70.0f, 0.0f, 70.0f);
|
||||
|
||||
vecMonsterMinBox[68]=vector3(-112.0f,0.0f, -105.0f);
|
||||
vecMonsterMaxBox[68]=vector3(112.0f, 0.0f, 126.0f);
|
||||
|
||||
vecMonsterMinBox[69]=vector3(-70.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[69]=vector3(70.0f, 0.0f, 70.0f);
|
||||
|
||||
vecMonsterMinBox[70]=vector3(-70.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[70]=vector3(70.0f, 0.0f, 70.0f);
|
||||
|
||||
vecMonsterMinBox[71]=vector3(-119.0f,0.0f, -49.0f);
|
||||
vecMonsterMaxBox[71]=vector3(119.0f, 0.0f, 189.0f);
|
||||
|
||||
vecMonsterMinBox[72]=vector3(-168.0f,0.0f, -184.0f);
|
||||
vecMonsterMaxBox[72]=vector3(88.0f, 0.0f, 192.0f);
|
||||
|
||||
vecMonsterMinBox[73]=vector3(-25.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[73]=vector3(20.0f, 0.0f, 40.0f);
|
||||
|
||||
vecMonsterMinBox[74]=vector3(-75.0f,0.0f, -110.0f);
|
||||
vecMonsterMaxBox[74]=vector3(60.0f, 0.0f, 90.0f);
|
||||
|
||||
vecMonsterMinBox[75]=vector3(-75.0f,0.0f, -110.0f);
|
||||
vecMonsterMaxBox[75]=vector3(60.0f, 0.0f, 90.0f);
|
||||
|
||||
vecMonsterMinBox[76]=vector3(-25.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[76]=vector3(20.0f, 0.0f, 40.0f);
|
||||
|
||||
vecMonsterMinBox[77]=vector3(-65.0f,0.0f, -50.0f);
|
||||
vecMonsterMaxBox[77]=vector3(75.0f, 0.0f, 75.0f);
|
||||
|
||||
vecMonsterMinBox[78]=vector3(-70.0f,0.0f, -90.0f);
|
||||
vecMonsterMaxBox[78]=vector3(30.0f, 0.0f, 45.0f);
|
||||
|
||||
vecMonsterMinBox[79]=vector3(-65.0f,0.0f, -50.0f);
|
||||
vecMonsterMaxBox[79]=vector3(75.0f, 0.0f, 75.0f);
|
||||
|
||||
vecMonsterMinBox[80]=vector3(-65.0f,0.0f, -50.0f);
|
||||
vecMonsterMaxBox[80]=vector3(75.0f, 0.0f, 75.0f);
|
||||
|
||||
vecMonsterMinBox[81]=vector3(-80.0f,0.0f, -65.0f);
|
||||
vecMonsterMaxBox[81]=vector3(100.0f, 0.0f, 85.0f);
|
||||
|
||||
vecMonsterMinBox[82]=vector3(-55.0f,0.0f, -45.0f);
|
||||
vecMonsterMaxBox[82]=vector3(55.0f, 0.0f, 70.0f);
|
||||
|
||||
vecMonsterMinBox[83]=vector3(-55.0f,0.0f, -45.0f);
|
||||
vecMonsterMaxBox[83]=vector3(55.0f, 0.0f, 70.0f);
|
||||
|
||||
vecMonsterMinBox[84]=vector3(-20.0f,0.0f, -70.0f);
|
||||
vecMonsterMaxBox[84]=vector3(15.0f, 0.0f, 55.0f);
|
||||
|
||||
vecMonsterMinBox[85]=vector3(-58.5f,0.0f, -36.0f);
|
||||
vecMonsterMaxBox[85]=vector3(108.0f, 0.0f, 144.0f);
|
||||
|
||||
vecMonsterMinBox[86]=vector3(-71.5f,0.0f, -44.0f);
|
||||
vecMonsterMaxBox[86]=vector3(132.0f, 0.0f, 176.0f);
|
||||
|
||||
vecMonsterMinBox[87]=vector3(-24.0f,0.0f, -84.0f);
|
||||
vecMonsterMaxBox[87]=vector3(18.0f, 0.0f, 66.0f);
|
||||
|
||||
vecMonsterMinBox[88]=vector3(-240.0f,0.0f, -230.0f);
|
||||
vecMonsterMaxBox[88]=vector3(190.0f, 0.0f, 240.0f);
|
||||
|
||||
vecMonsterMinBox[89]=vector3(-22.5f,0.0f, -52.5f);
|
||||
vecMonsterMaxBox[89]=vector3(22.5f, 0.0f, 127.5f);
|
||||
|
||||
vecMonsterMinBox[90]=vector3(-66.0f,0.0f, -11.0f);
|
||||
vecMonsterMaxBox[90]=vector3(82.5f, 0.0f, 66.0f);
|
||||
|
||||
vecMonsterMinBox[91]=vector3(-78.0f,0.0f, -72.0f);
|
||||
vecMonsterMaxBox[91]=vector3(60.0f, 0.0f, 78.0f);
|
||||
|
||||
vecMonsterMinBox[92]=vector3(-98.0f,0.0f, -91.0f);
|
||||
vecMonsterMaxBox[92]=vector3(147.0f, 0.0f, 140.0f);
|
||||
|
||||
vecMonsterMinBox[93]=vector3(-55.0f,0.0f, -45.0f);
|
||||
vecMonsterMaxBox[93]=vector3(55.0f, 0.0f, 70.0f);
|
||||
|
||||
vecMonsterMinBox[94]=vector3(-91.0f,0.0f, -56.0f);
|
||||
vecMonsterMaxBox[94]=vector3(168.0f, 0.0f, 224.0f);
|
||||
|
||||
vecMonsterMinBox[95]=vector3(-150.0f,0.0f, -65.0f);
|
||||
vecMonsterMaxBox[95]=vector3(105.0f, 0.0f, 160.0f);
|
||||
|
||||
vecMonsterMinBox[96]=vector3(-130.0f,0.0f, -80.0f);
|
||||
vecMonsterMaxBox[96]=vector3(240.0f, 0.0f, 320.0f);
|
||||
|
||||
vecMonsterMinBox[97]=vector3(-45.0f,0.0f, -105.0f);
|
||||
vecMonsterMaxBox[97]=vector3(45.0f, 0.0f, 255.0f);
|
||||
|
||||
vecMonsterMinBox[98]=vector3(-150.0f,0.0f, -65.0f);
|
||||
vecMonsterMaxBox[98]=vector3(105.0f, 0.0f, 160.0f);
|
||||
|
||||
vecMonsterMinBox[99]=vector3(-130.0f,0.0f, -55.0f);
|
||||
vecMonsterMaxBox[99]=vector3(80.0f, 0.0f, 130.0f);
|
||||
|
||||
vecMonsterMinBox[100]=vector3(-115.0f,0.0f, -55.0f);
|
||||
vecMonsterMaxBox[100]=vector3(80.0f, 0.0f, 75.0f);
|
||||
|
||||
vecMonsterMinBox[101]=vector3(-180.0f,0.0f, -78.0f);
|
||||
vecMonsterMaxBox[101]=vector3(126.0f, 0.0f, 192.0f);
|
||||
|
||||
vecMonsterMinBox[102]=vector3(-156.0f,0.0f, -66.0f);
|
||||
vecMonsterMaxBox[102]=vector3(96.0f, 0.0f, 156.0f);
|
||||
|
||||
vecMonsterMinBox[103]=vector3(-96.0f,0.0f, -16.0f);
|
||||
vecMonsterMaxBox[103]=vector3(120.0f, 0.0f, 96.0f);
|
||||
|
||||
vecMonsterMinBox[104]=vector3(-138.0f,0.0f, -66.0f);
|
||||
vecMonsterMaxBox[104]=vector3(96.0f, 0.0f, 90.0f);
|
||||
|
||||
vecMonsterMinBox[105]=vector3(-50.0f,0.0f, -25.0f);
|
||||
vecMonsterMaxBox[105]=vector3(60.0f, 0.0f, 130.0f);
|
||||
|
||||
vecMonsterMinBox[106]=vector3(-50.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[106]=vector3(45.0f, 0.0f, 40.0f);
|
||||
|
||||
vecMonsterMinBox[107]=vector3(-25.0f,0.0f, -35.0f);
|
||||
vecMonsterMaxBox[107]=vector3(25.0f, 0.0f, 150.0f);
|
||||
|
||||
vecMonsterMinBox[108]=vector3(-25.0f,0.0f, -35.0f);
|
||||
vecMonsterMaxBox[108]=vector3(25.0f, 0.0f, 150.0f);
|
||||
|
||||
vecMonsterMinBox[109]=vector3(-30.0f,0.0f, -35.0f);
|
||||
vecMonsterMaxBox[109]=vector3(40.0f, 0.0f, 60.0f);
|
||||
|
||||
vecMonsterMinBox[110]=vector3(-30.0f,0.0f, -35.0f);
|
||||
vecMonsterMaxBox[110]=vector3(40.0f, 0.0f, 60.0f);
|
||||
|
||||
vecMonsterMinBox[111]=vector3(-60.0f,0.0f, -30.0f);
|
||||
vecMonsterMaxBox[111]=vector3(72.0f, 0.0f, 156.0f);
|
||||
|
||||
vecMonsterMinBox[112]=vector3(-60.0f,0.0f, -24.0f);
|
||||
vecMonsterMaxBox[112]=vector3(54.0f, 0.0f, 48.0f);
|
||||
|
||||
vecMonsterMinBox[113]=vector3(-210.0f,0.0f, -91.0f);
|
||||
vecMonsterMaxBox[113]=vector3(147.0f, 0.0f, 224.0f);
|
||||
|
||||
vecMonsterMinBox[114]=vector3(-182.0f,0.0f, -77.0f);
|
||||
vecMonsterMaxBox[114]=vector3(112.0f, 0.0f, 182.0f);
|
||||
|
||||
vecMonsterMinBox[115]=vector3(-161.0f,0.0f, -77.0f);
|
||||
vecMonsterMaxBox[115]=vector3(112.0f, 0.0f, 105.0f);
|
||||
|
||||
vecMonsterMinBox[116]=vector3(-85.0f,0.0f, -110.0f);
|
||||
vecMonsterMaxBox[116]=vector3(85.0f, 0.0f, 230.0f);
|
||||
|
||||
vecMonsterMinBox[117]=vector3(-36.0f,0.0f, -42.0f);
|
||||
vecMonsterMaxBox[117]=vector3(48.0f, 0.0f, 72.0f);
|
||||
|
||||
vecMonsterMinBox[118]=vector3(-36.0f,0.0f, -42.0f);
|
||||
vecMonsterMaxBox[118]=vector3(48.0f, 0.0f, 72.0f);
|
||||
|
||||
vecMonsterMinBox[119]=vector3(-25.0f,0.0f, -35.0f);
|
||||
vecMonsterMaxBox[119]=vector3(25.0f, 0.0f, 150.0f);
|
||||
|
||||
vecMonsterMinBox[120]=vector3(-95.0f,0.0f, 0.0f);
|
||||
vecMonsterMaxBox[120]=vector3(95.0f, 0.0f, 165.0f);
|
||||
|
||||
vecMonsterMinBox[121]=vector3(-114.0f,0.0f, 0.0f);
|
||||
vecMonsterMaxBox[121]=vector3(114.0f, 0.0f, 198.0f);
|
||||
|
||||
vecMonsterMinBox[122]=vector3(-25.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[122]=vector3(20.0f, 0.0f, 40.0f);
|
||||
|
||||
vecMonsterMinBox[123]=vector3(-25.0f,0.0f, -20.0f);
|
||||
vecMonsterMaxBox[123]=vector3(20.0f, 0.0f, 40.0f);
|
||||
|
||||
vecMonsterMinBox[124]=vector3(-65.0f,0.0f, -50.0f);
|
||||
vecMonsterMaxBox[124]=vector3(75.0f, 0.0f, 75.0f);
|
||||
|
||||
vecMonsterMinBox[125]=vector3(-85.0f,0.0f, -110.0f);
|
||||
vecMonsterMaxBox[125]=vector3(85.0f, 0.0f, 230.0f);
|
||||
|
||||
vecMonsterMinBox[126]=vector3(-133.0f,0.0f, 0.0f);
|
||||
vecMonsterMaxBox[126]=vector3(133.0f, 0.0f, 231.0f);
|
||||
|
||||
vecMonsterMinBox[127]=vector3(-70.0f,0.0f, -35.0f);
|
||||
vecMonsterMaxBox[127]=vector3(84.0f, 0.0f, 182.0f);
|
||||
|
||||
vecMonsterMinBox[128]=vector3(-70.0f,0.0f, -28.0f);
|
||||
vecMonsterMaxBox[128]=vector3(63.0f, 0.0f, 56.0f);
|
||||
|
||||
vecMonsterMinBox[129]=vector3(-42.0f,0.0f, -49.0f);
|
||||
vecMonsterMaxBox[129]=vector3(56.0f, 0.0f, 84.0f);
|
||||
|
||||
vecMonsterMinBox[130]=vector3(-42.0f,0.0f, -49.0f);
|
||||
vecMonsterMaxBox[130]=vector3(56.0f, 0.0f, 84.0f);
|
||||
|
||||
vecMonsterMinBox[131]=vector3(-80.0f,0.0f, -40.0f);
|
||||
vecMonsterMaxBox[131]=vector3(96.0f, 0.0f, 208.0f);
|
||||
|
||||
vecMonsterMinBox[132]=vector3(-84.5f,0.0f, -78.0f);
|
||||
vecMonsterMaxBox[132]=vector3(65.0f, 0.0f, 84.5f);
|
||||
|
||||
vecMonsterMinBox[133]=vector3(-104.0f,0.0f, -96.0f);
|
||||
vecMonsterMaxBox[133]=vector3(80.0f, 0.0f, 104.0f);
|
||||
|
||||
vecMonsterMinBox[134]=vector3(-104.0f,0.0f, -96.0f);
|
||||
vecMonsterMaxBox[134]=vector3(80.0f, 0.0f, 104.0f);
|
||||
|
||||
vecMonsterMinBox[135]=vector3(-104.0f,0.0f, -96.0f);
|
||||
vecMonsterMaxBox[135]=vector3(80.0f, 0.0f, 104.0f);
|
||||
|
||||
vecMonsterMinBox[136]=vector3(-80.0f,0.0f, -70.0f);
|
||||
vecMonsterMaxBox[136]=vector3(70.0f, 0.0f, 145.0f);
|
||||
|
||||
vecMonsterMinBox[137]=vector3(-80.0f,0.0f, -55.0f);
|
||||
vecMonsterMaxBox[137]=vector3(60.0f, 0.0f, 115.0f);
|
||||
|
||||
vecMonsterMinBox[138]=vector3(-240.0f,0.0f, -262.5f);
|
||||
vecMonsterMaxBox[138]=vector3(405.0f, 0.0f, 225.0f);
|
||||
|
||||
vecMonsterMinBox[139]=vector3(-250.0f,0.0f, -205.0f);
|
||||
vecMonsterMaxBox[139]=vector3(195.0f, 0.0f, 135.0f);
|
||||
|
||||
vecMonsterMinBox[140]=vector3(-25.0f,0.0f, -25.0f);
|
||||
vecMonsterMaxBox[140]=vector3(25.0f, 0.0f, 25.0f);
|
||||
|
||||
vecMonsterMinBox[141]=vector3(-145.0f,0.0f, -280.0f);
|
||||
vecMonsterMaxBox[141]=vector3(135.0f, 0.0f, 230.0f);
|
||||
|
||||
vecMonsterMinBox[142]=vector3(-40.0f,0.0f, -90.0f);
|
||||
vecMonsterMaxBox[142]=vector3(40.0f, 0.0f, 280.0f);
|
||||
|
||||
vecMonsterMinBox[143]=vector3(-40.0f,0.0f, -90.0f);
|
||||
vecMonsterMaxBox[143]=vector3(40.0f, 0.0f, 290.0f);
|
||||
|
||||
vecMonsterMinBox[144]=vector3(-50.0f,0.0f, -70.0f);
|
||||
vecMonsterMaxBox[144]=vector3(50.0f, 0.0f, 300.0f);
|
||||
|
||||
vecMonsterMinBox[145]=vector3(-50.0f,0.0f, -70.0f);
|
||||
vecMonsterMaxBox[145]=vector3(50.0f, 0.0f, 300.0f);
|
||||
|
||||
vecMonsterMinBox[146]=vector3(-81.0f,0.0f, -108.0f);
|
||||
vecMonsterMaxBox[146]=vector3(81.0f, 0.0f, 72.0f);
|
||||
|
||||
vecMonsterMinBox[147]=vector3(-40.5f,0.0f, -148.5f);
|
||||
vecMonsterMaxBox[147]=vector3(49.5f, 0.0f, 72.0f);
|
||||
|
||||
vecMonsterMinBox[148]=vector3(-30.0f,0.0f, -37.5f);
|
||||
vecMonsterMaxBox[148]=vector3(30.0f, 0.0f, 37.5f);
|
||||
|
||||
vecMonsterMinBox[149]=vector3(-45.0f,0.0f, -22.5f);
|
||||
vecMonsterMaxBox[149]=vector3(58.5f, 0.0f, 139.5f);
|
||||
|
||||
vecMonsterMinBox[150]=vector3(-72.0f,0.0f, -67.5f);
|
||||
vecMonsterMaxBox[150]=vector3(72.0f, 0.0f, 81.0f);
|
||||
|
||||
vecMonsterMinBox[151]=vector3(-49.5f,0.0f, -180.0f);
|
||||
vecMonsterMaxBox[151]=vector3(40.5f, 0.0f, 54.0f);
|
||||
|
||||
vecMonsterMinBox[152]=vector3(-54.0f,0.0f, -9.0f);
|
||||
vecMonsterMaxBox[152]=vector3(67.5f, 0.0f, 54.0f);
|
||||
|
||||
vecMonsterMinBox[153]=vector3(-84.0f,0.0f, -78.0f);
|
||||
vecMonsterMaxBox[153]=vector3(126.0f, 0.0f, 120.0f);
|
||||
|
||||
vecMonsterMinBox[154]=vector3(-96.0f,0.0f, -84.0f);
|
||||
vecMonsterMaxBox[154]=vector3(84.0f, 0.0f, 174.0f);
|
||||
|
||||
vecMonsterMinBox[155]=vector3(-96.0f,0.0f, -66.0f);
|
||||
vecMonsterMaxBox[155]=vector3(72.0f, 0.0f, 138.0f);
|
||||
|
||||
vecMonsterMinBox[156]=vector3(-95.0f,0.0f, 0.0f);
|
||||
vecMonsterMaxBox[156]=vector3(95.0f, 0.0f, 165.0f);
|
||||
|
||||
vecMonsterMinBox[157]=vector3(-90.0f,0.0f, -120.0f);
|
||||
vecMonsterMaxBox[157]=vector3(90.0f, 0.0f, 80.0f);
|
||||
|
||||
vecMonsterMinBox[158]=vector3(-45.0f,0.0f, -165.0f);
|
||||
vecMonsterMaxBox[158]=vector3(55.0f, 0.0f, 80.0f);
|
||||
|
||||
vecMonsterMinBox[159]=vector3(-45.0f,0.0f, -22.5f);
|
||||
vecMonsterMaxBox[159]=vector3(58.5f, 0.0f, 139.5f);
|
||||
|
||||
}
|
||||
|
||||
~CCreatureSize() { }
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_CREATURESIZE_H__BBEA8409_2ADF_4341_B6EB_3D7628A334F9__INCLUDED_)
|
||||
202
GameTools/CaldronBase/Base.vcproj
Normal file
202
GameTools/CaldronBase/Base.vcproj
Normal file
@@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="Base"
|
||||
ProjectGUID="{C1552555-C254-4B21-8FE1-457F2494F4F7}"
|
||||
SccProjectName="SAK"
|
||||
SccAuxPath="SAK"
|
||||
SccLocalPath="SAK"
|
||||
SccProvider="SAK"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Base.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Base.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="소스 파일"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\BaseCacheMgr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ByteDataObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Caldron.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\D3D9GraphicLayer.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DInput8Mgr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ExceptionMgr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\LoadedObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\LogMgr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\MemoryPool.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ProfileMgr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ResourceLoader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Timer.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="헤더 파일"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\BaseCacheMgr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ByteDataObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\Include\Caldron.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\D3D9GraphicLayer.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DInput8Mgr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ExceptionMgr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\LoadedObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\LogMgr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\MemoryPool.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ProfileMgr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ResourceLoader.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ThreadQueue.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Timer.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="리소스 파일"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
10
GameTools/CaldronBase/Base.vcproj.vspscc
Normal file
10
GameTools/CaldronBase/Base.vcproj.vspscc
Normal file
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||
}
|
||||
29
GameTools/CaldronBase/BaseCacheMgr.cpp
Normal file
29
GameTools/CaldronBase/BaseCacheMgr.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* CBaseCacheMgr , CCacheObj
|
||||
|
||||
* 파일 : BaseCacheMgr.cpp
|
||||
* 기능 : Caldron엔진 내부에서 사용되는 모든 CacheMgr들의 어미 class
|
||||
* history :
|
||||
2004.01.16 wizardbug
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#include "BaseCacheMgr.h"
|
||||
|
||||
namespace Caldron {namespace Base {
|
||||
|
||||
unsigned long CBaseCacheMgr::GetHashID(const char *strFileName)
|
||||
{
|
||||
unsigned long ulHashId = 0;
|
||||
|
||||
int iLength = (int)strlen(strFileName);
|
||||
|
||||
for(int i=0;i < iLength; i++) {
|
||||
ulHashId += (( i + 1) * strFileName[i]);
|
||||
}
|
||||
return ulHashId;
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
120
GameTools/CaldronBase/BaseCacheMgr.h
Normal file
120
GameTools/CaldronBase/BaseCacheMgr.h
Normal file
@@ -0,0 +1,120 @@
|
||||
|
||||
#if !defined(AFX_BASECACHEMGR_H__C53D076B_14CF_47B5_B21C_F7EF3477C7EA__INCLUDED_)
|
||||
#define AFX_BASECACHEMGR_H__C53D076B_14CF_47B5_B21C_F7EF3477C7EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#pragma warning( disable : 4786 )
|
||||
#include "./Caldron.h"
|
||||
#include "./LoadedObj.h"
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
/* *********************************************************************
|
||||
|
||||
* CCacheObj
|
||||
|
||||
* 파일 : BaseCacheMgr.h
|
||||
* 기능 : Caldron엔진 내부에서 사용되는 CacheMgr에서 data 가 다뤄지는 단위
|
||||
* history :
|
||||
2004.01.16 wizardbug
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
class CCacheObj {
|
||||
public:
|
||||
std::vector<CLoadedObj *> m_lstDatas;
|
||||
int m_iDatasNum;
|
||||
CCacheObj() : m_iDatasNum(0)
|
||||
{
|
||||
m_lstDatas.clear();
|
||||
}
|
||||
CCacheObj(CLoadedObj *pObj) : m_iDatasNum(0)
|
||||
{
|
||||
m_lstDatas.clear();
|
||||
m_lstDatas.push_back(pObj);
|
||||
m_iDatasNum++;
|
||||
}
|
||||
void Add_Back(CLoadedObj *pObj)
|
||||
{
|
||||
m_lstDatas.push_back(pObj);
|
||||
m_iDatasNum++;
|
||||
}
|
||||
~CCacheObj() {
|
||||
if(m_iDatasNum > 0)
|
||||
{
|
||||
for(int i=0;i < m_iDatasNum; i++)
|
||||
{
|
||||
if(m_lstDatas[i])
|
||||
{
|
||||
SafeDelete(m_lstDatas[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_iDatasNum = 0;
|
||||
m_lstDatas.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
typedef std::map<unsigned long , CCacheObj *> CACHETABLE;
|
||||
typedef CACHETABLE::value_type CACHETABLEOBJ;
|
||||
typedef CACHETABLE::iterator CACHEITER;
|
||||
/* *********************************************************************
|
||||
|
||||
* CBaseCacheMgr
|
||||
|
||||
* 파일 : BaseCacheMgr.h
|
||||
* 기능 : Caldron엔진 내부에서 사용되는 모든 CacheMgr들의 어미 class
|
||||
* history :
|
||||
2004.01.16 wizardbug
|
||||
|
||||
********************************************************************** */
|
||||
const int DEFAULT_MAXCACHENUM = 100;
|
||||
|
||||
class CBaseCacheMgr
|
||||
{
|
||||
protected:
|
||||
unsigned long GetHashID(const char *strFileName);
|
||||
|
||||
CACHETABLE m_CacheTable;
|
||||
int m_iCachesNum;
|
||||
|
||||
|
||||
public:
|
||||
CBaseCacheMgr(): m_iCachesNum(0)
|
||||
{
|
||||
m_CacheTable.clear();
|
||||
}
|
||||
virtual ~CBaseCacheMgr()
|
||||
{
|
||||
if(m_iCachesNum > 0)
|
||||
{
|
||||
for(CACHEITER Itr = m_CacheTable.begin(); Itr != m_CacheTable.end();)
|
||||
{
|
||||
if(Itr->second != NULL)
|
||||
{
|
||||
SafeDelete(Itr->second);
|
||||
}
|
||||
|
||||
Itr++;
|
||||
}
|
||||
m_CacheTable.clear();
|
||||
m_iCachesNum = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
virtual void *GetData(const char *strFileName) = 0;
|
||||
virtual void *LoadData(const char *strFileName) = 0;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // !defined(AFX_BASECACHEMGR_H__C53D076B_14CF_47B5_B21C_F7EF3477C7EA__INCLUDED_)
|
||||
235
GameTools/CaldronBase/BaseObj.cpp
Normal file
235
GameTools/CaldronBase/BaseObj.cpp
Normal file
@@ -0,0 +1,235 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* CBaseObj
|
||||
|
||||
* 파일 : BaseObj.cpp
|
||||
* 기능 : Base Object 클래스 구현
|
||||
* history :
|
||||
2003.10.31 (yundi) 작성
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#include "BaseObj.h"
|
||||
|
||||
namespace Caldron{ namespace Base{
|
||||
|
||||
|
||||
int CBaseObj::ms_nTotalObjectCount = 0;
|
||||
|
||||
CBaseObj::CBaseObj( CBaseObj* pParentObj )
|
||||
{
|
||||
SetParent( NULL );
|
||||
SetPrevSibling( NULL );
|
||||
SetNextSibling( NULL );
|
||||
SetFirstChild( NULL );
|
||||
|
||||
EstablishLinkageToParent( pParentObj );
|
||||
|
||||
++ms_nTotalObjectCount;
|
||||
}
|
||||
|
||||
|
||||
CBaseObj::~CBaseObj()
|
||||
{
|
||||
// 일단 재귀적으로 구현했으나 비재귀적으로 수정해야할듯.
|
||||
if( NULL != GetFirstChild() )
|
||||
{
|
||||
CBaseObj* pObj = GetFirstChild()->GetLastSibling();
|
||||
while( pObj )
|
||||
{
|
||||
CBaseObj* pDeleteObj = pObj;
|
||||
pObj = pObj->GetPrevSibling();
|
||||
SafeDelete( pDeleteObj );
|
||||
}
|
||||
}
|
||||
|
||||
Unlink();
|
||||
|
||||
--ms_nTotalObjectCount;
|
||||
}
|
||||
|
||||
|
||||
CBaseObj* CBaseObj::GetParent()
|
||||
{
|
||||
return m_rpParent;
|
||||
}
|
||||
|
||||
|
||||
CBaseObj* CBaseObj::GetFirstChild()
|
||||
{
|
||||
return m_rpFirstChild;
|
||||
}
|
||||
|
||||
|
||||
CBaseObj* CBaseObj::GetPrevSibling()
|
||||
{
|
||||
return m_rpPrevSibling;
|
||||
}
|
||||
|
||||
|
||||
CBaseObj* CBaseObj::GetNextSibling()
|
||||
{
|
||||
return m_rpNextSibling;
|
||||
}
|
||||
|
||||
|
||||
bool CBaseObj::LinkToParent( CBaseObj* pParentObj )
|
||||
{
|
||||
if( pParentObj == GetParent() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
CBaseObj* pObj = pParentObj;
|
||||
while( NULL != pObj )
|
||||
{
|
||||
if( pObj == this )
|
||||
{
|
||||
// 자신의 자식 중 하나를 부모로 link하려고 시도한 경우
|
||||
return false;
|
||||
}
|
||||
|
||||
pObj = pObj->GetParent();
|
||||
}
|
||||
|
||||
if( !IsRoot() )
|
||||
{
|
||||
Unlink();
|
||||
}
|
||||
|
||||
EstablishLinkageToParent( pParentObj );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
CBaseObj* CBaseObj::GetLastSibling()
|
||||
{
|
||||
// 일단 안정성 측면에서 NULL 포인터 처리를 해 줬는데 이걸 계속 여기에 두는게 바람직한지는 모르겠다.
|
||||
if( NULL == this )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CBaseObj* pObj = this;
|
||||
|
||||
while( NULL != pObj->GetNextSibling() )
|
||||
{
|
||||
pObj = pObj->GetNextSibling();
|
||||
}
|
||||
|
||||
return pObj;
|
||||
}
|
||||
|
||||
|
||||
void CBaseObj::AddSiblingObj( CBaseObj* pObj )
|
||||
{
|
||||
CBaseObj* pLastSibling = GetLastSibling();
|
||||
|
||||
// establish mutual linkage
|
||||
pLastSibling->SetNextSibling( pObj );
|
||||
pObj->SetPrevSibling( pLastSibling );
|
||||
}
|
||||
|
||||
|
||||
void CBaseObj::Unlink()
|
||||
{
|
||||
// 부모와 sibling으로의 링크로부터 분리해 스스로가 root 가 됨
|
||||
if( IsRoot() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( GetParent()->GetFirstChild() == this )
|
||||
{
|
||||
GetParent()->SetFirstChild( GetNextSibling() );
|
||||
}
|
||||
|
||||
if( GetPrevSibling() != NULL )
|
||||
{
|
||||
GetPrevSibling()->SetNextSibling( GetNextSibling() );
|
||||
}
|
||||
|
||||
if( GetNextSibling() != NULL )
|
||||
{
|
||||
GetNextSibling()->SetPrevSibling( GetPrevSibling() );
|
||||
}
|
||||
|
||||
SetParent( NULL );
|
||||
SetPrevSibling( NULL );
|
||||
SetNextSibling( NULL );
|
||||
}
|
||||
|
||||
|
||||
void CBaseObj::EstablishLinkageToParent( CBaseObj* pParent )
|
||||
{
|
||||
// this의 parent와 sibling으로의 링크가 무효한 상태에서 parent의 child로서
|
||||
// 유효하도록 parent와 sibling으로의 링크를 설정
|
||||
if( NULL == pParent )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetParent( pParent );
|
||||
|
||||
CBaseObj* pParentFirstChild = pParent->GetFirstChild();
|
||||
|
||||
if( NULL == pParentFirstChild )
|
||||
{
|
||||
pParent->SetFirstChild( this );
|
||||
}
|
||||
else
|
||||
{
|
||||
pParentFirstChild->AddSiblingObj( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CBaseObj::IsRoot()
|
||||
{
|
||||
if( NULL == GetParent() &&
|
||||
NULL == GetPrevSibling() &&
|
||||
NULL == GetNextSibling() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CBaseObj::IsLeaf()
|
||||
{
|
||||
if( NULL == GetFirstChild() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CBaseObj::IsFirst()
|
||||
{
|
||||
if( NULL == GetPrevSibling() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CBaseObj::IsLast()
|
||||
{
|
||||
if( NULL == GetNextSibling() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}}
|
||||
62
GameTools/CaldronBase/BaseObj.h
Normal file
62
GameTools/CaldronBase/BaseObj.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* CBaseObj
|
||||
|
||||
* 파일 : BaseObj.h
|
||||
* 기능 : Caldron엔진 내부에서 사용되는 모든 Object들의 Base Object 클래스 선언
|
||||
* history :
|
||||
2003.10.31 (yundi) 작성
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Caldron.h"
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
namespace Base
|
||||
{
|
||||
class CBaseObj
|
||||
{
|
||||
public:
|
||||
CBaseObj( CBaseObj* pParentObj = NULL );
|
||||
virtual ~CBaseObj();
|
||||
|
||||
bool LinkToParent( CBaseObj* pParentObj );
|
||||
void Unlink();
|
||||
|
||||
bool IsRoot();
|
||||
bool IsLeaf();
|
||||
bool IsFirst();
|
||||
bool IsLast();
|
||||
|
||||
CBaseObj* GetParent();
|
||||
CBaseObj* GetFirstChild();
|
||||
CBaseObj* GetPrevSibling();
|
||||
CBaseObj* GetNextSibling();
|
||||
|
||||
private:
|
||||
void SetParent( CBaseObj* pObj ) { m_rpParent = pObj; }
|
||||
void SetFirstChild( CBaseObj* pObj ) { m_rpFirstChild = pObj; }
|
||||
void SetPrevSibling( CBaseObj* pObj ) { m_rpPrevSibling = pObj; }
|
||||
void SetNextSibling( CBaseObj* pObj ) { m_rpNextSibling = pObj; }
|
||||
|
||||
CBaseObj* GetLastSibling();
|
||||
void AddSiblingObj( CBaseObj* pObj );
|
||||
|
||||
void EstablishLinkageToParent( CBaseObj* pParent );
|
||||
|
||||
|
||||
static int _GetTotalObjectCount() { return ms_nTotalObjectCount; }
|
||||
|
||||
|
||||
CBaseObj* m_rpParent;
|
||||
CBaseObj* m_rpFirstChild;
|
||||
CBaseObj* m_rpPrevSibling;
|
||||
CBaseObj* m_rpNextSibling;
|
||||
|
||||
static int ms_nTotalObjectCount;
|
||||
};
|
||||
}
|
||||
}
|
||||
124
GameTools/CaldronBase/ByteDataObj.cpp
Normal file
124
GameTools/CaldronBase/ByteDataObj.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CByteDataObj
|
||||
|
||||
* 파일 : ByteDataObj.h
|
||||
* 기능 : Caldron Engine내 CResourceMgr 에서 읽어들이는 리소스들이 저장 되는 기본 형태.
|
||||
CLoadedObj를 상속한 각 리소스 들의 obj 들의 Load 루틴에서 각 리소스에 알맞은 형태로 변환 로드 된다.
|
||||
|
||||
* 작성일 : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#include "./LogMgr.h"
|
||||
#include "ByteDataObj.h"
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CByteDataObj::CByteDataObj()
|
||||
{
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
|
||||
CByteDataObj::~CByteDataObj()
|
||||
{
|
||||
if(m_pBytes)
|
||||
{
|
||||
delete[] m_pBytes;
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
}
|
||||
unsigned char *CByteDataObj::GetReadPtr()
|
||||
{
|
||||
if((m_lReadPos >= m_lSize) || (m_pBytes == NULL))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_pBytes[m_lReadPos]);
|
||||
|
||||
}
|
||||
bool CByteDataObj::LoadByte(char *strFileName,long lOffset)
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"rb");
|
||||
long lFileSize = 0;
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : %s file not exist\n",strFileName);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,0,SEEK_END);
|
||||
m_lSize = ftell(fp);
|
||||
if(m_lSize <= 0)
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : %s file size Wrong\n",strFileName);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
// Offset 적용
|
||||
if(m_lSize > lOffset)
|
||||
m_lSize -= lOffset;
|
||||
else
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : %s File Offset지정이 한계를 넘었습니다.\n",strFileName);
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
m_pBytes = new unsigned char[m_lSize];
|
||||
if(m_pBytes == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : File Load Buffer's New Fail.\n");
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,lOffset,SEEK_SET);
|
||||
if(fread((unsigned char *)m_pBytes,sizeof(unsigned char),m_lSize,fp) != m_lSize)
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : Load File Fail.\n");
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
long CByteDataObj::Read(void *ptr,size_t UnitSize,int iNum)
|
||||
{
|
||||
if(ptr == NULL)
|
||||
return -1;
|
||||
long lCurrentReaded = ((long)(UnitSize) * iNum) / UINT_SIZE;
|
||||
if(m_lSize >= lCurrentReaded + m_lReadPos)
|
||||
{
|
||||
memcpy(ptr,&(m_pBytes[m_lReadPos]), (size_t)(UINT_SIZE * lCurrentReaded));
|
||||
m_lReadPos += lCurrentReaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
|
||||
}
|
||||
return m_lReadPos;
|
||||
|
||||
}
|
||||
}}
|
||||
55
GameTools/CaldronBase/ByteDataObj.h
Normal file
55
GameTools/CaldronBase/ByteDataObj.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// ByteDataObj.h: interface for the CByteDataObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_)
|
||||
#define AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
const long UINT_SIZE = (long)sizeof(unsigned char);
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CByteDataObj
|
||||
|
||||
* 파일 : ByteDataObj.h
|
||||
* 기능 : Caldron Engine내 CResourceMgr 에서 읽어들이는 리소스들이 저장 되는 기본 형태.
|
||||
CLoadedObj를 상속한 각 리소스 들의 obj 들의 Load 루틴에서 각 리소스에 알맞은 형태로 변환 로드 된다.
|
||||
|
||||
* 작성일 : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
class CByteDataObj
|
||||
{
|
||||
public:
|
||||
CByteDataObj();
|
||||
virtual ~CByteDataObj();
|
||||
|
||||
bool LoadByte(char *strFileName,long lOffset = 0 );
|
||||
long GetByteSize() { return m_lSize; }
|
||||
long GetReadPos() { return m_lReadPos;}
|
||||
void SetReadPos(long lPos) { m_lReadPos = lPos;}
|
||||
unsigned char *GetReadPtr();
|
||||
long Read(void *ptr,size_t UnitSize,int iNum);
|
||||
|
||||
unsigned char *m_pBytes;
|
||||
long m_lSize;
|
||||
long m_lReadPos;
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // !defined(AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_)
|
||||
25
GameTools/CaldronBase/Caldron.cpp
Normal file
25
GameTools/CaldronBase/Caldron.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* Caldron Engine 공용헤더용 실제 상수 정의파일
|
||||
|
||||
* 파일 : Caldron.h
|
||||
* 기능 : Caldron namespace의 상수들을 정의
|
||||
* 작성일 : 2003.10.23
|
||||
* 작성자 : yundi ( 2003.10.23)
|
||||
* 수정자 :
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
const float FLOAT_RAD = 0.0174532925f;
|
||||
const float FLOAT_PI = 3.14159265358979323846f;
|
||||
const float FLOAT_2PI = 6.28318530717958647692f;
|
||||
|
||||
extern const float MIN_EPSILON = 1.0e-4f;
|
||||
extern const float MAX_EPSILON = 1.0e+10f;
|
||||
const int MAX_STRINGSIZE = 40;
|
||||
// const int MAX_RELOADING = 3;
|
||||
|
||||
|
||||
}
|
||||
197
GameTools/CaldronBase/Caldron.h
Normal file
197
GameTools/CaldronBase/Caldron.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* Caldron Engine 공용헤더파일
|
||||
|
||||
* 파일 : Caldron.h
|
||||
* 기능 : Caldron Engine 을 이용하는곳에서 공통적으로 사용하게되는 헤더파일
|
||||
* 작성일: 2003.10.23
|
||||
* 작성자: yundi ( 2003.10.23)
|
||||
* 수정자:
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4251)
|
||||
#pragma warning(disable:4503)
|
||||
|
||||
#include <algorithm>
|
||||
//#include <d3d9.h>
|
||||
#include <d3dx8.h>
|
||||
#include <tchar.h>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <math.h>
|
||||
#include <process.h>
|
||||
#include <mmsystem.h>
|
||||
#include <windows.h>
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
// epsilon 상수
|
||||
extern const float MIN_EPSILON;
|
||||
extern const float MAX_EPSILON;
|
||||
|
||||
|
||||
// 상수 선언
|
||||
const float FLOAT_RAD = 0.0174532925f; // radian 값
|
||||
extern const float FLOAT_PI; // pi
|
||||
extern const float FLOAT_2PI;
|
||||
|
||||
extern const int MAX_STRINGSIZE;
|
||||
const int MAX_RELOADING = 3; // Resource Loader 에서 Object 로딩 실패시 최대 Reloading 시도 횟수
|
||||
|
||||
#define FLOAT_TO_INT(fValue) (*(int *)&(fValue))
|
||||
#define IS_SIGNBIT(fValue) (FLOAT_TO_INT(fValue) & 0x80000000)
|
||||
|
||||
|
||||
// template function 정의
|
||||
template<class _T>
|
||||
inline void SafeDelete( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class _T>
|
||||
inline void SafeDeleteA( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete[] (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class _T>
|
||||
inline void SafeRelease( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
ptr->Release();
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool Succeeded( HRESULT hr )
|
||||
{
|
||||
return (hr >= 0);
|
||||
}
|
||||
|
||||
inline bool Failed( HRESULT hr )
|
||||
{
|
||||
return (hr < 0);
|
||||
}
|
||||
|
||||
inline bool IsZero(float fValue)
|
||||
{
|
||||
if((fValue > -(MIN_EPSILON)) && (fValue < MIN_EPSILON))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
inline float Def2Rad( float fDeg )
|
||||
{
|
||||
return fDeg*FLOAT_PI/180;
|
||||
}
|
||||
|
||||
// CProfileMgr 에서 사용
|
||||
inline void ProfileGetTicks(_int64 * ticks)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push edx;
|
||||
push ecx;
|
||||
mov ecx,ticks;
|
||||
_emit 0Fh
|
||||
_emit 31h
|
||||
mov [ecx],eax;
|
||||
mov [ecx+4],edx;
|
||||
pop ecx;
|
||||
pop edx;
|
||||
}
|
||||
}
|
||||
|
||||
inline float ProfileGetTickRate(void)
|
||||
{
|
||||
static float _CPUFrequency = -1.0f;
|
||||
|
||||
if (_CPUFrequency == -1.0f) {
|
||||
__int64 curr_rate = 0;
|
||||
::QueryPerformanceFrequency ((LARGE_INTEGER *)&curr_rate);
|
||||
_CPUFrequency = (float)curr_rate;
|
||||
}
|
||||
|
||||
return _CPUFrequency;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CBitset
|
||||
* 파일 : Bitset.h
|
||||
* 기능 : Caldron Engine내 Bitset Class
|
||||
* 작성일 : 2003.10.24
|
||||
* History : wizardbug ( 2003.10.24)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
class CBitset {
|
||||
protected:
|
||||
|
||||
unsigned int *m_pBits; // Bit Set ptr
|
||||
int m_iBitSize; // Bit Set Size
|
||||
|
||||
public:
|
||||
CBitset() {
|
||||
m_pBits = NULL;
|
||||
m_iBitSize = 0;
|
||||
}
|
||||
~CBitset() {
|
||||
if(m_pBits)
|
||||
{
|
||||
delete[] m_pBits;
|
||||
m_pBits = NULL;
|
||||
}
|
||||
}
|
||||
void ResizeBits(int iNewCount) {
|
||||
|
||||
m_iBitSize = iNewCount / 32 + 1; // Get Inteager Size
|
||||
if(m_pBits) {
|
||||
delete[] m_pBits;
|
||||
m_pBits = NULL;
|
||||
}
|
||||
m_pBits = new unsigned int[m_iBitSize]; // Allocate Bits
|
||||
ClearBits();
|
||||
|
||||
}
|
||||
void ClearBits() { // Clear All Bits
|
||||
memset(m_pBits,0,sizeof(unsigned int) * m_iBitSize);
|
||||
|
||||
}
|
||||
void ClearOneBit(int index) {
|
||||
|
||||
m_pBits[ index >> 5 ] &= ~( 1 << ( index & 31 ) );
|
||||
}
|
||||
void SetBit(int index) { // Set Bit
|
||||
m_pBits[ index >> 5 ] |= ( 1 << ( index & 31 ) );
|
||||
|
||||
}
|
||||
bool GetBit(int index) { // Return Bit's Setting : return true or false
|
||||
|
||||
return (m_pBits[ index >> 5 ] & ( 1 << (index & 31 ) )) ? true : false;
|
||||
|
||||
}
|
||||
};
|
||||
/********************************************************************** */
|
||||
|
||||
}
|
||||
92
GameTools/CaldronBase/CaldronBase.dsp
Normal file
92
GameTools/CaldronBase/CaldronBase.dsp
Normal file
@@ -0,0 +1,92 @@
|
||||
# Microsoft Developer Studio Project File - Name="CaldronBase" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=CaldronBase - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "CaldronBase.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "CaldronBase.mak" CFG="CaldronBase - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "CaldronBase - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "CaldronBase - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "CaldronBase - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x412 /d "NDEBUG"
|
||||
# ADD RSC /l 0x412 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "CaldronBase - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x412 /d "_DEBUG"
|
||||
# ADD RSC /l 0x412 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "CaldronBase - Win32 Release"
|
||||
# Name "CaldronBase - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
16
GameTools/CaldronBase/CaldronBase.plg
Normal file
16
GameTools/CaldronBase/CaldronBase.plg
Normal file
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: CaldronBase - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
CaldronBase.lib - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
161
GameTools/CaldronBase/CaldronBase.vcproj
Normal file
161
GameTools/CaldronBase/CaldronBase.vcproj
Normal file
@@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="CaldronBase"
|
||||
ProjectGUID="{D2E60DB8-59A3-4446-BAA7-53C4F661D8EF}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug/CaldronBase.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Debug\CaldronBase.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1042"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Release/CaldronBase.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Release\CaldronBase.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1042"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath=".\BaseCacheMgr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ByteDataObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Caldron.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Timer.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath=".\BaseCacheMgr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ByteDataObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Caldron.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ThreadQueue.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Timer.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
361
GameTools/CaldronBase/Console.cpp
Normal file
361
GameTools/CaldronBase/Console.cpp
Normal file
@@ -0,0 +1,361 @@
|
||||
#include "./console.h"
|
||||
#include "./DInput8Mgr.h"
|
||||
#include "./D3D9GraphicLayer.h"
|
||||
|
||||
#include "../Scene/D3DXFont.h"
|
||||
#include "../Scene/SceneStateMgr.h"
|
||||
#include "../Scene/MainSceneMgr.h"
|
||||
#include "../Scene/MaterialShaderMgr.h"
|
||||
|
||||
#include "../Scene/D3DXFont.h"
|
||||
#include "./Timer.h"
|
||||
#include "../Interface/CaldronMainInterface.h"
|
||||
|
||||
namespace Caldron {
|
||||
namespace Scene {
|
||||
|
||||
void CConsoleMaterialShder::Apply()
|
||||
{
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE ,FALSE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_TEXTUREFACTOR,0x00000000);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLOROP ,D3DTOP_SELECTARG1);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG1 ,D3DTA_TFACTOR);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_COLOROP ,D3DTOP_DISABLE );
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_ALPHAOP ,D3DTOP_DISABLE );
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
namespace Base {
|
||||
|
||||
|
||||
CConsole::CConsole(void) : m_iEnable(-1),m_fAniTime(0.5f),m_iUseLines(0),m_iWindowLines(20),m_iCurrentPos(0),m_iCursorX(0),m_iCursorY(0),
|
||||
m_dwScreenWidth(0),m_dwScreenHeight(0),m_iMaterialShaderIndex(-1),m_iCurrentPage(1),m_fUnitUv(0.1f),m_fTargetUv(30.0f),m_fCurrentUv(0.0f),
|
||||
m_fCurrentHeight(0.0f),m_fUnitAniHeight(0.0f),m_fTargetHeight(0.0f)
|
||||
{
|
||||
memset(m_strInputLine,0,sizeof(char) * 1024);
|
||||
memset(m_pBuffer,0,sizeof(char *) * CONSOLE_MAXLINE);
|
||||
|
||||
m_iMaterialShaderIndex = -1;
|
||||
m_dwConsoleDecl = D3DFVF_XYZRHW;// | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE1(2);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
CConsole::~CConsole(void)
|
||||
{
|
||||
|
||||
for(int i = 0; i < m_iUseLines; i++ )
|
||||
{
|
||||
SafeDeleteA(m_pBuffer[i]);
|
||||
m_pBuffer[i] = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
void CConsole::Init()
|
||||
{
|
||||
|
||||
|
||||
|
||||
Scene::CConsoleMaterialShder *pShader = new Scene::CConsoleMaterialShder;
|
||||
m_iMaterialShaderIndex = (Scene::CMainSceneMgr::_GetMaterialShaderMgr())->PushMaterialShader(pShader);
|
||||
|
||||
for(int i =0 ;i < 4;i++ )
|
||||
{
|
||||
m_pVertex[i].m_vecPos.w = 0.1f;
|
||||
m_pVertex[i].m_vecPos.z = 0.1f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void CConsole::Display()
|
||||
{
|
||||
if(m_iEnable != CONSOLEVIEW_HIDEANI)
|
||||
{
|
||||
CDInput8Mgr::Lock(CONSOLE_INPUTLOCK_KEY);
|
||||
memset(m_strInputLine,0,sizeof(char) * 1024);
|
||||
m_iEnable = CONSOLEVIEW_DISPLAYANI;
|
||||
m_iWindowLines = 20;
|
||||
m_iCurrentPos = 0;
|
||||
m_iCursorX = 10;
|
||||
m_iCursorY = (int)(m_fTargetHeight - 15);
|
||||
}
|
||||
}
|
||||
void CConsole::Hide()
|
||||
{
|
||||
if(m_iEnable != CONSOLEVIEW_DISPLAYANI)
|
||||
{
|
||||
m_iEnable = CONSOLEVIEW_HIDEANI;
|
||||
m_iWindowLines = 20;
|
||||
m_iCurrentPos = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void CConsole::ProcessKey()
|
||||
{
|
||||
if(m_iEnable == CONSOLEVIEW_DISPLAY)
|
||||
{
|
||||
if(CDInput8Mgr::PushOnceKey(DIK_GRAVE,CONSOLE_INPUTLOCK_KEY))
|
||||
{
|
||||
Scene::CMainSceneMgr::ChangeConsole();
|
||||
|
||||
}
|
||||
if(CDInput8Mgr::PushOnceKey(DIK_RETURN ,CONSOLE_INPUTLOCK_KEY))
|
||||
{
|
||||
CommandExec();
|
||||
m_iCurrentPos = 0;
|
||||
memset(m_strInputLine,0,sizeof(char) * 1024);
|
||||
|
||||
|
||||
}
|
||||
// key ÀÔ·Âó¸®
|
||||
CDInput8Mgr::KeyStrok(m_strInputLine,m_iCurrentPos);
|
||||
if(m_iCurrentPos >= 1024)
|
||||
m_iCurrentPos = 1023;
|
||||
if(m_iCurrentPos < 0)
|
||||
m_iCurrentPos = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void CConsole::Update(float fSkipFrame)
|
||||
{
|
||||
|
||||
CD3D9GraphicLayer::_GetWindowSize(m_dwScreenWidth,m_dwScreenHeight);
|
||||
|
||||
m_fTargetHeight = (float)m_dwScreenHeight * 0.6f;
|
||||
m_fUnitAniHeight = (float)m_fTargetHeight / m_fAniTime;
|
||||
|
||||
if(m_iEnable == CONSOLEVIEW_HIDE)
|
||||
return ;
|
||||
switch(m_iEnable)
|
||||
{
|
||||
case CONSOLEVIEW_HIDEANI:
|
||||
if(m_fCurrentHeight > 0)
|
||||
{
|
||||
m_fCurrentHeight -= (float)m_fUnitAniHeight * fSkipFrame;
|
||||
}
|
||||
break;
|
||||
case CONSOLEVIEW_DISPLAYANI:
|
||||
if(m_fCurrentHeight < m_fTargetHeight)
|
||||
{
|
||||
m_fCurrentHeight += (float)m_fUnitAniHeight * fSkipFrame;
|
||||
}
|
||||
break;
|
||||
case CONSOLEVIEW_DISPLAY:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
if(m_fCurrentHeight <= 0)
|
||||
{
|
||||
m_fCurrentHeight = 0;
|
||||
m_iEnable = CONSOLEVIEW_HIDE;
|
||||
CDInput8Mgr::Unlock();
|
||||
}
|
||||
else if(m_fCurrentHeight >= m_fTargetHeight)
|
||||
{
|
||||
m_fCurrentHeight = m_fTargetHeight;
|
||||
m_iEnable = CONSOLEVIEW_DISPLAY;
|
||||
}
|
||||
|
||||
m_fCurrentUv += m_fUnitUv * fSkipFrame;
|
||||
if(m_fCurrentUv >= m_fTargetUv)
|
||||
{
|
||||
m_fUnitUv *= -1.0f;
|
||||
}
|
||||
else if(m_fCurrentUv <= 0.0f)
|
||||
{
|
||||
m_fUnitUv *= -1.0f;
|
||||
}
|
||||
|
||||
ProcessKey();
|
||||
}
|
||||
void CConsole::Render(LPDIRECT3DDEVICE9 lpDevice)
|
||||
{
|
||||
|
||||
if(m_iEnable == CONSOLEVIEW_HIDE)
|
||||
return ;
|
||||
Scene::CMainSceneMgr::_GetMaterialShaderMgr()->GetNodes(m_iMaterialShaderIndex)->Apply();
|
||||
|
||||
m_pVertex[3].m_vecPos.x = (float)m_dwScreenWidth;
|
||||
m_pVertex[3].m_vecPos.y = m_fCurrentHeight;
|
||||
|
||||
m_pVertex[0].m_vecPos.x = 0.0f;
|
||||
m_pVertex[0].m_vecPos.y = m_fCurrentHeight;
|
||||
|
||||
m_pVertex[1].m_vecPos.x = 0.0f;
|
||||
m_pVertex[1].m_vecPos.y = 0.0f;
|
||||
|
||||
m_pVertex[2].m_vecPos.x = (float)m_dwScreenWidth;
|
||||
m_pVertex[2].m_vecPos.y = 0.0f;
|
||||
|
||||
lpDevice->SetFVF(m_dwConsoleDecl);
|
||||
lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN ,2,&m_pVertex,sizeof(CConsoleVertex));
|
||||
if(m_iEnable == CONSOLEVIEW_DISPLAY)
|
||||
{
|
||||
RenderText(5,m_iCursorY,">");
|
||||
if(m_iCurrentPos < 1023)
|
||||
m_strInputLine[m_iCurrentPos] = '_';
|
||||
RenderText((long)m_iCursorX,(long)m_iCursorY,m_strInputLine);
|
||||
int iCount = (m_iUseLines > m_iWindowLines) ? m_iWindowLines : m_iUseLines;
|
||||
|
||||
for(int iLine = 0; iLine < iCount; iLine++)
|
||||
{
|
||||
RenderText((long)m_iCursorX,(long)iLine * 13 + 2,m_pBuffer[iLine]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CConsole::RenderText(long iX,long iY,const char *strText)
|
||||
{
|
||||
Scene::CMainSceneMgr::_GetFont()->PrintFont(iX,iY,strText);
|
||||
}
|
||||
void CConsole::AddText(const char *fmt,...)
|
||||
{
|
||||
static char str[1024];
|
||||
int iLength;
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
vsprintf( str, fmt, va );
|
||||
va_end( va );
|
||||
|
||||
if(m_iUseLines == CONSOLE_MAXLINE)
|
||||
SafeDeleteA(m_pBuffer[--m_iUseLines]);
|
||||
memmove(&m_pBuffer[1],&m_pBuffer[0],sizeof(char *)*m_iUseLines);
|
||||
iLength = (int)strlen(str) + 1;
|
||||
m_pBuffer[0] = new char[iLength];
|
||||
memcpy(m_pBuffer[0],str,iLength);
|
||||
m_iUseLines++;
|
||||
|
||||
|
||||
}
|
||||
void CConsole::CommandExec()
|
||||
{
|
||||
m_strInputLine[m_iCurrentPos] = 0;
|
||||
AddText(m_strInputLine);
|
||||
if(strstr(m_strInputLine,"BYE")) // Console Close
|
||||
Scene::CMainSceneMgr::ChangeConsole();
|
||||
else if(strstr(m_strInputLine,"FOV")) // Fov
|
||||
{
|
||||
float fFov = 45.0f;
|
||||
float fMinDistance = 0.1f;
|
||||
float fMaxDistance = 10000.0f;
|
||||
bool bRight = true;
|
||||
|
||||
char *tok = strtok(m_strInputLine," ");
|
||||
|
||||
if((tok = strtok(NULL," ")) != NULL)
|
||||
{
|
||||
fFov = (float)atof(tok);
|
||||
if((tok = strtok(NULL," ")) != NULL)
|
||||
{
|
||||
fMinDistance = (float)atof(tok);
|
||||
if((tok = strtok(NULL," ")) != NULL)
|
||||
{
|
||||
fMaxDistance = (float)atof(tok);
|
||||
}
|
||||
else
|
||||
{
|
||||
bRight = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bRight = false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bRight = false;
|
||||
}
|
||||
|
||||
|
||||
if(bRight == true)
|
||||
Scene::CSceneStateMgr::_SetD3DPerspectiveLHMatrix(Scene::D3DMATRIX_PROJECT,fFov,(float)m_dwScreenWidth / (float)m_dwScreenHeight,fMinDistance,fMaxDistance);
|
||||
else
|
||||
AddText("FOV arg wrong. ex> FOV 45.0 0.1 1000.0");
|
||||
}
|
||||
else if(strstr(m_strInputLine,"WIREFRAME VIEW")) // Fill Mode setting
|
||||
Scene::CMainSceneMgr::_ChangeGlobalMode(Scene::GLOBAL_FILLMODE,D3DFILL_WIREFRAME);
|
||||
else if(strstr(m_strInputLine,"SOLID VIEW"))
|
||||
Scene::CMainSceneMgr::_ChangeGlobalMode(Scene::GLOBAL_FILLMODE,D3DFILL_SOLID);
|
||||
else if(strstr(m_strInputLine,"FPS ON")) // Fps View
|
||||
Scene::CMainSceneMgr::_ChangeGlobalMode(Scene::GLOBAL_FPSSTATE,1);
|
||||
else if(strstr(m_strInputLine,"FPS OFF"))
|
||||
Scene::CMainSceneMgr::_ChangeGlobalMode(Scene::GLOBAL_FPSSTATE,0);
|
||||
else if(strstr(m_strInputLine,"CAMERA INFO ON")) // Camera Info
|
||||
Scene::CMainSceneMgr::_ChangeGlobalMode(Scene::GLOBAL_CAMERAINFO,1);
|
||||
else if(strstr(m_strInputLine,"CAMERA INFO OFF"))
|
||||
Scene::CMainSceneMgr::_ChangeGlobalMode(Scene::GLOBAL_CAMERAINFO,0);
|
||||
else if(strstr(m_strInputLine,"LOG CONSOLE")) // Log Device Setting
|
||||
CLogMgr::_SetOutDevice(Caldron::LOG_CONSOLEOUT);
|
||||
else if(strstr(m_strInputLine,"LOG FILE"))
|
||||
CLogMgr::_SetOutDevice(Caldron::LOG_FILEOUT);
|
||||
else if(strstr(m_strInputLine,"LOG MESSAGEBOX"))
|
||||
CLogMgr::_SetOutDevice(Caldron::LOG_MESSAGEBOXOUT);
|
||||
else if(strstr(m_strInputLine,"HELP")) // Help
|
||||
HelpMessage();
|
||||
else if(strstr(m_strInputLine,"FPS HOLD")) // Fps Hold
|
||||
{
|
||||
|
||||
char *tok = strtok(m_strInputLine," ");
|
||||
int iHold = 0;
|
||||
|
||||
if((tok = strtok(NULL," ")) != NULL)
|
||||
{
|
||||
if((tok = strtok(NULL," ")) != NULL)
|
||||
{
|
||||
iHold = atoi(tok);
|
||||
Caldron::Base::CTimer::_GetInstance().SetFPS(iHold);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(strstr(m_strInputLine,"QUIT"))
|
||||
{
|
||||
Interface::CCaldronMsgObj *pNode = new Interface::CCaldronMsgObj(Interface::MESSAGE_APP_QUIT,0);
|
||||
|
||||
Interface::CCaldronMainInterface::PushCaldronMsg(pNode);
|
||||
}
|
||||
}
|
||||
void CConsole::HelpMessage()
|
||||
{
|
||||
|
||||
AddText(" BYE : Console Close");
|
||||
AddText(" FOV FovValue MinValue MaxValue : Fov Setting ( ex > FOV 45.0 0.1 1000.0)");
|
||||
AddText(" WIREFRAME VIEW : WireFrame View");
|
||||
AddText(" SOLID VIEW : Solid View");
|
||||
AddText(" FPS ON : FPS Draw");
|
||||
AddText(" FPS OFF : FPS Not Draw");
|
||||
AddText(" CAMERA INFO ON : Camera Info On");
|
||||
AddText(" CAMERA INFO OFF : Camera Info Off");
|
||||
AddText(" LOG CONSOLE : Log to Console");
|
||||
AddText(" LOG FILE : Log to File");
|
||||
AddText(" LOG MESSAGEBOX : Log to MessageBox");
|
||||
AddText(" FPS HOLD holdFps : FPS HOLD ( ex > FPS HOLD 100 )");
|
||||
AddText(" QUIT : APP Quit");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
|
||||
101
GameTools/CaldronBase/Console.h
Normal file
101
GameTools/CaldronBase/Console.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
#include "Caldron.h"
|
||||
#include "../Scene/MaterialShader.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
|
||||
namespace Scene {
|
||||
class CConsoleMaterialShder : public CMaterialShader
|
||||
{
|
||||
public:
|
||||
CConsoleMaterialShder(){}
|
||||
~CConsoleMaterialShder(){}
|
||||
virtual void Apply();
|
||||
|
||||
};
|
||||
}
|
||||
namespace Base {
|
||||
|
||||
const int CONSOLE_MAXLINE = 512;
|
||||
const int CONSOLE_LINE = 30;
|
||||
const int CONSOLE_COL = 40;
|
||||
const int CONSOLE_INPUTLOCK_KEY = 10;
|
||||
|
||||
enum CONSOLE_VIEWSTATE
|
||||
{
|
||||
CONSOLEVIEW_HIDE = 0,
|
||||
CONSOLEVIEW_HIDEANI,
|
||||
CONSOLEVIEW_DISPLAY,
|
||||
CONSOLEVIEW_DISPLAYANI,
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CConsole
|
||||
{
|
||||
public:
|
||||
|
||||
class CConsoleVertex {
|
||||
public:
|
||||
D3DXVECTOR4 m_vecPos;
|
||||
};
|
||||
|
||||
int m_iEnable;
|
||||
float m_fAniTime;
|
||||
char *m_pBuffer[CONSOLE_MAXLINE];
|
||||
int m_iUseLines;
|
||||
int m_iWindowLines;
|
||||
|
||||
char m_strInputLine[1024]; // ÀÔ·Â ¹öÆÛ
|
||||
int m_iCurrentPos;
|
||||
int m_iCursorX,m_iCursorY;
|
||||
DWORD m_dwScreenWidth,m_dwScreenHeight;
|
||||
|
||||
float m_fCurrentHeight;
|
||||
float m_fUnitAniHeight;
|
||||
float m_fTargetHeight;
|
||||
|
||||
float m_fUnitUv;
|
||||
float m_fTargetUv;
|
||||
float m_fCurrentUv;
|
||||
|
||||
int m_iCurrentPage;
|
||||
|
||||
int m_iMaterialShaderIndex;
|
||||
|
||||
|
||||
|
||||
|
||||
CConsoleVertex m_pVertex[4];
|
||||
|
||||
DWORD m_dwConsoleDecl;
|
||||
|
||||
|
||||
|
||||
CConsole(void);
|
||||
~CConsole(void);
|
||||
|
||||
void Init();
|
||||
|
||||
void Display(); // Console DisPlay
|
||||
void Hide(); // Console Display Hide
|
||||
void Render(LPDIRECT3DDEVICE9 lpDevice); // Console Render
|
||||
void Update(float fSkipFrame);
|
||||
void ProcessKey();
|
||||
|
||||
void RenderText(long iX,long iY,const char *strText);
|
||||
|
||||
void AddText(const char *str,...);
|
||||
void CommandExec();
|
||||
void HelpMessage();
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}}
|
||||
400
GameTools/CaldronBase/D3D9GraphicLayer.cpp
Normal file
400
GameTools/CaldronBase/D3D9GraphicLayer.cpp
Normal file
@@ -0,0 +1,400 @@
|
||||
// D3D9GraphicLayer.cpp: implementation of the CD3D9GraphicLayer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#include "D3D9GraphicLayer.h"
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CD3D9GraphicLayer
|
||||
|
||||
* 파일 : D3D9GraphicLayer.h
|
||||
* 기능 : Caldron Engine내 D3D9 디바이스등을 크리에이트 시켜주는 BaseGraphic Layer
|
||||
실 app에서 사용할 시에 이 레이어를 상속받아 D3d Layer로 사용한다.
|
||||
* 작성일 : 2003.10.30
|
||||
* history :
|
||||
wizardbug ( 2003.10.30)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
LPDIRECT3DDEVICE9 Caldron::Base::CD3D9GraphicLayer::ms_pD3DDevice = NULL;
|
||||
Caldron::Base::CD3D9GraphicLayer::CD3D9WindowInfo Caldron::Base::CD3D9GraphicLayer::m_WindowInfo;
|
||||
Caldron::Base::CD3D9GraphicLayer::CD3D9ModeInfo Caldron::Base::CD3D9GraphicLayer::m_ModeInfo;
|
||||
|
||||
Caldron::Base::CD3D9GraphicLayer::CD3D9GraphicLayer()
|
||||
{
|
||||
m_pD3D9Obj = NULL;
|
||||
m_hWnd = 0;
|
||||
m_pExceptionMgr = new CExceptionMgr;
|
||||
|
||||
|
||||
}
|
||||
Caldron::Base::CD3D9GraphicLayer::~CD3D9GraphicLayer()
|
||||
{
|
||||
ReleaseAll();
|
||||
}
|
||||
void Caldron::Base::CD3D9GraphicLayer::ReleaseAll()
|
||||
{
|
||||
SafeRelease(m_pD3D9Obj);
|
||||
SafeRelease(ms_pD3DDevice);
|
||||
CLogMgr::_Close();
|
||||
SafeDelete(m_pExceptionMgr);
|
||||
|
||||
|
||||
}
|
||||
HRESULT Caldron::Base::CD3D9GraphicLayer::InitD3DLayer(HINSTANCE hInstance,HWND hWnd,DWORD dwWidth, DWORD dwHeight,
|
||||
bool bWindowed,D3DFORMAT ColorFormat,D3DFORMAT ZFormat,
|
||||
DWORD dwVertexProcess,D3DMULTISAMPLE_TYPE Antial)
|
||||
{
|
||||
|
||||
if((m_pD3D9Obj = Direct3DCreate9(D3D_SDK_VERSION)) == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::InitD3DLayer() : D3D9 Object Create Failed");
|
||||
m_WindowInfo.m_bD3DRunning = false;
|
||||
return E_FAIL;
|
||||
}
|
||||
m_ModeInfo.m_ColorFormat = ColorFormat;
|
||||
m_ModeInfo.m_DepthStencilFormat = ZFormat;
|
||||
m_ModeInfo.m_dwVertexProcessing = dwVertexProcess| D3DCREATE_MULTITHREADED;
|
||||
m_ModeInfo.m_MultiSampling = Antial;
|
||||
|
||||
m_WindowInfo.m_hInstance = hInstance;
|
||||
m_WindowInfo.m_dwWidth = dwWidth;
|
||||
m_WindowInfo.m_dwHeight = dwHeight;
|
||||
m_WindowInfo.m_bWindowed = bWindowed;
|
||||
|
||||
|
||||
ZeroMemory(&m_PresentParameters,sizeof(m_PresentParameters));
|
||||
|
||||
m_PresentParameters.Windowed = m_WindowInfo.m_bWindowed;
|
||||
m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
|
||||
m_PresentParameters.EnableAutoDepthStencil = true;
|
||||
m_PresentParameters.AutoDepthStencilFormat = m_ModeInfo.m_DepthStencilFormat;
|
||||
m_hWnd = m_PresentParameters.hDeviceWindow = hWnd;
|
||||
|
||||
m_PresentParameters.BackBufferWidth = m_WindowInfo.m_dwWidth;
|
||||
m_PresentParameters.BackBufferHeight = m_WindowInfo.m_dwHeight;
|
||||
m_PresentParameters.BackBufferFormat = m_ModeInfo.m_ColorFormat;
|
||||
m_PresentParameters.BackBufferCount = 1;
|
||||
CheckD3DFormat(!(m_WindowInfo.m_bWindowed),m_ModeInfo.m_ColorFormat,&(m_PresentParameters.BackBufferFormat));
|
||||
m_ModeInfo.m_ColorFormat = m_PresentParameters.BackBufferFormat;
|
||||
|
||||
m_PresentParameters.MultiSampleType = m_ModeInfo.m_MultiSampling;
|
||||
m_PresentParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
|
||||
m_PresentParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
if(ms_pD3DDevice != NULL)
|
||||
{
|
||||
SafeRelease(ms_pD3DDevice);
|
||||
}
|
||||
|
||||
|
||||
HRESULT hr;
|
||||
if(Failed(hr = m_pD3D9Obj->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_hWnd,m_ModeInfo.m_dwVertexProcessing,
|
||||
&m_PresentParameters,&ms_pD3DDevice)))
|
||||
{
|
||||
if(m_ModeInfo.m_dwVertexProcessing & D3DCREATE_HARDWARE_VERTEXPROCESSING)
|
||||
{
|
||||
m_ModeInfo.m_dwVertexProcessing &= ~D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
||||
m_ModeInfo.m_dwVertexProcessing |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||
if(Failed(m_pD3D9Obj->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_hWnd,m_ModeInfo.m_dwVertexProcessing,
|
||||
&m_PresentParameters,&ms_pD3DDevice)))
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::InitD3DLayer() : D3D9 Device Create Failed");
|
||||
m_WindowInfo.m_bD3DRunning = false;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
}
|
||||
if(m_ModeInfo.m_dwVertexProcessing & D3DCREATE_MULTITHREADED)
|
||||
{
|
||||
m_ModeInfo.m_dwVertexProcessing &= ~D3DCREATE_MULTITHREADED;
|
||||
|
||||
if(Failed(m_pD3D9Obj->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_hWnd,m_ModeInfo.m_dwVertexProcessing,
|
||||
&m_PresentParameters,&ms_pD3DDevice)))
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::InitD3DLayer() : D3D9 Device Create Failed");
|
||||
m_WindowInfo.m_bD3DRunning = false;
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//D3DDISPLAYMODE pMode;
|
||||
//ms_pD3DDevice->GetDisplayMode( 0,&pMode);
|
||||
|
||||
InitScene();
|
||||
CheckDeviceCaps();
|
||||
m_WindowInfo.m_bD3DRunning = true;
|
||||
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
|
||||
// Lost 시에 E_FAIL return
|
||||
HRESULT Caldron::Base::CD3D9GraphicLayer::CheckDeviceLost()
|
||||
{
|
||||
if(!ms_pD3DDevice)
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChecDeviceLost() : Device == NULL");
|
||||
return E_FAIL;
|
||||
|
||||
}
|
||||
switch(ms_pD3DDevice->TestCooperativeLevel())
|
||||
{
|
||||
|
||||
case D3DERR_DEVICELOST:
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChecDeviceLost() : Device Lost");
|
||||
Sleep(100); // Device 가 D3DERR_DEVICENOTRESET 상태가 될때까지 기다린다.
|
||||
m_WindowInfo.m_bD3DRunning = false;
|
||||
return E_FAIL;
|
||||
case D3DERR_DEVICENOTRESET:
|
||||
{
|
||||
if(Failed(ms_pD3DDevice->Reset(&m_PresentParameters)))
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChecDeviceLost() : Reset Failed");
|
||||
m_WindowInfo.m_bD3DRunning = false;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
InitScene();
|
||||
m_WindowInfo.m_bD3DRunning = true;
|
||||
return S_OK;
|
||||
}
|
||||
default:
|
||||
m_WindowInfo.m_bD3DRunning = true;
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CD3D9GraphicLayer::SaveSetting()
|
||||
{
|
||||
|
||||
}
|
||||
void Caldron::Base::CD3D9GraphicLayer::LoadSetting()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Caldron::Base::CD3D9GraphicLayer::InitScene() // Scene Init
|
||||
{
|
||||
|
||||
}
|
||||
HRESULT Caldron::Base::CD3D9GraphicLayer::ChangePresentMode(UINT UIPresent)
|
||||
{
|
||||
m_PresentParameters.PresentationInterval = UIPresent;
|
||||
|
||||
//change device mode
|
||||
if(ms_pD3DDevice == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChangeMode() : Device == NULL");
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
if(FAILED(ms_pD3DDevice->Reset(&m_PresentParameters)))
|
||||
{
|
||||
// Mode Back.
|
||||
m_PresentParameters.AutoDepthStencilFormat = m_ModeInfo.m_DepthStencilFormat;
|
||||
m_PresentParameters.BackBufferWidth = m_WindowInfo.m_dwWidth;
|
||||
m_PresentParameters.BackBufferHeight = m_WindowInfo.m_dwHeight;
|
||||
m_PresentParameters.BackBufferFormat = m_ModeInfo.m_ColorFormat;
|
||||
|
||||
ms_pD3DDevice->Reset(&m_PresentParameters);
|
||||
|
||||
InitScene();
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChangeMode() : Reset Failed");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Success Info Setting
|
||||
|
||||
InitScene();
|
||||
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
HRESULT Caldron::Base::CD3D9GraphicLayer::ChangeMode(DWORD dwWidth, DWORD dwHeight, D3DFORMAT Pixel, D3DFORMAT Zbuffer,UINT uiPresent)
|
||||
{
|
||||
//set new parameters
|
||||
m_PresentParameters.AutoDepthStencilFormat = Zbuffer;
|
||||
m_PresentParameters.BackBufferWidth = dwWidth;
|
||||
m_PresentParameters.BackBufferHeight = dwHeight;
|
||||
m_PresentParameters.BackBufferFormat = Pixel;
|
||||
m_PresentParameters.PresentationInterval = uiPresent;
|
||||
|
||||
CheckD3DFormat(!m_WindowInfo.m_bWindowed,Pixel,&(m_PresentParameters.BackBufferFormat));
|
||||
//change device mode
|
||||
if(ms_pD3DDevice == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChangeMode() : Device == NULL");
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
if(FAILED(ms_pD3DDevice->Reset(&m_PresentParameters)))
|
||||
{
|
||||
// Mode Back.
|
||||
m_PresentParameters.AutoDepthStencilFormat = m_ModeInfo.m_DepthStencilFormat;
|
||||
m_PresentParameters.BackBufferWidth = m_WindowInfo.m_dwWidth;
|
||||
m_PresentParameters.BackBufferHeight = m_WindowInfo.m_dwHeight;
|
||||
m_PresentParameters.BackBufferFormat = m_ModeInfo.m_ColorFormat;
|
||||
|
||||
CheckD3DFormat(!m_WindowInfo.m_bWindowed,Pixel,&(m_PresentParameters.BackBufferFormat));
|
||||
ms_pD3DDevice->Reset(&m_PresentParameters);
|
||||
|
||||
InitScene();
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChangeMode() : Reset Failed");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Success Info Setting
|
||||
m_WindowInfo.m_dwWidth = dwWidth;
|
||||
m_WindowInfo.m_dwHeight = dwHeight;
|
||||
m_ModeInfo.m_ColorFormat = Pixel;
|
||||
m_ModeInfo.m_DepthStencilFormat = Zbuffer;
|
||||
|
||||
InitScene();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT Caldron::Base::CD3D9GraphicLayer::CheckDeviceCaps()
|
||||
{
|
||||
|
||||
if(ms_pD3DDevice == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::CheckDeviceCaps() : Device == NULL");
|
||||
return E_FAIL;
|
||||
}
|
||||
/////////////// Cap 검사 루틴 들어가야 함
|
||||
/*
|
||||
if(ms_pD3DDevice->m_D3dCaps->TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE )
|
||||
return S_OK;
|
||||
*/
|
||||
return E_FAIL;
|
||||
|
||||
}
|
||||
HRESULT Caldron::Base::CD3D9GraphicLayer::SetFullScreen(bool bWin)
|
||||
{
|
||||
|
||||
m_PresentParameters.Windowed = !bWin;
|
||||
|
||||
//change device mode
|
||||
if(ms_pD3DDevice == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChangeMode() : Device == NULL");
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
CheckD3DFormat(!bWin,m_ModeInfo.m_ColorFormat,&(m_PresentParameters.BackBufferFormat));
|
||||
if(FAILED(ms_pD3DDevice->Reset(&m_PresentParameters)))
|
||||
{
|
||||
// Mode Back.
|
||||
m_PresentParameters.Windowed = m_WindowInfo.m_bWindowed;
|
||||
CheckD3DFormat(!m_WindowInfo.m_bWindowed,m_ModeInfo.m_ColorFormat,&(m_PresentParameters.BackBufferFormat));
|
||||
ms_pD3DDevice->Reset(&m_PresentParameters);
|
||||
|
||||
InitScene();
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::ChangeMode() : Reset Failed");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
m_WindowInfo.m_bWindowed = !bWin;
|
||||
InitScene();
|
||||
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
// 전체화면 모드일때 Color Bit 지원 하는지 Test
|
||||
HRESULT Caldron::Base::CD3D9GraphicLayer::CheckD3DFormat(bool bFullScreen,D3DFORMAT iDepth,D3DFORMAT *pFormat)
|
||||
{
|
||||
if(bFullScreen){
|
||||
|
||||
switch(iDepth) {
|
||||
|
||||
case D3DFMT_R5G6B5:
|
||||
case D3DFMT_X1R5G5B5:
|
||||
(*pFormat)= Find16BitMode();
|
||||
break;
|
||||
case D3DFMT_A8R8G8B8:
|
||||
case D3DFMT_X8R8G8B8:
|
||||
(*pFormat)= Find32BitMode();
|
||||
break;
|
||||
default:
|
||||
(*pFormat)=D3DFMT_UNKNOWN;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//D3D will automatically use the Desktop's format
|
||||
(*pFormat)=D3DFMT_UNKNOWN;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
D3DFORMAT Caldron::Base::CD3D9GraphicLayer::Find16BitMode()
|
||||
{
|
||||
const D3DFORMAT BufferFormats[]={D3DFMT_R5G6B5,D3DFMT_X1R5G5B5};
|
||||
const int iFormatCount=sizeof(BufferFormats)/sizeof(D3DFORMAT);
|
||||
HRESULT hr;
|
||||
|
||||
for(int count=0;count<iFormatCount;count++){
|
||||
|
||||
//CheckDeviceType() is used to verify that a Device can support a particular display mode.
|
||||
hr=m_pD3D9Obj->CheckDeviceType(D3DADAPTER_DEFAULT,
|
||||
D3DDEVTYPE_HAL,
|
||||
BufferFormats[count], //The is the primary (viewable) buffer format
|
||||
BufferFormats[count], //This is the back (drawable) buffer format
|
||||
FALSE);
|
||||
|
||||
if(Succeeded(hr)){
|
||||
return BufferFormats[count];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::Find16BitMode() : 16Bit Mode Not Support");
|
||||
return D3DFMT_UNKNOWN;
|
||||
|
||||
}
|
||||
D3DFORMAT Caldron::Base::CD3D9GraphicLayer::Find32BitMode()
|
||||
{
|
||||
const D3DFORMAT BufferFormats[]={D3DFMT_A8R8G8B8,D3DFMT_X8R8G8B8};
|
||||
const int iFormatCount=sizeof(BufferFormats)/sizeof(D3DFORMAT);
|
||||
HRESULT hr;
|
||||
|
||||
for(int count=0;count<iFormatCount;count++){
|
||||
|
||||
//CheckDeviceType() is used to verify that a Device can support a particular display mode.
|
||||
hr=m_pD3D9Obj->CheckDeviceType(D3DADAPTER_DEFAULT,
|
||||
D3DDEVTYPE_HAL,
|
||||
BufferFormats[count], //The is the primary (viewable) buffer format
|
||||
BufferFormats[count], //This is the back (drawable) buffer format
|
||||
FALSE);
|
||||
|
||||
if(Succeeded(hr)){
|
||||
return BufferFormats[count];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
CLogMgr::_LogError("CD3D9GraphicLayer::Find16BitMode() : 16Bit Mode Not Support");
|
||||
return D3DFMT_UNKNOWN;
|
||||
|
||||
}
|
||||
void Caldron::Base::CD3D9GraphicLayer::Render()
|
||||
{
|
||||
if(Succeeded(CheckDeviceLost()))
|
||||
{
|
||||
RenderScene();
|
||||
Update();
|
||||
// Show the frame on the primary surface.
|
||||
ms_pD3DDevice->Present( NULL, NULL, NULL, NULL );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
150
GameTools/CaldronBase/D3D9GraphicLayer.h
Normal file
150
GameTools/CaldronBase/D3D9GraphicLayer.h
Normal file
@@ -0,0 +1,150 @@
|
||||
// D3D9GraphicLayer.h: interface for the CD3D9GraphicLayer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_D3D9GRAPHICLAYER_H__1026F404_E2F8_4612_A94C_A84F641A0C9A__INCLUDED_)
|
||||
#define AFX_D3D9GRAPHICLAYER_H__1026F404_E2F8_4612_A94C_A84F641A0C9A__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Caldron.h"
|
||||
#include "./ExceptionMgr.h"
|
||||
#include "./LogMgr.h"
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CD3D9GraphicLayer
|
||||
|
||||
* 파일 : D3D9GraphicLayer.h
|
||||
* 기능 : Caldron Engine내 D3D9 디바이스등을 크리에이트 시켜주는 BaseGraphic Layer
|
||||
실 app에서 사용할 시에 이 레이어를 상속받아 D3d Layer로 사용한다.
|
||||
* 작성일 : 2003.10.30
|
||||
* history :
|
||||
wizardbug ( 2003.10.30)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
class CD3D9GraphicLayer
|
||||
{
|
||||
public:
|
||||
class CD3D9WindowInfo
|
||||
{
|
||||
public:
|
||||
bool m_bWindowed;
|
||||
DWORD m_dwWidth;
|
||||
DWORD m_dwHeight;
|
||||
bool m_bD3DRunning;
|
||||
|
||||
HINSTANCE m_hInstance;
|
||||
|
||||
CD3D9WindowInfo()
|
||||
{
|
||||
m_bWindowed = true;
|
||||
m_dwWidth = 800;
|
||||
m_dwHeight = 600;
|
||||
m_bD3DRunning = true;
|
||||
m_hInstance = 0;
|
||||
|
||||
}
|
||||
~CD3D9WindowInfo() {}
|
||||
};
|
||||
class CD3D9ModeInfo
|
||||
{
|
||||
public:
|
||||
|
||||
DWORD m_dwVertexProcessing;
|
||||
D3DFORMAT m_ColorFormat;
|
||||
D3DFORMAT m_DepthStencilFormat;
|
||||
D3DMULTISAMPLE_TYPE m_MultiSampling;
|
||||
CD3D9ModeInfo()
|
||||
{
|
||||
m_dwVertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
||||
m_ColorFormat = D3DFMT_R5G6B5;
|
||||
m_DepthStencilFormat = D3DFMT_D16;
|
||||
m_MultiSampling = D3DMULTISAMPLE_NONE;
|
||||
|
||||
}
|
||||
~CD3D9ModeInfo() {}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
LPDIRECT3D9 m_pD3D9Obj;
|
||||
static LPDIRECT3DDEVICE9 ms_pD3DDevice;
|
||||
HWND m_hWnd;
|
||||
|
||||
D3DPRESENT_PARAMETERS m_PresentParameters;
|
||||
D3DCAPS9 m_DeviceCaps;
|
||||
|
||||
|
||||
CExceptionMgr *m_pExceptionMgr;
|
||||
|
||||
|
||||
public:
|
||||
static CD3D9WindowInfo m_WindowInfo;
|
||||
static CD3D9ModeInfo m_ModeInfo;
|
||||
|
||||
static inline void _GetWindowSize(DWORD &dwWidth,DWORD &dwHeight)
|
||||
{
|
||||
dwWidth = m_WindowInfo.m_dwWidth;
|
||||
dwHeight = m_WindowInfo.m_dwHeight;
|
||||
}
|
||||
//static inline CD3D9ModeInfo _GetModeInfo() { return m_ModeInfo;}
|
||||
static inline LPDIRECT3DDEVICE9 _GetDevice() { return (ms_pD3DDevice != NULL) ? ms_pD3DDevice : NULL; }
|
||||
inline HWND GetHwnd() { return m_hWnd;}
|
||||
inline bool IsFullScreen() { return m_WindowInfo.m_bWindowed; }
|
||||
inline bool IsD3DRunning() { return m_WindowInfo.m_bD3DRunning; }
|
||||
// Change Fullscreen Mode
|
||||
HRESULT SetFullScreen(bool bWin);
|
||||
|
||||
CD3D9GraphicLayer();
|
||||
virtual ~CD3D9GraphicLayer();
|
||||
// Device Create
|
||||
HRESULT InitD3DLayer(HINSTANCE hInstance,
|
||||
HWND hWnd,
|
||||
DWORD dwWidth,
|
||||
DWORD dwHeight,
|
||||
bool bWindowed = true,
|
||||
D3DFORMAT ColorFormat = D3DFMT_R5G6B5,
|
||||
D3DFORMAT ZFormat = D3DFMT_D16,
|
||||
DWORD dwVertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
||||
D3DMULTISAMPLE_TYPE Antial = D3DMULTISAMPLE_NONE
|
||||
);
|
||||
|
||||
void SaveSetting(); // Save D3D Create Info
|
||||
void LoadSetting(); // Load D3D Create Info
|
||||
// Device 로스트 되었나 테스팅
|
||||
HRESULT CheckDeviceLost();
|
||||
// Change Bit , width, height ..etc..
|
||||
HRESULT ChangeMode(DWORD dwWidth, DWORD dwHeight, D3DFORMAT Pixel, D3DFORMAT Zbuffer,UINT UIPresent = D3DPRESENT_INTERVAL_IMMEDIATE);
|
||||
HRESULT ChangePresentMode(UINT UIPresent = D3DPRESENT_INTERVAL_IMMEDIATE);
|
||||
|
||||
// 전체 모드시 Color Bit 지원되는가 check
|
||||
HRESULT CheckD3DFormat(bool bFullScreen,D3DFORMAT iDepth,D3DFORMAT *pFormat);
|
||||
D3DFORMAT Find16BitMode();
|
||||
D3DFORMAT Find32BitMode();
|
||||
|
||||
void ReleaseAll();
|
||||
|
||||
virtual HRESULT CheckDeviceCaps();
|
||||
virtual void InitScene();
|
||||
void Render();
|
||||
// 실 렌더링 코드가 들어갈 부분 Render Scene 부분
|
||||
virtual void RenderScene(){};
|
||||
virtual void Update(){};
|
||||
virtual void Destroy(){};
|
||||
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_D3D9GRAPHICLAYER_H__1026F404_E2F8_4612_A94C_A84F641A0C9A__INCLUDED_)
|
||||
444
GameTools/CaldronBase/DInput8Mgr.cpp
Normal file
444
GameTools/CaldronBase/DInput8Mgr.cpp
Normal file
@@ -0,0 +1,444 @@
|
||||
// DInput9Mgr.cpp: implementation of the CDInput9Mgr class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "DInput8Mgr.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int Caldron::Base::CDInput8Mgr::ms_iLockKey = -1;
|
||||
DIMOUSESTATE Caldron::Base::CDInput8Mgr::m_MouseState;
|
||||
int Caldron::Base::CDInput8Mgr::m_iMouseMove[MOUSE_AXISNUMS];
|
||||
char Caldron::Base::CDInput8Mgr::m_strKeys[256];
|
||||
char Caldron::Base::CDInput8Mgr::m_strBackKeys[256];
|
||||
LPDIRECTINPUTDEVICE8 Caldron::Base::CDInput8Mgr::m_lpMouseDevice = NULL;
|
||||
|
||||
Caldron::Base::CDInput8Mgr::CDInput8Mgr()
|
||||
{
|
||||
|
||||
m_lpKeyboardDevice = NULL;
|
||||
m_lpMouseDevice = NULL;
|
||||
m_lpDirectInput = NULL;
|
||||
|
||||
}
|
||||
|
||||
Caldron::Base::CDInput8Mgr::~CDInput8Mgr()
|
||||
{
|
||||
if(m_lpKeyboardDevice)
|
||||
{
|
||||
m_lpKeyboardDevice->Unacquire();
|
||||
SafeRelease(m_lpKeyboardDevice);
|
||||
}
|
||||
if(m_lpMouseDevice)
|
||||
{
|
||||
m_lpMouseDevice->Unacquire();
|
||||
SafeRelease(m_lpMouseDevice);
|
||||
m_lpMouseDevice = NULL;
|
||||
}
|
||||
|
||||
if(m_lpDirectInput)
|
||||
{
|
||||
SafeRelease(m_lpDirectInput);
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT Caldron::Base::CDInput8Mgr::InitInputMgr(HINSTANCE hInstance,HWND hWnd,DWORD dwKeyboardLevel,DWORD dwMouseLevel)
|
||||
{
|
||||
HRESULT hr;
|
||||
// direct input create
|
||||
if(Failed(hr = DirectInput8Create(hInstance,DIRECTINPUT_VERSION,IID_IDirectInput8,(void **)&m_lpDirectInput,NULL)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : DInput8 Create Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
//device create
|
||||
if(Failed(hr = m_lpDirectInput->CreateDevice(GUID_SysMouse,&m_lpMouseDevice,NULL)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse Device Create Failed");
|
||||
return hr;
|
||||
}
|
||||
if(Failed(hr = m_lpDirectInput->CreateDevice(GUID_SysKeyboard,&m_lpKeyboardDevice,NULL)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Keyboard Device Create Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
|
||||
//device information interface setting
|
||||
if(Failed(hr = m_lpKeyboardDevice->SetDataFormat(&c_dfDIKeyboard)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Keyboard DataFormat Set Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
if(Failed(hr = m_lpMouseDevice->SetDataFormat(&c_dfDIMouse)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse DataFormat Set Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
|
||||
//device cooperative setting (Ű ¾î¶»°Ô °¡·ÎÿÁö.)
|
||||
if(Failed(hr = m_lpKeyboardDevice->SetCooperativeLevel(hWnd,dwKeyboardLevel)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Keyboard CooperativeLevel Set Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
if(Failed(hr = m_lpMouseDevice->SetCooperativeLevel(hWnd,dwMouseLevel)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse CooperativeLevel Set Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
|
||||
//device acquire
|
||||
|
||||
if(Failed(hr = m_lpKeyboardDevice->Acquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : KeyBoard Acquire Failed");
|
||||
return hr;
|
||||
}
|
||||
if(Failed(hr = m_lpMouseDevice->Acquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse Acquire Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
|
||||
// information update
|
||||
memset(m_strKeys,0,sizeof(char) * 256);
|
||||
memset(m_strBackKeys,0,sizeof(char) * 256);
|
||||
|
||||
|
||||
if(Failed(hr = m_lpKeyboardDevice->GetDeviceState(256,&m_strKeys)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Keyboard DeviceState Read Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
if(Failed(hr = m_lpMouseDevice->GetDeviceState(sizeof(DIMOUSESTATE),&m_MouseState)))
|
||||
{
|
||||
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse DeviceState Read Failed");
|
||||
return hr;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
HRESULT Caldron::Base::CDInput8Mgr::Acquire()
|
||||
{
|
||||
HRESULT hr;
|
||||
if(Failed(hr = m_lpMouseDevice->Acquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse Acquire Failed");
|
||||
return hr;
|
||||
}
|
||||
if(Failed(hr = m_lpKeyboardDevice->Acquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Keyboard Acquire Failed");
|
||||
return hr;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
HRESULT Caldron::Base::CDInput8Mgr::Unacquire()
|
||||
{
|
||||
HRESULT hr;
|
||||
if(Failed(hr = m_lpMouseDevice->Unacquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse Unacquire Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
|
||||
if(Failed(hr = m_lpKeyboardDevice->Unacquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Keyboard Unacquire Failed");
|
||||
return hr;
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
|
||||
bool Caldron::Base::CDInput8Mgr ::PushButton(int index,int iKey)
|
||||
{
|
||||
if(ms_iLockKey != iKey)
|
||||
return false;
|
||||
|
||||
HRESULT hr;
|
||||
if(Failed(hr = m_lpMouseDevice->Acquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse Acquire Failed");
|
||||
return false;
|
||||
|
||||
}
|
||||
if(Failed(hr = m_lpMouseDevice->GetDeviceState(sizeof(DIMOUSESTATE),&m_MouseState)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse DeviceState Get Failed");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return (m_MouseState.rgbButtons[index] &0x80) ? true : false;
|
||||
}
|
||||
|
||||
bool Caldron::Base::CDInput8Mgr::UpButton(int index,int iKey)
|
||||
{
|
||||
if(ms_iLockKey != iKey)
|
||||
return false;
|
||||
|
||||
HRESULT hr;
|
||||
if(Failed(hr = m_lpMouseDevice->Acquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse Acquire Failed");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if(Failed(hr = m_lpMouseDevice->GetDeviceState(sizeof(DIMOUSESTATE),&m_MouseState)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse DeviceState Get Failed");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return (m_MouseState.rgbButtons[index] &0x80) ? false : true;
|
||||
}
|
||||
bool Caldron::Base::CDInput8Mgr:: PushOnceKey(int index,int iKey)
|
||||
{
|
||||
if(ms_iLockKey != iKey)
|
||||
return false;
|
||||
|
||||
bool bReturn = (m_strKeys[index] &0x80) ? true : false;
|
||||
if(bReturn && (m_strBackKeys[index] != m_strKeys[index]))
|
||||
return bReturn;
|
||||
return false;
|
||||
|
||||
}
|
||||
bool Caldron::Base::CDInput8Mgr::KeyStrok(char *strBuffer,int &iPos)
|
||||
{
|
||||
bool bPush = false;
|
||||
|
||||
for(int i = 0; i < 256; i++ )
|
||||
{
|
||||
|
||||
bPush = (m_strKeys[i] &0x80) ? true : false;
|
||||
if(bPush && (m_strBackKeys[i] != m_strKeys[i])) {
|
||||
switch(i)
|
||||
{
|
||||
case 0x02:
|
||||
strBuffer[iPos++] = '1';
|
||||
break;
|
||||
case 0x03:
|
||||
strBuffer[iPos++] = '2';
|
||||
break;
|
||||
case 0x04:
|
||||
strBuffer[iPos++] = '3';
|
||||
break;
|
||||
case 0x05:
|
||||
strBuffer[iPos++] = '4';
|
||||
break;
|
||||
case 0x06:
|
||||
strBuffer[iPos++] = '5';
|
||||
break;
|
||||
case 0x07:
|
||||
strBuffer[iPos++] = '6';
|
||||
break;
|
||||
case 0x08:
|
||||
strBuffer[iPos++] = '7';
|
||||
break;
|
||||
case 0x09:
|
||||
strBuffer[iPos++] = '8';
|
||||
break;
|
||||
case 0x0A:
|
||||
strBuffer[iPos++] = '9';
|
||||
break;
|
||||
case 0x0B:
|
||||
strBuffer[iPos++] = '0';
|
||||
break;
|
||||
case 0x0C:
|
||||
strBuffer[iPos++] = '-';
|
||||
break;
|
||||
case 0x0D:
|
||||
strBuffer[iPos++] = '=';
|
||||
break;
|
||||
case 0x0E:
|
||||
strBuffer[iPos--] = 0;
|
||||
break;
|
||||
case 0x0F:
|
||||
strBuffer[iPos++] = '\t';
|
||||
break;
|
||||
case 0x10:
|
||||
strBuffer[iPos++] = 'Q';
|
||||
break;
|
||||
case 0x11:
|
||||
strBuffer[iPos++] = 'W';
|
||||
break;
|
||||
case 0x12:
|
||||
strBuffer[iPos++] = 'E';
|
||||
break;
|
||||
case 0x13:
|
||||
strBuffer[iPos++] = 'R';
|
||||
break;
|
||||
case 0x14:
|
||||
strBuffer[iPos++] = 'T';
|
||||
break;
|
||||
case 0x15:
|
||||
strBuffer[iPos++] = 'Y';
|
||||
break;
|
||||
case 0x16:
|
||||
strBuffer[iPos++] = 'U';
|
||||
break;
|
||||
case 0x17:
|
||||
strBuffer[iPos++] = 'I';
|
||||
break;
|
||||
case 0x18:
|
||||
strBuffer[iPos++] = 'O';
|
||||
break;
|
||||
case 0x19:
|
||||
strBuffer[iPos++] = 'P';
|
||||
break;
|
||||
case 0x1E:
|
||||
strBuffer[iPos++] = 'A';
|
||||
break;
|
||||
case 0x1F:
|
||||
strBuffer[iPos++] = 'S';
|
||||
break;
|
||||
case 0x20:
|
||||
strBuffer[iPos++] = 'D';
|
||||
break;
|
||||
case 0x21:
|
||||
strBuffer[iPos++] = 'F';
|
||||
break;
|
||||
case 0x22:
|
||||
strBuffer[iPos++] = 'G';
|
||||
break;
|
||||
case 0x23:
|
||||
strBuffer[iPos++] = 'H';
|
||||
break;
|
||||
case 0x24:
|
||||
strBuffer[iPos++] = 'J';
|
||||
break;
|
||||
case 0x25:
|
||||
strBuffer[iPos++] = 'K';
|
||||
break;
|
||||
case 0x26:
|
||||
strBuffer[iPos++] = 'L';
|
||||
break;
|
||||
case 0x27:
|
||||
strBuffer[iPos++] = ';';
|
||||
break;
|
||||
case 0x2B:
|
||||
strBuffer[iPos++] = '\\';
|
||||
break;
|
||||
case 0x2C:
|
||||
strBuffer[iPos++] = 'Z';
|
||||
break;
|
||||
case 0x2D:
|
||||
strBuffer[iPos++] = 'X';
|
||||
break;
|
||||
case 0x2E:
|
||||
strBuffer[iPos++] = 'C';
|
||||
break;
|
||||
case 0x2F:
|
||||
strBuffer[iPos++] = 'V';
|
||||
break;
|
||||
case 0x30:
|
||||
strBuffer[iPos++] = 'B';
|
||||
break;
|
||||
case 0x31:
|
||||
strBuffer[iPos++] = 'N';
|
||||
break;
|
||||
case 0x32:
|
||||
strBuffer[iPos++] = 'M';
|
||||
break;
|
||||
case 0x33:
|
||||
strBuffer[iPos++] = ',';
|
||||
break;
|
||||
case 0x34:
|
||||
strBuffer[iPos++] = '.';
|
||||
break;
|
||||
case 0x39:
|
||||
strBuffer[iPos++] = ' ';
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return bPush;
|
||||
|
||||
}
|
||||
bool Caldron::Base::CDInput8Mgr::PushKey(int index,int iKey)
|
||||
{
|
||||
if(ms_iLockKey != iKey)
|
||||
return false;
|
||||
|
||||
return (m_strKeys[index] &0x80) ? true : false;
|
||||
|
||||
}
|
||||
bool Caldron::Base::CDInput8Mgr:: UpKey(int index,int iKey)
|
||||
{
|
||||
if(ms_iLockKey != iKey)
|
||||
return false;
|
||||
|
||||
return (m_strKeys[index] &0x80) ? false : true;
|
||||
}
|
||||
|
||||
HRESULT Caldron::Base::CDInput8Mgr::Update()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
// Key
|
||||
// memset(m_strKeys,0,256);
|
||||
if(Failed(hr = m_lpKeyboardDevice->Acquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : KeyBoard Acquire Failed");
|
||||
return hr;
|
||||
}
|
||||
memcpy(m_strBackKeys,m_strKeys,sizeof(char) * 256);
|
||||
|
||||
if(Failed(hr = m_lpKeyboardDevice->GetDeviceState(256,&m_strKeys)))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Keyboard DeviceState Get Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
|
||||
// Mouse
|
||||
if(Failed(hr = m_lpMouseDevice->Acquire()))
|
||||
{
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse Acquire Failed");
|
||||
return hr;
|
||||
}
|
||||
|
||||
if(Failed(hr = m_lpMouseDevice->GetDeviceState(sizeof(DIMOUSESTATE),&m_MouseState)))
|
||||
{
|
||||
|
||||
CLogMgr::_LogError("CDInput8Mgr::InitInputMgr() : Mouse DeviceState Get Failed");
|
||||
return hr;
|
||||
|
||||
}
|
||||
|
||||
m_iMouseMove[MOUSE_XAXIS] = m_MouseState.lX;
|
||||
m_iMouseMove[MOUSE_YAXIS] = m_MouseState.lY;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
void Caldron::Base::CDInput8Mgr::GetMouseMove(int &iX,int &iY,int iKey)
|
||||
{
|
||||
if(ms_iLockKey != iKey)
|
||||
{
|
||||
iX = 0;
|
||||
iY = 0;
|
||||
}
|
||||
iX = m_iMouseMove[MOUSE_XAXIS];
|
||||
iY = m_iMouseMove[MOUSE_YAXIS];
|
||||
}
|
||||
|
||||
98
GameTools/CaldronBase/DInput8Mgr.h
Normal file
98
GameTools/CaldronBase/DInput8Mgr.h
Normal file
@@ -0,0 +1,98 @@
|
||||
// DInput9Mgr.h: interface for the CDInput9Mgr class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_DINPUT9MGR_H__7F904814_C54A_42A0_A3F0_43B3EC33364B__INCLUDED_)
|
||||
#define AFX_DINPUT9MGR_H__7F904814_C54A_42A0_A3F0_43B3EC33364B__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <Dinput.h>
|
||||
#include "Caldron.h"
|
||||
#include "./LogMgr.h"
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CDInput9Mgr
|
||||
|
||||
* 파일 : DInput8Mgr.h
|
||||
* 기능 : Caldron Engine내 Direct Input9 을 이용한 input 키, mouse 처리 class
|
||||
* 작성일 : 2003.10.31
|
||||
* history :
|
||||
wizardbug ( 2003.10.31)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
|
||||
|
||||
namespace Base
|
||||
{
|
||||
enum DINPUT8DEVICES
|
||||
{
|
||||
DINPUT8_KEYBOARD,
|
||||
DINPUT8_MOUSE,
|
||||
};
|
||||
enum DINPUT8MOUSEBUTTON // Mouse Input
|
||||
{
|
||||
MOUSE_LBUTTON,
|
||||
MOUSE_RBUTTON,
|
||||
MOUSE_BUTTONNUMS,
|
||||
};
|
||||
enum DINPUT8MOUSEAXIS // Mouse Move Axis
|
||||
{
|
||||
MOUSE_XAXIS,
|
||||
MOUSE_YAXIS,
|
||||
MOUSE_AXISNUMS,
|
||||
|
||||
};
|
||||
|
||||
class CDInput8Mgr
|
||||
{
|
||||
protected:
|
||||
LPDIRECTINPUT8 m_lpDirectInput;
|
||||
LPDIRECTINPUTDEVICE8 m_lpKeyboardDevice;
|
||||
static LPDIRECTINPUTDEVICE8 m_lpMouseDevice;
|
||||
|
||||
static DIMOUSESTATE m_MouseState;
|
||||
static int m_iMouseMove[MOUSE_AXISNUMS];
|
||||
static char m_strKeys[256];
|
||||
static char m_strBackKeys[256];
|
||||
|
||||
static int ms_iLockKey;
|
||||
|
||||
public:
|
||||
CDInput8Mgr();
|
||||
~CDInput8Mgr();
|
||||
|
||||
HRESULT InitInputMgr(HINSTANCE ,HWND ,DWORD dwKeyboard = DISCL_FOREGROUND,DWORD dwMouse = DISCL_FOREGROUND);
|
||||
HRESULT Acquire();
|
||||
HRESULT Unacquire();
|
||||
HRESULT Update();
|
||||
|
||||
static bool PushButton(int ,int iKey = -1);
|
||||
static bool UpButton(int ,int iKey = -1);
|
||||
|
||||
static bool PushOnceKey(int ,int iKey = -1);
|
||||
static bool PushKey(int ,int iKey = -1);
|
||||
static bool UpKey(int ,int iKey = -1);
|
||||
|
||||
static bool KeyStrok(char *strBuffer,int &iPos);
|
||||
|
||||
static void GetMouseMove(int &iX,int &iY ,int iKey = -1);
|
||||
|
||||
static void Lock(const int &iKey) { ms_iLockKey = iKey;}
|
||||
static void Unlock() { ms_iLockKey = -1;}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // !defined(AFX_DINPUT9MGR_H__7F904814_C54A_42A0_A3F0_43B3EC33364B__INCLUDED_)
|
||||
557
GameTools/CaldronBase/ExceptionMgr.cpp
Normal file
557
GameTools/CaldronBase/ExceptionMgr.cpp
Normal file
@@ -0,0 +1,557 @@
|
||||
|
||||
|
||||
#include "./exceptionmgr.h"
|
||||
#include "./LogMgr.h"
|
||||
|
||||
|
||||
#pragma comment(linker, "/defaultlib:dbghelp.lib")
|
||||
|
||||
|
||||
namespace Caldron { namespace Base {
|
||||
|
||||
LPTOP_LEVEL_EXCEPTION_FILTER CExceptionMgr::m_lpPrevFilter = NULL;
|
||||
HANDLE CExceptionMgr::m_hProcess = NULL;
|
||||
|
||||
|
||||
CExceptionMgr::CExceptionMgr(void)
|
||||
{
|
||||
|
||||
m_lpPrevFilter = SetUnhandledExceptionFilter(Caldron::Base::CExceptionMgr::ExceptionFilter);
|
||||
m_hProcess = GetCurrentProcess();
|
||||
|
||||
|
||||
}
|
||||
CExceptionMgr::~CExceptionMgr(void)
|
||||
{
|
||||
SetUnhandledExceptionFilter(m_lpPrevFilter);
|
||||
|
||||
}
|
||||
LONG WINAPI CExceptionMgr::ExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo )
|
||||
{
|
||||
WriteExceptionReport(pExceptionInfo);
|
||||
if(m_lpPrevFilter)
|
||||
return m_lpPrevFilter(pExceptionInfo);
|
||||
else
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
}
|
||||
void CExceptionMgr::WriteExceptionReport(PEXCEPTION_POINTERS pExceptionInfo )
|
||||
{
|
||||
// Start out with a banner
|
||||
CLogMgr::_LogNoHeader("========= Exception Report ============\n");
|
||||
PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
|
||||
|
||||
// First print information about the type of fault
|
||||
CLogMgr::_LogNoHeader("Exception Code : %08X %s\n",pExceptionRecord->ExceptionCode,GetExceptionString(pExceptionRecord->ExceptionCode) );
|
||||
|
||||
// Now print information about where the fault occured
|
||||
TCHAR szFaultingModule[MAX_PATH];
|
||||
DWORD section, offset;
|
||||
GetLogicalAddress( pExceptionRecord->ExceptionAddress,
|
||||
szFaultingModule,
|
||||
sizeof( szFaultingModule ),
|
||||
section, offset );
|
||||
|
||||
CLogMgr::_LogNoHeader("Fault address: %08X %02X:%08X %s\n",
|
||||
pExceptionRecord->ExceptionAddress,
|
||||
section, offset, szFaultingModule );
|
||||
|
||||
PCONTEXT pCtx = pExceptionInfo->ContextRecord;
|
||||
|
||||
// Show the registers
|
||||
#ifdef _M_IX86 // X86 Only!
|
||||
CLogMgr::_LogNoHeader("\nRegisters :\n");
|
||||
CLogMgr::_LogNoHeader("EAX:%08X\nEBX:%08X\nECX:%08X\nEDX:%08X\nESI:%08X\nEDI:%08X\n",
|
||||
pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx,
|
||||
pCtx->Esi, pCtx->Edi );
|
||||
|
||||
CLogMgr::_LogNoHeader("CS:EIP:%04X:%08X\n", pCtx->SegCs, pCtx->Eip );
|
||||
CLogMgr::_LogNoHeader("SS:ESP:%04X:%08X EBP:%08X\n",
|
||||
pCtx->SegSs, pCtx->Esp, pCtx->Ebp );
|
||||
CLogMgr::_LogNoHeader("DS:%04X ES:%04X FS:%04X GS:%04X\n",
|
||||
pCtx->SegDs, pCtx->SegEs, pCtx->SegFs, pCtx->SegGs );
|
||||
CLogMgr::_LogNoHeader("Flags:%08X\n",pCtx->EFlags );
|
||||
|
||||
#endif
|
||||
|
||||
SymSetOptions( SYMOPT_DEFERRED_LOADS );
|
||||
|
||||
// Initialize DbgHelp
|
||||
if ( !SymInitialize( GetCurrentProcess(), 0, TRUE ) )
|
||||
return;
|
||||
|
||||
CONTEXT trashableContext = *pCtx;
|
||||
|
||||
WriteCallStack( &trashableContext, false );
|
||||
|
||||
#ifdef _M_IX86 // X86 Only!
|
||||
|
||||
CLogMgr::_LogNoHeader("======================================\n");
|
||||
CLogMgr::_LogNoHeader("Local Variable & Parameters\n");
|
||||
|
||||
trashableContext = *pCtx;
|
||||
WriteCallStack( &trashableContext, true );
|
||||
|
||||
CLogMgr::_LogNoHeader("======================================\n");
|
||||
CLogMgr::_LogNoHeader("Global Variable\n");
|
||||
|
||||
SymEnumSymbols( GetCurrentProcess(),
|
||||
(DWORD64)GetModuleHandle(szFaultingModule),
|
||||
0, EnumerateSymbolsCallback, 0 );
|
||||
|
||||
#endif // X86 Only!
|
||||
|
||||
SymCleanup( GetCurrentProcess() );
|
||||
|
||||
CLogMgr::_LogNoHeader("\n");
|
||||
}
|
||||
LPSTR CExceptionMgr::GetExceptionString(DWORD dwCode)
|
||||
{
|
||||
#define EXCEPTION( x ) case EXCEPTION_##x: return _T(#x);
|
||||
|
||||
switch ( dwCode )
|
||||
{
|
||||
EXCEPTION( ACCESS_VIOLATION )
|
||||
EXCEPTION( DATATYPE_MISALIGNMENT )
|
||||
EXCEPTION( BREAKPOINT )
|
||||
EXCEPTION( SINGLE_STEP )
|
||||
EXCEPTION( ARRAY_BOUNDS_EXCEEDED )
|
||||
EXCEPTION( FLT_DENORMAL_OPERAND )
|
||||
EXCEPTION( FLT_DIVIDE_BY_ZERO )
|
||||
EXCEPTION( FLT_INEXACT_RESULT )
|
||||
EXCEPTION( FLT_INVALID_OPERATION )
|
||||
EXCEPTION( FLT_OVERFLOW )
|
||||
EXCEPTION( FLT_STACK_CHECK )
|
||||
EXCEPTION( FLT_UNDERFLOW )
|
||||
EXCEPTION( INT_DIVIDE_BY_ZERO )
|
||||
EXCEPTION( INT_OVERFLOW )
|
||||
EXCEPTION( PRIV_INSTRUCTION )
|
||||
EXCEPTION( IN_PAGE_ERROR )
|
||||
EXCEPTION( ILLEGAL_INSTRUCTION )
|
||||
EXCEPTION( NONCONTINUABLE_EXCEPTION )
|
||||
EXCEPTION( STACK_OVERFLOW )
|
||||
EXCEPTION( INVALID_DISPOSITION )
|
||||
EXCEPTION( GUARD_PAGE )
|
||||
EXCEPTION( INVALID_HANDLE )
|
||||
}
|
||||
|
||||
// If not one of the "known" exceptions, try to get the string
|
||||
// from NTDLL.DLL's message table.
|
||||
|
||||
static TCHAR szBuffer[512] = { 0 };
|
||||
|
||||
FormatMessage( FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
|
||||
GetModuleHandle( _T("NTDLL.DLL") ),
|
||||
dwCode, 0, szBuffer, sizeof( szBuffer ), 0 );
|
||||
|
||||
return szBuffer;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Given a linear address, locates the module, section, and offset containing
|
||||
// that address.
|
||||
//
|
||||
// Note: the szModule paramater buffer is an output buffer of length specified
|
||||
// by the len parameter (in characters!)
|
||||
//=============================================================================
|
||||
|
||||
BOOL CExceptionMgr::GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len,DWORD& section, DWORD& offset)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
|
||||
if ( !VirtualQuery( addr, &mbi, sizeof(mbi) ) )
|
||||
return FALSE;
|
||||
|
||||
DWORD hMod = (DWORD)mbi.AllocationBase;
|
||||
|
||||
if ( !GetModuleFileName( (HMODULE)hMod, szModule, len ) )
|
||||
return FALSE;
|
||||
|
||||
// Point to the DOS header in memory
|
||||
PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)hMod;
|
||||
|
||||
// From the DOS header, find the NT (PE) header
|
||||
PIMAGE_NT_HEADERS pNtHdr = (PIMAGE_NT_HEADERS)(hMod + pDosHdr->e_lfanew);
|
||||
|
||||
PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION( pNtHdr );
|
||||
|
||||
DWORD rva = (DWORD)addr - hMod; // RVA is offset from module load address
|
||||
|
||||
// Iterate through the section table, looking for the one that encompasses
|
||||
// the linear address.
|
||||
for ( unsigned i = 0;
|
||||
i < pNtHdr->FileHeader.NumberOfSections;
|
||||
i++, pSection++ )
|
||||
{
|
||||
DWORD sectionStart = pSection->VirtualAddress;
|
||||
DWORD sectionEnd = sectionStart
|
||||
+ max(pSection->SizeOfRawData, pSection->Misc.VirtualSize);
|
||||
|
||||
// Is the address in this section???
|
||||
if ( (rva >= sectionStart) && (rva <= sectionEnd) )
|
||||
{
|
||||
// Yes, address is in the section. Calculate section and offset,
|
||||
// and store in the "section" & "offset" params, which were
|
||||
// passed by reference.
|
||||
section = i+1;
|
||||
offset = rva - sectionStart;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE; // Should never get here!
|
||||
|
||||
}
|
||||
void CExceptionMgr::WriteCallStack(PCONTEXT pContext,bool bWriteVariables )
|
||||
{
|
||||
|
||||
CLogMgr::_LogNoHeader("==========Call Stack==========\n");
|
||||
CLogMgr::_LogNoHeader("Address Frame Function SourceFile\n");
|
||||
|
||||
DWORD dwMachineType = 0;
|
||||
// Could use SymSetOptions here to add the SYMOPT_DEFERRED_LOADS flag
|
||||
|
||||
STACKFRAME sf;
|
||||
memset( &sf, 0, sizeof(sf) );
|
||||
|
||||
#ifdef _M_IX86
|
||||
// Initialize the STACKFRAME structure for the first call. This is only
|
||||
// necessary for Intel CPUs, and isn't mentioned in the documentation.
|
||||
sf.AddrPC.Offset = pContext->Eip;
|
||||
sf.AddrPC.Mode = AddrModeFlat;
|
||||
sf.AddrStack.Offset = pContext->Esp;
|
||||
sf.AddrStack.Mode = AddrModeFlat;
|
||||
sf.AddrFrame.Offset = pContext->Ebp;
|
||||
sf.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
dwMachineType = IMAGE_FILE_MACHINE_I386;
|
||||
#endif
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
// Get the next stack frame
|
||||
if ( ! StackWalk( dwMachineType,
|
||||
m_hProcess,
|
||||
GetCurrentThread(),
|
||||
&sf,
|
||||
pContext,
|
||||
0,
|
||||
SymFunctionTableAccess,
|
||||
SymGetModuleBase,
|
||||
0 ) )
|
||||
break;
|
||||
|
||||
if ( 0 == sf.AddrFrame.Offset ) // Basic sanity check to make sure
|
||||
break; // the frame is OK. Bail if not.
|
||||
|
||||
CLogMgr::_LogNoHeader("%08X %08X ",sf.AddrPC.Offset, sf.AddrFrame.Offset );
|
||||
|
||||
// Get the name of the function for this stack frame entry
|
||||
BYTE symbolBuffer[ sizeof(SYMBOL_INFO) + 1024 ];
|
||||
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)symbolBuffer;
|
||||
pSymbol->SizeOfStruct = sizeof(symbolBuffer);
|
||||
pSymbol->MaxNameLen = 1024;
|
||||
|
||||
DWORD64 symDisplacement = 0; // Displacement of the input address,
|
||||
// relative to the start of the symbol
|
||||
|
||||
if ( SymFromAddr(m_hProcess,sf.AddrPC.Offset,&symDisplacement,pSymbol))
|
||||
{
|
||||
CLogMgr::_LogNoHeader("%hs+%I64X",pSymbol->Name, symDisplacement );
|
||||
|
||||
}
|
||||
else // No symbol found. Print out the logical address instead.
|
||||
{
|
||||
TCHAR szModule[MAX_PATH] = _T("");
|
||||
DWORD section = 0, offset = 0;
|
||||
|
||||
GetLogicalAddress( (PVOID)sf.AddrPC.Offset,
|
||||
szModule, sizeof(szModule), section, offset );
|
||||
CLogMgr::_LogNoHeader("%04X:%08X %s",section, offset, szModule );
|
||||
|
||||
}
|
||||
|
||||
// Get the source line for this stack frame entry
|
||||
IMAGEHLP_LINE lineInfo = { sizeof(IMAGEHLP_LINE) };
|
||||
DWORD dwLineDisplacement;
|
||||
if ( SymGetLineFromAddr( m_hProcess, sf.AddrPC.Offset,
|
||||
&dwLineDisplacement, &lineInfo ) )
|
||||
{
|
||||
CLogMgr::_LogNoHeader(" %s line %u",lineInfo.FileName,lineInfo.LineNumber);
|
||||
|
||||
}
|
||||
CLogMgr::_LogNoHeader("\n");
|
||||
|
||||
// Write out the variables, if desired
|
||||
if ( bWriteVariables )
|
||||
{
|
||||
// Use SymSetContext to get just the locals/params for this frame
|
||||
IMAGEHLP_STACK_FRAME imagehlpStackFrame;
|
||||
imagehlpStackFrame.InstructionOffset = sf.AddrPC.Offset;
|
||||
SymSetContext( m_hProcess, &imagehlpStackFrame, 0 );
|
||||
|
||||
// Enumerate the locals/parameters
|
||||
SymEnumSymbols( m_hProcess, 0, 0, EnumerateSymbolsCallback, &sf );
|
||||
CLogMgr::_LogNoHeader("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CALLBACK CExceptionMgr::EnumerateSymbolsCallback( PSYMBOL_INFO pSymInfo, ULONG SymbolSize,PVOID UserContext )
|
||||
{
|
||||
|
||||
char szBuffer[2048];
|
||||
|
||||
__try
|
||||
{
|
||||
if ( FormatSymbolValue( pSymInfo, (STACKFRAME*)UserContext,
|
||||
szBuffer, sizeof(szBuffer) ) )
|
||||
CLogMgr::_LogNoHeader("\t%s\n",szBuffer);
|
||||
|
||||
|
||||
}
|
||||
__except( 1 )
|
||||
{
|
||||
CLogMgr::_LogNoHeader("punting on symbol %s\n",pSymInfo->Name);
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Given a SYMBOL_INFO representing a particular variable, displays its
|
||||
// contents. If it's a user defined type, display the members and their
|
||||
// values.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool CExceptionMgr::FormatSymbolValue( PSYMBOL_INFO pSym, STACKFRAME *sf, char * pszBuffer, unsigned cbBuffer )
|
||||
{
|
||||
char * pszCurrBuffer = pszBuffer;
|
||||
|
||||
// Indicate if the variable is a local or parameter
|
||||
if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER )
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, "Parameter " );
|
||||
else if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_LOCAL )
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, "Local " );
|
||||
|
||||
// If it's a function, don't do anything.
|
||||
if ( pSym->Tag == 5 ) // SymTagFunction from CVCONST.H from the DIA SDK
|
||||
return false;
|
||||
|
||||
// Emit the variable name
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, "\'%s\'", pSym->Name );
|
||||
|
||||
DWORD_PTR pVariable = 0; // Will point to the variable's data in memory
|
||||
|
||||
if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE )
|
||||
{
|
||||
// if ( pSym->Register == 8 ) // EBP is the value 8 (in DBGHELP 5.1)
|
||||
{ // This may change!!!
|
||||
pVariable = sf->AddrFrame.Offset;
|
||||
pVariable += (DWORD_PTR)pSym->Address;
|
||||
}
|
||||
// else
|
||||
// return false;
|
||||
}
|
||||
else if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER )
|
||||
{
|
||||
return false; // Don't try to report register variable
|
||||
}
|
||||
else
|
||||
{
|
||||
pVariable = (DWORD_PTR)pSym->Address; // It must be a global variable
|
||||
}
|
||||
|
||||
// Determine if the variable is a user defined type (UDT). IF so, bHandled
|
||||
// will return true.
|
||||
bool bHandled;
|
||||
pszCurrBuffer = DumpTypeIndex(pszCurrBuffer,pSym->ModBase, pSym->TypeIndex,
|
||||
0, pVariable, bHandled );
|
||||
|
||||
if ( !bHandled )
|
||||
{
|
||||
// The symbol wasn't a UDT, so do basic, stupid formatting of the
|
||||
// variable. Based on the size, we're assuming it's a char, WORD, or
|
||||
// DWORD.
|
||||
BasicType basicType = GetBasicType( pSym->TypeIndex, pSym->ModBase );
|
||||
|
||||
pszCurrBuffer = FormatOutputValue(pszCurrBuffer, basicType, pSym->Size,
|
||||
(PVOID)pVariable );
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// If it's a user defined type (UDT), recurse through its members until we're
|
||||
// at fundamental types. When he hit fundamental types, return
|
||||
// bHandled = false, so that FormatSymbolValue() will format them.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
char * CExceptionMgr::DumpTypeIndex(
|
||||
char * pszCurrBuffer,
|
||||
DWORD64 modBase,
|
||||
DWORD dwTypeIndex,
|
||||
unsigned nestingLevel,
|
||||
DWORD_PTR offset,
|
||||
bool & bHandled )
|
||||
{
|
||||
bHandled = false;
|
||||
|
||||
// Get the name of the symbol. This will either be a Type name (if a UDT),
|
||||
// or the structure member name.
|
||||
WCHAR * pwszTypeName;
|
||||
if ( SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_SYMNAME,
|
||||
&pwszTypeName ) )
|
||||
{
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, " %ls", pwszTypeName );
|
||||
LocalFree( pwszTypeName );
|
||||
}
|
||||
|
||||
// Determine how many children this type has.
|
||||
DWORD dwChildrenCount = 0;
|
||||
SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_CHILDRENCOUNT,
|
||||
&dwChildrenCount );
|
||||
|
||||
if ( !dwChildrenCount ) // If no children, we're done
|
||||
return pszCurrBuffer;
|
||||
|
||||
// Prepare to get an array of "TypeIds", representing each of the children.
|
||||
// SymGetTypeInfo(TI_FINDCHILDREN) expects more memory than just a
|
||||
// TI_FINDCHILDREN_PARAMS struct has. Use derivation to accomplish this.
|
||||
struct FINDCHILDREN : TI_FINDCHILDREN_PARAMS
|
||||
{
|
||||
ULONG MoreChildIds[1024];
|
||||
FINDCHILDREN(){Count = sizeof(MoreChildIds) / sizeof(MoreChildIds[0]);}
|
||||
} children;
|
||||
|
||||
children.Count = dwChildrenCount;
|
||||
children.Start= 0;
|
||||
|
||||
// Get the array of TypeIds, one for each child type
|
||||
if ( !SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_FINDCHILDREN,
|
||||
&children ) )
|
||||
{
|
||||
return pszCurrBuffer;
|
||||
}
|
||||
|
||||
// Append a line feed
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, "\r\n" );
|
||||
|
||||
// Iterate through each of the children
|
||||
for ( unsigned i = 0; i < dwChildrenCount; i++ )
|
||||
{
|
||||
// Add appropriate indentation level (since this routine is recursive)
|
||||
for ( unsigned j = 0; j <= nestingLevel+1; j++ )
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, "\t" );
|
||||
|
||||
// Recurse for each of the child types
|
||||
bool bHandled2;
|
||||
pszCurrBuffer = DumpTypeIndex( pszCurrBuffer, modBase,
|
||||
children.ChildId[i], nestingLevel+1,
|
||||
offset, bHandled2 );
|
||||
|
||||
// If the child wasn't a UDT, format it appropriately
|
||||
if ( !bHandled2 )
|
||||
{
|
||||
// Get the offset of the child member, relative to its parent
|
||||
DWORD dwMemberOffset;
|
||||
SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i],
|
||||
TI_GET_OFFSET, &dwMemberOffset );
|
||||
|
||||
// Get the real "TypeId" of the child. We need this for the
|
||||
// SymGetTypeInfo( TI_GET_TYPEID ) call below.
|
||||
DWORD typeId;
|
||||
SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i],
|
||||
TI_GET_TYPEID, &typeId );
|
||||
|
||||
// Get the size of the child member
|
||||
ULONG64 length;
|
||||
SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH,&length);
|
||||
|
||||
// Calculate the address of the member
|
||||
DWORD_PTR dwFinalOffset = offset + dwMemberOffset;
|
||||
|
||||
BasicType basicType = GetBasicType(children.ChildId[i], modBase );
|
||||
|
||||
pszCurrBuffer = FormatOutputValue( pszCurrBuffer, basicType,
|
||||
length, (PVOID)dwFinalOffset );
|
||||
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, "\r\n" );
|
||||
}
|
||||
}
|
||||
|
||||
bHandled = true;
|
||||
return pszCurrBuffer;
|
||||
}
|
||||
char * CExceptionMgr::FormatOutputValue( char * pszCurrBuffer,
|
||||
BasicType basicType,
|
||||
DWORD64 length,
|
||||
PVOID pAddress )
|
||||
{
|
||||
// Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!)
|
||||
if ( length == 1 )
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, " = %X", *(PBYTE)pAddress );
|
||||
else if ( length == 2 )
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, " = %X", *(PWORD)pAddress );
|
||||
else if ( length == 4 )
|
||||
{
|
||||
if ( basicType == btFloat )
|
||||
{
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer," = %f", *(PFLOAT)pAddress);
|
||||
}
|
||||
else if ( basicType == btChar )
|
||||
{
|
||||
if ( !IsBadStringPtr( *(PSTR*)pAddress, 32) )
|
||||
{
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, " = \"%.31s\"",
|
||||
*(PDWORD)pAddress );
|
||||
}
|
||||
else
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, " = %X",
|
||||
*(PDWORD)pAddress );
|
||||
}
|
||||
else
|
||||
pszCurrBuffer += sprintf(pszCurrBuffer," = %X", *(PDWORD)pAddress);
|
||||
}
|
||||
else if ( length == 8 )
|
||||
{
|
||||
if ( basicType == btFloat )
|
||||
{
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, " = %lf",
|
||||
*(double *)pAddress );
|
||||
}
|
||||
else
|
||||
pszCurrBuffer += sprintf( pszCurrBuffer, " = %I64X",
|
||||
*(DWORD64*)pAddress );
|
||||
}
|
||||
|
||||
return pszCurrBuffer;
|
||||
}
|
||||
|
||||
BasicType CExceptionMgr::GetBasicType( DWORD typeIndex, DWORD64 modBase )
|
||||
{
|
||||
BasicType basicType;
|
||||
if ( SymGetTypeInfo( m_hProcess, modBase, typeIndex,
|
||||
TI_GET_BASETYPE, &basicType ) )
|
||||
{
|
||||
return basicType;
|
||||
}
|
||||
|
||||
// Get the real "TypeId" of the child. We need this for the
|
||||
// SymGetTypeInfo( TI_GET_TYPEID ) call below.
|
||||
DWORD typeId;
|
||||
if (SymGetTypeInfo(m_hProcess,modBase, typeIndex, TI_GET_TYPEID, &typeId))
|
||||
{
|
||||
if ( SymGetTypeInfo( m_hProcess, modBase, typeId, TI_GET_BASETYPE,
|
||||
&basicType ) )
|
||||
{
|
||||
return basicType;
|
||||
}
|
||||
}
|
||||
|
||||
return btNoType;
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
92
GameTools/CaldronBase/ExceptionMgr.h
Normal file
92
GameTools/CaldronBase/ExceptionMgr.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "Caldron.h"
|
||||
#include <dbghelp.h>
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CExceptionMgr
|
||||
* 파일 : CException Mgr.h
|
||||
* 기능 : Caldron Engine내 Dbghelp와 LogMgr을 이용한 exception 출력 루틴.
|
||||
* 작성일 : 2004.02.11
|
||||
* 작성자 : wizardbug ( 2004.02.11)
|
||||
* 수정자 :
|
||||
* 개요 : Exception 핸들링 루틴은 microsoft 기술 칼럼 ' under the hood' 의 예제의 루틴 변형한 것임.
|
||||
********************************************************************** */
|
||||
|
||||
#pragma once
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
// Stolen from Dbg Help Example
|
||||
enum BasicType
|
||||
{
|
||||
btNoType = 0,
|
||||
btVoid = 1,
|
||||
btChar = 2,
|
||||
btWChar = 3,
|
||||
btInt = 6,
|
||||
btUInt = 7,
|
||||
btFloat = 8,
|
||||
btBCD = 9,
|
||||
btBool = 10,
|
||||
btLong = 13,
|
||||
btULong = 14,
|
||||
btCurrency = 25,
|
||||
btDate = 26,
|
||||
btVariant = 27,
|
||||
btComplex = 28,
|
||||
btBit = 29,
|
||||
btBSTR = 30,
|
||||
btHresult = 31
|
||||
};
|
||||
|
||||
class CExceptionMgr
|
||||
{
|
||||
public:
|
||||
CExceptionMgr(void);
|
||||
~CExceptionMgr(void);
|
||||
|
||||
// entry point where control comes on an unhandled exception
|
||||
static LONG WINAPI ExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo );
|
||||
static void WriteExceptionReport(PEXCEPTION_POINTERS pExceptionInfo );
|
||||
static LPSTR GetExceptionString(DWORD dwCode);
|
||||
static BOOL GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len,DWORD& section, DWORD& offset);
|
||||
static void WriteCallStack(PCONTEXT pContext,bool bWriteVariables );
|
||||
static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID);
|
||||
|
||||
static bool FormatSymbolValue( PSYMBOL_INFO, STACKFRAME *, char * pszBuffer, unsigned cbBuffer );
|
||||
static char * DumpTypeIndex( char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool & );
|
||||
static char * FormatOutputValue( char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress );
|
||||
static BasicType GetBasicType( DWORD typeIndex, DWORD64 modBase );
|
||||
|
||||
protected:
|
||||
static LPTOP_LEVEL_EXCEPTION_FILTER m_lpPrevFilter;
|
||||
static HANDLE m_hProcess;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// where report info is extracted and generated
|
||||
static void GenerateExceptionReport( PEXCEPTION_POINTERS pExceptionInfo );
|
||||
|
||||
// Helper functions
|
||||
|
||||
static void WriteStackDetails( PCONTEXT pContext, bool bWriteVariables );
|
||||
|
||||
|
||||
|
||||
|
||||
static int __cdecl _tprintf(const TCHAR * format, ...);
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern WheatyExceptionReport g_WheatyExceptionReport; // global instance of class
|
||||
|
||||
*/
|
||||
}}
|
||||
23
GameTools/CaldronBase/LoadedObj.cpp
Normal file
23
GameTools/CaldronBase/LoadedObj.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// LoadedObj.cpp: implementation of the CLoadedObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma warning( disable : 4786 )
|
||||
#include "./ByteDataObj.h"
|
||||
#include "LoadedObj.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
namespace Caldron { namespace Base {
|
||||
CLoadedObj::CLoadedObj()
|
||||
{
|
||||
m_bLoaded = false;
|
||||
m_iReloadingCount = 0;
|
||||
|
||||
}
|
||||
|
||||
CLoadedObj::~CLoadedObj()
|
||||
{
|
||||
|
||||
}
|
||||
}}
|
||||
48
GameTools/CaldronBase/LoadedObj.h
Normal file
48
GameTools/CaldronBase/LoadedObj.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// LoadedObj.h: interface for the CLoadedObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_LOADEDOBJ_H__7BBE3A5F_6665_4F40_AA4D_82BACEBC32D3__INCLUDED_)
|
||||
#define AFX_LOADEDOBJ_H__7BBE3A5F_6665_4F40_AA4D_82BACEBC32D3__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CLoadedObj
|
||||
|
||||
* 파일 : LoadedObj.h
|
||||
* 기능 : Caldron Engine내 CResourceMgr 을 이용해 로드 가능한 리소스 obj 들의 어미 class
|
||||
* 작성일 : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
class CByteDataObj;
|
||||
|
||||
class CLoadedObj
|
||||
{
|
||||
public:
|
||||
CLoadedObj();
|
||||
virtual ~CLoadedObj();
|
||||
|
||||
virtual bool Load(CByteDataObj *) = 0;
|
||||
virtual bool Unload() = 0;
|
||||
bool m_bLoaded;
|
||||
char m_strName[40];
|
||||
int m_iReloadingCount; // ReLoading 횟수.
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif // !defined(AFX_LOADEDOBJ_H__7BBE3A5F_6665_4F40_AA4D_82BACEBC32D3__INCLUDED_)
|
||||
319
GameTools/CaldronBase/LogMgr.cpp
Normal file
319
GameTools/CaldronBase/LogMgr.cpp
Normal file
@@ -0,0 +1,319 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* CLogMgr
|
||||
* 파일 : LogMgr.cpp
|
||||
* 기능 : Caldron Engine내 메세지나 에러 등을 처리하는 Log System
|
||||
* 작성일 : 2003.10.23
|
||||
* 작성자 : wizardbug ( 2003.10.23)
|
||||
* 수정자 :
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#include "./LogMgr.h"
|
||||
#include "./Console.h"
|
||||
#include "../Scene/MainSceneMgr.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// static 함수, 변수
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Caldron::Base::CLogMgr *Caldron::Base::CLogMgr::ms_pInstance = NULL;
|
||||
|
||||
/*
|
||||
Caldron::Base::CLogMgr *Caldron::Base::CLogMgr::_GetInstance();
|
||||
void Caldron::Base::CLogMgr::_LogMessage(const char *,...);
|
||||
void Caldron::Base::CLogMgr::_LogError(const char *,...);
|
||||
void Caldron::Base::CLogMgr::_SetOutDevice(Caldron::LOG_OUTDEVICES iDevice);
|
||||
void Caldron::Base::CLogMgr::_SetOutMessageFlag(Caldron::LOG_MESSAGES iMessage,bool bFlag);
|
||||
void Caldron::Base::CLogMgr::_Close();
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Caldron::Base::CLogMgr::CLogMgr() : m_pLogFile(0), m_iOutDevice(Caldron::LOG_FILEOUT),m_bBufferEmpty(true)
|
||||
{
|
||||
|
||||
|
||||
m_pBitFlag = new CBitset;
|
||||
|
||||
if(m_pBitFlag != NULL)
|
||||
{
|
||||
|
||||
m_pBitFlag->ResizeBits(Caldron::LOG_MESSAGES_NUM);
|
||||
m_pBitFlag->ClearBits();
|
||||
|
||||
for(int i = 0; i < Caldron::LOG_MESSAGES_NUM; i++ )
|
||||
{
|
||||
m_pBitFlag->SetBit(i);
|
||||
}
|
||||
}
|
||||
|
||||
memset((char *)m_pLogBuffer,sizeof(char),2560);
|
||||
memset((char *)m_pLogFileName,sizeof(char),256);
|
||||
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::ValueRelease()
|
||||
{
|
||||
|
||||
if(m_pLogFile != NULL)
|
||||
{
|
||||
fclose(m_pLogFile);
|
||||
m_pLogFile = NULL;
|
||||
}
|
||||
Caldron::SafeDelete(m_pBitFlag);
|
||||
m_pBitFlag = NULL;
|
||||
|
||||
}
|
||||
Caldron::Base::CLogMgr::~CLogMgr()
|
||||
{
|
||||
}
|
||||
|
||||
void Caldron::Base::CLogMgr::_Close()
|
||||
{
|
||||
if(ms_pInstance != NULL)
|
||||
{
|
||||
ms_pInstance->ValueRelease();
|
||||
Caldron::SafeDelete(ms_pInstance);
|
||||
ms_pInstance = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Caldron::Base::CLogMgr *Caldron::Base::CLogMgr::_GetInstance()
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
ms_pInstance = new Caldron::Base::CLogMgr;
|
||||
ms_pInstance->WriteFirstRunLog();
|
||||
|
||||
}
|
||||
|
||||
return ms_pInstance;
|
||||
|
||||
}
|
||||
|
||||
void Caldron::Base::CLogMgr::_SetOutDevice(Caldron::LOG_OUTDEVICES iDevice)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr 생성
|
||||
}
|
||||
|
||||
switch(iDevice)
|
||||
{
|
||||
|
||||
case LOG_FILEOUT:
|
||||
case LOG_CONSOLEOUT: // Console
|
||||
case LOG_MESSAGEBOXOUT: // Window Message Box
|
||||
ms_pInstance->m_iOutDevice = iDevice;
|
||||
break;
|
||||
default:
|
||||
_LogError("CLogMgr::SetOutDevice() | 지원하지 않는 Device를 선택하셨습니다.");
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::_SetOutMessageFlag(Caldron::LOG_MESSAGES iMessage,bool bFlag)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr 생성
|
||||
}
|
||||
if(ms_pInstance->m_pBitFlag != NULL) {
|
||||
if(bFlag == true)
|
||||
{
|
||||
ms_pInstance->m_pBitFlag->SetBit(iMessage);
|
||||
ms_pInstance->_LogMessage("======= %s Bit On =======",LOG_LABEL[iMessage]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ms_pInstance->_LogMessage("======= %s Bit Off =======",LOG_LABEL[iMessage]);
|
||||
ms_pInstance->m_pBitFlag->ClearOneBit(iMessage);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CLogMgr::_LogMessage(const char *pFormat,...)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr 생성
|
||||
}
|
||||
if((ms_pInstance->m_pBitFlag != NULL) && (!ms_pInstance->m_pBitFlag->GetBit(Caldron::LOG_MESSAGE)))
|
||||
return;
|
||||
|
||||
/*
|
||||
// Checking 루틴시작
|
||||
char *pCheckptr = (char *)pFormat;
|
||||
int iFCount = 0; // % Count
|
||||
|
||||
while((*pCheckptr) != '\0')
|
||||
{
|
||||
if((*pCheckptr) == '%')
|
||||
iFCount++;
|
||||
pCheckptr++;
|
||||
|
||||
}
|
||||
|
||||
int iExist = 0;
|
||||
int iVaCount = 0;
|
||||
va_list ap;
|
||||
|
||||
va_start( ap, pFormat );
|
||||
while( iExist != -1 )
|
||||
{
|
||||
iVaCount++;
|
||||
iExist = va_arg( ap, char);
|
||||
}
|
||||
va_end( ap );
|
||||
if( iFCount != iVaCount )
|
||||
return;
|
||||
// Checking 루틴종료
|
||||
*/
|
||||
va_list ap;
|
||||
va_start(ap, pFormat);
|
||||
vsprintf(ms_pInstance->m_pLogBuffer, pFormat, ap);
|
||||
va_end(ap);
|
||||
ms_pInstance->m_bBufferEmpty = false;
|
||||
|
||||
switch(ms_pInstance->m_iOutDevice)
|
||||
{
|
||||
case LOG_FILEOUT:
|
||||
ms_pInstance->WriteBufferToFile(LOG_MESSAGE);
|
||||
break;
|
||||
case LOG_CONSOLEOUT: // Console
|
||||
ms_pInstance->WriteBufferToConsole(LOG_MESSAGE);
|
||||
break;
|
||||
case LOG_MESSAGEBOXOUT: // Window Message Box
|
||||
ms_pInstance->WriteBufferToMessageBox(LOG_MESSAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CLogMgr::_LogError(const char *pFormat,...)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr 생성
|
||||
}
|
||||
|
||||
if((ms_pInstance->m_pBitFlag != NULL) && (!ms_pInstance->m_pBitFlag->GetBit(Caldron::LOG_ERROR)))
|
||||
return;
|
||||
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, pFormat);
|
||||
vsprintf(ms_pInstance->m_pLogBuffer, pFormat, ap);
|
||||
va_end(ap);
|
||||
ms_pInstance->m_bBufferEmpty = false;
|
||||
|
||||
switch(ms_pInstance->m_iOutDevice)
|
||||
{
|
||||
case LOG_FILEOUT:
|
||||
ms_pInstance->WriteBufferToFile(LOG_ERROR);
|
||||
break;
|
||||
case LOG_CONSOLEOUT: // Console
|
||||
ms_pInstance->WriteBufferToConsole(LOG_ERROR);
|
||||
break;
|
||||
case LOG_MESSAGEBOXOUT: // Window Message Box
|
||||
ms_pInstance->WriteBufferToMessageBox(LOG_ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CLogMgr::_LogNoHeader(const char *pFormat,...)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr 생성
|
||||
}
|
||||
|
||||
if((ms_pInstance->m_pBitFlag != NULL) && (!ms_pInstance->m_pBitFlag->GetBit(Caldron::LOG_NOHEADER)))
|
||||
return;
|
||||
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, pFormat);
|
||||
vsprintf(ms_pInstance->m_pLogBuffer, pFormat, ap);
|
||||
va_end(ap);
|
||||
ms_pInstance->m_bBufferEmpty = false;
|
||||
|
||||
switch(ms_pInstance->m_iOutDevice)
|
||||
{
|
||||
case LOG_FILEOUT:
|
||||
ms_pInstance->WriteBufferToFile(LOG_NOHEADER);
|
||||
break;
|
||||
case LOG_CONSOLEOUT: // Console
|
||||
ms_pInstance->WriteBufferToConsole(LOG_NOHEADER);
|
||||
break;
|
||||
case LOG_MESSAGEBOXOUT: // Window Message Box
|
||||
ms_pInstance->WriteBufferToMessageBox(LOG_NOHEADER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CLogMgr::WriteFirstRunLog()
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
char *pDate = asctime(localtime(&t));
|
||||
|
||||
if(m_pLogFile == NULL)
|
||||
{
|
||||
m_pLogFile = fopen(Caldron::Base::LOG_FILENAME,"at+");
|
||||
}
|
||||
if(m_pLogFile != NULL)
|
||||
{
|
||||
fprintf(m_pLogFile,"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
|
||||
fprintf(m_pLogFile,"!!!!!!! Below Logs, Application Last Run !!!!!!! %s",pDate);
|
||||
fprintf(m_pLogFile,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n");
|
||||
fclose(m_pLogFile);
|
||||
}
|
||||
|
||||
m_pLogFile = NULL;
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::WriteBufferToFile(Caldron::LOG_MESSAGES iMessage)
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
char *pDate = asctime(localtime(&t));
|
||||
|
||||
if(m_pLogFile == NULL)
|
||||
{
|
||||
m_pLogFile = fopen(Caldron::Base::LOG_FILENAME,"at+");
|
||||
}
|
||||
if(m_pLogFile != NULL)
|
||||
{
|
||||
if(iMessage == LOG_NOHEADER)
|
||||
{
|
||||
fprintf(m_pLogFile,"%s",m_pLogBuffer);
|
||||
}
|
||||
else
|
||||
fprintf(m_pLogFile,"%s %s | %s",LOG_LABEL[iMessage],m_pLogBuffer,pDate);
|
||||
fclose(m_pLogFile);
|
||||
}
|
||||
|
||||
m_pLogFile = NULL;
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::WriteBufferToConsole(Caldron::LOG_MESSAGES iMessage)
|
||||
{
|
||||
if(iMessage == LOG_NOHEADER)
|
||||
{
|
||||
Caldron::Scene::CMainSceneMgr::_GetConsole()->AddText("%s",m_pLogBuffer);
|
||||
}
|
||||
else
|
||||
Caldron::Scene::CMainSceneMgr::_GetConsole()->AddText("%s %s",LOG_LABEL[iMessage],m_pLogBuffer);
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::WriteBufferToMessageBox(Caldron::LOG_MESSAGES iMessage)
|
||||
{
|
||||
|
||||
MessageBox(NULL,m_pLogBuffer,LOG_LABEL[iMessage],MB_OK);
|
||||
|
||||
}
|
||||
96
GameTools/CaldronBase/LogMgr.h
Normal file
96
GameTools/CaldronBase/LogMgr.h
Normal file
@@ -0,0 +1,96 @@
|
||||
// WBLogSystem.h: interface for the WBLogSystem class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_WBLOGSYSTEM_H__3836C71D_3ABD_4A3D_99E8_385123E4F17C__INCLUDED_)
|
||||
#define AFX_WBLOGSYSTEM_H__3836C71D_3ABD_4A3D_99E8_385123E4F17C__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CLogMgr
|
||||
* 파일 : LogMgr.h
|
||||
* 기능 : Caldron Engine내 메세지나 에러 등을 처리하는 Log System
|
||||
* 작성일 : 2003.10.23
|
||||
* 작성자 : wizardbug ( 2003.10.23)
|
||||
* 수정자 :
|
||||
|
||||
********************************************************************** */
|
||||
#include <time.h>
|
||||
#include "./caldron.h"
|
||||
|
||||
|
||||
//#define __LOG_WRITE__ // __LOG_WRITE__ 를 define 시켜주어야 Log 가 출력된다.
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
// 외부로 공개되는 Enum.
|
||||
enum LOG_MESSAGES
|
||||
{
|
||||
LOG_MESSAGE, // 일반 Log Message
|
||||
LOG_ERROR, // Error Log Message
|
||||
LOG_NOHEADER, // Header 없는 메세지.
|
||||
LOG_MESSAGES_NUM,
|
||||
};
|
||||
|
||||
enum LOG_OUTDEVICES
|
||||
{
|
||||
LOG_FILEOUT, // Log File
|
||||
LOG_CONSOLEOUT, // Console
|
||||
LOG_MESSAGEBOXOUT, // Window Message Box
|
||||
LOG_OUTDEVICES_NUM,
|
||||
};
|
||||
|
||||
namespace Base
|
||||
{
|
||||
|
||||
const char * const LOG_LABEL[3] = {
|
||||
" LOG[ MESSAGE ] | ",
|
||||
" LOG[ ERROR ] | ",
|
||||
""
|
||||
|
||||
};
|
||||
const char LOG_FILENAME[] = "Caldron.log";
|
||||
|
||||
class CLogMgr
|
||||
{
|
||||
private:
|
||||
static CLogMgr *ms_pInstance;
|
||||
FILE *m_pLogFile;
|
||||
Caldron::LOG_OUTDEVICES m_iOutDevice;
|
||||
|
||||
char m_pLogBuffer[2560]; // Log Buffer
|
||||
char m_pLogFileName[256];
|
||||
|
||||
bool m_bBufferEmpty;
|
||||
CBitset *m_pBitFlag;
|
||||
|
||||
|
||||
protected:
|
||||
CLogMgr();
|
||||
|
||||
void WriteBufferToFile(Caldron::LOG_MESSAGES);
|
||||
void WriteBufferToConsole(Caldron::LOG_MESSAGES);
|
||||
void WriteBufferToMessageBox(Caldron::LOG_MESSAGES);
|
||||
void WriteFirstRunLog();
|
||||
public:
|
||||
~CLogMgr();
|
||||
void ValueRelease();
|
||||
|
||||
static void _SetOutDevice(Caldron::LOG_OUTDEVICES iDevice);
|
||||
static CLogMgr * _GetInstance();
|
||||
static void _LogMessage(const char *,...);
|
||||
static void _LogError(const char *,...);
|
||||
static void _LogNoHeader(const char *,...);
|
||||
|
||||
static void _SetOutMessageFlag(Caldron::LOG_MESSAGES iMessage,bool bFlag);
|
||||
static void _Close();
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
#endif // !defined(AFX_WBLOGSYSTEM_H__3836C71D_3ABD_4A3D_99E8_385123E4F17C__INCLUDED_)
|
||||
11
GameTools/CaldronBase/MemoryPool.cpp
Normal file
11
GameTools/CaldronBase/MemoryPool.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include ".\memorypool.h"
|
||||
namespace Caldron { namespace Base {
|
||||
CMemoryPool::CMemoryPool(void)
|
||||
{
|
||||
}
|
||||
|
||||
CMemoryPool::~CMemoryPool(void)
|
||||
{
|
||||
}
|
||||
|
||||
}}
|
||||
14
GameTools/CaldronBase/MemoryPool.h
Normal file
14
GameTools/CaldronBase/MemoryPool.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Caldron.h"
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
class CMemoryPool
|
||||
{
|
||||
public:
|
||||
CMemoryPool(void);
|
||||
~CMemoryPool(void);
|
||||
};
|
||||
|
||||
}}
|
||||
252
GameTools/CaldronBase/ProfileMgr.cpp
Normal file
252
GameTools/CaldronBase/ProfileMgr.cpp
Normal file
@@ -0,0 +1,252 @@
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CProfileMgr
|
||||
|
||||
* 파일 : ProfileMgr.cpp
|
||||
* 기능 :
|
||||
* 작성일 : 2003.11.05
|
||||
* history :
|
||||
wizardbug ( 2003.11.05) :: Gem3의 Profile System을 Caldron에 맞게 변형
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
#include "./ProfileMgr.h"
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileObj
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
/***********************************************************************************************
|
||||
* INPUT: *
|
||||
* name - pointer to a static string which is the name of this profile node *
|
||||
* parent - parent pointer *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* The name is assumed to be a static pointer, only the pointer is stored and compared for *
|
||||
* efficiency reasons. *
|
||||
*=============================================================================================*/
|
||||
Caldron::Base::CProfileObj::CProfileObj( const char * strName, CProfileObj * pParent ) :
|
||||
m_strName( strName ),
|
||||
m_iTotalCalls( 0 ),
|
||||
m_fTotalTime( 0 ),
|
||||
m_iStartTime( 0 ),
|
||||
m_iRecursionCounter( 0 ),
|
||||
m_pParent( pParent ),
|
||||
m_pChild( NULL ),
|
||||
m_pSibling( NULL )
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
Caldron::Base::CProfileObj::~CProfileObj( void )
|
||||
{
|
||||
delete m_pChild;
|
||||
delete m_pSibling;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* INPUT: *
|
||||
* name - static string pointer to the name of the node we are searching for *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* All profile names are assumed to be static strings so this function uses pointer compares *
|
||||
* to find the named node. *
|
||||
*=============================================================================================*/
|
||||
Caldron::Base::CProfileObj *Caldron::Base::CProfileObj::Get_Sub_Node( const char * strName )
|
||||
{
|
||||
// Try to find this sub node
|
||||
CProfileObj * child = m_pChild;
|
||||
while ( child ) {
|
||||
if ( child->m_strName == strName ) {
|
||||
return child;
|
||||
}
|
||||
child = child->m_pSibling;
|
||||
}
|
||||
|
||||
// We didn't find it, so add it
|
||||
CProfileObj * node = new CProfileObj( strName, this );
|
||||
node->m_pSibling = m_pChild;
|
||||
m_pChild = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void Caldron::Base::CProfileObj::Reset()
|
||||
{
|
||||
m_iTotalCalls = 0;
|
||||
m_fTotalTime = 0.0f;
|
||||
|
||||
if ( m_pChild ) {
|
||||
m_pChild->Reset();
|
||||
}
|
||||
if ( m_pSibling ) {
|
||||
m_pSibling->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Caldron::Base::CProfileObj::Call()
|
||||
{
|
||||
m_iTotalCalls++;
|
||||
if (m_iRecursionCounter++ == 0) {
|
||||
Caldron::ProfileGetTicks(&m_iStartTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Caldron::Base::CProfileObj::Return()
|
||||
{
|
||||
if ( --m_iRecursionCounter == 0 && m_iTotalCalls != 0 ) {
|
||||
__int64 time;
|
||||
Caldron::ProfileGetTicks(&time);
|
||||
time -= m_iStartTime;
|
||||
m_fTotalTime += (float)time / Caldron::ProfileGetTickRate();
|
||||
}
|
||||
return ( m_iRecursionCounter == 0 );
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileChecker
|
||||
**
|
||||
***************************************************************************************************/
|
||||
Caldron::Base::CProfileChecker::CProfileChecker( CProfileObj * pStart )
|
||||
{
|
||||
m_pCurrentParent = pStart;
|
||||
m_pCurrentChild = m_pCurrentParent->Get_Child();
|
||||
}
|
||||
|
||||
|
||||
void Caldron::Base::CProfileChecker::First(void)
|
||||
{
|
||||
m_pCurrentChild = m_pCurrentParent->Get_Child();
|
||||
}
|
||||
|
||||
|
||||
void Caldron::Base::CProfileChecker::Next(void)
|
||||
{
|
||||
m_pCurrentChild = m_pCurrentChild->Get_Sibling();
|
||||
}
|
||||
|
||||
|
||||
bool Caldron::Base::CProfileChecker::Is_Done(void)
|
||||
{
|
||||
return m_pCurrentChild == NULL;
|
||||
}
|
||||
|
||||
|
||||
void Caldron::Base::CProfileChecker::Enter_Child( int iIndex )
|
||||
{
|
||||
m_pCurrentChild = m_pCurrentParent->Get_Child();
|
||||
while ( (m_pCurrentChild != NULL) && (iIndex != 0) ) {
|
||||
iIndex--;
|
||||
m_pCurrentChild = m_pCurrentChild->Get_Sibling();
|
||||
}
|
||||
|
||||
if ( m_pCurrentChild != NULL ) {
|
||||
m_pCurrentParent = m_pCurrentChild;
|
||||
m_pCurrentChild = m_pCurrentParent->Get_Child();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Caldron::Base::CProfileChecker::Enter_Parent( void )
|
||||
{
|
||||
if ( m_pCurrentParent->Get_Parent() != NULL ) {
|
||||
m_pCurrentParent = m_pCurrentParent->Get_Parent();
|
||||
}
|
||||
m_pCurrentChild = m_pCurrentParent->Get_Child();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileMgr
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
Caldron::Base::CProfileObj Caldron::Base::CProfileMgr::m_Root( "Root", NULL );
|
||||
Caldron::Base::CProfileObj *Caldron::Base::CProfileMgr::m_pCurrentNode = &CProfileMgr::m_Root;
|
||||
int Caldron::Base::CProfileMgr::m_iFrameCounter = 0;
|
||||
__int64 Caldron::Base::CProfileMgr::m_iResetTime = 0;
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Start_Profile -- Begin a named profile *
|
||||
* *
|
||||
* Steps one level deeper into the tree, if a child already exists with the specified name *
|
||||
* then it accumulates the profiling; otherwise a new child node is added to the profile tree. *
|
||||
* *
|
||||
* INPUT: *
|
||||
* name - name of this profiling record *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* The string used is assumed to be a static string; pointer compares are used throughout *
|
||||
* the profiling code for efficiency. *
|
||||
*=============================================================================================*/
|
||||
void Caldron::Base::CProfileMgr::StartProfile( const char * strName )
|
||||
{
|
||||
if (strName != m_pCurrentNode->Get_Name()) {
|
||||
m_pCurrentNode = m_pCurrentNode->Get_Sub_Node( strName );
|
||||
}
|
||||
|
||||
m_pCurrentNode->Call();
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Stop_Profile -- Stop timing and record the results. *
|
||||
*=============================================================================================*/
|
||||
void Caldron::Base::CProfileMgr::StopProfile( void )
|
||||
{
|
||||
// Return will indicate whether we should back up to our parent (we may
|
||||
// be profiling a recursive function)
|
||||
if (m_pCurrentNode->Return()) {
|
||||
m_pCurrentNode = m_pCurrentNode->Get_Parent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Reset -- Reset the contents of the profiling system *
|
||||
* *
|
||||
* This resets everything except for the tree structure. All of the timing data is reset. *
|
||||
*=============================================================================================*/
|
||||
void Caldron::Base::CProfileMgr::Reset( void )
|
||||
{
|
||||
m_Root.Reset();
|
||||
m_iFrameCounter = 0;
|
||||
Caldron::ProfileGetTicks(&m_iResetTime);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Increment_Frame_Counter -- Increment the frame counter *
|
||||
*=============================================================================================*/
|
||||
void Caldron::Base::CProfileMgr::Increment_Frame_Counter( void )
|
||||
{
|
||||
m_iFrameCounter++;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset *
|
||||
*=============================================================================================*/
|
||||
float Caldron::Base::CProfileMgr::Get_Time_Since_Reset( void )
|
||||
{
|
||||
__int64 time;
|
||||
Caldron::ProfileGetTicks(&time);
|
||||
time -= m_iResetTime;
|
||||
return (float)time / Caldron::ProfileGetTickRate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
141
GameTools/CaldronBase/ProfileMgr.h
Normal file
141
GameTools/CaldronBase/ProfileMgr.h
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CProfileMgr
|
||||
|
||||
* 파일 : ProfileMgr.h
|
||||
* 기능 :
|
||||
* 작성일 : 2003.11.05
|
||||
* history :
|
||||
wizardbug ( 2003.11.05) :: Gem3의 Profile System을 Caldron에 맞게 변형
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
/*
|
||||
** A node in the Profile Hierarchy Tree
|
||||
*/
|
||||
|
||||
#include "Caldron.h"
|
||||
#include "./LogMgr.h"
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
class CProfileObj {
|
||||
|
||||
public:
|
||||
CProfileObj( const char * strName, CProfileObj * pParent );
|
||||
~CProfileObj( void );
|
||||
|
||||
CProfileObj *Get_Sub_Node( const char * strName );
|
||||
|
||||
CProfileObj *Get_Parent( void ) { return m_pParent; }
|
||||
CProfileObj *Get_Sibling( void ) { return m_pSibling; }
|
||||
CProfileObj *Get_Child( void ) { return m_pChild; }
|
||||
|
||||
void Reset( void );
|
||||
void Call( void );
|
||||
bool Return( void );
|
||||
|
||||
const char *Get_Name( void ) { return m_strName; }
|
||||
int Get_Total_Calls( void ) { return m_iTotalCalls; }
|
||||
float Get_Total_Time( void ) { return m_fTotalTime; }
|
||||
|
||||
protected:
|
||||
|
||||
const char * m_strName;
|
||||
int m_iTotalCalls;
|
||||
float m_fTotalTime;
|
||||
__int64 m_iStartTime;
|
||||
int m_iRecursionCounter;
|
||||
|
||||
CProfileObj * m_pParent;
|
||||
CProfileObj * m_pChild;
|
||||
CProfileObj * m_pSibling;
|
||||
};
|
||||
|
||||
/*
|
||||
** An iterator to navigate through the tree
|
||||
*/
|
||||
class CProfileChecker
|
||||
{
|
||||
public:
|
||||
// Access all the children of the current parent
|
||||
void First(void);
|
||||
void Next(void);
|
||||
bool Is_Done(void);
|
||||
|
||||
void Enter_Child( int iIndex ); // Make the given child the new parent
|
||||
void Enter_Largest_Child( void ); // Make the largest child the new parent
|
||||
void Enter_Parent( void ); // Make the current parent's parent the new parent
|
||||
|
||||
// Access the current child
|
||||
const char * Get_Current_Name( void ) { return m_pCurrentChild->Get_Name(); }
|
||||
int Get_Current_Total_Calls( void ) { return m_pCurrentChild->Get_Total_Calls(); }
|
||||
float Get_Current_Total_Time( void ) { return m_pCurrentChild->Get_Total_Time(); }
|
||||
|
||||
// Access the current parent
|
||||
const char * Get_Current_Parent_Name( void ) { return m_pCurrentParent->Get_Name(); }
|
||||
int Get_Current_Parent_Total_Calls( void ) { return m_pCurrentParent->Get_Total_Calls(); }
|
||||
float Get_Current_Parent_Total_Time( void ) { return m_pCurrentParent->Get_Total_Time(); }
|
||||
CProfileObj * GetParentPtr() {return m_pCurrentParent;}
|
||||
CProfileObj * GetChildPtr() { return m_pCurrentChild;}
|
||||
protected:
|
||||
|
||||
CProfileObj * m_pCurrentParent;
|
||||
CProfileObj * m_pCurrentChild;
|
||||
|
||||
CProfileChecker( CProfileObj * start );
|
||||
friend class CProfileMgr;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** The Manager for the Profile system
|
||||
*/
|
||||
class CProfileMgr {
|
||||
public:
|
||||
static void StartProfile( const char * strName );
|
||||
static void StopProfile( void );
|
||||
|
||||
static void Reset( void );
|
||||
static void Increment_Frame_Counter( void );
|
||||
static int Get_Frame_Count_Since_Reset( void ) { return m_iFrameCounter; }
|
||||
static float Get_Time_Since_Reset( void );
|
||||
|
||||
static CProfileChecker *GetChecker( void ) { return new CProfileChecker( &m_Root ); }
|
||||
static void ReleaseChecker( CProfileChecker * iterator ) { SafeDelete(iterator); }
|
||||
|
||||
private:
|
||||
static CProfileObj m_Root;
|
||||
static CProfileObj *m_pCurrentNode;
|
||||
static int m_iFrameCounter;
|
||||
static __int64 m_iResetTime;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** ProfileSampleClass is a simple way to profile a function's scope
|
||||
** Use the PROFILE macro at the start of scope to time
|
||||
*/
|
||||
class CProfileSample {
|
||||
public:
|
||||
CProfileSample( const char * name )
|
||||
{
|
||||
CProfileMgr::StartProfile( name );
|
||||
}
|
||||
|
||||
~CProfileSample( void )
|
||||
{
|
||||
CProfileMgr::StopProfile();
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define PROFILE( name ) Caldron::Base::CProfileSample __profile( name )
|
||||
#else
|
||||
#define PROFILE( name )
|
||||
#endif
|
||||
|
||||
|
||||
21
GameTools/CaldronBase/ReadMe.txt
Normal file
21
GameTools/CaldronBase/ReadMe.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
========================================================================
|
||||
정적 라이브러리 : Base 프로젝트 개요
|
||||
========================================================================
|
||||
|
||||
응용 프로그램 마법사에서 이 Base 라이브러리 프로젝트를 만들었습니다.
|
||||
프로젝트에 대해 소스 파일은 만들어지지 않았습니다.
|
||||
|
||||
|
||||
Base.vcproj
|
||||
응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다.
|
||||
해당 파일을 생성한 Visual C++의 버전 정보를 비롯하여
|
||||
응용 프로그램 마법사에서 선택한 플랫폼, 구성 및
|
||||
프로젝트 기능에 대한 정보가 들어 있습니다.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
기타 참고:
|
||||
|
||||
응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는
|
||||
소스 코드 부분을 나타냅니다.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
252
GameTools/CaldronBase/ResourceLoader.cpp
Normal file
252
GameTools/CaldronBase/ResourceLoader.cpp
Normal file
@@ -0,0 +1,252 @@
|
||||
#pragma warning( disable : 4786 )
|
||||
|
||||
#include "Caldron.h"
|
||||
#include "./LoadedObj.h"
|
||||
|
||||
#include "ResourceLoader.h"
|
||||
|
||||
namespace Caldron {namespace Base {
|
||||
/* *********************************************************************
|
||||
|
||||
* CResourceLoaderObj
|
||||
|
||||
* 파일 : ResourceLoader.cpp
|
||||
* 기능 : Caldron Engine내 CResourceLoader 에서 Load Queue에 들어갈 resource 단위
|
||||
* 작성일 : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
CResourceLoaderObj::CResourceLoaderObj()
|
||||
{
|
||||
m_pObj = NULL;
|
||||
m_State = RLOBJSTATE_READY;
|
||||
}
|
||||
CResourceLoaderObj::CResourceLoaderObj(const char *strFileName,CLoadedObj *pObj)
|
||||
{
|
||||
strcpy(m_strFileName,strFileName);
|
||||
m_pObj = pObj;
|
||||
m_pObj->m_bLoaded = false;
|
||||
m_State = RLOBJSTATE_READY;
|
||||
}
|
||||
CResourceLoaderObj::~CResourceLoaderObj()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CResourceLoader
|
||||
|
||||
* 파일 : ResourceLoader.cpp
|
||||
* 기능 : Caldron Engine내 ResourceLoader,
|
||||
thread를 분리하여 메린 루틴 과 로딩루틴을 분리 하였다.
|
||||
* 작성일 : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
DWORD WINAPI LoaderThreadProc(LPVOID lpParam)
|
||||
{
|
||||
CResourceLoader *pLoader = (CResourceLoader *)(lpParam);
|
||||
pLoader->LoaderFunc();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
DWORD WINAPI ProcessThreadProc(LPVOID lpParam)
|
||||
{
|
||||
CResourceLoader *pLoader = (CResourceLoader *)(lpParam);
|
||||
pLoader->ProcessFunc();
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
CResourceLoader::CResourceLoader() : m_Queue(g_iMaxLoaderQueue)
|
||||
{
|
||||
m_bLoading = false;
|
||||
|
||||
m_dwWait = 0;
|
||||
m_lstObj.clear();
|
||||
m_lstReady.clear();
|
||||
InitializeCriticalSection(&m_ObjCriticalSection);
|
||||
m_LoaderThreadID = m_ProcessThreadID = 0;
|
||||
m_EndEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
m_LoaderHandle = 0;
|
||||
m_ProcessHandle = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
CResourceLoader::~CResourceLoader()
|
||||
{
|
||||
DeleteCriticalSection(&m_ObjCriticalSection);
|
||||
CloseHandle(m_EndEvent);
|
||||
CloseHandle(m_LoaderHandle);
|
||||
CloseHandle(m_ProcessHandle);
|
||||
|
||||
}
|
||||
void CResourceLoader::Loading()
|
||||
{
|
||||
m_bLoading = true;
|
||||
// Event 초기화
|
||||
ResetEvent(m_EndEvent);
|
||||
if((m_LoaderHandle = CreateThread(NULL,0,LoaderThreadProc,(LPVOID)this,0,&m_LoaderThreadID)) == NULL) {
|
||||
CLogMgr::_LogError("CResourceLoader::Loading() : Create Loader Thread Failed");
|
||||
|
||||
}
|
||||
if((m_ProcessHandle = CreateThread(NULL,0,ProcessThreadProc,(LPVOID)this,0,&m_ProcessThreadID)) == NULL) {
|
||||
CLogMgr::_LogError("CResourceLoader::Loading() : Create Process Thread Failed");
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CResourceLoader::WaitFinished()
|
||||
{
|
||||
return WaitForMultipleObjects(1, &m_EndEvent, FALSE, m_dwWait);
|
||||
}
|
||||
int CResourceLoader::FinishPercent() {
|
||||
return 0;
|
||||
}
|
||||
void CResourceLoader::LoaderFunc()
|
||||
{
|
||||
for(int iIndex = 0; iIndex < GetObjNum(); iIndex++)
|
||||
{
|
||||
CResourceLoaderObj *pObj = &m_lstObj[iIndex];
|
||||
if(!(pObj->m_ByteData.LoadByte(pObj->m_strFileName)))
|
||||
{
|
||||
pObj->m_State = RLOBJSTATE_FAILED;
|
||||
if(pObj->m_pObj)
|
||||
pObj->m_pObj->m_bLoaded = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_State = RLOBJSTATE_LOADING;
|
||||
m_Queue.PushBack(pObj);
|
||||
}
|
||||
}
|
||||
m_Queue.Terminate();
|
||||
}
|
||||
void CResourceLoader::ProcessFunc()
|
||||
{
|
||||
CResourceLoaderObj *pObj = NULL;
|
||||
while( m_Queue.RemoveFront(pObj))
|
||||
{
|
||||
if((pObj) && (pObj->m_pObj))
|
||||
{
|
||||
if(!pObj->m_pObj->Load(&(pObj->m_ByteData)))
|
||||
{ // 로딩 실패시에 다시 queue에 넣어서 ReLoading 시도 한다.
|
||||
if(pObj->m_pObj->m_iReloadingCount < Caldron::MAX_RELOADING) {
|
||||
pObj->m_State = RLOBJSTATE_LOADING;
|
||||
pObj->m_pObj->m_bLoaded = false;
|
||||
m_Queue.PushBack(pObj);
|
||||
CLogMgr::_LogError("CResourceLoader::ProcessFunc: Load fail, Reloading.");
|
||||
pObj->m_pObj->m_iReloadingCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_State = RLOBJSTATE_FAILED;
|
||||
pObj->m_pObj->m_bLoaded = true;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_State = RLOBJSTATE_LOADED;
|
||||
pObj->m_pObj->m_bLoaded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMgr::_LogError("CResourceLoader::ProcessFunc: Obj Ptr is NULL");
|
||||
}
|
||||
}
|
||||
SetEvent(m_EndEvent);
|
||||
}
|
||||
int CResourceLoader::AddObj(CResourceLoaderObj &Obj)
|
||||
{
|
||||
if(!m_bLoading) {
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
m_lstObj.push_back(Obj);
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
return (int)(m_lstObj.size());
|
||||
}
|
||||
else {
|
||||
m_lstReady.push_back(Obj);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
CResourceLoaderObj CResourceLoader::GetObj(int iIndex)
|
||||
{
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
CResourceLoaderObj Obj = m_lstObj[iIndex];
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
|
||||
return Obj;
|
||||
}
|
||||
void CResourceLoader::SetObj(int iIndex,CResourceLoaderObj &Obj)
|
||||
{
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
m_lstObj[iIndex] = Obj;
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
|
||||
}
|
||||
int CResourceLoader::GetObjNum()
|
||||
{
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
int iNum = (int)m_lstObj.size();
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
|
||||
return iNum;
|
||||
}
|
||||
void CResourceLoader::ClearAllObj()
|
||||
{
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
m_lstObj.clear();
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
|
||||
}
|
||||
CResourceLoaderObjState CResourceLoader::GetObjState(int iIndex)
|
||||
{
|
||||
return m_lstObj[iIndex].m_State;
|
||||
}
|
||||
bool CResourceLoader::Finished()
|
||||
{
|
||||
if(WaitFinished() != (WAIT_OBJECT_0))
|
||||
return false;
|
||||
CloseHandle(m_LoaderHandle);
|
||||
CloseHandle(m_ProcessHandle);
|
||||
m_LoaderHandle = m_ProcessHandle = 0;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
void CResourceLoader::Process() {
|
||||
if((m_bLoading == true) && WaitFinished() == (WAIT_OBJECT_0))
|
||||
{
|
||||
m_bLoading = false;
|
||||
ClearAllObj();
|
||||
CloseHandle(m_LoaderHandle);
|
||||
CloseHandle(m_ProcessHandle);
|
||||
m_LoaderHandle = m_ProcessHandle = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((m_lstObj.size() > 0 )&& (m_bLoading == false))
|
||||
Loading();
|
||||
return;
|
||||
}
|
||||
if(m_lstReady.size() > 0 && !m_bLoading)
|
||||
{
|
||||
|
||||
// Ready 큐에 들어 있는 것들을 로딩 리스트로 넘긴다
|
||||
m_lstObj.reserve(m_lstReady.size());
|
||||
std::copy(m_lstReady.begin(),m_lstReady.end(),std::back_inserter(m_lstObj));
|
||||
|
||||
m_lstReady.clear();
|
||||
Loading();
|
||||
}
|
||||
|
||||
}
|
||||
}}
|
||||
118
GameTools/CaldronBase/ResourceLoader.h
Normal file
118
GameTools/CaldronBase/ResourceLoader.h
Normal file
@@ -0,0 +1,118 @@
|
||||
// ResourceLoader.h: interface for the CResourceLoader class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_RESOURCELOADER_H__16578E31_424F_4D74_9304_44BEC2BE6F95__INCLUDED_)
|
||||
#define AFX_RESOURCELOADER_H__16578E31_424F_4D74_9304_44BEC2BE6F95__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
#include "./LoadedObj.h"
|
||||
#include "./ByteDataObj.h"
|
||||
#include "./ThreadQueue.h"
|
||||
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
/* *********************************************************************
|
||||
|
||||
* CResourceLoaderObj
|
||||
|
||||
* 파일 : ResourceLoader.h
|
||||
* 기능 : Caldron Engine내 CResourceLoader 에서 Load Queue에 들어갈 resource 단위
|
||||
* 작성일 : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
enum CResourceLoaderObjState {
|
||||
RLOBJSTATE_READY = 0,
|
||||
RLOBJSTATE_LOADING,
|
||||
RLOBJSTATE_LOADED,
|
||||
RLOBJSTATE_FAILED,
|
||||
|
||||
};
|
||||
const int g_iMaxLoaderQueue = 1023;
|
||||
|
||||
class CResourceLoaderObj {
|
||||
public:
|
||||
|
||||
CResourceLoaderObj();
|
||||
CResourceLoaderObj(const char *strFileName,CLoadedObj *pObj);
|
||||
|
||||
virtual ~CResourceLoaderObj();
|
||||
|
||||
CResourceLoaderObjState m_State;
|
||||
CByteDataObj m_ByteData;
|
||||
char m_strFileName[40];
|
||||
CLoadedObj *m_pObj;
|
||||
|
||||
};
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CResourceLoader
|
||||
|
||||
* 파일 : ResourceLoader.h
|
||||
* 기능 : Caldron Engine내 ResourceLoader
|
||||
* 작성일 : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
class CResourceLoader
|
||||
{
|
||||
public:
|
||||
CResourceLoader();
|
||||
virtual ~CResourceLoader();
|
||||
int FinishPercent();
|
||||
// 현재 queue안에 들어있는 obj 들의 로딩 시작 루틴
|
||||
void Loading();
|
||||
|
||||
void ClearAllObj();
|
||||
int AddObj(CResourceLoaderObj &);
|
||||
void SetObj(int iIndex,CResourceLoaderObj &);
|
||||
|
||||
int GetObjNum();
|
||||
CResourceLoaderObj GetObj(int iIndex);
|
||||
// 현재 로딩상태
|
||||
CResourceLoaderObjState GetObjState(int iIndex);
|
||||
|
||||
DWORD WaitFinished();
|
||||
// 프로세스 스레드에서 호출
|
||||
void ProcessFunc();
|
||||
// 로더 스레드에서 호출
|
||||
void LoaderFunc();
|
||||
bool Finished();
|
||||
void Process();
|
||||
|
||||
protected:
|
||||
// Loading Thread 호출뒤 기다리는 시간
|
||||
// 0 : 곧바로 return, INFINIT : Loading 끝날때 까지 기다림. (default : 0)
|
||||
DWORD m_dwWait;
|
||||
std::vector<CResourceLoaderObj> m_lstObj;
|
||||
std::vector<CResourceLoaderObj> m_lstReady;
|
||||
|
||||
CThreadQueue<CResourceLoaderObj *>m_Queue;
|
||||
|
||||
CRITICAL_SECTION m_ObjCriticalSection;
|
||||
|
||||
unsigned long m_LoaderThreadID;
|
||||
unsigned long m_ProcessThreadID;
|
||||
|
||||
HANDLE m_EndEvent;
|
||||
HANDLE m_LoaderHandle;
|
||||
HANDLE m_ProcessHandle;
|
||||
|
||||
bool m_bLoading;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // !defined(AFX_RESOURCELOADER_H__16578E31_424F_4D74_9304_44BEC2BE6F95__INCLUDED_)
|
||||
108
GameTools/CaldronBase/ThreadQueue.h
Normal file
108
GameTools/CaldronBase/ThreadQueue.h
Normal file
@@ -0,0 +1,108 @@
|
||||
// ThreadQueue.h: interface for the CThreadQueue class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_THREADQUEUE_H__D6165646_A901_43B4_BABC_5237337D0BFD__INCLUDED_)
|
||||
#define AFX_THREADQUEUE_H__D6165646_A901_43B4_BABC_5237337D0BFD__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include "Caldron.h"
|
||||
#include "./LogMgr.h"
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CThreadQueue
|
||||
|
||||
* 파일 : ThreadQueue.cpp
|
||||
* 기능 :
|
||||
* 작성일 : 2004.01.09
|
||||
* history :
|
||||
wizardbug ( 2004.01.09)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
enum CALDRONTHREADEVENT_ID {
|
||||
CALDRONTHREAD_SEMAPHORE = 0,
|
||||
CALDRONTHREAD_TERMINATE,
|
||||
};
|
||||
template<class T>
|
||||
class CThreadQueue
|
||||
{
|
||||
public:
|
||||
CThreadQueue(int iMaxQueueSize)
|
||||
{
|
||||
InitializeCriticalSection(&m_CriticalSection);
|
||||
m_Handle[CALDRONTHREAD_SEMAPHORE] = CreateSemaphore(NULL,0,iMaxQueueSize,NULL);
|
||||
m_Handle[CALDRONTHREAD_TERMINATE] = CreateEvent(NULL,TRUE,FALSE,NULL);
|
||||
|
||||
}
|
||||
virtual ~CThreadQueue()
|
||||
{
|
||||
DeleteCriticalSection(&m_CriticalSection);
|
||||
CloseHandle(m_Handle[CALDRONTHREAD_SEMAPHORE]);
|
||||
CloseHandle(m_Handle[CALDRONTHREAD_TERMINATE]);
|
||||
}
|
||||
bool PushBack(T Obj)
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
m_Queue.push(Obj);
|
||||
|
||||
// semaphore count 증가
|
||||
bool bResult = (ReleaseSemaphore(m_Handle[CALDRONTHREAD_SEMAPHORE],1,NULL) != 0);
|
||||
if(!bResult)
|
||||
{
|
||||
m_Queue.pop(); // pop()은 가장 마지막에 다룬것을 remove 시킨다.
|
||||
CLogMgr::_LogError("CThreadQueue::PushBack() : Queue is Full~!");
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
return bResult;
|
||||
}
|
||||
bool RemoveFront(T &Obj)
|
||||
{
|
||||
bool bResult = false;
|
||||
// Semarphore 에 쌓인 만큼 Return 값의 갯수가 들어간다
|
||||
CALDRONTHREADEVENT_ID ReturnID = (CALDRONTHREADEVENT_ID)WaitForMultipleObjects(2,m_Handle,FALSE,INFINITE);
|
||||
|
||||
if(ReturnID == CALDRONTHREAD_SEMAPHORE)
|
||||
{
|
||||
bResult = true;
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
if(m_Queue.size())
|
||||
{
|
||||
Obj = m_Queue.front();
|
||||
m_Queue.pop(); // pop()은 가장 마지막에 다룬것을 remove 시킨다.
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMgr::_LogError("CThreadQueue::RemoveFront() : Queue is Empty~!");
|
||||
bResult = false;
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void Terminate()
|
||||
{
|
||||
SetEvent(m_Handle[CALDRONTHREAD_TERMINATE]);
|
||||
}
|
||||
void UnTerminate()
|
||||
{
|
||||
ResetEvent(m_Handle[CALDRONTHREAD_TERMINATE]);
|
||||
}
|
||||
protected:
|
||||
|
||||
HANDLE m_Handle[2];
|
||||
CRITICAL_SECTION m_CriticalSection;
|
||||
std::queue<T> m_Queue;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // !defined(AFX_THREADQUEUE_H__D6165646_A901_43B4_BABC_5237337D0BFD__INCLUDED_)
|
||||
58
GameTools/CaldronBase/Timer.cpp
Normal file
58
GameTools/CaldronBase/Timer.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include "Timer.h"
|
||||
|
||||
|
||||
Caldron::Base::CTimer& Caldron::Base::CTimer::_GetInstance()
|
||||
{
|
||||
static CTimer Instance;
|
||||
return Instance;
|
||||
}
|
||||
|
||||
|
||||
Caldron::Base::CTimer::~CTimer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Caldron::Base::CTimer::Init( int keep )
|
||||
{
|
||||
if( !QueryPerformanceFrequency( &m_QPFTicksPerSec ) )
|
||||
MessageBox( NULL, "타이머시스템을지원할수없습니다.", "에러", MB_OK );
|
||||
|
||||
QueryPerformanceCounter( &m_StartTime );
|
||||
|
||||
m_fFps = 0;
|
||||
m_fElapsedTime = 0;
|
||||
m_iKeepFrame = keep;
|
||||
}
|
||||
|
||||
|
||||
void Caldron::Base::CTimer::Update()
|
||||
{
|
||||
static LARGE_INTEGER CurTime;
|
||||
static LARGE_INTEGER LastTime = m_StartTime;
|
||||
|
||||
QueryPerformanceCounter( &CurTime );
|
||||
|
||||
m_fElapsedTime = (float)(((double)CurTime.QuadPart - (double)LastTime.QuadPart) / (double)m_QPFTicksPerSec.QuadPart);
|
||||
m_fFps = (float)((double)m_QPFTicksPerSec.QuadPart / ((double)CurTime.QuadPart - (double)LastTime.QuadPart));
|
||||
m_fAppTime = (float)(((double)CurTime.QuadPart - (double)m_StartTime.QuadPart) / (double)m_QPFTicksPerSec.QuadPart);
|
||||
|
||||
if( m_iKeepFrame > 0 )
|
||||
{
|
||||
while( m_fFps > (float)m_iKeepFrame )
|
||||
{
|
||||
m_fFps = (float)((double)m_QPFTicksPerSec.QuadPart / ((double)CurTime.QuadPart - (double)LastTime.QuadPart));
|
||||
QueryPerformanceCounter( &CurTime );
|
||||
}
|
||||
}
|
||||
|
||||
LastTime = CurTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
45
GameTools/CaldronBase/Timer.h
Normal file
45
GameTools/CaldronBase/Timer.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/**********************************************************************
|
||||
|
||||
* CTimer
|
||||
|
||||
* 파일 : Timer.h
|
||||
* 기능 : Caldron Engine내 시간을 관리해주는 시스템이다.
|
||||
* 작성일 : 2003.10.24
|
||||
* history :
|
||||
kamzic072 ( 2003.10.24 )
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#if !defined(CALDRON__TIMER_H_)
|
||||
#define CALDRON__TIMER_H_
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
namespace Base
|
||||
{
|
||||
class CTimer
|
||||
{
|
||||
private:
|
||||
LARGE_INTEGER m_QPFTicksPerSec;
|
||||
LARGE_INTEGER m_StartTime;
|
||||
float m_fFps;
|
||||
float m_fElapsedTime;
|
||||
float m_fAppTime;
|
||||
int m_iKeepFrame;
|
||||
|
||||
public:
|
||||
virtual ~CTimer();
|
||||
|
||||
static CTimer& _GetInstance();
|
||||
void Init( int keep = -1 );
|
||||
float GetElapsedTime() { return m_fElapsedTime; };
|
||||
float GetFPS() { return m_fFps; };
|
||||
void SetFPS(int frame) { m_iKeepFrame = frame; };
|
||||
void FreeFPS() { m_iKeepFrame = -1; };
|
||||
float GetAppTime() { return m_fAppTime; };
|
||||
void Update();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !defined(CALDRON__TIMER_H_)
|
||||
6601
GameTools/Effect/CEffscript.cpp
Normal file
6601
GameTools/Effect/CEffscript.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1087
GameTools/Effect/CEffscript.h
Normal file
1087
GameTools/Effect/CEffscript.h
Normal file
File diff suppressed because it is too large
Load Diff
109
GameTools/Effect/CEffscriptDefine.h
Normal file
109
GameTools/Effect/CEffscriptDefine.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef __EFFSCRIPTDEFINE_H__
|
||||
#define __EFFSCRIPTDEFINE_H__
|
||||
|
||||
|
||||
#define ESBUF_SIZE 256
|
||||
#define ESEMPTY -1
|
||||
|
||||
#define ESSTART "INDEX"
|
||||
#define ESEND "FIN:"
|
||||
#define ESLIST "LIST:"
|
||||
#define ESLOOP "LOOP:"
|
||||
#define ESPLAY "PLAY:"
|
||||
#define ESSNAP "SNAP:"
|
||||
#define ESFADEOUT "OUT:"
|
||||
#define ESFADEIN "IN:"
|
||||
#define ESSHAKE "SHAKE:"
|
||||
#define ESSOUND "SOUND:"
|
||||
#define ESSUB "SUB:"
|
||||
#define ESCLIGHT "CLIGHT:"
|
||||
#define ESHIT "HIT:"
|
||||
#define ESSLIDE "SLIDE:"
|
||||
#define ESEXT5 "EXT5:"
|
||||
#define ESLIGHTN "LIGHTNING:"
|
||||
#define ESLIGHTN2 "LIGHTNING2:"
|
||||
#define ESLIGHTN3 "LIGHTNING3:"
|
||||
#define ESWHEEL "WHEEL:"
|
||||
#define ESWEAPON "WEAPON:"
|
||||
#define ESBEZIERM "GHOST:"
|
||||
#define ESLIGHT "LIGHT:"
|
||||
#define ESPLAYT "PLAYTIME:"
|
||||
#define ESCHAR "CHARACTER:"
|
||||
#define ESWEAPONL "WEAPONLINE:"
|
||||
|
||||
#define ESPI 3.14159f
|
||||
#define ESHALF_PI (ESPI/2)
|
||||
#define ESGRAVITY 9.806650f
|
||||
|
||||
#define ESEXTLINESIZE 8.0f //line size
|
||||
|
||||
//m_TickFrame deault 값
|
||||
#define DEFAULTESTICK 40
|
||||
|
||||
enum EZVALUE {
|
||||
ESNORMAL, // normal effect
|
||||
ESINTERFACE, // interface effect
|
||||
};
|
||||
|
||||
enum EDIR{
|
||||
EUP,
|
||||
ELEFT,
|
||||
ERIGHT,
|
||||
EFRONT,
|
||||
ERAND
|
||||
};
|
||||
enum ECURRENT{ // 파일에서 지금 읽어들이는 데이터 종류
|
||||
ESS, //start
|
||||
ESE, // end
|
||||
EST, // list
|
||||
ESL, //loop
|
||||
ESP, //play
|
||||
ESFO, //FADE out
|
||||
ESFI, //FADE IN
|
||||
ESSK, // camera shake
|
||||
ESN, // snap
|
||||
ESO, // sound
|
||||
ESB, // Sub
|
||||
ESCL, // CLight
|
||||
ESH, // Hit
|
||||
ESSL, // slide
|
||||
ESE5, //ext5extension
|
||||
ESLN, //lightning
|
||||
ESLN2, //lightning2
|
||||
ESLN3, //lightning3
|
||||
ESW, // wheel
|
||||
ESWP, // Weapon
|
||||
ESBM, // Bezier Middle
|
||||
ESLT, // Light
|
||||
ESPT, // Play Time
|
||||
ESCH, // Character
|
||||
ESWL,
|
||||
};
|
||||
enum EVALUE { // 어떤 것을 진행중인지..
|
||||
ED, // Delay frame
|
||||
ES, // S effect
|
||||
EM, // M effect
|
||||
EE, // E effect
|
||||
EN, //Snap effect
|
||||
EF, //finish effect
|
||||
};
|
||||
enum EPIVOT { // extension4 용 pivot index
|
||||
EHEAD,
|
||||
ENECK,
|
||||
ECHEST,
|
||||
EWAIST,
|
||||
EPELVIS,
|
||||
ER_HAND,
|
||||
ER_FOREARM,
|
||||
ER_UPPERARM,
|
||||
ER_THIGH,
|
||||
ER_CALF,
|
||||
ER_FOOT,
|
||||
EL_HAND,
|
||||
EL_FOREARM,
|
||||
EL_UPPERARM,
|
||||
EL_THIGH,
|
||||
EL_CALF,
|
||||
EL_FOOT,
|
||||
};
|
||||
#endif
|
||||
2592
GameTools/Effect/CGemRender.cpp
Normal file
2592
GameTools/Effect/CGemRender.cpp
Normal file
File diff suppressed because it is too large
Load Diff
442
GameTools/Effect/CGemRender.h
Normal file
442
GameTools/Effect/CGemRender.h
Normal file
@@ -0,0 +1,442 @@
|
||||
#ifndef __CGEMRENDER_H__
|
||||
#define __CGEMRENDER_H__
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
|
||||
#define BUF_SIZE 256
|
||||
#define VOT 1.0f
|
||||
#define GEM_HEADER "GemDataFile\n"
|
||||
|
||||
|
||||
class CGemRender {
|
||||
public:
|
||||
void SetClearBuffer(bool b);
|
||||
bool m_bClearBuffer;
|
||||
class GemTexture {
|
||||
public:
|
||||
CTexture *m_Tex;
|
||||
int TexNum;
|
||||
GemTexture() {
|
||||
m_Tex = NULL;
|
||||
TexNum = 0;
|
||||
}
|
||||
~GemTexture() {
|
||||
if(m_Tex) {
|
||||
/* if(TexNum >1)
|
||||
delete[] m_Tex;
|
||||
else*/
|
||||
delete[] m_Tex;
|
||||
}
|
||||
}
|
||||
};
|
||||
class GemSubFace{
|
||||
public:
|
||||
int *sub;
|
||||
int *sub_mat;
|
||||
int sub_num;
|
||||
GemSubFace() {
|
||||
sub = NULL;
|
||||
sub_mat = NULL;
|
||||
sub_num = 0;
|
||||
}
|
||||
~GemSubFace() {
|
||||
delete[] sub;
|
||||
delete[] sub_mat;
|
||||
}
|
||||
};
|
||||
class GemVertex{
|
||||
public:
|
||||
float x,y,z;
|
||||
float nx,ny,nz;
|
||||
float s,t;
|
||||
GemVertex() {
|
||||
x = y = z = 0.0f;
|
||||
nx = ny = nz = 0.0f;
|
||||
s = t = 0.0f;
|
||||
}
|
||||
~GemVertex() {}
|
||||
};
|
||||
class GemRotKey {
|
||||
public:
|
||||
int frame;
|
||||
D3DXVECTOR4 rot;
|
||||
|
||||
GemRotKey() {
|
||||
frame = 0;
|
||||
rot.x = rot.y = rot.z = rot.w = 0.0f;
|
||||
}
|
||||
|
||||
~GemRotKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemPosKey{
|
||||
public:
|
||||
int frame;
|
||||
bool bez;
|
||||
D3DXVECTOR3 pos;
|
||||
D3DXVECTOR3 intan;
|
||||
D3DXVECTOR3 outtan;
|
||||
GemPosKey() {
|
||||
frame = 0;
|
||||
bez = false;
|
||||
pos.x = pos.y = pos.z = 0.0f;
|
||||
intan.x = intan.y = intan.z = 0.0f;
|
||||
outtan.x = outtan.y = outtan.z = 0.0f;
|
||||
}
|
||||
~GemPosKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemScaleKey{
|
||||
public:
|
||||
int frame;
|
||||
D3DXVECTOR3 scale;
|
||||
GemScaleKey() {
|
||||
frame = 0;
|
||||
scale.x = scale.y = scale.z= 1.0f;
|
||||
}
|
||||
~GemScaleKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemVisKey{
|
||||
public:
|
||||
int frame;
|
||||
float vis;
|
||||
GemVisKey(){
|
||||
frame = 0;
|
||||
vis = 1.0f;
|
||||
}
|
||||
~GemVisKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemObject {
|
||||
public:
|
||||
char m_Name[BUF_SIZE];
|
||||
char m_ParentName[BUF_SIZE];
|
||||
bool m_bParent;
|
||||
|
||||
D3DXMATRIX m_TmMatrix;
|
||||
|
||||
// vertex info
|
||||
D3DXVECTOR2 *m_Coord;
|
||||
D3DXVECTOR3 *m_CoordFace;
|
||||
|
||||
D3DXVECTOR3 *m_Vert;
|
||||
D3DXVECTOR4 *m_Face;
|
||||
D3DXVECTOR3 *m_Fnormal;
|
||||
D3DXVECTOR3 *m_Normal;
|
||||
int m_MatId;
|
||||
|
||||
int m_Frame;
|
||||
int m_CoordNum;
|
||||
int m_iVertexStartCount;
|
||||
|
||||
int m_VertexNum;
|
||||
int m_FaceNum;
|
||||
// anikey info
|
||||
int m_RotKeyNum;
|
||||
int m_PosKeyNum;
|
||||
int m_ScaleKeyNum;
|
||||
int m_VisKeyNum;
|
||||
//morphing
|
||||
int m_MorphNum;
|
||||
// 추가기능
|
||||
bool m_Bil1;
|
||||
bool m_Bil2;
|
||||
bool m_Bil3;
|
||||
// multy uv ani
|
||||
bool m_Multy;
|
||||
bool m_TexAni;
|
||||
bool m_RandAni;
|
||||
bool m_RandStartTexAni; //시작 프레임이 다른 텍스쳐 애니 flag
|
||||
bool m_RandStartSetting; //start 되었는지
|
||||
bool m_Zenable;
|
||||
bool m_Opacity;
|
||||
//사용되는 texture 갯수
|
||||
int m_AniTextureNum;
|
||||
int m_CurrentAniTexture;
|
||||
int m_BeforeAniTexture;
|
||||
|
||||
int m_Red;
|
||||
int m_Green;
|
||||
int m_Blue;
|
||||
// 보간법 선택
|
||||
bool m_bH;
|
||||
// cullmode on flag
|
||||
bool m_bCull;
|
||||
|
||||
float m_AniChangeFrame;
|
||||
//tex ani start frame
|
||||
float m_StartTexAniFrame;
|
||||
|
||||
bool m_Zbuffer;
|
||||
bool m_bDecal;
|
||||
|
||||
GemObject *m_Morph;
|
||||
|
||||
|
||||
|
||||
GemVisKey *m_Vis;
|
||||
GemScaleKey *m_Scale;
|
||||
GemPosKey *m_Pos;
|
||||
GemRotKey *m_Rot;
|
||||
DWORD m_Color;
|
||||
// vertex buffer 생성시에 필요한 vert pointer
|
||||
GemVertex *m_VertexBuffer;
|
||||
bool m_bInterpol;
|
||||
|
||||
GemObject() {
|
||||
|
||||
m_Multy = false;
|
||||
m_RotKeyNum = m_PosKeyNum = m_ScaleKeyNum = m_VisKeyNum = 0;
|
||||
m_Vis = NULL;
|
||||
m_Scale = NULL;
|
||||
m_Pos = NULL;
|
||||
m_Rot = NULL;
|
||||
m_Red = m_Green = m_Blue = 255;
|
||||
m_bH = false;
|
||||
//morphing vertex
|
||||
m_Morph = NULL;
|
||||
m_MorphNum = 0;
|
||||
m_StartTexAniFrame = 0.0f;
|
||||
m_Zbuffer = false;
|
||||
m_Zenable = false;
|
||||
|
||||
m_bCull = false;
|
||||
m_Color = D3DCOLOR_ARGB(255,255,255,255);
|
||||
|
||||
m_MatId = -1;
|
||||
|
||||
m_Frame = -1;
|
||||
m_VertexNum = 0;
|
||||
m_FaceNum = 0;
|
||||
m_CoordNum =0;
|
||||
|
||||
m_Coord = NULL;
|
||||
m_CoordFace = NULL;
|
||||
|
||||
m_Vert = NULL;
|
||||
m_Face = NULL;
|
||||
m_Fnormal = NULL;
|
||||
m_Normal = NULL;
|
||||
m_bParent = false;
|
||||
m_Bil1 = m_Bil2 = m_Bil3 = false;
|
||||
m_TexAni = false;
|
||||
m_RandAni = false;
|
||||
m_RandStartTexAni = false;
|
||||
m_RandStartSetting = false;
|
||||
m_Opacity = false;
|
||||
m_AniChangeFrame = 0.0f;
|
||||
m_AniTextureNum = 0;
|
||||
m_CurrentAniTexture = 0;
|
||||
m_BeforeAniTexture = 0;
|
||||
D3DXMatrixIdentity(&m_TmMatrix);
|
||||
memset(m_Name,0,sizeof(char)*BUF_SIZE);
|
||||
memset(m_ParentName,0,sizeof(char)*BUF_SIZE);
|
||||
m_VertexBuffer = NULL;
|
||||
m_bInterpol = true;
|
||||
m_bDecal = false;
|
||||
m_iVertexStartCount = 0;
|
||||
|
||||
}
|
||||
~GemObject() {
|
||||
if(m_Scale != NULL)
|
||||
delete[] m_Scale;
|
||||
if(m_Vis != NULL)
|
||||
delete[] m_Vis;
|
||||
if(m_Vert != NULL)
|
||||
delete[] m_Vert;
|
||||
if(m_Face != NULL)
|
||||
delete[] m_Face;
|
||||
if(m_Coord != NULL)
|
||||
delete[] m_Coord;
|
||||
if(m_CoordFace != NULL)
|
||||
delete[] m_CoordFace;
|
||||
if(m_Fnormal != NULL)
|
||||
delete[] m_Fnormal;
|
||||
if(m_Normal != NULL)
|
||||
delete[] m_Normal;
|
||||
if(m_Rot)
|
||||
delete[] m_Rot;
|
||||
if(m_Pos)
|
||||
delete[] m_Pos;
|
||||
if(m_Morph)
|
||||
delete[] m_Morph;
|
||||
if(m_VertexBuffer)
|
||||
delete[] m_VertexBuffer;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class GemMaterial {
|
||||
public:
|
||||
char m_TextureName[BUF_SIZE];
|
||||
int m_SubNum;
|
||||
GemMaterial *m_Sub;
|
||||
GemMaterial() {
|
||||
memset(m_TextureName,0,BUF_SIZE);
|
||||
m_Sub = NULL;
|
||||
m_SubNum = 0;
|
||||
}
|
||||
~GemMaterial() {
|
||||
if(m_SubNum)
|
||||
delete[] m_Sub;
|
||||
}
|
||||
};
|
||||
CGemRender();
|
||||
~CGemRender();
|
||||
|
||||
void SetTransMatrix(D3DXMATRIX m) {m_TrMatrix = m;}
|
||||
bool CheckPosition(D3DXVECTOR3 center,D3DXVECTOR3 user);
|
||||
void SetXrot(float rot) { m_Xrot = rot;}
|
||||
void SetYrot(float rot) { m_Yrot = rot;}
|
||||
void SetZrot(float rot) { m_Zrot = rot;}
|
||||
|
||||
|
||||
void ScaleAni(int object_index,D3DXMATRIX &);
|
||||
void PosAni(int object_index,D3DXMATRIX &);
|
||||
void RotAni(int object_index,D3DXMATRIX &);
|
||||
|
||||
bool LoadGemFile(char *,LPDIRECT3DDEVICE8 ,bool bVisibility = true);
|
||||
bool LoadUvFile(char *);
|
||||
|
||||
bool LoadMorph(int );
|
||||
void MsgPrint(char *);
|
||||
void SetInitBuffer();
|
||||
|
||||
void SetVertexBuffer(int index,GemVertex *ppTmp);
|
||||
void SetDecalBuffer(int index); // Vertex Buffer 에 세팅
|
||||
void SetDecalBufferInit(int index); // Decal Buffer Init
|
||||
|
||||
void SetStartFrame(float s);
|
||||
|
||||
void SetCash(bool b) { m_bCash = b;}
|
||||
|
||||
void Render();
|
||||
void RenderObject(int object_index,GemVertex **ppTmp);
|
||||
|
||||
void Update();
|
||||
void Update(D3DXVECTOR3 center,D3DXVECTOR3 user);
|
||||
|
||||
void UnUpdate();
|
||||
bool VertexInterpolation(int index);
|
||||
void LoadSubFace(int object_index);
|
||||
void LoadTexture();
|
||||
// set zbuffer cullface all object
|
||||
void SetCullZbuffer(bool );
|
||||
// my effect setting
|
||||
void SetMine(bool t);
|
||||
|
||||
void LoadTexAni(int object_index);
|
||||
bool VisAni(int object_index);
|
||||
void CreateAniTm(int index,D3DXMATRIX &,D3DXMATRIX &);
|
||||
void SetChangeAniFrame(int object_index,float f);
|
||||
void SetStartTexAniFrame(int object_index,float f);
|
||||
int GetMaxFrame() {return (m_EndF / m_UnitF);}
|
||||
// effect scale setting func
|
||||
void SetScale(float x,float y,float z);
|
||||
void SetEffectPos(float x,float y,float z);
|
||||
void SetEffectPos(D3DXVECTOR3 pos);
|
||||
void SetCurrentFrame(float f);
|
||||
void SetCurrentFrame(float f,int *,DWORD *,bool *,bool update = false);
|
||||
|
||||
void SetSrcBlend(DWORD s) {m_SrcBlend = s;}
|
||||
void SetDstBlend(DWORD d) {m_DstBlend = d;}
|
||||
void SetBlend(DWORD s,DWORD d) { m_SrcBlend = s; m_DstBlend = d;}
|
||||
void SetColor(int object_index,int r,int g,int b);
|
||||
void SetNullTexture(bool b) {m_bNullTexture = b;}
|
||||
void SetPickObject(int index);
|
||||
void SetVot(float v) {m_Vot = v;}
|
||||
void SetLoop(bool b) {m_bLoop = b;}
|
||||
int GetObjectNum() {return m_ObjectNum;}
|
||||
void SetStartTexAni(bool b) {m_bTexAni = b;}
|
||||
void SetAxis(D3DXMATRIX & );
|
||||
void GetAxis(float ,float ,float ,float );
|
||||
void GetAxis(D3DXQUATERNION tmp) {m_AxisSet = true; m_Axis = tmp;}
|
||||
// ANI MESH USE
|
||||
void SetRandAni(bool b) {m_RandAni = b;}
|
||||
void SetRandAniMax(float s) {m_RandAniMax = s;}
|
||||
void SetRandAniMin(float s) {m_RandAniMin = s;}
|
||||
void SetSwitchAni(bool b) {m_SwitchAni = b;}
|
||||
void SetAniRad(float r) {m_AniRad = r;}
|
||||
// light 적용 mesh
|
||||
void SetLight(bool b) {m_bLight = b;}
|
||||
void SetVertexMorphData(int i);
|
||||
|
||||
char *GetFileName() {return m_FileName;}
|
||||
|
||||
FILE *m_GemFile;
|
||||
//multy uv
|
||||
int m_bMulty;
|
||||
|
||||
int m_StartF;
|
||||
int m_EndF;
|
||||
int m_UnitF;
|
||||
int m_ObjectNum;
|
||||
int m_PickObject;
|
||||
|
||||
int m_MatNum;
|
||||
bool m_bNullTexture;
|
||||
bool m_bLoop;
|
||||
bool m_bCash;
|
||||
|
||||
bool m_bTexAni;
|
||||
bool m_Mine;
|
||||
bool m_bDecal;
|
||||
|
||||
DWORD m_SrcBlend,m_DstBlend;
|
||||
|
||||
float m_CurrentF;
|
||||
LPDIRECT3DDEVICE8 m_Device;
|
||||
D3DXMATRIX m_Scale;
|
||||
D3DXMATRIX m_TrMatrix;
|
||||
D3DXVECTOR3 m_Pos;
|
||||
D3DXQUATERNION global;
|
||||
D3DXQUATERNION m_Axis;
|
||||
bool m_AxisSet;
|
||||
//ANI MESH
|
||||
float m_Xrot,m_Yrot,m_Zrot;
|
||||
bool m_RandAni;
|
||||
float m_RandAniMax;
|
||||
float m_RandAniMin;
|
||||
float m_AniRad;
|
||||
bool m_SwitchAni;
|
||||
bool m_StartSwitch;
|
||||
GemMaterial *m_Mtl;
|
||||
|
||||
|
||||
GemObject *m_Object;
|
||||
GemSubFace *m_Sub;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_ObjectVertex;
|
||||
int m_iTotalVertexNum;
|
||||
int m_iTotalFaceNum;
|
||||
|
||||
GemTexture *m_Texture;
|
||||
GemTexture *m_TexAni;
|
||||
|
||||
int m_TexNum;
|
||||
float m_Vot;
|
||||
|
||||
//// vertex buffer 생성시에 필요한 vert pointer
|
||||
//GemVertex *m_Vert;
|
||||
int VbufferNum;
|
||||
// multy uv ani
|
||||
CGemRender *m_Multy;
|
||||
bool m_bLight;
|
||||
char m_FileName[256];
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
1422
GameTools/Effect/CLightning.cpp
Normal file
1422
GameTools/Effect/CLightning.cpp
Normal file
File diff suppressed because it is too large
Load Diff
202
GameTools/Effect/CLightning.h
Normal file
202
GameTools/Effect/CLightning.h
Normal file
@@ -0,0 +1,202 @@
|
||||
#ifndef __CLIGHTNING_H__
|
||||
#define __CLIGHTNING_H__
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
|
||||
#define LIGHTHALFWIDTH 10.0f
|
||||
// lightning 을 표현 하는 plane 방식
|
||||
enum PLANE {
|
||||
LPLANE_ONE, // one plane
|
||||
LPLANE_CROSS, //십자 plane
|
||||
LPLANE_X, // X자 plane
|
||||
};
|
||||
enum LIGHTNINGVALUE { // 어떤종류 인지 : 0 라이트닝, 궤적, 1 베지어 곡선
|
||||
LV_LIGHTNING,
|
||||
LV_BEZIER,
|
||||
|
||||
};
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CLightning {
|
||||
public:
|
||||
class CLightVertex {
|
||||
public:
|
||||
float x,y,z;
|
||||
DWORD color;
|
||||
float s,t;
|
||||
CLightVertex() {
|
||||
x = y = z = 0.0f;
|
||||
color = D3DCOLOR_ARGB(255,255,255,255);
|
||||
s = t = 0.0f;
|
||||
}
|
||||
~CLightVertex() {}
|
||||
|
||||
};
|
||||
class CBezierInfo { // Bezier Line 관련 Data
|
||||
public:
|
||||
float m_fControl;
|
||||
float m_fControlHeight;
|
||||
float m_fSpeed;
|
||||
float m_fAccel;
|
||||
float m_fStartEndLength;
|
||||
float m_fFade;
|
||||
float m_fLimitLength;
|
||||
float m_ft;
|
||||
int m_iAxis;
|
||||
int m_iEndSpeed;
|
||||
int m_iEndAccel;
|
||||
int m_iUvMode;
|
||||
|
||||
CBezierInfo() {
|
||||
|
||||
m_fControl = 0.5;
|
||||
m_fControlHeight = 30.0f;
|
||||
m_fSpeed = 0.0f;
|
||||
m_fAccel = 0.0f;
|
||||
m_fStartEndLength = 0.0f;
|
||||
m_fFade = 0.0f;
|
||||
m_fLimitLength = 0.0f;
|
||||
m_ft = 0.05f;
|
||||
m_iAxis = 0;
|
||||
|
||||
m_iEndSpeed = 0;
|
||||
m_iEndAccel = 0;
|
||||
m_iUvMode = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
// Bezier Point List
|
||||
vector<D3DXVECTOR3> m_BezierPointList;
|
||||
|
||||
// 기준점 및 렌덤점 포인터
|
||||
D3DXVECTOR3 *m_PointList;
|
||||
int m_EndCount;
|
||||
|
||||
int m_PointNum;
|
||||
// 한 퀴드의 width
|
||||
float m_QuadHalfWidth;
|
||||
// insert 된 point
|
||||
int m_InsertCount;
|
||||
// render 된 count
|
||||
int m_RenderCount;
|
||||
int m_MaxRenderCount;
|
||||
|
||||
LPDIRECT3DDEVICE8 m_Device;
|
||||
//가로 플랜
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_Vert;
|
||||
// 세로 플랜
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_VerticalVert;
|
||||
// 세로 플랜 2
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_VerticalVert2;
|
||||
int m_VertNum;
|
||||
CTexture *m_Texture;
|
||||
int m_TexNum;
|
||||
//shake value 최소치
|
||||
float m_ShakeMin;
|
||||
//shake value 최대치
|
||||
float m_ShakeMax;
|
||||
|
||||
DWORD m_Color;
|
||||
float m_Alpha;
|
||||
|
||||
bool m_bFadeOut;
|
||||
float m_FadeSpeed;
|
||||
// uv ani 를 위한 증가치
|
||||
float m_UvAni;
|
||||
// 업데이트시 증가되는 uv 단위양
|
||||
float m_UnitUv;
|
||||
// 십자, 1자 플랜 인지 결정
|
||||
int m_PlaneValue;
|
||||
// 이팩트 end setting
|
||||
bool m_bSetEndEffect;
|
||||
// 줄어드는 속도
|
||||
int m_EndUnit;
|
||||
|
||||
int m_LightningValue;
|
||||
|
||||
// Bezier Value
|
||||
CBezierInfo m_Bezier;
|
||||
bool m_bCrash; // 충돌한 light beam 인가?
|
||||
bool m_bEndInput;
|
||||
|
||||
int m_iAlpha; // 충돌한 light beam alpha value
|
||||
|
||||
CLightVertex *tmp_Vertex;
|
||||
CLightVertex *tmp_Vertex2;
|
||||
CLightVertex *tmp_Vertex3;
|
||||
|
||||
|
||||
CLightning(LPDIRECT3DDEVICE8 );
|
||||
CLightning(int ,LPDIRECT3DDEVICE8 );
|
||||
CLightning();
|
||||
|
||||
~CLightning();
|
||||
//wheel이 세팅되어 있는 esf 에서 wheel 이 더이상 업데이트 되지 않을때 setting
|
||||
// render2에 영향을 줌
|
||||
void SetEffectEnd(bool s,int end) {m_bSetEndEffect = s; m_EndUnit = end;}
|
||||
|
||||
void SetUnitUv(float s) {m_UnitUv = s;}
|
||||
|
||||
void SetSize(float s) {m_QuadHalfWidth = s;}
|
||||
|
||||
void SetDevice(LPDIRECT3DDEVICE8 device) {m_Device = device;}
|
||||
|
||||
void SetShakeValue(float smin,float smax) {m_ShakeMin = smin;
|
||||
m_ShakeMax = smax;}
|
||||
|
||||
void CreateList(int );
|
||||
void DeleteList();
|
||||
|
||||
void InsertPoint(float ,float ,float );
|
||||
void InsertPoint(D3DXVECTOR3 );
|
||||
void InsertEmptyPoint(float ,float ,float );
|
||||
void SetStartPoint(float ,float ,float );
|
||||
void SetVertNum(int n) {m_VertNum = n;}
|
||||
void SetFadeStart(bool t) {m_bFadeOut = t;}
|
||||
void SetFadeSpeed(float s) { m_FadeSpeed = s;}
|
||||
bool GetEnd();
|
||||
void SetEnd();
|
||||
void SetEndPoint(float ,float ,float );
|
||||
void SetRandPoint();
|
||||
bool SetBezierPoint(); //Bezier Curve Point Setting
|
||||
|
||||
void SetColor(DWORD c) {m_Color = c;}
|
||||
void SetColor();
|
||||
void SetPlaneValue(int k) { m_PlaneValue = k;}
|
||||
|
||||
void CreateTexture(int );
|
||||
void SetTexture(int ,char *);
|
||||
|
||||
void CreateVertexBuffer();
|
||||
void SetVertexBuffer(int ,int wheelvalue = 0 );
|
||||
void SetBezierBuffer(int ,int wheelvalue = 0 );
|
||||
|
||||
void Render(int blendmode);
|
||||
void SetCrash(bool b) { m_bCrash = b;} // Crash Check Setting Func
|
||||
|
||||
// wheel (궤적 그리는 루틴)
|
||||
void Render2(int blendmode);
|
||||
|
||||
bool UpdateLightning(D3DXVECTOR3 &pos,bool bCrash);
|
||||
|
||||
void SetLightningValue(int t) { m_LightningValue = t;}
|
||||
void SetBezierControl(float control,float height,float speed,float accel,float length,
|
||||
float fade,float limitlength,int axis,int endspeed,int endaccel,int uv);
|
||||
|
||||
D3DXVECTOR3 GetBezierLastPos();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
65
GameTools/Effect/EffAseDefine.h
Normal file
65
GameTools/Effect/EffAseDefine.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/************************
|
||||
ase label define
|
||||
**************************/
|
||||
|
||||
|
||||
|
||||
#ifndef __EFFASEDEFINE_H__
|
||||
|
||||
#define __EFFASEDEFINE_H__
|
||||
|
||||
#define OBJECT "*GEOMOBJECT" // An object tag for new objects
|
||||
#define LIGHT_OBJECT "*LIGHTOBJECT"
|
||||
#define NODE_NAME "*NODE_NAME"
|
||||
#define NODE_PARENT "*NODE_PARENT"
|
||||
#define NODE_TM "*NODE_TM"
|
||||
#define TM_ROW0 "*TM_ROW0"
|
||||
#define TM_ROW1 "*TM_ROW1"
|
||||
#define TM_ROW2 "*TM_ROW2"
|
||||
#define TM_ROW3 "*TM_ROW3"
|
||||
#define TM_POS "*TM_POS"
|
||||
#define TM_ROTAXIS "*TM_ROTAXIS"
|
||||
#define TM_ROTANGLE "*TM_ROTANGLE"
|
||||
#define TM_SCALE "*TM_SCALE"
|
||||
#define TM_SCALEAXIS "*TM_SCALEAXIS"
|
||||
#define TM_SCALEAXISANG "*TM_SCALEAXISANG"
|
||||
|
||||
#define BLOCK_START "{"
|
||||
#define BLOCK_END "}"
|
||||
|
||||
#define NUM_VERTEX "*MESH_NUMVERTEX" // The number of vertices tag
|
||||
#define NUM_FACES "*MESH_NUMFACES" // The number of faces tag
|
||||
#define NUM_TVERTEX "*MESH_NUMTVERTEX" // The number of texture coordinates
|
||||
#define VERTEX "*MESH_VERTEX" // The list of vertices tag
|
||||
#define FACE "*MESH_FACE" // The list of faces tag
|
||||
#define NORMALS "*MESH_NORMALS" // The list of normals tag (If you want)
|
||||
#define FACE_NORMAL "*MESH_FACENORMAL" // The face normal for the current index
|
||||
#define NVERTEX "*MESH_VERTEXNORMAL" // The list of vertex normals
|
||||
#define TVERTEX "*MESH_TVERT" // The texture coordinate index tag
|
||||
#define TFACE "*MESH_TFACE" // The vertex index tag
|
||||
#define TEXTURE "*BITMAP" // The file name for the object's texture map
|
||||
#define UTILE "*UVW_U_TILING" // The U tiling ratio tag
|
||||
#define VTILE "*UVW_V_TILING" // The V tiling ratio tag
|
||||
#define UOFFSET "*UVW_U_OFFSET" // The U tile offset tag
|
||||
#define VOFFSET "*UVW_V_OFFSET" // The V tile offset tag
|
||||
#define MATERIAL_ID "*MATERIAL_REF" // The material ID tag
|
||||
#define MATERIAL_COUNT "*MATERIAL_COUNT" // The material count tag
|
||||
#define MATERIAL "*MATERIAL" // The material tag
|
||||
#define MATERIAL_NAME "*MATERIAL_NAME" // The material name tag
|
||||
#define MATERIAL_COLOR "*MATERIAL_DIFFUSE" // The material color tag
|
||||
|
||||
#define TM_ANIMATION "*TM_ANIMATION"
|
||||
#define CONTROL_ROT_TCB "*CONTROL_ROT_TCB"
|
||||
#define CONTROL_TCB_ROT_KEY "*CONTROL_TCB_ROT_KEY"
|
||||
#define CONTROL_POS_BEZIER "*CONTROL_POS_BEZIER"
|
||||
#define CONTROL_BEZIER_POS_KEY "*CONTROL_BEZIER_POS_KEY"
|
||||
#define CONTROL_SCALE_BEZIER "*CONTROL_SCALE_BEZIER"
|
||||
#define CONTROL_BEZIER_SCALE_KEY "*CONTROL_BEZIER_SCALE_KEY"
|
||||
///////////////////////////////////
|
||||
// mesh ani value
|
||||
//////////////////////////////////
|
||||
#define MESH_ANIMATION "*MESH_ANIMATION"
|
||||
// use check ani frame num.
|
||||
#define MESH_TIMEVALUE "*TIMEVALUE"
|
||||
|
||||
#endif
|
||||
8
GameTools/Effect/EffDebugLog.cpp
Normal file
8
GameTools/Effect/EffDebugLog.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "EffDebugLog.h"
|
||||
|
||||
void WriteDebug(char *strErr) {
|
||||
char *strDebugFile = "EffectErr.txt";
|
||||
FILE *fp = fopen(strDebugFile,"at+");
|
||||
fprintf(fp,"File Not Found : %s\n",strErr);
|
||||
fclose(fp);
|
||||
}
|
||||
8
GameTools/Effect/EffDebugLog.h
Normal file
8
GameTools/Effect/EffDebugLog.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __EFFDEBUGLOG__H__
|
||||
#define __EFFDEBUGLOG__H__
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
void WriteDebug(char *strErr);
|
||||
|
||||
#endif
|
||||
212
GameTools/Effect/Effect.dsp
Normal file
212
GameTools/Effect/Effect.dsp
Normal file
@@ -0,0 +1,212 @@
|
||||
# Microsoft Developer Studio Project File - Name="Effect" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=Effect - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Effect.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Effect.mak" CFG="Effect - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Effect - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "Effect - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""$/Effect", ILCAAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Effect - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x412 /d "NDEBUG"
|
||||
# ADD RSC /l 0x412 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "Effect - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x412 /d "_DEBUG"
|
||||
# ADD RSC /l 0x412 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Effect - Win32 Release"
|
||||
# Name "Effect - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CEffscript.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CGemRender.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CLightning.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\EffDebugLog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MemoryPool.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffect.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectBase.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectBillboard.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectCylinder.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectManager.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectMesh.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectParticle.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectPlane.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectSphere.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CEffscript.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CEffscriptDefine.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CGemRender.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CLightning.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\EffDebugLog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Key.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MemoryPool.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffect.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectBase.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectBillboard.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectCylinder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectManager.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectMesh.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectParticle.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectPlane.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\X3DEffectSphere.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
29
GameTools/Effect/Effect.dsw
Normal file
29
GameTools/Effect/Effect.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Effect"=.\Effect.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
BIN
GameTools/Effect/Effect.opt
Normal file
BIN
GameTools/Effect/Effect.opt
Normal file
Binary file not shown.
26
GameTools/Effect/Effect.plg
Normal file
26
GameTools/Effect/Effect.plg
Normal file
@@ -0,0 +1,26 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: Effect - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6F.tmp" with contents
|
||||
[
|
||||
/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /Fp"Debug/Effect.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
|
||||
"C:\ryl\Effect\mmgr.cpp"
|
||||
]
|
||||
Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6F.tmp"
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
Skipping... (no relevant changes detected)
|
||||
mmgr.cpp
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
mmgr.obj - 0 error(s), 0 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
430
GameTools/Effect/Effect.vcproj
Normal file
430
GameTools/Effect/Effect.vcproj
Normal file
@@ -0,0 +1,430 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="Effect"
|
||||
ProjectGUID="{F6D69046-0CA3-4A3B-A6CA-5638A45AC9E8}"
|
||||
SccProjectName=""$/Effect", ILCAAAAA"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\ZALLA3D BASECLASS;..\Effect;..\CHARACTERACTIONCONTROL;..\SoundLib;..\CaldronBase;..\Zallad3D SceneClass"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug/Effect.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Debug\Effect.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1042"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="4"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\ZALLA3D BASECLASS;..\Effect;..\CHARACTERACTIONCONTROL;..\SoundLib;..\CaldronBase;..\Zallad3D SceneClass"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Release/Effect.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile=".\Release\Effect.lib"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1042"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath="CEffscript.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CGemRender.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CLightning.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="EffDebugLog.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="MemoryPool.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffect.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectBase.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectBillboard.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectCylinder.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectManager.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectMesh.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectParticle.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectPlane.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectSphere.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="CEffscript.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CEffscriptDefine.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CGemRender.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CLightning.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="EffDebugLog.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Key.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="MemoryPool.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffect.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectBase.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectBillboard.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectCylinder.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectManager.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectMesh.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectParticle.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectPlane.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="X3DEffectSphere.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
143
GameTools/Effect/EffectCasher.cpp
Normal file
143
GameTools/Effect/EffectCasher.cpp
Normal file
@@ -0,0 +1,143 @@
|
||||
// EffectCasher.cpp: implementation of the CEffectCasher class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "EffectCasher.h"
|
||||
#include "SceneManager.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
CEffectCashObj::CEffectCashObj()
|
||||
{
|
||||
m_pData = NULL;
|
||||
}
|
||||
CEffectCashObj::CEffectCashObj(const char *strName)
|
||||
{
|
||||
EffectLoad(strName);
|
||||
}
|
||||
bool CEffectCashObj::EffectLoad(const char *strName) {
|
||||
|
||||
m_pData = new CEffScript;
|
||||
m_pData->GetScriptBinData((char *)strName);
|
||||
m_pData->SetDevice(CSceneManager::GetDevice());
|
||||
/* m_pData->SetStartPos(0.0f,0.0f,0.0f);
|
||||
m_pData->SetEndPos(0.0f,0.0f,0.0f);
|
||||
|
||||
|
||||
m_pData->ProcessEffect();
|
||||
*/
|
||||
return true;
|
||||
|
||||
}
|
||||
CEffectCashObj::~CEffectCashObj()
|
||||
{
|
||||
if(m_pData != NULL)
|
||||
{
|
||||
delete m_pData;
|
||||
m_pData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CEffectCasher::CEffectCasher()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CEffectCasher::~CEffectCasher()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
bool CEffectCasher::LoadCashData(const char *strPath)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
bool CEffectCasher::BuildHashTable(const char *strPath)
|
||||
{
|
||||
char strFilePath[256] = {0,};
|
||||
|
||||
|
||||
strcpy(strFilePath,strPath);
|
||||
strcat(strFilePath,"/*.esf");
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
HANDLE hFind;
|
||||
hFind = FindFirstFile(strFilePath, &FindFileData);
|
||||
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
MessageBox(NULL,"Effect Loader가 실패 했습니다.","ERROR",MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_iCashNum = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
unsigned long ulTmp;
|
||||
CEffectCashObj *pNode = new CEffectCashObj(FindFileData.cFileName);
|
||||
|
||||
ulTmp = CheckHashIndex(FindFileData.cFileName);
|
||||
|
||||
ISDATAITER itr = m_HashTable.find(ulTmp);
|
||||
|
||||
if(itr == m_HashTable.end())
|
||||
{
|
||||
|
||||
m_HashTable.insert(DATACASHOBJ(ulTmp,pNode));
|
||||
m_iCashNum++;
|
||||
}
|
||||
else
|
||||
{// map 안에 똑같은 Hash Index 를 가지는 요소 존재
|
||||
((*itr).second)->m_pNext.push_back(pNode);
|
||||
((*itr).second)->m_iNext++;
|
||||
}
|
||||
if(!FindNextFile(hFind,&FindFileData))
|
||||
break;
|
||||
}
|
||||
FindClose(hFind);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
void *CEffectCasher::GetCashData(const char *strName)
|
||||
{
|
||||
unsigned long ulTmp = CheckHashIndex(strName);
|
||||
ISDATAITER itr = m_HashTable.find(ulTmp);
|
||||
|
||||
if(itr == m_HashTable.end())
|
||||
return NULL;
|
||||
|
||||
if((*itr).second != NULL) {
|
||||
if(!strcmp(((CEffectCashObj *)((*itr).second))->m_pData->m_FileName,strName))
|
||||
return ((CEffectCashObj *)((*itr).second))->m_pData;
|
||||
else {
|
||||
for(int i=0;i < ((*itr).second)->m_iNext; i++) {
|
||||
if(!strcmp(((CEffectCashObj *)(((*itr).second)->m_pNext[i]))->m_pData->m_FileName,strName))
|
||||
return ((CEffectCashObj *)(((*itr).second)->m_pNext[i]))->m_pData;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
// Hash Index Check( 문자열 )
|
||||
unsigned long CEffectCasher::CheckHashIndex(const char *strFileName)
|
||||
{
|
||||
unsigned long ulHashId = 0;
|
||||
|
||||
int iLength = strlen(strFileName);
|
||||
|
||||
for(int i=0;i < iLength; i++) {
|
||||
ulHashId += (( i + 1) * strFileName[i]);
|
||||
}
|
||||
return ulHashId;
|
||||
|
||||
}
|
||||
42
GameTools/Effect/EffectCasher.h
Normal file
42
GameTools/Effect/EffectCasher.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// EffectCasher.h: interface for the CEffectCasher class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_EFFECTCASHER_H__D6702665_FFC9_4B8C_B303_40C01D6B80DB__INCLUDED_)
|
||||
#define AFX_EFFECTCASHER_H__D6702665_FFC9_4B8C_B303_40C01D6B80DB__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include "DataCasher.h"
|
||||
#include "CEffScript.h"
|
||||
|
||||
|
||||
|
||||
class CEffectCashObj : public CDataObj
|
||||
{
|
||||
public:
|
||||
CEffectCashObj();
|
||||
CEffectCashObj(const char *strName);
|
||||
bool EffectLoad(const char *strName);
|
||||
|
||||
virtual ~CEffectCashObj();
|
||||
CEffScript *m_pData;
|
||||
|
||||
|
||||
};
|
||||
class CEffectCasher : public CDataCasher
|
||||
{
|
||||
public:
|
||||
CEffectCasher();
|
||||
virtual ~CEffectCasher();
|
||||
virtual bool LoadCashData(const char *strPath);
|
||||
virtual void *GetCashData(const char *strName);
|
||||
virtual bool BuildHashTable(const char *strPath);
|
||||
|
||||
unsigned long CheckHashIndex(const char *strFileName);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_EFFECTCASHER_H__D6702665_FFC9_4B8C_B303_40C01D6B80DB__INCLUDED_)
|
||||
160
GameTools/Effect/Key.h
Normal file
160
GameTools/Effect/Key.h
Normal file
@@ -0,0 +1,160 @@
|
||||
#if !defined(KEY_H)
|
||||
#define KEY_H
|
||||
|
||||
#pragma warning(disable:4786) // don't warn about browse name overflow.
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <vector.h>
|
||||
#include <vertex.h>
|
||||
#include <quaternion.h>
|
||||
#include "z3dmath.h"
|
||||
|
||||
typedef std::map< unsigned long, vector3, std::less<unsigned long> > VectorKeyList;
|
||||
typedef std::map< unsigned long, quaternion, std::less<unsigned long> > QuaternionKeyList;
|
||||
typedef std::map< unsigned long, float, std::less<unsigned long> > FloatKeyList;
|
||||
typedef std::map< unsigned long, color, std::less<unsigned long> > ColorKeyList;
|
||||
|
||||
template <typename KeyList>
|
||||
class CKeyList
|
||||
{
|
||||
protected:
|
||||
KeyList m_lstKey;
|
||||
typename KeyList::iterator Lower, Upper;
|
||||
unsigned long dwLower, dwUpper;
|
||||
|
||||
public:
|
||||
CKeyList(void) { }
|
||||
~CKeyList(void) { }
|
||||
|
||||
typename KeyList::iterator Begin(void) { return m_lstKey.begin(); }
|
||||
typename KeyList::iterator End(void) { return m_lstKey.end(); }
|
||||
template <typename NewData> void SetKey(unsigned long dwFrame, NewData &Data) { m_lstKey[dwFrame] = Data; }
|
||||
template <typename NewData> BOOL Find(unsigned long dwFrame, NewData &Data)
|
||||
{
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = m_lstKey.find(dwFrame);
|
||||
if(Lower == m_lstKey.end())
|
||||
{
|
||||
Lower = m_lstKey.lower_bound(dwFrame);
|
||||
if(Lower != m_lstKey.begin()) { Lower--; }
|
||||
Data = ((*Lower).second);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
Data = ((*Lower).second);
|
||||
return TRUE;
|
||||
}
|
||||
BOOL Find(unsigned long dwFrame)
|
||||
{
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = m_lstKey.find(dwFrame);
|
||||
if(Lower == m_lstKey.end()) return FALSE; else return TRUE;
|
||||
}
|
||||
void Erase(unsigned long dwFrame)
|
||||
{
|
||||
Lower = m_lstKey.find(dwFrame);
|
||||
m_lstKey.erase(Lower);
|
||||
}
|
||||
template <typename DataType> void Load(FILE *fp, DataType &Data)
|
||||
{
|
||||
unsigned short frame;
|
||||
dwLower = 0;
|
||||
fread(&dwLower, 2, 1, fp);
|
||||
for(dwUpper = 0; dwUpper < dwLower; dwUpper++)
|
||||
{
|
||||
fread(&frame, 2, 1, fp);
|
||||
fread(&Data, sizeof(Data), 1, fp);
|
||||
m_lstKey[frame] = Data;
|
||||
}
|
||||
}
|
||||
void Save(FILE *fp)
|
||||
{
|
||||
dwLower = m_lstKey.size();
|
||||
fwrite(&dwLower, 2, 1, fp);
|
||||
for(Lower = m_lstKey.begin(); Lower != m_lstKey.end(); Lower++)
|
||||
{
|
||||
fwrite(&((*Lower).first), 2, 1, fp);
|
||||
fwrite(&((*Lower).second), sizeof((*Lower).second), 1, fp);
|
||||
}
|
||||
}
|
||||
BOOL InterpolationQ(float fFrame, quaternion &Data)
|
||||
{
|
||||
quaternion rdLower, rdUpper;
|
||||
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = Upper = m_lstKey.lower_bound(ceilf(fFrame));
|
||||
if(Upper == m_lstKey.begin()) { Upper = Lower; Upper++; } else { Lower--; }
|
||||
|
||||
dwLower = (*Lower).first;
|
||||
rdLower = (*Lower).second;
|
||||
if(Upper != m_lstKey.end())
|
||||
{
|
||||
dwUpper = (*Upper).first;
|
||||
rdUpper = (*Upper).second;
|
||||
z3d::QuaternionSlerp(Data, rdLower, rdUpper, 1.0f / (dwUpper - dwLower) * (fFrame - dwLower));
|
||||
} else
|
||||
{
|
||||
Data = rdLower;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
BOOL InterpolationC(float fFrame, color &Data)
|
||||
{
|
||||
color rdLower, rdUpper;
|
||||
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = Upper = m_lstKey.lower_bound(ceilf(fFrame));
|
||||
if(Upper == m_lstKey.begin()) { Upper = Lower; Upper++; } else { Lower--; }
|
||||
|
||||
dwLower = (*Lower).first;
|
||||
rdLower = (*Lower).second;
|
||||
if(Upper != m_lstKey.end())
|
||||
{
|
||||
dwUpper = (*Upper).first;
|
||||
rdUpper = (*Upper).second;
|
||||
Data = color::Interpolation(rdLower, rdUpper, 1.0f / (dwUpper - dwLower) * (fFrame - dwLower));
|
||||
} else
|
||||
{
|
||||
Data = rdLower;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
template <typename RetData> BOOL Interpolation(float fFrame, RetData &Data)
|
||||
{
|
||||
RetData rdLower, rdUpper;
|
||||
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = Upper = m_lstKey.lower_bound(ceilf(fFrame));
|
||||
if(Upper == m_lstKey.begin()) { Upper = Lower; Upper++; } else { Lower--; }
|
||||
|
||||
dwLower = (*Lower).first;
|
||||
rdLower = (*Lower).second;
|
||||
if(Upper != m_lstKey.end())
|
||||
{
|
||||
dwUpper = (*Upper).first;
|
||||
rdUpper = (*Upper).second;
|
||||
Data = (((rdUpper - rdLower) / (dwUpper - dwLower)) * (fFrame - dwLower)) + rdLower;
|
||||
} else
|
||||
{
|
||||
Data = rdLower;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename KeyList, class Data>
|
||||
inline void SetKey(unsigned long dwFrame, KeyList &lstKey, Data NewData)
|
||||
{
|
||||
lstKey.SetKey(dwFrame, NewData);
|
||||
}
|
||||
|
||||
#endif // !defined(KEY_H)
|
||||
325
GameTools/Effect/MemoryPool.cpp
Normal file
325
GameTools/Effect/MemoryPool.cpp
Normal file
@@ -0,0 +1,325 @@
|
||||
#include "MemoryPool.h"
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <new>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
const char* const CFixedPool::ms_strErrLogFileName = "FixedMemoryPool_ErrLog.txt";
|
||||
|
||||
|
||||
struct CFixedPool::ChunkNode
|
||||
{
|
||||
ChunkNode* m_pNext;
|
||||
};
|
||||
|
||||
struct CFixedPool::AllocateInfo
|
||||
{
|
||||
AllocateInfo* m_pNext;
|
||||
|
||||
static const int ms_nPaddingSize;
|
||||
static const char* ms_strAllocatedPadding;
|
||||
static const char* ms_strDeallocatedPadding;
|
||||
static const char* ms_strNotUsedPadding;
|
||||
};
|
||||
|
||||
const char* CFixedPool::AllocateInfo::ms_strAllocatedPadding = "Aloc";
|
||||
const char* CFixedPool::AllocateInfo::ms_strDeallocatedPadding = "Free";
|
||||
const char* CFixedPool::AllocateInfo::ms_strNotUsedPadding = "Nuse";
|
||||
|
||||
|
||||
#ifdef MEMPOOL_DBGMODE
|
||||
const int CFixedPool::AllocateInfo::ms_nPaddingSize = 4;
|
||||
#else
|
||||
const int CFixedPool::AllocateInfo::ms_nPaddingSize = 0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
DEFINE_ALLOCATOR(CFixedPool)
|
||||
{
|
||||
if(nSize != m_nOriginalSize)
|
||||
{
|
||||
return operator new(nSize);
|
||||
}
|
||||
|
||||
m_PoolLock.Lock();
|
||||
|
||||
if(NULL == m_pNodeHead)
|
||||
{
|
||||
if(!AllocateChunks())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
AllocateInfo* pNode = m_pNodeHead;
|
||||
m_pNodeHead = m_pNodeHead->m_pNext;
|
||||
++m_nTotalInUse;
|
||||
|
||||
m_PoolLock.Unlock();
|
||||
|
||||
char* pResult = reinterpret_cast<char*>(pNode);
|
||||
|
||||
#ifdef MEMPOOL_DBGMODE
|
||||
memcpy(pResult + m_nPerAllocateSize - AllocateInfo::ms_nPaddingSize,
|
||||
AllocateInfo::ms_strAllocatedPadding, AllocateInfo::ms_nPaddingSize);
|
||||
#endif
|
||||
|
||||
return pResult + sizeof(AllocateInfo);
|
||||
}
|
||||
|
||||
|
||||
DEFINE_DEALLOCATOR(CFixedPool)
|
||||
{
|
||||
if(NULL == pDelete)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(nSize != m_nOriginalSize)
|
||||
{
|
||||
operator delete(pDelete);
|
||||
return;
|
||||
}
|
||||
|
||||
char* pszDelete = reinterpret_cast<char*>(pDelete) - sizeof(AllocateInfo);
|
||||
AllocateInfo* pNode = reinterpret_cast<AllocateInfo*>(pszDelete);
|
||||
|
||||
#ifdef MEMPOOL_DBGMODE
|
||||
|
||||
// 버퍼 오버플로우 혹은 메모리를 여러번 해제.
|
||||
const char* pszPadding = pszDelete + m_nPerAllocateSize - AllocateInfo::ms_nPaddingSize;
|
||||
if(0 != memcmp(pszPadding, AllocateInfo::ms_strAllocatedPadding, AllocateInfo::ms_nPaddingSize))
|
||||
{
|
||||
LogBufferOverflow(pszPadding);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
m_PoolLock.Lock();
|
||||
|
||||
pNode->m_pNext = m_pNodeHead;
|
||||
m_pNodeHead = pNode;
|
||||
--m_nTotalInUse;
|
||||
|
||||
m_PoolLock.Unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CFixedPool::AllocateChunks()
|
||||
{
|
||||
// Allocation and make list
|
||||
ChunkNode* pChunkNode = reinterpret_cast<ChunkNode*>(
|
||||
::operator new(sizeof(ChunkNode) + m_nPerAllocateSize * m_nPerAllocateNum));
|
||||
|
||||
if(0 == pChunkNode)
|
||||
{
|
||||
// Chunk 메모리 할당 에러.
|
||||
return false;
|
||||
}
|
||||
|
||||
pChunkNode->m_pNext = m_pChunkHead;
|
||||
m_pChunkHead = pChunkNode;
|
||||
m_pNodeHead = reinterpret_cast<AllocateInfo*>(m_pChunkHead + 1);
|
||||
|
||||
m_nTotalAllocated += m_nPerAllocateNum; // 전체 개수 증가.
|
||||
|
||||
char* pMakeList = reinterpret_cast<char*>(m_pNodeHead);
|
||||
size_t nAllocated = m_nPerAllocateNum - 1;
|
||||
|
||||
while(0 < nAllocated--)
|
||||
{
|
||||
reinterpret_cast<AllocateInfo*>(pMakeList)->m_pNext =
|
||||
reinterpret_cast<AllocateInfo*>(pMakeList + m_nPerAllocateSize);
|
||||
pMakeList += m_nPerAllocateSize;
|
||||
|
||||
#ifdef MEMPOOL_DBGMODE
|
||||
// 메모리가 사용되지 않았음을 나타내는 패딩을 넣음.
|
||||
memcpy(pMakeList - AllocateInfo::ms_nPaddingSize,
|
||||
AllocateInfo::ms_strNotUsedPadding, AllocateInfo::ms_nPaddingSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
reinterpret_cast<AllocateInfo*>(pMakeList)->m_pNext = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CFixedPool::CFixedPool()
|
||||
: m_pChunkHead(NULL), m_pNodeHead(NULL),
|
||||
m_nOriginalSize(0), m_nPerAllocateNum(0), m_nPerAllocateSize(0),
|
||||
m_nTotalAllocated(0), m_nTotalInUse(0)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
CFixedPool::CFixedPool(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen)
|
||||
: m_pChunkHead(NULL), m_pNodeHead(NULL),
|
||||
m_nOriginalSize(0), m_nPerAllocateNum(0), m_nPerAllocateSize(0),
|
||||
m_nTotalAllocated(0), m_nTotalInUse(0)
|
||||
{
|
||||
Initialize(nPerAllocateSize, nPerAllocateNum, strMaxPoolName, nNameLen);
|
||||
}
|
||||
|
||||
|
||||
CFixedPool::~CFixedPool()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool CFixedPool::Initialize(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_nOriginalSize = nPerAllocateSize;
|
||||
m_nPerAllocateNum = nPerAllocateNum;
|
||||
m_nPerAllocateSize = nPerAllocateSize + GetLeastAllocateSize();
|
||||
|
||||
const size_t nLastPos = min(nNameLen, MAX_POOL_NAME - 1);
|
||||
strncpy(m_pszPoolName, strMaxPoolName, nLastPos);
|
||||
m_pszPoolName[nLastPos] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CFixedPool::LogBufferOverflow(const char* lpBuffer)
|
||||
{
|
||||
FILE* pLogFile = fopen(ms_strErrLogFileName, "ab");
|
||||
if(NULL != pLogFile)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
__try
|
||||
{
|
||||
fprintf(pLogFile, "\n[%d-%d-%d %d:%d:%d] %s 메모리 풀에서 버퍼 오버플로우 또는, "
|
||||
"메모리 해제가 여러 번 있었습니다. PerAllocateSize = %d(0x%08x)\n<",
|
||||
sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, m_pszPoolName,
|
||||
m_nPerAllocateSize, m_nPerAllocateSize);
|
||||
|
||||
fwrite(lpBuffer, m_nPerAllocateSize * 2, 1, pLogFile);
|
||||
}
|
||||
__finally
|
||||
{
|
||||
fprintf(pLogFile, ">");
|
||||
fclose(pLogFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CFixedPool::Destroy()
|
||||
{
|
||||
PoolLock::Syncronize sync(m_PoolLock);
|
||||
|
||||
if(0 != m_nTotalInUse)
|
||||
{
|
||||
// 메모리 관련 로그를 남긴다. (Chunk를 전부 뒤져서 해제가 되지 않은 메모리를 찾아낸다.)
|
||||
/*FILE* pLogFile = fopen(ms_strErrLogFileName, "ab");
|
||||
if(NULL != pLogFile)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
fprintf(pLogFile, "[%d-%d-%d %d:%d:%d] %s 메모리 풀에서 %d개가 해제되지 않았습니다. 로그로 기록합니다.\r\n",
|
||||
sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond,
|
||||
m_pszPoolName, m_nTotalInUse);
|
||||
|
||||
fclose(pLogFile);
|
||||
}*/
|
||||
}
|
||||
|
||||
for(ChunkNode* pChunkNode = m_pChunkHead; NULL != pChunkNode;)
|
||||
{
|
||||
ChunkNode* pDelNode = pChunkNode;
|
||||
pChunkNode = pChunkNode->m_pNext;
|
||||
delete pDelNode;
|
||||
}
|
||||
|
||||
m_nTotalAllocated = m_nTotalInUse = 0;
|
||||
m_pChunkHead = NULL;
|
||||
m_pNodeHead = NULL;
|
||||
}
|
||||
|
||||
|
||||
size_t CFixedPool::GetLeastAllocateSize()
|
||||
{
|
||||
return sizeof(AllocateInfo) + AllocateInfo::ms_nPaddingSize;
|
||||
}
|
||||
|
||||
const char* CFixedPool::GetErrFileName()
|
||||
{
|
||||
return ms_strErrLogFileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CFixedPoolTest::DoTest()
|
||||
{
|
||||
const char* const strErrLogFileName = CFixedPool::GetErrFileName();
|
||||
|
||||
//printf("%s Test Started.\n", __FUNCTION__);
|
||||
remove(strErrLogFileName);
|
||||
|
||||
CFixedPool pool;
|
||||
|
||||
const char* pName = "테스트풀";
|
||||
|
||||
const int nSize = 10;
|
||||
const int nPerAllocate = 100;
|
||||
|
||||
const int MAX_ALLOC = nPerAllocate * 10;
|
||||
|
||||
void* pAlloc[MAX_ALLOC];
|
||||
pool.Initialize(nSize, nPerAllocate, pName, strlen(pName));
|
||||
|
||||
|
||||
for(int i = 0; i < MAX_ALLOC; ++i)
|
||||
{
|
||||
pAlloc[i] = pool.ALLOC(nSize);
|
||||
}
|
||||
|
||||
for(i = 0; i < MAX_ALLOC; ++i)
|
||||
{
|
||||
pool.FREE(pAlloc[i], nSize);
|
||||
}
|
||||
|
||||
pool.Destroy();
|
||||
|
||||
FILE* pFile = fopen(strErrLogFileName, "rb");
|
||||
if(NULL == pFile)
|
||||
{
|
||||
printf("\tTest Successed!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(pFile);
|
||||
|
||||
#ifdef WIN32
|
||||
char szPath[MAX_PATH];
|
||||
char szFileNameWithPath[MAX_PATH];
|
||||
|
||||
UINT nResult = GetWindowsDirectory(szPath, MAX_PATH);
|
||||
if(0 != nResult && nResult <= MAX_PATH)
|
||||
{
|
||||
_snprintf(szFileNameWithPath, MAX_PATH, "%s\\NotePad.exe %s", szPath, strErrLogFileName);
|
||||
WinExec(szFileNameWithPath, SW_SHOW);
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("\tMemory Leak or Curruption Detected!\n\tPlease See %s File\n", strErrLogFileName);
|
||||
}
|
||||
|
||||
//printf("%s Test Completed.\n\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
93
GameTools/Effect/MemoryPool.h
Normal file
93
GameTools/Effect/MemoryPool.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _MEMORYPOOL_H_
|
||||
#define _MEMORYPOOL_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
|
||||
#define MEMPOOL_DBGMODE
|
||||
|
||||
#define ALLOC(nSize) Allocate((nSize))
|
||||
#define FREE(pDelete, nSize) Deallocate((pDelete), (nSize))
|
||||
|
||||
#define DECLARE_ALLOCATOR void* Allocate(size_t nSize)
|
||||
#define DECLARE_DEALLOCATOR void Deallocate(void* pDelete, size_t nSize)
|
||||
|
||||
#define DEFINE_ALLOCATOR(className) void* className::Allocate(size_t nSize)
|
||||
#define DEFINE_DEALLOCATOR(className) void className::Deallocate(void* pDelete, size_t nSize)
|
||||
|
||||
|
||||
class CNullLock
|
||||
{
|
||||
public:
|
||||
|
||||
class Syncronize
|
||||
{
|
||||
public:
|
||||
Syncronize(CNullLock& nullLock) { }
|
||||
};
|
||||
|
||||
void Lock() { }
|
||||
void Unlock() { }
|
||||
};
|
||||
|
||||
class CFixedPool
|
||||
{
|
||||
public:
|
||||
|
||||
enum { MAX_POOL_NAME = 32 };
|
||||
|
||||
CFixedPool();
|
||||
CFixedPool(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen);
|
||||
|
||||
~CFixedPool();
|
||||
|
||||
bool Initialize(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen);
|
||||
|
||||
void Destroy();
|
||||
unsigned long GetTotalUse() const { return static_cast<unsigned long>(m_nTotalInUse); }
|
||||
|
||||
static size_t GetLeastAllocateSize();
|
||||
static const char* GetErrFileName();
|
||||
|
||||
size_t m_nTotalInUse;
|
||||
|
||||
DECLARE_ALLOCATOR;
|
||||
DECLARE_DEALLOCATOR;
|
||||
|
||||
private:
|
||||
|
||||
bool AllocateChunks();
|
||||
void LogBufferOverflow(const char* lpBuffer);
|
||||
|
||||
typedef CNullLock PoolLock;
|
||||
struct ChunkNode;
|
||||
struct AllocateInfo;
|
||||
|
||||
PoolLock m_PoolLock;
|
||||
|
||||
ChunkNode* m_pChunkHead;
|
||||
AllocateInfo* m_pNodeHead;
|
||||
|
||||
size_t m_nOriginalSize;
|
||||
size_t m_nPerAllocateSize;
|
||||
size_t m_nPerAllocateNum;
|
||||
|
||||
size_t m_nTotalAllocated;
|
||||
|
||||
|
||||
char m_pszPoolName[MAX_POOL_NAME];
|
||||
|
||||
static const char* const ms_strErrLogFileName;
|
||||
};
|
||||
|
||||
|
||||
class CFixedPoolTest
|
||||
{
|
||||
public:
|
||||
void DoTest();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
465
GameTools/Effect/X3DEffect.cpp
Normal file
465
GameTools/Effect/X3DEffect.cpp
Normal file
@@ -0,0 +1,465 @@
|
||||
// X3DEffect.cpp: implementation of the CX3DEffect class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectParticle.h"
|
||||
#include "X3DEffectBillboard.h"
|
||||
#include "X3DEffectCylinder.h"
|
||||
#include "X3DEffectPlane.h"
|
||||
#include "X3DEffectSphere.h"
|
||||
#include "X3DEffectMesh.h"
|
||||
#include "EffDebugLog.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
//#define __EFF_WCREATOR__
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffect::CX3DEffect()
|
||||
{
|
||||
m_dwMinFrame = 0.0f;
|
||||
m_fFrame = 0.0f;
|
||||
m_fBeforeFrame = 0.0f;
|
||||
m_bImportCenter = FALSE;
|
||||
m_lpCenter = NULL;
|
||||
m_bImportAxis = FALSE;
|
||||
m_lpAxis = NULL;
|
||||
m_dwKindMove = 0;
|
||||
m_dwCount = 0;
|
||||
m_SectorX = -1;
|
||||
m_SectorY = -1;
|
||||
map_effect = false;
|
||||
m_StartEffect = false;
|
||||
m_dwFrameTick = 33;
|
||||
m_MoveState = false;
|
||||
m_Mine = true;
|
||||
m_GemScale[0] = m_GemScale[1] = m_GemScale[2] = 1.0f;
|
||||
m_bLight = false;
|
||||
|
||||
}
|
||||
|
||||
CX3DEffect::~CX3DEffect()
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
delete pEffect;
|
||||
pEffect = NULL;
|
||||
}
|
||||
|
||||
m_lstEffect.clear();
|
||||
|
||||
if(!m_bImportCenter) if(m_lpCenter) { delete m_lpCenter; m_lpCenter = NULL; }
|
||||
if(m_lpAxis) { delete m_lpAxis; m_lpAxis = NULL; }
|
||||
}
|
||||
void CX3DEffect::SetScale(float x,float y,float z) {
|
||||
|
||||
m_GemScale[0] = x;m_GemScale[1] = y;m_GemScale[2] = z;
|
||||
if(m_lstEffect.size() > 0) {
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
if(pEffect != NULL)
|
||||
pEffect->SetEffectScale(x,y,z);
|
||||
}
|
||||
}
|
||||
}
|
||||
unsigned long CX3DEffect::AddEffect(CX3DEffectBase *pNewEffect)
|
||||
{
|
||||
pNewEffect->SetLocalDevice(m_lpD3DDevice);
|
||||
pNewEffect->SetLocalView(m_lpViewMatrix);
|
||||
pNewEffect->SetLocalEffect((void *)this);
|
||||
pNewEffect->SetLocalCenter(m_lpCenter);
|
||||
pNewEffect->SetLocalAxis(m_lpAxis);
|
||||
|
||||
m_lstEffect.push_back(pNewEffect);
|
||||
|
||||
return m_lstEffect.size() - 1;
|
||||
}
|
||||
|
||||
BOOL CX3DEffect::Interpolation(unsigned long dwTick, float fFrame)
|
||||
{
|
||||
|
||||
if((m_fFrame > m_dwMaxFrame) && !m_bLoop)
|
||||
return FALSE;
|
||||
|
||||
switch(m_dwKindMove)
|
||||
{
|
||||
case 1:
|
||||
if(m_dwCount == 30)
|
||||
return FALSE;
|
||||
m_lpCenter->x += m_vecPower.x;
|
||||
m_lpCenter->y += m_vecPower.y;
|
||||
m_lpCenter->z += m_vecPower.z;
|
||||
m_dwCount++;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
if(-1.0f == fFrame)
|
||||
{
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
|
||||
if(!pEffect->Interpolation(m_fFrame))
|
||||
return FALSE;
|
||||
}
|
||||
m_fBeforeFrame = m_fFrame;
|
||||
m_fFrame += ((dwTick / m_dwFrameTick) * m_fIncFrame);
|
||||
if(m_bLoop && (m_fFrame >= m_dwMaxFrame)) {
|
||||
m_fFrame -= m_dwMaxFrame;
|
||||
m_fFrame += m_dwMinFrame;
|
||||
}
|
||||
} else
|
||||
{
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
|
||||
if(!pEffect->Interpolation(fFrame))
|
||||
return FALSE;
|
||||
}
|
||||
m_fBeforeFrame = m_fFrame;
|
||||
|
||||
m_fFrame = fFrame;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
void CX3DEffect::SetVisibility(bool bVis)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetVisibility(bVis);
|
||||
}
|
||||
|
||||
}
|
||||
void CX3DEffect::Render(void)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
if(m_StartEffect) {
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->Render();
|
||||
}
|
||||
}
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
}
|
||||
|
||||
CX3DEffectBase *CX3DEffect::GetEffect(unsigned long dwEffectNumber)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
unsigned long dwEffectCount = 0;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
if(dwEffectCount == dwEffectNumber) { return (CX3DEffectBase *)(*it); }
|
||||
dwEffectCount++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL CX3DEffect::DeleteEffect(unsigned long dwEffectNumber)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
unsigned long dwEffectCount = 0;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
if(dwEffectCount == dwEffectNumber)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
m_lstEffect.erase(it);
|
||||
delete pEffect;
|
||||
pEffect = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
dwEffectCount++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
void CX3DEffect::SetAxis(quaternion *pAxis) {
|
||||
m_bImportAxis = TRUE;
|
||||
if(!m_lpAxis) m_lpAxis = new quaternion;
|
||||
|
||||
m_lpAxis->x = pAxis->x;
|
||||
m_lpAxis->y = pAxis->y;
|
||||
m_lpAxis->z = pAxis->z;
|
||||
m_lpAxis->w = pAxis->w;
|
||||
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetAxis(*pAxis);
|
||||
}
|
||||
}
|
||||
void CX3DEffect::SetAxis(float fAxisX, float fAxisY, float fAxisZ){
|
||||
|
||||
m_bImportAxis = TRUE;
|
||||
|
||||
if(!m_lpAxis) m_lpAxis = new quaternion;
|
||||
m_lpAxis->Identity();
|
||||
m_lpAxis->Pitch(FLOAT_DEG(fAxisX - (((unsigned long)(fAxisX / 360)) * 360.0f)));
|
||||
m_lpAxis->Yaw(FLOAT_DEG(fAxisY - (((unsigned long)(fAxisY / 360)) * 360.0f)));
|
||||
m_lpAxis->Roll(FLOAT_DEG(fAxisZ - (((unsigned long)(fAxisZ / 360)) * 360.0f)));
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetAxis(*m_lpAxis);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CX3DEffect::SetEffectSetting(void)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetLocalDevice(m_lpD3DDevice);
|
||||
pEffect->SetLocalView(m_lpViewMatrix);
|
||||
}
|
||||
}
|
||||
void CX3DEffect::SetMine(bool b) {
|
||||
m_Mine = b;
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetMine(m_Mine);
|
||||
}
|
||||
}
|
||||
void CX3DEffect::Load(const char *strFilePath, const char *strFileName,bool bLoad)
|
||||
{
|
||||
FILE *fp;
|
||||
char strFile[MAX_PATH];
|
||||
strcpy(strFile, strFilePath);
|
||||
strcat(strFile, strFileName);
|
||||
fp = fopen(strFile, "rb");
|
||||
if(!fp) {
|
||||
#ifdef __EFF_WCREATOR__
|
||||
WriteDebug(strFile); // File Converting용 Log File Write 루틴
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
CX3DEffectBase *lpEffect;
|
||||
unsigned short Size, Kind;
|
||||
unsigned long i, dwStartFrame, dwEndFrame;
|
||||
unsigned char len;
|
||||
char strTextureFile[MAX_PATH], strTemp[MAX_PATH];
|
||||
|
||||
fread(&m_dwMaxFrame, 4, 1, fp);
|
||||
fread(&m_dwFrameTick, 4, 1, fp);
|
||||
fread(&m_fIncFrame, 4, 1, fp);
|
||||
fread(&Size, 2, 1, fp);
|
||||
for(i = 0; i < Size; i++)
|
||||
{
|
||||
bool bParticle = false;
|
||||
|
||||
fread(&Kind, 2, 1, fp);
|
||||
|
||||
switch(Kind)
|
||||
{
|
||||
case EFFECT_PARTICLE:
|
||||
lpEffect = new CX3DEffectParticle;
|
||||
bParticle = true;
|
||||
break;
|
||||
|
||||
case EFFECT_BILLBOARD:
|
||||
lpEffect = new CX3DEffectBillboard;
|
||||
break;
|
||||
|
||||
case EFFECT_CYLINDER:
|
||||
lpEffect = new CX3DEffectCylinder;
|
||||
break;
|
||||
|
||||
case EFFECT_PLANE:
|
||||
lpEffect = new CX3DEffectPlane;
|
||||
break;
|
||||
|
||||
case EFFECT_SPHERE:
|
||||
lpEffect = new CX3DEffectSphere;
|
||||
break;
|
||||
|
||||
case EFFECT_MESH:
|
||||
lpEffect = new CX3DEffectMesh;
|
||||
break;
|
||||
|
||||
default:
|
||||
MessageBox(NULL, "에러", "에러", MB_OK);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
fread(&len, 1, 1, fp);
|
||||
if(len)
|
||||
{
|
||||
char *t_ptr = NULL;
|
||||
fread(strTemp, len, 1, fp);
|
||||
t_ptr = strrchr(strTemp,'\\');
|
||||
if(t_ptr != NULL) {
|
||||
t_ptr++;
|
||||
strcpy(strTextureFile,t_ptr);
|
||||
}
|
||||
else {
|
||||
strcpy(strTextureFile,strTemp);
|
||||
}
|
||||
//strcpy(strTextureFile, strFilePath);
|
||||
//strcat(strTextureFile, strTemp);
|
||||
|
||||
} else
|
||||
{
|
||||
strcpy(strTextureFile, "");
|
||||
}
|
||||
|
||||
AddEffect(lpEffect);
|
||||
if(bLoad)
|
||||
if(strTextureFile) lpEffect->LoadTexture(strTextureFile);
|
||||
fread(&dwStartFrame, 4, 1, fp);
|
||||
fread(&dwEndFrame, 4, 1, fp);
|
||||
lpEffect->SetVisibility(bLoad);
|
||||
lpEffect->Create(dwStartFrame, dwEndFrame);
|
||||
lpEffect->SetEffectKind(Kind);
|
||||
lpEffect->SetEffectScale(m_GemScale[0],m_GemScale[1],m_GemScale[2]);
|
||||
lpEffect->SetLight(m_bLight);
|
||||
lpEffect->Load(fp, strFilePath);
|
||||
if(bLoad || bParticle)
|
||||
lpEffect->CreateBuffer();
|
||||
// 스케일 세팅
|
||||
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void CX3DEffect::Save(const char *strFilePath, const char *strFileName)
|
||||
{
|
||||
FILE *fp;
|
||||
char strFile[MAX_PATH];
|
||||
strcpy(strFile, strFilePath);
|
||||
strcat(strFile, strFileName);
|
||||
fp = fopen(strFile, "wb");
|
||||
if(!fp) return;
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
unsigned short Size = m_lstEffect.size(), Kind;
|
||||
unsigned char len;
|
||||
unsigned long StartFrame, EndFrame;
|
||||
|
||||
fwrite(&m_dwMaxFrame, 4, 1, fp);
|
||||
fwrite(&m_dwFrameTick, 4, 1, fp);
|
||||
fwrite(&m_fIncFrame, 4, 1, fp);
|
||||
fwrite(&Size, 2, 1, fp);
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
|
||||
Kind = (unsigned short)pEffect->GetEffectKind();
|
||||
StartFrame = pEffect->GetStartFrame();
|
||||
EndFrame = pEffect->GetEndFrame();
|
||||
len = strlen(pEffect->GetTextureFileName()) + 1;
|
||||
|
||||
fwrite(&Kind, 2, 1, fp);
|
||||
if(len == 1)
|
||||
{
|
||||
len = 0;
|
||||
fwrite(&len, 1, 1, fp);
|
||||
} else
|
||||
{
|
||||
fwrite(&len, 1, 1, fp);
|
||||
fwrite(pEffect->GetTextureFileName(), len, 1, fp);
|
||||
}
|
||||
fwrite(&StartFrame, 4, 1, fp);
|
||||
fwrite(&EndFrame, 4, 1, fp);
|
||||
|
||||
pEffect->Save(fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void CX3DEffect::SetDirectMove(vector3 &vecDest, vector3 &vecPower, vector3 &vecEForce)
|
||||
{
|
||||
m_dwKindMove = 1;
|
||||
m_vecDest = vecDest;
|
||||
m_vecPower = (m_vecDest - *m_lpCenter) / 30.0f;
|
||||
m_vecEForce = vecEForce;
|
||||
}
|
||||
void CX3DEffect::SetLoop(BOOL bLoop) {
|
||||
m_bLoop = bLoop;
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetGemClearBuffer(!bLoop); // clear buffer setting
|
||||
}
|
||||
|
||||
}
|
||||
void CX3DEffect::SetWorldEffect(bool t) {
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetWorldEffect(t);
|
||||
}
|
||||
|
||||
}
|
||||
void CX3DEffect::SetStopParticle(int t) {
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetStopParticle(t);
|
||||
}
|
||||
|
||||
}
|
||||
144
GameTools/Effect/X3DEffect.h
Normal file
144
GameTools/Effect/X3DEffect.h
Normal file
@@ -0,0 +1,144 @@
|
||||
// X3DEffect.h: interface for the CX3DEffect class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECT_H__36D22C0B_3861_4B57_B539_4E4BFAD198C1__INCLUDED_)
|
||||
#define AFX_X3DEFFECT_H__36D22C0B_3861_4B57_B539_4E4BFAD198C1__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#pragma warning(disable:4786) // don't warn about browse name overflow.
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "z3dmath.h"
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CX3DEffect
|
||||
{
|
||||
protected:
|
||||
list<CX3DEffectBase *> m_lstEffect;
|
||||
LPDIRECT3DDEVICE8 m_lpD3DDevice;
|
||||
matrix *m_lpViewMatrix;
|
||||
|
||||
unsigned long m_dwFrameTick;
|
||||
float m_fFrame;
|
||||
float m_fBeforeFrame;
|
||||
|
||||
float m_fIncFrame;
|
||||
unsigned long m_dwMaxFrame;
|
||||
unsigned long m_dwMinFrame;
|
||||
// 이펙트 이동 중인지
|
||||
bool m_MoveState;
|
||||
|
||||
BOOL m_bLoop;
|
||||
unsigned long m_dwKindMove;
|
||||
vector3 m_vecDest;
|
||||
vector3 m_vecPower;
|
||||
vector3 m_vecEForce;
|
||||
unsigned long m_dwCount;
|
||||
unsigned long m_dwOldTick;
|
||||
|
||||
BOOL m_bImportCenter;
|
||||
vector3 *m_lpCenter;
|
||||
BOOL m_bImportAxis;
|
||||
quaternion *m_lpAxis;
|
||||
color m_lFlash;
|
||||
//scale value
|
||||
float m_GemScale[3];
|
||||
// effect가 시작 되었는지
|
||||
bool m_StartEffect;
|
||||
bool m_Mine;
|
||||
|
||||
CKeyList<ColorKeyList> m_lstFlash;
|
||||
bool m_bLight;
|
||||
|
||||
public:
|
||||
bool map_effect;
|
||||
int m_SectorX;
|
||||
int m_SectorY;
|
||||
|
||||
CX3DEffect();
|
||||
virtual ~CX3DEffect();
|
||||
void SetMine(bool b);
|
||||
|
||||
void SetCenter(vector3 *pCenter) { m_bImportCenter = TRUE; m_lpCenter = pCenter; }
|
||||
void SetCenter(float fX, float fY, float fZ)
|
||||
{
|
||||
m_bImportCenter = FALSE;
|
||||
if(!m_lpCenter) m_lpCenter = new vector3;
|
||||
m_lpCenter->x = fX;
|
||||
m_lpCenter->y = fY;
|
||||
m_lpCenter->z = fZ;
|
||||
}
|
||||
vector3 *GetCenter(void) { return m_lpCenter; }
|
||||
|
||||
void SetAxis(quaternion *pAxis);
|
||||
void SetAxis(float fAxisX, float fAxisY, float fAxisZ);
|
||||
|
||||
quaternion *GetAxis(void) { return m_lpAxis; }
|
||||
|
||||
|
||||
void SetFlash(unsigned long dwTick, color lColor)
|
||||
{
|
||||
SetKey(dwTick, m_lstFlash, lColor);
|
||||
}
|
||||
BOOL GetFlash(unsigned long dwTick, color &lColor)
|
||||
{
|
||||
return m_lstFlash.Find(dwTick, lColor);
|
||||
}
|
||||
void SetDevice(LPDIRECT3DDEVICE8 lpD3DDevice) { m_lpD3DDevice = lpD3DDevice; }
|
||||
LPDIRECT3DDEVICE8 GetDevice(void) { return m_lpD3DDevice; }
|
||||
void SetViewMatrix(matrix *pViewMatrix) { m_lpViewMatrix = pViewMatrix; }
|
||||
matrix *GetViewMatrix(void) { return m_lpViewMatrix; }
|
||||
|
||||
|
||||
void SetFrameTick(unsigned long dwFrameTick) { m_dwFrameTick = dwFrameTick; }
|
||||
unsigned long GetFrameTick(void) { return m_dwFrameTick; }
|
||||
void SetTick(unsigned long dwTick) { m_dwOldTick = dwTick; }
|
||||
unsigned long GetTick(void) { return m_dwOldTick; }
|
||||
void SetMaxFrame(unsigned long dwMaxFrame) { m_dwMaxFrame = dwMaxFrame - 1; }
|
||||
void SetMinFrame(unsigned long dwMinFrame) {m_dwMinFrame = dwMinFrame;}
|
||||
void SetStopParticle(int t);
|
||||
|
||||
unsigned long GetMaxFrame(void) { return m_dwMaxFrame; }
|
||||
void SetFrame(float fFrame) { m_fBeforeFrame = m_fFrame; m_fFrame = fFrame; }
|
||||
float GetBeforeFrame(void) { return m_fBeforeFrame;}
|
||||
float GetFrame(void) { return m_fFrame; }
|
||||
void SetIncFrame(float fIncFrame) { m_fIncFrame = fIncFrame; }
|
||||
float GetIncFrame(void) { return m_fIncFrame; }
|
||||
void SetLoop(BOOL bLoop);
|
||||
BOOL GetLoop(void) { return m_bLoop; }
|
||||
//effect 시작
|
||||
void SetEffectStart(bool t) {m_StartEffect = t;}
|
||||
bool GetEffectStart() { return m_StartEffect;}
|
||||
|
||||
unsigned long AddEffect(CX3DEffectBase *pNewEffect);
|
||||
CX3DEffectBase *GetEffect(unsigned long dwEffectNumber);
|
||||
BOOL DeleteEffect(unsigned long dwEffectNumber);
|
||||
void SetEffectSetting(void);
|
||||
|
||||
void SetFreezeMove(void) { m_dwKindMove = 0; }
|
||||
void SetDirectMove(vector3 &vecDest, vector3 &vecPower, vector3 &vecEForce);
|
||||
void SetMoveState(bool t){ m_MoveState = t;}
|
||||
bool GetMoveState() {return m_MoveState;}
|
||||
void SetScale(float x,float y,float z); //{m_GemScale[0] = x;m_GemScale[1] = y;m_GemScale[2] = z;}
|
||||
|
||||
void Render(void);
|
||||
void SetWorldEffect(bool t);
|
||||
void SetLight(bool b) { m_bLight = b;}
|
||||
|
||||
BOOL Interpolation(unsigned long dwTick, float fFrame = -1.0f);
|
||||
|
||||
void Load(const char *strFilePath, const char *strFileName,bool bLoad = true);
|
||||
void Save(const char *strFilePath, const char *strFileName);
|
||||
void SetStart(bool bStart) { m_StartEffect = bStart;}
|
||||
void SetVisibility(bool bVis);
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECT_H__36D22C0B_3861_4B57_B539_4E4BFAD198C1__INCLUDED_)
|
||||
51
GameTools/Effect/X3DEffectBase.cpp
Normal file
51
GameTools/Effect/X3DEffectBase.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// X3DEffectBase.cpp: implementation of the CX3DEffectBase class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectBase::CX3DEffectBase()
|
||||
{
|
||||
m_QuatSet = false;
|
||||
m_lpTexture = NULL;
|
||||
m_index=-1;
|
||||
m_Scale[0] = m_Scale[1] = m_Scale[2] = 1.0f;
|
||||
strcpy(m_strTextureFile, "");
|
||||
m_bWorldEffect = false;
|
||||
m_Mine = true;
|
||||
m_StopParticleFrame = -1;
|
||||
m_bLight = false;
|
||||
m_bClearBuffer = true;
|
||||
m_bVisibility = true;
|
||||
}
|
||||
|
||||
CX3DEffectBase::~CX3DEffectBase()
|
||||
{
|
||||
if(m_lpTexture) { delete m_lpTexture; m_lpTexture = NULL; }
|
||||
}
|
||||
void CX3DEffectBase::SetStopParticle(int t) {
|
||||
m_StopParticleFrame = t;
|
||||
}
|
||||
int CX3DEffectBase::GetStopParticle() {
|
||||
return m_StopParticleFrame;
|
||||
}
|
||||
void CX3DEffectBase::LoadTexture(const char *strFilename)
|
||||
{
|
||||
if(m_lpTexture) { delete m_lpTexture; m_lpTexture = NULL; }
|
||||
m_lpTexture = new CTexture();
|
||||
m_lpTexture->Init(m_lpD3DDevice);
|
||||
|
||||
m_lpTexture->SetPath(EFFECTTEXTUREPATH);
|
||||
m_lpTexture->Load((char *)strFilename);
|
||||
strcpy(m_strTextureFile, strFilename);
|
||||
}
|
||||
|
||||
void CX3DEffectBase::SetGemClearBuffer(bool b)
|
||||
{
|
||||
m_bClearBuffer = b;
|
||||
|
||||
}
|
||||
147
GameTools/Effect/X3DEffectBase.h
Normal file
147
GameTools/Effect/X3DEffectBase.h
Normal file
@@ -0,0 +1,147 @@
|
||||
// X3DEffectBase.h: interface for the CX3DEffectBase class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTBASE_H__C6A7B2C5_B699_4078_9690_00AF0121FFA9__INCLUDED_)
|
||||
#define AFX_X3DEFFECTBASE_H__C6A7B2C5_B699_4078_9690_00AF0121FFA9__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "key.h"
|
||||
#include "Texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
#define EFFECT_PARTICLE 0
|
||||
#define EFFECT_BILLBOARD 1
|
||||
#define EFFECT_CYLINDER 2
|
||||
#define EFFECT_PLANE 3
|
||||
#define EFFECT_SPHERE 4
|
||||
#define EFFECT_MESH 5
|
||||
|
||||
class CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwEffectKind; // 이펙트 종류
|
||||
// 0 : 파티클 1 : 빌보드
|
||||
// 2 : 실린더 3 : 플레인
|
||||
// 4 : 스피어 5 : 메쉬
|
||||
|
||||
LPDIRECT3DDEVICE8 m_lpD3DDevice;
|
||||
CTexture *m_lpTexture;
|
||||
char m_strTextureFile[256];
|
||||
unsigned long m_dwStartFrame, m_dwEndFrame;
|
||||
|
||||
void *m_lpLocalEffect;
|
||||
matrix *m_matLocalView;
|
||||
vector3 *m_vecLocalCenter;
|
||||
quaternion *m_quatLocalAxis;
|
||||
|
||||
quaternion m_quatAxis;
|
||||
quaternion m_TmpQuat;
|
||||
|
||||
bool m_QuatSet;
|
||||
vector3 m_vecCenter;
|
||||
color m_lColor;
|
||||
|
||||
BOOL m_bTexAni;
|
||||
bool m_Mine;
|
||||
|
||||
int m_index;
|
||||
float m_Scale[3];
|
||||
//world map effect 인지 세팅
|
||||
bool m_bWorldEffect;
|
||||
int m_StopParticleFrame;
|
||||
|
||||
unsigned long m_dwSrcBlending;
|
||||
unsigned long m_dwDestBlending;
|
||||
bool m_bLight;
|
||||
bool m_bVisibility;
|
||||
|
||||
public:
|
||||
CKeyList<VectorKeyList> m_lstCenter;
|
||||
CKeyList<QuaternionKeyList> m_lstAxis;
|
||||
CKeyList<ColorKeyList> m_lstColor;
|
||||
|
||||
public:
|
||||
bool m_bClearBuffer;
|
||||
void SetGemClearBuffer(bool b);
|
||||
CX3DEffectBase();
|
||||
virtual ~CX3DEffectBase();
|
||||
|
||||
void LoadTexture(const char *strFilename);
|
||||
LPDIRECT3DBASETEXTURE8 GetTexture(void) { return m_lpTexture->GetTexture(); }
|
||||
char *GetTextureFileName(void) { return m_strTextureFile; }
|
||||
|
||||
void SetLocalEffect(void *lpLocalEffect) { m_lpLocalEffect = lpLocalEffect; }
|
||||
void *GetLocalEffect(void) { return m_lpLocalEffect; }
|
||||
|
||||
void SetLocalCenter(vector3 *vecLocalCenter) { m_vecLocalCenter = vecLocalCenter; }
|
||||
vector3 *GetLocalCenter(void) { return m_vecLocalCenter; }
|
||||
void SetLocalAxis(quaternion *quatLocalAxis) { m_quatLocalAxis = quatLocalAxis; }
|
||||
quaternion *GetLocalAxis(void) { return m_quatLocalAxis; }
|
||||
|
||||
void SetLocalView(matrix *matLocalView) { m_matLocalView = matLocalView; }
|
||||
matrix *GetLocalView(void) { return m_matLocalView; }
|
||||
void SetLocalDevice(LPDIRECT3DDEVICE8 lpD3DDevice) { m_lpD3DDevice = lpD3DDevice; }
|
||||
LPDIRECT3DDEVICE8 GetLocalDevice(void) { return m_lpD3DDevice; }
|
||||
// world map effect 인지 세팅하는 함수
|
||||
void SetWorldEffect(bool b) {m_bWorldEffect = b;}
|
||||
bool GetWorldEffect() { return m_bWorldEffect;}
|
||||
|
||||
void SetTexAni(BOOL bTexAni) { m_bTexAni = bTexAni; }
|
||||
BOOL GetTexAni(void) { return m_bTexAni; }
|
||||
|
||||
void SetColor(color lColor) { m_lColor = lColor; }
|
||||
color GetColor(void) { return m_lColor; }
|
||||
void SetMine(bool t) { m_Mine = t;}
|
||||
|
||||
void SetAlpha(COLORVALUE cAlpha) { m_lColor.a = cAlpha; }
|
||||
COLORVALUE GetAlpha(void) { return m_lColor.a; }
|
||||
void SetRColor(COLORVALUE cRColor) { m_lColor.r = cRColor; }
|
||||
COLORVALUE GetRColor(void) { return m_lColor.r; }
|
||||
void SetGColor(COLORVALUE cGColor) { m_lColor.g = cGColor; }
|
||||
COLORVALUE GetGColor(void) { return m_lColor.g; }
|
||||
void SetBColor(COLORVALUE cBColor) { m_lColor.b = cBColor; }
|
||||
COLORVALUE GetBColor(void) { return m_lColor.b; }
|
||||
|
||||
void SetSrcBlending(unsigned long dwSrcBlending) { m_dwSrcBlending = dwSrcBlending; }
|
||||
unsigned long GetSrcBlending(void) { return m_dwSrcBlending; }
|
||||
void SetDestBlending(unsigned long dwDestBlending) { m_dwDestBlending = dwDestBlending; }
|
||||
unsigned long GetDestBlending(void) { return m_dwDestBlending; }
|
||||
|
||||
void SetStartFrame(unsigned long dwStartFrame) { m_dwStartFrame = dwStartFrame; }
|
||||
unsigned long GetStartFrame(void) { return m_dwStartFrame; }
|
||||
void SetEndFrame(unsigned long dwEndFrame) { m_dwEndFrame = dwEndFrame; }
|
||||
unsigned long GetEndFrame(void) { return m_dwEndFrame; }
|
||||
|
||||
void SetEffectKind(unsigned long dwEffectKind) { m_dwEffectKind = dwEffectKind; }
|
||||
unsigned long GetEffectKind(void) { return m_dwEffectKind; }
|
||||
//scale set
|
||||
void SetEffectScale(float x,float y,float z) { m_Scale[0] = x;m_Scale[1] = y;m_Scale[2] = z;}
|
||||
|
||||
void SetAxis(float fX, float fY, float fZ, float fW) { m_quatAxis.x = fX; m_quatAxis.y = fY; m_quatAxis.z = fZ; m_quatAxis.w = fW; }
|
||||
void SetAxis(quaternion &quatAxis) {
|
||||
m_QuatSet = true;
|
||||
m_quatAxis = quatAxis;
|
||||
m_TmpQuat = m_quatAxis;
|
||||
}
|
||||
quaternion GetAxis(void) { return m_quatAxis; }
|
||||
void SetStopParticle(int t);
|
||||
int GetStopParticle();
|
||||
void SetCenter(float fX, float fY, float fZ) { m_vecCenter.x = fX; m_vecCenter.y = fY; m_vecCenter.z = fZ; }
|
||||
void SetCenter(vector3 &vecCenter) { m_vecCenter = vecCenter; }
|
||||
vector3 GetCenter(void) { return m_vecCenter; }
|
||||
void SetLight(bool b) { m_bLight = b;}
|
||||
void SetVisibility(bool b) { m_bVisibility = b;}
|
||||
|
||||
virtual void Create(unsigned long dwStartFrame, unsigned long dwEndFrame) = 0;
|
||||
virtual BOOL CreateBuffer(void) = 0;
|
||||
virtual void Render(void) = 0;
|
||||
virtual BOOL Interpolation(float fFrame) = 0;
|
||||
virtual void Load(FILE *fp, const char *strOriginalPath = NULL) = 0;
|
||||
virtual void Save(FILE *fp, const char *strOriginalPath = NULL) = 0;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTBASE_H__C6A7B2C5_B699_4078_9690_00AF0121FFA9__INCLUDED_)
|
||||
287
GameTools/Effect/X3DEffectBillboard.cpp
Normal file
287
GameTools/Effect/X3DEffectBillboard.cpp
Normal file
@@ -0,0 +1,287 @@
|
||||
// X3DEffectBillboard.cpp: implementation of the CX3DEffectBillboard class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectBillboard.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectBillboard::CX3DEffectBillboard()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectBillboard::~CX3DEffectBillboard()
|
||||
{
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectBillboard::CreateBuffer(void)
|
||||
{
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
m_lpD3DDevice->CreateVertexBuffer( 4 * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF, D3DPOOL_DEFAULT, &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( 4 * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF, D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
|
||||
if(m_lpVertices == NULL) return;
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
|
||||
if(m_bTexAni)
|
||||
{
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
}/**/
|
||||
}
|
||||
|
||||
BOOL CX3DEffectBillboard::Interpolation(float fFrame)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
|
||||
if(!m_lstWidth.Interpolation(fFrame, m_fWidth)) return FALSE;
|
||||
if(!m_lstHeight.Interpolation(fFrame, m_fHeight)) return FALSE;
|
||||
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
if(m_bVisibility) {
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
if(FAILED( m_lpVertices->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD ) ) ) return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) ) return FALSE;
|
||||
|
||||
if(m_bAxisAligned)
|
||||
{
|
||||
m_vecAxisT = vector3(0.0f, (m_fHeight / 2), 0.0f);
|
||||
m_vecEyeT = vector3(0.0f, 0.0f, -1.0f);
|
||||
|
||||
z3d::VectorRotate(m_vecAxisT, m_vecAxisT, m_quatAxis);
|
||||
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis()) z3d::VectorRotate(m_vecAxisT, m_vecAxisT, (*((CX3DEffect *)m_lpLocalEffect)->GetAxis()));
|
||||
m_vecEyeT = vector3(m_vecEyeT.x * m_matLocalView->_11 + m_vecEyeT.y * m_matLocalView->_12 + m_vecEyeT.z * m_matLocalView->_13,
|
||||
m_vecEyeT.x * m_matLocalView->_21 + m_vecEyeT.y * m_matLocalView->_22 + m_vecEyeT.z * m_matLocalView->_23,
|
||||
m_vecEyeT.x * m_matLocalView->_31 + m_vecEyeT.y * m_matLocalView->_32 + m_vecEyeT.z * m_matLocalView->_33);
|
||||
m_vecWidthT = m_vecAxisT ^ m_vecEyeT;
|
||||
m_vecWidthT.Normalize();
|
||||
m_vecWidthT *= (m_fWidth / 2);
|
||||
|
||||
pVertices[0].v = m_vecAxisT + m_vecWidthT + m_vecCenter;
|
||||
pVertices[1].v = m_vecAxisT - m_vecWidthT + m_vecCenter;
|
||||
pVertices[2].v = -m_vecAxisT + m_vecWidthT + m_vecCenter;
|
||||
pVertices[3].v = -m_vecAxisT - m_vecWidthT + m_vecCenter;
|
||||
} else
|
||||
{
|
||||
matrix *matView = ((CX3DEffect *)m_lpLocalEffect)->GetViewMatrix();
|
||||
|
||||
float w = m_fWidth / 2;
|
||||
float h = m_fHeight / 2;
|
||||
|
||||
pVertices[0].v = vector3(-w, h, 0.0f);
|
||||
pVertices[1].v = vector3(w, h, 0.0f);
|
||||
pVertices[2].v = vector3(-w, -h, 0.0f);
|
||||
pVertices[3].v = vector3(w, -h, 0.0f);
|
||||
|
||||
vector3 vecCenter;
|
||||
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, m_quatAxis);
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
{
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
|
||||
z3d::VectorRotate(vecCenter, m_vecCenter, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
} else
|
||||
{
|
||||
vecCenter = m_vecCenter;
|
||||
}
|
||||
|
||||
pVertices[0].v = vector3(pVertices[0].v.x * matView->_11 + pVertices[0].v.y * matView->_12, pVertices[0].v.x * matView->_21 + pVertices[0].v.y * matView->_22, pVertices[0].v.x * matView->_31 + pVertices[0].v.y * matView->_32);
|
||||
pVertices[1].v = vector3(pVertices[1].v.x * matView->_11 + pVertices[1].v.y * matView->_12, pVertices[1].v.x * matView->_21 + pVertices[1].v.y * matView->_22, pVertices[1].v.x * matView->_31 + pVertices[1].v.y * matView->_32);
|
||||
pVertices[2].v = vector3(pVertices[2].v.x * matView->_11 + pVertices[2].v.y * matView->_12, pVertices[2].v.x * matView->_21 + pVertices[2].v.y * matView->_22, pVertices[2].v.x * matView->_31 + pVertices[2].v.y * matView->_32);
|
||||
pVertices[3].v = vector3(pVertices[3].v.x * matView->_11 + pVertices[3].v.y * matView->_12, pVertices[3].v.x * matView->_21 + pVertices[3].v.y * matView->_22, pVertices[3].v.x * matView->_31 + pVertices[3].v.y * matView->_32);
|
||||
|
||||
pVertices[0].v += vecCenter;
|
||||
pVertices[1].v += vecCenter;
|
||||
pVertices[2].v += vecCenter;
|
||||
pVertices[3].v += vecCenter;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
pVerticesBlend[0].v = pVertices[0].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[1].v = pVertices[1].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[2].v = pVertices[2].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[3].v = pVertices[3].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
} else
|
||||
{
|
||||
pVerticesBlend[0].v = pVertices[0].v;
|
||||
pVerticesBlend[1].v = pVertices[1].v;
|
||||
pVerticesBlend[2].v = pVertices[2].v;
|
||||
pVerticesBlend[3].v = pVertices[3].v;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
fEndU = f1 + 0.25f;
|
||||
fEndV = f2 + 0.25f;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndBU = f1 + 0.25f;
|
||||
fEndBV = f2 + 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU;
|
||||
fEndBV = fEndV = m_fTileV;
|
||||
}
|
||||
pVertices[0].tu = fStartU; pVertices[0].tv = fStartV;
|
||||
pVertices[1].tu = fEndU; pVertices[1].tv = fStartV;
|
||||
pVertices[2].tu = fStartU; pVertices[2].tv = fEndV;
|
||||
pVertices[3].tu = fEndU; pVertices[3].tv = fEndV;
|
||||
pVerticesBlend[0].tu = fStartBU; pVerticesBlend[0].tv = fStartBV;
|
||||
pVerticesBlend[1].tu = fEndBU; pVerticesBlend[1].tv = fStartBV;
|
||||
pVerticesBlend[2].tu = fStartBU; pVerticesBlend[2].tv = fEndBV;
|
||||
pVerticesBlend[3].tu = fEndBU; pVerticesBlend[3].tv = fEndBV;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
pVertices[0].diff = pVertices[1].diff = pVertices[2].diff = pVertices[3].diff = m_lColor;
|
||||
pVerticesBlend[0].diff = pVerticesBlend[1].diff = pVerticesBlend[2].diff = pVerticesBlend[3].diff = m_lColor;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[3].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVertices[0].diff.a = pVertices[1].diff.a = pVertices[2].diff.a = pVertices[3].diff.a;
|
||||
pVerticesBlend[3].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
pVerticesBlend[0].diff.a = pVerticesBlend[1].diff.a = pVerticesBlend[2].diff.a = pVerticesBlend[3].diff.a;
|
||||
}
|
||||
pVertices[0].spec = pVertices[1].spec = pVertices[2].spec = pVertices[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].spec = pVerticesBlend[1].spec = pVerticesBlend[2].spec = pVerticesBlend[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
fread(&m_bAxisAligned, 4, 1, fp);
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstWidth.Load(fp, m_fWidth);
|
||||
m_lstHeight.Load(fp, m_fHeight);
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
fwrite(&m_bAxisAligned, 4, 1, fp);
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
m_lstColor.Save(fp);
|
||||
m_lstWidth.Save(fp);
|
||||
m_lstHeight.Save(fp);
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
77
GameTools/Effect/X3DEffectBillboard.h
Normal file
77
GameTools/Effect/X3DEffectBillboard.h
Normal file
@@ -0,0 +1,77 @@
|
||||
// X3DEffectBillboard.h: interface for the CX3DEffectBillboard class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTBILLBOARD_H__C83DF58D_552F_430C_8BBD_7274114C7B44__INCLUDED_)
|
||||
#define AFX_X3DEFFECTBILLBOARD_H__C83DF58D_552F_430C_8BBD_7274114C7B44__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectBillboard : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
float m_fWidth;
|
||||
float m_fHeight;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
BOOL m_bAxisAligned;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstWidth;
|
||||
CKeyList<FloatKeyList> m_lstHeight;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
// ³»ºÎ Interpolation ¿ë º¯¼ö
|
||||
vector3 m_vecEyeT, m_vecAxisT, m_vecWidthT;
|
||||
|
||||
public:
|
||||
CX3DEffectBillboard();
|
||||
virtual ~CX3DEffectBillboard();
|
||||
|
||||
void SetWidth(float fWidth) { m_fWidth = fWidth; }
|
||||
float GetWidth(void) { return m_fWidth; }
|
||||
void SetHeight(float fHeight) { m_fHeight = fHeight; }
|
||||
float GetHeight(void) { return m_fHeight; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetAxisAligned(BOOL bAxisAligned) { m_bAxisAligned = bAxisAligned; }
|
||||
BOOL GetAxisAligned(void) { return m_bAxisAligned; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTBILLBOARD_H__C83DF58D_552F_430C_8BBD_7274114C7B44__INCLUDED_)
|
||||
282
GameTools/Effect/X3DEffectCylinder.cpp
Normal file
282
GameTools/Effect/X3DEffectCylinder.cpp
Normal file
@@ -0,0 +1,282 @@
|
||||
// X3DEffectCylinder.cpp: implementation of the CX3DEffectCylinder class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectCylinder.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectCylinder::CX3DEffectCylinder()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectCylinder::~CX3DEffectCylinder()
|
||||
{
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectCylinder::CreateBuffer(void)
|
||||
{
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
m_lpD3DDevice->CreateVertexBuffer( ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
|
||||
m_dwPrimitive = m_dwSidePlane * 2;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
if(m_lpVertices == NULL) return;
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
|
||||
if(quatAxis) { z3d::MatrixRotationQuaternion(matWorld, (*quatAxis)); }
|
||||
if(m_QuatSet) {
|
||||
z3d::MatrixRotationQuaternion(matWorld, (m_TmpQuat));
|
||||
}
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
vector3 *vecTemp = ((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
matWorld._41 = vecTemp->x;
|
||||
matWorld._42 = vecTemp->y;
|
||||
matWorld._43 = vecTemp->z;
|
||||
}
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, m_dwPrimitive);
|
||||
|
||||
if(m_bTexAni)
|
||||
{
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, m_dwPrimitive);
|
||||
}/**/
|
||||
}
|
||||
|
||||
BOOL CX3DEffectCylinder::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
|
||||
if(!m_lstUpperHeight.Interpolation(fFrame, m_fUpperHeight)) return FALSE;
|
||||
if(!m_lstUpperRadius.Interpolation(fFrame, m_fUpperRadius)) return FALSE;
|
||||
if(!m_lstLowerHeight.Interpolation(fFrame, m_fLowerHeight)) return FALSE;
|
||||
if(!m_lstLowerRadius.Interpolation(fFrame, m_fLowerRadius)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fUpperHeight *=m_Scale[0];
|
||||
m_fUpperRadius *=m_Scale[0];
|
||||
m_fLowerHeight *=m_Scale[0];
|
||||
m_fLowerRadius *=m_Scale[0];
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
if(m_bVisibility) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
if(FAILED( m_lpVertices->Lock( 0, ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
|
||||
unsigned long i, tempi;
|
||||
float degree;
|
||||
float divangle = 360.0f / m_dwSidePlane;
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
|
||||
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
|
||||
fEndU = fEndBU = 0.25f;
|
||||
fEndV = fEndBV = 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU - fStartBU;
|
||||
fEndBV = fEndV = m_fTileV - fStartBV;
|
||||
}
|
||||
|
||||
for(i = 0; i < m_dwSidePlane; i++)
|
||||
{
|
||||
degree = FLOAT_DEG(i * divangle);
|
||||
|
||||
tempi = i * 2 + 1;
|
||||
pVertices[tempi].v = vector3(m_fUpperRadius * cosf(degree), m_fUpperHeight, m_fUpperRadius * sinf(degree));
|
||||
z3d::VectorRotate(pVertices[tempi].v, pVertices[tempi].v, m_quatAxis);
|
||||
pVertices[tempi].v += m_vecCenter;
|
||||
pVerticesBlend[tempi].v = pVertices[tempi].v;
|
||||
|
||||
pVertices[tempi].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVertices[tempi].tv = fStartV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[tempi].tv = fStartBV;
|
||||
|
||||
tempi = i * 2;
|
||||
pVertices[tempi].v = vector3(m_fLowerRadius * cosf(degree), -m_fLowerHeight, m_fLowerRadius * sinf(degree));
|
||||
z3d::VectorRotate(pVertices[tempi].v, pVertices[tempi].v, m_quatAxis);
|
||||
pVertices[tempi].v += m_vecCenter;
|
||||
pVerticesBlend[tempi].v = pVertices[tempi].v;
|
||||
|
||||
pVertices[tempi].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVertices[tempi].tv = fEndV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[tempi].tv = fEndBV;
|
||||
}
|
||||
tempi = m_dwSidePlane * 2 + 1;
|
||||
pVertices[tempi].v = pVertices[1].v;
|
||||
pVertices[tempi].tu = fStartU + fEndU;
|
||||
pVertices[tempi].tv = fStartV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU;
|
||||
pVerticesBlend[tempi].tv = fStartBV;
|
||||
|
||||
tempi = m_dwSidePlane * 2;
|
||||
pVertices[tempi].v = pVertices[0].v;
|
||||
pVertices[tempi].tu = fStartU + fEndU;
|
||||
pVertices[tempi].tv = fEndV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU;
|
||||
pVerticesBlend[tempi].tv = fEndBV;
|
||||
|
||||
pVertices[0].diff = m_lColor;
|
||||
pVertices[0].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].diff = pVertices[0].diff;
|
||||
pVerticesBlend[0].spec = pVertices[0].spec;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[0].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVerticesBlend[0].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
}
|
||||
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * 2; i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
fread(&m_dwSidePlane, 4, 1, fp);
|
||||
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstUpperHeight.Load(fp, m_fUpperHeight);
|
||||
m_lstUpperRadius.Load(fp, m_fUpperRadius);
|
||||
m_lstLowerHeight.Load(fp, m_fLowerHeight);
|
||||
m_lstLowerRadius.Load(fp, m_fLowerRadius);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fUpperHeight *=m_Scale[0];
|
||||
m_fUpperRadius *=m_Scale[0];
|
||||
m_fLowerHeight *=m_Scale[0];
|
||||
m_fLowerRadius *=m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
fwrite(&m_dwSidePlane, 4, 1, fp);
|
||||
|
||||
m_lstColor.Save(fp);
|
||||
m_lstUpperHeight.Save(fp);
|
||||
m_lstUpperRadius.Save(fp);
|
||||
m_lstLowerHeight.Save(fp);
|
||||
m_lstLowerRadius.Save(fp);
|
||||
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
82
GameTools/Effect/X3DEffectCylinder.h
Normal file
82
GameTools/Effect/X3DEffectCylinder.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// X3DEffectCylinder.h: interface for the CX3DEffectCylinder class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_)
|
||||
#define AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectCylinder : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwSidePlane, m_dwPrimitive;
|
||||
float m_fUpperHeight;
|
||||
float m_fLowerHeight;
|
||||
float m_fUpperRadius;
|
||||
float m_fLowerRadius;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstUpperHeight;
|
||||
CKeyList<FloatKeyList> m_lstLowerHeight;
|
||||
CKeyList<FloatKeyList> m_lstUpperRadius;
|
||||
CKeyList<FloatKeyList> m_lstLowerRadius;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectCylinder();
|
||||
virtual ~CX3DEffectCylinder();
|
||||
|
||||
void SetSidePlane(unsigned long dwSidePlane) { m_dwSidePlane = dwSidePlane; }
|
||||
unsigned long GetSidePlane(void) { return m_dwSidePlane; }
|
||||
|
||||
void SetUpperHeight(float fUpperHeight) { m_fUpperHeight = fUpperHeight; }
|
||||
float GetUpperHeight(void) { return m_fUpperHeight; }
|
||||
void SetLowerHeight(float fLowerHeight) { m_fLowerHeight = fLowerHeight; }
|
||||
float GetLowerHeight(void) { return m_fLowerHeight; }
|
||||
|
||||
void SetUpperRadius(float fUpperRadius) { m_fUpperRadius = fUpperRadius; }
|
||||
float GetUpperRadius(void) { return m_fUpperRadius; }
|
||||
void SetLowerRadius(float fLowerRadius) { m_fLowerRadius = fLowerRadius; }
|
||||
float GetLowerRadius(void) { return m_fLowerRadius; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_)
|
||||
973
GameTools/Effect/X3DEffectManager.cpp
Normal file
973
GameTools/Effect/X3DEffectManager.cpp
Normal file
@@ -0,0 +1,973 @@
|
||||
// X3DEffectManager.cpp: implementation of the CX3DEffectManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffectManager.h"
|
||||
#include "X3DEffectMesh.h"
|
||||
#include "SceneNode.h"
|
||||
#include "SceneManager.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
//#include <crtdbg.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectManager::CX3DEffectManager()
|
||||
{
|
||||
m_lstExist.clear();
|
||||
m_lstFree.clear();
|
||||
m_lstEffect.clear();
|
||||
m_lstScript.clear();
|
||||
m_lstWScript.clear();
|
||||
m_lstIScript.clear();
|
||||
m_lstLightning.clear();
|
||||
|
||||
m_EffScriptLimitNum = DEFAULTLIMITSCRIPT;
|
||||
m_EffScriptLimitCount = 0;
|
||||
|
||||
m_pFrustum = new CViewFrustum;
|
||||
|
||||
}
|
||||
|
||||
CX3DEffectManager::~CX3DEffectManager()
|
||||
{
|
||||
DeleteAllEffect();
|
||||
DeleteAllEffectScript();
|
||||
DeleteAllWorldScript();
|
||||
DeleteAllInterfaceScript();
|
||||
DeleteAllLightning();
|
||||
|
||||
delete m_pFrustum;
|
||||
m_pFrustum = NULL;
|
||||
|
||||
// CX3DEffectMesh::DeleteAllCash(); // Mesh Cash List Delete
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectManager::UpdateFrame(void)
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
long count = m_lstExist.size() - 1, j;
|
||||
CX3DEffect *pEffect;
|
||||
|
||||
m_lpD3DDevice->GetTransform(D3DTS_VIEW, (D3DMATRIX *)&m_matView);
|
||||
|
||||
m_dwTick = timeGetTime();
|
||||
|
||||
for(it = m_lstExist.begin(), j = 0; j <= count; it++, j++)
|
||||
{
|
||||
pEffect = m_lstEffect[(*it)];
|
||||
// 시작 되었으면 update
|
||||
if(pEffect->GetEffectStart()) {
|
||||
if(m_dwTick - pEffect->GetTick() >= pEffect->GetFrameTick())
|
||||
{
|
||||
if(!pEffect->Interpolation(m_dwTick - pEffect->GetTick()))
|
||||
{
|
||||
m_lstFree.push_back((*it));
|
||||
delete pEffect;
|
||||
pEffect = NULL;
|
||||
m_lstExist.erase(it);
|
||||
it--;
|
||||
} else
|
||||
{
|
||||
pEffect->SetTick(m_dwTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectManager::Render(int num)
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
int i=0;
|
||||
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
|
||||
m_lpD3DDevice->SetTexture(0, NULL);
|
||||
m_lpD3DDevice->SetTexture(1, NULL);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_LIGHTING, FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHAFUNC,D3DCMP_ALWAYS);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHAREF,0x00000000);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++,i++)
|
||||
{
|
||||
if(i== num) {
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
|
||||
|
||||
}
|
||||
//if(effectmap->EffectSectorIn(
|
||||
//camera pos
|
||||
matrix *matViewPosition=CSceneManager::GetCamera()->GetMatPosition();
|
||||
vector3 vecViewPos=matViewPosition->GetLoc();
|
||||
|
||||
int indexx=(int)(vecViewPos.x/SECTORSIZE);
|
||||
int indexy=(int)(vecViewPos.z/SECTORSIZE);
|
||||
|
||||
//culling
|
||||
CSceneNode CheckNode;
|
||||
|
||||
CheckNode.m_fRad=100.0f;
|
||||
CheckNode.m_AccumulateTM.Translation(*m_lstEffect[(*it)]->GetCenter());
|
||||
if(m_lstEffect[(*it)]->map_effect == true) {
|
||||
if(CheckNode.isCulling())
|
||||
{
|
||||
//if(effectmap->EffectSectorIn(indexx,indexy,i)) {
|
||||
if(m_lstEffect[(*it)]) m_lstEffect[(*it)]->Render();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(m_lstEffect[(*it)]) m_lstEffect[(*it)]->Render();
|
||||
}
|
||||
if(i == num)
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
|
||||
|
||||
}
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
}
|
||||
|
||||
void CX3DEffectManager::Render()
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
int i=0;
|
||||
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
|
||||
m_lpD3DDevice->SetTexture(0, NULL);
|
||||
m_lpD3DDevice->SetTexture(1, NULL);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_LIGHTING, FALSE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHAFUNC,D3DCMP_ALWAYS);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHAREF,0x00000000);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++,i++)
|
||||
{
|
||||
if(!(m_lstEffect[(*it)]->GetEffectStart()))
|
||||
continue;
|
||||
//if(effectmap->EffectSectorIn(
|
||||
//camera pos
|
||||
matrix *matViewPosition=CSceneManager::GetCamera()->GetMatPosition();
|
||||
vector3 vecViewPos=matViewPosition->GetLoc();
|
||||
|
||||
int indexx=(int)(vecViewPos.x/SECTORSIZE);
|
||||
int indexy=(int)(vecViewPos.z/SECTORSIZE);
|
||||
|
||||
//culling
|
||||
CSceneNode CheckNode;
|
||||
|
||||
CheckNode.m_fRad=100.0f;
|
||||
CheckNode.m_AccumulateTM.Translation(*m_lstEffect[(*it)]->GetCenter());
|
||||
if(m_lstEffect[(*it)]->map_effect == true) {
|
||||
if(CheckNode.isCulling())
|
||||
{
|
||||
//if(effectmap->EffectSectorIn(indexx,indexy,i)) {
|
||||
if(m_lstEffect[(*it)]) m_lstEffect[(*it)]->Render();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(m_lstEffect[(*it)]) m_lstEffect[(*it)]->Render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
}
|
||||
|
||||
XEFFECT CX3DEffectManager::AddEffect(CX3DEffect *lpNewEffect)
|
||||
{
|
||||
XEFFECT hEffect;
|
||||
if(m_lstFree.empty())
|
||||
{
|
||||
hEffect = m_lstEffect.size();
|
||||
m_lstEffect.push_back(lpNewEffect);
|
||||
} else
|
||||
{
|
||||
hEffect = m_lstFree.back();
|
||||
m_lstEffect[hEffect] = lpNewEffect;
|
||||
m_lstFree.pop_back();
|
||||
}
|
||||
|
||||
lpNewEffect->SetDevice(m_lpD3DDevice);
|
||||
lpNewEffect->SetViewMatrix(&m_matView);
|
||||
lpNewEffect->SetEffectSetting();
|
||||
lpNewEffect->SetTick(timeGetTime());
|
||||
m_lstExist.push_back(hEffect);
|
||||
return hEffect;
|
||||
}
|
||||
char *CX3DEffectManager::GetEsfName(int index) {
|
||||
if(m_lstScript[index] != NULL) {
|
||||
return m_lstScript[index]->m_FileName;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void CX3DEffectManager::AddLightning(CLightning *new_light) {
|
||||
m_lstLightning.push_back(new_light);
|
||||
}
|
||||
CEffScript *CX3DEffectManager::AddEffScript(CEffScript *new_script) {
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
if(!new_script->GetMine()) { // 내가 사용한 스킬이 아니면 제한 갯수 적용
|
||||
if(new_script->GetBSkill() && (!new_script->GetChant())) { // skill effect 이면 적용
|
||||
if(m_EffScriptLimitCount > m_EffScriptLimitNum) {
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
m_EffScriptLimitCount++;
|
||||
}
|
||||
}
|
||||
m_lstScript.push_back(new_script);
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
///////// 인터페이스 이팩트 테스트///
|
||||
/*
|
||||
// interface effect
|
||||
vector3 pos;
|
||||
matrix *matpos = NULL;
|
||||
vector3 camera_fwd;
|
||||
matpos = CSceneManager::GetCamera()->GetMatPosition();
|
||||
|
||||
camera_fwd = CSceneManager::GetCamera()->GetViewTowardVector();
|
||||
|
||||
pos.x = matpos->_41;
|
||||
pos.y = matpos->_42;
|
||||
pos.z = matpos->_43;
|
||||
|
||||
pos.x += (camera_fwd.x * 300.0f);
|
||||
pos.y += (camera_fwd.y * 300.0f);
|
||||
pos.z += (camera_fwd.z * 300.0f);
|
||||
|
||||
new_script->SetStartPos(pos.x,pos.y,pos.z);
|
||||
|
||||
// interface effect
|
||||
//screen projection
|
||||
D3DXMATRIX t_project;
|
||||
D3DXMATRIX t_view;
|
||||
D3DXMATRIX t_world;
|
||||
D3DXVECTOR3 t_pos;
|
||||
|
||||
D3DVIEWPORT8 t_viewport;
|
||||
|
||||
t_pos.x = pos.x;
|
||||
t_pos.y = pos.y;
|
||||
t_pos.z = pos.z;
|
||||
|
||||
m_lpD3DDevice->GetViewport(&t_viewport);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_WORLD,&t_world);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_VIEW,&t_view);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_PROJECTION,&t_project);
|
||||
|
||||
D3DXVec3Project(&(new_script->m_Projection),
|
||||
&t_pos,
|
||||
&t_viewport,
|
||||
&t_project,
|
||||
&t_view,
|
||||
&t_world);
|
||||
|
||||
new_script->SetScriptValue(ESINTERFACE);
|
||||
*/
|
||||
//////////
|
||||
new_script->SetDevice(m_lpD3DDevice);
|
||||
//return (m_lstScript.size() - 1);
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
return new_script;
|
||||
|
||||
}
|
||||
int CX3DEffectManager::AddWorldEffScript(CEffScript *new_script) {
|
||||
m_lstWScript.push_back(new_script);
|
||||
new_script->SetDevice(m_lpD3DDevice);
|
||||
new_script->SetWorldEffect(true);
|
||||
return (m_lstWScript.size() - 1);
|
||||
|
||||
}
|
||||
CEffScript *CX3DEffectManager::AddInterfaceScript(CEffScript *new_script) {
|
||||
// 특정 포지션이 설정되어있지 않으면
|
||||
|
||||
/* if(!(new_script->m_bInterfaceSet)) {
|
||||
vector3 pos;
|
||||
matrix *matpos = NULL;
|
||||
vector3 camera_fwd;
|
||||
vector3 camera_up;
|
||||
vector3 camera_right;
|
||||
|
||||
matpos = CSceneManager::GetCamera()->GetMatPosition();
|
||||
|
||||
camera_fwd = CSceneManager::GetCamera()->GetViewTowardVector();
|
||||
camera_up = CSceneManager::GetCamera()->GetViewUpVector();
|
||||
|
||||
camera_right = camera_fwd^camera_up;
|
||||
|
||||
//camera_fwd = CSceneManager::GetCamera()->GetFwdVector();
|
||||
|
||||
pos.x = matpos->_41;
|
||||
pos.y = matpos->_42;
|
||||
pos.z = matpos->_43;
|
||||
|
||||
pos.x += (camera_fwd.x * 100.0f);
|
||||
pos.y += (camera_fwd.y * 100.0f);
|
||||
pos.z += (camera_fwd.z * 100.0f);
|
||||
|
||||
if(new_script->m_bInterfacePos) {
|
||||
pos += (camera_up * (new_script->m_InterfacePos[1]));
|
||||
pos += ((-camera_right) * (new_script->m_InterfacePos[0]));
|
||||
}
|
||||
//pos *= 100.0f;
|
||||
|
||||
new_script->SetStartPos(pos.x,pos.y,pos.z);
|
||||
|
||||
// interface effect
|
||||
//screen projection
|
||||
D3DXMATRIX t_project;
|
||||
D3DXMATRIX t_view;
|
||||
D3DXMATRIX t_world;
|
||||
D3DXVECTOR3 t_pos;
|
||||
|
||||
D3DVIEWPORT8 t_viewport;
|
||||
|
||||
t_pos.x = pos.x;
|
||||
t_pos.y = pos.y;
|
||||
t_pos.z = pos.z;
|
||||
|
||||
|
||||
m_lpD3DDevice->GetViewport(&t_viewport);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_WORLD,&t_world);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_VIEW,&t_view);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_PROJECTION,&t_project);
|
||||
|
||||
D3DXVec3Project(&(new_script->m_Projection),
|
||||
&t_pos,
|
||||
&t_viewport,
|
||||
&t_project,
|
||||
&t_view,
|
||||
&t_world);
|
||||
|
||||
|
||||
new_script->SetScriptValue(ESINTERFACE);
|
||||
for(int i=0;i<new_script->m_SubScriptNum;i++) {
|
||||
new_script->m_SubScript[i].m_Projection = new_script->m_Projection;
|
||||
}
|
||||
}
|
||||
*/
|
||||
new_script->SetInterfaceSet(true);
|
||||
if(new_script->m_SubScriptNum >0) {
|
||||
new_script->m_bInterfacePos = true; // sub interface effect 를 이용하기 위한 setting
|
||||
}
|
||||
m_lstIScript.push_back(new_script);
|
||||
|
||||
new_script->SetDevice(m_lpD3DDevice);
|
||||
return new_script;
|
||||
|
||||
}
|
||||
|
||||
int CX3DEffectManager::ProcessScript(int i) {// return value 0: 스크립트 종료
|
||||
// 1: 스크립트 유지
|
||||
// 2: effect target에 충돌
|
||||
|
||||
|
||||
int index = 0;
|
||||
|
||||
if((m_lstScript.size() - 1)< i) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(m_lstScript[i] == NULL) {
|
||||
DeleteEndScript(i);
|
||||
return 0;
|
||||
}
|
||||
index = m_lstScript[i]->ProcessEffect();
|
||||
if(!index)
|
||||
DeleteEndScript(i);
|
||||
else if(index == 2) {
|
||||
m_lstScript[i]->SetCrash(true);
|
||||
}
|
||||
else
|
||||
m_lstScript[i]->SetCrash(false);
|
||||
return index;
|
||||
}
|
||||
// 두번째 타입의 이팩트 검사 :: NULL 이면 처리 끝이라는 의미로 true return
|
||||
bool CX3DEffectManager::CheckNullScript(CEffScript *t) {
|
||||
int script_num = m_lstScript.size();
|
||||
int i;
|
||||
for(i=0;i<script_num;i++) {
|
||||
if(m_lstScript[i] == t)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool CX3DEffectManager::CheckNullInterfaceScript(CEffScript *t) {
|
||||
int script_num = m_lstIScript.size();
|
||||
int i;
|
||||
for(i=0;i<script_num;i++) {
|
||||
if(m_lstIScript[i] == t)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CX3DEffectManager::CheckScript(int index,CEffScript *t) {
|
||||
if((m_lstScript.size() -1) < index)
|
||||
return false;
|
||||
if(m_lstScript[index] == t)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool CX3DEffectManager::ProcessWScript(int i,bool bCull) {
|
||||
int index = 0;
|
||||
|
||||
if((m_lstWScript.size() - 1)< i)
|
||||
return false;
|
||||
|
||||
if(m_lstWScript[i] == NULL) {
|
||||
DeleteWScript(i);
|
||||
return false;
|
||||
}
|
||||
/*if(bCull == false) { // Culling 적용
|
||||
if(m_lstWScript[i]->GetSectorCull())
|
||||
return false;
|
||||
}*/
|
||||
index = m_lstWScript[i]->ProcessEffect();
|
||||
|
||||
if(!index)
|
||||
DeleteWScript(i);
|
||||
else if(index == 2) {
|
||||
m_lstWScript[i]->SetCrash(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
m_lstWScript[i]->SetCrash(false);
|
||||
return false;
|
||||
}
|
||||
bool CX3DEffectManager::ProcessLightning(int index) {
|
||||
|
||||
if((m_lstLightning.size() - 1)< index)
|
||||
return false;
|
||||
|
||||
if(m_lstWScript[index] == NULL) {
|
||||
DeleteWScript(index);
|
||||
return false;
|
||||
}
|
||||
D3DXVECTOR3 dermy;
|
||||
|
||||
m_lstLightning[index]->UpdateLightning(dermy,false);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
bool CX3DEffectManager::ProcessInterfaceScript(int i) {
|
||||
int index = 0;
|
||||
|
||||
if((m_lstIScript.size() - 1)< i)
|
||||
return false;
|
||||
|
||||
if(m_lstIScript[i] == NULL) {
|
||||
DeleteInterfaceScript(i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
index = m_lstIScript[i]->ProcessEffect();
|
||||
if(!index)
|
||||
DeleteInterfaceScript(i);
|
||||
else if(index == 2) {
|
||||
m_lstIScript[i]->SetCrash(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
m_lstIScript[i]->SetCrash(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CX3DEffectManager::CheckInterfaceScript(int index,CEffScript *t) {
|
||||
if(m_lstIScript[index] == t)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
int CX3DEffectManager::GetLightningNum() {
|
||||
int size = m_lstLightning.size();
|
||||
return size;
|
||||
}
|
||||
|
||||
int CX3DEffectManager::GetScriptNum() {
|
||||
int size = m_lstScript.size();
|
||||
return size;
|
||||
}
|
||||
int CX3DEffectManager::GetWScriptNum() {
|
||||
int size = m_lstWScript.size();
|
||||
return size;
|
||||
|
||||
}
|
||||
int CX3DEffectManager::GetInterfaceScriptNum() {
|
||||
int size = m_lstIScript.size();
|
||||
return size;
|
||||
}
|
||||
void CX3DEffectManager::RenderScript() {
|
||||
|
||||
/* if(m_pFrustum != NULL)
|
||||
m_pFrustum->Update();
|
||||
*/
|
||||
|
||||
int size = m_lstScript.size();
|
||||
int i;
|
||||
|
||||
for(i=0;i<size;i++) {
|
||||
if(m_lstScript[i] != NULL) {
|
||||
|
||||
// Frustum Culling
|
||||
/*
|
||||
int iCount = 0;
|
||||
int iFalse = 0;
|
||||
|
||||
if(m_pFrustum != NULL) {
|
||||
if(m_lstScript[i]->m_StartPosSet)
|
||||
{
|
||||
iCount++;
|
||||
|
||||
if(!m_pFrustum->SphereInFrustum(m_lstScript[i]->m_StartPos.x,
|
||||
m_lstScript[i]->m_StartPos.y,
|
||||
m_lstScript[i]->m_StartPos.z,
|
||||
1600.0f))
|
||||
iFalse++;
|
||||
}
|
||||
if(m_lstScript[i]->m_EndPosNum > 0)
|
||||
{
|
||||
iCount++;
|
||||
|
||||
if(!m_pFrustum->SphereInFrustum(m_lstScript[i]->m_EndPos[0].x,
|
||||
m_lstScript[i]->m_EndPos[0].y,
|
||||
m_lstScript[i]->m_EndPos[0].z,
|
||||
1600.0f))
|
||||
iFalse++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(iFalse != iCount)*/
|
||||
m_lstScript[i]->Render();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::RenderLightning() {
|
||||
int i;
|
||||
for(i=0;i<m_lstLightning.size();i++) {
|
||||
if(m_lstLightning[i] != NULL)
|
||||
m_lstLightning[i]->Render(0);
|
||||
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::RenderWorldScript(bool bCull) {
|
||||
|
||||
if(m_pFrustum != NULL)
|
||||
m_pFrustum->Update();
|
||||
|
||||
int size = m_lstWScript.size();
|
||||
int i;
|
||||
for(i=0;i<size;i++) {
|
||||
if(m_lstWScript[i] != NULL) {
|
||||
|
||||
if((bCull == false) && (m_lstWScript[i]->m_bFrustumCull) ) { // Culling 적용
|
||||
if(m_lstWScript[i]->GetSectorCull())
|
||||
continue;
|
||||
}
|
||||
|
||||
if(m_lstWScript[i]->m_bPlayTime) { // Play Time Setting 되어 있을때
|
||||
if(m_lstWScript[i]->m_bVisTime) {
|
||||
// Frustum Culling
|
||||
if(m_pFrustum != NULL) {
|
||||
if(m_lstWScript[i]->m_StartPosSet)
|
||||
{
|
||||
if(m_lstWScript[i]->m_bFrustumCull) {
|
||||
if(!m_pFrustum->SphereInFrustum(m_lstWScript[i]->m_StartPos.x,
|
||||
m_lstWScript[i]->m_StartPos.y,
|
||||
m_lstWScript[i]->m_StartPos.z,
|
||||
600.0f))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_lstWScript[i]->Render();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Frustum Culling
|
||||
if(m_pFrustum != NULL) {
|
||||
if(m_lstWScript[i]->m_StartPosSet)
|
||||
{
|
||||
|
||||
if(m_lstWScript[i]->m_bFrustumCull) {
|
||||
if(!m_pFrustum->SphereInFrustum(m_lstWScript[i]->m_StartPos.x,
|
||||
m_lstWScript[i]->m_StartPos.y,
|
||||
m_lstWScript[i]->m_StartPos.z,
|
||||
600.0f))
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lstWScript[i]->Render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::RenderInterfaceScript() {
|
||||
int i;
|
||||
int size = m_lstIScript.size();
|
||||
|
||||
for(i=0;i<size;i++) {
|
||||
|
||||
if(m_lstIScript[i] != NULL) {
|
||||
// unprojection
|
||||
|
||||
D3DXMATRIX t_project;
|
||||
D3DXMATRIX t_view;
|
||||
D3DXMATRIX t_world;
|
||||
|
||||
D3DXMATRIX t_ortho;
|
||||
D3DXMATRIX t_oworld;
|
||||
D3DXMATRIX t_oview;
|
||||
|
||||
D3DXMatrixIdentity(&t_oworld);
|
||||
D3DXMatrixIdentity(&t_oview);
|
||||
|
||||
D3DXVECTOR3 t_pos;
|
||||
|
||||
D3DVIEWPORT8 t_viewport;
|
||||
|
||||
m_lpD3DDevice->GetViewport(&t_viewport);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_WORLD,&t_world);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_VIEW,&t_view);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_PROJECTION,&t_project);
|
||||
|
||||
D3DXMatrixOrthoLH(&t_ortho,100,100,0.1f, 10000.0f);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&t_ortho);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD,&t_oworld);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_VIEW,&t_oview);
|
||||
|
||||
D3DXVECTOR3 t_proj(0.0f,0.0f,0.2f);
|
||||
if(m_lstIScript[i]->m_bInterfacePos) {
|
||||
if(m_lstIScript[i]->m_SubScriptNum >0) { //subscript use
|
||||
for(int j=0;j<(m_lstIScript[i]->m_SubScriptNum);j++) {
|
||||
D3DXMatrixOrthoLH(&t_ortho,100,100,0.1f, 10000.0f);
|
||||
|
||||
m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&t_ortho);
|
||||
|
||||
D3DXMatrixIdentity(&t_oworld);
|
||||
D3DXMatrixIdentity(&t_oview);
|
||||
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD,&t_oworld);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_VIEW,&t_oview);
|
||||
|
||||
t_proj.x = m_lstIScript[i]->m_SubScript[j].m_InterfacePos[0];
|
||||
t_proj.y = m_lstIScript[i]->m_SubScript[j].m_InterfacePos[1];
|
||||
|
||||
D3DXVec3Unproject(
|
||||
&t_pos,
|
||||
&t_proj,
|
||||
&t_viewport,
|
||||
&t_ortho,
|
||||
&t_oview,
|
||||
&t_oworld);
|
||||
|
||||
m_lstIScript[i]->SetStartPos(t_pos.x,t_pos.y,t_pos.z);
|
||||
}
|
||||
}
|
||||
else { // sub script not use
|
||||
t_proj.x = m_lstIScript[i]->m_InterfacePos[0];
|
||||
t_proj.y = m_lstIScript[i]->m_InterfacePos[1];
|
||||
D3DXVec3Unproject(
|
||||
&t_pos,
|
||||
&t_proj,
|
||||
&t_viewport,
|
||||
&t_ortho,
|
||||
&t_oview,
|
||||
&t_oworld);
|
||||
|
||||
m_lstIScript[i]->SetStartPos(t_pos.x,t_pos.y,t_pos.z);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
m_lstIScript[i]->Render();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&t_project);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD,&t_world);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_VIEW,&t_view);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::DeleteEndScript(int index) {
|
||||
int i;
|
||||
for(i=0;i<m_lstScript.size();i++) {
|
||||
if(i== index) {
|
||||
if(m_lstScript[i] != NULL) {
|
||||
|
||||
if(!m_lstScript[i]->GetMine()) { // 내가 사용한 스킬이 아니면 제한 갯수 적용
|
||||
if(m_lstScript[i]->GetBSkill()) { // skill effect 이면 적용
|
||||
if(m_EffScriptLimitCount)
|
||||
m_EffScriptLimitCount--;
|
||||
}
|
||||
}
|
||||
delete m_lstScript[i];
|
||||
m_lstScript[i] = NULL;
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
|
||||
m_lstScript.erase(&(m_lstScript[i]));
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
void CX3DEffectManager::DeleteLightning(int index) {
|
||||
int i;
|
||||
for(i=0;i<m_lstLightning.size();i++) {
|
||||
if(i == index) {
|
||||
if(m_lstLightning[i] != NULL) {
|
||||
delete m_lstLightning[i];
|
||||
m_lstLightning[i] = NULL;
|
||||
|
||||
}
|
||||
m_lstLightning.erase(&(m_lstLightning[i]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::DeleteEndScript(CEffScript *del) {
|
||||
int i;
|
||||
for(i=0;i<m_lstScript.size();i++) {
|
||||
if(m_lstScript[i] == del) {
|
||||
if(!m_lstScript[i]->GetMine()) { // 내가 사용한 스킬이 아니면 제한 갯수 적용
|
||||
if(m_lstScript[i]->GetBSkill()) { // skill effect 이면 적용
|
||||
if(m_EffScriptLimitCount)
|
||||
m_EffScriptLimitCount--;
|
||||
}
|
||||
}
|
||||
|
||||
delete m_lstScript[i];
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
m_lstScript[i] = NULL;
|
||||
|
||||
m_lstScript.erase(&(m_lstScript[i]));
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
void CX3DEffectManager::DeleteWScript(int index) {
|
||||
|
||||
int i;
|
||||
for(i=0;i<m_lstWScript.size();i++) {
|
||||
if(i== index) {
|
||||
if(m_lstWScript[i] != NULL) {
|
||||
delete m_lstWScript[i];
|
||||
m_lstWScript[i] = NULL;
|
||||
}
|
||||
m_lstWScript.erase(&(m_lstWScript[i]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteInterfaceScript(int index) {
|
||||
int i;
|
||||
for(i=0;i<m_lstIScript.size();i++) {
|
||||
if(i== index) {
|
||||
if(m_lstIScript[i] != NULL) {
|
||||
delete m_lstIScript[i];
|
||||
m_lstIScript[i] = NULL;
|
||||
}
|
||||
m_lstIScript.erase(&(m_lstIScript[i]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteInterfaceScript(CEffScript *del) {
|
||||
int i;
|
||||
for(i=0;i<m_lstIScript.size();i++) {
|
||||
if(m_lstIScript[i] == del) {
|
||||
delete m_lstIScript[i];
|
||||
m_lstIScript[i] = NULL;
|
||||
m_lstIScript.erase(&(m_lstIScript[i]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectManager::DeleteEffect(XEFFECT hEffect)
|
||||
{
|
||||
m_lstFree.push_back(hEffect);
|
||||
delete (CX3DEffect *)m_lstEffect[hEffect];
|
||||
|
||||
EffectHandleList::iterator it;
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++)
|
||||
{
|
||||
if(hEffect == (*it)) {
|
||||
m_lstExist.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CX3DEffectManager::IsLive(XEFFECT hEffect)
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
|
||||
for(it = m_lstFree.begin(); it != m_lstFree.end(); it++)
|
||||
{
|
||||
if(hEffect == (*it)) return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectManager::DeleteAllEffect(void)
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
|
||||
if(m_lstExist.size())
|
||||
{
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++)
|
||||
{
|
||||
delete (CX3DEffect *)m_lstEffect[(*it)];
|
||||
}
|
||||
|
||||
m_lstExist.clear();
|
||||
}
|
||||
m_lstFree.clear();
|
||||
m_lstEffect.clear();
|
||||
//m_lstScript.clear();
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteAllEffectScript() {
|
||||
|
||||
int i;
|
||||
|
||||
if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<m_lstScript.size();i++) {
|
||||
if(m_lstScript[i] != NULL) {
|
||||
delete m_lstScript[i];
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
m_lstScript[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
m_lstScript.clear();
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
void CX3DEffectManager::DeleteAllLightning() {
|
||||
int i;
|
||||
for(i=0;i<m_lstLightning.size();i++) {
|
||||
if(m_lstLightning[i] != NULL) {
|
||||
delete m_lstLightning[i];
|
||||
m_lstLightning[i] = NULL;
|
||||
}
|
||||
}
|
||||
m_lstLightning.clear();
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteAllWorldScript() {
|
||||
|
||||
int i;
|
||||
if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<m_lstWScript.size();i++) {
|
||||
if(m_lstWScript[i] != NULL) {
|
||||
delete m_lstWScript[i];
|
||||
m_lstWScript[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
m_lstWScript.clear();
|
||||
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteAllInterfaceScript() {
|
||||
int i;
|
||||
if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<m_lstIScript.size();i++) {
|
||||
if(m_lstIScript[i] != NULL) {
|
||||
delete m_lstIScript[i];
|
||||
m_lstIScript[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
m_lstIScript.clear();
|
||||
|
||||
|
||||
}
|
||||
130
GameTools/Effect/X3DEffectManager.h
Normal file
130
GameTools/Effect/X3DEffectManager.h
Normal file
@@ -0,0 +1,130 @@
|
||||
// X3DEffectManager.h: interface for the CX3DEffectManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTMANAGER_H__4DAA8921_D30C_4F05_B138_89DFFC19B449__INCLUDED_)
|
||||
#define AFX_X3DEFFECTMANAGER_H__4DAA8921_D30C_4F05_B138_89DFFC19B449__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#pragma warning(disable:4786) // don't warn about browse name overflow.
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
#include <vector>
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectSphere.h"
|
||||
#include "SectorEffectMap.h"
|
||||
#include "CEffscript.h"
|
||||
#include "ViewFrustum.h"
|
||||
|
||||
#define DEFAULTLIMITSCRIPT 5
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef unsigned long XEFFECT;
|
||||
typedef vector<CX3DEffect *> EffectList;
|
||||
typedef vector<XEFFECT> EffectHandleList;
|
||||
typedef vector<CEffScript *> EffectScriptList;
|
||||
typedef vector<CLightning *> LightningList;
|
||||
|
||||
class CX3DEffectManager
|
||||
{
|
||||
protected:
|
||||
LPDIRECT3DDEVICE8 m_lpD3DDevice;
|
||||
matrix m_matView;
|
||||
matrix m_matWorld;
|
||||
|
||||
EffectHandleList m_lstExist;
|
||||
EffectHandleList m_lstFree;
|
||||
|
||||
// ¹è°æ script list
|
||||
EffectScriptList m_lstWScript;
|
||||
// Interface script list
|
||||
EffectScriptList m_lstIScript;
|
||||
|
||||
//Lightning list
|
||||
LightningList m_lstLightning;
|
||||
|
||||
unsigned long m_dwTick;
|
||||
unsigned long m_dwOldTick;
|
||||
int m_EffScriptLimitNum;
|
||||
int m_EffScriptLimitCount;
|
||||
|
||||
CViewFrustum *m_pFrustum;
|
||||
|
||||
|
||||
public:
|
||||
EffectList m_lstEffect;
|
||||
// skill script list
|
||||
EffectScriptList m_lstScript;
|
||||
|
||||
XEFFECT AddEffect(CX3DEffect *lpNewEffect);
|
||||
|
||||
CEffScript *AddEffScript(CEffScript *);
|
||||
int AddWorldEffScript(CEffScript *);
|
||||
CEffScript *AddInterfaceScript(CEffScript *);
|
||||
void AddLightning(CLightning *);
|
||||
|
||||
// play script :return index num
|
||||
int ProcessScript(int index);
|
||||
bool ProcessWScript(int index,bool bCull = true);
|
||||
bool ProcessInterfaceScript(int index);
|
||||
bool ProcessLightning(int index);
|
||||
|
||||
bool CheckScript(int index,CEffScript *);
|
||||
bool CheckNullScript(CEffScript *t);
|
||||
bool CheckNullInterfaceScript(CEffScript *t);
|
||||
bool CheckInterfaceScript(int index,CEffScript *t);
|
||||
|
||||
int GetScriptNum();
|
||||
int GetWScriptNum();
|
||||
int GetLightningNum();
|
||||
|
||||
char *GetEsfName(int index);
|
||||
|
||||
int GetInterfaceScriptNum();
|
||||
void SetEffScriptLimitNum(int n) {m_EffScriptLimitNum = n;}
|
||||
int GetEffScriptLimitNum() {return m_EffScriptLimitNum;}
|
||||
|
||||
|
||||
void RenderScript();
|
||||
void RenderWorldScript(bool bCull = true);
|
||||
void RenderLightning();
|
||||
|
||||
void RenderInterfaceScript();
|
||||
|
||||
void DeleteEndScript(int i);
|
||||
void DeleteEndScript(CEffScript *del);
|
||||
void DeleteWScript(int i);
|
||||
void DeleteLightning(int i);
|
||||
|
||||
void DeleteInterfaceScript(int i);
|
||||
void DeleteInterfaceScript(CEffScript *del);
|
||||
|
||||
void DeleteEffect(XEFFECT hEffect);
|
||||
BOOL IsLive(XEFFECT hEffect);
|
||||
|
||||
void Render();
|
||||
void Render(int num);
|
||||
void UpdateFrame(void);
|
||||
CX3DEffectManager();
|
||||
~CX3DEffectManager();
|
||||
|
||||
void DeleteAllEffect(void);
|
||||
void DeleteAllEffectScript();
|
||||
void DeleteAllInterfaceScript();
|
||||
void DeleteAllLightning();
|
||||
|
||||
// ¿ùµå ½ºÅ©¸³Æ®
|
||||
void DeleteAllWorldScript();
|
||||
void SetDevice(LPDIRECT3DDEVICE8 pD3DDevice) { m_lpD3DDevice = pD3DDevice; }
|
||||
LPDIRECT3DDEVICE8 GetDevice(void) { return m_lpD3DDevice; }
|
||||
|
||||
matrix *GetViewMatrix(void) { return &m_matView; }
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTMANAGER_H__4DAA8921_D30C_4F05_B138_89DFFC19B449__INCLUDED_)
|
||||
385
GameTools/Effect/X3DEffectMesh.cpp
Normal file
385
GameTools/Effect/X3DEffectMesh.cpp
Normal file
@@ -0,0 +1,385 @@
|
||||
// X3DEffectMesh.cpp: implementation of the CX3DEffectMesh class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectMesh.h"
|
||||
#include "EffDebugLog.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
//#define __EFF_WCREATOR__
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CashNode CX3DEffectMesh::m_lstCash; // Mesh cash list
|
||||
//int CX3DEffectMesh::m_nCash = 0; // Mesh cash Num
|
||||
//void CX3DEffectMesh::DeleteAllCash(); // Cash 전부 delete
|
||||
|
||||
CX3DEffectMesh::CX3DEffectMesh()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
m_moMesh = NULL;
|
||||
m_GemRender = NULL;
|
||||
m_fRenderFrame = 0.0f;
|
||||
m_GemObjectTexNum = NULL;
|
||||
m_dwTick = NULL;
|
||||
m_bFirst = NULL;
|
||||
m_bUpdateFrame = false;
|
||||
// 수정:m_GemRender = new CGemRender;
|
||||
}
|
||||
|
||||
CX3DEffectMesh::~CX3DEffectMesh()
|
||||
{
|
||||
if(m_moMesh) { delete[] m_moMesh; m_moMesh = NULL; }
|
||||
|
||||
|
||||
SubUseCount(m_GemRender->GetFileName()); // 참조 카운터 1 감소
|
||||
// 수정:if(m_GemRender) {delete m_GemRender; m_GemRender = NULL;}
|
||||
if(m_GemObjectTexNum != NULL)
|
||||
delete[] m_GemObjectTexNum;
|
||||
if(m_dwTick != NULL)
|
||||
delete[] m_dwTick;
|
||||
delete m_bFirst;
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectMesh::CreateBuffer()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::Render(void)
|
||||
{
|
||||
|
||||
|
||||
DWORD cullmode,zmode;
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_CULLMODE,&cullmode);
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_ZWRITEENABLE,&zmode);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE, D3DCULL_CW);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
|
||||
D3DXVECTOR3 *vecCenter = (D3DXVECTOR3 *)((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
|
||||
m_GemRender->SetScale(m_Scale[0],m_Scale[1],m_Scale[2]);
|
||||
m_GemRender->SetEffectPos(*vecCenter);
|
||||
// rotation setting
|
||||
if(m_QuatSet) {
|
||||
D3DXQUATERNION tm_q;
|
||||
tm_q.x = m_quatAxis.x;
|
||||
tm_q.y = m_quatAxis.y;
|
||||
tm_q.z = m_quatAxis.z;
|
||||
tm_q.w = m_quatAxis.w;
|
||||
|
||||
m_GemRender->GetAxis(tm_q);
|
||||
}
|
||||
|
||||
m_GemRender->SetClearBuffer(m_bClearBuffer);
|
||||
if(m_bUpdateFrame) {
|
||||
// Cash 로 인한 문제점 1 해결
|
||||
// Texture ani 와 Random Start Texture Ani 그리고 Random Ani 를 위해 m_GemObjectTexNum 배열을 이용한다
|
||||
// Gem의 캐쉬에 의해 일어나는 오류 수정중의 하나임.
|
||||
// m_GemObjectTexNum[ 0 ~ ObjectNum - 1] : 텍스쳐 애니 를 사용한 mesh의 현재 택스쳐 번호
|
||||
// m_GemObjectTexNun[ObjectNum] : Mesh Before Frame
|
||||
// m_GemObjectTexNum[ObjectNum + 1] : Mesh Current Frame
|
||||
// m_GemObjectTexNum[ObjectNum + 2] : 렌덤 스타트 애니시에 처음 텍스쳐 프레임 세팅 되었는가를 체크하는 체크 플래그
|
||||
// m_GemObjectTexNum[ObjectNum + 3] : 텍스쳐 애니시에 바로 전에 텍스쳐가 갱신되었던 프레임 기억.
|
||||
// Cash 로 인한 문제점 2 해결
|
||||
// Cash 를 함에 있어서 렌더전에 SetCurrentFrame 을 해주어야 한다
|
||||
// 그러므로 gem 이 update되었을 때에만 bUpdateFrame 을 true 로 세팅해주어
|
||||
// Update 해준다.
|
||||
m_GemRender->SetCurrentFrame(m_fRenderFrame,m_GemObjectTexNum,m_dwTick,m_bFirst,m_bUpdateFrame);
|
||||
m_bUpdateFrame = false;
|
||||
}
|
||||
else
|
||||
m_GemRender->SetCurrentFrame(m_fRenderFrame,m_GemObjectTexNum,m_dwTick,m_bFirst,m_bUpdateFrame);
|
||||
if(m_bVisibility)
|
||||
m_GemRender->Render();
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,cullmode);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,zmode);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::LoadFile(char *file)
|
||||
{
|
||||
|
||||
strcpy(m_strMeshFile, file);
|
||||
|
||||
// Cash Load
|
||||
if( ( m_GemRender = LoadCash(file) ) == NULL ) {
|
||||
|
||||
m_GemRender = new CGemRender;
|
||||
m_GemRender->SetLight(m_bLight); //Set Vertex Light
|
||||
|
||||
#ifdef __EFF_WCREATOR__
|
||||
if(!m_GemRender->LoadGemFile(file,m_lpD3DDevice,m_bVisibility))
|
||||
WriteDebug(file);
|
||||
#else
|
||||
m_GemRender->LoadGemFile(file,m_lpD3DDevice,m_bVisibility);
|
||||
#endif
|
||||
|
||||
InputCash(m_GemRender); //Cash List 안에 Mesh가 없다면 Cash List에 input.
|
||||
|
||||
}
|
||||
else { //Cash load
|
||||
if(m_GemRender->m_bDecal) // Decal을 이용한것들은 Vertex Buffer 를 초기화 해준다
|
||||
m_GemRender->SetInitBuffer();
|
||||
|
||||
}
|
||||
// Frame Init
|
||||
//m_GemRender->SetCurrentFrame(0.0f);
|
||||
|
||||
// Texture Load (이팩트 보기옵션이 커져있다가 켜졌을때 캐쉬의 gem 에 texture Load)
|
||||
if(m_bVisibility && (m_GemRender->m_Texture == NULL))
|
||||
m_GemRender->LoadTexture();
|
||||
|
||||
m_GemRender->SetLight(m_bLight); //Set Vertex Light
|
||||
m_GemRender->SetMine(m_Mine);
|
||||
m_GemRender->SetBlend(m_dwSrcBlending, m_dwDestBlending);
|
||||
m_GemRender->SetScale(m_Scale[0],m_Scale[1],m_Scale[2]);
|
||||
m_GemRender->SetCash(false); // Boid 만 킨다
|
||||
|
||||
m_dwObjectNum = m_GemRender->GetObjectNum();
|
||||
|
||||
m_GemObjectTexNum = new int[m_dwObjectNum + 4];
|
||||
m_dwTick = new DWORD[2];
|
||||
m_bFirst = new bool;
|
||||
|
||||
*m_bFirst = false;
|
||||
memset(m_dwTick,0,sizeof(DWORD) * 2);
|
||||
|
||||
memset(m_GemObjectTexNum,0,sizeof(int) * (m_dwObjectNum + 4));
|
||||
m_GemObjectTexNum[m_dwObjectNum + 2] = -1; // Rand Start Ani 를 위한 초기화
|
||||
|
||||
m_moMesh = new MeshObject[m_dwObjectNum];
|
||||
}
|
||||
|
||||
BOOL CX3DEffectMesh::Interpolation(float fFrame)
|
||||
{
|
||||
for(long i = 0; i < m_dwObjectNum; i++)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_moMesh[i].m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// color setting
|
||||
m_GemRender->SetColor(i,m_lColor.r, m_lColor.g, m_lColor.b);
|
||||
//m_GemObjectTexNum[i]++;
|
||||
}
|
||||
|
||||
// current frame setting
|
||||
m_fRenderFrame = fFrame;
|
||||
m_bUpdateFrame = true;
|
||||
//m_GemRender->SetCurrentFrame(fFrame);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
unsigned char len;
|
||||
fread(&len, 1, 1, fp);
|
||||
if(len)
|
||||
{
|
||||
char strTemp[MAX_PATH];
|
||||
fread(strTemp, len, 1, fp);
|
||||
strcpy(m_strMeshFile, strOriginalPath);
|
||||
strcat(m_strMeshFile, strTemp);
|
||||
} else
|
||||
{
|
||||
strcpy(m_strMeshFile, "");
|
||||
}
|
||||
|
||||
LoadFile(m_strMeshFile);
|
||||
|
||||
for(long i = 0; i < m_dwObjectNum; i++)
|
||||
{
|
||||
|
||||
m_moMesh[i].m_lstColor.Load(fp, m_lColor);
|
||||
fread(&m_moMesh[i].m_fTexFrame, 4, 1, fp);
|
||||
|
||||
m_GemRender->SetChangeAniFrame(i,m_moMesh[i].m_fTexFrame);
|
||||
|
||||
fread(&m_moMesh[i].m_fStartTexFrame, 4, 1, fp);
|
||||
m_GemRender->SetStartTexAniFrame(i,m_moMesh[i].m_fStartTexFrame);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
if(strlen(m_strMeshFile))
|
||||
{
|
||||
char strMesh[MAX_PATH], strTemp[MAX_PATH];
|
||||
strcpy(strMesh, m_strMeshFile);
|
||||
if(!strncmp(strMesh, strOriginalPath, strlen(strOriginalPath)))
|
||||
{
|
||||
strcpy(strTemp, &strMesh[strlen(strOriginalPath)]);
|
||||
} else {
|
||||
MessageBox(NULL, "메쉬 폴더가 잘못됐으", "Effect Editor", MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char len = strlen(strTemp) + 1;
|
||||
fwrite(&len, 1, 1, fp);
|
||||
fwrite(strTemp, len, 1, fp);
|
||||
|
||||
for(long i = 0; i < m_dwObjectNum; i++)
|
||||
{
|
||||
m_moMesh[i].m_lstColor.Save(fp);
|
||||
fwrite(&m_moMesh[i].m_fTexFrame, 4, 1, fp);
|
||||
fwrite(&m_moMesh[i].m_fStartTexFrame, 4, 1, fp);
|
||||
}
|
||||
} else
|
||||
{
|
||||
MessageBox(NULL, "메쉬 파일이 잘못됐으", "Effect Editor", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////// Mesh Cash Func Start //////////////////////////////////
|
||||
|
||||
void CX3DEffectMesh::InputCash(CGemRender *pMesh) { // Cash 안에 mesh data input
|
||||
if(m_lstCash.m_Cash.size() > EFF_MAXCASH) {
|
||||
DeleteCash();
|
||||
}
|
||||
_CashNode *pNode;
|
||||
pNode = new _CashNode;
|
||||
pNode->m_pMesh = pMesh;
|
||||
|
||||
pNode->m_nUseCount = 1;
|
||||
m_lstCash.m_Cash.push_back(pNode);
|
||||
m_lstCash.m_nCash++;
|
||||
/*
|
||||
if(m_lstCash.size() > EFF_MAXCASH) {
|
||||
DeleteCash();
|
||||
}
|
||||
_CashNode *pNode;
|
||||
pNode = new _CashNode;
|
||||
pNode->m_pMesh = pMesh;
|
||||
|
||||
pNode->m_nUseCount = 1;
|
||||
m_lstCash.push_back(pNode);
|
||||
|
||||
m_nCash++;
|
||||
*/
|
||||
}
|
||||
void CX3DEffectMesh::SubUseCount(char *strFilename) { //Cash Node의 참조 카운터 감소
|
||||
|
||||
if(strFilename == NULL)
|
||||
return;
|
||||
for(int i=0;i<m_lstCash.m_Cash.size();i++) {
|
||||
if(strstr(m_lstCash.m_Cash[i]->m_pMesh->GetFileName(),strFilename)) {
|
||||
m_lstCash.m_Cash[i]->m_nUseCount--;
|
||||
}
|
||||
}
|
||||
/* if(strFilename == NULL)
|
||||
return;
|
||||
for(int i=0;i<m_lstCash.size();i++) {
|
||||
if(strstr(m_lstCash[i]->m_pMesh->GetFileName(),strFilename)) {
|
||||
m_lstCash[i]->m_nUseCount--;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
CGemRender *CX3DEffectMesh::LoadCash(char *strFilename) { // Cash 안의 mesh load
|
||||
|
||||
if(strFilename == NULL)
|
||||
return NULL;
|
||||
|
||||
for(int i=0;i<m_lstCash.m_Cash.size();i++) {
|
||||
if(!strcmp(m_lstCash.m_Cash[i]->m_pMesh->GetFileName(),strFilename)) {
|
||||
|
||||
m_lstCash.m_Cash[i]->m_nUseCount++;
|
||||
return m_lstCash.m_Cash[i]->m_pMesh;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
if(strFilename == NULL)
|
||||
return NULL;
|
||||
|
||||
for(int i=0;i<m_lstCash.size();i++) {
|
||||
if(strstr(m_lstCash[i]->m_pMesh->GetFileName(),strFilename)) {
|
||||
|
||||
m_lstCash[i]->m_nUseCount++;
|
||||
return m_lstCash[i]->m_pMesh;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
*/
|
||||
/*
|
||||
|
||||
std::map<char*,CGemRender *>::iterator it;
|
||||
|
||||
it = m_lstCash.find( const_cast<char*>(strFilename));
|
||||
|
||||
if( m_lstCash.end() == it )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
*/
|
||||
}
|
||||
void CX3DEffectMesh::DeleteCash() { // Cash 안의 mesh Data delete
|
||||
|
||||
for(int i=0;i<m_lstCash.m_Cash.size();i++) {
|
||||
if(!m_lstCash.m_Cash[i]->m_nUseCount) {
|
||||
delete m_lstCash.m_Cash[i];
|
||||
m_lstCash.m_Cash[i] = NULL;
|
||||
m_lstCash.m_Cash.erase(&(m_lstCash.m_Cash[i]));
|
||||
m_lstCash.m_nCash--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
for(int i=0;i<m_lstCash.size();i++) {
|
||||
if(!m_lstCash[i]->m_nUseCount) {
|
||||
delete m_lstCash[i];
|
||||
m_lstCash[i] = NULL;
|
||||
m_lstCash.erase(&(m_lstCash[i]));
|
||||
m_nCash--;
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
/*
|
||||
void CX3DEffectMesh::DeleteAllCash() { // Cash list 전부 delete
|
||||
|
||||
for(int i=0;i<m_lstCash.m_Cash.size();i++) {
|
||||
delete m_lstCash.m_Cash[i];
|
||||
m_lstCash.m_Cash[i] = NULL;
|
||||
}
|
||||
m_lstCash.m_Cash.clear();
|
||||
m_lstCash.m_nCash = 0;
|
||||
|
||||
/*
|
||||
for(int i=0;i<m_lstCash.size();i++) {
|
||||
delete m_lstCash[i];
|
||||
m_lstCash[i] = NULL;
|
||||
}
|
||||
m_lstCash.clear();
|
||||
m_nCash = 0;
|
||||
*/
|
||||
//}
|
||||
////////////////////////////////// Mesh Cash Func End //////////////////////////////////
|
||||
146
GameTools/Effect/X3DEffectMesh.h
Normal file
146
GameTools/Effect/X3DEffectMesh.h
Normal file
@@ -0,0 +1,146 @@
|
||||
// X3DEffectMesh.h: interface for the CX3DEffectMesh class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTMESH_H__AE1D13FE_1406_41C3_B13A_98825BC9C07C__INCLUDED_)
|
||||
#define AFX_X3DEFFECTMESH_H__AE1D13FE_1406_41C3_B13A_98825BC9C07C__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
#include "CGemRender.h"
|
||||
|
||||
#include <vector>
|
||||
//#include <map>
|
||||
|
||||
#define EFF_MAXCASH 60
|
||||
|
||||
using namespace std;
|
||||
|
||||
class _CashNode { // Mesh Cash List node class
|
||||
public:
|
||||
CGemRender *m_pMesh; // Mesh Data
|
||||
int m_nUseCount; // 이 노드를 이용하는 effect의 갯수(0이 되면 list 에서 삭제 가능)
|
||||
_CashNode() {
|
||||
m_pMesh = NULL;
|
||||
m_nUseCount = 0;
|
||||
}
|
||||
~_CashNode() {
|
||||
if(m_pMesh != NULL) {
|
||||
delete m_pMesh;
|
||||
m_pMesh = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
class CashNode {
|
||||
public:
|
||||
|
||||
vector<_CashNode *> m_Cash;
|
||||
int m_nCash;
|
||||
CashNode() {
|
||||
m_Cash.clear();
|
||||
m_nCash = 0;
|
||||
}
|
||||
~CashNode() {
|
||||
for(int i=0;i<m_Cash.size();i++) {
|
||||
delete m_Cash[i];
|
||||
m_Cash[i] = NULL;
|
||||
}
|
||||
m_Cash.clear();
|
||||
m_nCash = 0;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//typedef vector<_CashNode *> CashNode;
|
||||
|
||||
//typedef std::map<char* ,CGemRender *> CashNode;
|
||||
|
||||
typedef struct _MeshObject
|
||||
{
|
||||
CKeyList<ColorKeyList> m_lstColor;
|
||||
float m_fStartTexFrame;
|
||||
float m_fTexFrame;
|
||||
} MeshObject;
|
||||
|
||||
class CX3DEffectMesh : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
|
||||
bool m_bUpdateFrame;
|
||||
|
||||
char m_strMeshFile[MAX_PATH];
|
||||
// CEffectMesh *Mesh;
|
||||
CGemRender *m_GemRender;
|
||||
float m_fRenderFrame; // Render 되어야 할 Frame
|
||||
static CashNode m_lstCash; // Mesh cash list
|
||||
// static int m_nCash; // Mesh cash Num
|
||||
int *m_GemObjectTexNum; // Gem Object Texture Num
|
||||
DWORD *m_dwTick;
|
||||
bool *m_bFirst;
|
||||
public:
|
||||
unsigned long m_dwObjectNum;
|
||||
MeshObject *m_moMesh;
|
||||
|
||||
public:
|
||||
CX3DEffectMesh();
|
||||
virtual ~CX3DEffectMesh();
|
||||
|
||||
// Mesh Cash Func
|
||||
CGemRender *LoadCash(char *strFilename); // Cash 안의 mesh load
|
||||
void InputCash(CGemRender *); // Cash 안에 mesh data input
|
||||
void DeleteCash(); // Cash 안의 mesh Data delete
|
||||
//static void DeleteAllCash(); // Cash 전부 delete
|
||||
void SubUseCount(char *strFilename); // Cash 참조 카운터 1 감소
|
||||
|
||||
unsigned long GetMaxFrame(void) { return (unsigned long)m_GemRender->GetMaxFrame(); }
|
||||
|
||||
void SetSrcBlending(unsigned long dwSrcBlending)
|
||||
{
|
||||
m_dwSrcBlending = dwSrcBlending;
|
||||
// Mesh->SetBlend(m_dwSrcBlending, m_dwDestBlending);
|
||||
m_GemRender->SetSrcBlend(m_dwSrcBlending);
|
||||
}
|
||||
void SetDestBlending(unsigned long dwDestBlending)
|
||||
{
|
||||
m_dwDestBlending = dwDestBlending;
|
||||
// Mesh->SetBlend(m_dwSrcBlending, m_dwDestBlending);
|
||||
m_GemRender->SetDstBlend(m_dwDestBlending);
|
||||
}
|
||||
|
||||
void SetTexFrame(unsigned long dwObjectNum, float fTexFrame)
|
||||
{
|
||||
m_moMesh[dwObjectNum].m_fTexFrame = fTexFrame;
|
||||
// Mesh->SetTexAniFrame(dwObjectNum, fTexFrame);
|
||||
m_GemRender->SetChangeAniFrame(dwObjectNum, fTexFrame);
|
||||
}
|
||||
float GetTexFrame(unsigned long dwObjectNum) { return m_moMesh[dwObjectNum].m_fTexFrame; }
|
||||
|
||||
void SetStartTexFrame(unsigned long dwObjectNum, float fStartTexFrame)
|
||||
{
|
||||
m_moMesh[dwObjectNum].m_fStartTexFrame = fStartTexFrame;
|
||||
m_GemRender->SetStartTexAniFrame(dwObjectNum,fStartTexFrame);
|
||||
// Mesh->SetStartTexAni(dwObjectNum, fStartTexFrame);
|
||||
}
|
||||
float GetStartTexFrame(unsigned long dwObjectNum) { return m_moMesh[dwObjectNum].m_fStartTexFrame; }
|
||||
|
||||
void SetObjectColor(unsigned long dwObjectNum)
|
||||
{
|
||||
// Mesh->SetPickColor(dwObjectNum, r, g, b, a);
|
||||
// Mesh->SetPickNum(dwObjectNum);
|
||||
m_GemRender->SetPickObject(dwObjectNum);
|
||||
}
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer();
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
|
||||
void LoadFile(char *file);
|
||||
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTMESH_H__AE1D13FE_1406_41C3_B13A_98825BC9C07C__INCLUDED_)
|
||||
769
GameTools/Effect/X3DEffectParticle.cpp
Normal file
769
GameTools/Effect/X3DEffectParticle.cpp
Normal file
@@ -0,0 +1,769 @@
|
||||
// X3DEffectParticle.cpp: implementation of the CX3DEffectParticle class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectParticle.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectParticle::CX3DEffectParticle()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
m_lpVerticeIndex = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectParticle::~CX3DEffectParticle()
|
||||
{
|
||||
if(m_lpVerticeInfo) { delete[] m_lpVerticeInfo; m_lpVerticeInfo = NULL; }
|
||||
if(m_lpVerticeIndex) { m_lpVerticeIndex->Release(); m_lpVerticeIndex = NULL; }
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
|
||||
m_lpVerticeInfo = NULL;
|
||||
|
||||
m_dwMaxAmount = m_dwDrawAmount = 0;
|
||||
|
||||
m_dwVolumeType = 0;
|
||||
m_fVolX = m_fVolY = m_fVolZ = m_fRadius = m_fInnerRadius = 0.0f;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectParticle::CreateBuffer(void)
|
||||
{
|
||||
FloatKeyList::iterator fIt;
|
||||
unsigned long i;
|
||||
|
||||
m_dwMaxAmount = m_dwDrawAmount = 0;
|
||||
for(fIt = m_lstAmount.Begin(); fIt != m_lstAmount.End(); fIt++)
|
||||
{
|
||||
m_dwMaxAmount += ((*fIt).second);
|
||||
}
|
||||
|
||||
if(m_lpVerticeInfo) { delete[] m_lpVerticeInfo; m_lpVerticeInfo = NULL; }
|
||||
if(m_lpVerticeIndex) { m_lpVerticeIndex->Release(); m_lpVerticeIndex = NULL; }
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
m_lpD3DDevice->CreateVertexBuffer( m_dwMaxAmount * 4 * sizeof(LVertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT , &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( m_dwMaxAmount * 4 * sizeof(LVertex), D3DUSAGE_DYNAMIC |D3DUSAGE_WRITEONLY, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
m_lpD3DDevice->CreateIndexBuffer( m_dwMaxAmount * 2 * 3 * sizeof(unsigned short), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16,
|
||||
D3DPOOL_MANAGED, &m_lpVerticeIndex);
|
||||
m_lpVerticeInfo = new Particle[m_dwMaxAmount];
|
||||
|
||||
unsigned short *pVerticeIndex;
|
||||
m_lpVerticeIndex->Lock(0, m_dwMaxAmount * 2 * 3 * sizeof(unsigned short), (unsigned char **)&pVerticeIndex, 0);
|
||||
|
||||
for(i = 0; i < m_dwMaxAmount; i++)
|
||||
{
|
||||
m_lpVerticeInfo[i].fLifetime = -1.0f;
|
||||
|
||||
pVerticeIndex[i * 6 + 0] = i * 4 + 0;
|
||||
pVerticeIndex[i * 6 + 1] = i * 4 + 1;
|
||||
pVerticeIndex[i * 6 + 2] = i * 4 + 2;
|
||||
|
||||
pVerticeIndex[i * 6 + 3] = i * 4 + 1;
|
||||
pVerticeIndex[i * 6 + 4] = i * 4 + 3;
|
||||
pVerticeIndex[i * 6 + 5] = i * 4 + 2;
|
||||
}
|
||||
|
||||
m_lpVerticeIndex->Unlock();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectParticle::CreateParticle(LPParticle lpParticle)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
if(m_lpVerticeInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
for(i = 0; i < m_dwMaxAmount; i++)
|
||||
{
|
||||
if(m_lpVerticeInfo[i].fLifetime > 0.0f) continue;
|
||||
|
||||
m_lpVerticeInfo[i].vecPos = lpParticle->vecPos;
|
||||
m_lpVerticeInfo[i].vecVel = lpParticle->vecVel;
|
||||
m_lpVerticeInfo[i].lColor = lpParticle->lColor;
|
||||
m_lpVerticeInfo[i].fRotation = lpParticle->fRotation;
|
||||
m_lpVerticeInfo[i].dwRotationCount = rand() % 128;
|
||||
m_lpVerticeInfo[i].fWidth = lpParticle->fWidth;
|
||||
m_lpVerticeInfo[i].fHeight = lpParticle->fHeight;
|
||||
m_lpVerticeInfo[i].fMaxLife = m_lpVerticeInfo[i].fLifetime = lpParticle->fLifetime;
|
||||
m_lpVerticeInfo[i].fTexFrame = lpParticle->fTexFrame;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::SetVolumeNone(void)
|
||||
{
|
||||
m_dwVolumeType = 0;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::SetVolumeSquare(float fVolX, float fVolY, float fVolZ)
|
||||
{
|
||||
m_dwVolumeType = 1;
|
||||
m_fVolX = fVolX;
|
||||
m_fVolY = fVolY;
|
||||
m_fVolZ = fVolZ;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::SetVolumeCircle(float fRadius, float fInnerRadius)
|
||||
{
|
||||
m_dwVolumeType = 2;
|
||||
m_fRadius = fRadius;
|
||||
m_fInnerRadius = fInnerRadius;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
|
||||
if(m_lpVertices == NULL) return;
|
||||
DWORD cullmode,zmode;
|
||||
DWORD amode;
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_ZWRITEENABLE,&zmode);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_ALPHABLENDENABLE,&amode);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_CULLMODE,&cullmode);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_COLORARG1,D3DTA_DIFFUSE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_COLORARG2,D3DTA_TEXTURE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1,D3DTSS_COLOROP,D3DTOP_DISABLE);
|
||||
CSceneStateMgr::_SetD3DTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
|
||||
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
if(m_dwDrawAmount)
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwDrawAmount * 4, 0, m_dwDrawAmount * 2);
|
||||
/**/
|
||||
if(m_fTexSpeed)
|
||||
{
|
||||
// CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
// CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
if(m_dwDrawAmount)
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwDrawAmount * 4, 0, m_dwDrawAmount * 2);
|
||||
}//***/
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,zmode);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_CULLMODE,cullmode);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ALPHABLENDENABLE,amode);
|
||||
|
||||
}
|
||||
|
||||
BOOL CX3DEffectParticle::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
float local_volx;
|
||||
float local_voly;
|
||||
float local_volz;
|
||||
float local_rad;
|
||||
float local_inrad;
|
||||
|
||||
if(m_lpVertices == NULL) return FALSE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
float fTempFrame;
|
||||
|
||||
fTempFrame = ((CX3DEffect *)m_lpLocalEffect)->GetFrame();
|
||||
if(m_StopParticleFrame != -1) {
|
||||
// extension3 :: mid effect 의 파티클이 end effect 가 끝나더라도 계속 자신의 생명이
|
||||
// 끝날때 까지 유지
|
||||
|
||||
if(!m_lstCenter.Interpolation(fTempFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstEForce.Interpolation(fTempFrame, m_vecEForce)) return FALSE;
|
||||
if(!m_lstAlpha.Interpolation(fTempFrame, m_fAlpha)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fTempFrame, m_quatAxis)) return FALSE;
|
||||
if(!m_lstDirection.InterpolationQ(fTempFrame, m_quatDir)) return FALSE;
|
||||
if(!m_lstPower.Interpolation(fTempFrame, m_fPower)) return FALSE;
|
||||
if(!m_lstAngle.Interpolation(fTempFrame, m_fAngle)) return FALSE;
|
||||
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(m_bWorldEffect) {
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
|
||||
m_fPower *=m_Scale[0];
|
||||
m_vecEForce.x *=m_Scale[0];
|
||||
m_vecEForce.y *=m_Scale[0];
|
||||
m_vecEForce.z *=m_Scale[0];
|
||||
|
||||
m_fAngle *=m_Scale[0];
|
||||
|
||||
local_volx= m_fVolX * m_Scale[0];
|
||||
local_voly = m_fVolY * m_Scale[0];
|
||||
local_volz = m_fVolZ * m_Scale[0];
|
||||
local_rad = m_fRadius * m_Scale[0];
|
||||
local_inrad = m_fInnerRadius * m_Scale[0];
|
||||
|
||||
}
|
||||
else {
|
||||
local_volx = m_fVolX;
|
||||
local_voly = m_fVolY;
|
||||
local_volz = m_fVolZ;
|
||||
local_rad = m_fRadius;
|
||||
local_inrad = m_fInnerRadius;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
local_volx = m_fVolX;
|
||||
local_voly = m_fVolY;
|
||||
local_volz = m_fVolZ;
|
||||
local_rad = m_fRadius;
|
||||
local_inrad = m_fInnerRadius;
|
||||
|
||||
}
|
||||
if(m_bVisibility) {
|
||||
matrix *matView = ((CX3DEffect *)m_lpLocalEffect)->GetViewMatrix();
|
||||
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
if(FAILED( m_lpVertices->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
|
||||
m_dwDrawAmount = 0;
|
||||
unsigned long mul;
|
||||
float w, h, d, degree, cosx, siny;
|
||||
vector3 vecCenter, pVer[4];
|
||||
|
||||
if(m_lpVerticeInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
for(unsigned long i = 0; i < m_dwMaxAmount; i++)
|
||||
{
|
||||
|
||||
if(m_lpVerticeInfo[i].fLifetime < 0.0f) continue;
|
||||
else if(m_lpVerticeInfo[i].fLifetime < ((CX3DEffect *)m_lpLocalEffect)->GetIncFrame())
|
||||
m_lpVerticeInfo[i].fLifetime = 0.0f;
|
||||
|
||||
m_lpVerticeInfo[i].vecVel += m_vecEForce;
|
||||
m_lpVerticeInfo[i].vecPos += m_lpVerticeInfo[i].vecVel;
|
||||
|
||||
if(!ParticleInterpolation(i)) return FALSE;
|
||||
|
||||
w = m_lpVerticeInfo[i].fWidth / 2;
|
||||
h = m_lpVerticeInfo[i].fHeight / 2;
|
||||
|
||||
d = m_lpVerticeInfo[i].fRotation * m_lpVerticeInfo[i].dwRotationCount;
|
||||
degree = d - (((unsigned long)(d / 360)) * 360.0f);
|
||||
cosx = cosf(degree);
|
||||
siny = sinf(degree);
|
||||
|
||||
mul = m_dwDrawAmount << 2;
|
||||
|
||||
pVer[0] = vector3(-w * cosx - h * siny, -w * siny + h * cosx, 0.0f);
|
||||
pVer[1] = vector3(w * cosx - h * siny, w * siny + h * cosx, 0.0f);
|
||||
pVer[2] = vector3(-w * cosx + h * siny, -w * siny - h * cosx, 0.0f);
|
||||
pVer[3] = vector3(w * cosx + h * siny, w * siny - h * cosx, 0.0f);
|
||||
|
||||
/* if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
{
|
||||
z3d::VectorRotate(pVer[0], pVer[0], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[1], pVer[1], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[2], pVer[2], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[3], pVer[3], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
}*/
|
||||
|
||||
pVertices[mul + 0].v = vector3(pVer[0].x * matView->_11 + pVer[0].y * matView->_12, pVer[0].x * matView->_21 + pVer[0].y * matView->_22, pVer[0].x * matView->_31 + pVer[0].y * matView->_32);
|
||||
pVertices[mul + 1].v = vector3(pVer[1].x * matView->_11 + pVer[1].y * matView->_12, pVer[1].x * matView->_21 + pVer[1].y * matView->_22, pVer[1].x * matView->_31 + pVer[1].y * matView->_32);
|
||||
pVertices[mul + 2].v = vector3(pVer[2].x * matView->_11 + pVer[2].y * matView->_12, pVer[2].x * matView->_21 + pVer[2].y * matView->_22, pVer[2].x * matView->_31 + pVer[2].y * matView->_32);
|
||||
pVertices[mul + 3].v = vector3(pVer[3].x * matView->_11 + pVer[3].y * matView->_12, pVer[3].x * matView->_21 + pVer[3].y * matView->_22, pVer[3].x * matView->_31 + pVer[3].y * matView->_32);
|
||||
|
||||
pVertices[mul + 0].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 1].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 2].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 3].v += m_lpVerticeInfo[i].vecPos;
|
||||
|
||||
pVertices[mul + 0].diff = pVertices[mul + 1].diff =
|
||||
pVertices[mul + 2].diff = pVertices[mul + 3].diff = m_lpVerticeInfo[i].lColor;
|
||||
|
||||
pVertices[mul + 3].diff.a *= m_fAlpha;
|
||||
pVertices[mul + 0].diff.a = pVertices[mul + 1].diff.a =
|
||||
pVertices[mul + 2].diff.a = pVertices[mul + 3].diff.a;
|
||||
|
||||
|
||||
pVertices[mul + 0].spec = pVertices[mul + 1].spec =
|
||||
pVertices[mul + 2].spec = pVertices[mul + 3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
if(m_fTexSpeed)
|
||||
{
|
||||
pVerticesBlend[mul + 0].v = pVertices[mul + 0].v;
|
||||
pVerticesBlend[mul + 1].v = pVertices[mul + 1].v;
|
||||
pVerticesBlend[mul + 2].v = pVertices[mul + 2].v;
|
||||
pVerticesBlend[mul + 3].v = pVertices[mul + 3].v;
|
||||
|
||||
pVerticesBlend[mul + 0].diff = pVerticesBlend[mul + 1].diff =
|
||||
pVerticesBlend[mul + 2].diff = pVerticesBlend[mul + 3].diff = pVertices[mul + 0].diff;
|
||||
|
||||
pVerticesBlend[mul + 0].spec = pVerticesBlend[mul + 1].spec =
|
||||
pVerticesBlend[mul + 2].spec = pVerticesBlend[mul + 3].spec = pVertices[mul + 0].spec;
|
||||
|
||||
long t = (long)m_lpVerticeInfo[i].fTexFrame;
|
||||
float f1 = (t % 4) * 0.25;
|
||||
float f2 = (t / 4) * 0.25;
|
||||
pVertices[mul + 0].tu = f1; pVertices[mul + 0].tv = f2;
|
||||
pVertices[mul + 1].tu = f1 + 0.25f; pVertices[mul + 1].tv = f2;
|
||||
pVertices[mul + 2].tu = f1; pVertices[mul + 2].tv = f2 + 0.25f;
|
||||
pVertices[mul + 3].tu = f1 + 0.25f; pVertices[mul + 3].tv = f2 + 0.25f;
|
||||
|
||||
if(15 == t) { if(0.16f < m_fTexSpeed) t = 0; else t = 15; } else t++;
|
||||
f1 = (t % 4) * 0.25;
|
||||
f2 = (t / 4) * 0.25;
|
||||
pVerticesBlend[mul + 0].tu = f1; pVerticesBlend[mul + 0].tv = f2;
|
||||
pVerticesBlend[mul + 1].tu = f1 + 0.25f; pVerticesBlend[mul + 1].tv = f2;
|
||||
pVerticesBlend[mul + 2].tu = f1; pVerticesBlend[mul + 2].tv = f2 + 0.25f;
|
||||
pVerticesBlend[mul + 3].tu = f1 + 0.25f; pVerticesBlend[mul + 3].tv = f2 + 0.25f;
|
||||
|
||||
///////////////////////////////////////////
|
||||
// float fAlpha = ;
|
||||
pVertices[mul + 3].diff.a *= (floorf(m_lpVerticeInfo[i].fTexFrame + 1.0f) - m_lpVerticeInfo[i].fTexFrame);
|
||||
pVertices[mul + 0].diff.a = pVertices[mul + 1].diff.a = pVertices[mul + 2].diff.a = pVertices[mul + 3].diff.a;
|
||||
|
||||
pVerticesBlend[mul + 3].diff.a *= (m_lpVerticeInfo[i].fTexFrame - floorf(m_lpVerticeInfo[i].fTexFrame));
|
||||
// pVerticesBlend[mul + 3].diff.a *= (1.0f - fAlpha);
|
||||
pVerticesBlend[mul + 0].diff.a = pVerticesBlend[mul + 1].diff.a = pVerticesBlend[mul + 2].diff.a = pVerticesBlend[mul + 3].diff.a;
|
||||
///////////////////////////////////////////
|
||||
} else
|
||||
{
|
||||
pVertices[mul + 0].tu = 0.0f; pVertices[mul + 0].tv = 0.0f;
|
||||
pVertices[mul + 1].tu = 1.0f; pVertices[mul + 1].tv = 0.0f;
|
||||
pVertices[mul + 2].tu = 0.0f; pVertices[mul + 2].tv = 1.0f;
|
||||
pVertices[mul + 3].tu = 1.0f; pVertices[mul + 3].tv = 1.0f;
|
||||
}
|
||||
|
||||
m_lpVerticeInfo[i].fLifetime -= ((CX3DEffect *)m_lpLocalEffect)->GetIncFrame();
|
||||
m_lpVerticeInfo[i].dwRotationCount++;
|
||||
|
||||
// 알파값이 5이하이면 draw list에서 제외
|
||||
if((pVertices[mul +3].diff.a)<1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_dwDrawAmount++;
|
||||
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
} //if(m_bVisibility)
|
||||
|
||||
}
|
||||
else { // 일반 particle
|
||||
|
||||
if(!m_lstCenter.Interpolation(fTempFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstEForce.Interpolation(fTempFrame, m_vecEForce)) return FALSE;
|
||||
if(!m_lstAlpha.Interpolation(fTempFrame, m_fAlpha)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fTempFrame, m_quatAxis)) return FALSE;
|
||||
if(!m_lstDirection.InterpolationQ(fTempFrame, m_quatDir)) return FALSE;
|
||||
if(!m_lstPower.Interpolation(fTempFrame, m_fPower)) return FALSE;
|
||||
if(!m_lstAngle.Interpolation(fTempFrame, m_fAngle)) return FALSE;
|
||||
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(m_bWorldEffect) {
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
|
||||
m_fPower *=m_Scale[0];
|
||||
m_vecEForce.x *=m_Scale[0];
|
||||
m_vecEForce.y *=m_Scale[0];
|
||||
m_vecEForce.z *=m_Scale[0];
|
||||
|
||||
m_fAngle *=m_Scale[0];
|
||||
|
||||
local_volx= m_fVolX * m_Scale[0];
|
||||
local_voly = m_fVolY * m_Scale[0];
|
||||
local_volz = m_fVolZ * m_Scale[0];
|
||||
local_rad = m_fRadius * m_Scale[0];
|
||||
local_inrad = m_fInnerRadius * m_Scale[0];
|
||||
|
||||
}
|
||||
else {
|
||||
local_volx = m_fVolX;
|
||||
local_voly = m_fVolY;
|
||||
local_volz = m_fVolZ;
|
||||
local_rad = m_fRadius;
|
||||
local_inrad = m_fInnerRadius;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
local_volx = m_fVolX;
|
||||
local_voly = m_fVolY;
|
||||
local_volz = m_fVolZ;
|
||||
local_rad = m_fRadius;
|
||||
local_inrad = m_fInnerRadius;
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(m_bVisibility) {
|
||||
float fAmount;
|
||||
Particle pNewParticle;
|
||||
|
||||
if(m_lstAmount.Find(fTempFrame, fAmount))
|
||||
{
|
||||
float a, b, r, c, a1, p;
|
||||
|
||||
a1 = FLOAT_PHI / fAmount;
|
||||
c = ((2 * FLOAT_PHI) / fAmount);
|
||||
|
||||
for(unsigned long i = 0; i < (unsigned long)fAmount; i++)
|
||||
{
|
||||
p = m_fPower * (1.0f - m_fPowerSeed * (1.0f - (((float)rand()) / RAND_MAX) * 2.0f));
|
||||
a = (m_fAngle * (((float)rand()) / RAND_MAX));
|
||||
b = c * i;
|
||||
r = p * sinf(a);
|
||||
|
||||
pNewParticle.vecVel = vector3(r * cosf(b), p * cosf(a), r * sinf(b));
|
||||
z3d::VectorRotate(pNewParticle.vecVel, pNewParticle.vecVel, m_quatDir);
|
||||
z3d::VectorRotate(pNewParticle.vecVel, pNewParticle.vecVel, m_quatAxis);
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
z3d::VectorRotate(pNewParticle.vecVel, pNewParticle.vecVel, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
pNewParticle.fMaxLife = pNewParticle.fLifetime = m_fLifetime * (1.0f - m_fLifetimeSeed * (1.0f - (((float)rand()) / RAND_MAX) * 2.0f));
|
||||
|
||||
pNewParticle.fRotation = m_fRotation * (1.0f - m_fPowerSeed * (1.0f - (((float)rand()) / RAND_MAX) * 2.0f));
|
||||
pNewParticle.fTexFrame = 01.0;
|
||||
|
||||
switch(m_dwVolumeType)
|
||||
{
|
||||
case 0:
|
||||
pNewParticle.vecPos = m_vecCenter;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
pNewParticle.vecPos = vector3(((float)rand() / RAND_MAX) * local_volx,
|
||||
((float)rand() / RAND_MAX) * local_voly,
|
||||
((float)rand() / RAND_MAX) * local_volz) - vector3(local_volx / 2, local_voly / 2, local_volz / 2);
|
||||
z3d::VectorRotate(pNewParticle.vecPos, pNewParticle.vecPos, m_quatAxis);
|
||||
pNewParticle.vecPos += m_vecCenter;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
float degree = 2.0f * FLOAT_PHI * (((float)rand()) / RAND_MAX);
|
||||
float radius = local_inrad + (local_rad - local_inrad * (((float)rand()) / RAND_MAX));
|
||||
|
||||
pNewParticle.vecPos = vector3(radius * cosf(degree), 0, radius * sinf(degree));
|
||||
z3d::VectorRotate(pNewParticle.vecPos, pNewParticle.vecPos, m_quatAxis);
|
||||
pNewParticle.vecPos += m_vecCenter;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis()) z3d::VectorRotate(pNewParticle.vecPos, pNewParticle.vecPos, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter()) pNewParticle.vecPos += (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
|
||||
CreateParticle(&pNewParticle);
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
matrix *matView = ((CX3DEffect *)m_lpLocalEffect)->GetViewMatrix();
|
||||
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
if(FAILED( m_lpVertices->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVertices, 0 ) ) )
|
||||
return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, 0 ) ) )
|
||||
return FALSE;
|
||||
|
||||
m_dwDrawAmount = 0;
|
||||
unsigned long mul;
|
||||
float w, h, d, degree, cosx, siny;
|
||||
vector3 vecCenter, pVer[4];
|
||||
|
||||
if(m_lpVerticeInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
for(unsigned long i = 0; i < m_dwMaxAmount; i++)
|
||||
{
|
||||
|
||||
if(m_lpVerticeInfo[i].fLifetime < 0.0f) continue;
|
||||
else if(m_lpVerticeInfo[i].fLifetime < ((CX3DEffect *)m_lpLocalEffect)->GetIncFrame())
|
||||
m_lpVerticeInfo[i].fLifetime = 0.0f;
|
||||
|
||||
m_lpVerticeInfo[i].vecVel += m_vecEForce;
|
||||
m_lpVerticeInfo[i].vecPos += m_lpVerticeInfo[i].vecVel;
|
||||
|
||||
if(!ParticleInterpolation(i)) return FALSE;
|
||||
|
||||
w = m_lpVerticeInfo[i].fWidth / 2;
|
||||
h = m_lpVerticeInfo[i].fHeight / 2;
|
||||
|
||||
d = m_lpVerticeInfo[i].fRotation * m_lpVerticeInfo[i].dwRotationCount;
|
||||
degree = d - (((unsigned long)(d / 360)) * 360.0f);
|
||||
cosx = cosf(degree);
|
||||
siny = sinf(degree);
|
||||
|
||||
mul = m_dwDrawAmount << 2;
|
||||
|
||||
pVer[0] = vector3(-w * cosx - h * siny, -w * siny + h * cosx, 0.0f);
|
||||
pVer[1] = vector3(w * cosx - h * siny, w * siny + h * cosx, 0.0f);
|
||||
pVer[2] = vector3(-w * cosx + h * siny, -w * siny - h * cosx, 0.0f);
|
||||
pVer[3] = vector3(w * cosx + h * siny, w * siny - h * cosx, 0.0f);
|
||||
|
||||
/* if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
{
|
||||
z3d::VectorRotate(pVer[0], pVer[0], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[1], pVer[1], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[2], pVer[2], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[3], pVer[3], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
}*/
|
||||
|
||||
pVertices[mul + 0].v = vector3(pVer[0].x * matView->_11 + pVer[0].y * matView->_12, pVer[0].x * matView->_21 + pVer[0].y * matView->_22, pVer[0].x * matView->_31 + pVer[0].y * matView->_32);
|
||||
pVertices[mul + 1].v = vector3(pVer[1].x * matView->_11 + pVer[1].y * matView->_12, pVer[1].x * matView->_21 + pVer[1].y * matView->_22, pVer[1].x * matView->_31 + pVer[1].y * matView->_32);
|
||||
pVertices[mul + 2].v = vector3(pVer[2].x * matView->_11 + pVer[2].y * matView->_12, pVer[2].x * matView->_21 + pVer[2].y * matView->_22, pVer[2].x * matView->_31 + pVer[2].y * matView->_32);
|
||||
pVertices[mul + 3].v = vector3(pVer[3].x * matView->_11 + pVer[3].y * matView->_12, pVer[3].x * matView->_21 + pVer[3].y * matView->_22, pVer[3].x * matView->_31 + pVer[3].y * matView->_32);
|
||||
|
||||
pVertices[mul + 0].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 1].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 2].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 3].v += m_lpVerticeInfo[i].vecPos;
|
||||
|
||||
pVertices[mul + 0].diff = pVertices[mul + 1].diff =
|
||||
pVertices[mul + 2].diff = pVertices[mul + 3].diff = m_lpVerticeInfo[i].lColor;
|
||||
|
||||
pVertices[mul + 3].diff.a *= m_fAlpha;
|
||||
pVertices[mul + 0].diff.a = pVertices[mul + 1].diff.a =
|
||||
pVertices[mul + 2].diff.a = pVertices[mul + 3].diff.a;
|
||||
|
||||
|
||||
pVertices[mul + 0].spec = pVertices[mul + 1].spec =
|
||||
pVertices[mul + 2].spec = pVertices[mul + 3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
if(m_fTexSpeed)
|
||||
{
|
||||
pVerticesBlend[mul + 0].v = pVertices[mul + 0].v;
|
||||
pVerticesBlend[mul + 1].v = pVertices[mul + 1].v;
|
||||
pVerticesBlend[mul + 2].v = pVertices[mul + 2].v;
|
||||
pVerticesBlend[mul + 3].v = pVertices[mul + 3].v;
|
||||
|
||||
pVerticesBlend[mul + 0].diff = pVerticesBlend[mul + 1].diff =
|
||||
pVerticesBlend[mul + 2].diff = pVerticesBlend[mul + 3].diff = pVertices[mul + 0].diff;
|
||||
|
||||
pVerticesBlend[mul + 0].spec = pVerticesBlend[mul + 1].spec =
|
||||
pVerticesBlend[mul + 2].spec = pVerticesBlend[mul + 3].spec = pVertices[mul + 0].spec;
|
||||
|
||||
long t = (long)m_lpVerticeInfo[i].fTexFrame;
|
||||
float f1 = (t % 4) * 0.25;
|
||||
float f2 = (t / 4) * 0.25;
|
||||
pVertices[mul + 0].tu = f1; pVertices[mul + 0].tv = f2;
|
||||
pVertices[mul + 1].tu = f1 + 0.25f; pVertices[mul + 1].tv = f2;
|
||||
pVertices[mul + 2].tu = f1; pVertices[mul + 2].tv = f2 + 0.25f;
|
||||
pVertices[mul + 3].tu = f1 + 0.25f; pVertices[mul + 3].tv = f2 + 0.25f;
|
||||
|
||||
if(15 == t) { if(0.16f < m_fTexSpeed) t = 0; else t = 15; } else t++;
|
||||
f1 = (t % 4) * 0.25;
|
||||
f2 = (t / 4) * 0.25;
|
||||
pVerticesBlend[mul + 0].tu = f1; pVerticesBlend[mul + 0].tv = f2;
|
||||
pVerticesBlend[mul + 1].tu = f1 + 0.25f; pVerticesBlend[mul + 1].tv = f2;
|
||||
pVerticesBlend[mul + 2].tu = f1; pVerticesBlend[mul + 2].tv = f2 + 0.25f;
|
||||
pVerticesBlend[mul + 3].tu = f1 + 0.25f; pVerticesBlend[mul + 3].tv = f2 + 0.25f;
|
||||
|
||||
///////////////////////////////////////////
|
||||
// float fAlpha = ;
|
||||
pVertices[mul + 3].diff.a *= (floorf(m_lpVerticeInfo[i].fTexFrame + 1.0f) - m_lpVerticeInfo[i].fTexFrame);
|
||||
pVertices[mul + 0].diff.a = pVertices[mul + 1].diff.a = pVertices[mul + 2].diff.a = pVertices[mul + 3].diff.a;
|
||||
|
||||
pVerticesBlend[mul + 3].diff.a *= (m_lpVerticeInfo[i].fTexFrame - floorf(m_lpVerticeInfo[i].fTexFrame));
|
||||
// pVerticesBlend[mul + 3].diff.a *= (1.0f - fAlpha);
|
||||
pVerticesBlend[mul + 0].diff.a = pVerticesBlend[mul + 1].diff.a = pVerticesBlend[mul + 2].diff.a = pVerticesBlend[mul + 3].diff.a;
|
||||
///////////////////////////////////////////
|
||||
} else
|
||||
{
|
||||
pVertices[mul + 0].tu = 0.0f; pVertices[mul + 0].tv = 0.0f;
|
||||
pVertices[mul + 1].tu = 1.0f; pVertices[mul + 1].tv = 0.0f;
|
||||
pVertices[mul + 2].tu = 0.0f; pVertices[mul + 2].tv = 1.0f;
|
||||
pVertices[mul + 3].tu = 1.0f; pVertices[mul + 3].tv = 1.0f;
|
||||
}
|
||||
|
||||
m_lpVerticeInfo[i].fLifetime -= ((CX3DEffect *)m_lpLocalEffect)->GetIncFrame();
|
||||
m_lpVerticeInfo[i].dwRotationCount++;
|
||||
|
||||
// 알파값이 1이하이면 draw list에서 제외
|
||||
if((pVertices[mul +3].diff.a)<1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_dwDrawAmount++;
|
||||
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
} //if(m_bVisibility)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectParticle::ParticleInterpolation(unsigned long dwNumber)
|
||||
{
|
||||
if(m_lpVerticeInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
float fFrame = 100.0f * (1.0f - (m_lpVerticeInfo[dwNumber].fLifetime / m_lpVerticeInfo[dwNumber].fMaxLife));
|
||||
|
||||
if(!m_lstWidth.Interpolation(fFrame, m_lpVerticeInfo[dwNumber].fWidth)) return FALSE;
|
||||
if(!m_lstHeight.Interpolation(fFrame, m_lpVerticeInfo[dwNumber].fHeight)) return FALSE;
|
||||
m_lpVerticeInfo[dwNumber].fWidth *=m_Scale[0];
|
||||
m_lpVerticeInfo[dwNumber].fHeight *=m_Scale[0];
|
||||
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lpVerticeInfo[dwNumber].lColor)) return FALSE;
|
||||
|
||||
if(m_fTexSpeed)
|
||||
{
|
||||
if(fFrame == 100.0f)
|
||||
{
|
||||
m_lpVerticeInfo[dwNumber].fTexFrame = 15.0f;
|
||||
} else
|
||||
{
|
||||
float a = fFrame * m_fTexSpeed;
|
||||
m_lpVerticeInfo[dwNumber].fTexFrame = a - (((unsigned long)(a / 16)) * 16.0f);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
fread(&m_fPowerSeed, 4, 1, fp);
|
||||
fread(&m_fLifetime, 4, 1, fp);
|
||||
fread(&m_fLifetimeSeed, 4, 1, fp);
|
||||
|
||||
fread(&m_fRotation, 4, 1, fp);
|
||||
fread(&m_fTexSpeed, 4, 1, fp);
|
||||
|
||||
// 볼륨
|
||||
fread(&m_dwVolumeType, 4, 1, fp); // 0 : None, 1 : Square, 2 : Circle
|
||||
fread(&m_fVolX, 4, 1, fp);
|
||||
fread(&m_fVolY, 4, 1, fp);
|
||||
fread(&m_fVolZ, 4, 1, fp);
|
||||
fread(&m_fRadius, 4, 1, fp);
|
||||
fread(&m_fInnerRadius, 4, 1, fp);
|
||||
if(m_bWorldEffect) {
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fVolX *=m_Scale[0];
|
||||
m_fVolY *=m_Scale[0];
|
||||
m_fVolZ *=m_Scale[0];
|
||||
m_fRadius *=m_Scale[0];
|
||||
m_fInnerRadius *=m_Scale[0];
|
||||
}
|
||||
}
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
float fAmount;
|
||||
m_lstAmount.Load(fp, fAmount);
|
||||
m_lstAlpha.Load(fp, m_fAlpha);
|
||||
m_lstPower.Load(fp, m_fPower);
|
||||
m_lstAngle.Load(fp, m_fAngle);
|
||||
m_lstEForce.Load(fp, m_vecEForce);
|
||||
if(m_bWorldEffect) {
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fPower *=m_Scale[0];
|
||||
m_vecEForce.x *=m_Scale[0];
|
||||
m_vecEForce.y *=m_Scale[0];
|
||||
m_vecEForce.z *=m_Scale[0];
|
||||
}
|
||||
}
|
||||
m_lstDirection.Load(fp, m_quatDir);
|
||||
|
||||
// Scenario용 리스트
|
||||
m_lstWidth.Load(fp, m_fAlpha);
|
||||
m_lstHeight.Load(fp, m_fAlpha);
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
fwrite(&m_fPowerSeed, 4, 1, fp);
|
||||
fwrite(&m_fLifetime, 4, 1, fp);
|
||||
fwrite(&m_fLifetimeSeed, 4, 1, fp);
|
||||
|
||||
fwrite(&m_fRotation, 4, 1, fp);
|
||||
fwrite(&m_fTexSpeed, 4, 1, fp);
|
||||
|
||||
// 볼륨
|
||||
fwrite(&m_dwVolumeType, 4, 1, fp); // 0 : None, 1 : Square, 2 : Circle
|
||||
fwrite(&m_fVolX, 4, 1, fp);
|
||||
fwrite(&m_fVolY, 4, 1, fp);
|
||||
fwrite(&m_fVolZ, 4, 1, fp);
|
||||
fwrite(&m_fRadius, 4, 1, fp);
|
||||
fwrite(&m_fInnerRadius, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
|
||||
m_lstAmount.Save(fp);
|
||||
m_lstAlpha.Save(fp);
|
||||
m_lstPower.Save(fp);
|
||||
m_lstAngle.Save(fp);
|
||||
m_lstEForce.Save(fp);
|
||||
m_lstDirection.Save(fp);
|
||||
|
||||
// Scenario용 리스트
|
||||
m_lstWidth.Save(fp);
|
||||
m_lstHeight.Save(fp);
|
||||
m_lstColor.Save(fp);
|
||||
}
|
||||
114
GameTools/Effect/X3DEffectParticle.h
Normal file
114
GameTools/Effect/X3DEffectParticle.h
Normal file
@@ -0,0 +1,114 @@
|
||||
// X3DEffectParticle.h: interface for the CX3DEffectParticle class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTPARTICLE_H__0750B6D9_11E2_41A9_BFEF_D92F0F1E0CC5__INCLUDED_)
|
||||
#define AFX_X3DEFFECTPARTICLE_H__0750B6D9_11E2_41A9_BFEF_D92F0F1E0CC5__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
typedef struct _Particle
|
||||
{
|
||||
vector3 vecPos;
|
||||
vector3 vecVel;
|
||||
float fLifetime;
|
||||
float fMaxLife;
|
||||
float fTexFrame;
|
||||
|
||||
float fRotation;
|
||||
unsigned long dwRotationCount;
|
||||
float fWidth;
|
||||
float fHeight;
|
||||
color lColor;
|
||||
} Particle, *LPParticle;
|
||||
|
||||
class CX3DEffectParticle : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwMaxAmount;
|
||||
unsigned long m_dwDrawAmount;
|
||||
float m_fAlpha;
|
||||
float m_fPower;
|
||||
float m_fAngle;
|
||||
vector3 m_vecEForce;
|
||||
quaternion m_quatDir;
|
||||
|
||||
float m_fPowerSeed;
|
||||
float m_fLifetime;
|
||||
float m_fLifetimeSeed;
|
||||
|
||||
float m_fRotation;
|
||||
float m_fTexSpeed;
|
||||
|
||||
// 볼륨
|
||||
unsigned long m_dwVolumeType; // 0 : None, 1 : Square, 2 : Circle
|
||||
float m_fVolX;
|
||||
float m_fVolY;
|
||||
float m_fVolZ;
|
||||
float m_fRadius;
|
||||
float m_fInnerRadius;
|
||||
|
||||
// 파티클 정보 / 버퍼
|
||||
LPParticle m_lpVerticeInfo;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
LPDIRECT3DINDEXBUFFER8 m_lpVerticeIndex;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstAmount;
|
||||
CKeyList<FloatKeyList> m_lstAlpha;
|
||||
CKeyList<FloatKeyList> m_lstPower;
|
||||
CKeyList<FloatKeyList> m_lstAngle;
|
||||
CKeyList<VectorKeyList> m_lstEForce;
|
||||
CKeyList<QuaternionKeyList> m_lstDirection;
|
||||
|
||||
// Scenario용 리스트
|
||||
CKeyList<FloatKeyList> m_lstWidth;
|
||||
CKeyList<FloatKeyList> m_lstHeight;
|
||||
|
||||
public:
|
||||
CX3DEffectParticle();
|
||||
virtual ~CX3DEffectParticle();
|
||||
|
||||
void SetVolumeNone(void);
|
||||
void SetVolumeSquare(float fVolX, float fVolY, float fVolZ);
|
||||
void SetVolumeCircle(float fRadius, float fInnerRadius);
|
||||
|
||||
void SetPowerSeed(float fPowerSeed) { m_fPowerSeed = fPowerSeed; }
|
||||
void SetLifetime(float fLifetime) { m_fLifetime = fLifetime; }
|
||||
void SetLifetimeSeed(float fLifetimeSeed) { m_fLifetimeSeed = fLifetimeSeed; }
|
||||
void SetRotation(float fRotation) { m_fRotation = fRotation; }
|
||||
void SetTexSpeed(float fTexSpeed) { m_fTexSpeed = fTexSpeed; }
|
||||
|
||||
vector3 GetEForce(void) { return m_vecEForce; }
|
||||
unsigned char GetMainAlpha(void) { return (unsigned char)(m_fAlpha * 255); }
|
||||
float GetAmount(float fFrame) { float temp; m_lstAmount.Interpolation(fFrame, temp); return temp;}
|
||||
float GetLifetime(void) { return m_fLifetime; }
|
||||
float GetPower(void) { return m_fPower; }
|
||||
float GetAngle(void) { return m_fAngle; }
|
||||
quaternion GetDirection(void) { return m_quatDir; }
|
||||
float GetWidth(float fFrame) { float temp; m_lstWidth.Interpolation(fFrame, temp); return temp; }
|
||||
float GetHeight(float fFrame) { float temp; m_lstHeight.Interpolation(fFrame, temp); return temp; }
|
||||
|
||||
unsigned char GetAlpha(float fFrame) { color temp; m_lstColor.InterpolationC(fFrame, temp); return temp.a; }
|
||||
unsigned char GetRColor(float fFrame) { color temp; m_lstColor.InterpolationC(fFrame, temp); return temp.r; }
|
||||
unsigned char GetGColor(float fFrame) { color temp; m_lstColor.InterpolationC(fFrame, temp); return temp.g; }
|
||||
unsigned char GetBColor(float fFrame) { color temp; m_lstColor.InterpolationC(fFrame, temp); return temp.b; }
|
||||
|
||||
BOOL CreateParticle(LPParticle lpParticle);
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
|
||||
BOOL ParticleInterpolation(unsigned long dwNumber);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTPARTICLE_H__0750B6D9_11E2_41A9_BFEF_D92F0F1E0CC5__INCLUDED_)
|
||||
246
GameTools/Effect/X3DEffectPlane.cpp
Normal file
246
GameTools/Effect/X3DEffectPlane.cpp
Normal file
@@ -0,0 +1,246 @@
|
||||
// X3DEffectPlane.cpp: implementation of the CX3DEffectPlane class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectPlane.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectPlane::CX3DEffectPlane()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectPlane::~CX3DEffectPlane()
|
||||
{
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectPlane::CreateBuffer(void)
|
||||
{
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
m_lpD3DDevice->CreateVertexBuffer( 4 * sizeof(LVertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, LVERTEXFVF, D3DPOOL_DEFAULT, &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( 4 * sizeof(LVertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, LVERTEXFVF, D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
if(m_lpVertices == NULL) return;
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
if(quatAxis) { z3d::MatrixRotationQuaternion(matWorld, (*quatAxis)); }
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
vector3 *vecTemp = ((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
matWorld._41 = vecTemp->x;
|
||||
matWorld._42 = vecTemp->y;
|
||||
matWorld._43 = vecTemp->z;
|
||||
}
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
|
||||
if(m_bTexAni)
|
||||
{
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CX3DEffectPlane::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
|
||||
if(!m_lstWidth.Interpolation(fFrame, m_fWidth)) return FALSE;
|
||||
if(!m_lstHeight.Interpolation(fFrame, m_fHeight)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if(m_bVisibility) {
|
||||
|
||||
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
if(FAILED( m_lpVertices->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD ) ) ) return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) ) return FALSE;
|
||||
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
fEndU = f1 + 0.25f;
|
||||
fEndV = f2 + 0.25f;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndBU = f1 + 0.25f;
|
||||
fEndBV = f2 + 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU;
|
||||
fEndBV = fEndV = m_fTileV;
|
||||
}
|
||||
|
||||
pVertices[0].v = vector3(-(m_fWidth / 2), 0, (m_fHeight / 2));
|
||||
pVertices[1].v = vector3( (m_fWidth / 2), 0, (m_fHeight / 2));
|
||||
pVertices[2].v = vector3(-(m_fWidth / 2), 0, -(m_fHeight / 2));
|
||||
pVertices[3].v = vector3( (m_fWidth / 2), 0, -(m_fHeight / 2));
|
||||
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, m_quatAxis);
|
||||
|
||||
/* quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
if(quatAxis)
|
||||
{
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, (*quatAxis));
|
||||
}
|
||||
|
||||
pVerticesBlend[0].v = pVertices[0].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[1].v = pVertices[1].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[2].v = pVertices[2].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[3].v = pVertices[3].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());*/
|
||||
pVerticesBlend[0].v = pVertices[0].v += m_vecCenter;
|
||||
pVerticesBlend[1].v = pVertices[1].v += m_vecCenter;
|
||||
pVerticesBlend[2].v = pVertices[2].v += m_vecCenter;
|
||||
pVerticesBlend[3].v = pVertices[3].v += m_vecCenter;
|
||||
|
||||
pVertices[0].tu = fStartU; pVertices[0].tv = fStartV;
|
||||
pVertices[1].tu = fEndU; pVertices[1].tv = fStartV;
|
||||
pVertices[2].tu = fStartU; pVertices[2].tv = fEndV;
|
||||
pVertices[3].tu = fEndU; pVertices[3].tv = fEndV;
|
||||
pVerticesBlend[0].tu = fStartBU; pVerticesBlend[0].tv = fStartBV;
|
||||
pVerticesBlend[1].tu = fEndBU; pVerticesBlend[1].tv = fStartBV;
|
||||
pVerticesBlend[2].tu = fStartBU; pVerticesBlend[2].tv = fEndBV;
|
||||
pVerticesBlend[3].tu = fEndBU; pVerticesBlend[3].tv = fEndBV;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
pVertices[0].diff = pVertices[1].diff = pVertices[2].diff = pVertices[3].diff = m_lColor;
|
||||
pVerticesBlend[0].diff = pVerticesBlend[1].diff = pVerticesBlend[2].diff = pVerticesBlend[3].diff = m_lColor;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[3].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVertices[0].diff.a = pVertices[1].diff.a = pVertices[2].diff.a = pVertices[3].diff.a;
|
||||
pVerticesBlend[3].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
pVerticesBlend[0].diff.a = pVerticesBlend[1].diff.a = pVerticesBlend[2].diff.a = pVerticesBlend[3].diff.a;
|
||||
}
|
||||
pVertices[0].spec = pVertices[1].spec = pVertices[2].spec = pVertices[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].spec = pVerticesBlend[1].spec = pVerticesBlend[2].spec = pVerticesBlend[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstWidth.Load(fp, m_fWidth);
|
||||
m_lstHeight.Load(fp, m_fHeight);
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
m_lstColor.Save(fp);
|
||||
m_lstWidth.Save(fp);
|
||||
m_lstHeight.Save(fp);
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
69
GameTools/Effect/X3DEffectPlane.h
Normal file
69
GameTools/Effect/X3DEffectPlane.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// X3DEffectPlane.h: interface for the CX3DEffectPlane class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_)
|
||||
#define AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectPlane : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
float m_fWidth;
|
||||
float m_fHeight;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstWidth;
|
||||
CKeyList<FloatKeyList> m_lstHeight;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectPlane();
|
||||
virtual ~CX3DEffectPlane();
|
||||
|
||||
void SetWidth(float fWidth) { m_fWidth = fWidth; }
|
||||
float GetWidth(void) { return m_fWidth; }
|
||||
void SetHeight(float fHeight) { m_fHeight = fHeight; }
|
||||
float GetHeight(void) { return m_fHeight; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_)
|
||||
473
GameTools/Effect/X3DEffectSphere.cpp
Normal file
473
GameTools/Effect/X3DEffectSphere.cpp
Normal file
@@ -0,0 +1,473 @@
|
||||
// X3DEffectSphere.cpp: implementation of the CX3DEffectSphere class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectSphere.h"
|
||||
#include "SceneStateMgr.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectSphere::CX3DEffectSphere()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
m_lpVerticeIndex = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectSphere::~CX3DEffectSphere()
|
||||
{
|
||||
if(m_lpVerticeIndex) { m_lpVerticeIndex->Release(); m_lpVerticeIndex = NULL; }
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectSphere::CreateBuffer()
|
||||
{
|
||||
if(m_lpVerticeIndex) { m_lpVerticeIndex->Release(); m_lpVerticeIndex = NULL; }
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
if(m_bUpperVis && m_bLowerVis) m_dwTotalSegment = m_dwSegment * 2;
|
||||
else if(m_bUpperVis || m_bLowerVis) m_dwTotalSegment = m_dwSegment;
|
||||
else return FALSE;
|
||||
|
||||
m_lpD3DDevice->CreateVertexBuffer( (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
m_lpD3DDevice->CreateIndexBuffer( m_dwSidePlane * m_dwTotalSegment * 2 * 3 * sizeof(unsigned short), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16,
|
||||
D3DPOOL_MANAGED, &m_lpVerticeIndex);
|
||||
|
||||
if(m_dwTotalSegment == m_dwSegment)
|
||||
{
|
||||
m_dwNumVertex = (m_dwSidePlane + 1) * (m_dwSegment + 1);
|
||||
} else
|
||||
{
|
||||
m_dwNumVertex = (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2;
|
||||
}
|
||||
m_dwPrimitive = m_dwSidePlane * m_dwTotalSegment * 2;
|
||||
|
||||
unsigned short *pVerticeIndex;
|
||||
m_lpVerticeIndex->Lock(0, m_dwSidePlane * m_dwTotalSegment * 2 * 3 * sizeof(unsigned short), (unsigned char **)&pVerticeIndex, 0);
|
||||
|
||||
unsigned long i, j, ti = 0, tv = 0;
|
||||
unsigned long temp, t1, t2;
|
||||
|
||||
// Upper
|
||||
if(m_bUpperVis)
|
||||
{
|
||||
for(j = 0; j < m_dwSegment; j++)
|
||||
{
|
||||
for(i = 0; i < m_dwSidePlane; i++)
|
||||
{
|
||||
temp = j * (m_dwSidePlane * 6) + i * 6;
|
||||
t1 = (m_dwSidePlane + 1) * j + i;
|
||||
t2 = (m_dwSidePlane + 1) * (j + 1) + i;
|
||||
if(m_bUpperUp)
|
||||
{
|
||||
// Up
|
||||
pVerticeIndex[temp + 0] = t1 + 0;
|
||||
pVerticeIndex[temp + 1] = t1 + 1;
|
||||
pVerticeIndex[temp + 2] = t2;
|
||||
|
||||
pVerticeIndex[temp + 3] = t1 + 1;
|
||||
pVerticeIndex[temp + 4] = t2 + 1;
|
||||
pVerticeIndex[temp + 5] = t2;
|
||||
} else
|
||||
{
|
||||
// Center
|
||||
pVerticeIndex[temp + 0] = t1 + 0;
|
||||
pVerticeIndex[temp + 1] = t2;
|
||||
pVerticeIndex[temp + 2] = t1 + 1;
|
||||
|
||||
pVerticeIndex[temp + 3] = t2;
|
||||
pVerticeIndex[temp + 4] = t2 + 1;
|
||||
pVerticeIndex[temp + 5] = t1 + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ti = m_dwSidePlane * m_dwSegment * 2 * 3;
|
||||
tv = (m_dwSidePlane + 1) * (m_dwSegment + 1);
|
||||
}
|
||||
|
||||
// Lower
|
||||
if(m_bLowerVis)
|
||||
{
|
||||
for(j = 0; j < m_dwSegment; j++)
|
||||
{
|
||||
for(i = 0; i < m_dwSidePlane; i++)
|
||||
{
|
||||
temp = j * (m_dwSidePlane * 6) + i * 6 + ti;
|
||||
t1 = (m_dwSidePlane + 1) * j + i;
|
||||
t2 = (m_dwSidePlane + 1) * (j + 1) + i;
|
||||
if(m_bLowerUp)
|
||||
{
|
||||
// Up
|
||||
pVerticeIndex[temp + 0] = tv + t1 + 0;
|
||||
pVerticeIndex[temp + 1] = tv + t2;
|
||||
pVerticeIndex[temp + 2] = tv + t1 + 1;
|
||||
|
||||
pVerticeIndex[temp + 3] = tv + t2;
|
||||
pVerticeIndex[temp + 4] = tv + t2 + 1;
|
||||
pVerticeIndex[temp + 5] = tv + t1 + 1;
|
||||
} else
|
||||
{
|
||||
// Center
|
||||
pVerticeIndex[temp + 0] = tv + t1 + 0;
|
||||
pVerticeIndex[temp + 1] = tv + t1 + 1;
|
||||
pVerticeIndex[temp + 2] = tv + t2;
|
||||
|
||||
pVerticeIndex[temp + 3] = tv + t1 + 1;
|
||||
pVerticeIndex[temp + 4] = tv + t2 + 1;
|
||||
pVerticeIndex[temp + 5] = tv + t2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_lpVerticeIndex->Unlock();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
if(m_lpVertices == NULL) return;
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
if(quatAxis) { z3d::MatrixRotationQuaternion(matWorld, (*quatAxis)); }
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
vector3 *vecTemp = ((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
matWorld._41 = vecTemp->x;
|
||||
matWorld._42 = vecTemp->y;
|
||||
matWorld._43 = vecTemp->z;
|
||||
}
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwNumVertex, 0, m_dwPrimitive);
|
||||
|
||||
if(m_bTexAni)
|
||||
{
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
CSceneStateMgr::_SetD3DRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwNumVertex, 0, m_dwPrimitive);
|
||||
}/**/
|
||||
}
|
||||
|
||||
BOOL CX3DEffectSphere::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
|
||||
if(m_lpVertices == NULL) return FALSE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
if(!m_lstHeightFactor.Interpolation(fFrame, m_fHeightFactor)) return FALSE;
|
||||
if(!m_lstRadius.Interpolation(fFrame, m_fRadius)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fRadius *= m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(!m_lstUpperFactor.Interpolation(fFrame, m_fUpperFactor)) return FALSE;
|
||||
if(!m_lstLowerFactor.Interpolation(fFrame, m_fLowerFactor)) return FALSE;
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(m_bVisibility) {
|
||||
|
||||
{
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
if(FAILED( m_lpVertices->Lock( 0, (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
|
||||
unsigned long i, tempi, j, t1, tv = 0;
|
||||
float degree, hdegree, height, hcos;
|
||||
float divangle = FLOAT_PHI * 2.0f / m_dwSidePlane;
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndU = fEndBU = 0.25f;
|
||||
fEndV = fEndBV = 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU - fStartBU;
|
||||
fEndBV = fEndV = m_fTileV - fStartBV;
|
||||
}
|
||||
|
||||
float fHEV = fEndV / 2.0f, fSV = fHEV + fStartV, fDSV = fSV * 2.0f;
|
||||
float fHEBV = fEndBV / 2.0f, fSBV = fHEBV + fStartBV, fDSBV = fSBV * 2.0f;
|
||||
float fSegTemp, fSegBTemp;
|
||||
if(m_bUpperVis)
|
||||
{
|
||||
for(j = 0; j <= m_dwSegment; j++)
|
||||
{
|
||||
if(m_bUpperUp)
|
||||
hdegree = (FLOAT_PHI / 2.0f) - ((j * FLOAT_PHI) / (2.0f * m_dwSegment) * m_fUpperFactor);
|
||||
else
|
||||
hdegree = ((j * FLOAT_PHI) / (2.0f * m_dwSegment)) * m_fUpperFactor;
|
||||
height = m_fRadius * m_fHeightFactor * sinf(hdegree);
|
||||
hcos = cosf(hdegree);
|
||||
fSegTemp = fHEV * j / m_dwSegment;
|
||||
fSegBTemp = fHEBV * j / m_dwSegment;
|
||||
|
||||
for(i = 0; i <= m_dwSidePlane; i++)
|
||||
{
|
||||
if(i == m_dwSidePlane) tempi = 0; else tempi = i;
|
||||
|
||||
degree = tempi * divangle;
|
||||
t1 = (m_dwSidePlane + 1) * j + i;
|
||||
|
||||
pVertices[t1].v = vector3(m_fRadius * cosf(degree) * hcos, height, m_fRadius * sinf(degree) * hcos);
|
||||
z3d::VectorRotate(pVertices[t1].v, pVertices[t1].v, m_quatAxis);
|
||||
pVertices[t1].v += m_vecCenter;
|
||||
pVerticesBlend[t1].v = pVertices[t1].v;
|
||||
|
||||
pVertices[t1].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[t1].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
if(m_bUpperUp)
|
||||
{
|
||||
if(m_bUpperTex)
|
||||
{
|
||||
pVertices[t1].tv = fStartV + fSegTemp * m_fUpperFactor;
|
||||
pVerticesBlend[t1].tv = fStartBV + fSegBTemp * m_fUpperFactor;
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fStartV + fSegTemp;
|
||||
pVerticesBlend[t1].tv = fStartBV + fSegBTemp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_bUpperTex)
|
||||
{
|
||||
pVertices[t1].tv = (fStartV + fSV) - ((fStartV + fSegTemp) * m_fUpperFactor);
|
||||
pVerticesBlend[t1].tv = (fStartBV + fSBV) - ((fStartBV + fSegBTemp) * m_fUpperFactor);
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fSV - fSegTemp;
|
||||
pVerticesBlend[t1].tv = fSBV - fSegBTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tv = (m_dwSidePlane + 1) * (m_dwSegment + 1);
|
||||
}
|
||||
|
||||
if(m_bLowerVis)
|
||||
{
|
||||
for(j = 0; j <= m_dwSegment; j++)
|
||||
{
|
||||
if(m_bLowerUp)
|
||||
hdegree = (FLOAT_PHI / 2.0f) - ((j * FLOAT_PHI) / (2.0f * m_dwSegment) * m_fLowerFactor);
|
||||
else
|
||||
hdegree = ((j * FLOAT_PHI) / (2.0f * m_dwSegment)) * m_fLowerFactor;
|
||||
height = m_fRadius * m_fHeightFactor * sinf(hdegree);
|
||||
hcos = cosf(hdegree);
|
||||
fSegTemp = fHEV * j / m_dwSegment;
|
||||
fSegBTemp = fHEBV * j / m_dwSegment;
|
||||
|
||||
for(i = 0; i <= m_dwSidePlane; i++)
|
||||
{
|
||||
if(i == m_dwSidePlane) tempi = 0; else tempi = i;
|
||||
|
||||
degree = tempi * divangle;
|
||||
t1 = tv + (m_dwSidePlane + 1) * j + i;
|
||||
|
||||
pVertices[t1].v = vector3(m_fRadius * cosf(degree) * hcos, -height, m_fRadius * sinf(degree) * hcos);
|
||||
z3d::VectorRotate(pVertices[t1].v, pVertices[t1].v, m_quatAxis);
|
||||
pVertices[t1].v += m_vecCenter;
|
||||
pVerticesBlend[t1].v = pVertices[t1].v;
|
||||
|
||||
pVertices[t1].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[t1].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
if(m_bLowerUp)
|
||||
{
|
||||
if(m_bLowerTex)
|
||||
{
|
||||
pVertices[t1].tv = fDSV - ((fStartV + fSegTemp) * m_fLowerFactor);
|
||||
pVerticesBlend[t1].tv = fDSBV - ((fStartBV + fSegBTemp) * m_fLowerFactor);
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fDSV - (fStartV + fSegTemp);
|
||||
pVerticesBlend[t1].tv = fDSBV - (fStartBV + fSegBTemp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_bLowerTex)
|
||||
{
|
||||
pVertices[t1].tv = fSV + fSegTemp * m_fLowerFactor;
|
||||
pVerticesBlend[t1].tv = fSBV + fSegBTemp * m_fLowerFactor;
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fSV + fSegTemp;
|
||||
pVerticesBlend[t1].tv = fSBV + fSegBTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pVertices[0].diff = m_lColor;
|
||||
pVertices[0].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].diff =pVertices[0].diff;
|
||||
pVerticesBlend[0].spec =pVertices[0].spec;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[0].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVerticesBlend[0].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
}
|
||||
|
||||
if(m_dwTotalSegment == m_dwSegment)
|
||||
{
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * (m_dwSegment + 1); i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
} else
|
||||
{
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2; i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
}
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
|
||||
fread(&m_dwSidePlane, 4, 1, fp);
|
||||
fread(&m_dwSegment, 4, 1, fp);
|
||||
|
||||
fread(&m_bUpperTex, 4, 1, fp);
|
||||
fread(&m_bUpperUp, 4, 1, fp);
|
||||
fread(&m_bUpperVis, 4, 1, fp);
|
||||
fread(&m_bLowerTex, 4, 1, fp);
|
||||
fread(&m_bLowerUp, 4, 1, fp);
|
||||
fread(&m_bLowerVis, 4, 1, fp);
|
||||
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstHeightFactor.Load(fp, m_fHeightFactor);
|
||||
m_lstRadius.Load(fp, m_fRadius);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fRadius *= m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
m_lstUpperFactor.Load(fp, m_fUpperFactor);
|
||||
m_lstLowerFactor.Load(fp, m_fLowerFactor);
|
||||
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
|
||||
fwrite(&m_dwSidePlane, 4, 1, fp);
|
||||
fwrite(&m_dwSegment, 4, 1, fp);
|
||||
|
||||
fwrite(&m_bUpperTex, 4, 1, fp);
|
||||
fwrite(&m_bUpperUp, 4, 1, fp);
|
||||
fwrite(&m_bUpperVis, 4, 1, fp);
|
||||
fwrite(&m_bLowerTex, 4, 1, fp);
|
||||
fwrite(&m_bLowerUp, 4, 1, fp);
|
||||
fwrite(&m_bLowerVis, 4, 1, fp);
|
||||
|
||||
m_lstColor.Save(fp);
|
||||
m_lstHeightFactor.Save(fp);
|
||||
m_lstRadius.Save(fp);
|
||||
m_lstUpperFactor.Save(fp);
|
||||
m_lstLowerFactor.Save(fp);
|
||||
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
107
GameTools/Effect/X3DEffectSphere.h
Normal file
107
GameTools/Effect/X3DEffectSphere.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// X3DEffectSphere.h: interface for the CX3DEffectSphere class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_)
|
||||
#define AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectSphere : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwSegment, m_dwTotalSegment;
|
||||
unsigned long m_dwSidePlane;
|
||||
unsigned long m_dwPrimitive, m_dwNumVertex;
|
||||
float m_fHeightFactor;
|
||||
float m_fRadius;
|
||||
|
||||
BOOL m_bUpperVis;
|
||||
BOOL m_bUpperUp;
|
||||
BOOL m_bUpperTex;
|
||||
float m_fUpperFactor;
|
||||
BOOL m_bLowerVis;
|
||||
BOOL m_bLowerUp;
|
||||
BOOL m_bLowerTex;
|
||||
float m_fLowerFactor;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
LPDIRECT3DINDEXBUFFER8 m_lpVerticeIndex;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstHeightFactor;
|
||||
CKeyList<FloatKeyList> m_lstRadius;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstUpperFactor;
|
||||
CKeyList<FloatKeyList> m_lstLowerFactor;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectSphere();
|
||||
virtual ~CX3DEffectSphere();
|
||||
|
||||
void SetSegment(unsigned long dwSegment) { m_dwSegment = dwSegment; }
|
||||
unsigned long GetSegment(void) { return m_dwSegment; }
|
||||
void SetSidePlane(unsigned long dwSidePlane) { m_dwSidePlane = dwSidePlane * 4; }
|
||||
unsigned long GetSidePlane(void) { return m_dwSidePlane; }
|
||||
|
||||
void SetUpperVis(BOOL bUpperVis) { m_bUpperVis = bUpperVis; }
|
||||
BOOL GetUpperVis(void) { return m_bUpperVis; }
|
||||
void SetUpperUp(BOOL bUpperUp) { m_bUpperUp = bUpperUp; }
|
||||
BOOL GetUpperUp(void) { return m_bUpperUp; }
|
||||
void SetUpperTex(BOOL bUpperTex) { m_bUpperTex = bUpperTex; }
|
||||
BOOL GetUpperTex(void) { return m_bUpperTex; }
|
||||
void SetLowerVis(BOOL bLowerVis) { m_bLowerVis = bLowerVis; }
|
||||
BOOL GetLowerVis(void) { return m_bLowerVis; }
|
||||
void SetLowerUp(BOOL bLowerUp) { m_bLowerUp = bLowerUp; }
|
||||
BOOL GetLowerUp(void) { return m_bLowerUp; }
|
||||
void SetLowerTex(BOOL bLowerTex) { m_bLowerTex = bLowerTex; }
|
||||
BOOL GetLowerTex(void) { return m_bLowerTex; }
|
||||
|
||||
void SetRadius(float fRadius) { m_fRadius = fRadius; }
|
||||
float GetRadius(void) { return m_fRadius; }
|
||||
void SetHeightFactor(float fHeightFactor) { m_fHeightFactor = fHeightFactor; }
|
||||
float GetHeightFactor(void) { return m_fHeightFactor; }
|
||||
void SetUpperFactor(float fUpperFactor) { m_fUpperFactor = fUpperFactor; }
|
||||
float GetUpperFactor(void) { return m_fUpperFactor; }
|
||||
void SetLowerFactor(float fLowerFactor) { m_fLowerFactor = fLowerFactor; }
|
||||
float GetLowerFactor(void) { return m_fLowerFactor; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer();
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_)
|
||||
1752
GameTools/Effect/mmgr.cpp
Normal file
1752
GameTools/Effect/mmgr.cpp
Normal file
File diff suppressed because it is too large
Load Diff
165
GameTools/Effect/mmgr.h
Normal file
165
GameTools/Effect/mmgr.h
Normal file
@@ -0,0 +1,165 @@
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// _
|
||||
// | |
|
||||
// _ __ ___ _ __ ___ __ _ _ __ | |__
|
||||
// | '_ ` _ \| '_ ` _ \ / _` | '__| | '_ \
|
||||
// | | | | | | | | | | | (_| | | _ | | | |
|
||||
// |_| |_| |_|_| |_| |_|\__, |_| (_)|_| |_|
|
||||
// __/ |
|
||||
// |___/
|
||||
//
|
||||
// Memory manager & tracking software
|
||||
//
|
||||
// Best viewed with 8-character tabs and (at least) 132 columns
|
||||
//
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Restrictions & freedoms pertaining to usage and redistribution of this software:
|
||||
//
|
||||
// * This software is 100% free
|
||||
// * If you use this software (in part or in whole) you must credit the author.
|
||||
// * This software may not be re-distributed (in part or in whole) in a modified
|
||||
// form without clear documentation on how to obtain a copy of the original work.
|
||||
// * You may not use this software to directly or indirectly cause harm to others.
|
||||
// * This software is provided as-is and without warrantee. Use at your own risk.
|
||||
//
|
||||
// For more information, visit HTTP://www.FluidStudios.com
|
||||
//
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Originally created on 12/22/2000 by Paul Nettle
|
||||
//
|
||||
// Copyright 2000, Fluid Studios, Inc., all rights reserved.
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _H_MMGR
|
||||
#define _H_MMGR
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// For systems that don't have the __FUNCTION__ variable, we can just define it here
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define __FUNCTION__ "??"
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Types
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct tag_au
|
||||
{
|
||||
size_t actualSize;
|
||||
size_t reportedSize;
|
||||
void *actualAddress;
|
||||
void *reportedAddress;
|
||||
char sourceFile[40];
|
||||
char sourceFunc[40];
|
||||
unsigned int sourceLine;
|
||||
unsigned int allocationType;
|
||||
bool breakOnDealloc;
|
||||
bool breakOnRealloc;
|
||||
unsigned int allocationNumber;
|
||||
struct tag_au *next;
|
||||
struct tag_au *prev;
|
||||
} sAllocUnit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int totalReportedMemory;
|
||||
unsigned int totalActualMemory;
|
||||
unsigned int peakReportedMemory;
|
||||
unsigned int peakActualMemory;
|
||||
unsigned int accumulatedReportedMemory;
|
||||
unsigned int accumulatedActualMemory;
|
||||
unsigned int accumulatedAllocUnitCount;
|
||||
unsigned int totalAllocUnitCount;
|
||||
unsigned int peakAllocUnitCount;
|
||||
} sMStats;
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// External constants
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
extern const unsigned int m_alloc_unknown;
|
||||
extern const unsigned int m_alloc_new;
|
||||
extern const unsigned int m_alloc_new_array;
|
||||
extern const unsigned int m_alloc_malloc;
|
||||
extern const unsigned int m_alloc_calloc;
|
||||
extern const unsigned int m_alloc_realloc;
|
||||
extern const unsigned int m_alloc_delete;
|
||||
extern const unsigned int m_alloc_delete_array;
|
||||
extern const unsigned int m_alloc_free;
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Used by the macros
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void m_setOwner(const char *file, const unsigned int line, const char *func);
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Allocation breakpoints
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
bool &m_breakOnRealloc(void *reportedAddress);
|
||||
bool &m_breakOnDealloc(void *reportedAddress);
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// The meat of the memory tracking software
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void *m_allocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc,
|
||||
const unsigned int allocationType, const size_t reportedSize);
|
||||
void *m_reallocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc,
|
||||
const unsigned int reallocationType, const size_t reportedSize, void *reportedAddress);
|
||||
void m_deallocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc,
|
||||
const unsigned int deallocationType, const void *reportedAddress);
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Utilitarian functions
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
bool m_validateAddress(const void *reportedAddress);
|
||||
bool m_validateAllocUnit(const sAllocUnit *allocUnit);
|
||||
bool m_validateAllAllocUnits();
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Unused RAM calculations
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
unsigned int m_calcUnused(const sAllocUnit *allocUnit);
|
||||
unsigned int m_calcAllUnused();
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Logging and reporting
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void m_dumpAllocUnit(const sAllocUnit *allocUnit, const char *prefix = "");
|
||||
void m_dumpMemoryReport(const char *filename = "memreport.log", const bool overwrite = true);
|
||||
sMStats m_getMemoryStatistics();
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Variations of global operators new & delete
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void *operator new(size_t reportedSize);
|
||||
void *operator new[](size_t reportedSize);
|
||||
void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine);
|
||||
void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine);
|
||||
void operator delete(void *reportedAddress);
|
||||
void operator delete[](void *reportedAddress);
|
||||
|
||||
#endif // _H_MMGR
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Macros -- "Kids, please don't try this at home. We're trained professionals here." :)
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "nommgr.h"
|
||||
#define new (m_setOwner (__FILE__,__LINE__,__FUNCTION__),false) ? NULL : new
|
||||
#define delete (m_setOwner (__FILE__,__LINE__,__FUNCTION__),false) ? m_setOwner("",0,"") : delete
|
||||
#define malloc(sz) m_allocator (__FILE__,__LINE__,__FUNCTION__,m_alloc_malloc,sz)
|
||||
#define calloc(sz) m_allocator (__FILE__,__LINE__,__FUNCTION__,m_alloc_calloc,sz)
|
||||
#define realloc(ptr,sz) m_reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
|
||||
#define free(ptr) m_deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// mmgr.h - End of file
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
60
GameTools/Effect/nommgr.h
Normal file
60
GameTools/Effect/nommgr.h
Normal file
@@ -0,0 +1,60 @@
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// _
|
||||
// | |
|
||||
// _ __ ___ _ __ ___ _ __ ___ __ _ _ __ | |__
|
||||
// | '_ \ / _ \| '_ ` _ \| '_ ` _ \ / _` | '__| | '_ \
|
||||
// | | | | (_) | | | | | | | | | | | (_| | | _ | | | |
|
||||
// |_| |_|\___/|_| |_| |_|_| |_| |_|\__, |_| (_)|_| |_|
|
||||
// __/ |
|
||||
// |___/
|
||||
//
|
||||
// Memory manager & tracking software
|
||||
//
|
||||
// Best viewed with 8-character tabs and (at least) 132 columns
|
||||
//
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Restrictions & freedoms pertaining to usage and redistribution of this software:
|
||||
//
|
||||
// * This software is 100% free
|
||||
// * If you use this software (in part or in whole) you must credit the author.
|
||||
// * This software may not be re-distributed (in part or in whole) in a modified
|
||||
// form without clear documentation on how to obtain a copy of the original work.
|
||||
// * You may not use this software to directly or indirectly cause harm to others.
|
||||
// * This software is provided as-is and without warrantee. Use at your own risk.
|
||||
//
|
||||
// For more information, visit HTTP://www.FluidStudios.com
|
||||
//
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Originally created on 12/22/2000 by Paul Nettle
|
||||
//
|
||||
// Copyright 2000, Fluid Studios, Inc., all rights reserved.
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
#ifdef delete
|
||||
#undef delete
|
||||
#endif
|
||||
|
||||
#ifdef malloc
|
||||
#undef malloc
|
||||
#endif
|
||||
|
||||
#ifdef calloc
|
||||
#undef calloc
|
||||
#endif
|
||||
|
||||
#ifdef realloc
|
||||
#undef realloc
|
||||
#endif
|
||||
|
||||
#ifdef free
|
||||
#undef free
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// nommgr.h - End of file
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
277
GameTools/Effect/profile.cpp
Normal file
277
GameTools/Effect/profile.cpp
Normal file
@@ -0,0 +1,277 @@
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** profile.cpp
|
||||
**
|
||||
** Real-Time Hierarchical Profiling for Game Programming Gems 3
|
||||
**
|
||||
** by Greg Hjelstrom & Byon Garrabrant
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
#include "profile.h"
|
||||
|
||||
|
||||
inline void Profile_Get_Ticks(_int64 * ticks)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push edx;
|
||||
push ecx;
|
||||
mov ecx,ticks;
|
||||
_emit 0Fh
|
||||
_emit 31h
|
||||
mov [ecx],eax;
|
||||
mov [ecx+4],edx;
|
||||
pop ecx;
|
||||
pop edx;
|
||||
}
|
||||
}
|
||||
|
||||
inline float Profile_Get_Tick_Rate(void)
|
||||
{
|
||||
static float _CPUFrequency = -1.0f;
|
||||
|
||||
if (_CPUFrequency == -1.0f) {
|
||||
__int64 curr_rate = 0;
|
||||
::QueryPerformanceFrequency ((LARGE_INTEGER *)&curr_rate);
|
||||
_CPUFrequency = (float)curr_rate;
|
||||
}
|
||||
|
||||
return _CPUFrequency;
|
||||
}
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileNode
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
/***********************************************************************************************
|
||||
* INPUT: *
|
||||
* name - pointer to a static string which is the name of this profile node *
|
||||
* parent - parent pointer *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* The name is assumed to be a static pointer, only the pointer is stored and compared for *
|
||||
* efficiency reasons. *
|
||||
*=============================================================================================*/
|
||||
CProfileNode::CProfileNode( const char * name, CProfileNode * parent ) :
|
||||
Name( name ),
|
||||
TotalCalls( 0 ),
|
||||
TotalTime( 0 ),
|
||||
StartTime( 0 ),
|
||||
RecursionCounter( 0 ),
|
||||
Parent( parent ),
|
||||
Child( NULL ),
|
||||
Sibling( NULL )
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
||||
CProfileNode::~CProfileNode( void )
|
||||
{
|
||||
delete Child;
|
||||
delete Sibling;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* INPUT: *
|
||||
* name - static string pointer to the name of the node we are searching for *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* All profile names are assumed to be static strings so this function uses pointer compares *
|
||||
* to find the named node. *
|
||||
*=============================================================================================*/
|
||||
CProfileNode * CProfileNode::Get_Sub_Node( const char * name )
|
||||
{
|
||||
// Try to find this sub node
|
||||
CProfileNode * child = Child;
|
||||
while ( child ) {
|
||||
if ( child->Name == name ) {
|
||||
return child;
|
||||
}
|
||||
child = child->Sibling;
|
||||
}
|
||||
|
||||
// We didn't find it, so add it
|
||||
CProfileNode * node = new CProfileNode( name, this );
|
||||
node->Sibling = Child;
|
||||
Child = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void CProfileNode::Reset( void )
|
||||
{
|
||||
TotalCalls = 0;
|
||||
TotalTime = 0.0f;
|
||||
|
||||
if ( Child ) {
|
||||
Child->Reset();
|
||||
}
|
||||
if ( Sibling ) {
|
||||
Sibling->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CProfileNode::Call( void )
|
||||
{
|
||||
TotalCalls++;
|
||||
if (RecursionCounter++ == 0) {
|
||||
Profile_Get_Ticks(&StartTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CProfileNode::Return( void )
|
||||
{
|
||||
if ( --RecursionCounter == 0 && TotalCalls != 0 ) {
|
||||
__int64 time;
|
||||
Profile_Get_Ticks(&time);
|
||||
time-=StartTime;
|
||||
TotalTime += (float)time / Profile_Get_Tick_Rate();
|
||||
}
|
||||
return ( RecursionCounter == 0 );
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileIterator
|
||||
**
|
||||
***************************************************************************************************/
|
||||
CProfileIterator::CProfileIterator( CProfileNode * start )
|
||||
{
|
||||
CurrentParent = start;
|
||||
CurrentChild = CurrentParent->Get_Child();
|
||||
}
|
||||
|
||||
|
||||
void CProfileIterator::First(void)
|
||||
{
|
||||
CurrentChild = CurrentParent->Get_Child();
|
||||
}
|
||||
|
||||
|
||||
void CProfileIterator::Next(void)
|
||||
{
|
||||
CurrentChild = CurrentChild->Get_Sibling();
|
||||
}
|
||||
|
||||
|
||||
bool CProfileIterator::Is_Done(void)
|
||||
{
|
||||
return CurrentChild == NULL;
|
||||
}
|
||||
|
||||
|
||||
void CProfileIterator::Enter_Child( int index )
|
||||
{
|
||||
CurrentChild = CurrentParent->Get_Child();
|
||||
while ( (CurrentChild != NULL) && (index != 0) ) {
|
||||
index--;
|
||||
CurrentChild = CurrentChild->Get_Sibling();
|
||||
}
|
||||
|
||||
if ( CurrentChild != NULL ) {
|
||||
CurrentParent = CurrentChild;
|
||||
CurrentChild = CurrentParent->Get_Child();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CProfileIterator::Enter_Parent( void )
|
||||
{
|
||||
if ( CurrentParent->Get_Parent() != NULL ) {
|
||||
CurrentParent = CurrentParent->Get_Parent();
|
||||
}
|
||||
CurrentChild = CurrentParent->Get_Child();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** CProfileManager
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
CProfileNode CProfileManager::Root( "Root", NULL );
|
||||
CProfileNode * CProfileManager::CurrentNode = &CProfileManager::Root;
|
||||
int CProfileManager::FrameCounter = 0;
|
||||
__int64 CProfileManager::ResetTime = 0;
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Start_Profile -- Begin a named profile *
|
||||
* *
|
||||
* Steps one level deeper into the tree, if a child already exists with the specified name *
|
||||
* then it accumulates the profiling; otherwise a new child node is added to the profile tree. *
|
||||
* *
|
||||
* INPUT: *
|
||||
* name - name of this profiling record *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* The string used is assumed to be a static string; pointer compares are used throughout *
|
||||
* the profiling code for efficiency. *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Start_Profile( const char * name )
|
||||
{
|
||||
if (name != CurrentNode->Get_Name()) {
|
||||
CurrentNode = CurrentNode->Get_Sub_Node( name );
|
||||
}
|
||||
|
||||
CurrentNode->Call();
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Stop_Profile -- Stop timing and record the results. *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Stop_Profile( void )
|
||||
{
|
||||
// Return will indicate whether we should back up to our parent (we may
|
||||
// be profiling a recursive function)
|
||||
if (CurrentNode->Return()) {
|
||||
CurrentNode = CurrentNode->Get_Parent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Reset -- Reset the contents of the profiling system *
|
||||
* *
|
||||
* This resets everything except for the tree structure. All of the timing data is reset. *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Reset( void )
|
||||
{
|
||||
Root.Reset();
|
||||
FrameCounter = 0;
|
||||
Profile_Get_Ticks(&ResetTime);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Increment_Frame_Counter -- Increment the frame counter *
|
||||
*=============================================================================================*/
|
||||
void CProfileManager::Increment_Frame_Counter( void )
|
||||
{
|
||||
FrameCounter++;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* CProfileManager::Get_Time_Since_Reset -- returns the elapsed time since last reset *
|
||||
*=============================================================================================*/
|
||||
float CProfileManager::Get_Time_Since_Reset( void )
|
||||
{
|
||||
__int64 time;
|
||||
Profile_Get_Ticks(&time);
|
||||
time -= ResetTime;
|
||||
return (float)time / Profile_Get_Tick_Rate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
132
GameTools/Effect/profile.h
Normal file
132
GameTools/Effect/profile.h
Normal file
@@ -0,0 +1,132 @@
|
||||
/***************************************************************************************************
|
||||
**
|
||||
** profile.h
|
||||
**
|
||||
** Real-Time Hierarchical Profiling for Game Programming Gems 3
|
||||
**
|
||||
** by Greg Hjelstrom & Byon Garrabrant
|
||||
**
|
||||
***************************************************************************************************/
|
||||
|
||||
/*
|
||||
** A node in the Profile Hierarchy Tree
|
||||
*/
|
||||
#include "WBValue.h"
|
||||
|
||||
class CProfileNode {
|
||||
|
||||
public:
|
||||
CProfileNode( const char * name, CProfileNode * parent );
|
||||
~CProfileNode( void );
|
||||
|
||||
CProfileNode * Get_Sub_Node( const char * name );
|
||||
|
||||
CProfileNode * Get_Parent( void ) { return Parent; }
|
||||
CProfileNode * Get_Sibling( void ) { return Sibling; }
|
||||
CProfileNode * Get_Child( void ) { return Child; }
|
||||
|
||||
void Reset( void );
|
||||
void Call( void );
|
||||
bool Return( void );
|
||||
|
||||
const char * Get_Name( void ) { return Name; }
|
||||
int Get_Total_Calls( void ) { return TotalCalls; }
|
||||
float Get_Total_Time( void ) { return TotalTime; }
|
||||
|
||||
protected:
|
||||
|
||||
const char * Name;
|
||||
int TotalCalls;
|
||||
float TotalTime;
|
||||
__int64 StartTime;
|
||||
int RecursionCounter;
|
||||
|
||||
CProfileNode * Parent;
|
||||
CProfileNode * Child;
|
||||
CProfileNode * Sibling;
|
||||
};
|
||||
|
||||
/*
|
||||
** An iterator to navigate through the tree
|
||||
*/
|
||||
class CProfileIterator
|
||||
{
|
||||
public:
|
||||
// Access all the children of the current parent
|
||||
void First(void);
|
||||
void Next(void);
|
||||
bool Is_Done(void);
|
||||
|
||||
void Enter_Child( int index ); // Make the given child the new parent
|
||||
void Enter_Largest_Child( void ); // Make the largest child the new parent
|
||||
void Enter_Parent( void ); // Make the current parent's parent the new parent
|
||||
|
||||
// Access the current child
|
||||
const char * Get_Current_Name( void ) { return CurrentChild->Get_Name(); }
|
||||
int Get_Current_Total_Calls( void ) { return CurrentChild->Get_Total_Calls(); }
|
||||
float Get_Current_Total_Time( void ) { return CurrentChild->Get_Total_Time(); }
|
||||
|
||||
// Access the current parent
|
||||
const char * Get_Current_Parent_Name( void ) { return CurrentParent->Get_Name(); }
|
||||
int Get_Current_Parent_Total_Calls( void ) { return CurrentParent->Get_Total_Calls(); }
|
||||
float Get_Current_Parent_Total_Time( void ) { return CurrentParent->Get_Total_Time(); }
|
||||
CProfileNode * GetParentPtr() {return CurrentParent;}
|
||||
CProfileNode * GetChildPtr() { return CurrentChild;}
|
||||
protected:
|
||||
|
||||
CProfileNode * CurrentParent;
|
||||
CProfileNode * CurrentChild;
|
||||
|
||||
CProfileIterator( CProfileNode * start );
|
||||
friend class CProfileManager;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** The Manager for the Profile system
|
||||
*/
|
||||
class CProfileManager {
|
||||
public:
|
||||
static void Start_Profile( const char * name );
|
||||
static void Stop_Profile( void );
|
||||
|
||||
static void Reset( void );
|
||||
static void Increment_Frame_Counter( void );
|
||||
static int Get_Frame_Count_Since_Reset( void ) { return FrameCounter; }
|
||||
static float Get_Time_Since_Reset( void );
|
||||
|
||||
static CProfileIterator * Get_Iterator( void ) { return new CProfileIterator( &Root ); }
|
||||
static void Release_Iterator( CProfileIterator * iterator ) { delete iterator; }
|
||||
|
||||
private:
|
||||
static CProfileNode Root;
|
||||
static CProfileNode * CurrentNode;
|
||||
static int FrameCounter;
|
||||
static __int64 ResetTime;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** ProfileSampleClass is a simple way to profile a function's scope
|
||||
** Use the PROFILE macro at the start of scope to time
|
||||
*/
|
||||
class CProfileSample {
|
||||
public:
|
||||
CProfileSample( const char * name )
|
||||
{
|
||||
CProfileManager::Start_Profile( name );
|
||||
}
|
||||
|
||||
~CProfileSample( void )
|
||||
{
|
||||
CProfileManager::Stop_Profile();
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef WBDEBUG
|
||||
#define PROFILE( name ) CProfileSample __profile( name )
|
||||
#else
|
||||
#define PROFILE( name )
|
||||
#endif
|
||||
|
||||
|
||||
73
GameTools/Effect/readme.txt
Normal file
73
GameTools/Effect/readme.txt
Normal file
@@ -0,0 +1,73 @@
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
You can find the latest version of this source at:
|
||||
|
||||
HTTP://www.FluidStudios.com/publications.html
|
||||
|
||||
!IMPORTANT! Please spend just a couple minutes reading the comments at the top
|
||||
of the mmgr.cpp file... it will save you a lot of headaches!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
This code originally appeared on www.flipcode.com as an entry to the
|
||||
"Ask Midnight" column titled "Presenting A Memory Manager":
|
||||
|
||||
http://www.flipcode.com/askmid/archives.shtml
|
||||
|
||||
Here's the text that appeared with the release of this code:
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
This installment of the Ask Midnight column is not in response to a question,
|
||||
but rather a follow-up to the last question about memory management & tracking.
|
||||
I’ve spent the past week developing and testing a new industrial-grade memory
|
||||
manager.
|
||||
|
||||
During this effort, I found three bugs in an application I thought to be bug-
|
||||
free (at least, as far as memory usage goes.) I had this confidence because I
|
||||
often run with BoundsChecker (as well as the memory tracking tools in the
|
||||
Microsoft libraries.) Neither of these tools was able to locate these particular
|
||||
bugs, so I assumed the bugs didn’t actually exist. As it turns out, the memory
|
||||
manager presented here located them and told me exactly where to go to fix them.
|
||||
As a result, I now have a little more confidence in the application I was
|
||||
testing with, and even more confidence in my memory tracker. Here’s what this
|
||||
memory tracker told me:
|
||||
|
||||
* I was never deallocating the frame buffer. Sounds simple but the fact is,
|
||||
neither BoundsChecker nor Microsoft’s memory tracking library noticed this
|
||||
memory leak.
|
||||
|
||||
* I noticed that there was over a MEG of unused RAM in the memory report. By
|
||||
attaching a memory report dump to a key, I was able to see a snapshot of what
|
||||
memory was in use (every single allocation) and noticed that a particular
|
||||
block of allocated RAM contained a large amount of unused RAM within it. Going
|
||||
to the line in the source where the allocation took place, I found that I was
|
||||
allocating a z-buffer from legacy code and had forgot to remove the allocation
|
||||
when I removed the rest of the z-buffer code.
|
||||
|
||||
* When the application started up, the window would be bright green prior
|
||||
rendering the first frame. This was because the "unused memory" fill pattern
|
||||
used by the memory manager translates to bright green. Looking at the source,
|
||||
I found that I wasn’t clearing the frame buffer after the allocation.
|
||||
|
||||
Is your code bug-free? Take the Memory Manager challenge! I urge you to include
|
||||
this software in your projects as a test. If your projects have any size to them
|
||||
at all, or use memory in a multitude of various ways, then this memory tracker
|
||||
may very likely find bugs in your code that you never knew were there. Just
|
||||
include this software with your project, include the MMGR.H file in each of your
|
||||
source files and recompile. After each run, check for any MEM*.LOG files in the
|
||||
project’s directory. If you really want to test your software, simply edit
|
||||
MMGR.CPP and uncomment the STRESS_TEST macro. This will slow your allocations
|
||||
down a bit, but it’s worth it. And finally, spend a couple minutes and read the
|
||||
comments at the top of the MMGR.CPP file.
|
||||
|
||||
If this code helps you find bugs you never knew existed or helps you track down
|
||||
a tough bug, then please visit this issue of Ask Midnight and leave a
|
||||
testimonial in the comments. I will periodically check them and may eventually
|
||||
release an updated version of this software based on your comments.
|
||||
|
||||
So go ahead. Take the challenge. I dare you. :)
|
||||
|
||||
- Paul Nettle
|
||||
midnight@FluidStudios.com
|
||||
|
||||
378
GameTools/EffectEditor/Bubble.cpp
Normal file
378
GameTools/EffectEditor/Bubble.cpp
Normal file
@@ -0,0 +1,378 @@
|
||||
// Bubble.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Bubble.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
static CBitmap bmpShadow;
|
||||
static CBrush brShadow;
|
||||
|
||||
#define SHADOW_SIZE 5
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CBubble
|
||||
|
||||
// static members
|
||||
CString CBubble::m_strClassName;
|
||||
|
||||
CBubble::CBubble()
|
||||
{
|
||||
m_iTextFormat = DT_CENTER;
|
||||
m_iRowHeight = 0;
|
||||
m_iImageWidth = 0;
|
||||
m_iImageHeight = 0;
|
||||
m_bShadow = FALSE;
|
||||
}
|
||||
|
||||
CBubble::~CBubble()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CBubble::Create(CWnd* pWndParent, BOOL bShadow)
|
||||
{
|
||||
m_bShadow = bShadow;
|
||||
|
||||
// create our bubble window but leave it invisible
|
||||
|
||||
// do we need to register the class?
|
||||
if (m_strClassName.IsEmpty ())
|
||||
{
|
||||
// first, create the background brush
|
||||
CBrush brBrush;
|
||||
|
||||
try
|
||||
{
|
||||
brBrush.CreateSolidBrush (::GetSysColor (COLOR_INFOBK));
|
||||
}
|
||||
catch (CResourceException* pEx)
|
||||
{
|
||||
// brush creation failed
|
||||
pEx->Delete ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// register the class name
|
||||
m_strClassName = ::AfxRegisterWndClass (
|
||||
CS_BYTEALIGNCLIENT | CS_SAVEBITS | CS_HREDRAW | CS_VREDRAW,
|
||||
0,
|
||||
(HBRUSH)brBrush.Detach ());
|
||||
|
||||
// we're we successful?
|
||||
if (m_strClassName.IsEmpty ())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// create the bubble window and set the created flag
|
||||
CRect rect;
|
||||
rect.SetRectEmpty();
|
||||
|
||||
HWND hwndParent = (pWndParent == NULL) ? NULL :
|
||||
pWndParent->GetSafeHwnd ();
|
||||
if (!CreateEx (0, m_strClassName, _T (""), WS_POPUP,
|
||||
rect.left, rect.top, rect.right, rect.bottom,
|
||||
hwndParent, (HMENU)NULL))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (bmpShadow.GetSafeHandle () == NULL)
|
||||
{
|
||||
ASSERT (brShadow.GetSafeHandle () == NULL);
|
||||
|
||||
int aPattern[] = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55};
|
||||
bmpShadow.CreateBitmap (8, 8, 1, 1, aPattern);
|
||||
brShadow.CreatePatternBrush (&bmpShadow);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CBubble, CWnd)
|
||||
//{{AFX_MSG_MAP(CBubble)
|
||||
ON_WM_PAINT()
|
||||
ON_WM_ERASEBKGND()
|
||||
//}}AFX_MSG_MAP
|
||||
ON_MESSAGE(WM_SETTEXT, OnSetText)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CBubble message handlers
|
||||
|
||||
void CBubble::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
// paint our text, centered in the window
|
||||
CRect rect;
|
||||
GetClientRect(rect);
|
||||
|
||||
if (m_bShadow)
|
||||
{
|
||||
rect.right -= SHADOW_SIZE;
|
||||
rect.bottom -= SHADOW_SIZE;
|
||||
}
|
||||
|
||||
dc.FillSolidRect (&rect, ::GetSysColor (COLOR_INFOBK));
|
||||
dc.Draw3dRect (rect, GetSysColor (COLOR_3DSHADOW), GetSysColor (COLOR_3DDKSHADOW));
|
||||
|
||||
// select our font and setup for text painting
|
||||
CFont *pOldFont = (CFont*) dc.SelectStockObject (DEFAULT_GUI_FONT);
|
||||
dc.SetBkMode(TRANSPARENT);
|
||||
dc.SetTextColor(::GetSysColor (COLOR_INFOTEXT));
|
||||
|
||||
// paint our text
|
||||
int y = rect.top + 3 * GetSystemMetrics(SM_CYBORDER);
|
||||
int x;
|
||||
|
||||
TEXTMETRIC tm;
|
||||
dc.GetTextMetrics(&tm);
|
||||
|
||||
for (POSITION pos = m_strTextRows.GetHeadPosition (); pos != NULL;)
|
||||
{
|
||||
CString strText = m_strTextRows.GetNext (pos);
|
||||
|
||||
x = m_iImageWidth + 5;
|
||||
|
||||
if (strText [0] == '\r') // Draw a line
|
||||
{
|
||||
dc.SelectStockObject (WHITE_PEN);
|
||||
dc.MoveTo (x, y);
|
||||
dc.LineTo (rect.right - x, y);
|
||||
|
||||
dc.SelectStockObject (BLACK_PEN);
|
||||
dc.MoveTo (x, y + 1);
|
||||
dc.LineTo (rect.right - 5, y + 1);
|
||||
|
||||
strText = strText.Right (strText.GetLength () - 1);
|
||||
y += 5;
|
||||
}
|
||||
|
||||
if (strText [0] == '\a' && // Next 2 digits - image number
|
||||
m_Images.GetSafeHandle () != NULL)
|
||||
{
|
||||
int iImage = _ttol (strText.Mid (1, 2));
|
||||
m_Images.Draw (&dc, iImage, CPoint (3, y), ILD_NORMAL);
|
||||
|
||||
strText = strText.Mid (3);
|
||||
}
|
||||
|
||||
CRect rectText = rect;
|
||||
rectText.top = y;
|
||||
rectText.left = x;
|
||||
rectText.bottom = y + tm.tmHeight + tm.tmExternalLeading;
|
||||
|
||||
int iFormat = m_iTextFormat | DT_SINGLELINE | DT_VCENTER;
|
||||
dc.DrawText (strText, rectText, iFormat);
|
||||
y += m_iRowHeight;
|
||||
}
|
||||
|
||||
// Draw shadow:
|
||||
if (m_bShadow)
|
||||
{
|
||||
dc.SetBkColor(RGB(255,255,255));
|
||||
|
||||
brShadow.UnrealizeObject ();
|
||||
CBrush *pbrOld = (CBrush *) dc.SelectObject (&brShadow);
|
||||
|
||||
// bottom shadow
|
||||
|
||||
dc.PatBlt (rect.left + SHADOW_SIZE,
|
||||
rect.bottom,
|
||||
rect.Width (),
|
||||
SHADOW_SIZE,
|
||||
0xA000C9);
|
||||
|
||||
// right-side shadow
|
||||
|
||||
dc.PatBlt (rect.right,
|
||||
rect.top + SHADOW_SIZE,
|
||||
SHADOW_SIZE,
|
||||
rect.Height (),
|
||||
0xA000C9);
|
||||
dc.SelectObject(pbrOld);
|
||||
}
|
||||
|
||||
dc.SelectObject(pOldFont);
|
||||
}
|
||||
//*******************************************************************************************
|
||||
BOOL CBubble::OnEraseBkgnd(CDC* pDC)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
//*******************************************************************************************
|
||||
afx_msg LONG CBubble::OnSetText(UINT, LONG lParam)
|
||||
{
|
||||
// resize the bubble window to fit the new string
|
||||
int i;
|
||||
|
||||
m_iTextFormat = DT_CENTER;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Parse a text to get bitmaps + lines. For example, if text
|
||||
// looks "<\a><image1-res-id>text1<\n><\a><image2-res-id>text2",
|
||||
// we should create a bubble window with tow rows and draw in the
|
||||
// beggining of each row a specific bitmap:
|
||||
// (REMARK: image should be placed in the start of row only!)
|
||||
//-----------------------------------------------------------
|
||||
CString str ((LPCTSTR) lParam);
|
||||
|
||||
m_strTextRows.RemoveAll ();
|
||||
|
||||
// compute new size based on string x extent
|
||||
CClientDC dc(this);
|
||||
|
||||
CFont *pOldFont = (CFont*) dc.SelectStockObject (DEFAULT_GUI_FONT);
|
||||
|
||||
// get the text metrics
|
||||
TEXTMETRIC tm;
|
||||
dc.GetTextMetrics(&tm);
|
||||
|
||||
m_iRowHeight = max (m_iImageHeight, tm.tmHeight + tm.tmExternalLeading);
|
||||
int nBubbleHeight = 6*GetSystemMetrics(SM_CYBORDER);
|
||||
|
||||
int nMaxWidth = 0;
|
||||
int nExtraHeight = 0;
|
||||
|
||||
CString strTmp = str;
|
||||
while ((i = strTmp.Find ('\r')) != -1)
|
||||
{
|
||||
nExtraHeight += 5;
|
||||
strTmp = strTmp.Right (strTmp.GetLength () - i - 1);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
CString strCurrRow;
|
||||
|
||||
if ((i = str.Find ('\n')) == -1)
|
||||
{
|
||||
strCurrRow = str; // Whole string
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iTextFormat = DT_LEFT;
|
||||
strCurrRow = str.Left (i);
|
||||
str = str.Right (str.GetLength () - i - 1);
|
||||
}
|
||||
|
||||
if (strCurrRow.IsEmpty ())
|
||||
{
|
||||
strCurrRow = " ";
|
||||
}
|
||||
|
||||
m_strTextRows.AddTail (strCurrRow);
|
||||
|
||||
int iCurrWidth = m_iImageWidth;
|
||||
if (strCurrRow [0] == '\a')
|
||||
{
|
||||
strCurrRow = strCurrRow.Mid (3);
|
||||
}
|
||||
|
||||
iCurrWidth += dc.GetTextExtent (strCurrRow).cx;
|
||||
if (iCurrWidth > nMaxWidth)
|
||||
{
|
||||
nMaxWidth = iCurrWidth;
|
||||
}
|
||||
|
||||
nBubbleHeight += m_iRowHeight;
|
||||
}
|
||||
while (i != -1);
|
||||
|
||||
CRect rect;
|
||||
GetWindowRect(rect); // get current size and position
|
||||
|
||||
// compute width
|
||||
rect.right = rect.left + nMaxWidth + (6*GetSystemMetrics(SM_CXBORDER)) + 10;
|
||||
|
||||
// set height
|
||||
rect.bottom = rect.top + nBubbleHeight + nExtraHeight;
|
||||
|
||||
if (m_bShadow)
|
||||
{
|
||||
rect.right += SHADOW_SIZE;
|
||||
rect.bottom += SHADOW_SIZE;
|
||||
}
|
||||
|
||||
MoveWindow(&rect);
|
||||
|
||||
// clean up
|
||||
dc.SelectObject(pOldFont);
|
||||
|
||||
// do the default processing
|
||||
return CWnd::Default();
|
||||
}
|
||||
//*******************************************************************************************
|
||||
void CBubble::Track(CPoint point, const CString& string)
|
||||
{
|
||||
if (m_strLastText == string &&
|
||||
m_ptLastPoint == point)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// set the text
|
||||
SetWindowText(string);
|
||||
|
||||
// move the window
|
||||
SetWindowPos(&wndTop, point.x, point.y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
|
||||
//-----------------------------------------------
|
||||
// Adjust the window position by the screen size:
|
||||
//-----------------------------------------------
|
||||
CRect rectWindow;
|
||||
GetWindowRect (rectWindow);
|
||||
|
||||
if (rectWindow.right > ::GetSystemMetrics (SM_CXFULLSCREEN))
|
||||
{
|
||||
point.x = ::GetSystemMetrics (SM_CXFULLSCREEN) - rectWindow.Width ();
|
||||
SetWindowPos(&wndTop, point.x, point.y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
if (rectWindow.bottom > ::GetSystemMetrics (SM_CYFULLSCREEN) - 20)
|
||||
{
|
||||
point.y = ::GetSystemMetrics (SM_CYFULLSCREEN) - rectWindow.Height () - 20;
|
||||
SetWindowPos(&wndTop, point.x, point.y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
// show the window
|
||||
ShowWindow(SW_SHOWNOACTIVATE);
|
||||
Invalidate ();
|
||||
UpdateWindow ();
|
||||
|
||||
m_strLastText = string;
|
||||
m_ptLastPoint = point;
|
||||
}
|
||||
//*******************************************************************************************
|
||||
void CBubble::Hide()
|
||||
{
|
||||
// hide the bubble window
|
||||
ShowWindow(SW_HIDE);
|
||||
m_strLastText.Empty ();
|
||||
}
|
||||
//*******************************************************************************************
|
||||
BOOL CBubble::SetImageList (UINT uiId, int iImageWidth, COLORREF cltTransparent)
|
||||
{
|
||||
if (!m_Images.Create (uiId, iImageWidth, 0, cltTransparent))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IMAGEINFO info;
|
||||
m_Images.GetImageInfo (0, &info);
|
||||
|
||||
CRect rect = info.rcImage;
|
||||
|
||||
m_iImageWidth = rect.Width () + 3;
|
||||
m_iImageHeight = rect.Height ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
81
GameTools/EffectEditor/Bubble.h
Normal file
81
GameTools/EffectEditor/Bubble.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#if !defined(AFX_BUBBLE_H__BC6DC093_229B_11D1_8F0A_00A0C93A70EC__INCLUDED_)
|
||||
#define AFX_BUBBLE_H__BC6DC093_229B_11D1_8F0A_00A0C93A70EC__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
// Bubble.h : header file
|
||||
//
|
||||
|
||||
#ifndef __AFXCMN_H__
|
||||
#include <afxcmn.h>
|
||||
#endif // __AFXCMN_H__
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CBubble window
|
||||
|
||||
class CBubble : public CWnd
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CBubble();
|
||||
|
||||
// Attributes
|
||||
private:
|
||||
static CString m_strClassName; // bubble window class name
|
||||
CStringList m_strTextRows; // text rows
|
||||
CString m_strLastText;
|
||||
CPoint m_ptLastPoint;
|
||||
CImageList m_Images;
|
||||
int m_iRowHeight;
|
||||
int m_iImageWidth;
|
||||
int m_iImageHeight;
|
||||
BOOL m_bShadow;
|
||||
|
||||
// Operations
|
||||
public:
|
||||
BOOL Create(CWnd* pWndParent = NULL, BOOL bShadow = FALSE); // create the bubble window
|
||||
|
||||
// request the bubble window to track with the specified text and string resource ID
|
||||
void Track(CPoint pt, const CString& string);
|
||||
void Hide(); // hide the bubble window
|
||||
|
||||
void SetTextFormat (int iFormat)
|
||||
{
|
||||
m_iTextFormat = iFormat;
|
||||
}
|
||||
|
||||
int GetTextFormat () const
|
||||
{
|
||||
return m_iTextFormat;
|
||||
}
|
||||
|
||||
BOOL SetImageList (UINT uiId, int iImageWidth = 15, COLORREF cltTransparent = RGB (255, 0, 255));
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CBubble)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CBubble();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CBubble)
|
||||
afx_msg void OnPaint();
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
//}}AFX_MSG
|
||||
afx_msg LONG OnSetText(UINT, LONG lParam);
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
int m_iTextFormat;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_BUBBLE_H__BC6DC093_229B_11D1_8F0A_00A0C93A70EC__INCLUDED_)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user