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:
2025-11-29 20:17:20 +09:00
parent 5d3cd64a25
commit dd97ddec92
11602 changed files with 1446576 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View 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 <20><>
#define DEFAULTESTICK 40
enum EZVALUE {
ESNORMAL, // normal effect
ESINTERFACE, // interface effect
};
enum EDIR{
EUP,
ELEFT,
ERIGHT,
EFRONT,
ERAND
};
enum ECURRENT{ // <20><><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD> <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>̴<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
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 { // <20><20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..
ED, // Delay frame
ES, // S effect
EM, // M effect
EE, // E effect
EN, //Snap effect
EF, //finish effect
};
enum EPIVOT { // extension4 <20><> 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

File diff suppressed because it is too large Load Diff

View 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;
// <20>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD>
bool m_Bil1;
bool m_Bil2;
bool m_Bil3;
// multy uv ani
bool m_Multy;
bool m_TexAni;
bool m_RandAni;
bool m_RandStartTexAni; //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٸ<EFBFBD> <20>ؽ<EFBFBD><D8BD><EFBFBD> <20>ִ<EFBFBD> flag
bool m_RandStartSetting; //start <20>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD>
bool m_Zenable;
bool m_Opacity;
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> texture <20><><EFBFBD><EFBFBD>
int m_AniTextureNum;
int m_CurrentAniTexture;
int m_BeforeAniTexture;
int m_Red;
int m_Green;
int m_Blue;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
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 <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD> 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 <20><> <20><><EFBFBD><EFBFBD>
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 <20><><EFBFBD><EFBFBD> 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 <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD> vert pointer
//GemVertex *m_Vert;
int VbufferNum;
// multy uv ani
CGemRender *m_Multy;
bool m_bLight;
char m_FileName[256];
};
#endif

File diff suppressed because it is too large Load Diff

View 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 <20><> ǥ<><C7A5> <20>ϴ<EFBFBD> plane <20><><EFBFBD><EFBFBD>
enum PLANE {
LPLANE_ONE, // one plane
LPLANE_CROSS, //<2F><><EFBFBD><EFBFBD> plane
LPLANE_X, // X<><58> plane
};
enum LIGHTNINGVALUE { // <20><EFBFBD><EEB6B2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : 0 <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE>, <20><><EFBFBD><EFBFBD>, 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
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 <20><><EFBFBD><EFBFBD> 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;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
D3DXVECTOR3 *m_PointList;
int m_EndCount;
int m_PointNum;
// <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> width
float m_QuadHalfWidth;
// insert <20><> point
int m_InsertCount;
// render <20><> count
int m_RenderCount;
int m_MaxRenderCount;
LPDIRECT3DDEVICE8 m_Device;
//<2F><><EFBFBD><EFBFBD> <20>÷<EFBFBD>
LPDIRECT3DVERTEXBUFFER8 *m_Vert;
// <20><><EFBFBD><EFBFBD> <20>÷<EFBFBD>
LPDIRECT3DVERTEXBUFFER8 *m_VerticalVert;
// <20><><EFBFBD><EFBFBD> <20>÷<EFBFBD> 2
LPDIRECT3DVERTEXBUFFER8 *m_VerticalVert2;
int m_VertNum;
CTexture *m_Texture;
int m_TexNum;
//shake value <20>ּ<EFBFBD>ġ
float m_ShakeMin;
//shake value <20>ִ<EFBFBD>ġ
float m_ShakeMax;
DWORD m_Color;
float m_Alpha;
bool m_bFadeOut;
float m_FadeSpeed;
// uv ani <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ġ
float m_UvAni;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> uv <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
float m_UnitUv;
// <20><><EFBFBD><EFBFBD>, 1<><31> <20>÷<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
int m_PlaneValue;
// <20><><EFBFBD><EFBFBD>Ʈ end setting
bool m_bSetEndEffect;
// <20>پ<EFBFBD><D9BE><EFBFBD><EFBFBD><EFBFBD> <20>ӵ<EFBFBD>
int m_EndUnit;
int m_LightningValue;
// Bezier Value
CBezierInfo m_Bezier;
bool m_bCrash; // <20><EFBFBD><E6B5B9> light beam <20>ΰ<EFBFBD>?
bool m_bEndInput;
int m_iAlpha; // <20><EFBFBD><E6B5B9> light beam alpha value
CLightVertex *tmp_Vertex;
CLightVertex *tmp_Vertex2;
CLightVertex *tmp_Vertex3;
CLightning(LPDIRECT3DDEVICE8 );
CLightning(int ,LPDIRECT3DDEVICE8 );
CLightning();
~CLightning();
//wheel<65><6C> <20><><EFBFBD>õǾ<C3B5> <20>ִ<EFBFBD> esf <20><><EFBFBD><EFBFBD> wheel <20><> <20><><EFBFBD>̻<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> setting
// render2<72><32> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
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 (<28><><EFBFBD><EFBFBD> <20>׸<EFBFBD><D7B8><EFBFBD> <20><>ƾ)
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

View 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

View 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);
}

