37 static void DrawVertex(
C4Facet &cgo,
float tx,
float ty, int32_t col, int32_t contact)
39 if (Inside<int32_t>(tx,cgo.
X,cgo.
X+cgo.
Wdt) && Inside<int32_t>(ty,cgo.
Y,cgo.
Y+cgo.
Hgt))
85 void C4Object::DrawFaceImpl(
C4TargetFacet &cgo,
bool action,
float fx,
float fy,
float fwdt,
float fhgt,
float tx,
float ty,
float twdt,
float thgt,
C4DrawTransform* transform)
const
98 cgo.
Surface, tx, ty, twdt, thgt,
113 mesh_center = matrix * mesh_center;
119 if(twdt != fwdt || thgt != fhgt)
140 auto fx = float(swdt * iPhaseX);
141 auto fy = float(shgt * iPhaseY);
142 auto fwdt = float(swdt);
143 auto fhgt = float(shgt);
145 float stretch_factor =
static_cast<float>(
Con) /
FullCon;
148 float twdt = swdt * stretch_factor;
149 float thgt = shgt * stretch_factor;
162 bool transform_active =
false;
166 transform_active =
true;
176 transform_active =
true;
179 DrawFaceImpl(cgo,
false, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform :
nullptr);
198 auto fwdt = float(swdt);
199 auto fhgt = float(shgt);
202 float stretch_factor =
static_cast<float>(
Con) /
FullCon;
205 float twdt = swdt * stretch_factor;
206 float thgt = shgt * stretch_factor;
221 fy += offset_from_top;
222 fhgt -= offset_from_top;
226 bool transform_active =
false;
230 transform_active =
true;
240 transform_active =
true;
243 DrawFaceImpl(cgo,
true, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform :
nullptr);
255 if (!
IsVisible(iByPlayer, !!eDrawMode))
return;
267 float newzoom = cgo.
Zoom;
274 bool fYStretchObject=
false;
278 fYStretchObject=
true;
316 float offX1, offY1, offX2, offY2, newzoom;
326 int32_t iAngle; iAngle=
Angle(ccx,ccy,pCom->
Tx.
_getInt(),pCom->
Ty);
while (iAngle>180) iAngle-=360;
338 iMoveTos++; szCommand[0]=0;
446 if (!pGfxOvrl->IsPicture())
447 pGfxOvrl->Draw(cgo,
this, iByPlayer);
514 float newzoom = cgo.
Zoom;
533 fctConSign.
X, fctConSign.
Y,
534 fctConSign.
Wdt, fctConSign.
Hgt,
537 fctConSign.
Wdt, fctConSign.
Hgt,
true);
593 int32_t color0 = 0xFFFF00FF;
599 std::vector<C4BltVertex> vertices;
603 DwTo4UB(color0, vertices[2*vtx].color);
604 DwTo4UB(color0, vertices[2*vtx+1].color);
647 fctPicture.
Draw(cgo,
true);
652 if (pGfxOvrl->IsPicture())
653 pGfxOvrl->DrawPicture(cgo,
this,
nullptr);
666 float offX, offY, newzoom;
669 if (!Inside<float>(offX, cgo.
X, cgo.
X + cgo.
Wdt)
670 || !Inside<float>(offY, cgo.
Y, cgo.
Y + cgo.
Hgt))
return;
672 float cox = offX +
Shape.
GetX() - cgo.
X + cgo.
X - 2;
673 float coy = offY +
Shape.
GetY() - cgo.
Y + cgo.
Y - 2;
698 assert(parX); assert(parY);
699 *parX = 100; *parY = 100;
702 *parX = 0; *parY = 0;
717 if (!parV)
return false;
720 C4Def * def =
nullptr;
721 if (!obj) def = parV.
getDef();
722 if (drag_object) *drag_object = obj;
723 if (drag_def) *drag_def = def;
730 if (Category &
C4D_Parallax) GetViewPosPar(riX, riY, tx, ty, fctViewport);
else { riX = float(GetX()); riY = float(GetY()); }
734 float & resultx,
float & resulty,
float & resultzoom)
const
747 resultx = cgo.
X + objx + cgo.
Wdt;
749 resultx = cgo.
X + objx;
752 resulty = cgo.
Y + objy + cgo.
Hgt;
754 resulty = cgo.
Y + objy;
763 float parx = iParX / 100.0f;
float pary = iParY / 100.0f;
767 resultzoom = 1.0 / (1.0 - (par - par/zoom));
769 if (resultzoom <= 0 || resultzoom > 100)
772 float rx = ((1 - parx) * cgo.
ParRefX) * resultzoom + objx / (parx + zoom - parx * zoom);
773 float ry = ((1 - pary) * cgo.
ParRefY) * resultzoom + objy / (pary + zoom - pary * zoom);
776 if(parx == 0 &&
fix_x < 0)
777 resultx = cgo.
X + (objx + cgo.
Wdt) * zoom / resultzoom;
779 resultx = cgo.
X + (rx - targetx) * zoom / resultzoom;
781 if(pary == 0 &&
fix_y < 0)
782 resulty = cgo.
Y + (objy + cgo.
Hgt) * zoom / resultzoom;
784 resulty = cgo.
Y + (ry - targety) * zoom / resultzoom;
794 if (!iParX &&
GetX()<0)
800 if (!iParY &&
GetY()<0)
811 if (!
Status)
return false;
813 if (!pSourceDef) pSourceDef =
Def;
816 if (!pGrp)
return false;
828 if (!pNewGfx)
return false;
839 while (pOverlay && pOverlay->
GetID() < iForID) pOverlay = pOverlay->
GetNext();
841 if (pOverlay && pOverlay->
GetID() == iForID)
return pOverlay;
850 while (pOverlay && pOverlay->
GetID() < iForID) { pPrevOverlay = pOverlay; pOverlay = pOverlay->
GetNext(); }
852 if (pOverlay && pOverlay->
GetID() == iForID)
return pOverlay;
854 if (!fCreate)
return nullptr;
856 pNewOverlay->
SetID(iForID);
857 pNewOverlay->
SetNext(pOverlay);
858 if (pPrevOverlay) pPrevOverlay->SetNext(pNewOverlay);
else pGfxOverlay = pNewOverlay;
867 while (pOverlay && pOverlay->
GetID() < iOverlayID) { pPrevOverlay = pOverlay; pOverlay = pOverlay->
GetNext(); }
869 if (pOverlay && pOverlay->
GetID() == iOverlayID)
887 if ((pGfxOvrlObj = pGfxOvrl->GetOverlayObject()))
889 if (pGfxOvrlObj == pCheckObj)
return true;
898 if (
id != pOtherObject->
id)
return false;
916 if (!(allow_picture_stack &
APS_Name))
925 if (pOwnOverlay->IsPicture())
928 if (!pOtherOverlay || !(*pOtherOverlay == *pOwnOverlay))
return false;
931 if (pOtherOverlay->IsPicture())
const char * CommandName(int32_t iCommand)
const uint32_t OCF_Construct
const uint32_t OCF_Collection
const uint32_t OCF_Entrance
const BYTE CNAT_NoCollision
const int32_t C4D_Foreground
const int32_t C4D_IgnoreFoW
const int32_t C4D_Parallax
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
bool C4ValueToMatrix(C4Value &value, StdMeshMatrix *matrix)
C4GraphicsSystem GraphicsSystem
C4GraphicsResource GraphicsResource
float fixtof(const C4Fixed &x)
#define C4GFXBLIT_CLRSFC_MOD2
int32_t Angle(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2, int32_t iPrec)
C4DefGraphics * Get(const char *szGrpName)
C4Surface * GetBitmap(DWORD dwClr=0)
int32_t AllowPictureStack
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
void SetFoW(const C4FoWRegion *fow)
bool Blit(C4Surface *sfcSource, float fx, float fy, float fwdt, float fhgt, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
void DrawFrameDw(C4Surface *sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width=1.0f)
void SetBlitMode(DWORD dwBlitMode)
const C4FoWRegion * GetFoW() const
bool RenderMesh(StdMeshInstance &instance, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform *pTransform)
virtual void PerformMultiLines(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, float width, C4ShaderCall *shader_call)=0
void DeactivateBlitModulation()
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
void SetMeshTransform(const StdMeshMatrix *Transform)
void ActivateBlitModulation(DWORD dwWithClr)
C4ScriptUniform scriptUniform
bool TextOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
void Set(C4Surface &rSfc)
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
void Set(const C4Facet &cpy)
void SetNext(C4GraphicsOverlay *paNext)
C4GraphicsOverlay * GetNext() const
C4FacetID fctConstruction
bool GetDrawPosition(const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
bool SetGraphics(const char *szGraphicsName=nullptr, C4Def *pSourceDef=nullptr)
void GetViewPos(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const
C4PropList * GetAction() const
void UpdateFace(bool bUpdateShape, bool fTemp=false)
class C4GraphicsOverlay * pGfxOverlay
void DrawLine(C4TargetFacet &cgo, int32_t at_player)
void DrawPicture(C4Facet &cgo, bool fSelected=false, C4DrawTransform *transform=nullptr)
void SetAudibilityAt(C4TargetFacet &cgo, int32_t iX, int32_t iY, int32_t player)
C4DrawTransform * pDrawTransform
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
void PrepareDrawing() const
void Picture2Facet(C4FacetSurface &cgo)
void GetParallaxity(int32_t *parX, int32_t *parY) const
bool GetDragImage(C4Object **drag_object, C4Def **drag_id) const
bool IsVisible(int32_t iForPlr, bool fAsOverlay) const
bool HasGraphicsOverlayRecursion(const C4Object *pCheckObj) const
void DrawActionFace(C4TargetFacet &cgo, float offX, float offY) const
bool RemoveGraphicsOverlay(int32_t iOverlayID)
StdMeshInstance * pMeshInstance
class C4ParticleList * BackParticles
void Draw(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
void DrawSelectMark(C4TargetFacet &cgo) const
void GetViewPosPar(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const
void FinishedDrawing() const
bool CanConcatPictureWith(C4Object *pOtherObject) const
void DrawFaceImpl(C4TargetFacet &cgo, bool action, float fx, float fy, float fwdt, float fhgt, float tx, float ty, float twdt, float thgt, C4DrawTransform *transform) const
void DrawFace(C4TargetFacet &cgo, float offX, float offY, int32_t iPhaseX=0, int32_t iPhaseY=0) const
class C4GraphicsOverlay * GetGraphicsOverlay(int32_t iForID) const
C4DefGraphics * pGraphics
C4DefGraphics * GetGraphics() const
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)
class C4ParticleList * FrontParticles
void Draw(C4TargetFacet cgo, C4Object *obj)
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
virtual const char * GetName() const
bool GetProperty(C4PropertyName k, C4Value *pResult) const
int32_t VtxCNAT[C4D_MaxVertex]
int32_t VtxContactCNAT[C4D_MaxVertex]
int32_t VtxY[C4D_MaxVertex]
int32_t VtxX[C4D_MaxVertex]
const char * GetCStr() const
const C4Value & GetItem(int32_t iElem) const
C4ValueArray * getArray() const
C4Object * getObj() const
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup=true)
const StdMeshBox & GetBoundingBox() const
AttachedMesh * GetAttachParent() const
bool DetachMesh(unsigned int number)
void SetFaceOrderingForClrModulation(uint32_t clrmod)
const StdMesh & GetMesh() const
static StdMeshMatrix Identity()
static StdMeshMatrix Rotate(float angle, float rx, float ry, float rz)
static StdMeshMatrix Scale(float sx, float sy, float sz)
static StdMeshMatrix Translate(float dx, float dy, float dz)
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
const char * getData() const
void AppendChar(char cChar)
void Append(const char *pnData, size_t iChars)
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
StdMeshVector GetCenter() const