440 lines
9.8 KiB
C++
440 lines
9.8 KiB
C++
|
|
#pragma once
|
|
|
|
#include "KObject.h"
|
|
#include "KPrimitiveMesh.h"
|
|
#include "KPrimitiveSprite.h"
|
|
#include "KPrimitiveFXParticle.h"
|
|
#include "K3DBound.h"
|
|
#include "KRenderObject.h"
|
|
#include "KSmartPtr.h"
|
|
|
|
class KViewportObject;
|
|
class K3DRenderDeviceDX;
|
|
//class K3DFrustum;
|
|
|
|
|
|
/// "REQ_INTERSECTIONLINE"
|
|
class KMsgREQ_INTERLINE : public KArg
|
|
{
|
|
public:
|
|
KMsgREQ_INTERLINE( KViewportObject *vp, int sx, int sy ) : pViewport(vp), nScrx(sx), nScry(sy) {}
|
|
|
|
/// result
|
|
K3DVertex vNear;
|
|
K3DVertex vFar;
|
|
/// argument
|
|
KViewportObject *pViewport;
|
|
int nScrx;
|
|
int nScry;
|
|
};
|
|
|
|
/// "SET_CAMERARENDER"
|
|
class KMsgSET_CAMERARENDER : public KArg
|
|
{
|
|
public:
|
|
KMsgSET_CAMERARENDER() : bRenderFlag(FALSE) {}
|
|
BOOL bRenderFlag;
|
|
};
|
|
|
|
/// "GET_CAMERASEQ"
|
|
class KMsgGET_CAMERASEQ : public KArg
|
|
{
|
|
public:
|
|
KMsgGET_CAMERASEQ() : pCamSeq(NULL) {}
|
|
class KCameraSeq* pCamSeq;
|
|
};
|
|
|
|
|
|
|
|
DECL_SPTR(K3DResCamera)
|
|
class K3DCamera;
|
|
class KCameraSeq : public KSeqObject
|
|
{
|
|
public:
|
|
KCameraSeq();
|
|
virtual ~KCameraSeq();
|
|
|
|
void SetRes( K3DResCamera *res );
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual void *Perform( KID id, KArg& msg );
|
|
|
|
virtual KSeqObject* Clone();
|
|
protected:
|
|
virtual void realizeTime();
|
|
protected:
|
|
float m_fFOV;
|
|
K3DMatrix m_matView;
|
|
K3DVector m_vCamPos;
|
|
K3DResCameraSPtr m_spRes;
|
|
|
|
K3DCamera* m_ViewCamera;
|
|
};
|
|
|
|
/// "REQ_LIGHT"
|
|
class KMsgREQ_LIGHT : public KArg
|
|
{
|
|
public:
|
|
KMsgREQ_LIGHT() {}
|
|
~KMsgREQ_LIGHT() { m_pLightList.clear(); }
|
|
|
|
std::vector<K3DLight*> m_pLightList; ///< result
|
|
};
|
|
|
|
DECL_SPTR(K3DResLight)
|
|
class KLightSeq : public KSeqObject
|
|
{
|
|
public:
|
|
KLightSeq();
|
|
virtual ~KLightSeq();
|
|
|
|
void SetRes( K3DResLight *res );
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual void *Perform( KID id, KArg& msg );
|
|
|
|
virtual KSeqObject* Clone();
|
|
virtual void realizeTime();
|
|
protected:
|
|
K3DLight m_Light;
|
|
K3DResLightSPtr m_spRes;
|
|
};
|
|
|
|
|
|
/// "SET_RENDER_SIZE"
|
|
class KMsgSET_RENDER_SIZE : public KArg
|
|
{
|
|
public:
|
|
KMsgSET_RENDER_SIZE( KSize _sizeR ) : sizeRender(_sizeR) {}
|
|
KSize sizeRender;
|
|
};
|
|
DECL_SPTR(KResSpriteAnimation)
|
|
class KSpriteSeq : public KSeqObject
|
|
{
|
|
public:
|
|
KSpriteSeq();
|
|
virtual ~KSpriteSeq();
|
|
|
|
LPCSTR GetSeqName();
|
|
|
|
void SetRes( KResSpriteAnimation *res );
|
|
KResSpriteAnimation* GetRes();
|
|
|
|
int GetFrameCount();
|
|
KResSprite *GetFrame( int nFrame );
|
|
int GetCurrentIndex();
|
|
KResSprite *GetCurrentFrame();
|
|
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual void *Perform( KID id, KArg& msg );
|
|
|
|
virtual KSeqObject* Clone();
|
|
virtual void realizeTime();
|
|
protected:
|
|
K3DMatrix m_matLocal;
|
|
K3DMatrix m_matResult;
|
|
|
|
std::string m_sSeqName;
|
|
KResSpriteAnimationSPtr m_spRes;
|
|
KSpritePrimitive m_prSprite;
|
|
KSize m_sizeRender;
|
|
};
|
|
|
|
|
|
|
|
class KEventSeq : public KSeqObject
|
|
{
|
|
public:
|
|
enum {
|
|
KEVTYPE_INVALID,
|
|
KEVTYPE_BOX,
|
|
KEVTYPE_POINT,
|
|
};
|
|
KEventSeq() { m_nType = KEVTYPE_INVALID; }
|
|
virtual ~KEventSeq() {}
|
|
int GetEventType() { return m_nType; }
|
|
protected:
|
|
int m_nType;
|
|
};
|
|
|
|
DECL_SPTR(K3DResEventBox)
|
|
class KEventBoxSeq : public KEventSeq
|
|
{
|
|
public:
|
|
KEventBoxSeq();
|
|
virtual ~KEventBoxSeq();
|
|
const char *GetName();
|
|
void SetRes( K3DResEventBox *res );
|
|
const K3DBoundRotCube &GetCube();
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual KSeqObject *Clone();
|
|
virtual void *Perform( KID id, KArg& msg );
|
|
virtual void realizeTime();
|
|
|
|
virtual void SetParentTransform( const K3DMatrix *pMatParent, const K3DMatrix *pMatAttach = NULL, BOOL bRotationLock = FALSE );
|
|
|
|
protected:
|
|
K3DBoundRotCube m_bCube;
|
|
K3DResEventBoxSPtr m_spRes;
|
|
};
|
|
/// "REQ_EVBOX"
|
|
class KMsgREQ_EVBOX : public KArg
|
|
{
|
|
public:
|
|
void AddBox( KEventBoxSeq *pSeqBox )
|
|
{
|
|
m_vecSeq.push_back( pSeqBox );
|
|
}
|
|
KEventBoxSeq *GetBox( int index )
|
|
{
|
|
return m_vecSeq[index];
|
|
}
|
|
int GetBoxCount()
|
|
{
|
|
return static_cast<int>(m_vecSeq.size());
|
|
}
|
|
protected:
|
|
std::vector<KEventBoxSeq*> m_vecSeq;
|
|
};
|
|
|
|
DECL_SPTR(K3DResEventPoint)
|
|
class KEventPointSeq : public KEventSeq
|
|
{
|
|
public:
|
|
KEventPointSeq();
|
|
virtual ~KEventPointSeq();
|
|
const char *GetName();
|
|
void SetRes( K3DResEventPoint *res );
|
|
const K3DMatrix &GetPoint();
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual KSeqObject *Clone();
|
|
virtual void *Perform( KID id, KArg& msg );
|
|
virtual void realizeTime();
|
|
K3DMatrix * GetTransform() { return &m_matPoint; }
|
|
|
|
static void SetToggleEffectPos() { m_sIsRender = !m_sIsRender; }
|
|
|
|
protected:
|
|
K3DMatrix m_matPoint; //
|
|
K3DResEventPointSPtr m_spRes;
|
|
static bool m_sIsRender;
|
|
K3DBoundRotCube m_bCube;
|
|
|
|
// KWireUtilPrimitive m_prAxisWire01;
|
|
KWireUtilPrimitive m_prAxisWire02;
|
|
};
|
|
/// "REQ_EVPOINT"
|
|
class KMsgREQ_EVPOINT : public KArg
|
|
{
|
|
public:
|
|
void AddPoint( KEventPointSeq *pSeqPoint )
|
|
{
|
|
m_vecSeq.push_back( pSeqPoint );
|
|
}
|
|
KEventPointSeq *GetPoint( int index )
|
|
{
|
|
return m_vecSeq[index];
|
|
}
|
|
int GetPointCount()
|
|
{
|
|
return static_cast<int>(m_vecSeq.size());
|
|
}
|
|
protected:
|
|
std::vector<KEventPointSeq*> m_vecSeq;
|
|
};
|
|
|
|
|
|
class KFXSeq : public KSeqObject
|
|
{
|
|
public:
|
|
enum {
|
|
KFXTYPE_INVALID,
|
|
KFXTYPE_BILLBOARD,
|
|
KFXTYPE_PARTICLE,
|
|
KFXTYPE_AFTERIMAGE,
|
|
};
|
|
KFXSeq() { m_nType = KFXTYPE_INVALID; m_fVisResult = 1.0f;}
|
|
virtual ~KFXSeq() {}
|
|
int GetFXType() { return m_nType; }
|
|
|
|
protected:
|
|
void GetUVAniRect( int nCurFrame, int nFrameCount );
|
|
protected:
|
|
float m_fLeft, m_fTop, m_fRight, m_fBottom;
|
|
float m_fTLeft, m_fTTop, m_fTRight, m_fTBottom;
|
|
float m_fVisResult;
|
|
int m_nType;
|
|
|
|
};
|
|
|
|
DECL_SPTR(KResFXBillboard)
|
|
class KFXBillboardSeq : public KFXSeq
|
|
{
|
|
public:
|
|
KFXBillboardSeq();
|
|
virtual ~KFXBillboardSeq();
|
|
|
|
void SetRes( KResFXBillboard *res );
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual KSeqObject *Clone();
|
|
virtual void realizeTime();
|
|
virtual void *Perform( KID id, KArg& msg );
|
|
void SetCube( float minx, float maxx, float miny, float maxy, float minz, float maxz );
|
|
|
|
static void SetToggleVisbleCube() { m_sVisbleCube = !m_sVisbleCube; }
|
|
|
|
protected:
|
|
K3DMatrix m_matTransform;
|
|
KResFXBillboardSPtr m_spRes;
|
|
KFXBillboardPrimitive m_prBillboard;
|
|
|
|
static bool m_sVisbleCube;
|
|
|
|
K3DBoundRotCube m_boundCube;
|
|
KWireUtilPrimitive m_prCenterWire;
|
|
};
|
|
|
|
class KFXParticleObject;
|
|
class KFXGravityParticleObject;
|
|
class KFXReverseParticleObject;
|
|
|
|
DECL_SPTR(KResFXParticle)
|
|
class KFXParticleSeq : public KFXSeq
|
|
{
|
|
public:
|
|
KFXParticleSeq(DWORD dwParticleType);
|
|
virtual ~KFXParticleSeq();
|
|
|
|
void SetRes( KResFXParticle *res );
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual KSeqObject *Clone();
|
|
virtual void realizeTime();
|
|
virtual void *Perform( KID id, KArg& msg );
|
|
enum PARTILE_TYPE
|
|
{
|
|
KPARTICLE_DEFAULT = 0,
|
|
KPARTICLE_GRAVITY,
|
|
KPARTICLE_REVERSE,
|
|
};
|
|
private:
|
|
void _CreateParticle( int index, int timeUnit );
|
|
void _Initialize();
|
|
float _GetRandom( float min, float variation );
|
|
void _GenerateObject();
|
|
void _ClearObject();
|
|
|
|
private:
|
|
float m_fRadius;
|
|
DWORD m_dwParticleType;
|
|
DWORD m_dwMyTime;
|
|
DWORD m_dwOldTime;
|
|
DWORD m_dwOldCreateTime;
|
|
bool m_bInited;
|
|
K3DVector m_vecVector;
|
|
K3DVector m_vecVelocity;
|
|
K3DMatrix m_matTransform;
|
|
KResFXParticleSPtr m_spRes;
|
|
KFXParticlePrimitive m_prParticle;
|
|
int m_nParticleCount;
|
|
KFXParticleObject** m_ppParticles;
|
|
};
|
|
|
|
|
|
/// "AFTER_IMAGE_MOVE = 'KAIM';
|
|
class KMsgAfterImage_MOVE : public KArg
|
|
{
|
|
public:
|
|
void SetMoveAdded(const K3DVertex & vMoveAdded)
|
|
{
|
|
m_vMoveAdded = vMoveAdded;
|
|
}
|
|
const K3DVertex & GetMoveAdded() const
|
|
{
|
|
return m_vMoveAdded;
|
|
}
|
|
protected:
|
|
K3DVector m_vMoveAdded;
|
|
};
|
|
|
|
DECL_SPTR(KResFXAfterImage)
|
|
class KFXAfterImageSeq : public KFXSeq
|
|
{
|
|
public:
|
|
KFXAfterImageSeq();
|
|
virtual ~KFXAfterImageSeq();
|
|
|
|
void SetRes( KResFXAfterImage *res );
|
|
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual void* Perform( int id, KArg& msg);
|
|
virtual KSeqObject *Clone();
|
|
virtual void realizeTime();
|
|
private:
|
|
void _MakeLerpMatrix(DWORD dwAddFrame, int nInterval);
|
|
void _PushNormalLine(int nInterval);
|
|
void _PushSpline(DWORD dwAddFrames);
|
|
|
|
|
|
private:
|
|
bool m_bOldValidate;
|
|
DWORD m_dwLastSplinePushCount;
|
|
DWORD m_dwLastNormalLineCount;
|
|
|
|
K3DMatrix m_matRoot;
|
|
K3DMatrix m_matLocal;
|
|
|
|
K3DMatrix m_matOld;
|
|
KResFXAfterImageSPtr m_spRes;
|
|
int m_nFrameTime;
|
|
int m_nFrameNumber;
|
|
K3DMatrix* m_pMatLerp;
|
|
|
|
DWORD m_dwVertexCount;
|
|
K3DVertex* m_pVertexListOne;
|
|
K3DVertex* m_pVertexListTwo;
|
|
|
|
KFXAfterImagePrimitive m_prAfterImage;
|
|
DWORD m_dwOldTime;
|
|
};
|
|
|
|
|
|
|
|
class K3DCamera;
|
|
class KSeqTextureRender : public KSeqObject
|
|
{
|
|
public:
|
|
KSeqTextureRender();
|
|
virtual ~KSeqTextureRender();
|
|
|
|
enum
|
|
{
|
|
KSEQ_RENDER_ALL,
|
|
KSEQ_RENDER_60,
|
|
KSEQ_RENDER_30,
|
|
KSEQ_RENDER_ONCE,
|
|
};
|
|
|
|
void Initialize( KSeqObject *src, const KSize &targetSize, const K3DFORMAT &texformat = K3DFMT_A1R5G5B5);
|
|
KSeqObject* GetSource() { return m_pSeqSource;}
|
|
void SetUserCamera( K3DCamera *pCam );
|
|
void AddUserLight( K3DLight * pLight);
|
|
void SetViewportInfo( float fov, float nearClip, float farClip );
|
|
void SetRenderFreq(DWORD dwRenderFreq);
|
|
void SetAddictive(bool bUseAddictive);
|
|
virtual void Render( KViewportObject *viewport, DWORD flag = RENDEREFX_NONE, const K3DMatrix * pAttachMat = NULL );
|
|
virtual KSeqObject* Clone();
|
|
virtual void realizeTime();
|
|
protected:
|
|
bool m_bSourceRenderFlag;
|
|
DWORD m_dwRenderFrameTime;
|
|
KSize m_sizeTarget;
|
|
K3DFORMAT m_formatTarget;
|
|
K3DMatrix m_matLocal;
|
|
K3DMatrix m_matResult;
|
|
KViewportObject* m_pViewport;
|
|
K3DCamera* m_pCamera;
|
|
KSeqObject* m_pSeqSource;
|
|
K3DRenderTarget* m_pRenderTarget;
|
|
KSpritePrimitive m_prSprite;
|
|
std::vector<K3DLight *> m_vtUserLight;
|
|
};
|