OpenClonk
C4ObjectGraphics.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Logic for C4Object: Graphics and drawing */
19 
20 #include "C4Include.h"
22 #include "object/C4Object.h"
23 
24 #include "game/C4GraphicsSystem.h"
25 #include "graphics/C4Draw.h"
27 #include "landscape/C4Particles.h"
28 #include "lib/StdColors.h"
29 #include "object/C4Command.h"
30 #include "object/C4Def.h"
31 #include "object/C4DefList.h"
32 #include "object/C4GameObjects.h"
34 
35 
36 #ifndef USE_CONSOLE
37 static void DrawVertex(C4Facet &cgo, float tx, float ty, int32_t col, int32_t contact)
38 {
39  if (Inside<int32_t>(tx,cgo.X,cgo.X+cgo.Wdt) && Inside<int32_t>(ty,cgo.Y,cgo.Y+cgo.Hgt))
40  {
41  pDraw->DrawLineDw(cgo.Surface, tx - 1, ty, tx + 1, ty, col, 0.5f);
42  pDraw->DrawLineDw(cgo.Surface, tx, ty - 1, tx, ty + 1, col, 0.5f);
43  if (contact) pDraw->DrawFrameDw(cgo.Surface,tx-1.5,ty-1.5,tx+1.5,ty+1.5,C4RGB(0xff, 0xff, 0xff));
44  }
45 }
46 #endif
47 
48 void C4Object::UpdateGraphics(bool fGraphicsChanged, bool fTemp)
49 {
50  // check color
51  if (!fTemp) if (!pGraphics->IsColorByOwner()) Color=0;
52  // new grafics: update face
53  if (fGraphicsChanged)
54  {
55  // Keep mesh instance if it uses the same underlying mesh
57  &pMeshInstance->GetMesh() != pGraphics->Mesh)
58  {
59  // If this mesh is attached somewhere, detach it before deletion
60  if(pMeshInstance && pMeshInstance->GetAttachParent() != nullptr)
61  {
62  // TODO: If the new mesh has a bone with the same name, we could try updating...
64  attach_parent->Parent->DetachMesh(attach_parent->Number);
65  }
66 
67  delete pMeshInstance;
68 
70  {
71  pMeshInstance = new StdMeshInstance(*pGraphics->Mesh, Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
73  }
74  else
75  {
76  pMeshInstance = nullptr;
77  }
78  }
79 
80  // update face - this also puts any SolidMask
81  UpdateFace(false);
82  }
83 }
84 
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
86 {
87  C4Surface* sfc;
88  switch (GetGraphics()->Type)
89  {
91  // no graphics.
92  break;
94  sfc = action ? Action.Facet.Surface : GetGraphics()->GetBitmap(Color);
95 
96  pDraw->Blit(sfc,
97  fx, fy, fwdt, fhgt,
98  cgo.Surface, tx, ty, twdt, thgt,
99  true, transform);
100  break;
102  C4Value value;
104  StdMeshMatrix matrix;
105  if (!C4ValueToMatrix(value, &matrix))
106  matrix = StdMeshMatrix::Identity();
107 
108  if (fix_r != Fix0)
109  {
110  // Rotation should happen around the mesh center after application of any mesh transformation
111  // So translate back by the transformed mesh center before rotation
112  auto mesh_center = pMeshInstance->GetMesh().GetBoundingBox().GetCenter();
113  mesh_center = matrix * mesh_center;
114  matrix = StdMeshMatrix::Translate(-mesh_center.x, -mesh_center.y, -mesh_center.z) * matrix;
115  matrix = StdMeshMatrix::Rotate(fixtof(fix_r) * (M_PI / 180.0f), 0.0f, 0.0f, 1.0f) * matrix;
116  matrix = StdMeshMatrix::Translate(mesh_center.x, mesh_center.y, mesh_center.z) * matrix;
117  }
118 
119  if(twdt != fwdt || thgt != fhgt)
120  {
121  // Also scale Z so that the mesh is not totally distorted and
122  // so that normals halfway keep pointing into sensible directions.
123  // We don't have a better guess so use the geometric mean for Z scale.
124  matrix = StdMeshMatrix::Scale(twdt/fwdt,thgt/fhgt,std::sqrt(twdt*thgt/(fwdt*fhgt))) * matrix;
125  }
126 
127  pDraw->SetMeshTransform(&matrix);
128 
129  pDraw->RenderMesh(*pMeshInstance, cgo.Surface, tx, ty, twdt, thgt, Color, transform);
130  pDraw->SetMeshTransform(nullptr);
131  break;
132  }
133 }
134 
135 void C4Object::DrawFace(C4TargetFacet &cgo, float offX, float offY, int32_t iPhaseX, int32_t iPhaseY) const
136 {
137  const auto swdt = float(Def->Shape.Wdt);
138  const auto shgt = float(Def->Shape.Hgt);
139  // Grow Type Display
140  auto fx = float(swdt * iPhaseX);
141  auto fy = float(shgt * iPhaseY);
142  auto fwdt = float(swdt);
143  auto fhgt = float(shgt);
144 
145  float stretch_factor = static_cast<float>(Con) / FullCon;
146  float tx = offX + Def->Shape.GetX() * stretch_factor;
147  float ty = offY + Def->Shape.GetY() * stretch_factor;
148  float twdt = swdt * stretch_factor;
149  float thgt = shgt * stretch_factor;
150 
151  // Construction Type Display
152  if (!Def->GrowthType)
153  {
154  tx = offX + Def->Shape.GetX();
155  twdt = swdt;
156 
157  fy += fhgt - thgt;
158  fhgt = thgt;
159  }
160 
161  C4DrawTransform transform;
162  bool transform_active = false;
163  if (pDrawTransform)
164  {
165  transform.SetTransformAt(*pDrawTransform, offX, offY);
166  transform_active = true;
167  }
168 
169  // Meshes aren't rotated via DrawTransform to ensure lighting is applied correctly.
171  {
172  if (pDrawTransform)
173  transform.Rotate(fixtof(fix_r), offX, offY);
174  else
175  transform.SetRotate(fixtof(fix_r), offX, offY);
176  transform_active = true;
177  }
178 
179  DrawFaceImpl(cgo, false, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform : nullptr);
180 }
181 
182 void C4Object::DrawActionFace(C4TargetFacet &cgo, float offX, float offY) const
183 {
184  // This should not be called for meshes since Facet has no meaning
185  // for them. Only use DrawFace() with meshes!
186  assert(GetGraphics()->Type == C4DefGraphics::TYPE_Bitmap);
187  C4PropList* pActionDef = GetAction();
188 
189  // Regular action facet
190  const auto swdt = float(Action.Facet.Wdt);
191  const auto shgt = float(Action.Facet.Hgt);
192  int32_t iPhase = Action.Phase;
193  if (pActionDef->GetPropertyInt(P_Reverse)) iPhase = pActionDef->GetPropertyInt(P_Length) - 1 - Action.Phase;
194 
195  // Grow Type Display
196  auto fx = float(Action.Facet.X + swdt * iPhase);
197  auto fy = float(Action.Facet.Y + shgt * Action.DrawDir);
198  auto fwdt = float(swdt);
199  auto fhgt = float(shgt);
200 
201  // draw stretched towards shape center with transform
202  float stretch_factor = static_cast<float>(Con) / FullCon;
203  float tx = (Def->Shape.GetX() + Action.FacetX) * stretch_factor + offX;
204  float ty = (Def->Shape.GetY() + Action.FacetY) * stretch_factor + offY;
205  float twdt = swdt * stretch_factor;
206  float thgt = shgt * stretch_factor;
207 
208  // Construction Type Display
209  if (!Def->GrowthType)
210  {
211  // FIXME
212  if (Con != FullCon)
213  {
214  // incomplete constructions do not show actions
215  DrawFace(cgo, offX, offY);
216  return;
217  }
218  tx = Def->Shape.GetX() + Action.FacetX + offX;
219  twdt = swdt;
220  float offset_from_top = shgt * std::max(FullCon - Con, 0) / FullCon;
221  fy += offset_from_top;
222  fhgt -= offset_from_top;
223  }
224 
225  C4DrawTransform transform;
226  bool transform_active = false;
227  if (pDrawTransform)
228  {
229  transform.SetTransformAt(*pDrawTransform, offX, offY);
230  transform_active = true;
231  }
232 
233  // Meshes aren't rotated via DrawTransform to ensure lighting is applied correctly.
234  if (GetGraphics()->Type != C4DefGraphics::TYPE_Mesh && Def->Rotateable && fix_r != Fix0)
235  {
236  if (pDrawTransform)
237  transform.Rotate(fixtof(fix_r), offX, offY);
238  else
239  transform.SetRotate(fixtof(fix_r), offX, offY);
240  transform_active = true;
241  }
242 
243  DrawFaceImpl(cgo, true, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform : nullptr);
244 }
245 
246 void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode, float offX, float offY)
247 {
248 #ifndef USE_CONSOLE
249  C4Facet ccgo;
250 
251  // Status
252  if (!Status || !Def) return;
253 
254  // visible?
255  if (!IsVisible(iByPlayer, !!eDrawMode)) return;
256 
257  // Set up custom uniforms.
258  auto uniform_popper = pDraw->scriptUniform.Push(this);
259 
260  // Line
261  if (Def->Line) { DrawLine(cgo, iByPlayer); return; }
262 
263  // background particles (bounds not checked)
264  if (BackParticles) BackParticles->Draw(cgo, this);
265 
266  // Object output position
267  float newzoom = cgo.Zoom;
268  if (eDrawMode!=ODM_Overlay)
269  {
270  if (!GetDrawPosition(cgo, offX, offY, newzoom)) return;
271  }
272  ZoomDataStackItem zdsi(newzoom);
273 
274  bool fYStretchObject=false;
275  C4PropList* pActionDef = GetAction();
276  if (pActionDef)
277  if (pActionDef->GetPropertyInt(P_FacetTargetStretch))
278  fYStretchObject=true;
279 
280  // Set audibility
281  if (!eDrawMode) SetAudibilityAt(cgo, GetX(), GetY(), iByPlayer);
282 
283  // Output boundary
284  if (!fYStretchObject && !eDrawMode && !(Category & C4D_Parallax))
285  {
286  // For actions with a custom facet set, check against that action facet. Otherwise (or with oversize objects), just check against shape.
287  if (pActionDef && fix_r == Fix0 && !pActionDef->GetPropertyInt(P_FacetBase) && Con <= FullCon && Action.Facet.Wdt)
288  {
289  // active
290  if ( !Inside<float>(offX+Shape.GetX()+Action.FacetX,cgo.X-Action.Facet.Wdt,cgo.X+cgo.Wdt)
291  || (!Inside<float>(offY+Shape.GetY()+Action.FacetY,cgo.Y-Action.Facet.Hgt,cgo.Y+cgo.Hgt)) )
292  {
293  if (FrontParticles && !Contained) FrontParticles->Draw(cgo, this);
294  return;
295  }
296  }
297  else
298  // idle
299  if ( !Inside<float>(offX+Shape.GetX(),cgo.X-Shape.Wdt,cgo.X+cgo.Wdt)
300  || (!Inside<float>(offY+Shape.GetY(),cgo.Y-Shape.Hgt,cgo.Y+cgo.Hgt)) )
301  {
302  if (FrontParticles && !Contained) FrontParticles->Draw(cgo, this);
303  return;
304  }
305  }
306 
307  // ensure correct color is set
309  if (GetGraphics()->Bmp.BitmapClr) GetGraphics()->Bmp.BitmapClr->SetClr(Color);
310 
311  // Debug Display //////////////////////////////////////////////////////////////////////
312  if (::GraphicsSystem.ShowCommand && !eDrawMode)
313  {
314  C4Command *pCom;
315  int32_t ccx=GetX(),ccy=GetY();
316  float offX1, offY1, offX2, offY2, newzoom;
317  char szCommand[200];
318  StdStrBuf Cmds;
319  int32_t iMoveTos=0;
320  for (pCom=Command; pCom; pCom=pCom->Next)
321  {
322  switch (pCom->Command)
323  {
324  case C4CMD_MoveTo:
325  // Angle
326  int32_t iAngle; iAngle=Angle(ccx,ccy,pCom->Tx._getInt(),pCom->Ty); while (iAngle>180) iAngle-=360;
327  // Path
328  if(GetDrawPosition(cgo, ccx, ccy, cgo.Zoom, offX1, offY1, newzoom) &&
329  GetDrawPosition(cgo, pCom->Tx._getInt(), pCom->Ty, cgo.Zoom, offX2, offY2, newzoom))
330  {
331  ZoomDataStackItem zdsi(newzoom);
332  pDraw->DrawLineDw(cgo.Surface,offX1,offY1,offX2,offY2,C4RGB(0xca,0,0));
333  pDraw->DrawFrameDw(cgo.Surface,offX2-1,offY2-1,offX2+1,offY2+1,C4RGB(0xca,0,0));
334  }
335 
336  ccx=pCom->Tx._getInt(); ccy=pCom->Ty;
337  // Message
338  iMoveTos++; szCommand[0]=0;
339  break;
340  case C4CMD_Put:
341  sprintf(szCommand,"%s %s to %s",CommandName(pCom->Command),pCom->Target2 ? pCom->Target2->GetName() : pCom->Data ? pCom->Data.GetDataString().getData() : "Content",pCom->Target ? pCom->Target->GetName() : "");
342  break;
343  case C4CMD_Buy: case C4CMD_Sell:
344  sprintf(szCommand,"%s %s at %s",CommandName(pCom->Command),pCom->Data.GetDataString().getData(),pCom->Target ? pCom->Target->GetName() : "closest base");
345  break;
346  case C4CMD_Acquire:
347  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Data.GetDataString().getData());
348  break;
349  case C4CMD_Call:
350  sprintf(szCommand,"%s %s in %s",CommandName(pCom->Command),pCom->Text->GetCStr(),pCom->Target ? pCom->Target->GetName() : "(null)");
351  break;
352  case C4CMD_None:
353  szCommand[0]=0;
354  break;
355  case C4CMD_Transfer:
356  // Path
357  if(GetDrawPosition(cgo, ccx, ccy, cgo.Zoom, offX1, offY1, newzoom) &&
358  GetDrawPosition(cgo, pCom->Tx._getInt(), pCom->Ty, cgo.Zoom, offX2, offY2, newzoom))
359  {
360  ZoomDataStackItem zdsi(newzoom);
361  pDraw->DrawLineDw(cgo.Surface,offX1,offY1,offX2,offY2,C4RGB(0,0xca,0));
362  pDraw->DrawFrameDw(cgo.Surface,offX2-1,offY2-1,offX2+1,offY2+1,C4RGB(0,0xca,0));
363  }
364 
365  ccx=pCom->Tx._getInt(); ccy=pCom->Ty;
366  // Message
367  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Target ? pCom->Target->GetName() : "");
368  break;
369  default:
370  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Target ? pCom->Target->GetName() : "");
371  break;
372  }
373  // Compose command stack message
374  if (szCommand[0])
375  {
376  // End MoveTo stack first
377  if (iMoveTos) { Cmds.AppendChar('|'); Cmds.AppendFormat("%dx MoveTo",iMoveTos); iMoveTos=0; }
378  // Current message
379  Cmds.AppendChar('|');
380  if (pCom->Finished) Cmds.Append("<i>");
381  Cmds.Append(szCommand);
382  if (pCom->Finished) Cmds.Append("</i>");
383  }
384  }
385  // Open MoveTo stack
386  if (iMoveTos) { Cmds.AppendChar('|'); Cmds.AppendFormat("%dx MoveTo",iMoveTos); iMoveTos=0; }
387  // Draw message
388  int32_t cmwdt,cmhgt; ::GraphicsResource.FontRegular.GetTextExtent(Cmds.getData(),cmwdt,cmhgt,true);
390  }
391  // Debug Display ///////////////////////////////////////////////////////////////////////////////
392 
393  // Don't draw (show solidmask)
394  if (::GraphicsSystem.Show8BitSurface != 0)
395  if (SolidMask.Wdt)
396  {
397  // DrawSolidMask(cgo); - no need to draw it, because the 8bit-surface will be shown
398  return;
399  }
400 
401  // Contained check
402  if (Contained && !eDrawMode) return;
403 
404  // Visibility inside FoW
405  const C4FoWRegion* pOldFoW = pDraw->GetFoW();
406  if(pOldFoW && (Category & C4D_IgnoreFoW))
407  pDraw->SetFoW(nullptr);
408 
409  // color modulation (including construction sign...)
410  if (ColorMod != 0xffffffff || BlitMode) if (!eDrawMode) PrepareDrawing();
411 
412  // Not active or rotated: BaseFace only
413  if (!pActionDef)
414  {
415  DrawFace(cgo, offX, offY);
416  }
417 
418  // Active
419  else
420  {
421  // FacetBase
422  if (pActionDef->GetPropertyInt(P_FacetBase) || GetGraphics()->Type != C4DefGraphics::TYPE_Bitmap)
423  DrawFace(cgo, offX, offY, 0, Action.DrawDir);
424 
425  // Special: stretched action facet
427  {
428  if (Action.Target)
430  float(Action.Facet.X),float(Action.Facet.Y),float(Action.Facet.Wdt),float(Action.Facet.Hgt),
431  cgo.Surface,
432  offX + Shape.GetX() + Action.FacetX, offY + Shape.GetY() + Action.FacetY,Action.Facet.Wdt,
434  true);
435  }
436  else if (Action.Facet.Surface)
437  DrawActionFace(cgo, offX, offY);
438  }
439 
440  // end of color modulation
441  if (ColorMod != 0xffffffff || BlitMode) if (!eDrawMode) FinishedDrawing();
442 
443  // draw overlays - after blit mode changes, because overlay gfx set their own
444  if (pGfxOverlay) if (eDrawMode!=ODM_BaseOnly)
445  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
446  if (!pGfxOvrl->IsPicture())
447  pGfxOvrl->Draw(cgo, this, iByPlayer);
448 
449  // local particles in front of the object
450  if (eDrawMode!=ODM_BaseOnly)
451  {
452  if (FrontParticles)
453  FrontParticles->Draw(cgo, this);
454  }
455 
456  // Debug Display ////////////////////////////////////////////////////////////////////////
457  if (::GraphicsSystem.ShowVertices) if (eDrawMode!=ODM_BaseOnly)
458  {
459  int32_t cnt;
460  if (Shape.VtxNum>1)
461  for (cnt=0; cnt<Shape.VtxNum; cnt++)
462  {
463  DrawVertex(cgo,
464  offX+Shape.VtxX[cnt],
465  offY+Shape.VtxY[cnt],
466  (Shape.VtxCNAT[cnt] & CNAT_NoCollision) ? C4RGB(0, 0, 0xff) : (Mobile ? C4RGB(0xff, 0, 0) : C4RGB(0xef, 0xef, 0)),
467  Shape.VtxContactCNAT[cnt]);
468  }
469  }
470 
471  if (::GraphicsSystem.ShowEntrance) if (eDrawMode!=ODM_BaseOnly)
472  {
473  if (OCF & OCF_Entrance)
474  pDraw->DrawFrameDw(cgo.Surface,offX+Def->Entrance.x,
475  offY+Def->Entrance.y,
476  offX+Def->Entrance.x+Def->Entrance.Wdt-1,
477  offY+Def->Entrance.y+Def->Entrance.Hgt-1,
478  C4RGB(0, 0, 0xff));
479  if (OCF & OCF_Collection)
481  offY+Def->Collection.y,
482  offX+Def->Collection.x+Def->Collection.Wdt-1,
483  offY+Def->Collection.y+Def->Collection.Hgt-1,
484  C4RGB(0xca, 0, 0));
485  }
486 
487  if (::GraphicsSystem.ShowAction) if (eDrawMode!=ODM_BaseOnly)
488  {
489  if (pActionDef)
490  {
491  StdStrBuf str;
492  str.Format("%s (%d)",pActionDef->GetName(),Action.Phase);
493  int32_t cmwdt,cmhgt; ::GraphicsResource.FontRegular.GetTextExtent(str.getData(),cmwdt,cmhgt,true);
495  1.0, cgo.Surface, offX, offY + Shape.GetY() - cmhgt,
497  }
498  }
499  // Debug Display ///////////////////////////////////////////////////////////////////////
500 
501  // Restore visibility inside FoW
502  if (pOldFoW) pDraw->SetFoW(pOldFoW);
503 #endif
504 }
505 
506 void C4Object::DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode, float offX, float offY)
507 {
508 #ifndef USE_CONSOLE
509  // Status
510  if (!Status || !Def) return;
511  // visible?
512  if (!IsVisible(iByPlayer, eDrawMode==ODM_Overlay)) return;
513  // target pos (parallax)
514  float newzoom = cgo.Zoom;
515  if (eDrawMode!=ODM_Overlay) GetDrawPosition(cgo, offX, offY, newzoom);
516  ZoomDataStackItem zdsi(newzoom);
517  // TopFace
518  if (!(TopFace.Surface || (OCF & OCF_Construct))) return;
519  // Output bounds check
520  if (!Inside<float>(offX, cgo.X - Shape.Wdt, cgo.X + cgo.Wdt)
521  || !Inside<float>(offY, cgo.Y - Shape.Hgt, cgo.Y + cgo.Hgt))
522  return;
523  // Don't draw (show solidmask)
524  if (::GraphicsSystem.Show8BitSurface != 0 && SolidMask.Wdt) return;
525  // Contained
526  if (Contained) if (eDrawMode!=ODM_Overlay) return;
527  // Construction sign
528  if (OCF & OCF_Construct && fix_r == Fix0)
529  if (eDrawMode!=ODM_BaseOnly)
530  {
532  pDraw->Blit(fctConSign.Surface,
533  fctConSign.X, fctConSign.Y,
534  fctConSign.Wdt, fctConSign.Hgt,
535  cgo.Surface,
536  offX + Shape.GetX(), offY + Shape.GetY() + Shape.Hgt - fctConSign.Hgt,
537  fctConSign.Wdt, fctConSign.Hgt, true);
538  }
539  if(TopFace.Surface)
540  {
541  // FacetTopFace: Override TopFace.GetX()/GetY()
542  C4PropList* pActionDef = GetAction();
543  if (pActionDef && pActionDef->GetPropertyInt(P_FacetTopFace))
544  {
545  int32_t iPhase = Action.Phase;
546  if (pActionDef->GetPropertyInt(P_Reverse)) iPhase = pActionDef->GetPropertyInt(P_Length) - 1 - Action.Phase;
547  TopFace.X = pActionDef->GetPropertyInt(P_X) + Def->TopFace.x + pActionDef->GetPropertyInt(P_Wdt) * iPhase;
548  TopFace.Y = pActionDef->GetPropertyInt(P_Y) + Def->TopFace.y + pActionDef->GetPropertyInt(P_Hgt) * Action.DrawDir;
549  }
550  // ensure correct color is set
551  if (GetGraphics()->Bmp.BitmapClr) GetGraphics()->Bmp.BitmapClr->SetClr(Color);
552  // color modulation
553  if (!eDrawMode) PrepareDrawing();
554  // Draw top face bitmap
555  if (Con!=FullCon && Def->GrowthType)
556  // stretched
559  cgo.Surface,
560  offX + Shape.GetX() + float(Def->TopFace.tx * Con) / FullCon, offY + Shape.GetY() + float(Def->TopFace.ty * Con) / FullCon,
561  float(TopFace.Wdt * Con) / FullCon, float(TopFace.Hgt * Con) / FullCon,
562  true, pDrawTransform ? &C4DrawTransform(*pDrawTransform, offX, offY) : nullptr);
563  else
564  // normal
566  TopFace.X,TopFace.Y,
568  cgo.Surface,
569  offX + Shape.GetX() + Def->TopFace.tx, offY + Shape.GetY() + Def->TopFace.ty,
571  true, pDrawTransform ? &C4DrawTransform(*pDrawTransform, offX, offY) : nullptr);
572  }
573  // end of color modulation
574  if (!eDrawMode) FinishedDrawing();
575 #endif
576 }
577 
578 void C4Object::DrawLine(C4TargetFacet &cgo, int32_t at_player)
579 {
580  // Nothing to draw if the object has less than two vertices
581  if (Shape.VtxNum < 2)
582  return;
583 #ifndef USE_CONSOLE
584  // Audibility
585  SetAudibilityAt(cgo, Shape.VtxX[0], Shape.VtxY[0], at_player);
586  SetAudibilityAt(cgo, Shape.VtxX[Shape.VtxNum - 1], Shape.VtxY[Shape.VtxNum - 1], at_player);
587  // additive mode?
588  PrepareDrawing();
589  // Draw line segments
590  C4Value colorsV; GetProperty(P_LineColors, &colorsV);
591  C4ValueArray *colors = colorsV.getArray();
592  // TODO: Edge color (color1) is currently ignored.
593  int32_t color0 = 0xFFFF00FF;// , color1 = 0xFFFF00FF; // use bright colors so author notices
594  if (colors)
595  {
596  color0 = colors->GetItem(0).getInt();
597  }
598 
599  std::vector<C4BltVertex> vertices;
600  vertices.resize( (Shape.VtxNum - 1) * 2);
601  for (int32_t vtx=0; vtx+1<Shape.VtxNum; vtx++)
602  {
603  DwTo4UB(color0, vertices[2*vtx].color);
604  DwTo4UB(color0, vertices[2*vtx+1].color);
605 
606  vertices[2*vtx].ftx = Shape.VtxX[vtx] + cgo.X - cgo.TargetX;
607  vertices[2*vtx].fty = Shape.VtxY[vtx] + cgo.Y - cgo.TargetY;
608  vertices[2*vtx+1].ftx = Shape.VtxX[vtx+1] + cgo.X - cgo.TargetX;
609  vertices[2*vtx+1].fty = Shape.VtxY[vtx+1] + cgo.Y - cgo.TargetY;
610  }
611 
612  pDraw->PerformMultiLines(cgo.Surface, &vertices[0], vertices.size(), 1.0f, nullptr);
613 
614  // reset blit mode
615  FinishedDrawing();
616 #endif
617 }
618 
619 void C4Object::DrawPicture(C4Facet &cgo, bool fSelected, C4DrawTransform* transform)
620 {
621  // Draw def picture with object color
622  Def->Draw(cgo,fSelected,Color,this,0,0,transform);
623 }
624 
626 {
627  // set picture rect to facet
628  C4Rect fctPicRect = PictureRect;
629  if (!fctPicRect.Wdt) fctPicRect = Def->PictureRect;
630  C4Facet fctPicture;
631  fctPicture.Set(GetGraphics()->GetBitmap(Color),fctPicRect.x,fctPicRect.y,fctPicRect.Wdt,fctPicRect.Hgt);
632 
633  // use direct facet w/o own data if possible
634  if (ColorMod == 0xffffffff && BlitMode == C4GFXBLIT_NORMAL && !pGfxOverlay)
635  {
636  cgo.Set(fctPicture);
637  return;
638  }
639 
640  // otherwise, draw to picture facet
641  if (!cgo.Create(cgo.Wdt, cgo.Hgt)) return;
642 
643  // specific object color?
644  PrepareDrawing();
645 
646  // draw picture itself
647  fctPicture.Draw(cgo,true);
648 
649  // draw overlays
650  if (pGfxOverlay)
651  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
652  if (pGfxOvrl->IsPicture())
653  pGfxOvrl->DrawPicture(cgo, this, nullptr);
654 
655  // done; reset drawing states
656  FinishedDrawing();
657 }
658 
660 {
661  // Status
662  if (!Status) return;
663  // No select marks in film playback
664  if (Game.C4S.Head.Film && Game.C4S.Head.Replay) return;
665  // target pos (parallax)
666  float offX, offY, newzoom;
667  GetDrawPosition(cgo, offX, offY, newzoom);
668  // Output boundary
669  if (!Inside<float>(offX, cgo.X, cgo.X + cgo.Wdt)
670  || !Inside<float>(offY, cgo.Y, cgo.Y + cgo.Hgt)) return;
671  // Draw select marks
672  float cox = offX + Shape.GetX() - cgo.X + cgo.X - 2;
673  float coy = offY + Shape.GetY() - cgo.Y + cgo.Y - 2;
674  GfxR->fctSelectMark.Draw(cgo.Surface,cox,coy,0);
675  GfxR->fctSelectMark.Draw(cgo.Surface,cox+Shape.Wdt,coy,1);
676  GfxR->fctSelectMark.Draw(cgo.Surface,cox,coy+Shape.Hgt,2);
677  GfxR->fctSelectMark.Draw(cgo.Surface,cox+Shape.Wdt,coy+Shape.Hgt,3);
678 }
679 
681 {
682  // color modulation
684  // other blit modes
686 }
687 
689 {
690  // color modulation
692  // extra blitting flags
693  pDraw->ResetBlitMode();
694 }
695 
696 void C4Object::GetParallaxity(int32_t *parX, int32_t *parY) const
697 {
698  assert(parX); assert(parY);
699  *parX = 100; *parY = 100;
700  if (Category & C4D_Foreground)
701  {
702  *parX = 0; *parY = 0;
703  return;
704  }
705  if (!(Category & C4D_Parallax)) return;
706  C4Value parV; GetProperty(P_Parallaxity, &parV);
707  C4ValueArray *par = parV.getArray();
708  if (!par) return;
709  *parX = par->GetItem(0).getInt();
710  *parY = par->GetItem(1).getInt();
711 }
712 
713 bool C4Object::GetDragImage(C4Object **drag_object, C4Def **drag_def) const
714 {
715  // drag is possible if MouseDragImage is assigned
716  C4Value parV; GetProperty(P_MouseDragImage, &parV);
717  if (!parV) return false;
718  // determine drag object/id
719  C4Object *obj = parV.getObj();
720  C4Def * def = nullptr;
721  if (!obj) def = parV.getDef();
722  if (drag_object) *drag_object = obj;
723  if (drag_def) *drag_def = def;
724  // drag possible, even w./o image
725  return true;
726 }
727 
728 void C4Object::GetViewPos(float & riX, float & riY, float tx, float ty, const C4Facet & fctViewport) const // get position this object is seen at (for given scroll)
729 {
730  if (Category & C4D_Parallax) GetViewPosPar(riX, riY, tx, ty, fctViewport); else { riX = float(GetX()); riY = float(GetY()); }
731 }
732 
734  float & resultx, float & resulty, float & resultzoom) const
735 {
736  return GetDrawPosition(cgo, fixtof(fix_x), fixtof(fix_y), cgo.Zoom, resultx, resulty, resultzoom);
737 }
738 
739 bool C4Object::GetDrawPosition(const C4TargetFacet & cgo, float objx, float objy, float zoom, float & resultx, float & resulty, float & resultzoom) const
740 {
741  // for HUD
743  {
744  resultzoom = zoom;
745 
746  if(fix_x < 0)
747  resultx = cgo.X + objx + cgo.Wdt;
748  else
749  resultx = cgo.X + objx;
750 
751  if(fix_y < 0)
752  resulty = cgo.Y + objy + cgo.Hgt;
753  else
754  resulty = cgo.Y + objy;
755 
756  return true;
757  }
758 
759  // zoom with parallaxity
760  int iParX, iParY;
761  GetParallaxity(&iParX, &iParY);
762  float targetx = cgo.TargetX; float targety = cgo.TargetY;
763  float parx = iParX / 100.0f; float pary = iParY / 100.0f;
764  float par = parx; // and pary?
765 
766  // Step 1: project to landscape coordinates
767  resultzoom = 1.0 / (1.0 - (par - par/zoom));
768  // it would be par / (1.0 - (par - par/zoom)) if objects would get smaller farther away
769  if (resultzoom <= 0 || resultzoom > 100) // FIXME: optimize treshhold
770  return false;
771 
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);
774 
775  // Step 2: convert to screen coordinates
776  if(parx == 0 && fix_x < 0)
777  resultx = cgo.X + (objx + cgo.Wdt) * zoom / resultzoom;
778  else
779  resultx = cgo.X + (rx - targetx) * zoom / resultzoom;
780 
781  if(pary == 0 && fix_y < 0)
782  resulty = cgo.Y + (objy + cgo.Hgt) * zoom / resultzoom;
783  else
784  resulty = cgo.Y + (ry - targety) * zoom / resultzoom;
785 
786  return true;
787 }
788 
789 void C4Object::GetViewPosPar(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const
790 {
791  int iParX, iParY;
792  GetParallaxity(&iParX, &iParY);
793  // get drawing pos, then subtract original target pos to get drawing pos on landscape
794  if (!iParX && GetX()<0)
795  // HUD element at right viewport pos
796  riX=fixtof(fix_x)+tx+fctViewport.Wdt;
797  else
798  // regular parallaxity
799  riX=fixtof(fix_x)-(tx*(iParX-100)/100);
800  if (!iParY && GetY()<0)
801  // HUD element at bottom viewport pos
802  riY=fixtof(fix_y)+ty+fctViewport.Hgt;
803  else
804  // regular parallaxity
805  riY=fixtof(fix_y)-(ty*(iParY-100)/100);
806 }
807 
808 bool C4Object::SetGraphics(const char *szGraphicsName, C4Def *pSourceDef)
809 {
810  // safety
811  if (!Status) return false;
812  // default def
813  if (!pSourceDef) pSourceDef = Def;
814  // get graphics
815  C4DefGraphics *pGrp = pSourceDef->Graphics.Get(szGraphicsName);
816  if (!pGrp) return false;
817  // set new graphics
818  pGraphics = pGrp;
819  // update Color, etc.
820  UpdateGraphics(true);
821  // success
822  return true;
823 }
824 
825 bool C4Object::SetGraphics(C4DefGraphics *pNewGfx, bool fTemp)
826 {
827  // safety
828  if (!pNewGfx) return false;
829  // set it and update related stuff
830  pGraphics = pNewGfx;
831  UpdateGraphics(true, fTemp);
832  return true;
833 }
834 
836 {
837  // search in list until ID is found or passed
838  C4GraphicsOverlay *pOverlay = pGfxOverlay;
839  while (pOverlay && pOverlay->GetID() < iForID) pOverlay = pOverlay->GetNext();
840  // exact match found?
841  if (pOverlay && pOverlay->GetID() == iForID) return pOverlay;
842  // none found
843  return nullptr;
844 }
845 
846 C4GraphicsOverlay *C4Object::GetGraphicsOverlay(int32_t iForID, bool fCreate)
847 {
848  // search in list until ID is found or passed
849  C4GraphicsOverlay *pOverlay = pGfxOverlay, *pPrevOverlay = nullptr;
850  while (pOverlay && pOverlay->GetID() < iForID) { pPrevOverlay = pOverlay; pOverlay = pOverlay->GetNext(); }
851  // exact match found?
852  if (pOverlay && pOverlay->GetID() == iForID) return pOverlay;
853  // ID has been passed: Create new if desired
854  if (!fCreate) return nullptr;
855  C4GraphicsOverlay *pNewOverlay = new C4GraphicsOverlay();
856  pNewOverlay->SetID(iForID);
857  pNewOverlay->SetNext(pOverlay);
858  if (pPrevOverlay) pPrevOverlay->SetNext(pNewOverlay); else pGfxOverlay = pNewOverlay;
859  // return newly created overlay
860  return pNewOverlay;
861 }
862 
863 bool C4Object::RemoveGraphicsOverlay(int32_t iOverlayID)
864 {
865  // search in list until ID is found or passed
866  C4GraphicsOverlay *pOverlay = pGfxOverlay, *pPrevOverlay = nullptr;
867  while (pOverlay && pOverlay->GetID() < iOverlayID) { pPrevOverlay = pOverlay; pOverlay = pOverlay->GetNext(); }
868  // exact match found?
869  if (pOverlay && pOverlay->GetID() == iOverlayID)
870  {
871  // remove it
872  if (pPrevOverlay) pPrevOverlay->SetNext(pOverlay->GetNext()); else pGfxOverlay = pOverlay->GetNext();
873  pOverlay->SetNext(nullptr); // prevents deletion of following overlays
874  delete pOverlay;
875  // removed
876  return true;
877  }
878  // no match found
879  return false;
880 }
881 
883 {
884  C4Object *pGfxOvrlObj;
885  if (pGfxOverlay)
886  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
887  if ((pGfxOvrlObj = pGfxOvrl->GetOverlayObject()))
888  {
889  if (pGfxOvrlObj == pCheckObj) return true;
890  if (pGfxOvrlObj->HasGraphicsOverlayRecursion(pCheckObj)) return true;
891  }
892  return false;
893 }
894 
895 bool C4Object::CanConcatPictureWith(C4Object *pOtherObject) const
896 {
897  // check current definition ID
898  if (id != pOtherObject->id) return false;
899  // def overwrite of stack conditions
900  int32_t allow_picture_stack = Def->AllowPictureStack;
901  if (!(allow_picture_stack & APS_Color))
902  {
903  // check color if ColorByOwner (flags)
904  if (Color != pOtherObject->Color && Def->ColorByOwner) return false;
905  // check modulation
906  if (ColorMod != pOtherObject->ColorMod) return false;
907  if (BlitMode != pOtherObject->BlitMode) return false;
908  }
909  if (!(allow_picture_stack & APS_Graphics))
910  {
911  // check graphics
912  if (pGraphics != pOtherObject->pGraphics) return false;
913  // check any own picture rect
914  if (PictureRect != pOtherObject->PictureRect) return false;
915  }
916  if (!(allow_picture_stack & APS_Name))
917  {
918  // check name, so zagabar's sandwiches don't stack
919  if (GetName() != pOtherObject->GetName()) return false;
920  }
921  if (!(allow_picture_stack & APS_Overlay))
922  {
923  // check overlay graphics
924  for (C4GraphicsOverlay *pOwnOverlay = pGfxOverlay; pOwnOverlay; pOwnOverlay = pOwnOverlay->GetNext())
925  if (pOwnOverlay->IsPicture())
926  {
927  C4GraphicsOverlay *pOtherOverlay = pOtherObject->GetGraphicsOverlay(pOwnOverlay->GetID(), false);
928  if (!pOtherOverlay || !(*pOtherOverlay == *pOwnOverlay)) return false;
929  }
930  for (C4GraphicsOverlay *pOtherOverlay = pOtherObject->pGfxOverlay; pOtherOverlay; pOtherOverlay = pOtherOverlay->GetNext())
931  if (pOtherOverlay->IsPicture())
932  if (!GetGraphicsOverlay(pOtherOverlay->GetID())) return false;
933  }
934  // concat OK
935  return true;
936 }
const char * CommandName(int32_t iCommand)
Definition: C4Command.cpp:46
@ C4CMD_Acquire
Definition: C4Command.h:48
@ C4CMD_Call
Definition: C4Command.h:51
@ C4CMD_Sell
Definition: C4Command.h:47
@ C4CMD_Transfer
Definition: C4Command.h:44
@ C4CMD_None
Definition: C4Command.h:28
@ C4CMD_MoveTo
Definition: C4Command.h:30
@ C4CMD_Put
Definition: C4Command.h:39
@ C4CMD_Buy
Definition: C4Command.h:46
@ APS_Color
Definition: C4Constants.h:162
@ APS_Graphics
Definition: C4Constants.h:163
@ APS_Name
Definition: C4Constants.h:164
@ APS_Overlay
Definition: C4Constants.h:165
const int32_t FullCon
Definition: C4Constants.h:181
const uint32_t OCF_Construct
Definition: C4Constants.h:80
const uint32_t OCF_Collection
Definition: C4Constants.h:93
const uint32_t OCF_Entrance
Definition: C4Constants.h:90
const BYTE CNAT_NoCollision
Definition: C4Constants.h:116
const int32_t C4D_Foreground
Definition: C4Def.h:53
const int32_t C4D_IgnoreFoW
Definition: C4Def.h:55
const int32_t C4D_Parallax
Definition: C4Def.h:51
C4Draw * pDraw
Definition: C4Draw.cpp:42
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
bool C4ValueToMatrix(C4Value &value, StdMeshMatrix *matrix)
C4Game Game
Definition: C4Globals.cpp:52
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
C4GraphicsResource GraphicsResource
#define GfxR
float fixtof(const C4Fixed &x)
Definition: C4Real.h:257
const C4Real Fix0
Definition: C4Real.h:312
@ P_FacetTargetStretch
@ P_FacetTopFace
@ P_LineColors
@ P_FacetBase
@ P_Wdt
@ P_Y
@ P_Length
@ P_Hgt
@ P_Parallaxity
@ P_MouseDragImage
@ P_X
@ P_MeshTransformation
@ P_Reverse
#define C4GFXBLIT_NORMAL
Definition: C4Surface.h:25
#define C4GFXBLIT_MOD2
Definition: C4Surface.h:27
#define C4GFXBLIT_CLRSFC_MOD2
Definition: C4Surface.h:29
const int ACenter
Definition: C4Surface.h:41
int32_t Angle(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2, int32_t iPrec)
Definition: Standard.cpp:37
#define sprintf
Definition: Standard.h:162
#define C4RGB(r, g, b)
Definition: StdColors.h:26
C4Facet Facet
Definition: C4Object.h:88
int32_t Phase
Definition: C4Object.h:85
int32_t FacetY
Definition: C4Object.h:89
int32_t DrawDir
Definition: C4Object.h:81
int32_t FacetX
Definition: C4Object.h:89
C4ObjectPtr Target
Definition: C4Object.h:87
void SetRotate(float iAngle, float fOffX, float fOffY)
void Rotate(float Angle, float fOffX, float fOffY)
C4Value Data
Definition: C4Command.h:85
int32_t Finished
Definition: C4Command.h:87
C4Value Tx
Definition: C4Command.h:82
C4ObjectPtr Target
Definition: C4Command.h:84
C4ObjectPtr Target2
Definition: C4Command.h:84
int32_t Ty
Definition: C4Command.h:83
int32_t Command
Definition: C4Command.h:81
C4String * Text
Definition: C4Command.h:89
C4Command * Next
Definition: C4Command.h:90
C4DefGraphics * Get(const char *szGrpName)
GraphicsType Type
Definition: C4DefGraphics.h:48
C4Surface * GetBitmap(DWORD dwClr=0)
bool IsColorByOwner()
Definition: C4DefGraphics.h:74
Definition: C4Def.h:99
int32_t AllowPictureStack
Definition: C4Def.h:147
C4DefGraphics Graphics
Definition: C4Def.h:191
int32_t Line
Definition: C4Def.h:126
int32_t ColorByOwner
Definition: C4Def.h:121
int32_t Rotateable
Definition: C4Def.h:119
C4Rect Collection
Definition: C4Def.h:106
int32_t GrowthType
Definition: C4Def.h:111
C4Rect PictureRect
Definition: C4Def.h:107
C4Shape Shape
Definition: C4Def.h:104
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)
Definition: C4Def.cpp:607
C4Rect Entrance
Definition: C4Def.h:105
C4TargetRect TopFace
Definition: C4Def.h:109
void SetFoW(const C4FoWRegion *fow)
Definition: C4Draw.h:193
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)
Definition: C4Draw.cpp:301
void DrawFrameDw(C4Surface *sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:635
@ DEFAULT_MESSAGE_COLOR
Definition: C4Draw.h:167
void SetBlitMode(DWORD dwBlitMode)
Definition: C4Draw.h:191
const C4FoWRegion * GetFoW() const
Definition: C4Draw.h:194
bool RenderMesh(StdMeshInstance &instance, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform *pTransform)
Definition: C4Draw.cpp:397
virtual void PerformMultiLines(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, float width, C4ShaderCall *shader_call)=0
void DeactivateBlitModulation()
Definition: C4Draw.h:189
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:608
void SetMeshTransform(const StdMeshMatrix *Transform)
Definition: C4Draw.h:200
void ResetBlitMode()
Definition: C4Draw.h:192
void ActivateBlitModulation(DWORD dwWithClr)
Definition: C4Draw.h:188
C4ScriptUniform scriptUniform
Definition: C4Draw.h:100
bool TextOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
Definition: C4Draw.cpp:561
void SetTransformAt(C4DrawTransform &rCopy, float iOffX, float iOffY)
Definition: C4Facet.cpp:541
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
C4Surface * Surface
Definition: C4Facet.h:117
float Hgt
Definition: C4Facet.h:118
float Wdt
Definition: C4Facet.h:118
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
float Y
Definition: C4Facet.h:118
float X
Definition: C4Facet.h:118
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void Set(const C4Facet &cpy)
Definition: C4FacetEx.h:46
C4Scenario C4S
Definition: C4Game.h:74
void SetNext(C4GraphicsOverlay *paNext)
int32_t GetID() const
C4GraphicsOverlay * GetNext() const
void SetID(int32_t aID)
bool GetDrawPosition(const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
bool SetGraphics(const char *szGraphicsName=nullptr, C4Def *pSourceDef=nullptr)
C4Real fix_y
Definition: C4Object.h:123
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
Definition: C4Object.h:169
void DrawLine(C4TargetFacet &cgo, int32_t at_player)
C4Rect PictureRect
Definition: C4Object.h:150
C4TargetRect SolidMask
Definition: C4Object.h:148
C4Real fix_x
Definition: C4Object.h:123
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
Definition: C4Object.h:135
void DrawTopFace(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
C4Command * Command
Definition: C4Object.h:165
void PrepareDrawing() const
int32_t GetX() const
Definition: C4Object.h:285
void Picture2Facet(C4FacetSurface &cgo)
int32_t Category
Definition: C4Object.h:111
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
uint32_t OCF
Definition: C4Object.h:132
bool HasGraphicsOverlayRecursion(const C4Object *pCheckObj) const
C4Real fix_r
Definition: C4Object.h:123
bool Mobile
Definition: C4Object.h:126
int32_t Con
Definition: C4Object.h:172
C4ID id
Definition: C4Object.h:106
void DrawActionFace(C4TargetFacet &cgo, float offX, float offY) const
bool RemoveGraphicsOverlay(int32_t iOverlayID)
int32_t GetY() const
Definition: C4Object.h:286
StdMeshInstance * pMeshInstance
Definition: C4Object.h:154
class C4ParticleList * BackParticles
Definition: C4Object.h:157
void Draw(C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
void DrawSelectMark(C4TargetFacet &cgo) const
C4ObjectPtr Contained
Definition: C4Object.h:142
C4Action Action
Definition: C4Object.h:145
@ ODM_Overlay
Definition: C4Object.h:215
@ ODM_BaseOnly
Definition: C4Object.h:215
void GetViewPosPar(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const
bool InLiquid
Definition: C4Object.h:129
uint32_t BlitMode
Definition: C4Object.h:161
void FinishedDrawing() const
uint32_t ColorMod
Definition: C4Object.h:160
bool CanConcatPictureWith(C4Object *pOtherObject) const
C4Def * Def
Definition: C4Object.h:141
uint32_t Color
Definition: C4Object.h:118
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
C4Facet TopFace
Definition: C4Object.h:140
C4Shape Shape
Definition: C4Object.h:146
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
Definition: C4Object.h:153
C4DefGraphics * GetGraphics() const
Definition: C4Object.h:339
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)
class C4ParticleList * FrontParticles
Definition: C4Object.h:157
void Draw(C4TargetFacet cgo, C4Object *obj)
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:855
virtual const char * GetName() const
Definition: C4PropList.cpp:618
int32_t Status
Definition: C4PropList.h:173
bool GetProperty(C4PropertyName k, C4Value *pResult) const
Definition: C4PropList.h:105
Definition: C4Rect.h:28
int32_t y
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
int32_t Wdt
Definition: C4Rect.h:30
int32_t x
Definition: C4Rect.h:30
bool Replay
Definition: C4Scenario.h:72
int32_t Film
Definition: C4Scenario.h:73
C4SHead Head
Definition: C4Scenario.h:232
std::unique_ptr< Popper > Push(C4PropList *proplist)
Definition: C4Shader.cpp:757
int32_t GetX() const
Definition: C4Shape.h:62
int32_t VtxCNAT[C4D_MaxVertex]
Definition: C4Shape.h:45
int32_t VtxContactCNAT[C4D_MaxVertex]
Definition: C4Shape.h:51
int32_t VtxNum
Definition: C4Shape.h:42
int32_t GetY() const
Definition: C4Shape.h:63
int32_t VtxY[C4D_MaxVertex]
Definition: C4Shape.h:44
int32_t VtxX[C4D_MaxVertex]
Definition: C4Shape.h:43
const char * GetCStr() const
Definition: C4StringTable.h:49
float TargetY
Definition: C4Facet.h:165
float TargetX
Definition: C4Facet.h:165
float Zoom
Definition: C4Facet.h:165
float ParRefY
Definition: C4Facet.h:177
float ParRefX
Definition: C4Facet.h:177
int32_t tx
Definition: C4Rect.h:79
int32_t ty
Definition: C4Rect.h:79
const C4Value & GetItem(int32_t iElem) const
Definition: C4ValueArray.h:38
C4ValueArray * getArray() const
Definition: C4Value.h:118
C4Object * getObj() const
Definition: C4Value.cpp:68
int32_t getInt() const
Definition: C4Value.h:112
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:131
int32_t _getInt() const
Definition: C4Value.h:122
C4Def * getDef() const
Definition: C4Value.cpp:78
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup=true)
const StdMeshBox & GetBoundingBox() const
Definition: StdMesh.h:206
StdMeshInstance * Parent
Definition: StdMesh.h:510
AttachedMesh * GetAttachParent() const
Definition: StdMesh.h:586
bool DetachMesh(unsigned int number)
Definition: StdMesh.cpp:1395
void SetFaceOrderingForClrModulation(uint32_t clrmod)
Definition: StdMesh.cpp:1135
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
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
Definition: StdBuf.cpp:190
const char * getData() const
Definition: StdBuf.h:442
void AppendChar(char cChar)
Definition: StdBuf.h:588
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
StdMeshVector GetCenter() const
Definition: StdMesh.h:149