/* A drawregion takes given 3D coords and make dirty regions which fits the final 2D viewport. */ class CDrawRegion { public: /* AddRegion will translate given box into screen coordinates which rendering can use as a viewport. */ void AddRegion(const CTranslationMatrix &origin, const float &width, const float &height); void AddRegion(const CDrawRegion ®ion); bool ContainsRegion(); /* Fills given parameters with information about a drawing region and returns true if a region exist. TODO perhaps this could be used for multiple pass rendering, while (GetRegion(...)) Render(); */ bool GetRegion(float &x, float &y, float &width, float &height); }; /* Simple 3D vector */ class CVector3 { public: CVector3(float x, float y, float z = 0.0f) { m_x = x; m_y = y; m_z = z; } float m_x; float m_y; float m_z; }; /* Simple 3D translation matrix. */ class CTranslationMatrix { public: void translate(float x, float y, float z = 0.0f); void rotateX(float angle); void rotateY(float angle); void rotateZ(float angle); void scale(float x, float y); CVector3 getPoint(CVector3 &in); }; CWindow { public: void Invalidate(CGUIControl &callingControl, CTime invalidationTime = 0 /* NOW */); }; /* A control is one or more 2D planes in a 3D world. */ class CGUIControl { public: /* Update will be called when an underlying control or something have invalidated the view. The control should push a needed draw region. Note that if control was drawn previously and have moved, the drawregion MUST contain both the old region and the new so it will clear properly. Return true if the control have changed, false if not. */ bool Update(const CTranslationMatrix &origin, bool originChanged, CDrawRegion ®ion) = 0; bool Draw(CGraphicContext &context, CDrawRegion ®ion) = 0; /* Invalidate the control, this will add an update event and possibly draw the control. */ void Invalidate(); protected: // Given from xml CTranslationMatrix m_origin; // Current relative translation, given from m_origin but changed with animation. CTranslationMatrix m_relativeTranslation; // On an update this equals origin, from fathering control, * m_relativeTranslation and will be used for drawregions. CTranslationMatrix m_finalTranslation; float width; float height; // The root of the control, may be used to schedule invalidation. CWindow m_root; CDrawRegion m_lastRender; CDrawRegion m_currentRender; // Contains lastRender + currentRender after an update call CDrawRegion m_temporaryRender; };