#pragma once #include "K3DTypes.h" #include "KResource.h" //#include #include "KPrimitive.h" #include "KPrimitiveSpriteScroll.h" /// 2011.01.18 - prodongi class KViewportObject; class K3DRenderDevice; class KSpritePrimitive : public KPrimitive { public: KSpritePrimitive( bool bIsMng = true ); virtual ~KSpritePrimitive(); void Clear(); /// Set Clipping Area (Screen coordinate) void SetRenderEnable(bool bEnable); void SetClipRect( KRect *cliprect ); const KRect *GetClipRect() { return m_pClipRect;} void SetTransform( const K3DMatrix &transform ); void SetResVisibility( float vis ); void SetVisibility( float vis ); K3DVector GetPosition(); void SetPosition(const K3DVector& vPosition); void SetPosition(float fXPos, float fYPos, float fZPos); void SetAddPosition(float fXPos, float fYPos, float fZPos = 0.f); void SetZPosition(float fZPos); #ifdef _KUI_INVALIDATION // { [sonador] void SetRenderOffset( const K3DVector& vRenderOffset ); // } #endif /// Mirror Setting void SetMirror( bool h, bool v ) { m_bMirrorH = h; m_bMirrorV = v; } void SetCWRotation(bool r) { m_bCWRotation = r; } void SetCCWRotation(bool r) { m_bCCWRotation = r; } /// Set Sprite Resource. void SetRes( KResSprite *spr ); /// Rendering destination target size. void SetTargetSize( float width, float height ) { m_fTargetWidth = width; m_fTargetHeight = height; } void SetColor ( const KColor &color ) { m_colSprite = color;} void SetRenderValidate(bool bValidate) { m_bRenderValidate = bValidate; } /// Rendering source target rectangle. void SetSourceUVRect( float left, float top, float right, float bottom ) { m_fLeft = left; m_fTop = top; m_fRight = right; m_fBottom = bottom; } void SetSourceRect(const KRect& rcRect); void SetSourceRectRatio(float fLeft, float fTop, float fRight ,float fBottom); KResSprite *GetRes() { return m_spRes; } K3DMatrix &GetTransform() { return m_matTransform;} void SetDepthOrder(float fZorder) { m_fDepthOrder = fZorder; } float GetDepthOrder() { return m_fDepthOrder; } const KColor &GetColor() { return m_colSprite; } void GetSourceUVRect( float &left, float &top, float &right, float &bottom ) { left = m_fLeft; top = m_fTop; right = m_fRight; bottom = m_fBottom; } void GetTargetSize( float &width, float &height ) { width = m_fTargetWidth; height = m_fTargetHeight; } float GetTargetWidth() { return m_fTargetWidth; } float GetTargetHeight() { return m_fTargetHeight;} bool IsMirrorHori() { return m_bMirrorH; } bool IsMirrorVert() { return m_bMirrorV; } void SetAdditiveRenderMode( bool useAdditive ) { m_bUseAdditiveRender = useAdditive; } bool GetAdditiveRenderMode() { return m_bUseAdditiveRender; } virtual void Render( KViewportObject *viewport, class K3DRenderDevice *dev, bool bUseAccum = true ); void UpdateSprite(); void initScroll(bool is, DWORD type, float v, float margin); /// 2011.01.18 - prodongi void setScrollImgUv(int width, int height); /// 2011.02.23 - prodongi void DeviceLost(); /// 사용가능 한가? bool IsUse() { return m_bIsUse; } struct TEMPEXTVERTEX { TEMPEXTVERTEX() { w = 1.0f; } float x, y, z, w; KColor color; float u, v; }; KSpritePrimitive::TEMPEXTVERTEX* GetVertex(int _id) { return &m_VtxBuf[_id]; } /// 2011.03.23 - servantes sSpritePrimitiveScroll* GetScrollBrother() { return &m_scroll; } /// 2011.03.23 - servantes sSpritePrimitiveScrollType* GetScroll() { return m_scroll.m_type; } /// 2011.03.23 - servantes protected: bool m_bIsUse; bool m_bIsMng; ///< Device Lost 관리 KRect* m_pClipRect; K3DMatrix m_matTransform; #ifdef _KUI_INVALIDATION // { [sonador] K3DVector m_vRenderOffset; //GetOffset().x : 0 ); m_matTransform._42 += (m_spRes ? m_spRes->GetOffset().y : 0 ); m_bModify = true; } inline void KSpritePrimitive::SetPosition(float fXPos, float fYPos, float fZPos) { m_matTransform._41 = fXPos + (m_spRes ? m_spRes->GetOffset().x : 0 ); m_matTransform._42 = fYPos + (m_spRes ? m_spRes->GetOffset().y : 0 ); m_matTransform._43 = fZPos; m_bModify = true; } inline void KSpritePrimitive::SetAddPosition(float fXPos, float fYPos, float fZPos) { m_matTransform._41 += fXPos; m_matTransform._42 += fYPos; m_matTransform._43 += fZPos; m_bModify = true; }