#pragma once #include "KPrimitive.h" #include class SSpeedTreePrimitive : public K3DPrimitive { public : enum { TREE_BRANCH = 0, TREE_FROND, TREE_LEAF, TREE_BILLBOARD }; SSpeedTreePrimitive(); ~SSpeedTreePrimitive(); void Clear(); inline bool IsValid() { //if(m_nType == TREE_BILLBOARD) return true; // 임시 코드 if(m_nType == TREE_BILLBOARD) { if(m_nSubCount > 0) return true; else return false; } if( m_ppVB == NULL ) return false; if( m_bIsValid == false ) return false; return (NULL != m_ppVB[0]); } void SetSubMeshCount( int count ); void SetTextureCount( int count ); inline void SetRenderState( int renderstate ) { m_nRenderState = renderstate; } inline void SetIndexBuffer( int index, K3DIndexBuffer *buf ) { if( m_nSubCount <= 0 ) return; if( index >= m_nSubCount || index < 0 ) return; m_ppIB[index] = buf; } inline void SetVertexBuffer( int index, K3DVertexBuffer *buf, int nType, unsigned int nVtxCount, unsigned short* m_pIndexCounts ) { if( m_nSubCount <= 0 ) return; if( index >= m_nSubCount || index < 0 ) return; m_nType = nType; if( m_nType == TREE_BRANCH ) m_pBranchIndexCounts = m_pIndexCounts; else if( m_nType == TREE_FROND ) m_pFrondIndexCounts = m_pIndexCounts; m_unVertexCount = nVtxCount; m_ppVB[index] = buf; } inline void SetMaterial( int index, K3DMaterial *mtl ) { if( m_nSubCount <= 0 ) return; if( index >= m_nSubCount || index < 0 ) return; m_ppMtl[index] = mtl; } inline void SetTexture( int index, K3DTexture *tex ) { if( index >= m_nTexCount || m_nTexCount < 0 ) return; m_nTexActiveCount = index+1; m_ppTex[index] = tex; } inline void SetShaderTable( DWORD dwRegister, const float* pTable, DWORD dwCount ) { m_registerTable = dwRegister; m_cntTable = dwCount; m_pTable = pTable; } inline void SetShaderVecConstant( DWORD dwRegister, const float* pvecConstant, DWORD dwCount ) { m_registerVecConstant = dwRegister; m_cntVecConstant = dwCount; m_pvecConstant = pvecConstant; } inline void SetShaderUsefulConstant( DWORD dwRegister, const float* pafUsefulConstants, DWORD dwCount ) { m_registerUsefulConstants = dwRegister; m_cntUsefulConstants = dwCount; m_pafUsefulConstants = pafUsefulConstants; } inline void SetShaderMaterial( DWORD dwRegister, const float* pafMaterial, DWORD dwCount ) { m_registerMaterial = dwRegister; m_cntMaterial = dwCount; m_pafMaterial = pafMaterial; } inline void SetSpeedTree( CSpeedTreeRT* pSpeedTree ) { m_pSpeedTree = pSpeedTree; } inline void SetGeometry( CSpeedTreeRT::SGeometry* pGeometry ) { m_pGeometryCache = pGeometry; } inline void SetValid( bool bValid ) { m_bIsValid = bValid; } /// Render to viewport. virtual void Render( KViewportObject *viewport, class K3DRenderDevice *dev, bool bUseAccum = true ); // True when transparent-render mode (nearer than player character) static void setTransparentRenderMode(bool bTransparent); static bool getTransparentRenderMode(); protected: int m_nSubCount; int m_nTexCount; int m_nTexActiveCount; K3DIndexBuffer** m_ppIB; K3DVertexBuffer** m_ppVB; K3DTexture** m_ppTex; K3DMaterial** m_ppMtl; int m_nRenderState; // geometry cache CSpeedTreeRT::SGeometry* m_pGeometryCache; ///< geometry cache CSpeedTreeRT* m_pSpeedTree; ///< SpeedTree object int m_nType; unsigned int m_unVertexCount; unsigned short* m_pBranchIndexCounts; ///< number of indexes per branch LOD level unsigned short* m_pFrondIndexCounts; ///< number of indexes per frond LOD level bool m_bLeavesUpdatedByCpu; bool m_bIsValid; //Speed Tree Shader DWORD m_registerTable; DWORD m_cntTable; const float* m_pTable; DWORD m_registerVecConstant; DWORD m_cntVecConstant; const float* m_pvecConstant; DWORD m_registerUsefulConstants; DWORD m_cntUsefulConstants; const float* m_pafUsefulConstants; DWORD m_registerMaterial; DWORD m_cntMaterial; const float* m_pafMaterial; };