View 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
View 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

View 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

Binary file not shown.

View 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>

View 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="&quot;$/Effect&quot;, 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>

View 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<65><72> <20><><EFBFBD><EFBFBD> <20>߽<EFBFBD><DFBD>ϴ<EFBFBD>.","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 <20>ȿ<EFBFBD> <20>Ȱ<EFBFBD><C8B0><EFBFBD> Hash Index <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
((*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( <20><><EFBFBD>ڿ<EFBFBD> )
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;
}

View 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
View 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)

View 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
// <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>÷ο<C3B7> Ȥ<><C8A4> <20>޸𸮸<DEB8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
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 <20>޸<EFBFBD><DEB8><EFBFBD> <20>Ҵ<EFBFBD> <20><><EFBFBD><EFBFBD>.
return false;
}
pChunkNode->m_pNext = m_pChunkHead;
m_pChunkHead = pChunkNode;
m_pNodeHead = reinterpret_cast<AllocateInfo*>(m_pChunkHead + 1);
m_nTotalAllocated += m_nPerAllocateNum; // <20><>ü <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
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
// <09>޸𸮰<DEB8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD> <20>е<EFBFBD><D0B5><EFBFBD> <20><><EFBFBD><EFBFBD>.
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 <20>޸<EFBFBD><DEB8><EFBFBD> Ǯ<><C7AE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>÷ο<C3B7> <20>Ǵ<EFBFBD>, "
"<EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>־<EFBFBD><D6BE><EFBFBD><EFBFBD>ϴ<EFBFBD>. 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)
{
// <09>޸<EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD> <20>α׸<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. (Chunk<6E><6B> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>޸𸮸<DEB8> ã<>Ƴ<EFBFBD><C6B3><EFBFBD>.)
/*FILE* pLogFile = fopen(ms_strErrLogFileName, "ab");
if(NULL != pLogFile)
{
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
fprintf(pLogFile, "[%d-%d-%d %d:%d:%d] %s <20>޸<EFBFBD><DEB8><EFBFBD> Ǯ<><C7AE><EFBFBD><EFBFBD> %d<><64><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>. <20>α׷<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.\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 = "<EFBFBD>׽<EFBFBD>ƮǮ";
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");
}

View 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

View 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<6E><67> Log File Write <20><>ƾ
#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, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 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();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
}
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);
}
}

View 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;
// <20><><EFBFBD><EFBFBD>Ʈ <20>̵<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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<63><74> <20><><EFBFBD><EFBFBD> <20>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD>
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 <20><><EFBFBD><EFBFBD>
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_)

View 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;
}

View 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; // <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
// 0 : <20><>ƼŬ 1 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 2 : <20>Ǹ<EFBFBD><C7B8><EFBFBD> 3 : <20>÷<EFBFBD><C3B7><EFBFBD>
// 4 : <20><><EFBFBD>Ǿ<EFBFBD> 5 : <20>޽<EFBFBD>
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 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
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 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
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_)

View 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);
}

View 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;
// <20><><EFBFBD><EFBFBD> Interpolation <20><> <20><><EFBFBD><EFBFBD>
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_)

View 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);
}

View 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_)

View 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)];
// <20><><EFBFBD><EFBFBD> <20>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD> 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()) { // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20>ƴϸ<C6B4> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
if(new_script->GetBSkill() && (!new_script->GetChant())) { // skill effect <20≯<EFBFBD> <20><><EFBFBD><EFBFBD>
if(m_EffScriptLimitCount > m_EffScriptLimitNum) {
return NULL;
}
else
m_EffScriptLimitCount++;
}
}
m_lstScript.push_back(new_script);
// _ASSERTE( _CrtCheckMemory());
///////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ <20>׽<EFBFBD>Ʈ///
/*
// 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) {
// Ư<><C6AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/* 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 <20><> <20>̿<EFBFBD><CCBF>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> setting
}
m_lstIScript.push_back(new_script);
new_script->SetDevice(m_lpD3DDevice);
return new_script;
}
int CX3DEffectManager::ProcessScript(int i) {// return value 0: <20><>ũ<EFBFBD><C5A9>Ʈ <20><><EFBFBD><EFBFBD>
// 1: <20><>ũ<EFBFBD><C5A9>Ʈ <20><><EFBFBD><EFBFBD>
// 2: effect target<65><74> <20>
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;
}
// <20>ι<EFBFBD>° Ÿ<><C5B8><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ <20>˻<EFBFBD> :: NULL <20≯<EFBFBD> ó<><C3B3> <20><><EFBFBD>̶<EFBFBD><CCB6><EFBFBD> <20>ǹ̷<C7B9> 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 <20><><EFBFBD><EFBFBD>
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 <20><><EFBFBD><EFBFBD>
if(m_lstWScript[i]->GetSectorCull())
continue;
}
if(m_lstWScript[i]->m_bPlayTime) { // Play Time Setting <20>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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()) { // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20>ƴϸ<C6B4> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
if(m_lstScript[i]->GetBSkill()) { // skill effect <20≯<EFBFBD> <20><><EFBFBD><EFBFBD>
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()) { // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20>ƴϸ<C6B4> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
if(m_lstScript[i]->GetBSkill()) { // skill effect <20≯<EFBFBD> <20><><EFBFBD><EFBFBD>
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();
}

View 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;
// <20><><EFBFBD><EFBFBD> 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();
// <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9>Ʈ
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_)

View 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 <20><><EFBFBD><EFBFBD> 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;
// <09><><EFBFBD><EFBFBD>:m_GemRender = new CGemRender;
}
CX3DEffectMesh::~CX3DEffectMesh()
{
if(m_moMesh) { delete[] m_moMesh; m_moMesh = NULL; }
SubUseCount(m_GemRender->GetFileName()); // <20><><EFBFBD><EFBFBD> ī<><C4AB><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD>
// <09><><EFBFBD><EFBFBD>: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 <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <20>ذ<EFBFBD>
// Texture ani <20><> Random Start Texture Ani <20>׸<EFBFBD><D7B8><EFBFBD> Random Ani <20><> <20><><EFBFBD><EFBFBD> m_GemObjectTexNum <20><EFBFBD><E8BFAD> <20>̿<EFBFBD><CCBF>Ѵ<EFBFBD>
// Gem<65><6D> ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ͼ<CFBE><EEB3AA> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϳ<EFBFBD><CFB3><EFBFBD>.
// m_GemObjectTexNum[ 0 ~ ObjectNum - 1] : <20>ؽ<EFBFBD><D8BD><EFBFBD> <20>ִ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mesh<73><68> <20><><EFBFBD><EFBFBD> <20>ý<EFBFBD><C3BD><EFBFBD> <20><>ȣ
// m_GemObjectTexNun[ObjectNum] : Mesh Before Frame
// m_GemObjectTexNum[ObjectNum + 1] : Mesh Current Frame
// m_GemObjectTexNum[ObjectNum + 2] : <20><><EFBFBD><EFBFBD> <20><>ŸƮ <20>ִϽÿ<CFBD> ó<><C3B3> <20>ؽ<EFBFBD><D8BD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǿ<EFBFBD><C7BE>°<EFBFBD><C2B0><EFBFBD> üũ<C3BC>ϴ<EFBFBD> üũ <20>÷<EFBFBD><C3B7><EFBFBD>
// m_GemObjectTexNum[ObjectNum + 3] : <20>ؽ<EFBFBD><D8BD><EFBFBD> <20>ִϽÿ<CFBD> <20>ٷ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ؽ<EFBFBD><D8BD>İ<EFBFBD> <20><><EFBFBD>ŵǾ<C5B5><C7BE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
// Cash <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>ذ<EFBFBD>
// Cash <20><> <20>Կ<EFBFBD> <20>־ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SetCurrentFrame <20><> <20><><EFBFBD>־<EFBFBD><D6BE><EFBFBD> <20>Ѵ<EFBFBD>
// <20>׷<EFBFBD><D7B7>Ƿ<EFBFBD> gem <20><> update<74>Ǿ<EFBFBD><C7BE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> bUpdateFrame <20><> true <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>
// Update <20><><EFBFBD>ش<EFBFBD>.
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 <20>ȿ<EFBFBD> Mesh<73><68> <20><><EFBFBD>ٸ<EFBFBD> Cash List<73><74> input.
}
else { //Cash load
if(m_GemRender->m_bDecal) // Decal<61><6C> <20>̿<EFBFBD><CCBF>Ѱ͵<D1B0><CDB5><EFBFBD> Vertex Buffer <20><> <20>ʱ<EFBFBD>ȭ <20><><EFBFBD>ش<EFBFBD>
m_GemRender->SetInitBuffer();
}
// Frame Init
//m_GemRender->SetCurrentFrame(0.0f);
// Texture Load (<28><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD> Ŀ<><C4BF><EFBFBD>ִٰ<D6B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD> gem <20><> 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 <20><> Ų<><C5B2>
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 <20><> <20><><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ
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, "<EFBFBD>޽<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߸<EFBFBD><DFB8><EFBFBD><EFBFBD><EFBFBD>", "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, "<EFBFBD>޽<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߸<EFBFBD><DFB8><EFBFBD><EFBFBD><EFBFBD>", "Effect Editor", MB_OK);
}
}
////////////////////////////////// Mesh Cash Func Start //////////////////////////////////
void CX3DEffectMesh::InputCash(CGemRender *pMesh) { // Cash <20>ȿ<EFBFBD> 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<64><65> <20><><EFBFBD><EFBFBD> ī<><C4AB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
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 <20><><EFBFBD><EFBFBD> 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 <20><><EFBFBD><EFBFBD> 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 <20><><EFBFBD><EFBFBD> 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 //////////////////////////////////

View 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; // <20><> <20><><EFBFBD><20>̿<EFBFBD><CCBF>ϴ<EFBFBD> effect<63><74> <20><><EFBFBD><EFBFBD>(0<><30> <20>Ǹ<EFBFBD> list <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>)
_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 <20>Ǿ<EFBFBD><C7BE><EFBFBD> <20><> 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 <20><><EFBFBD><EFBFBD> mesh load
void InputCash(CGemRender *); // Cash <20>ȿ<EFBFBD> mesh data input
void DeleteCash(); // Cash <20><><EFBFBD><EFBFBD> mesh Data delete
//static void DeleteAllCash(); // Cash <20><><EFBFBD><EFBFBD> delete
void SubUseCount(char *strFilename); // Cash <20><><EFBFBD><EFBFBD> ī<><C4AB><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD>
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_)

View 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 <20><> <20><>ƼŬ<C6BC><C5AC> end effect <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ڽ<EFBFBD><DABD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
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++;
// <20><><EFBFBD>İ<EFBFBD><C4B0><EFBFBD> 5<><35><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD> draw list<73><74><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
if((pVertices[mul +3].diff.a)<1) {
continue;
}
m_dwDrawAmount++;
}
///////////////////////////////////////////////////////////////////////////////////
m_lpVerticesBlend->Unlock();
m_lpVertices->Unlock();
} //if(m_bVisibility)
}
else { // <20>Ϲ<EFBFBD> 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++;
// <20><><EFBFBD>İ<EFBFBD><C4B0><EFBFBD> 1<><31><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD> draw list<73><74><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
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);
// <20><><EFBFBD><EFBFBD>
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<69><6F> <20><><EFBFBD><EFBFBD>Ʈ
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);
// <20><><EFBFBD><EFBFBD>
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<69><6F> <20><><EFBFBD><EFBFBD>Ʈ
m_lstWidth.Save(fp);
m_lstHeight.Save(fp);
m_lstColor.Save(fp);
}

View 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;
// <20><><EFBFBD><EFBFBD>
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;
// <20><>ƼŬ <20><><EFBFBD><EFBFBD> / <20><><EFBFBD><EFBFBD>
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<69><6F> <20><><EFBFBD><EFBFBD>Ʈ
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_)

View 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);
}

View 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_)

View 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);
}

View 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

File diff suppressed because it is too large Load Diff

165
GameTools/Effect/mmgr.h Normal file
View 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
View 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
// ---------------------------------------------------------------------------------------------------------------------------------

View 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
View 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

View 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<EFBFBD>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<64>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<72>s what this
memory tracker told me:
* I was never deallocating the frame buffer. Sounds simple but the fact is,
neither BoundsChecker nor Microsoft<66>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<73>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<EFBFBD>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<69>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