Files
2026-06-01 12:46:52 +02:00

265 lines
4.6 KiB
C++

#ifndef __KPRIMITIVE__
#define __KPRIMITIVE__
#include "K3Dtypes.h"
#include "KResource.h"
//#include "KRenderDevice.h"
//#include <vector>
class KViewportObject;
/// Prototype primitive class
class KPrimitive
{
public:
KPrimitive(void);
virtual ~KPrimitive(void);
enum
{
KPRIMITIVE_3DOBJ,
KPRIMITIVE_2DOBJ,
KPRIMITIVE_FXPARTICLE,
KPRIMITIVE_BILLBOARD,
KPRIMITIVE_FXBILLBOARD,
KPRIMITIVE_FXAFTERIMAGE,
KPRIMITIVE_SHADOWVOLUME,
KPRIMITIVE_MESH,
KPRIMITIVE_WIREUTIL,
KPRIMITIVE_SSPEEDTREE,
KPRIMITIVE_SPRITE,
KPRIMITIVE_ENV,
KPRIMITIVE_TERRAIN,
KPRIMITIVE_LOADINGSCREEN,
KPRIMITIVE_QUAD,
KPRIMITIVE_LINE,
};
int GetType()
{
return m_type;
}
//virtual void Succeed( KPrimitive *prev ) = 0;
virtual bool IsValid();
virtual void Render( KViewportObject *viewport, class K3DRenderDevice *dev, bool bUseAccum = true ) = 0;
protected:
int m_type;
};
/// 3D Prototype primitive class
class K3DPrimitive : public KPrimitive
{
public:
K3DPrimitive()
{
m_type = KPRIMITIVE_3DOBJ;
m_nLightIndex = 0;
m_nBlendMode = K3DMaterial::MBM_DEFAULT;
m_bIsTrans = false;
m_bIsVS = false;
m_bIsSpecular = false;
m_bIsBump = false;
m_bDiffuseAlpha = false;
m_bIsPos = false;
m_bUseLightMap = false;
m_bUseFix = false;
m_bIsEffectMat = false;
m_pTransform = NULL;
K3DMatrixIdentity( m_RootMat );
m_pEffectMat = NULL;
m_fVisibility = 1.f;
SetOcclusioCull(false);
m_bIsMTE = false; //MTE
}
virtual ~K3DPrimitive()
{
}
void SetLightIndex( char nLightIndex )
{
m_nLightIndex = nLightIndex;
}
char GetLightIndex()
{
return m_nLightIndex;
}
bool IsTransparent()
{
return m_bIsTrans;
}
void SetTransparent( bool trans )
{
m_bIsTrans = trans;
}
bool IsDiffuseAlpha()
{
return m_bDiffuseAlpha;
}
void SetDiffuseAlpha( bool trans )
{
m_bDiffuseAlpha = trans;
}
void SetBlendMode( int blendmode )
{
m_nBlendMode = blendmode;
}
int GetBlendMode()
{
return m_nBlendMode;
}
void SetVSMode( bool bVSMode )
{
m_bIsVS = bVSMode;
}
bool GetVSMode()
{
return m_bIsVS;
}
void SetSpecular( bool bSpecular )
{
m_bIsSpecular = bSpecular;
}
bool IsSpecular()
{
return m_bIsSpecular;
}
void SetBump( bool bBump )
{
m_bIsBump = bBump;
}
bool IsBump()
{
return m_bIsBump;
}
void SetUseLightMap(bool bUseLightMap)
{
m_bUseLightMap = bUseLightMap;
}
bool IsUseLightMap()
{
return m_bUseLightMap;
}
void SetUseFixMap(bool bUseFixMap)
{
m_bUseFix = bUseFixMap;
}
bool IsUseFixMap()
{
return m_bUseFix;
}
bool IsPosition()
{
return m_bIsPos;
}
void SetTransform( K3DMatrix *pLocalMat, K3DMatrix * pRootMat )
{
m_pTransform = pLocalMat;
m_RootMat = *pRootMat;
m_bIsPos = true;
}
void SetRootMat( K3DMatrix * pRootMat )
{
m_RootMat = *pRootMat;
}
void SetEffectTransform( K3DMatrix *pEffectMat )
{
m_pEffectMat = pEffectMat;
m_bIsEffectMat = true;
}
K3DMatrix * GetRootMat()
{
return &m_RootMat;
}
K3DMatrix * GetTransform()
{
return m_pTransform;
}
void SetCenterPosition(const K3DVector &pos)
{
m_vCenterPosition = pos;
}
const K3DVector & GetCenterPosition()
{
return m_vCenterPosition;
}
virtual DWORD GetMagicNumber()
{
return 0;
}
virtual void ResetReleatedMesh()
{
}
virtual bool AddRelatedMesh(K3DPrimitive *p)
{
return false;
}
void SetVisibility( float vis )
{
m_fVisibility = vis;
}
float GetVisibility()
{
return m_fVisibility;
}
void SetEnableMTE( bool bEnable ) { m_bIsMTE = bEnable; }
bool GetEnableMTE( ) { return m_bIsMTE; }
void SetOcclusioCull( bool bCull ) { m_bIsOcclusioCulled = bCull; }
bool IsOcclusioCulled() const { return m_bIsOcclusioCulled; }
virtual bool SupportsBoundOcclusion() { return false; }
virtual void RenderBoundOcclusion( KViewportObject* pViewport, K3DRenderDevice* pDev ) {}
protected:
char m_nLightIndex; ///< 사용할 라이트 인덱스
bool m_bIsTrans; ///< 투명인가?
int m_nBlendMode; //
bool m_bIsVS; ///< 쉐이더 사용 여부
bool m_bIsSpecular; ///< 스페큘러 사용 여부
bool m_bIsBump;
bool m_bUseLightMap;
bool m_bUseFix; ///< 임의 고정 텍스트 사용 여부
bool m_bDiffuseAlpha;///< Diffuse 를 사용한 반투명인가?
// for depth sort and Get Use Light Index
bool m_bIsPos; ///< 위치 값이 설정 되어 있는가?
K3DMatrix* m_pTransform; ///< Local
K3DMatrix m_RootMat; ///< Root
K3DMatrix* m_pEffectMat;
bool m_bIsEffectMat;
K3DVector m_vCenterPosition;
float m_fVisibility;
bool m_bIsOcclusioCulled;
bool m_bIsMTE; //MTE
};
#endif