223 lines
6.9 KiB
C++
223 lines
6.9 KiB
C++
/*
|
|
SGameFxSwordSlash.h
|
|
검광 표시 Fx
|
|
|
|
Created 2006/04, by JiYoung
|
|
*/
|
|
|
|
#ifndef __SGAMEFXSWORDSLASH_H__
|
|
#define __SGAMEFXSWORDSLASH_H__
|
|
|
|
#include "KResourceDXDynamic.h"
|
|
#include <deque>
|
|
|
|
#include "KSeqModel.h"
|
|
#include "KPrimitiveMesh.h"
|
|
|
|
struct TrailNode {
|
|
K3DMatrix matrix; ///< Transform matrix, relative to world
|
|
K3DVector base; ///< [0,0,0] * matrix
|
|
K3DVector top; ///< far_end_point * matrix
|
|
DWORD time; ///< Rendered time
|
|
};
|
|
|
|
|
|
class TrailPrimitive : public KMeshPrimitive
|
|
{
|
|
public:
|
|
TrailPrimitive(int maxTrails=0);
|
|
virtual ~TrailPrimitive();
|
|
|
|
virtual void init(int maxTrails);
|
|
virtual void close();
|
|
|
|
virtual void Render( KViewportObject *viewport, class K3DRenderDevice *dev, bool bUseAccum = true );
|
|
|
|
//
|
|
// Display control
|
|
//
|
|
/** true면 addTrail()됨에 따라 trail을 새로 추가한다
|
|
false면 기존의 trail이 사라지기만 하고 새로 추가되지는 않는다 */
|
|
void runTrail(bool bOn);
|
|
bool isTrailRunning() { return trailRunning; }
|
|
void SetUseRight( bool bRight ) { m_bRight = bRight; }
|
|
|
|
|
|
//
|
|
// Add trail positions
|
|
//
|
|
/** Note : addTrails(count, ... , ... , NULL) == purgeTrails(count)
|
|
내부적으로 endTrail()상태면 purgeTrails(count)와 같다 */
|
|
void addTrails(
|
|
int count, ///< matrix[]의 갯수
|
|
DWORD starttime, ///< matrix[0]이 realize된 시간. (가장 과거)
|
|
DWORD endtime, ///< matrix[count-1]이 realize된 시간. (가장 최근)
|
|
K3DMatrix *matrix, ///< base transform matrix. "matrix[count]"
|
|
bool isBow, // 활인가?
|
|
float angle // 캐릭터 angle
|
|
);
|
|
|
|
/// trail buffer에 들어있는 position을 과거부터 count개 삭제
|
|
void purgeTrails(int count);
|
|
/// buffer를 완전 삭제
|
|
void clearTrails();
|
|
|
|
|
|
//
|
|
// Trail 파라미터들
|
|
//
|
|
/// Display되는 trail의 node갯수 (segment갯수-1)
|
|
void setTrailNodeCount(int count);
|
|
int getTrailNodeCount() { return trailCount; }
|
|
|
|
/// 검광 폭. base와 top간의 거리. 새로 add되는 trail에 대해서만 유효
|
|
void setTrailWidth(float width) { trailWidth=width; }
|
|
float getTrailWidth() { return trailWidth; }
|
|
|
|
|
|
enum {
|
|
NODE_NEWEST_BOTTOM=0 ///< 검광 폴리곤상 가장 최근 노드의 뿌리 부분. 손 위치
|
|
, NODE_NEWEST_TOP ///< 가장 최근 노드의 꼭지 부분. 칼 끝 위치
|
|
, NODE_OLDEST_BOTTOM ///< 가장 과거 노드의 뿌리 부분
|
|
, NODE_OLDEST_TOP ///< 가장 과거 노드의 꼭지 부분
|
|
, NODE_MAX
|
|
};
|
|
void setTrailNodeColor(int nodeNumber ///< node번호. NODE_START_xxxx 나 NODE_END_xxxx
|
|
, DWORD _color0, DWORD _color1 ///< 화면표시색 = (텍스처 * color0) + color1
|
|
, float _u, float _v ///< 텍스처 좌표
|
|
);
|
|
void getTriailNodeColor(int nodeNumber
|
|
, DWORD *_color0, DWORD *_color1 ///< Pointers can be NULL
|
|
, float *_u, float *_v
|
|
);
|
|
|
|
void setTrailTexture(const char *texName);
|
|
void setTrailTexture(K3DTexture *texture);
|
|
|
|
|
|
/** Trail parameter를 통째로 받아서 세팅
|
|
검광 파라미터를 text string으로 받아서 parsing, 세팅한다
|
|
WeaponTrailProcessConsoleCommand()의 셋업 파일을 그대로 넣으면 된다 */
|
|
bool setupTrailByConfigurationText(const char *config);
|
|
|
|
|
|
void processConsoleCommand(std::string &key, int argc, std::vector<std::string> &argv, char *outputBuffer);
|
|
|
|
|
|
|
|
protected:
|
|
//
|
|
// Internal functions
|
|
//
|
|
bool createBuffers(); ///< called by init() to create proper indexBuffer / vertexBuffer / triangleCount
|
|
void initPolygon(); ///< color, uv, count등이 변경되었을 때 vertex buffer/index buffer를 rebuild한다
|
|
|
|
bool buildPolygon(); ///< 매 렌더링시마다 trails로부터 폴리곤 만들기. 폴리곤 0개이면 false
|
|
|
|
//
|
|
// Variables
|
|
//
|
|
KIndexBufferDX_dynamic *indexBuffer; ///< Actual index buffer
|
|
KVertexBufferDX_dynamic *vertexBuffer; ///< Actual vertex buffer
|
|
|
|
int vertexCount;
|
|
int indexCount;
|
|
int polygonCount; ///< copied to m_nPrimitivesCount
|
|
|
|
int maxTrailCount; ///< indexBuffer/vertexBuffer상 최대 trail길이
|
|
|
|
bool trailRunning; ///< beginTrail() ~ endTrail()사이일때 true
|
|
int trailCount; ///< Display할 최대 trail길이 ( <= maxTrailCount )
|
|
|
|
|
|
std::deque<TrailNode> trails;
|
|
|
|
float trailWidth; ///< trail폭
|
|
|
|
DWORD color0[NODE_MAX], color1[NODE_MAX]; ///< 각 node의 color & uv
|
|
float u[NODE_MAX], v[NODE_MAX];
|
|
|
|
bool rebuildPolygon; ///< Color, UV, 기타등등이 변경되었을 때 vertex/index를 싹 다시 계산한다
|
|
|
|
bool m_bRight;
|
|
|
|
//-----------------------------
|
|
// Console용 local틱한 함수들
|
|
//-----------------------------
|
|
void twprintNode(char *buffer, int nodeNo);
|
|
void twprintSize(char *buffer);
|
|
void twprint(char *buffer);
|
|
bool TrailPrimitive::twParseCommands(char *buffer);
|
|
void TrailPrimitive::twWriteCommands(char *buffer);
|
|
bool TrailPrimitive::twLoadCommands(const char *filename);
|
|
bool TrailPrimitive::twSaveCommand(const char *filename);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SGameFxSwordSlash : public KSeqModel { // KSeqForm { // KSeqForm :: hierarchical mesh and animation holder
|
|
public:
|
|
SGameFxSwordSlash( bool bRight );
|
|
virtual ~SGameFxSwordSlash();
|
|
|
|
//
|
|
// Inherits
|
|
//
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
|
|
//
|
|
// Original
|
|
//
|
|
TrailPrimitive *getTrailPrimitive() { return primitive; }
|
|
|
|
|
|
|
|
|
|
//
|
|
// primitive->...()를 그냥 call하는 함수들
|
|
// : 그냥 multiple상속 받고파 -_-
|
|
// 농땡이 : get...()계열 함수가 필요하면 getTrailPrimitive()->get...()해서 직접 부를 것 -_-
|
|
//
|
|
/** true면 addTrail()됨에 따라 trail을 새로 추가한다
|
|
false면 기존의 trail이 사라지기만 하고 새로 추가되지는 않는다 */
|
|
void runTrail(bool bOn);
|
|
|
|
bool IsRunTrail();
|
|
|
|
void setTrailWidth(float _width); ///< Trail의 길이
|
|
void setTrailNodeCount(int count); ///< Trail의 node갯수 (segment갯수-1). 길이
|
|
|
|
void setTrailNodeColor(int nodeNumber ///< node번호. TrailPrimitive::NODE_START_xxxx 나 TrailPrimitive::NODE_END_xxxx
|
|
, int nIndex, DWORD color ///< 화면표시색 = (텍스처 * color0) + color1
|
|
);
|
|
|
|
void getTriailNodeColor(int nodeNumber
|
|
, DWORD *_color0, DWORD *_color1 ///< Pointers can be NULL
|
|
, float *_u, float *_v
|
|
);
|
|
|
|
void setTrailTexture(const char *texName);
|
|
|
|
void addTrails(int count, DWORD starttime, DWORD endtime, K3DMatrix *matrix, bool isBow = FALSE, float angle = 0.0f);
|
|
void purgeTrails(int count); ///< primitive->purgeTrails() call
|
|
void clearTrails(); ///< primitive->clearTrails()를 그냥 call
|
|
|
|
/** 검광 파라미터를 text string으로 받아서 parsing, 세팅한다
|
|
WeaponTrailProcessConsoleCommand()의 셋업 파일을 그대로 넣으면 된다
|
|
primitive->setupTrailByConfigurationText()을 그냥 부른다 */
|
|
bool setupTrailByConfigurationText(const char *config);
|
|
|
|
|
|
protected:
|
|
TrailPrimitive *primitive;
|
|
|
|
bool m_bRight;
|
|
};
|
|
|
|
|
|
/// 콘솔에서 파라미터 받아서 처리용
|
|
char *WeaponTrailProcessConsoleCommand(std::string &key, int argc, std::vector<std::string> &argv);
|
|
|
|
#endif // __SGAMEFXSWORDSLASH_H__
|