Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
7065
Engine/Effect/CEffscript.cpp
Normal file
7065
Engine/Effect/CEffscript.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1282
Engine/Effect/CEffscript.h
Normal file
1282
Engine/Effect/CEffscript.h
Normal file
File diff suppressed because it is too large
Load Diff
109
Engine/Effect/CEffscriptDefine.h
Normal file
109
Engine/Effect/CEffscriptDefine.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef __EFFSCRIPTDEFINE_H__
|
||||
#define __EFFSCRIPTDEFINE_H__
|
||||
|
||||
|
||||
#define ESBUF_SIZE 256
|
||||
#define ESEMPTY -1
|
||||
|
||||
#define ESSTART "INDEX"
|
||||
#define ESEND "FIN:"
|
||||
#define ESLIST "LIST:"
|
||||
#define ESLOOP "LOOP:"
|
||||
#define ESPLAY "PLAY:"
|
||||
#define ESSNAP "SNAP:"
|
||||
#define ESFADEOUT "OUT:"
|
||||
#define ESFADEIN "IN:"
|
||||
#define ESSHAKE "SHAKE:"
|
||||
#define ESSOUND "SOUND:"
|
||||
#define ESSUB "SUB:"
|
||||
#define ESCLIGHT "CLIGHT:"
|
||||
#define ESHIT "HIT:"
|
||||
#define ESSLIDE "SLIDE:"
|
||||
#define ESEXT5 "EXT5:"
|
||||
#define ESLIGHTN "LIGHTNING:"
|
||||
#define ESLIGHTN2 "LIGHTNING2:"
|
||||
#define ESLIGHTN3 "LIGHTNING3:"
|
||||
#define ESWHEEL "WHEEL:"
|
||||
#define ESWEAPON "WEAPON:"
|
||||
#define ESBEZIERM "GHOST:"
|
||||
#define ESLIGHT "LIGHT:"
|
||||
#define ESPLAYT "PLAYTIME:"
|
||||
#define ESCHAR "CHARACTER:"
|
||||
#define ESWEAPONL "WEAPONLINE:"
|
||||
|
||||
#define ESPI 3.14159f
|
||||
#define ESHALF_PI (ESPI/2)
|
||||
#define ESGRAVITY 9.806650f
|
||||
|
||||
#define ESEXTLINESIZE 8.0f //line size
|
||||
|
||||
//m_TickFrame deault <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
|
||||
2607
Engine/Effect/CGemRender.cpp
Normal file
2607
Engine/Effect/CGemRender.cpp
Normal file
File diff suppressed because it is too large
Load Diff
443
Engine/Effect/CGemRender.h
Normal file
443
Engine/Effect/CGemRender.h
Normal file
@@ -0,0 +1,443 @@
|
||||
#ifndef __CGEMRENDER_H__
|
||||
#define __CGEMRENDER_H__
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
|
||||
#define BUF_SIZE 256
|
||||
#define VOT 1.0f
|
||||
#define GEM_HEADER "GemDataFile\n"
|
||||
|
||||
|
||||
class CGemRender {
|
||||
public:
|
||||
void SetClearBuffer(bool b);
|
||||
bool m_bClearBuffer;
|
||||
class GemTexture {
|
||||
public:
|
||||
CTexture *m_Tex;
|
||||
int TexNum;
|
||||
GemTexture() {
|
||||
m_Tex = NULL;
|
||||
TexNum = 0;
|
||||
}
|
||||
~GemTexture() {
|
||||
if(m_Tex) {
|
||||
/* if(TexNum >1)
|
||||
delete[] m_Tex;
|
||||
else*/
|
||||
delete[] m_Tex;
|
||||
}
|
||||
}
|
||||
};
|
||||
class GemSubFace{
|
||||
public:
|
||||
int *sub;
|
||||
int *sub_mat;
|
||||
int sub_num;
|
||||
GemSubFace() {
|
||||
sub = NULL;
|
||||
sub_mat = NULL;
|
||||
sub_num = 0;
|
||||
}
|
||||
~GemSubFace() {
|
||||
delete[] sub;
|
||||
delete[] sub_mat;
|
||||
}
|
||||
};
|
||||
class GemVertex{
|
||||
public:
|
||||
float x,y,z;
|
||||
float nx,ny,nz;
|
||||
float s,t;
|
||||
GemVertex() {
|
||||
x = y = z = 0.0f;
|
||||
nx = ny = nz = 0.0f;
|
||||
s = t = 0.0f;
|
||||
}
|
||||
~GemVertex() {}
|
||||
};
|
||||
class GemRotKey {
|
||||
public:
|
||||
int frame;
|
||||
D3DXVECTOR4 rot;
|
||||
|
||||
GemRotKey() {
|
||||
frame = 0;
|
||||
rot.x = rot.y = rot.z = rot.w = 0.0f;
|
||||
}
|
||||
|
||||
~GemRotKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemPosKey{
|
||||
public:
|
||||
int frame;
|
||||
bool bez;
|
||||
D3DXVECTOR3 pos;
|
||||
D3DXVECTOR3 intan;
|
||||
D3DXVECTOR3 outtan;
|
||||
GemPosKey() {
|
||||
frame = 0;
|
||||
bez = false;
|
||||
pos.x = pos.y = pos.z = 0.0f;
|
||||
intan.x = intan.y = intan.z = 0.0f;
|
||||
outtan.x = outtan.y = outtan.z = 0.0f;
|
||||
}
|
||||
~GemPosKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemScaleKey{
|
||||
public:
|
||||
int frame;
|
||||
D3DXVECTOR3 scale;
|
||||
GemScaleKey() {
|
||||
frame = 0;
|
||||
scale.x = scale.y = scale.z= 1.0f;
|
||||
}
|
||||
~GemScaleKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemVisKey{
|
||||
public:
|
||||
int frame;
|
||||
float vis;
|
||||
GemVisKey(){
|
||||
frame = 0;
|
||||
vis = 1.0f;
|
||||
}
|
||||
~GemVisKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemObject {
|
||||
public:
|
||||
char m_Name[BUF_SIZE];
|
||||
char m_ParentName[BUF_SIZE];
|
||||
bool m_bParent;
|
||||
|
||||
D3DXMATRIX m_TmMatrix;
|
||||
|
||||
// vertex info
|
||||
D3DXVECTOR2 *m_Coord;
|
||||
D3DXVECTOR3 *m_CoordFace;
|
||||
|
||||
D3DXVECTOR3 *m_Vert;
|
||||
D3DXVECTOR4 *m_Face;
|
||||
D3DXVECTOR3 *m_Fnormal;
|
||||
D3DXVECTOR3 *m_Normal;
|
||||
int m_MatId;
|
||||
|
||||
int m_Frame;
|
||||
int m_CoordNum;
|
||||
int m_VertexNum;
|
||||
int m_iStartBufferIndex;
|
||||
|
||||
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_iStartBufferIndex = 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);
|
||||
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);
|
||||
|
||||
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;}
|
||||
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;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertexBuffer;
|
||||
int m_iTotalVertexNums;
|
||||
bool m_bDynamic;
|
||||
VOID *m_VertexLockPtr;
|
||||
|
||||
|
||||
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
|
||||
1444
Engine/Effect/CLightning.cpp
Normal file
1444
Engine/Effect/CLightning.cpp
Normal file
File diff suppressed because it is too large
Load Diff
202
Engine/Effect/CLightning.h
Normal file
202
Engine/Effect/CLightning.h
Normal file
@@ -0,0 +1,202 @@
|
||||
#ifndef __CLIGHTNING_H__
|
||||
#define __CLIGHTNING_H__
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
|
||||
#define LIGHTHALFWIDTH 10.0f
|
||||
// lightning <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
|
||||
65
Engine/Effect/EffAseDefine.h
Normal file
65
Engine/Effect/EffAseDefine.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/************************
|
||||
ase label define
|
||||
**************************/
|
||||
|
||||
|
||||
|
||||
#ifndef __EFFASEDEFINE_H__
|
||||
|
||||
#define __EFFASEDEFINE_H__
|
||||
|
||||
#define OBJECT "*GEOMOBJECT" // An object tag for new objects
|
||||
#define LIGHT_OBJECT "*LIGHTOBJECT"
|
||||
#define NODE_NAME "*NODE_NAME"
|
||||
#define NODE_PARENT "*NODE_PARENT"
|
||||
#define NODE_TM "*NODE_TM"
|
||||
#define TM_ROW0 "*TM_ROW0"
|
||||
#define TM_ROW1 "*TM_ROW1"
|
||||
#define TM_ROW2 "*TM_ROW2"
|
||||
#define TM_ROW3 "*TM_ROW3"
|
||||
#define TM_POS "*TM_POS"
|
||||
#define TM_ROTAXIS "*TM_ROTAXIS"
|
||||
#define TM_ROTANGLE "*TM_ROTANGLE"
|
||||
#define TM_SCALE "*TM_SCALE"
|
||||
#define TM_SCALEAXIS "*TM_SCALEAXIS"
|
||||
#define TM_SCALEAXISANG "*TM_SCALEAXISANG"
|
||||
|
||||
#define BLOCK_START "{"
|
||||
#define BLOCK_END "}"
|
||||
|
||||
#define NUM_VERTEX "*MESH_NUMVERTEX" // The number of vertices tag
|
||||
#define NUM_FACES "*MESH_NUMFACES" // The number of faces tag
|
||||
#define NUM_TVERTEX "*MESH_NUMTVERTEX" // The number of texture coordinates
|
||||
#define VERTEX "*MESH_VERTEX" // The list of vertices tag
|
||||
#define FACE "*MESH_FACE" // The list of faces tag
|
||||
#define NORMALS "*MESH_NORMALS" // The list of normals tag (If you want)
|
||||
#define FACE_NORMAL "*MESH_FACENORMAL" // The face normal for the current index
|
||||
#define NVERTEX "*MESH_VERTEXNORMAL" // The list of vertex normals
|
||||
#define TVERTEX "*MESH_TVERT" // The texture coordinate index tag
|
||||
#define TFACE "*MESH_TFACE" // The vertex index tag
|
||||
#define TEXTURE "*BITMAP" // The file name for the object's texture map
|
||||
#define UTILE "*UVW_U_TILING" // The U tiling ratio tag
|
||||
#define VTILE "*UVW_V_TILING" // The V tiling ratio tag
|
||||
#define UOFFSET "*UVW_U_OFFSET" // The U tile offset tag
|
||||
#define VOFFSET "*UVW_V_OFFSET" // The V tile offset tag
|
||||
#define MATERIAL_ID "*MATERIAL_REF" // The material ID tag
|
||||
#define MATERIAL_COUNT "*MATERIAL_COUNT" // The material count tag
|
||||
#define MATERIAL "*MATERIAL" // The material tag
|
||||
#define MATERIAL_NAME "*MATERIAL_NAME" // The material name tag
|
||||
#define MATERIAL_COLOR "*MATERIAL_DIFFUSE" // The material color tag
|
||||
|
||||
#define TM_ANIMATION "*TM_ANIMATION"
|
||||
#define CONTROL_ROT_TCB "*CONTROL_ROT_TCB"
|
||||
#define CONTROL_TCB_ROT_KEY "*CONTROL_TCB_ROT_KEY"
|
||||
#define CONTROL_POS_BEZIER "*CONTROL_POS_BEZIER"
|
||||
#define CONTROL_BEZIER_POS_KEY "*CONTROL_BEZIER_POS_KEY"
|
||||
#define CONTROL_SCALE_BEZIER "*CONTROL_SCALE_BEZIER"
|
||||
#define CONTROL_BEZIER_SCALE_KEY "*CONTROL_BEZIER_SCALE_KEY"
|
||||
///////////////////////////////////
|
||||
// mesh ani value
|
||||
//////////////////////////////////
|
||||
#define MESH_ANIMATION "*MESH_ANIMATION"
|
||||
// use check ani frame num.
|
||||
#define MESH_TIMEVALUE "*TIMEVALUE"
|
||||
|
||||
#endif
|
||||
9
Engine/Effect/EffDebugLog.cpp
Normal file
9
Engine/Effect/EffDebugLog.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "EffDebugLog.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
void WriteDebug(char *strErr) {
|
||||
char *strDebugFile = "EffectErr.txt";
|
||||
FILE *fp = fopen(strDebugFile,"at+");
|
||||
fprintf(fp,"File Not Found : %s\n",strErr);
|
||||
fclose(fp);
|
||||
}
|
||||
8
Engine/Effect/EffDebugLog.h
Normal file
8
Engine/Effect/EffDebugLog.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __EFFDEBUGLOG__H__
|
||||
#define __EFFDEBUGLOG__H__
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
void WriteDebug(char *strErr);
|
||||
|
||||
#endif
|
||||
1231
Engine/Effect/EffMeshloader.cpp
Normal file
1231
Engine/Effect/EffMeshloader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
232
Engine/Effect/EffMeshloader.h
Normal file
232
Engine/Effect/EffMeshloader.h
Normal file
@@ -0,0 +1,232 @@
|
||||
#ifndef __EFFECTMESH_H__
|
||||
#define __EFFECTMESH_H__
|
||||
|
||||
#define BUF_SIZE 256
|
||||
|
||||
#include <vector>
|
||||
#include "EffAseDefine.h"
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
#define EFF_FILE "GEMDatafile"
|
||||
#define VOT 1.0f
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
class CEffectMesh {
|
||||
public:
|
||||
CEffectMesh();
|
||||
~CEffectMesh();
|
||||
|
||||
|
||||
bool LoadWadfile(char *filename,LPDIRECT3DDEVICE8 );
|
||||
float Render(LPDIRECT3DDEVICE8 ,D3DXVECTOR3 );
|
||||
D3DXMATRIX RotateObject(LPDIRECT3DDEVICE8 ,int object_index,float frame,D3DXMATRIX *w);
|
||||
D3DXMATRIX TranslateObject(LPDIRECT3DDEVICE8 d_device,int object_index,float frame,D3DXMATRIX *w);
|
||||
D3DXMATRIX ScaleObject(LPDIRECT3DDEVICE8 ,int object_index,float frame,D3DXMATRIX *w);
|
||||
int vertex_interpolation(int object_index,float now_frame);
|
||||
void Change_Vertexbuffer(int object_index);
|
||||
void SetObjectColor(int obj_num,int r,int g,int b,int a);
|
||||
void Create_Vertex(int i,LPDIRECT3DDEVICE8 );
|
||||
void CreateTexture(LPDIRECT3DDEVICE8 device);
|
||||
void CreateAniTexture(LPDIRECT3DDEVICE8 device,int obj_num);
|
||||
void LoadSubface(int object_index);
|
||||
void SetTexAniFrame(int object_index,float frame);
|
||||
void SetStartTexAni(int object_index,float frame);
|
||||
void StartTexAni(bool b) {m_texanistart = b;}
|
||||
void SetPickColor(int object_index,int r,int g,int b,int a);
|
||||
//picking <20>Ǿ<EFBFBD><C7BE>ִ<EFBFBD> object <20><> index
|
||||
void SetPickNum(int n) {pick_index = n;}
|
||||
void SetNullTexture(bool b) {m_NullTexture = b;}
|
||||
float UpdateMesh();
|
||||
|
||||
void SetFrame(float f);
|
||||
|
||||
void SetColor(int r,int g,int b,int a) {Color = D3DCOLOR_ARGB(a,r,g,b);}
|
||||
// alpha : 0~255
|
||||
float GetMaxframe() {return max_frame;}
|
||||
int GetObjectNum(){return Model.object_num;}
|
||||
void SetAlpha(int );
|
||||
void SetLoop(bool b) {m_Loop = b; }
|
||||
void StartAni(bool b) {m_Start = b;}
|
||||
void SetBlend(DWORD s,DWORD d) {SrcBlend = s; DstBlend = d;}
|
||||
|
||||
bool GetStart() {return m_Start;}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
void SetVot(float n) {vot = n;}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// in class
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class WadFace {
|
||||
public:
|
||||
vector<int> sub;
|
||||
int sub_num;
|
||||
};
|
||||
class WadTexture {
|
||||
public:
|
||||
vector<LPDIRECT3DTEXTURE8 *> tex;
|
||||
int tex_num;
|
||||
};
|
||||
class custom_vertex{
|
||||
public:
|
||||
float x,y,z;
|
||||
float nx,ny,nz;
|
||||
float s,t;
|
||||
};
|
||||
class custom_vertex2{
|
||||
public:
|
||||
float x,y,z;
|
||||
};
|
||||
|
||||
class AseFace{
|
||||
public:
|
||||
int vertex_index[4];
|
||||
int coord_index[3];
|
||||
};
|
||||
class AseMaterial{
|
||||
public:
|
||||
char texture_name[255];
|
||||
char texture_file[255];
|
||||
BYTE color[3];
|
||||
// standard ot multy/sub
|
||||
int mat_class;
|
||||
AseMaterial *sub;
|
||||
int sub_num;
|
||||
float fcolor[3];
|
||||
int tex_id;
|
||||
float u_tile;
|
||||
float v_tile;
|
||||
float u_offset;
|
||||
float v_offset;
|
||||
};
|
||||
class AseRotKey{
|
||||
public:
|
||||
int frame_num;
|
||||
float x,y,z,w;
|
||||
};
|
||||
class AsePosKey{
|
||||
public:
|
||||
int frame_num;
|
||||
float x,y,z;
|
||||
};
|
||||
class AseScaleKey{
|
||||
public:
|
||||
int frame_num;
|
||||
float x,y,z;
|
||||
};
|
||||
class AseMorphObject{
|
||||
public:
|
||||
D3DXVECTOR3 *vertex;
|
||||
D3DXVECTOR2 *texcoord;
|
||||
D3DXVECTOR3 *normal;
|
||||
AseFace *face;
|
||||
int keynum;
|
||||
};
|
||||
|
||||
class AseObject{
|
||||
public:
|
||||
int material_id;
|
||||
int vertex_num;
|
||||
int face_num;
|
||||
int texcoord_num;
|
||||
bool btexture;
|
||||
bool bmorph;
|
||||
//bilboard mesh
|
||||
bool bBil;
|
||||
// bilboard2 mesh
|
||||
bool bBil2;
|
||||
// texture change ani.
|
||||
bool bTexani;
|
||||
// morphing <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool bMorphStart;
|
||||
// texture random change ani.
|
||||
bool bRandTex;
|
||||
//cull face
|
||||
bool bCull;
|
||||
// Ani texture num
|
||||
int AniTexNum;
|
||||
bool bZ;
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> tex index
|
||||
int current_tex;
|
||||
|
||||
char object_name[255];
|
||||
char parent_name[255];
|
||||
bool bparent;
|
||||
D3DXVECTOR3 *vertex;
|
||||
D3DXVECTOR2 *texcoord;
|
||||
D3DXVECTOR3 *normal;
|
||||
bool bnormal;
|
||||
//object <20><> RGBA
|
||||
DWORD ObjectColor;
|
||||
DWORD ObjectPickColor;
|
||||
|
||||
// ani texture
|
||||
CTexture *anitexture;
|
||||
|
||||
D3DXMATRIX matrix;
|
||||
D3DXVECTOR3 pos;
|
||||
D3DXVECTOR3 rot_axis;
|
||||
float rot_angle;
|
||||
vector<AseRotKey> rot_key;
|
||||
vector<AseMorphObject> morph;
|
||||
int morph_num;
|
||||
vector<AsePosKey> pos_key;
|
||||
int pos_keyNum;
|
||||
//
|
||||
vector<AseScaleKey> scale_key;
|
||||
int scale_KeyNum;
|
||||
int rot_keyNum;
|
||||
D3DXVECTOR3 scale;
|
||||
D3DXVECTOR3 scale_axis;
|
||||
D3DXQUATERNION *rot_quatkey;
|
||||
AseFace *face;
|
||||
float texstart_frame;
|
||||
float texchange_frame;
|
||||
};
|
||||
|
||||
class AseModel {
|
||||
public:
|
||||
int object_num;
|
||||
int material_num;
|
||||
vector<AseObject> pobject;
|
||||
vector<AseMaterial> pmaterial;
|
||||
};
|
||||
AseModel Model;
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private:
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 *object;
|
||||
CTexture *texture;
|
||||
|
||||
int pick_index;
|
||||
int texture_count;
|
||||
DWORD Color;
|
||||
|
||||
WadFace *object_sub;
|
||||
|
||||
custom_vertex *vert;
|
||||
D3DXVECTOR3 *vert2;
|
||||
float frame;
|
||||
float max_frame;
|
||||
|
||||
DWORD SrcBlend,DstBlend;
|
||||
int vot;
|
||||
// ani loop <20><><EFBFBD><EFBFBD> <20>ȵ<EFBFBD><C8B5><EFBFBD>
|
||||
bool m_Loop;
|
||||
// ani <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴ<EFBFBD><C6B4><EFBFBD>..
|
||||
bool m_Start;
|
||||
bool m_texanistart;
|
||||
bool m_NullTexture;
|
||||
FILE *wadfile;
|
||||
};
|
||||
|
||||
#endif
|
||||
341
Engine/Effect/Effect.vcproj
Normal file
341
Engine/Effect/Effect.vcproj
Normal file
@@ -0,0 +1,341 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="Effect"
|
||||
ProjectGUID="{AE5E7ECA-0D7F-4538-B80C-900B07AA00CE}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_NoGD|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="<22>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\CEffscript.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CGemRender.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CLightning.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\EffDebugLog.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\MemoryPool.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SMRHeader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SMRObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffect.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectBase.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectBillboard.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectCylinder.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectManager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectMesh.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectParticle.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectPlane.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectSphere.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<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=".\SMRHeader.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SMRObj.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>
|
||||
<Filter
|
||||
Name="<22><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
229
Engine/Effect/Effect.vcxproj
Normal file
229
Engine/Effect/Effect.vcxproj
Normal file
@@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug_MY|Win32">
|
||||
<Configuration>Debug_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_MY|Win32">
|
||||
<Configuration>Release_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_NoGD|Win32">
|
||||
<Configuration>Release_NoGD</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{AE5E7ECA-0D7F-4538-B80C-900B07AA00CE}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CEffscript.cpp" />
|
||||
<ClCompile Include="CGemRender.cpp" />
|
||||
<ClCompile Include="CLightning.cpp" />
|
||||
<ClCompile Include="EffDebugLog.cpp" />
|
||||
<ClCompile Include="MemoryPool.cpp" />
|
||||
<ClCompile Include="SMRHeader.cpp" />
|
||||
<ClCompile Include="SMRObj.cpp" />
|
||||
<ClCompile Include="X3DEffect.cpp" />
|
||||
<ClCompile Include="X3DEffectBase.cpp" />
|
||||
<ClCompile Include="X3DEffectBillboard.cpp" />
|
||||
<ClCompile Include="X3DEffectCylinder.cpp" />
|
||||
<ClCompile Include="X3DEffectManager.cpp" />
|
||||
<ClCompile Include="X3DEffectMesh.cpp" />
|
||||
<ClCompile Include="X3DEffectParticle.cpp" />
|
||||
<ClCompile Include="X3DEffectPlane.cpp" />
|
||||
<ClCompile Include="X3DEffectSphere.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CEffscript.h" />
|
||||
<ClInclude Include="CEffscriptDefine.h" />
|
||||
<ClInclude Include="CGemRender.h" />
|
||||
<ClInclude Include="CLightning.h" />
|
||||
<ClInclude Include="EffDebugLog.h" />
|
||||
<ClInclude Include="Key.h" />
|
||||
<ClInclude Include="MemoryPool.h" />
|
||||
<ClInclude Include="SMRHeader.h" />
|
||||
<ClInclude Include="SMRObj.h" />
|
||||
<ClInclude Include="X3DEffect.h" />
|
||||
<ClInclude Include="X3DEffectBase.h" />
|
||||
<ClInclude Include="X3DEffectBillboard.h" />
|
||||
<ClInclude Include="X3DEffectCylinder.h" />
|
||||
<ClInclude Include="X3DEffectManager.h" />
|
||||
<ClInclude Include="X3DEffectMesh.h" />
|
||||
<ClInclude Include="X3DEffectParticle.h" />
|
||||
<ClInclude Include="X3DEffectPlane.h" />
|
||||
<ClInclude Include="X3DEffectSphere.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MemoryManager\MemoryManager.vcxproj">
|
||||
<Project>{b6bdd524-1dde-4a65-aed7-9ee4bc86a05d}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Zalla3D Base Class\Zalla3D Base Class.vcxproj">
|
||||
<Project>{663b3237-d6e2-4d71-8696-1425ebbedbad}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
126
Engine/Effect/Effect.vcxproj.filters
Normal file
126
Engine/Effect/Effect.vcxproj.filters
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="소스 파일">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="헤더 파일">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="리소스 파일">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CEffscript.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CGemRender.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CLightning.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffDebugLog.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MemoryPool.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SMRHeader.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SMRObj.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffect.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectBase.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectBillboard.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectCylinder.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectManager.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectMesh.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectParticle.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectPlane.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectSphere.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CEffscript.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CEffscriptDefine.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CGemRender.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CLightning.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffDebugLog.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Key.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MemoryPool.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SMRHeader.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SMRObj.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffect.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectBase.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectBillboard.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectCylinder.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectManager.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectMesh.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectParticle.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectPlane.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectSphere.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
159
Engine/Effect/Key.h
Normal file
159
Engine/Effect/Key.h
Normal file
@@ -0,0 +1,159 @@
|
||||
#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)
|
||||
329
Engine/Effect/MemoryPool.cpp
Normal file
329
Engine/Effect/MemoryPool.cpp
Normal file
@@ -0,0 +1,329 @@
|
||||
#include "MemoryPool.h"
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <new>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "GMMemory.h"
|
||||
|
||||
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
|
||||
|
||||
|
||||
#include "GMUndefNew.h"
|
||||
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();
|
||||
}
|
||||
#include "GMRedefNew.h"
|
||||
|
||||
|
||||
|
||||
bool CFixedPool::AllocateChunks()
|
||||
{
|
||||
#include "GMUndefNew.h"
|
||||
// Allocation and make list
|
||||
ChunkNode* pChunkNode = reinterpret_cast<ChunkNode*>(
|
||||
::operator new(sizeof(ChunkNode) + m_nPerAllocateSize * m_nPerAllocateNum));
|
||||
#include "GMRedefNew.h"
|
||||
|
||||
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(int i = 0; i < MAX_ALLOC; ++i)
|
||||
{
|
||||
pool.FREE(pAlloc[i], nSize);
|
||||
}
|
||||
|
||||
pool.Destroy();
|
||||
|
||||
FILE* pFile = fopen(strErrLogFileName, "rb");
|
||||
if(NULL == pFile)
|
||||
{
|
||||
printf("\tTest Successed!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(pFile);
|
||||
|
||||
#ifdef WIN32
|
||||
char szPath[MAX_PATH];
|
||||
char szFileNameWithPath[MAX_PATH];
|
||||
|
||||
UINT nResult = GetWindowsDirectory(szPath, MAX_PATH);
|
||||
if(0 != nResult && nResult <= MAX_PATH)
|
||||
{
|
||||
_snprintf(szFileNameWithPath, MAX_PATH, "%s\\NotePad.exe %s", szPath, strErrLogFileName);
|
||||
WinExec(szFileNameWithPath, SW_SHOW);
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("\tMemory Leak or Curruption Detected!\n\tPlease See %s File\n", strErrLogFileName);
|
||||
}
|
||||
|
||||
//printf("%s Test Completed.\n\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
93
Engine/Effect/MemoryPool.h
Normal file
93
Engine/Effect/MemoryPool.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _MEMORYPOOL_H_
|
||||
#define _MEMORYPOOL_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
|
||||
#define MEMPOOL_DBGMODE
|
||||
|
||||
#define ALLOC(nSize) Allocate((nSize))
|
||||
#define FREE(pDelete, nSize) Deallocate((pDelete), (nSize))
|
||||
|
||||
#define DECLARE_ALLOCATOR void* Allocate(size_t nSize)
|
||||
#define DECLARE_DEALLOCATOR void Deallocate(void* pDelete, size_t nSize)
|
||||
|
||||
#define DEFINE_ALLOCATOR(className) void* className::Allocate(size_t nSize)
|
||||
#define DEFINE_DEALLOCATOR(className) void className::Deallocate(void* pDelete, size_t nSize)
|
||||
|
||||
|
||||
class CNullLock
|
||||
{
|
||||
public:
|
||||
|
||||
class Syncronize
|
||||
{
|
||||
public:
|
||||
Syncronize(CNullLock& nullLock) { }
|
||||
};
|
||||
|
||||
void Lock() { }
|
||||
void Unlock() { }
|
||||
};
|
||||
|
||||
class CFixedPool
|
||||
{
|
||||
public:
|
||||
|
||||
enum { MAX_POOL_NAME = 32 };
|
||||
|
||||
CFixedPool();
|
||||
CFixedPool(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen);
|
||||
|
||||
~CFixedPool();
|
||||
|
||||
bool Initialize(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen);
|
||||
|
||||
void Destroy();
|
||||
unsigned long GetTotalUse() const { return static_cast<unsigned long>(m_nTotalInUse); }
|
||||
|
||||
static size_t GetLeastAllocateSize();
|
||||
static const char* GetErrFileName();
|
||||
|
||||
size_t m_nTotalInUse;
|
||||
|
||||
DECLARE_ALLOCATOR;
|
||||
DECLARE_DEALLOCATOR;
|
||||
|
||||
private:
|
||||
|
||||
bool AllocateChunks();
|
||||
void LogBufferOverflow(const char* lpBuffer);
|
||||
|
||||
typedef CNullLock PoolLock;
|
||||
struct ChunkNode;
|
||||
struct AllocateInfo;
|
||||
|
||||
PoolLock m_PoolLock;
|
||||
|
||||
ChunkNode* m_pChunkHead;
|
||||
AllocateInfo* m_pNodeHead;
|
||||
|
||||
size_t m_nOriginalSize;
|
||||
size_t m_nPerAllocateSize;
|
||||
size_t m_nPerAllocateNum;
|
||||
|
||||
size_t m_nTotalAllocated;
|
||||
|
||||
|
||||
char m_pszPoolName[MAX_POOL_NAME];
|
||||
|
||||
static const char* const ms_strErrLogFileName;
|
||||
};
|
||||
|
||||
|
||||
class CFixedPoolTest
|
||||
{
|
||||
public:
|
||||
void DoTest();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
21
Engine/Effect/ReadMe.txt
Normal file
21
Engine/Effect/ReadMe.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
========================================================================
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺귯<CCBA><EAB7AF> : Effect <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
========================================================================
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><> Effect <20><><EFBFBD>̺귯<CCBA><EAB7AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.
|
||||
|
||||
|
||||
Effect.vcproj
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>縦 <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VC++ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>⺻ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
<20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Visual C++<2B><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>ɿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
<EFBFBD><EFBFBD>Ÿ <20><><EFBFBD><EFBFBD>:
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> "TODO:" <20>ּ<EFBFBD><D6BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD> <20>߰<EFBFBD><DFB0>ϰų<CFB0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>ϴ<EFBFBD>
|
||||
<EFBFBD>ҽ<EFBFBD> <20>ڵ<EFBFBD> <20>κ<EFBFBD><CEBA><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
634
Engine/Effect/SMRHeader.cpp
Normal file
634
Engine/Effect/SMRHeader.cpp
Normal file
@@ -0,0 +1,634 @@
|
||||
#include "./SMRHeader.h"
|
||||
#include "GMMemory.h"
|
||||
namespace SGEngine { namespace Core {
|
||||
bool ISSameVertex(const D3DXVECTOR3 &vec1,const D3DXVECTOR3 &vec2)
|
||||
{
|
||||
D3DXVECTOR3 vecSub = vec1 - vec2;
|
||||
if((fabs(vecSub.x) < 0.001f) &&
|
||||
(fabs(vecSub.y) < 0.001f) &&
|
||||
(fabs(vecSub.z) < 0.001f))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void CMeshCoreData::CMeshSMorphData::SetSmartMorphData(CExportMeshVertex *pSrc,CExportMeshVertex *pDest,const int &iVertices,const int &iModelIndex,char *strModelName)
|
||||
{
|
||||
std::vector<D3DXVECTOR3> ArrRelative;
|
||||
std::vector<int> ArrRelativeIndex;
|
||||
ArrRelative.clear();
|
||||
ArrRelativeIndex.clear();
|
||||
int i;
|
||||
D3DXVECTOR3 vecRelative;
|
||||
|
||||
for(i = 0; i < iVertices; i++)
|
||||
{
|
||||
if(!ISSameVertex(pSrc[i].m_vecPos,pDest[i].m_vecPos))
|
||||
{
|
||||
ArrRelativeIndex.push_back(i);
|
||||
vecRelative = pDest[i].m_vecPos - pSrc[i].m_vecPos;
|
||||
ArrRelative.push_back(vecRelative);
|
||||
}
|
||||
}
|
||||
|
||||
m_iRelativeNum = (int)ArrRelative.size();
|
||||
m_pRelativeVertices = new D3DXVECTOR3[ArrRelative.size()];
|
||||
memcpy(m_pRelativeVertices,&ArrRelative[0],sizeof(D3DXVECTOR3) * ArrRelative.size());
|
||||
m_pRelativeIndex = new int[ArrRelativeIndex.size()];
|
||||
memcpy(m_pRelativeIndex,&ArrRelativeIndex[0],sizeof(int) * ArrRelativeIndex.size());
|
||||
m_iModelID = iModelIndex;
|
||||
if(strModelName)
|
||||
{
|
||||
strcpy(m_strName,strModelName);
|
||||
}
|
||||
|
||||
}
|
||||
void CMeshCoreData::SetSkinMeshData(const int &iVertex,D3DXMATRIX *matTm,D3DXMATRIX *matInvNodeTm) // rigid
|
||||
{
|
||||
|
||||
if(iVertex < m_iVerticesNum)
|
||||
{
|
||||
|
||||
D3DXMATRIX matSkinTm;
|
||||
|
||||
m_bUpdateData = true;
|
||||
D3DXVECTOR3 *pPos = &(m_pDefaultVertices[iVertex].m_vecPos);
|
||||
D3DXVECTOR3 *pDestPos = &(m_pVertices[iVertex].m_vecPos);
|
||||
D3DXVECTOR4 vecTrans;
|
||||
|
||||
D3DXMatrixMultiply(&matSkinTm,matInvNodeTm,matTm);
|
||||
|
||||
D3DXVec3Transform(&vecTrans,pPos,&matSkinTm);
|
||||
|
||||
pDestPos->x = vecTrans.x;
|
||||
pDestPos->y = vecTrans.y;
|
||||
pDestPos->z = vecTrans.z;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void CMeshCoreData::SetSkinMeshData(const int &iVertex,CMeshSkinData::CMeshBlendData *pBlend,const int &iBlend)
|
||||
{
|
||||
int i;
|
||||
if(iVertex < m_iVerticesNum)
|
||||
{
|
||||
D3DXMATRIX matWorldTm;
|
||||
D3DXMATRIX matInvNodeTm;
|
||||
|
||||
D3DXMATRIX matSkinTm;
|
||||
|
||||
m_bUpdateData = true;
|
||||
D3DXVECTOR3 *pPos = &(m_pDefaultVertices[iVertex].m_vecPos);
|
||||
D3DXVECTOR3 *pDestPos = &(m_pVertices[iVertex].m_vecPos);
|
||||
D3DXVECTOR4 vecTrans;
|
||||
|
||||
pDestPos->x = pDestPos->y = pDestPos->z = 0.0f;
|
||||
|
||||
for(i = 0; i < iBlend; i++ )
|
||||
{
|
||||
|
||||
matWorldTm = pBlend[i].m_pNode->m_matNodeTm;
|
||||
matWorldTm *= pBlend[i].m_fNodeWeight;
|
||||
|
||||
matInvNodeTm = pBlend[i].m_pNode->m_matInvNodeTm;
|
||||
|
||||
D3DXMatrixMultiply(&matSkinTm,&matInvNodeTm,&matWorldTm);
|
||||
D3DXVec3Transform(&vecTrans,pPos,&matSkinTm);
|
||||
|
||||
pDestPos->x += vecTrans.x;
|
||||
pDestPos->y += vecTrans.y;
|
||||
pDestPos->z += vecTrans.z;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void CMeshCoreData::SetSmartMorphInterValue(const float &fValue,const int &iIndex)
|
||||
{
|
||||
|
||||
|
||||
if(m_bSMorph)
|
||||
{
|
||||
float fInter = fValue;
|
||||
if(m_iSMorph > iIndex && m_pfSMorphInterValue)
|
||||
{
|
||||
/* if(fInter > 1.0f)
|
||||
fInter = 1.0f;
|
||||
if(fInter < 0.0f)
|
||||
fInter = 0.0f;*/
|
||||
m_pfSMorphInterValue[iIndex] = fInter;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CMeshCoreData::UpdateMeshSmartMorph()
|
||||
{
|
||||
|
||||
if(m_bSMorph && m_pVertices && m_pDefaultVertices)
|
||||
{
|
||||
int i,j;
|
||||
m_bUpdateData = true;
|
||||
memcpy(m_pVertices,m_pDefaultVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
|
||||
for(i = 0; i < m_iSMorph; i++ )
|
||||
{
|
||||
if(fabs(m_pfSMorphInterValue[i]) > 0.00001f)
|
||||
{
|
||||
for(j = 0; j < m_pSMorph[i].m_iRelativeNum; j++ )
|
||||
{
|
||||
int iVertexIndex = m_pSMorph[i].m_pRelativeIndex[j];
|
||||
m_pVertices[iVertexIndex].m_vecPos += (m_pSMorph[i].m_pRelativeVertices[j] * m_pfSMorphInterValue[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CMeshCoreData::UpdateMeshMorph(const float &fFrame)
|
||||
{
|
||||
if(m_bMorph && !m_bSMorph) // <20>ϴ<EFBFBD> smorph<70><68> <20><><EFBFBD>ÿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ȵǰ<C8B5> <20>س<EFBFBD><D8B3>´<EFBFBD>.. <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
int i;
|
||||
int iSelect = 0;
|
||||
|
||||
int iCurrentFrame = (int)ceil(fFrame);
|
||||
int iBeforeFrame = 0;
|
||||
int iNextFrame = 0;
|
||||
|
||||
int iBeforeKey = 0;
|
||||
int iNextKey = 0;
|
||||
|
||||
float fInterval = 0.0f;
|
||||
|
||||
CExportMeshVertex *pVertices = NULL;
|
||||
|
||||
for(i = 0; i < m_iMorph; i++ )
|
||||
{
|
||||
if(m_pMorphData[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_iMorph == i)
|
||||
{
|
||||
iSelect = m_iMorph - 1;
|
||||
pVertices = m_pMorphData[iSelect].m_pVertices;
|
||||
memcpy(m_pVertices,pVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
m_bUpdateData = true;
|
||||
|
||||
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
pVertices = m_pMorphData[iSelect].m_pVertices;
|
||||
memcpy(m_pVertices,pVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
m_bUpdateData = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bUpdateData = true;
|
||||
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pMorphData[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pMorphData[iNextKey].m_iFrame;
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
for(i = 0 ;i < m_iVerticesNum; i++ )
|
||||
{
|
||||
m_pVertices[i].m_vecPos = m_pMorphData[iNextKey].m_pVertices[i].m_vecPos - m_pMorphData[iBeforeKey].m_pVertices[i].m_vecPos;
|
||||
m_pVertices[i].m_vecPos *= fInterval;
|
||||
|
||||
m_pVertices[i].m_vecPos += m_pMorphData[iBeforeKey].m_pVertices[i].m_vecPos;
|
||||
|
||||
|
||||
m_pVertices[i].m_vecNormal = m_pMorphData[iNextKey].m_pVertices[i].m_vecNormal - m_pMorphData[iBeforeKey].m_pVertices[i].m_vecNormal;
|
||||
m_pVertices[i].m_vecNormal *= fInterval;
|
||||
|
||||
m_pVertices[i].m_vecNormal += m_pMorphData[iBeforeKey].m_pVertices[i].m_vecNormal;
|
||||
|
||||
m_pVertices[i].m_vecTexcoord = m_pMorphData[iNextKey].m_pVertices[i].m_vecTexcoord - m_pMorphData[iBeforeKey].m_pVertices[i].m_vecTexcoord;
|
||||
m_pVertices[i].m_vecTexcoord *= fInterval;
|
||||
|
||||
m_pVertices[i].m_vecTexcoord += m_pMorphData[iBeforeKey].m_pVertices[i].m_vecTexcoord;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// Linear interpolation.
|
||||
void CMeshObjNode::UpdateTm(const float &fFrame,D3DXMATRIX *matParent)
|
||||
{
|
||||
int i;
|
||||
int iSelect = 0;
|
||||
|
||||
D3DXVECTOR3 vecPos;
|
||||
D3DXVECTOR3 vecScale;
|
||||
D3DXQUATERNION qRot;
|
||||
|
||||
int iCurrentFrame = (int)ceil(fFrame);
|
||||
int iBeforeFrame = 0;
|
||||
int iNextFrame = 0;
|
||||
|
||||
int iBeforeKey = 0;
|
||||
int iNextKey = 0;
|
||||
|
||||
float fInterval = 0.0f;
|
||||
D3DXVECTOR3 vecInterval;
|
||||
|
||||
if(m_bAniNode)
|
||||
{
|
||||
|
||||
if(m_pAniNode->m_bTmAni)
|
||||
{
|
||||
CNodeTMInfo CurrentTmInfo;
|
||||
|
||||
for(i = 0; i < m_pAniNode->m_iTmKeys; i++)
|
||||
{
|
||||
if(m_pAniNode->m_pTmKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iTmKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iTmKeys - 1;
|
||||
CurrentTmInfo = m_pAniNode->m_pTmKeys[iSelect].m_TmInfo;
|
||||
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
CurrentTmInfo = m_pAniNode->m_pTmKeys[iSelect].m_TmInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pTmKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pTmKeys[iNextKey].m_iFrame;
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
D3DXVECTOR3 vecInterval;
|
||||
|
||||
// Trans
|
||||
vecInterval.x = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecTrans.x - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.x;
|
||||
vecInterval.y = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecTrans.y - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.y;
|
||||
vecInterval.z = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecTrans.z - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.z;
|
||||
|
||||
vecInterval *= fInterval;
|
||||
|
||||
CurrentTmInfo.m_vecTrans.x = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.x + vecInterval.x;
|
||||
CurrentTmInfo.m_vecTrans.y = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.y + vecInterval.y;
|
||||
CurrentTmInfo.m_vecTrans.z = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.z + vecInterval.z;
|
||||
// Scale
|
||||
|
||||
vecInterval.x = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecScale.x - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.x;
|
||||
vecInterval.y = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecScale.y - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.y;
|
||||
vecInterval.z = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecScale.z - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.z;
|
||||
|
||||
vecInterval *= fInterval;
|
||||
|
||||
CurrentTmInfo.m_vecScale.x = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.x + vecInterval.x;
|
||||
CurrentTmInfo.m_vecScale.y = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.y + vecInterval.y;
|
||||
CurrentTmInfo.m_vecScale.z = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.z + vecInterval.z;
|
||||
// qrot
|
||||
|
||||
D3DXQuaternionSlerp(&CurrentTmInfo.m_qRot,
|
||||
&(m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_qRot),
|
||||
&(m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_qRot),
|
||||
fInterval);
|
||||
|
||||
// qscaleaxis
|
||||
D3DXQuaternionSlerp(&CurrentTmInfo.m_qScaleAxis,
|
||||
&(m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_qScaleAxis),
|
||||
&(m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_qScaleAxis),
|
||||
fInterval);
|
||||
// fDetermination
|
||||
|
||||
vecInterval.x = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_fDetermination - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_fDetermination;
|
||||
vecInterval.x *= fInterval;
|
||||
CurrentTmInfo.m_fDetermination = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_fDetermination + vecInterval.x;
|
||||
|
||||
}
|
||||
|
||||
/* Convert matrix from affine value.
|
||||
ptm = position component (t)
|
||||
rtm = "essential" rotation (q)
|
||||
srtm = "stretch" rotation (u)
|
||||
stm = scale component (k)
|
||||
ftm = the flip tm -> ScaleMatrix(Point3(ap.f,ap.f,ap.f));
|
||||
Here's the correct way of reassembling the decomposed matrix:
|
||||
Matrix3 srtm, rtm, ptm, stm, ftm;
|
||||
ptm.IdentityMatrix();
|
||||
ptm.SetTrans(ap.t);
|
||||
ap.q.MakeMatrix(rtm);
|
||||
ap.u.MakeMatrix(srtm);
|
||||
stm = ScaleMatrix(ap.k);
|
||||
mat = Inverse(srtm) * stm * srtm * rtm * ftm * ptm;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
D3DXMATRIX matR,matSA,matScale,matF,matP,matInvSA;
|
||||
|
||||
D3DXMatrixScaling(&matF,CurrentTmInfo.m_fDetermination,
|
||||
CurrentTmInfo.m_fDetermination,
|
||||
CurrentTmInfo.m_fDetermination);
|
||||
D3DXMatrixIdentity(&matP);
|
||||
D3DXMatrixTranslation(&matP,CurrentTmInfo.m_vecTrans.x,
|
||||
CurrentTmInfo.m_vecTrans.y,
|
||||
CurrentTmInfo.m_vecTrans.z);
|
||||
D3DXMatrixRotationQuaternion(&matR,&CurrentTmInfo.m_qRot);
|
||||
D3DXMatrixRotationQuaternion(&matSA,&CurrentTmInfo.m_qScaleAxis);
|
||||
D3DXMatrixInverse(&matInvSA,NULL,&matSA);
|
||||
D3DXMatrixScaling(&matScale,CurrentTmInfo.m_vecScale.x,
|
||||
CurrentTmInfo.m_vecScale.y,
|
||||
CurrentTmInfo.m_vecScale.z);
|
||||
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&matInvSA,&matScale);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matSA);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matR);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matF);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matP);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_pAniNode->m_bPosAni)
|
||||
{
|
||||
for(i = 0; i < m_pAniNode->m_iPosKeys; i++ )
|
||||
{
|
||||
if(m_pAniNode->m_pPosKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iPosKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iPosKeys - 1;
|
||||
vecPos = m_pAniNode->m_pPosKeys[iSelect].m_vecPos;
|
||||
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
vecPos = m_pAniNode->m_pPosKeys[iSelect].m_vecPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pPosKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pPosKeys[iNextKey].m_iFrame;
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
vecInterval.x = m_pAniNode->m_pPosKeys[iNextKey].m_vecPos.x - m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.x;
|
||||
vecInterval.y = m_pAniNode->m_pPosKeys[iNextKey].m_vecPos.y - m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.y;
|
||||
vecInterval.z = m_pAniNode->m_pPosKeys[iNextKey].m_vecPos.z - m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.z;
|
||||
|
||||
vecInterval *= fInterval;
|
||||
|
||||
vecPos.x = m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.x + vecInterval.x;
|
||||
vecPos.y = m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.y + vecInterval.y;
|
||||
vecPos.z = m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.z + vecInterval.z;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
vecPos = m_DefaultNodeTm.m_vecTrans;
|
||||
|
||||
if(m_pAniNode->m_bScaleAni)
|
||||
{
|
||||
iSelect = 0;
|
||||
|
||||
for(i = 0; i < m_pAniNode->m_iScaleKeys; i++ )
|
||||
{
|
||||
if(m_pAniNode->m_pScaleKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iScaleKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iScaleKeys - 1;
|
||||
vecScale = m_pAniNode->m_pScaleKeys[iSelect].m_vecScale;
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
vecScale = m_pAniNode->m_pScaleKeys[iSelect].m_vecScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pScaleKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pScaleKeys[iNextKey].m_iFrame;
|
||||
|
||||
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
vecInterval.x = m_pAniNode->m_pScaleKeys[iNextKey].m_vecScale.x - m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.x;
|
||||
vecInterval.y = m_pAniNode->m_pScaleKeys[iNextKey].m_vecScale.y - m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.y;
|
||||
vecInterval.z = m_pAniNode->m_pScaleKeys[iNextKey].m_vecScale.z - m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.z;
|
||||
|
||||
vecInterval *= fInterval;
|
||||
|
||||
vecScale.x = m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.x + vecInterval.x;
|
||||
vecScale.y = m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.y + vecInterval.y;
|
||||
vecScale.z = m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.z + vecInterval.z;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
vecScale = m_DefaultNodeTm.m_vecScale;
|
||||
|
||||
if(m_pAniNode->m_bRotAni)
|
||||
{
|
||||
iSelect = 0;
|
||||
for(i = 0; i < m_pAniNode->m_iRotKeys; i++ )
|
||||
{
|
||||
if(m_pAniNode->m_pRotKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iRotKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iRotKeys - 1;
|
||||
qRot = m_pAniNode->m_pRotKeys[iSelect].m_qRotKey;
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
qRot = m_pAniNode->m_pRotKeys[iSelect].m_qRotKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pRotKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pRotKeys[iNextKey].m_iFrame;
|
||||
|
||||
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
D3DXQuaternionSlerp(&qRot,
|
||||
&(m_pAniNode->m_pRotKeys[iBeforeKey].m_qRotKey),
|
||||
&(m_pAniNode->m_pRotKeys[iNextKey].m_qRotKey),
|
||||
fInterval);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
qRot = m_DefaultNodeTm.m_qRot;
|
||||
|
||||
|
||||
D3DXMatrixTransformation(&m_matNodeTm,
|
||||
NULL,NULL,&vecScale,NULL,&qRot,&vecPos);
|
||||
|
||||
} // else
|
||||
if(m_pAniNode->m_bVisAni)
|
||||
{
|
||||
|
||||
float fVis = 1.0f;
|
||||
float fInter = 0.0f;
|
||||
|
||||
for(i = 0; i < m_pAniNode->m_iVisKeys; i++ )
|
||||
{
|
||||
if(m_pAniNode->m_pVisKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iVisKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iVisKeys - 1;
|
||||
fVis = m_pAniNode->m_pVisKeys[iSelect].m_fVisibility;
|
||||
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
fVis = m_pAniNode->m_pVisKeys[iSelect].m_fVisibility;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pVisKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pVisKeys[iNextKey].m_iFrame;
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
fInter = m_pAniNode->m_pVisKeys[iNextKey].m_fVisibility - m_pAniNode->m_pVisKeys[iBeforeKey].m_fVisibility;
|
||||
|
||||
fInter *= fInterval;
|
||||
|
||||
fVis = m_pAniNode->m_pVisKeys[iBeforeKey].m_fVisibility + fInter;
|
||||
|
||||
|
||||
}
|
||||
m_fVisibility = fVis;
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* vecPos = m_DefaultNodeTm.m_vecTrans;
|
||||
qRot = m_DefaultNodeTm.m_qRot;
|
||||
vecScale = m_DefaultNodeTm.m_vecScale;
|
||||
|
||||
D3DXMatrixTransformation(&m_matNodeTm,
|
||||
NULL,NULL,&vecScale,NULL,&qRot,&vecPos);
|
||||
*/
|
||||
/* D3DXMATRIX mat;
|
||||
|
||||
D3DXMatrixInverse(&mat,NULL,&m_matInvNodeTm);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&mat);
|
||||
*/
|
||||
D3DXMatrixInverse(&m_matNodeTm,NULL,&m_matInvNodeTm);
|
||||
}
|
||||
|
||||
if(matParent)
|
||||
{
|
||||
|
||||
if(m_bWorldTM)
|
||||
{
|
||||
D3DXMATRIX matInv;
|
||||
D3DXMatrixInverse(&matInv,NULL,matParent); // exporter<65><72><EFBFBD><EFBFBD> (bipe <20><> ) ó<><C3B3> <20>ؾ<EFBFBD><D8BE><EFBFBD>.
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matInv); // LocalTm = WorldTm * Parent InvTm
|
||||
|
||||
}
|
||||
m_matLocalTm = m_matNodeTm;
|
||||
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,matParent); // WorldTm = LocalTm * ParentTm
|
||||
}
|
||||
}
|
||||
|
||||
void CMeshObjNode::UpdateSkinning()
|
||||
{
|
||||
int i;
|
||||
D3DXMATRIX matWorldTm;
|
||||
D3DXMATRIX matInvNodeTm;
|
||||
|
||||
int iVertexIndex;
|
||||
int iMatIndex;
|
||||
|
||||
if(m_bSkinMorph && m_pSkinData)
|
||||
{
|
||||
for(i = 0; i < m_pSkinData->m_iRigid; i++)
|
||||
{
|
||||
matWorldTm = m_pSkinData->m_pRigid[i].m_pNode->m_matNodeTm;
|
||||
matInvNodeTm = m_pSkinData->m_pRigid[i].m_pNode->m_matInvNodeTm;
|
||||
|
||||
iVertexIndex = m_pSkinData->m_pRigid[i].m_iVertexIndex;
|
||||
iMatIndex = m_pSkinData->m_pRigid[i].m_iMatIndex;
|
||||
|
||||
SetSkinMeshData(iMatIndex,iVertexIndex,&matWorldTm,&matInvNodeTm);
|
||||
|
||||
}
|
||||
for(i = 0; i < m_pSkinData->m_iBlend; i++ )
|
||||
{
|
||||
iVertexIndex = m_pSkinData->m_pBlend[i].m_iVertexIndex;
|
||||
iMatIndex = m_pSkinData->m_pBlend[i].m_iMatIndex;
|
||||
int iBlend = m_pSkinData->m_pBlend[i].m_iBlendData;
|
||||
CMeshSkinData::CMeshBlendData *pBlend = m_pSkinData->m_pBlend[i].m_pArrBlendData;
|
||||
SetSkinMeshData(iMatIndex,iVertexIndex,pBlend,iBlend);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}}
|
||||
860
Engine/Effect/SMRHeader.h
Normal file
860
Engine/Effect/SMRHeader.h
Normal file
@@ -0,0 +1,860 @@
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
#include <vector>
|
||||
|
||||
namespace SGEngine {
|
||||
|
||||
|
||||
// template function <20><><EFBFBD><EFBFBD>
|
||||
template<class _T>
|
||||
inline void SafeDelete( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class _T>
|
||||
inline void SafeDeleteA( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete[] (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
class CExportMeshVertex
|
||||
{
|
||||
public:
|
||||
D3DXVECTOR3 m_vecPos;
|
||||
D3DXVECTOR3 m_vecNormal;
|
||||
D3DXVECTOR2 m_vecTexcoord;
|
||||
CExportMeshVertex() : m_vecPos(0.0f,0.0f,0.0f),m_vecNormal(0.0f,0.0f,0.0f),m_vecTexcoord(0.0f,0.0f)
|
||||
{}
|
||||
~CExportMeshVertex(){}
|
||||
};
|
||||
enum MESHNODETYPE
|
||||
{
|
||||
MESHNODETYPE_DUMY = 0,
|
||||
MESHNODETYPE_MATERIAL, // Material
|
||||
MESHNODETYPE_MESHDATA, // Vertex, Index Data
|
||||
MESHNODETYPE_ANINODE, // Ani Node
|
||||
MESHNODETYPE_NUM,
|
||||
};
|
||||
|
||||
enum SMRNODE
|
||||
{
|
||||
SMRNODE_NODE = 0,
|
||||
SMRNODE_GROUP,
|
||||
SMRNODE_NUM,
|
||||
};
|
||||
enum SMROBJTYPE
|
||||
{
|
||||
SMROBJ_MESH = 0,
|
||||
SMROBJ_HELPER,
|
||||
SMROBJ_BONE,
|
||||
SMROBJ_NUM,
|
||||
};
|
||||
enum SMRMESHTYPE
|
||||
{
|
||||
SMRMESHTYPE_STATIC = 0,
|
||||
SMRMESHTYPE_STATIC_WITHOUTLIGHTMAP,
|
||||
SMRMESHTYPE_DYNAMIC,
|
||||
SMRMESHTYPE_NUM,
|
||||
};
|
||||
|
||||
enum SMRANICONTROLTYPE
|
||||
{
|
||||
SMRANICONTROL_BEZIER = 0,
|
||||
SMRANICONTROL_LINEAR,
|
||||
SMRANICONTROL_TCB,
|
||||
SMRANICONTROL_SAMPLE,
|
||||
SMRANICONTROL_NUM,
|
||||
|
||||
|
||||
};
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CMeshHeader
|
||||
{
|
||||
public:
|
||||
CMeshHeader() : m_fVersion(1.0f),m_iNodes(0),m_iType(SMRMESHTYPE_STATIC)
|
||||
{
|
||||
memset(m_iExtension,0,sizeof(int)*10);
|
||||
|
||||
}
|
||||
~CMeshHeader()
|
||||
{}
|
||||
float m_fVersion;
|
||||
int m_iNodes;
|
||||
int m_iType;
|
||||
|
||||
int m_iExtension[10]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ȯ<><C8AE>.
|
||||
|
||||
|
||||
};
|
||||
class CMeshObjNodeHeader
|
||||
{
|
||||
public:
|
||||
CMeshObjNodeHeader() : m_iNodeType(MESHNODETYPE_DUMY), m_iNodeSize(0)
|
||||
{}
|
||||
~CMeshObjNodeHeader()
|
||||
{}
|
||||
int m_iNodeType;
|
||||
unsigned long m_iNodeSize;
|
||||
|
||||
};
|
||||
|
||||
class CNodeTMInfo // MeshTM KeyInfo.
|
||||
{
|
||||
public:
|
||||
|
||||
D3DXVECTOR3 m_vecTrans; // Translation
|
||||
D3DXVECTOR3 m_vecScale; // Scale
|
||||
D3DXQUATERNION m_qRot; // Rot
|
||||
D3DXQUATERNION m_qScaleAxis;
|
||||
float m_fDetermination;
|
||||
|
||||
CNodeTMInfo() : m_vecTrans(0.0f,0.0f,0.0f),m_vecScale(1.0f,1.0f,1.0f),m_qRot(0.0f,0.0f,0.0f,1.0f),
|
||||
m_qScaleAxis(0.0f,0.0f,0.0f,1.0f),m_fDetermination(0.0f)
|
||||
{}
|
||||
~CNodeTMInfo(){}
|
||||
};
|
||||
|
||||
class CMeshKeyAniNode
|
||||
{
|
||||
public:
|
||||
class CMeshKeyAniTm
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniTm() : m_iFrame(0)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniTm()
|
||||
{
|
||||
|
||||
}
|
||||
int m_iFrame;
|
||||
CNodeTMInfo m_TmInfo;
|
||||
|
||||
};
|
||||
|
||||
class CMeshKeyAniRot
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniRot() : m_qRotKey(0.0f,0.0f,0.0f,1.0f),m_iFrame(0)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniRot()
|
||||
{
|
||||
|
||||
}
|
||||
D3DXQUATERNION m_qRotKey;
|
||||
int m_iFrame;
|
||||
|
||||
};
|
||||
class CMeshKeyAniPos
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniPos() : m_vecPos(0.0f,0.0f,0.0f),m_iFrame(0)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniPos()
|
||||
{
|
||||
|
||||
}
|
||||
D3DXVECTOR3 m_vecPos;
|
||||
int m_iFrame;
|
||||
|
||||
};
|
||||
class CMeshKeyAniScale
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniScale() : m_iFrame(0),m_vecScale(1.0f,1.0f,1.0f)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniScale()
|
||||
{
|
||||
|
||||
}
|
||||
D3DXVECTOR3 m_vecScale;
|
||||
int m_iFrame;
|
||||
};
|
||||
class CMeshKeyAniVis
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniVis() : m_iFrame(0),m_fVisibility(1.0f)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniVis()
|
||||
{
|
||||
|
||||
}
|
||||
float m_fVisibility;
|
||||
int m_iFrame;
|
||||
|
||||
};
|
||||
|
||||
CMeshKeyAniNode() :m_iRotKeys(0),m_pRotKeys(NULL),m_bRotAni(false),m_iRotType(SMRANICONTROL_BEZIER),
|
||||
m_iPosKeys(0),m_pPosKeys(NULL),m_bPosAni(false),m_iPosType(SMRANICONTROL_BEZIER),
|
||||
m_iScaleKeys(0),m_pScaleKeys(NULL),m_bScaleAni(false),m_iScaleType(SMRANICONTROL_BEZIER),
|
||||
m_iVisKeys(0),m_pVisKeys(NULL),m_bVisAni(false),m_iVisType(SMRANICONTROL_BEZIER),
|
||||
m_bTmAni(false),m_iTmKeys(0),m_pTmKeys(NULL)
|
||||
{
|
||||
}
|
||||
~CMeshKeyAniNode()
|
||||
{
|
||||
if(m_pRotKeys)
|
||||
{
|
||||
delete[] m_pRotKeys;
|
||||
m_pRotKeys = NULL;
|
||||
}
|
||||
|
||||
if(m_pPosKeys)
|
||||
{
|
||||
delete[] m_pPosKeys;
|
||||
m_pPosKeys = NULL;
|
||||
}
|
||||
|
||||
if(m_pScaleKeys)
|
||||
{
|
||||
delete[] m_pScaleKeys;
|
||||
m_pScaleKeys = NULL;
|
||||
}
|
||||
|
||||
if(m_pVisKeys)
|
||||
{
|
||||
delete[] m_pVisKeys;
|
||||
m_pVisKeys = NULL;
|
||||
}
|
||||
if(m_pTmKeys)
|
||||
{
|
||||
delete[] m_pTmKeys;
|
||||
m_pTmKeys = NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
bool m_bRotAni;
|
||||
|
||||
int m_iRotKeys;
|
||||
CMeshKeyAniRot *m_pRotKeys;
|
||||
int m_iRotType;
|
||||
|
||||
bool m_bPosAni;
|
||||
|
||||
int m_iPosKeys;
|
||||
CMeshKeyAniPos *m_pPosKeys;
|
||||
int m_iPosType;
|
||||
|
||||
|
||||
bool m_bScaleAni;
|
||||
|
||||
int m_iScaleKeys;
|
||||
CMeshKeyAniScale *m_pScaleKeys;
|
||||
int m_iScaleType;
|
||||
|
||||
|
||||
|
||||
bool m_bVisAni;
|
||||
|
||||
int m_iVisKeys;
|
||||
CMeshKeyAniVis *m_pVisKeys;
|
||||
int m_iVisType;
|
||||
|
||||
bool m_bTmAni;
|
||||
int m_iTmKeys;
|
||||
CMeshKeyAniTm *m_pTmKeys;
|
||||
|
||||
|
||||
};
|
||||
class CMeshMaterialInfo
|
||||
{
|
||||
public:
|
||||
CMeshMaterialInfo()
|
||||
{
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
}
|
||||
~CMeshMaterialInfo(){}
|
||||
bool CheckString(const char *strName)
|
||||
{
|
||||
|
||||
if(!strcmp(m_strName,strName))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
char m_strName[256];
|
||||
|
||||
|
||||
};
|
||||
class CMeshObjNode;
|
||||
class CMeshSkinData
|
||||
{
|
||||
public:
|
||||
|
||||
class CMeshSkinRigid
|
||||
{
|
||||
public:
|
||||
int m_iMatIndex;
|
||||
int m_iVertexIndex;
|
||||
char m_strNodeName[256];
|
||||
int m_iNodeIndex;
|
||||
CMeshObjNode *m_pNode;
|
||||
|
||||
CMeshSkinRigid() : m_iVertexIndex(0), m_iMatIndex(0),m_pNode(NULL)
|
||||
{
|
||||
memset(m_strNodeName,0,sizeof(char) * 256);
|
||||
m_iNodeIndex = 0;
|
||||
}
|
||||
~CMeshSkinRigid(){}
|
||||
};
|
||||
class CMeshBlendData
|
||||
{
|
||||
public:
|
||||
char m_strNodeName[256];
|
||||
int m_iNodeIndex;
|
||||
float m_fNodeWeight;
|
||||
CMeshObjNode *m_pNode;
|
||||
|
||||
CMeshBlendData() :m_fNodeWeight(0.0f) , m_pNode(NULL)
|
||||
{
|
||||
memset(m_strNodeName,0,sizeof(char) * 256);
|
||||
m_iNodeIndex = 0;
|
||||
}
|
||||
~CMeshBlendData(){}
|
||||
};
|
||||
class CMeshSkinBlend
|
||||
{
|
||||
public:
|
||||
int m_iMatIndex;
|
||||
int m_iVertexIndex;
|
||||
CMeshBlendData *m_pArrBlendData;
|
||||
int m_iBlendData;
|
||||
|
||||
|
||||
CMeshSkinBlend() : m_iVertexIndex(0),m_iMatIndex(0)
|
||||
{
|
||||
m_pArrBlendData = NULL;
|
||||
m_iBlendData = 0;
|
||||
|
||||
}
|
||||
~CMeshSkinBlend()
|
||||
{
|
||||
SafeDeleteA(m_pArrBlendData);
|
||||
m_pArrBlendData = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
CMeshSkinData() : m_iRigid(0),m_iBlend(0),m_pRigid(NULL),m_pBlend(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshSkinData()
|
||||
{
|
||||
SafeDeleteA(m_pRigid);
|
||||
m_pRigid = NULL;
|
||||
SafeDeleteA(m_pBlend);
|
||||
m_pBlend = NULL;
|
||||
|
||||
}
|
||||
void FindSkinRigidData(int iIndex,std::vector<CMeshSkinRigid *> *pArrRigid)
|
||||
{
|
||||
int i;
|
||||
if(pArrRigid)
|
||||
{
|
||||
for(i = 0; i < m_iRigid; i++)
|
||||
{
|
||||
if(m_pRigid[i].m_iVertexIndex == iIndex)
|
||||
{
|
||||
pArrRigid->push_back(&(m_pRigid[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void FindSkinBlendData(int iIndex,std::vector<CMeshSkinBlend *> *pArrBlend)
|
||||
{
|
||||
int i;
|
||||
if(pArrBlend)
|
||||
{
|
||||
for(i = 0; i < m_iBlend; i++)
|
||||
{
|
||||
if(m_pBlend[i].m_iVertexIndex == iIndex)
|
||||
{
|
||||
pArrBlend->push_back(&(m_pBlend[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int m_iRigid;
|
||||
CMeshSkinRigid *m_pRigid;
|
||||
|
||||
int m_iBlend;
|
||||
CMeshSkinBlend *m_pBlend;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CMeshObjNode;
|
||||
class CMeshCoreData
|
||||
{
|
||||
public:
|
||||
class CMeshSMorphData // Smart Morphing
|
||||
{
|
||||
public:
|
||||
int m_iModelID;
|
||||
char m_strName[256];
|
||||
D3DXVECTOR3 *m_pRelativeVertices;
|
||||
int *m_pRelativeIndex;
|
||||
int m_iRelativeNum;
|
||||
CMeshSMorphData() : m_iModelID(-1),m_pRelativeVertices(NULL),m_pRelativeIndex(NULL),m_iRelativeNum(0)
|
||||
{
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
}
|
||||
~CMeshSMorphData()
|
||||
{
|
||||
SafeDeleteA(m_pRelativeVertices);
|
||||
m_pRelativeVertices = NULL;
|
||||
SafeDeleteA(m_pRelativeIndex);
|
||||
m_pRelativeIndex = NULL;
|
||||
|
||||
}
|
||||
void SetSmartMorphData(CExportMeshVertex *pSrc,CExportMeshVertex *pDest,const int &iVertices,const int &iModelIndex = -1,char *strModelName = NULL);
|
||||
|
||||
};
|
||||
class CMeshMorphData
|
||||
{
|
||||
public:
|
||||
CMeshMorphData() : m_iFrame(0), m_pVertices(NULL)
|
||||
{}
|
||||
~CMeshMorphData()
|
||||
{
|
||||
SafeDeleteA(m_pVertices);
|
||||
m_pVertices = NULL;
|
||||
}
|
||||
int m_iFrame;
|
||||
CExportMeshVertex *m_pVertices;
|
||||
|
||||
|
||||
|
||||
};
|
||||
CMeshCoreData() : m_iType(SMRMESHTYPE_STATIC),m_iVerticesNum(0),m_iIndicesNum(0),
|
||||
m_pVertices(NULL),m_pIndices(NULL),m_iMaterialIndex(0),m_pNode(NULL),m_bUpdateData(false),
|
||||
m_bMorph(false),m_pMorphData(NULL),m_iMorph(0),
|
||||
m_bSMorph(false),m_pSMorph(NULL),m_iSMorph(0),m_pfSMorphInterValue(NULL),
|
||||
m_bCullOff(false),m_bZWriteOff(false),m_bZOff(false)
|
||||
{
|
||||
|
||||
m_bTotalBilboard = false;
|
||||
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
m_pDefaultVertices = NULL;
|
||||
}
|
||||
~CMeshCoreData()
|
||||
{
|
||||
SafeDeleteA(m_pVertices);
|
||||
m_pVertices = NULL;
|
||||
|
||||
SafeDeleteA(m_pDefaultVertices);
|
||||
m_pDefaultVertices = NULL;
|
||||
|
||||
|
||||
SafeDeleteA(m_pIndices);
|
||||
m_pIndices = NULL;
|
||||
|
||||
|
||||
SafeDeleteA(m_pMorphData);
|
||||
m_pMorphData = NULL;
|
||||
|
||||
SafeDeleteA(m_pSMorph);
|
||||
m_pSMorph = NULL;
|
||||
SafeDeleteA(m_pfSMorphInterValue);
|
||||
m_pfSMorphInterValue = NULL;
|
||||
|
||||
}
|
||||
|
||||
void SetTotalBilboard(bool bValue) { m_bTotalBilboard = bValue;}
|
||||
bool GetTotalBilboard() { return m_bTotalBilboard;}
|
||||
|
||||
void SetCullOffFlag(bool bValue) { m_bCullOff = bValue;}
|
||||
bool GetCullOffFlag() { return m_bCullOff; }
|
||||
|
||||
void SetZWriteOffFlag(bool bValue) { m_bZWriteOff = bValue;}
|
||||
bool GetZWriteOffFlag() { return m_bZWriteOff; }
|
||||
|
||||
void SetZOffFlag(bool bValue) { m_bZOff = bValue;}
|
||||
bool GetZOffFlag() { return m_bZOff; }
|
||||
|
||||
|
||||
void CreateBuffer()
|
||||
{
|
||||
|
||||
if(m_iIndicesNum > 0)
|
||||
{
|
||||
SafeDeleteA(m_pIndices);
|
||||
m_pIndices = NULL;
|
||||
m_pIndices = new WORD[m_iIndicesNum];
|
||||
}
|
||||
if(m_iVerticesNum > 0)
|
||||
{
|
||||
SafeDeleteA(m_pVertices);
|
||||
m_pVertices = NULL;
|
||||
|
||||
m_pVertices = new CExportMeshVertex[m_iVerticesNum];
|
||||
}
|
||||
}
|
||||
void CreateDefaultBuffer()
|
||||
{
|
||||
if(m_pDefaultVertices == NULL)
|
||||
{
|
||||
|
||||
if(m_iVerticesNum > 0)
|
||||
{
|
||||
m_pDefaultVertices = new CExportMeshVertex[m_iVerticesNum];
|
||||
memcpy(m_pDefaultVertices,m_pVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CopyBuffer(CExportMeshVertex *pData,WORD *pData2)
|
||||
{
|
||||
if(pData != NULL && m_pVertices != NULL)
|
||||
{
|
||||
memcpy(m_pVertices,pData,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
}
|
||||
if(pData2 != NULL && m_pIndices != NULL)
|
||||
{
|
||||
memcpy(m_pIndices,pData2,sizeof(WORD) * m_iIndicesNum);
|
||||
}
|
||||
}
|
||||
void AddBuffer(CExportMeshVertex *pData,int iData,WORD *pData2,int iData2)
|
||||
{
|
||||
int i;
|
||||
int iIndexStart = m_iVerticesNum;
|
||||
|
||||
if(pData && m_pVertices)
|
||||
{
|
||||
CExportMeshVertex *pNewData = new CExportMeshVertex[m_iVerticesNum + iData];
|
||||
memcpy(pNewData,m_pVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
for(i = 0; i < iData; i++ )
|
||||
{
|
||||
pNewData[m_iVerticesNum + i] = pData[i];
|
||||
}
|
||||
m_iVerticesNum += iData;
|
||||
SafeDeleteA(m_pVertices);
|
||||
m_pVertices = pNewData;
|
||||
}
|
||||
if(pData2 && m_pIndices)
|
||||
{
|
||||
WORD *pNewData2 = new WORD[iData2 + m_iIndicesNum];
|
||||
memcpy(pNewData2,m_pIndices,sizeof(WORD) * m_iIndicesNum);
|
||||
for(i = 0; i < iData2; i++ )
|
||||
{
|
||||
pData2[i] += iIndexStart;
|
||||
pNewData2[m_iIndicesNum + i] = pData2[i];
|
||||
|
||||
}
|
||||
m_iIndicesNum += iData2;
|
||||
SafeDeleteA(m_pIndices);
|
||||
m_pIndices = pNewData2;
|
||||
}
|
||||
|
||||
}
|
||||
void CreateMorphBuffer(int iMorphNums)
|
||||
{
|
||||
m_bMorph = true;
|
||||
m_iMorph = iMorphNums;
|
||||
m_pMorphData = new CMeshMorphData[m_iMorph];
|
||||
}
|
||||
void SetMorphBuffer(int iMorphIndex,int iFrame,int iVertices,CExportMeshVertex *pVertices)
|
||||
{
|
||||
if(pVertices && iMorphIndex < m_iMorph && m_pMorphData)
|
||||
{
|
||||
m_pMorphData[iMorphIndex].m_iFrame = iFrame;
|
||||
m_pMorphData[iMorphIndex].m_pVertices = new CExportMeshVertex[iVertices];
|
||||
memcpy(m_pMorphData[iMorphIndex].m_pVertices,pVertices,sizeof(CExportMeshVertex ) * iVertices);
|
||||
}
|
||||
}
|
||||
void SetSkinMeshData(const int &iVertex,D3DXMATRIX *matTm,D3DXMATRIX *matInvNodeTm); // rigid
|
||||
void SetSkinMeshData(const int &iVertex,CMeshSkinData::CMeshBlendData *pBlend,const int &iBlend);
|
||||
|
||||
void SetUpdateFlag(bool bFlag) { m_bUpdateData = bFlag;}
|
||||
void UpdateMeshMorph(const float &fFrame);
|
||||
|
||||
void UpdateMeshSmartMorph();
|
||||
void SetSmartMorphInterValue(const float &fValue,const int &iIndex);
|
||||
int GetSmartMorphNum() { return m_iSMorph;}
|
||||
|
||||
CMeshObjNode *m_pNode;
|
||||
|
||||
char m_strName[256];
|
||||
int m_iType;
|
||||
int m_iVerticesNum;
|
||||
int m_iIndicesNum;
|
||||
int m_iMaterialIndex;
|
||||
|
||||
bool m_bUpdateData;
|
||||
|
||||
|
||||
CExportMeshVertex *m_pVertices;
|
||||
CExportMeshVertex *m_pDefaultVertices; //skinning <20><> <20><><EFBFBD><EFBFBD> default vertices.
|
||||
|
||||
WORD *m_pIndices;
|
||||
|
||||
bool m_bMorph;
|
||||
CMeshMorphData *m_pMorphData;
|
||||
int m_iMorph;
|
||||
|
||||
bool m_bSMorph;
|
||||
CMeshSMorphData *m_pSMorph;
|
||||
int m_iSMorph;
|
||||
float *m_pfSMorphInterValue;
|
||||
bool m_bTotalBilboard;
|
||||
|
||||
bool m_bCullOff;
|
||||
bool m_bZWriteOff;
|
||||
bool m_bZOff;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CMeshObjNode
|
||||
{
|
||||
|
||||
public:
|
||||
CMeshObjNode() : m_pParent(0),m_pChild(0),m_iChild(0),m_iParentID(-1),m_iNodeID(-1),
|
||||
m_iNodeType(SMRNODE_NODE),m_iObjectType(SMROBJ_MESH),m_iMeshType(SMRMESHTYPE_STATIC),m_pAniNode(NULL),
|
||||
m_bSkinMorph(false),m_pSkinData(NULL)
|
||||
{
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
m_iMeshData = 0;
|
||||
m_pArrMeshData.clear();
|
||||
|
||||
m_bAniNode = false;
|
||||
D3DXMatrixIdentity(&m_matNodeTm);
|
||||
D3DXMatrixIdentity(&m_matInvNodeTm);
|
||||
|
||||
D3DXMatrixIdentity(&m_matLocalTm);
|
||||
|
||||
|
||||
m_fVisibility = 1.0f;
|
||||
|
||||
m_bWorldTM = false;
|
||||
|
||||
}
|
||||
~CMeshObjNode()
|
||||
{
|
||||
|
||||
SafeDeleteA(m_pChild);
|
||||
m_pChild = NULL;
|
||||
|
||||
|
||||
SafeDelete(m_pAniNode);
|
||||
m_pAniNode = NULL;
|
||||
|
||||
SafeDelete(m_pSkinData);
|
||||
m_pSkinData = NULL;
|
||||
|
||||
}
|
||||
void SetParentNode(CMeshObjNode *pNode,const int &iParentID)
|
||||
{
|
||||
m_pParent = pNode;
|
||||
m_iParentID = iParentID;
|
||||
}
|
||||
CMeshObjNode *GetParentNode()
|
||||
{
|
||||
return m_pParent;
|
||||
}
|
||||
int GetParentNodeID()
|
||||
{
|
||||
return m_iParentID;
|
||||
|
||||
}
|
||||
int GetChildNum()
|
||||
{
|
||||
return m_iChild;
|
||||
}
|
||||
CMeshObjNode *GetChildNode(int iNum)
|
||||
{
|
||||
if(iNum < m_iChild)
|
||||
{
|
||||
return &(m_pChild[iNum]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void SetNodeName(const char *strName) { strcpy(m_strName,strName);}
|
||||
bool IsNodeSameName(const char *strName)
|
||||
{
|
||||
if(!strcmp(m_strName,strName)) return true;
|
||||
return false;
|
||||
}
|
||||
char *GetNodeName() { return m_strName;}
|
||||
|
||||
int GetNodeID() { return m_iNodeID;}
|
||||
void SetNodeID(const int &iNodeID) { m_iNodeID = iNodeID;}
|
||||
void SetType(const int &iNodeType,const int &iObjType,const int &iMeshType)
|
||||
{
|
||||
m_iNodeType = iNodeType;
|
||||
m_iObjectType = iObjType;
|
||||
m_iMeshType = iMeshType;
|
||||
}
|
||||
int GetNodeType() { return m_iNodeType;}
|
||||
int GetObjectType() { return m_iObjectType;}
|
||||
int GetMeshType() { return m_iMeshType;}
|
||||
|
||||
|
||||
CMeshCoreData *GetMeshData(const int &iMat)
|
||||
{
|
||||
for(unsigned int i = 0; i < m_pArrMeshData.size(); i++ )
|
||||
{
|
||||
if(m_pArrMeshData[i]->m_iMaterialIndex == iMat)
|
||||
return m_pArrMeshData[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void SetSkinMeshData(const int &iMat,const int &iVertex,CMeshSkinData::CMeshBlendData *pBlend,const int &iBlend)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < m_pArrMeshData.size(); i++ )
|
||||
{
|
||||
if(m_pArrMeshData[i]->m_iMaterialIndex == iMat)
|
||||
m_pArrMeshData[i]->SetSkinMeshData(iVertex,pBlend,iBlend);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void SetSkinMeshData(const int &iMat,const int &iVertex,D3DXMATRIX *matTm,D3DXMATRIX *matInvNodeTm)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < m_pArrMeshData.size(); i++ )
|
||||
{
|
||||
if(m_pArrMeshData[i]->m_iMaterialIndex == iMat)
|
||||
m_pArrMeshData[i]->SetSkinMeshData(iVertex,matTm,matInvNodeTm);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void AddMeshData(CMeshCoreData *pMesh)
|
||||
{
|
||||
m_pArrMeshData.push_back(pMesh);
|
||||
pMesh->m_pNode = this;
|
||||
|
||||
m_iMeshData++;
|
||||
|
||||
}
|
||||
void SetChildNum(const int &iNum) {
|
||||
m_iChild = iNum;
|
||||
SafeDeleteA(m_pChild);
|
||||
if(iNum > 0)
|
||||
{
|
||||
m_pChild = new CMeshObjNode[m_iChild];
|
||||
for(int i = 0; i <m_iChild; i++ )
|
||||
{
|
||||
m_pChild[i].SetParentNode(this,m_iNodeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetAniNode(CMeshKeyAniNode *pNode)
|
||||
{
|
||||
m_pAniNode = pNode;
|
||||
m_bAniNode = true;
|
||||
}
|
||||
CMeshKeyAniNode *GetAniNode()
|
||||
{
|
||||
if(m_bAniNode)
|
||||
return m_pAniNode;
|
||||
return NULL;
|
||||
|
||||
}
|
||||
bool ISAniNode()
|
||||
{
|
||||
return m_bAniNode;
|
||||
|
||||
}
|
||||
void SetSkinData(CMeshSkinData *pData)
|
||||
{
|
||||
m_pSkinData = pData;
|
||||
m_bSkinMorph =true;
|
||||
|
||||
}
|
||||
CMeshSkinData *GetSkinData()
|
||||
{
|
||||
if(m_bSkinMorph)
|
||||
return m_pSkinData;
|
||||
return NULL;
|
||||
}
|
||||
bool ISSkinData()
|
||||
{
|
||||
return m_bSkinMorph;
|
||||
|
||||
}
|
||||
void SetWorldTMFlag(bool bFlag) { m_bWorldTM = bFlag;}
|
||||
bool GetWorldTMFlag() { return m_bWorldTM;}
|
||||
|
||||
void UpdateTm(const float &fFrame,D3DXMATRIX *matParent = NULL);
|
||||
void UpdateSkinning();
|
||||
|
||||
|
||||
CMeshObjNode * m_pParent;
|
||||
int m_iParentID;
|
||||
|
||||
CMeshObjNode * m_pChild;
|
||||
int m_iChild;
|
||||
|
||||
D3DXMATRIX m_matNodeTm;
|
||||
D3DXMATRIX m_matInvNodeTm;
|
||||
|
||||
D3DXMATRIX m_matLocalTm;
|
||||
|
||||
|
||||
|
||||
CNodeTMInfo m_DefaultNodeTm;
|
||||
float m_fVisibility;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
char m_strName[256];
|
||||
int m_iNodeID;
|
||||
|
||||
int m_iNodeType;
|
||||
int m_iObjectType;
|
||||
int m_iMeshType;
|
||||
bool m_bWorldTM;
|
||||
|
||||
|
||||
CMeshKeyAniNode *m_pAniNode;
|
||||
bool m_bAniNode;
|
||||
|
||||
bool m_bSkinMorph;
|
||||
CMeshSkinData *m_pSkinData;
|
||||
|
||||
|
||||
|
||||
std::vector<CMeshCoreData *> m_pArrMeshData; // loading <20>Ҷ<EFBFBD> ä<><C3A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
int m_iMeshData;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
572
Engine/Effect/SMRObj.cpp
Normal file
572
Engine/Effect/SMRObj.cpp
Normal file
@@ -0,0 +1,572 @@
|
||||
// SMRObj.cpp: implementation of the CSMRObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "SMRObj.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
const DWORD dwExportMeshVertex = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;
|
||||
|
||||
void CSMRObj::GetAniNode(SGEngine::Core::CMeshObjNode *pNode,FILE *fp)
|
||||
{
|
||||
bool bAni = false;
|
||||
bool bWorldTM = false;
|
||||
bool bSkin = false;
|
||||
|
||||
int iNum[8];
|
||||
int iAniNum[14];
|
||||
|
||||
fread(iNum,sizeof(int) * 8,1,fp);
|
||||
pNode->SetNodeID(iNum[0]);
|
||||
pNode->SetType(iNum[2],iNum[3],iNum[4]);
|
||||
pNode->SetChildNum(iNum[1]);
|
||||
|
||||
bAni = (iNum[5] == 1) ? true : false;
|
||||
bWorldTM = (iNum[6] == 1) ? true : false;
|
||||
bSkin = (iNum[7] == 1) ? true : false;
|
||||
|
||||
|
||||
pNode->SetWorldTMFlag(bWorldTM);
|
||||
|
||||
|
||||
fread(pNode->GetNodeName(),sizeof(char) * 256,1,fp);
|
||||
fread(&(pNode->m_DefaultNodeTm),sizeof(SGEngine::Core::CNodeTMInfo),1,fp);
|
||||
fread(&(pNode->m_matNodeTm),sizeof(D3DXMATRIX),1,fp);
|
||||
D3DXMatrixInverse(&(pNode->m_matInvNodeTm),NULL,&(pNode->m_matNodeTm));
|
||||
|
||||
|
||||
if(bAni)
|
||||
{
|
||||
SGEngine::Core::CMeshKeyAniNode *pAniNode = new SGEngine::Core::CMeshKeyAniNode;
|
||||
fread(iAniNum,sizeof(int) * 14,1,fp);
|
||||
|
||||
pAniNode->m_bPosAni = (iAniNum[0] == 1) ? true : false;
|
||||
pAniNode->m_bRotAni = (iAniNum[1] == 1) ? true : false;
|
||||
pAniNode->m_bScaleAni = (iAniNum[2] == 1) ? true : false;
|
||||
pAniNode->m_bVisAni = (iAniNum[3] == 1) ? true : false;
|
||||
|
||||
pAniNode->m_iPosKeys = iAniNum[4];
|
||||
pAniNode->m_iPosType = iAniNum[5];
|
||||
|
||||
pAniNode->m_iRotKeys = iAniNum[6];
|
||||
pAniNode->m_iRotType = iAniNum[7];
|
||||
|
||||
pAniNode->m_iScaleKeys = iAniNum[8];
|
||||
pAniNode->m_iScaleType = iAniNum[9];
|
||||
|
||||
pAniNode->m_iVisKeys = iAniNum[10];
|
||||
pAniNode->m_iVisType = iAniNum[11];
|
||||
|
||||
pAniNode->m_bTmAni = (iAniNum[12] == 1) ? true : false;
|
||||
pAniNode->m_iTmKeys = iAniNum[13];
|
||||
|
||||
if(pAniNode->m_iPosKeys > 0)
|
||||
{
|
||||
pAniNode->m_pPosKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniPos[pAniNode->m_iPosKeys];
|
||||
fread(pAniNode->m_pPosKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniPos) * pAniNode->m_iPosKeys,1,fp);
|
||||
}
|
||||
if(pAniNode->m_iRotKeys > 0)
|
||||
{
|
||||
pAniNode->m_pRotKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniRot[pAniNode->m_iRotKeys];
|
||||
fread(pAniNode->m_pRotKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniRot) *pAniNode->m_iRotKeys,1,fp);
|
||||
|
||||
}
|
||||
if(pAniNode->m_iScaleKeys > 0)
|
||||
{
|
||||
pAniNode->m_pScaleKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniScale[pAniNode->m_iScaleKeys ];
|
||||
fread(pAniNode->m_pScaleKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniScale) *pAniNode->m_iScaleKeys ,1,fp);
|
||||
|
||||
}
|
||||
if(pAniNode->m_iVisKeys > 0)
|
||||
{
|
||||
pAniNode->m_pVisKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniVis[pAniNode->m_iVisKeys];
|
||||
fread(pAniNode->m_pVisKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniVis) *pAniNode->m_iVisKeys,1,fp);
|
||||
|
||||
}
|
||||
if(pAniNode->m_iTmKeys > 0)
|
||||
{
|
||||
pAniNode->m_pTmKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniTm[pAniNode->m_iTmKeys];
|
||||
fread(pAniNode->m_pTmKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniTm) * pAniNode->m_iTmKeys,1,fp);
|
||||
}
|
||||
pNode->SetAniNode(pAniNode);
|
||||
|
||||
}
|
||||
if(bSkin)
|
||||
{
|
||||
SGEngine::Core::CMeshSkinData *pSkinData = new SGEngine::Core::CMeshSkinData;
|
||||
int iSkinNum[2];
|
||||
fread(iSkinNum,sizeof(int) * 2, 1,fp);
|
||||
|
||||
pSkinData->m_iRigid = iSkinNum[0];
|
||||
|
||||
pSkinData->m_iBlend = iSkinNum[1];
|
||||
|
||||
if(iSkinNum[0])
|
||||
{
|
||||
pSkinData->m_pRigid = new SGEngine::Core::CMeshSkinData::CMeshSkinRigid[iSkinNum[0]];
|
||||
fread(pSkinData->m_pRigid,sizeof(SGEngine::Core::CMeshSkinData::CMeshSkinRigid) * iSkinNum[0],1,fp);
|
||||
}
|
||||
if(iSkinNum[1])
|
||||
{
|
||||
pSkinData->m_pBlend = new SGEngine::Core::CMeshSkinData::CMeshSkinBlend[iSkinNum[1]];
|
||||
for(int iBlend = 0; iBlend < iSkinNum[1]; iBlend++)
|
||||
{
|
||||
int iBlendNum[3];
|
||||
|
||||
fread(iBlendNum,sizeof(int) * 3, 1,fp);
|
||||
pSkinData->m_pBlend[iBlend].m_iMatIndex = iBlendNum[0];
|
||||
pSkinData->m_pBlend[iBlend].m_iVertexIndex = iBlendNum[1];
|
||||
pSkinData->m_pBlend[iBlend].m_iBlendData = iBlendNum[2];
|
||||
|
||||
if(iBlendNum[2])
|
||||
{
|
||||
pSkinData->m_pBlend[iBlend].m_pArrBlendData = new SGEngine::Core::CMeshSkinData::CMeshBlendData[iBlendNum[2]];
|
||||
fread(pSkinData->m_pBlend[iBlend].m_pArrBlendData,sizeof(SGEngine::Core::CMeshSkinData::CMeshBlendData) * iBlendNum[2],1,fp);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
pNode->SetSkinData(pSkinData);
|
||||
}
|
||||
for(int i= 0; i < pNode->GetChildNum(); i++)
|
||||
GetAniNode(pNode->GetChildNode(i),fp);
|
||||
|
||||
|
||||
|
||||
}
|
||||
void CSMRObj::AddMesh(SGEngine::Core::CMeshCoreData *pMesh,SGEngine::Core::CMeshObjNode *pNode)
|
||||
{
|
||||
if(pNode && pMesh)
|
||||
{
|
||||
if(!strcmp(pNode->GetNodeName() , pMesh->m_strName))
|
||||
{
|
||||
pNode->AddMeshData(pMesh);
|
||||
|
||||
if(pNode->ISSkinData())
|
||||
{
|
||||
pMesh->CreateDefaultBuffer();
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
AddMesh(pMesh,pNode->GetChildNode(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSMRObj::Load(const char *strFileName)
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"rb");
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
if(fp)
|
||||
{
|
||||
fread(&m_MeshHeader,sizeof(SGEngine::Core::CMeshHeader),1,fp);
|
||||
|
||||
m_iFrameInfo[0] = m_MeshHeader.m_iExtension[0]; // Start Frame
|
||||
m_iFrameInfo[1] = m_MeshHeader.m_iExtension[1]; // End Frame
|
||||
m_iFrameInfo[2] = m_MeshHeader.m_iExtension[2]; // Frame Rate
|
||||
m_iFrameInfo[3] = m_MeshHeader.m_iExtension[3]; // TickPerFrame
|
||||
|
||||
for(i = 0; i < m_MeshHeader.m_iNodes; i++ )
|
||||
{
|
||||
SGEngine::Core::CMeshObjNodeHeader ObjHeader;
|
||||
fread(&ObjHeader,sizeof(SGEngine::Core::CMeshObjNodeHeader),1,fp);
|
||||
|
||||
if(ObjHeader.m_iNodeType == SGEngine::MESHNODETYPE_MATERIAL)
|
||||
{
|
||||
m_iMaterial = ObjHeader.m_iNodeSize;
|
||||
if(m_iMaterial)
|
||||
{
|
||||
m_pMaterial = new SGEngine::Core::CMeshMaterialInfo[m_iMaterial];
|
||||
fread(m_pMaterial,sizeof(SGEngine::Core::CMeshMaterialInfo) * m_iMaterial,1,fp);
|
||||
CTexture *pTexture = NULL;
|
||||
CTexture::SetPath(EFFECTTEXTUREPATH);
|
||||
|
||||
for(j = 0; j < m_iMaterial; j++ )
|
||||
{
|
||||
|
||||
pTexture = new CTexture;
|
||||
pTexture->Load(m_pMaterial[j].m_strName);
|
||||
m_lstTexture.push_back(pTexture);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else if(ObjHeader.m_iNodeType == SGEngine::MESHNODETYPE_MESHDATA)
|
||||
{
|
||||
int iNum[6];
|
||||
m_iMeshData = ObjHeader.m_iNodeSize;
|
||||
m_pMeshData = new SGEngine::Core::CMeshCoreData[m_iMeshData];
|
||||
m_pVertexBuffer = new LPDIRECT3DVERTEXBUFFER8[m_iMeshData];
|
||||
m_pIndexBuffer= new LPDIRECT3DINDEXBUFFER8[m_iMeshData];
|
||||
|
||||
for(j = 0 ; j < (int)ObjHeader.m_iNodeSize; j++ )
|
||||
{
|
||||
|
||||
fread(iNum,sizeof(int) * 6,1,fp);
|
||||
m_pMeshData[j].m_iVerticesNum = iNum[2];
|
||||
m_pMeshData[j].m_iIndicesNum = iNum[3];
|
||||
m_pMeshData[j].m_iMaterialIndex = iNum[1];
|
||||
m_pMeshData[j].m_iType = iNum[0];
|
||||
m_pMeshData[j].m_bMorph = (iNum[4] == 1) ? true : false;
|
||||
m_pMeshData[j].m_bSMorph = (iNum[5] == 1) ? true : false;
|
||||
|
||||
fread(m_pMeshData[j].m_strName,sizeof(char) * 256, 1,fp);
|
||||
if(strchr(m_pMeshData[j].m_strName,'C'))
|
||||
{
|
||||
m_pMeshData[j].SetTotalBilboard(true);
|
||||
}
|
||||
if(strchr(m_pMeshData[j].m_strName,'Z'))
|
||||
{
|
||||
m_pMeshData[j].SetZWriteOffFlag(true);
|
||||
}
|
||||
if(strchr(m_pMeshData[j].m_strName,'W'))
|
||||
{
|
||||
m_pMeshData[j].SetCullOffFlag(true);
|
||||
}
|
||||
if(strchr(m_pMeshData[j].m_strName,'K'))
|
||||
{
|
||||
m_pMeshData[j].SetZOffFlag(true);
|
||||
}
|
||||
m_pMeshData[j].CreateBuffer();
|
||||
fread(m_pMeshData[j].m_pIndices,sizeof(WORD) * m_pMeshData[j].m_iIndicesNum,1,fp);
|
||||
fread(m_pMeshData[j].m_pVertices,sizeof(SGEngine::CExportMeshVertex) * m_pMeshData[j].m_iVerticesNum,1,fp);
|
||||
if(m_pMeshData[j].m_bMorph)
|
||||
{
|
||||
fread(&m_pMeshData[j].m_iMorph,sizeof(int), 1,fp);
|
||||
m_pMeshData[j].m_pMorphData = new SGEngine::Core::CMeshCoreData::CMeshMorphData[m_pMeshData[j].m_iMorph];
|
||||
for(int iMorph= 0; iMorph < m_pMeshData[j].m_iMorph; iMorph++)
|
||||
{
|
||||
|
||||
fread(&m_pMeshData[j].m_pMorphData[iMorph].m_iFrame,sizeof(int),1,fp);
|
||||
m_pMeshData[j].m_pMorphData[iMorph].m_pVertices = new SGEngine::CExportMeshVertex[m_pMeshData[j].m_iVerticesNum];
|
||||
|
||||
fread(m_pMeshData[j].m_pMorphData[iMorph].m_pVertices,sizeof(SGEngine::CExportMeshVertex) * m_pMeshData[j].m_iVerticesNum,1,fp);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(m_pMeshData[j].m_bSMorph)
|
||||
{
|
||||
m_pMeshData[j].CreateDefaultBuffer();
|
||||
fread(&(m_pMeshData[j].m_iSMorph),sizeof(int),1,fp);
|
||||
m_pMeshData[j].m_pSMorph = new SGEngine::Core::CMeshCoreData::CMeshSMorphData[m_pMeshData[j].m_iSMorph];
|
||||
m_pMeshData[j].m_pfSMorphInterValue = new float[m_pMeshData[j].m_iSMorph];
|
||||
for(int ism = 0;ism < m_pMeshData[j].m_iSMorph; ism++)
|
||||
{
|
||||
m_pMeshData[j].m_pfSMorphInterValue[ism] = 0.0f;
|
||||
int iSMNum[2];
|
||||
fread(m_pMeshData[j].m_pSMorph[ism].m_strName,sizeof(char) * 256, 1,fp);
|
||||
fread(iSMNum,sizeof(int) * 2,1,fp);
|
||||
m_pMeshData[j].m_pSMorph[ism].m_iModelID = iSMNum[0];
|
||||
m_pMeshData[j].m_pSMorph[ism].m_iRelativeNum = iSMNum[1];
|
||||
m_pMeshData[j].m_pSMorph[ism].m_pRelativeVertices = new D3DXVECTOR3[iSMNum[1]];
|
||||
m_pMeshData[j].m_pSMorph[ism].m_pRelativeIndex = new int[iSMNum[1]];
|
||||
fread(m_pMeshData[j].m_pSMorph[ism].m_pRelativeVertices,sizeof(D3DXVECTOR3) * iSMNum[1],1,fp);
|
||||
fread(m_pMeshData[j].m_pSMorph[ism].m_pRelativeIndex,sizeof(int) * iSMNum[1],1,fp);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
CSceneManager::GetDevice()->CreateVertexBuffer(m_pMeshData[j].m_iVerticesNum * sizeof(SGEngine::CExportMeshVertex),D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC,
|
||||
D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1,D3DPOOL_DEFAULT,&(m_pVertexBuffer[j]));
|
||||
|
||||
SGEngine::CExportMeshVertex *pVert = NULL;
|
||||
|
||||
m_pVertexBuffer[j]->Lock(0,0,(BYTE **) &pVert,0);
|
||||
memcpy(pVert,m_pMeshData[j].m_pVertices,sizeof(SGEngine::CExportMeshVertex) * m_pMeshData[j].m_iVerticesNum);
|
||||
m_pVertexBuffer[j]->Unlock();
|
||||
|
||||
CSceneManager::GetDevice()->CreateIndexBuffer(sizeof(WORD) * m_pMeshData[j].m_iIndicesNum,D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_DEFAULT,&m_pIndexBuffer[j]);
|
||||
|
||||
WORD *pWord = NULL;
|
||||
|
||||
m_pIndexBuffer[j]->Lock(0,0,(BYTE **)&pWord,0);
|
||||
memcpy(pWord,m_pMeshData[j].m_pIndices,sizeof(WORD) * m_pMeshData[j].m_iIndicesNum);
|
||||
m_pIndexBuffer[j]->Unlock();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else if(ObjHeader.m_iNodeType == SGEngine::MESHNODETYPE_ANINODE)
|
||||
{
|
||||
m_pRootNode = new SGEngine::Core::CMeshObjNode;
|
||||
GetAniNode(m_pRootNode,fp);
|
||||
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
for(i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
AddMesh(&m_pMeshData[i],m_pRootNode);
|
||||
}
|
||||
SetSkinningLink(m_pRootNode);
|
||||
}
|
||||
}
|
||||
SGEngine::Core::CMeshObjNode *CSMRObj::FindNode(const char *strName,SGEngine::Core::CMeshObjNode *pNode)
|
||||
{
|
||||
int i;
|
||||
if(pNode)
|
||||
{
|
||||
if(pNode->IsNodeSameName(strName))
|
||||
return pNode;
|
||||
}
|
||||
for(i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
SGEngine::Core::CMeshObjNode * pN = NULL;
|
||||
if((pN = FindNode(strName,pNode->GetChildNode(i))) != NULL)
|
||||
return pN;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
void CSMRObj::SetSkinningLink(SGEngine::Core::CMeshObjNode *pNode)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
if(pNode->ISSkinData())
|
||||
{
|
||||
SGEngine::Core::CMeshSkinData *pSkinData = pNode->GetSkinData();
|
||||
|
||||
for(i = 0; i < pSkinData->m_iRigid; i++ )
|
||||
{
|
||||
pSkinData->m_pRigid[i].m_pNode = FindNode(pSkinData->m_pRigid[i].m_strNodeName,m_pRootNode);
|
||||
|
||||
}
|
||||
for(i =0; i < pSkinData->m_iBlend; i++ )
|
||||
{
|
||||
for(j = 0; j < (pSkinData->m_pBlend->m_iBlendData); j++ )
|
||||
{
|
||||
pSkinData->m_pBlend[i].m_pArrBlendData[j].m_pNode =
|
||||
FindNode(pSkinData->m_pBlend[i].m_pArrBlendData[j].m_strNodeName,m_pRootNode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for(i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
SetSkinningLink(pNode->GetChildNode(i));
|
||||
}
|
||||
}
|
||||
void CSMRObj::UpdateSkinning(SGEngine::Core::CMeshObjNode *pNode)
|
||||
{
|
||||
if(pNode->ISSkinData())
|
||||
{
|
||||
pNode->UpdateSkinning();
|
||||
}
|
||||
for(int i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
UpdateSkinning(pNode->GetChildNode(i));
|
||||
}
|
||||
|
||||
}
|
||||
void CSMRObj::UpdateBuffer(const float &fFrame)
|
||||
{
|
||||
int i;
|
||||
|
||||
SGEngine::CExportMeshVertex *pVert = NULL;
|
||||
|
||||
for(i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
m_pMeshData[i].UpdateMeshMorph(fFrame);
|
||||
m_pMeshData[i].UpdateMeshSmartMorph();
|
||||
|
||||
if(m_pMeshData[i].m_bUpdateData)
|
||||
{
|
||||
m_pMeshData[i].SetUpdateFlag(false);
|
||||
pVert = NULL;
|
||||
|
||||
m_pVertexBuffer[i]->Lock(0,0,(BYTE **) &pVert,0);
|
||||
memcpy(pVert,m_pMeshData[i].m_pVertices,sizeof(SGEngine::CExportMeshVertex) * m_pMeshData[i].m_iVerticesNum);
|
||||
m_pVertexBuffer[i]->Unlock();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CSMRObj::UpdateTm(SGEngine::Core::CMeshObjNode *pNode,const float &fFrame)
|
||||
{
|
||||
if(pNode->GetParentNode())
|
||||
pNode->UpdateTm(fFrame,&(pNode->GetParentNode()->m_matNodeTm));
|
||||
else
|
||||
pNode->UpdateTm(fFrame,NULL);
|
||||
for(int i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
UpdateTm(pNode->GetChildNode(i),fFrame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSMRObj::Render(LPDIRECT3DDEVICE8 lpDevice,D3DXVECTOR3 vecPos,D3DXVECTOR3 vecScale,D3DXQUATERNION quatRot,float fFrame)
|
||||
{
|
||||
|
||||
|
||||
|
||||
int i = 0;
|
||||
float iFrame = fFrame;
|
||||
|
||||
|
||||
// Scale, Pos ,setting
|
||||
// D3DXMATRIX matWorld;
|
||||
// D3DXMatrixIdentity(&matWorld);
|
||||
// matWorld._41 = vecPos.x;
|
||||
// matWorld._42 = vecPos.y;
|
||||
// matWorld._43 = vecPos.z;
|
||||
// matWorld._11 = vecScale.x;
|
||||
// matWorld._22 = vecScale.y;
|
||||
// matWorld._33 = vecScale.z;
|
||||
D3DXMATRIX matWorld, matScale, matRot;
|
||||
D3DXMatrixScaling( &matScale, vecScale.x, vecScale.y, vecScale.z );
|
||||
D3DXMatrixRotationQuaternion( &matRot, &quatRot );
|
||||
D3DXMatrixMultiply( &matWorld, &matRot, &matScale );
|
||||
matWorld._41 = vecPos.x;
|
||||
matWorld._42 = vecPos.y;
|
||||
matWorld._43 = vecPos.z;
|
||||
|
||||
|
||||
/*m_pRootNode->m_matNodeTm._41 = vecPos.x;
|
||||
m_pRootNode->m_matNodeTm._42 = vecPos.y;
|
||||
m_pRootNode->m_matNodeTm._43 = vecPos.z;
|
||||
|
||||
m_pRootNode->m_matNodeTm._11 = vecScale.x;
|
||||
m_pRootNode->m_matNodeTm._22 = vecScale.y;
|
||||
m_pRootNode->m_matNodeTm._33 = vecScale.z;
|
||||
*/
|
||||
|
||||
|
||||
UpdateTm(m_pRootNode,iFrame);
|
||||
UpdateSkinning(m_pRootNode); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
UpdateBuffer(iFrame);
|
||||
|
||||
|
||||
if(iFrame > (float)m_iFrameInfo[1])
|
||||
{
|
||||
iFrame = (float)m_iFrameInfo[0];
|
||||
|
||||
}
|
||||
if(iFrame < (float)m_iFrameInfo[0])
|
||||
iFrame = (float)m_iFrameInfo[1];
|
||||
|
||||
|
||||
|
||||
D3DXMATRIX matIdentity;
|
||||
D3DXMatrixIdentity(&matIdentity);
|
||||
|
||||
lpDevice->SetPixelShader(NULL);
|
||||
lpDevice->SetVertexShader(dwExportMeshVertex);
|
||||
|
||||
for(i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
if(m_pMeshData[i].m_iVerticesNum && m_pMeshData[i].m_iIndicesNum)
|
||||
{
|
||||
if(m_pMeshData[i].m_pNode)
|
||||
{
|
||||
|
||||
if(m_pMeshData[i].GetTotalBilboard())
|
||||
{ // bilboard
|
||||
|
||||
|
||||
D3DXMATRIX view;
|
||||
D3DXMATRIX invers_view;
|
||||
|
||||
lpDevice->GetTransform(D3DTS_VIEW,&view);
|
||||
view._41 = view._42 = view._43 =0.0;
|
||||
D3DXMatrixInverse(&invers_view,NULL,&view);
|
||||
D3DXMatrixMultiply(&(m_pMeshData[i].m_pNode->m_matNodeTm),&(m_pMeshData[i].m_pNode->m_matNodeTm),&invers_view);
|
||||
|
||||
|
||||
|
||||
}
|
||||
D3DXMatrixMultiply(&(m_pMeshData[i].m_pNode->m_matNodeTm),&(m_pMeshData[i].m_pNode->m_matNodeTm),&matWorld);
|
||||
|
||||
if(m_pMeshData[i].m_pNode->ISSkinData())
|
||||
{
|
||||
lpDevice->SetTransform(D3DTS_WORLD,&matIdentity);
|
||||
}
|
||||
else{
|
||||
lpDevice->SetTransform(D3DTS_WORLD,&(m_pMeshData[i].m_pNode->m_matNodeTm));
|
||||
|
||||
}
|
||||
|
||||
int iValue = (int)(m_pMeshData[i].m_pNode->m_fVisibility * 255.0f);
|
||||
|
||||
DWORD color = D3DCOLOR_ARGB(iValue,iValue,iValue,iValue);
|
||||
lpDevice->SetRenderState(D3DRS_TEXTUREFACTOR,color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
DWORD color = D3DCOLOR_ARGB(255,255,255,255);
|
||||
lpDevice->SetRenderState(D3DRS_TEXTUREFACTOR,color);
|
||||
}
|
||||
|
||||
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
|
||||
lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
lpDevice->SetRenderState(D3DRS_ALPHATESTENABLE,FALSE);
|
||||
lpDevice->SetRenderState(D3DRS_SRCBLEND,m_dwSrcBlend);
|
||||
lpDevice->SetRenderState(D3DRS_DESTBLEND,m_dwDstBlend);
|
||||
|
||||
if(m_pMeshData[i].GetCullOffFlag())
|
||||
lpDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
else
|
||||
lpDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
if(m_pMeshData[i].GetZWriteOffFlag())
|
||||
{
|
||||
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
}
|
||||
if(m_pMeshData[i].GetZOffFlag())
|
||||
lpDevice->SetRenderState(D3DRS_ZENABLE,FALSE);
|
||||
else
|
||||
lpDevice->SetRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TFACTOR);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
|
||||
lpDevice->SetTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TFACTOR);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_TEXTURE);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
lpDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_DISABLE);
|
||||
|
||||
|
||||
lpDevice->SetTexture(0,m_lstTexture[m_pMeshData[i].m_iMaterialIndex]->GetTexture());
|
||||
|
||||
lpDevice->SetStreamSource(0,m_pVertexBuffer[i],sizeof(SGEngine::CExportMeshVertex));
|
||||
lpDevice->SetIndices(m_pIndexBuffer[i],0);
|
||||
lpDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,m_pMeshData[i].m_iVerticesNum,0,m_pMeshData[i].m_iIndicesNum/3);
|
||||
|
||||
lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
lpDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_LESSEQUAL);
|
||||
lpDevice->SetRenderState(D3DRS_ALPHATESTENABLE,FALSE);
|
||||
lpDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CW);
|
||||
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
lpDevice->SetRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
140
Engine/Effect/SMRObj.h
Normal file
140
Engine/Effect/SMRObj.h
Normal file
@@ -0,0 +1,140 @@
|
||||
// SMRObj.h: interface for the CSMRObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SMROBJ_H__FD33169B_0305_4327_A366_EC1DB3AAD241__INCLUDED_)
|
||||
#define AFX_SMROBJ_H__FD33169B_0305_4327_A366_EC1DB3AAD241__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include "./SMRHeader.h"
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
class CSMRObj
|
||||
{
|
||||
public:
|
||||
CSMRObj() :m_pMaterial(NULL),m_iMaterial(0),
|
||||
m_pMeshData(NULL),m_iMeshData(0)
|
||||
{
|
||||
|
||||
m_pVertexBuffer = NULL;
|
||||
m_pIndexBuffer = NULL;
|
||||
m_lstTexture.clear();
|
||||
|
||||
m_pRootNode = NULL;
|
||||
memset(m_iFrameInfo,0,sizeof(int) * 4);
|
||||
|
||||
m_dwSrcBlend = D3DBLEND_SRCALPHA;
|
||||
m_dwDstBlend = D3DBLEND_INVSRCALPHA;
|
||||
|
||||
|
||||
|
||||
}
|
||||
~CSMRObj()
|
||||
{
|
||||
|
||||
if(m_pMaterial)
|
||||
{
|
||||
delete[] m_pMaterial;
|
||||
m_pMaterial = NULL;
|
||||
|
||||
}
|
||||
if(m_pMeshData)
|
||||
{
|
||||
delete[] m_pMeshData;
|
||||
m_pMeshData = NULL;
|
||||
|
||||
}
|
||||
if(m_pVertexBuffer)
|
||||
{
|
||||
for(int i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
if(m_pVertexBuffer[i])
|
||||
m_pVertexBuffer[i]->Release();
|
||||
}
|
||||
delete[] m_pVertexBuffer;
|
||||
}
|
||||
if(m_pIndexBuffer)
|
||||
{
|
||||
for(int i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
if(m_pIndexBuffer[i])
|
||||
m_pIndexBuffer[i]->Release();
|
||||
}
|
||||
delete[] m_pIndexBuffer;
|
||||
|
||||
}
|
||||
|
||||
std::vector<CTexture* >::iterator itr = m_lstTexture.begin() ;
|
||||
std::vector<CTexture* >::iterator end = m_lstTexture.end() ;
|
||||
while ( itr != end )
|
||||
{
|
||||
if ( NULL != (*itr) )
|
||||
{
|
||||
delete (*itr) ;
|
||||
(*itr) = NULL ;
|
||||
}
|
||||
|
||||
++itr ;
|
||||
}
|
||||
m_lstTexture.clear();
|
||||
|
||||
if(m_pRootNode)
|
||||
{
|
||||
delete m_pRootNode;
|
||||
m_pRootNode = NULL;
|
||||
}
|
||||
}
|
||||
void Render(LPDIRECT3DDEVICE8 lpDevice,D3DXVECTOR3 vecPos,D3DXVECTOR3 vecScale,D3DXQUATERNION quatRot,float fFrame);
|
||||
void UpdateTm(SGEngine::Core::CMeshObjNode *pNode,const float &fFrame);
|
||||
void UpdateBuffer(const float &fFrame);
|
||||
void UpdateSkinning(SGEngine::Core::CMeshObjNode *pNode);
|
||||
void SetSkinningLink(SGEngine::Core::CMeshObjNode *pNode);
|
||||
SGEngine::Core::CMeshObjNode *FindNode(const char *strName,SGEngine::Core::CMeshObjNode *pNode);
|
||||
void Load(const char *strFileName);
|
||||
void AddMesh(SGEngine::Core::CMeshCoreData *pMesh,SGEngine::Core::CMeshObjNode *pNode);
|
||||
void GetAniNode(SGEngine::Core::CMeshObjNode *pNode,FILE *fp);
|
||||
|
||||
void SetSrcBlend(DWORD dwValue) { m_dwSrcBlend = dwValue;}
|
||||
void SetDstBlend(DWORD dwValue) { m_dwDstBlend = dwValue;}
|
||||
|
||||
DWORD GetSrcBlend() { return m_dwSrcBlend;}
|
||||
DWORD GetDstBlend() { return m_dwDstBlend;}
|
||||
|
||||
|
||||
SGEngine::Core::CMeshHeader m_MeshHeader;
|
||||
|
||||
SGEngine::Core::CMeshMaterialInfo *m_pMaterial;
|
||||
int m_iMaterial;
|
||||
|
||||
SGEngine::Core::CMeshCoreData *m_pMeshData;
|
||||
|
||||
|
||||
|
||||
|
||||
SGEngine::Core::CMeshObjNode *m_pRootNode;
|
||||
|
||||
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_pVertexBuffer;
|
||||
LPDIRECT3DINDEXBUFFER8 *m_pIndexBuffer;
|
||||
|
||||
|
||||
std::vector<CTexture *> m_lstTexture;
|
||||
|
||||
|
||||
int m_iMeshData;
|
||||
|
||||
int m_iFrameInfo[4];
|
||||
|
||||
DWORD m_dwSrcBlend;
|
||||
DWORD m_dwDstBlend;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // !defined(AFX_SMROBJ_H__FD33169B_0305_4327_A366_EC1DB3AAD241__INCLUDED_)
|
||||
454
Engine/Effect/X3DEffect.cpp
Normal file
454
Engine/Effect/X3DEffect.cpp
Normal file
@@ -0,0 +1,454 @@
|
||||
// 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 "GMMemory.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::Render(void)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
if(m_StartEffect) {
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->Render();
|
||||
}
|
||||
}
|
||||
m_lpD3DDevice->SetRenderState(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);
|
||||
}
|
||||
|
||||
}
|
||||
141
Engine/Effect/X3DEffect.h
Normal file
141
Engine/Effect/X3DEffect.h
Normal file
@@ -0,0 +1,141 @@
|
||||
// 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);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECT_H__36D22C0B_3861_4B57_B539_4E4BFAD198C1__INCLUDED_)
|
||||
51
Engine/Effect/X3DEffectBase.cpp
Normal file
51
Engine/Effect/X3DEffectBase.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// X3DEffectBase.cpp: implementation of the CX3DEffectBase class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
#include "GMMemory.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;
|
||||
}
|
||||
|
||||
CX3DEffectBase::~CX3DEffectBase()
|
||||
{
|
||||
if(m_lpTexture) { delete m_lpTexture; m_lpTexture = NULL; }
|
||||
}
|
||||
void CX3DEffectBase::SetStopParticle(int t) {
|
||||
m_StopParticleFrame = t;
|
||||
}
|
||||
int CX3DEffectBase::GetStopParticle() {
|
||||
return m_StopParticleFrame;
|
||||
}
|
||||
void CX3DEffectBase::LoadTexture(const char *strFilename)
|
||||
{
|
||||
if(m_lpTexture) { delete m_lpTexture; m_lpTexture = NULL; }
|
||||
m_lpTexture = new CTexture();
|
||||
m_lpTexture->Init(m_lpD3DDevice);
|
||||
|
||||
m_lpTexture->SetPath(EFFECTTEXTUREPATH);
|
||||
m_lpTexture->Load((char *)strFilename);
|
||||
strcpy(m_strTextureFile, strFilename);
|
||||
}
|
||||
|
||||
void CX3DEffectBase::SetGemClearBuffer(bool b)
|
||||
{
|
||||
m_bClearBuffer = b;
|
||||
|
||||
}
|
||||
147
Engine/Effect/X3DEffectBase.h
Normal file
147
Engine/Effect/X3DEffectBase.h
Normal file
@@ -0,0 +1,147 @@
|
||||
// X3DEffectBase.h: interface for the CX3DEffectBase class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTBASE_H__C6A7B2C5_B699_4078_9690_00AF0121FFA9__INCLUDED_)
|
||||
#define AFX_X3DEFFECTBASE_H__C6A7B2C5_B699_4078_9690_00AF0121FFA9__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "key.h"
|
||||
#include "Texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
#define EFFECT_PARTICLE 0
|
||||
#define EFFECT_BILLBOARD 1
|
||||
#define EFFECT_CYLINDER 2
|
||||
#define EFFECT_PLANE 3
|
||||
#define EFFECT_SPHERE 4
|
||||
#define EFFECT_MESH 5
|
||||
|
||||
class CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwEffectKind; // <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_)
|
||||
321
Engine/Effect/X3DEffectBillboard.cpp
Normal file
321
Engine/Effect/X3DEffectBillboard.cpp
Normal file
@@ -0,0 +1,321 @@
|
||||
// X3DEffectBillboard.cpp: implementation of the CX3DEffectBillboard class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectBillboard.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.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) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
else
|
||||
m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
else
|
||||
m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
|
||||
// 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; }
|
||||
|
||||
if(m_lpVerticesBlend) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
//m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
// m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
// m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
/*
|
||||
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());
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetRenderState(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)
|
||||
{
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(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 | D3DLOCK_NOSYSLOCK) ) ) return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) ) return FALSE;
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0) ) ) return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (unsigned char **)&pVerticesBlend, 0) ) ) return FALSE;
|
||||
|
||||
if(m_bAxisAligned)
|
||||
{
|
||||
m_vecAxisT = vector3(0.0f, (m_fHeight / 2), 0.0f);
|
||||
m_vecEyeT = vector3(0.0f, 0.0f, -1.0f);
|
||||
|
||||
z3d::VectorRotate(m_vecAxisT, m_vecAxisT, m_quatAxis);
|
||||
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis()) z3d::VectorRotate(m_vecAxisT, m_vecAxisT, (*((CX3DEffect *)m_lpLocalEffect)->GetAxis()));
|
||||
m_vecEyeT = vector3(m_vecEyeT.x * m_matLocalView->_11 + m_vecEyeT.y * m_matLocalView->_12 + m_vecEyeT.z * m_matLocalView->_13,
|
||||
m_vecEyeT.x * m_matLocalView->_21 + m_vecEyeT.y * m_matLocalView->_22 + m_vecEyeT.z * m_matLocalView->_23,
|
||||
m_vecEyeT.x * m_matLocalView->_31 + m_vecEyeT.y * m_matLocalView->_32 + m_vecEyeT.z * m_matLocalView->_33);
|
||||
m_vecWidthT = m_vecAxisT ^ m_vecEyeT;
|
||||
m_vecWidthT.Normalize();
|
||||
m_vecWidthT *= (m_fWidth / 2);
|
||||
|
||||
pVertices[0].v = m_vecAxisT + m_vecWidthT + m_vecCenter;
|
||||
pVertices[1].v = m_vecAxisT - m_vecWidthT + m_vecCenter;
|
||||
pVertices[2].v = -m_vecAxisT + m_vecWidthT + m_vecCenter;
|
||||
pVertices[3].v = -m_vecAxisT - m_vecWidthT + m_vecCenter;
|
||||
} else
|
||||
{
|
||||
matrix *matView = ((CX3DEffect *)m_lpLocalEffect)->GetViewMatrix();
|
||||
|
||||
float w = m_fWidth / 2;
|
||||
float h = m_fHeight / 2;
|
||||
|
||||
pVertices[0].v = vector3(-w, h, 0.0f);
|
||||
pVertices[1].v = vector3(w, h, 0.0f);
|
||||
pVertices[2].v = vector3(-w, -h, 0.0f);
|
||||
pVertices[3].v = vector3(w, -h, 0.0f);
|
||||
|
||||
vector3 vecCenter;
|
||||
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, m_quatAxis);
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
{
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
|
||||
z3d::VectorRotate(vecCenter, m_vecCenter, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
} else
|
||||
{
|
||||
vecCenter = m_vecCenter;
|
||||
}
|
||||
|
||||
pVertices[0].v = vector3(pVertices[0].v.x * matView->_11 + pVertices[0].v.y * matView->_12, pVertices[0].v.x * matView->_21 + pVertices[0].v.y * matView->_22, pVertices[0].v.x * matView->_31 + pVertices[0].v.y * matView->_32);
|
||||
pVertices[1].v = vector3(pVertices[1].v.x * matView->_11 + pVertices[1].v.y * matView->_12, pVertices[1].v.x * matView->_21 + pVertices[1].v.y * matView->_22, pVertices[1].v.x * matView->_31 + pVertices[1].v.y * matView->_32);
|
||||
pVertices[2].v = vector3(pVertices[2].v.x * matView->_11 + pVertices[2].v.y * matView->_12, pVertices[2].v.x * matView->_21 + pVertices[2].v.y * matView->_22, pVertices[2].v.x * matView->_31 + pVertices[2].v.y * matView->_32);
|
||||
pVertices[3].v = vector3(pVertices[3].v.x * matView->_11 + pVertices[3].v.y * matView->_12, pVertices[3].v.x * matView->_21 + pVertices[3].v.y * matView->_22, pVertices[3].v.x * matView->_31 + pVertices[3].v.y * matView->_32);
|
||||
|
||||
pVertices[0].v += vecCenter;
|
||||
pVertices[1].v += vecCenter;
|
||||
pVertices[2].v += vecCenter;
|
||||
pVertices[3].v += vecCenter;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
pVerticesBlend[0].v = pVertices[0].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[1].v = pVertices[1].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[2].v = pVertices[2].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[3].v = pVertices[3].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
} else
|
||||
{
|
||||
pVerticesBlend[0].v = pVertices[0].v;
|
||||
pVerticesBlend[1].v = pVertices[1].v;
|
||||
pVerticesBlend[2].v = pVertices[2].v;
|
||||
pVerticesBlend[3].v = pVertices[3].v;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
fEndU = f1 + 0.25f;
|
||||
fEndV = f2 + 0.25f;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndBU = f1 + 0.25f;
|
||||
fEndBV = f2 + 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU;
|
||||
fEndBV = fEndV = m_fTileV;
|
||||
}
|
||||
pVertices[0].tu = fStartU; pVertices[0].tv = fStartV;
|
||||
pVertices[1].tu = fEndU; pVertices[1].tv = fStartV;
|
||||
pVertices[2].tu = fStartU; pVertices[2].tv = fEndV;
|
||||
pVertices[3].tu = fEndU; pVertices[3].tv = fEndV;
|
||||
pVerticesBlend[0].tu = fStartBU; pVerticesBlend[0].tv = fStartBV;
|
||||
pVerticesBlend[1].tu = fEndBU; pVerticesBlend[1].tv = fStartBV;
|
||||
pVerticesBlend[2].tu = fStartBU; pVerticesBlend[2].tv = fEndBV;
|
||||
pVerticesBlend[3].tu = fEndBU; pVerticesBlend[3].tv = fEndBV;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
pVertices[0].diff = pVertices[1].diff = pVertices[2].diff = pVertices[3].diff = m_lColor;
|
||||
pVerticesBlend[0].diff = pVerticesBlend[1].diff = pVerticesBlend[2].diff = pVerticesBlend[3].diff = m_lColor;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[3].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVertices[0].diff.a = pVertices[1].diff.a = pVertices[2].diff.a = pVertices[3].diff.a;
|
||||
pVerticesBlend[3].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
pVerticesBlend[0].diff.a = pVerticesBlend[1].diff.a = pVerticesBlend[2].diff.a = pVerticesBlend[3].diff.a;
|
||||
}
|
||||
pVertices[0].spec = pVertices[1].spec = pVertices[2].spec = pVertices[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].spec = pVerticesBlend[1].spec = pVerticesBlend[2].spec = pVerticesBlend[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
fread(&m_bAxisAligned, 4, 1, fp);
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstWidth.Load(fp, m_fWidth);
|
||||
m_lstHeight.Load(fp, m_fHeight);
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
fwrite(&m_bAxisAligned, 4, 1, fp);
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
m_lstColor.Save(fp);
|
||||
m_lstWidth.Save(fp);
|
||||
m_lstHeight.Save(fp);
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
77
Engine/Effect/X3DEffectBillboard.h
Normal file
77
Engine/Effect/X3DEffectBillboard.h
Normal file
@@ -0,0 +1,77 @@
|
||||
// X3DEffectBillboard.h: interface for the CX3DEffectBillboard class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTBILLBOARD_H__C83DF58D_552F_430C_8BBD_7274114C7B44__INCLUDED_)
|
||||
#define AFX_X3DEFFECTBILLBOARD_H__C83DF58D_552F_430C_8BBD_7274114C7B44__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectBillboard : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
float m_fWidth;
|
||||
float m_fHeight;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
BOOL m_bAxisAligned;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstWidth;
|
||||
CKeyList<FloatKeyList> m_lstHeight;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
// <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_)
|
||||
316
Engine/Effect/X3DEffectCylinder.cpp
Normal file
316
Engine/Effect/X3DEffectCylinder.cpp
Normal file
@@ -0,0 +1,316 @@
|
||||
// X3DEffectCylinder.cpp: implementation of the CX3DEffectCylinder class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectCylinder.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.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) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
else
|
||||
m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
else
|
||||
m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
/*
|
||||
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) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
//m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
// m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
// m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(((m_dwSidePlane + 1) * 2) * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(((m_dwSidePlane + 1) * 2) * sizeof(LVertex),LVERTEXFVF,true);
|
||||
m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(((m_dwSidePlane + 1) * 2) * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(((m_dwSidePlane + 1) * 2) * sizeof(LVertex),LVERTEXFVF,false);
|
||||
|
||||
/*
|
||||
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();
|
||||
|
||||
m_lpD3DDevice->SetRenderState(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());
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(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)
|
||||
{
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(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 | D3DLOCK_NOSYSLOCK) ) )
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0) ) )
|
||||
return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) )
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (unsigned char **)&pVerticesBlend, 0) ) )
|
||||
return FALSE;
|
||||
|
||||
unsigned long i, tempi;
|
||||
float degree;
|
||||
float divangle = 360.0f / m_dwSidePlane;
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
|
||||
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
|
||||
fEndU = fEndBU = 0.25f;
|
||||
fEndV = fEndBV = 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU - fStartBU;
|
||||
fEndBV = fEndV = m_fTileV - fStartBV;
|
||||
}
|
||||
|
||||
for(i = 0; i < m_dwSidePlane; i++)
|
||||
{
|
||||
degree = FLOAT_DEG(i * divangle);
|
||||
|
||||
tempi = i * 2 + 1;
|
||||
pVertices[tempi].v = vector3(m_fUpperRadius * cosf(degree), m_fUpperHeight, m_fUpperRadius * sinf(degree));
|
||||
z3d::VectorRotate(pVertices[tempi].v, pVertices[tempi].v, m_quatAxis);
|
||||
pVertices[tempi].v += m_vecCenter;
|
||||
pVerticesBlend[tempi].v = pVertices[tempi].v;
|
||||
|
||||
pVertices[tempi].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVertices[tempi].tv = fStartV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[tempi].tv = fStartBV;
|
||||
|
||||
tempi = i * 2;
|
||||
pVertices[tempi].v = vector3(m_fLowerRadius * cosf(degree), -m_fLowerHeight, m_fLowerRadius * sinf(degree));
|
||||
z3d::VectorRotate(pVertices[tempi].v, pVertices[tempi].v, m_quatAxis);
|
||||
pVertices[tempi].v += m_vecCenter;
|
||||
pVerticesBlend[tempi].v = pVertices[tempi].v;
|
||||
|
||||
pVertices[tempi].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVertices[tempi].tv = fEndV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[tempi].tv = fEndBV;
|
||||
}
|
||||
tempi = m_dwSidePlane * 2 + 1;
|
||||
pVertices[tempi].v = pVertices[1].v;
|
||||
pVertices[tempi].tu = fStartU + fEndU;
|
||||
pVertices[tempi].tv = fStartV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU;
|
||||
pVerticesBlend[tempi].tv = fStartBV;
|
||||
|
||||
tempi = m_dwSidePlane * 2;
|
||||
pVertices[tempi].v = pVertices[0].v;
|
||||
pVertices[tempi].tu = fStartU + fEndU;
|
||||
pVertices[tempi].tv = fEndV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU;
|
||||
pVerticesBlend[tempi].tv = fEndBV;
|
||||
|
||||
pVertices[0].diff = m_lColor;
|
||||
pVertices[0].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].diff = pVertices[0].diff;
|
||||
pVerticesBlend[0].spec = pVertices[0].spec;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[0].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVerticesBlend[0].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
}
|
||||
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * 2; i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
fread(&m_dwSidePlane, 4, 1, fp);
|
||||
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstUpperHeight.Load(fp, m_fUpperHeight);
|
||||
m_lstUpperRadius.Load(fp, m_fUpperRadius);
|
||||
m_lstLowerHeight.Load(fp, m_fLowerHeight);
|
||||
m_lstLowerRadius.Load(fp, m_fLowerRadius);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fUpperHeight *=m_Scale[0];
|
||||
m_fUpperRadius *=m_Scale[0];
|
||||
m_fLowerHeight *=m_Scale[0];
|
||||
m_fLowerRadius *=m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
fwrite(&m_dwSidePlane, 4, 1, fp);
|
||||
|
||||
m_lstColor.Save(fp);
|
||||
m_lstUpperHeight.Save(fp);
|
||||
m_lstUpperRadius.Save(fp);
|
||||
m_lstLowerHeight.Save(fp);
|
||||
m_lstLowerRadius.Save(fp);
|
||||
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
82
Engine/Effect/X3DEffectCylinder.h
Normal file
82
Engine/Effect/X3DEffectCylinder.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// X3DEffectCylinder.h: interface for the CX3DEffectCylinder class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_)
|
||||
#define AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectCylinder : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwSidePlane, m_dwPrimitive;
|
||||
float m_fUpperHeight;
|
||||
float m_fLowerHeight;
|
||||
float m_fUpperRadius;
|
||||
float m_fLowerRadius;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstUpperHeight;
|
||||
CKeyList<FloatKeyList> m_lstLowerHeight;
|
||||
CKeyList<FloatKeyList> m_lstUpperRadius;
|
||||
CKeyList<FloatKeyList> m_lstLowerRadius;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectCylinder();
|
||||
virtual ~CX3DEffectCylinder();
|
||||
|
||||
void SetSidePlane(unsigned long dwSidePlane) { m_dwSidePlane = dwSidePlane; }
|
||||
unsigned long GetSidePlane(void) { return m_dwSidePlane; }
|
||||
|
||||
void SetUpperHeight(float fUpperHeight) { m_fUpperHeight = fUpperHeight; }
|
||||
float GetUpperHeight(void) { return m_fUpperHeight; }
|
||||
void SetLowerHeight(float fLowerHeight) { m_fLowerHeight = fLowerHeight; }
|
||||
float GetLowerHeight(void) { return m_fLowerHeight; }
|
||||
|
||||
void SetUpperRadius(float fUpperRadius) { m_fUpperRadius = fUpperRadius; }
|
||||
float GetUpperRadius(void) { return m_fUpperRadius; }
|
||||
void SetLowerRadius(float fLowerRadius) { m_fLowerRadius = fLowerRadius; }
|
||||
float GetLowerRadius(void) { return m_fLowerRadius; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_)
|
||||
979
Engine/Effect/X3DEffectManager.cpp
Normal file
979
Engine/Effect/X3DEffectManager.cpp
Normal file
@@ -0,0 +1,979 @@
|
||||
// X3DEffectManager.cpp: implementation of the CX3DEffectManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffectManager.h"
|
||||
#include "X3DEffectMesh.h"
|
||||
#include "SceneNode.h"
|
||||
#include "SceneManager.h"
|
||||
//#include <crtdbg.h>
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectManager::CX3DEffectManager()
|
||||
{
|
||||
m_lstExist.clear();
|
||||
m_lstFree.clear();
|
||||
m_lstEffect.clear();
|
||||
m_lstEffect.reserve(40);
|
||||
m_lstScript.clear();
|
||||
m_lstScript.reserve(40);
|
||||
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);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
m_lpD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_ALWAYS);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHAREF,0x00000000);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++,i++)
|
||||
{
|
||||
if(i== num) {
|
||||
m_lpD3DDevice->SetRenderState(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)
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
|
||||
|
||||
}
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
m_lpD3DDevice->SetRenderState(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);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
m_lpD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_ALWAYS);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHAREF,0x00000000);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(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);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
m_lpD3DDevice->SetRenderState(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(((int)m_lstScript.size() - 1)< i) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(m_lstScript[i] == NULL) {
|
||||
DeleteEndScript(i);
|
||||
return 0;
|
||||
}
|
||||
index = m_lstScript[i]->ProcessEffect(CSceneManager::m_SkillWeatherEffect);
|
||||
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(((int)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(((int)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(((int)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(((int)m_lstIScript.size() - 1)< i)
|
||||
return false;
|
||||
|
||||
if(m_lstIScript[i] == NULL) {
|
||||
DeleteInterfaceScript(i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
index = m_lstIScript[i]->ProcessEffect(CSceneManager::m_SkillWeatherEffect);
|
||||
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<(int)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<(int)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.begin() + i);
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
void CX3DEffectManager::DeleteLightning(int index) {
|
||||
int i;
|
||||
for(i=0;i<(int)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.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::DeleteEndScript(CEffScript *del) {
|
||||
int i;
|
||||
for(i=0;i<(int)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.begin() + i);
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
void CX3DEffectManager::DeleteWScript(int index) {
|
||||
|
||||
int i;
|
||||
for(i=0;i<(int)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.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteInterfaceScript(int index) {
|
||||
int i;
|
||||
for(i=0;i<(int)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.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteInterfaceScript(CEffScript *del) {
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstIScript.size();i++) {
|
||||
if(m_lstIScript[i] == del) {
|
||||
delete m_lstIScript[i];
|
||||
m_lstIScript[i] = NULL;
|
||||
m_lstIScript.erase(m_lstIScript.begin() + 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;
|
||||
|
||||
// Pool <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ȵǰ<C8B5> <20><><EFBFBD><EFBFBD>.. by Vincent
|
||||
//if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<(int)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<(int)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;
|
||||
// Pool <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ȵǰ<C8B5> <20><><EFBFBD><EFBFBD>.. by Vincent
|
||||
//if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<(int)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;
|
||||
// Pool <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ȵǰ<C8B5> <20><><EFBFBD><EFBFBD>.. by Vincent
|
||||
//if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<(int)m_lstIScript.size();i++) {
|
||||
if(m_lstIScript[i] != NULL) {
|
||||
delete m_lstIScript[i];
|
||||
m_lstIScript[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
//}
|
||||
m_lstIScript.clear();
|
||||
}
|
||||
130
Engine/Effect/X3DEffectManager.h
Normal file
130
Engine/Effect/X3DEffectManager.h
Normal file
@@ -0,0 +1,130 @@
|
||||
// X3DEffectManager.h: interface for the CX3DEffectManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTMANAGER_H__4DAA8921_D30C_4F05_B138_89DFFC19B449__INCLUDED_)
|
||||
#define AFX_X3DEFFECTMANAGER_H__4DAA8921_D30C_4F05_B138_89DFFC19B449__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#pragma warning(disable:4786) // don't warn about browse name overflow.
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
#include <vector>
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectSphere.h"
|
||||
#include "SectorEffectMap.h"
|
||||
#include "CEffscript.h"
|
||||
#include "ViewFrustum.h"
|
||||
|
||||
#define DEFAULTLIMITSCRIPT 5
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef unsigned long XEFFECT;
|
||||
typedef vector<CX3DEffect *> EffectList;
|
||||
typedef vector<XEFFECT> EffectHandleList;
|
||||
typedef vector<CEffScript *> EffectScriptList;
|
||||
typedef vector<CLightning *> LightningList;
|
||||
|
||||
class CX3DEffectManager
|
||||
{
|
||||
protected:
|
||||
LPDIRECT3DDEVICE8 m_lpD3DDevice;
|
||||
matrix m_matView;
|
||||
matrix m_matWorld;
|
||||
|
||||
EffectHandleList m_lstExist;
|
||||
EffectHandleList m_lstFree;
|
||||
|
||||
// <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_)
|
||||
462
Engine/Effect/X3DEffectMesh.cpp
Normal file
462
Engine/Effect/X3DEffectMesh.cpp
Normal file
@@ -0,0 +1,462 @@
|
||||
// X3DEffectMesh.cpp: implementation of the CX3DEffectMesh class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectMesh.h"
|
||||
#include "EffDebugLog.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.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;
|
||||
m_pSmrMesh = NULL;
|
||||
|
||||
// <09><><EFBFBD><EFBFBD>:m_GemRender = new CGemRender;
|
||||
}
|
||||
|
||||
CX3DEffectMesh::~CX3DEffectMesh()
|
||||
{
|
||||
if(m_moMesh) { delete[] m_moMesh; m_moMesh = NULL; }
|
||||
|
||||
if(m_GemRender)
|
||||
{
|
||||
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_pSmrMesh)
|
||||
delete m_pSmrMesh;
|
||||
|
||||
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);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
|
||||
D3DXVECTOR3 *vecCenter = (D3DXVECTOR3 *)((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
|
||||
if(m_GemRender)
|
||||
{
|
||||
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();
|
||||
|
||||
}
|
||||
if(m_pSmrMesh)
|
||||
{
|
||||
D3DXQUATERNION tm_q(0,0,0,1);
|
||||
if(m_QuatSet)
|
||||
{
|
||||
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_pSmrMesh->Render(CSceneManager::GetDevice(),*vecCenter,D3DXVECTOR3(m_Scale[0],m_Scale[1],m_Scale[2]),tm_q,m_fRenderFrame);
|
||||
}
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE,cullmode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,zmode);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::LoadFile(char *file)
|
||||
{
|
||||
bool m_bGem = true;
|
||||
char strTest1[256];
|
||||
strcpy(strTest1, file);
|
||||
|
||||
char strTest2[256];
|
||||
strcpy(strTest2, file);
|
||||
|
||||
char *pStr = strrchr(strTest1,'.');
|
||||
pStr++;
|
||||
*(pStr++) = 'G';
|
||||
*(pStr++) = 'E';
|
||||
*(pStr) = 'M';
|
||||
|
||||
pStr = strrchr(strTest2,'.');
|
||||
pStr++;
|
||||
*(pStr++) = 'S';
|
||||
*(pStr++) = 'M';
|
||||
*(pStr) = 'R';
|
||||
|
||||
if(stricmp(file,strTest1) == 0)
|
||||
{
|
||||
strcpy(m_strMeshFile, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(m_strMeshFile, strTest2);
|
||||
m_bGem =false;
|
||||
}
|
||||
|
||||
if(m_bGem)
|
||||
{
|
||||
|
||||
|
||||
// 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>ȭ
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSmrMesh = new CSMRObj;
|
||||
m_pSmrMesh->SetSrcBlend(m_dwSrcBlending);
|
||||
m_pSmrMesh->SetDstBlend(m_dwDestBlending);
|
||||
m_pSmrMesh->Load(strTest2);
|
||||
|
||||
m_dwObjectNum = (DWORD)m_pSmrMesh->m_iMeshData;
|
||||
|
||||
}
|
||||
m_dwTick = new DWORD[2];
|
||||
m_bFirst = new bool;
|
||||
|
||||
*m_bFirst = false;
|
||||
memset(m_dwTick,0,sizeof(DWORD) * 2);
|
||||
|
||||
|
||||
m_moMesh = new MeshObject[m_dwObjectNum];
|
||||
}
|
||||
|
||||
BOOL CX3DEffectMesh::Interpolation(float fFrame)
|
||||
{
|
||||
for(long i = 0; i < (int)m_dwObjectNum; i++)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_moMesh[i].m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// color setting
|
||||
if(m_GemRender)
|
||||
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 < (int)m_dwObjectNum; i++)
|
||||
{
|
||||
|
||||
m_moMesh[i].m_lstColor.Load(fp, m_lColor);
|
||||
fread(&m_moMesh[i].m_fTexFrame, 4, 1, fp);
|
||||
if(m_GemRender)
|
||||
m_GemRender->SetChangeAniFrame(i,m_moMesh[i].m_fTexFrame);
|
||||
|
||||
fread(&m_moMesh[i].m_fStartTexFrame, 4, 1, fp);
|
||||
if(m_GemRender)
|
||||
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 < (int)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<(int)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<(int)(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<(int)(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.begin() + 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 //////////////////////////////////
|
||||
185
Engine/Effect/X3DEffectMesh.h
Normal file
185
Engine/Effect/X3DEffectMesh.h
Normal file
@@ -0,0 +1,185 @@
|
||||
// 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 "SMRObj.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< (int)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;
|
||||
CSMRObj *m_pSmrMesh;
|
||||
|
||||
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)
|
||||
{
|
||||
if(m_GemRender)
|
||||
return (unsigned long)m_GemRender->GetMaxFrame();
|
||||
else if(m_pSmrMesh)
|
||||
{
|
||||
return (unsigned long)m_pSmrMesh->m_iFrameInfo[1];
|
||||
}
|
||||
}
|
||||
|
||||
void SetSrcBlending(unsigned long dwSrcBlending)
|
||||
{
|
||||
m_dwSrcBlending = dwSrcBlending;
|
||||
if(m_GemRender)
|
||||
{
|
||||
// Mesh->SetBlend(m_dwSrcBlending, m_dwDestBlending);
|
||||
m_GemRender->SetSrcBlend(m_dwSrcBlending);
|
||||
}
|
||||
else if(m_pSmrMesh)
|
||||
{
|
||||
m_pSmrMesh->SetSrcBlend(m_dwSrcBlending);
|
||||
}
|
||||
|
||||
}
|
||||
void SetDestBlending(unsigned long dwDestBlending)
|
||||
{
|
||||
m_dwDestBlending = dwDestBlending;
|
||||
if(m_GemRender)
|
||||
{
|
||||
|
||||
// Mesh->SetBlend(m_dwSrcBlending, m_dwDestBlending);
|
||||
m_GemRender->SetDstBlend(m_dwDestBlending);
|
||||
|
||||
}
|
||||
else if(m_pSmrMesh)
|
||||
{
|
||||
m_pSmrMesh->SetDstBlend(m_dwDestBlending);
|
||||
}
|
||||
}
|
||||
|
||||
void SetTexFrame(unsigned long dwObjectNum, float fTexFrame)
|
||||
{
|
||||
m_moMesh[dwObjectNum].m_fTexFrame = fTexFrame;
|
||||
// Mesh->SetTexAniFrame(dwObjectNum, fTexFrame);
|
||||
if(m_GemRender)
|
||||
{
|
||||
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;
|
||||
if(m_GemRender)
|
||||
{
|
||||
|
||||
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);
|
||||
if(m_GemRender)
|
||||
{
|
||||
|
||||
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_)
|
||||
824
Engine/Effect/X3DEffectParticle.cpp
Normal file
824
Engine/Effect/X3DEffectParticle.cpp
Normal file
@@ -0,0 +1,824 @@
|
||||
// X3DEffectParticle.cpp: implementation of the CX3DEffectParticle class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectParticle.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.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;
|
||||
m_lpVerticeInfo = 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; }*/
|
||||
|
||||
if(m_lpVerticeIndex) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_INDEX,m_lpVerticeIndex);
|
||||
else
|
||||
m_lpVerticeIndex->Release();
|
||||
m_lpVerticeIndex = NULL;
|
||||
}
|
||||
if(m_lpVerticesBlend) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
else
|
||||
m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
else
|
||||
m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
|
||||
if (m_lpVerticeInfo) { delete[] m_lpVerticeInfo; m_lpVerticeInfo = NULL; }
|
||||
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; }
|
||||
*/
|
||||
if(m_lpVerticeIndex) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_INDEX,m_lpVerticeIndex);
|
||||
//m_lpVerticeIndex->Release();
|
||||
m_lpVerticeIndex = NULL;
|
||||
}
|
||||
if(m_lpVerticesBlend) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
//m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
// m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
// m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(m_dwMaxAmount * 4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(m_dwMaxAmount * 4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticeIndex = CSceneManager::ms_pBufferPools->GetIndexBuffer(m_dwMaxAmount * 2 * 3 * sizeof(unsigned short),D3DFMT_INDEX16,false);
|
||||
m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(m_dwMaxAmount * 4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(m_dwMaxAmount * 4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticeIndex = CSceneManager::ms_pBufferPools->GetIndexBuffer(m_dwMaxAmount * 2 * 3 * sizeof(unsigned short),D3DFMT_INDEX16,false);
|
||||
/*
|
||||
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);
|
||||
m_lpVerticeIndex->Lock(0, 0, (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);
|
||||
|
||||
//m_lpD3DDevice->SetRenderState(D3DRS_ZENABLE,FALSE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_ALPHABLENDENABLE,&amode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_CULLMODE,&cullmode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_DISABLE);
|
||||
m_lpD3DDevice->SetTextureStageState(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)
|
||||
{
|
||||
// m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
// m_lpD3DDevice->SetRenderState(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);
|
||||
}//***/
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,zmode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE,cullmode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,amode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
}
|
||||
|
||||
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 ) ) )
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0 ) ) )
|
||||
return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) )
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (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> 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 ) ) )
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0 ) ) )
|
||||
return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, 0 ) ) )
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (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);
|
||||
}
|
||||
114
Engine/Effect/X3DEffectParticle.h
Normal file
114
Engine/Effect/X3DEffectParticle.h
Normal file
@@ -0,0 +1,114 @@
|
||||
// X3DEffectParticle.h: interface for the CX3DEffectParticle class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTPARTICLE_H__0750B6D9_11E2_41A9_BFEF_D92F0F1E0CC5__INCLUDED_)
|
||||
#define AFX_X3DEFFECTPARTICLE_H__0750B6D9_11E2_41A9_BFEF_D92F0F1E0CC5__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
typedef struct _Particle
|
||||
{
|
||||
vector3 vecPos;
|
||||
vector3 vecVel;
|
||||
float fLifetime;
|
||||
float fMaxLife;
|
||||
float fTexFrame;
|
||||
|
||||
float fRotation;
|
||||
unsigned long dwRotationCount;
|
||||
float fWidth;
|
||||
float fHeight;
|
||||
color lColor;
|
||||
} Particle, *LPParticle;
|
||||
|
||||
class CX3DEffectParticle : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwMaxAmount;
|
||||
unsigned long m_dwDrawAmount;
|
||||
float m_fAlpha;
|
||||
float m_fPower;
|
||||
float m_fAngle;
|
||||
vector3 m_vecEForce;
|
||||
quaternion m_quatDir;
|
||||
|
||||
float m_fPowerSeed;
|
||||
float m_fLifetime;
|
||||
float m_fLifetimeSeed;
|
||||
|
||||
float m_fRotation;
|
||||
float m_fTexSpeed;
|
||||
|
||||
// <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_)
|
||||
281
Engine/Effect/X3DEffectPlane.cpp
Normal file
281
Engine/Effect/X3DEffectPlane.cpp
Normal file
@@ -0,0 +1,281 @@
|
||||
// X3DEffectPlane.cpp: implementation of the CX3DEffectPlane class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectPlane.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.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; }
|
||||
if(m_lpVerticesBlend) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
else
|
||||
m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
else
|
||||
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) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
//m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
// m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
// m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
|
||||
/*
|
||||
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);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(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)
|
||||
{
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(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 | D3DLOCK_NOSYSLOCK) ) ) return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) ) return FALSE;
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0) ) ) return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (unsigned char **)&pVerticesBlend, 0) ) ) return FALSE;
|
||||
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
fEndU = f1 + 0.25f;
|
||||
fEndV = f2 + 0.25f;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndBU = f1 + 0.25f;
|
||||
fEndBV = f2 + 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU;
|
||||
fEndBV = fEndV = m_fTileV;
|
||||
}
|
||||
|
||||
pVertices[0].v = vector3(-(m_fWidth / 2), 0, (m_fHeight / 2));
|
||||
pVertices[1].v = vector3( (m_fWidth / 2), 0, (m_fHeight / 2));
|
||||
pVertices[2].v = vector3(-(m_fWidth / 2), 0, -(m_fHeight / 2));
|
||||
pVertices[3].v = vector3( (m_fWidth / 2), 0, -(m_fHeight / 2));
|
||||
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, m_quatAxis);
|
||||
|
||||
/* quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
if(quatAxis)
|
||||
{
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, (*quatAxis));
|
||||
}
|
||||
|
||||
pVerticesBlend[0].v = pVertices[0].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[1].v = pVertices[1].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[2].v = pVertices[2].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[3].v = pVertices[3].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());*/
|
||||
pVerticesBlend[0].v = pVertices[0].v += m_vecCenter;
|
||||
pVerticesBlend[1].v = pVertices[1].v += m_vecCenter;
|
||||
pVerticesBlend[2].v = pVertices[2].v += m_vecCenter;
|
||||
pVerticesBlend[3].v = pVertices[3].v += m_vecCenter;
|
||||
|
||||
pVertices[0].tu = fStartU; pVertices[0].tv = fStartV;
|
||||
pVertices[1].tu = fEndU; pVertices[1].tv = fStartV;
|
||||
pVertices[2].tu = fStartU; pVertices[2].tv = fEndV;
|
||||
pVertices[3].tu = fEndU; pVertices[3].tv = fEndV;
|
||||
pVerticesBlend[0].tu = fStartBU; pVerticesBlend[0].tv = fStartBV;
|
||||
pVerticesBlend[1].tu = fEndBU; pVerticesBlend[1].tv = fStartBV;
|
||||
pVerticesBlend[2].tu = fStartBU; pVerticesBlend[2].tv = fEndBV;
|
||||
pVerticesBlend[3].tu = fEndBU; pVerticesBlend[3].tv = fEndBV;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
pVertices[0].diff = pVertices[1].diff = pVertices[2].diff = pVertices[3].diff = m_lColor;
|
||||
pVerticesBlend[0].diff = pVerticesBlend[1].diff = pVerticesBlend[2].diff = pVerticesBlend[3].diff = m_lColor;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[3].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVertices[0].diff.a = pVertices[1].diff.a = pVertices[2].diff.a = pVertices[3].diff.a;
|
||||
pVerticesBlend[3].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
pVerticesBlend[0].diff.a = pVerticesBlend[1].diff.a = pVerticesBlend[2].diff.a = pVerticesBlend[3].diff.a;
|
||||
}
|
||||
pVertices[0].spec = pVertices[1].spec = pVertices[2].spec = pVertices[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].spec = pVerticesBlend[1].spec = pVerticesBlend[2].spec = pVerticesBlend[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstWidth.Load(fp, m_fWidth);
|
||||
m_lstHeight.Load(fp, m_fHeight);
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
m_lstColor.Save(fp);
|
||||
m_lstWidth.Save(fp);
|
||||
m_lstHeight.Save(fp);
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
69
Engine/Effect/X3DEffectPlane.h
Normal file
69
Engine/Effect/X3DEffectPlane.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// X3DEffectPlane.h: interface for the CX3DEffectPlane class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_)
|
||||
#define AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectPlane : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
float m_fWidth;
|
||||
float m_fHeight;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstWidth;
|
||||
CKeyList<FloatKeyList> m_lstHeight;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectPlane();
|
||||
virtual ~CX3DEffectPlane();
|
||||
|
||||
void SetWidth(float fWidth) { m_fWidth = fWidth; }
|
||||
float GetWidth(void) { return m_fWidth; }
|
||||
void SetHeight(float fHeight) { m_fHeight = fHeight; }
|
||||
float GetHeight(void) { return m_fHeight; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_)
|
||||
473
Engine/Effect/X3DEffectSphere.cpp
Normal file
473
Engine/Effect/X3DEffectSphere.cpp
Normal file
@@ -0,0 +1,473 @@
|
||||
// X3DEffectSphere.cpp: implementation of the CX3DEffectSphere class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectSphere.h"
|
||||
#include "GMMemory.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);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(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)
|
||||
{
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwNumVertex, 0, m_dwPrimitive);
|
||||
}/**/
|
||||
}
|
||||
|
||||
BOOL CX3DEffectSphere::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
|
||||
if(m_lpVertices == NULL) return FALSE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
if(!m_lstHeightFactor.Interpolation(fFrame, m_fHeightFactor)) return FALSE;
|
||||
if(!m_lstRadius.Interpolation(fFrame, m_fRadius)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fRadius *= m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(!m_lstUpperFactor.Interpolation(fFrame, m_fUpperFactor)) return FALSE;
|
||||
if(!m_lstLowerFactor.Interpolation(fFrame, m_fLowerFactor)) return FALSE;
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(m_bVisibility) {
|
||||
|
||||
{
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
if(FAILED( m_lpVertices->Lock( 0, (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
|
||||
unsigned long i, tempi, j, t1, tv = 0;
|
||||
float degree, hdegree, height, hcos;
|
||||
float divangle = FLOAT_PHI * 2.0f / m_dwSidePlane;
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndU = fEndBU = 0.25f;
|
||||
fEndV = fEndBV = 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU - fStartBU;
|
||||
fEndBV = fEndV = m_fTileV - fStartBV;
|
||||
}
|
||||
|
||||
float fHEV = fEndV / 2.0f, fSV = fHEV + fStartV, fDSV = fSV * 2.0f;
|
||||
float fHEBV = fEndBV / 2.0f, fSBV = fHEBV + fStartBV, fDSBV = fSBV * 2.0f;
|
||||
float fSegTemp, fSegBTemp;
|
||||
if(m_bUpperVis)
|
||||
{
|
||||
for(j = 0; j <= m_dwSegment; j++)
|
||||
{
|
||||
if(m_bUpperUp)
|
||||
hdegree = (FLOAT_PHI / 2.0f) - ((j * FLOAT_PHI) / (2.0f * m_dwSegment) * m_fUpperFactor);
|
||||
else
|
||||
hdegree = ((j * FLOAT_PHI) / (2.0f * m_dwSegment)) * m_fUpperFactor;
|
||||
height = m_fRadius * m_fHeightFactor * sinf(hdegree);
|
||||
hcos = cosf(hdegree);
|
||||
fSegTemp = fHEV * j / m_dwSegment;
|
||||
fSegBTemp = fHEBV * j / m_dwSegment;
|
||||
|
||||
for(i = 0; i <= m_dwSidePlane; i++)
|
||||
{
|
||||
if(i == m_dwSidePlane) tempi = 0; else tempi = i;
|
||||
|
||||
degree = tempi * divangle;
|
||||
t1 = (m_dwSidePlane + 1) * j + i;
|
||||
|
||||
pVertices[t1].v = vector3(m_fRadius * cosf(degree) * hcos, height, m_fRadius * sinf(degree) * hcos);
|
||||
z3d::VectorRotate(pVertices[t1].v, pVertices[t1].v, m_quatAxis);
|
||||
pVertices[t1].v += m_vecCenter;
|
||||
pVerticesBlend[t1].v = pVertices[t1].v;
|
||||
|
||||
pVertices[t1].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[t1].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
if(m_bUpperUp)
|
||||
{
|
||||
if(m_bUpperTex)
|
||||
{
|
||||
pVertices[t1].tv = fStartV + fSegTemp * m_fUpperFactor;
|
||||
pVerticesBlend[t1].tv = fStartBV + fSegBTemp * m_fUpperFactor;
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fStartV + fSegTemp;
|
||||
pVerticesBlend[t1].tv = fStartBV + fSegBTemp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_bUpperTex)
|
||||
{
|
||||
pVertices[t1].tv = (fStartV + fSV) - ((fStartV + fSegTemp) * m_fUpperFactor);
|
||||
pVerticesBlend[t1].tv = (fStartBV + fSBV) - ((fStartBV + fSegBTemp) * m_fUpperFactor);
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fSV - fSegTemp;
|
||||
pVerticesBlend[t1].tv = fSBV - fSegBTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tv = (m_dwSidePlane + 1) * (m_dwSegment + 1);
|
||||
}
|
||||
|
||||
if(m_bLowerVis)
|
||||
{
|
||||
for(j = 0; j <= m_dwSegment; j++)
|
||||
{
|
||||
if(m_bLowerUp)
|
||||
hdegree = (FLOAT_PHI / 2.0f) - ((j * FLOAT_PHI) / (2.0f * m_dwSegment) * m_fLowerFactor);
|
||||
else
|
||||
hdegree = ((j * FLOAT_PHI) / (2.0f * m_dwSegment)) * m_fLowerFactor;
|
||||
height = m_fRadius * m_fHeightFactor * sinf(hdegree);
|
||||
hcos = cosf(hdegree);
|
||||
fSegTemp = fHEV * j / m_dwSegment;
|
||||
fSegBTemp = fHEBV * j / m_dwSegment;
|
||||
|
||||
for(i = 0; i <= m_dwSidePlane; i++)
|
||||
{
|
||||
if(i == m_dwSidePlane) tempi = 0; else tempi = i;
|
||||
|
||||
degree = tempi * divangle;
|
||||
t1 = tv + (m_dwSidePlane + 1) * j + i;
|
||||
|
||||
pVertices[t1].v = vector3(m_fRadius * cosf(degree) * hcos, -height, m_fRadius * sinf(degree) * hcos);
|
||||
z3d::VectorRotate(pVertices[t1].v, pVertices[t1].v, m_quatAxis);
|
||||
pVertices[t1].v += m_vecCenter;
|
||||
pVerticesBlend[t1].v = pVertices[t1].v;
|
||||
|
||||
pVertices[t1].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[t1].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
if(m_bLowerUp)
|
||||
{
|
||||
if(m_bLowerTex)
|
||||
{
|
||||
pVertices[t1].tv = fDSV - ((fStartV + fSegTemp) * m_fLowerFactor);
|
||||
pVerticesBlend[t1].tv = fDSBV - ((fStartBV + fSegBTemp) * m_fLowerFactor);
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fDSV - (fStartV + fSegTemp);
|
||||
pVerticesBlend[t1].tv = fDSBV - (fStartBV + fSegBTemp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_bLowerTex)
|
||||
{
|
||||
pVertices[t1].tv = fSV + fSegTemp * m_fLowerFactor;
|
||||
pVerticesBlend[t1].tv = fSBV + fSegBTemp * m_fLowerFactor;
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fSV + fSegTemp;
|
||||
pVerticesBlend[t1].tv = fSBV + fSegBTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pVertices[0].diff = m_lColor;
|
||||
pVertices[0].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].diff =pVertices[0].diff;
|
||||
pVerticesBlend[0].spec =pVertices[0].spec;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[0].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVerticesBlend[0].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
}
|
||||
|
||||
if(m_dwTotalSegment == m_dwSegment)
|
||||
{
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * (m_dwSegment + 1); i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
} else
|
||||
{
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2; i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
}
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
|
||||
fread(&m_dwSidePlane, 4, 1, fp);
|
||||
fread(&m_dwSegment, 4, 1, fp);
|
||||
|
||||
fread(&m_bUpperTex, 4, 1, fp);
|
||||
fread(&m_bUpperUp, 4, 1, fp);
|
||||
fread(&m_bUpperVis, 4, 1, fp);
|
||||
fread(&m_bLowerTex, 4, 1, fp);
|
||||
fread(&m_bLowerUp, 4, 1, fp);
|
||||
fread(&m_bLowerVis, 4, 1, fp);
|
||||
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstHeightFactor.Load(fp, m_fHeightFactor);
|
||||
m_lstRadius.Load(fp, m_fRadius);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fRadius *= m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
m_lstUpperFactor.Load(fp, m_fUpperFactor);
|
||||
m_lstLowerFactor.Load(fp, m_fLowerFactor);
|
||||
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
|
||||
fwrite(&m_dwSidePlane, 4, 1, fp);
|
||||
fwrite(&m_dwSegment, 4, 1, fp);
|
||||
|
||||
fwrite(&m_bUpperTex, 4, 1, fp);
|
||||
fwrite(&m_bUpperUp, 4, 1, fp);
|
||||
fwrite(&m_bUpperVis, 4, 1, fp);
|
||||
fwrite(&m_bLowerTex, 4, 1, fp);
|
||||
fwrite(&m_bLowerUp, 4, 1, fp);
|
||||
fwrite(&m_bLowerVis, 4, 1, fp);
|
||||
|
||||
m_lstColor.Save(fp);
|
||||
m_lstHeightFactor.Save(fp);
|
||||
m_lstRadius.Save(fp);
|
||||
m_lstUpperFactor.Save(fp);
|
||||
m_lstLowerFactor.Save(fp);
|
||||
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
107
Engine/Effect/X3DEffectSphere.h
Normal file
107
Engine/Effect/X3DEffectSphere.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// X3DEffectSphere.h: interface for the CX3DEffectSphere class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_)
|
||||
#define AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectSphere : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwSegment, m_dwTotalSegment;
|
||||
unsigned long m_dwSidePlane;
|
||||
unsigned long m_dwPrimitive, m_dwNumVertex;
|
||||
float m_fHeightFactor;
|
||||
float m_fRadius;
|
||||
|
||||
BOOL m_bUpperVis;
|
||||
BOOL m_bUpperUp;
|
||||
BOOL m_bUpperTex;
|
||||
float m_fUpperFactor;
|
||||
BOOL m_bLowerVis;
|
||||
BOOL m_bLowerUp;
|
||||
BOOL m_bLowerTex;
|
||||
float m_fLowerFactor;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
LPDIRECT3DINDEXBUFFER8 m_lpVerticeIndex;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstHeightFactor;
|
||||
CKeyList<FloatKeyList> m_lstRadius;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstUpperFactor;
|
||||
CKeyList<FloatKeyList> m_lstLowerFactor;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectSphere();
|
||||
virtual ~CX3DEffectSphere();
|
||||
|
||||
void SetSegment(unsigned long dwSegment) { m_dwSegment = dwSegment; }
|
||||
unsigned long GetSegment(void) { return m_dwSegment; }
|
||||
void SetSidePlane(unsigned long dwSidePlane) { m_dwSidePlane = dwSidePlane * 4; }
|
||||
unsigned long GetSidePlane(void) { return m_dwSidePlane; }
|
||||
|
||||
void SetUpperVis(BOOL bUpperVis) { m_bUpperVis = bUpperVis; }
|
||||
BOOL GetUpperVis(void) { return m_bUpperVis; }
|
||||
void SetUpperUp(BOOL bUpperUp) { m_bUpperUp = bUpperUp; }
|
||||
BOOL GetUpperUp(void) { return m_bUpperUp; }
|
||||
void SetUpperTex(BOOL bUpperTex) { m_bUpperTex = bUpperTex; }
|
||||
BOOL GetUpperTex(void) { return m_bUpperTex; }
|
||||
void SetLowerVis(BOOL bLowerVis) { m_bLowerVis = bLowerVis; }
|
||||
BOOL GetLowerVis(void) { return m_bLowerVis; }
|
||||
void SetLowerUp(BOOL bLowerUp) { m_bLowerUp = bLowerUp; }
|
||||
BOOL GetLowerUp(void) { return m_bLowerUp; }
|
||||
void SetLowerTex(BOOL bLowerTex) { m_bLowerTex = bLowerTex; }
|
||||
BOOL GetLowerTex(void) { return m_bLowerTex; }
|
||||
|
||||
void SetRadius(float fRadius) { m_fRadius = fRadius; }
|
||||
float GetRadius(void) { return m_fRadius; }
|
||||
void SetHeightFactor(float fHeightFactor) { m_fHeightFactor = fHeightFactor; }
|
||||
float GetHeightFactor(void) { return m_fHeightFactor; }
|
||||
void SetUpperFactor(float fUpperFactor) { m_fUpperFactor = fUpperFactor; }
|
||||
float GetUpperFactor(void) { return m_fUpperFactor; }
|
||||
void SetLowerFactor(float fLowerFactor) { m_fLowerFactor = fLowerFactor; }
|
||||
float GetLowerFactor(void) { return m_fLowerFactor; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer();
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_)
|
||||
Reference in New Issue
Block a user