Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cMapEntity.h
Go to the documentation of this file.
1 //
8 //
9 
10 #ifndef _INC_cMapEntity_H
11 #define _INC_cMapEntity_H
12 #ifndef NO_PRAGMA_ONCE
13 #pragma once
14 #endif
15 
16 #include "cMapBase.h"
20 
21 #if defined(_DEBUG) || defined(_DEBUG_FAST)
22 #define USE_DEBUG_OFFSETTEST
23 #endif
24 
25 enum OBJ_SLOT_TYPE; // cMapEntity 0=offset to parents root. -1 internally hidden, >0 = predefined attachment point from parent object. (bone?)
26 
27 namespace GrayMapData
28 {
29  class CMapMovable;
30  class CMapMover;
32 
34  {
37  OBJ_SAVE_Script, // store in patch SCP file. not permanently modifiable. (but may be temporarily displaced. i.e tree cut down)
38  OBJ_SAVE_Server, // Server dynamic item. server saves to db.
39  OBJ_SAVE_Template, // Part of template. not saved
40  OBJ_SAVE_Multi, // Part of multi. not saved
41  OBJ_SAVE_Temporary, // Temporary from some other source.
43  };
44 
46  {
50  public:
53 
54  void CopyEntityParams(const cMapEntityParams& from);
55 
56  bool isSolid() const
57  {
59  if (m_bFlagInsubstantial)
60  return false;
61  return true;
62  }
63 
64  public:
66  bool m_bFlagHover;
69  // CMapMovable ?
71  };
72 
74  : public IScriptableObj // IScriptableObj IXObject
75  , public cMapEntityParams
76  {
82 
83  static const XOBJTID_t RESTYPEID_MapEntity = MAKEFOURCC('M', 'p', 'a', 't');
84 
85  public:
86  cMapEntity();
87  virtual ~cMapEntity();
88 
89  virtual cMapBase* get_MapBase() const = 0; // what map is this attached to?
90  virtual MAP_LOD_TYPE get_PatchLod() const
91  {
94  return MAP_LOD_SECTOR; // default.
95  }
97  {
98  return MAP_SIZE(get_PatchLod());
99  }
100 
101  virtual bool isPatchSaved() const
102  {
105  return true; // like m_bItemStatic or IsUIDStatic()
106  }
107  bool isTopLevel() const; // is visible. m_eParentSlot >= 0
108 
109  virtual void UpdatePosition(); // update/recalc the matrix and m_BSphere from rotation,parent position. (assume parent was called first)
110 
112  {
115  return m_pParentCont;
116  }
117 
119  {
122  if (m_pParentCont == nullptr)
123  return nullptr;
124  if (m_pParentCont->get_XObjTypeId() != RESTYPEID_MapEntity)
125  return nullptr;
126  return SMARTS_CAST(cMapPatch, m_pParentCont);
127  }
128 
129  virtual void put_Scale1(float fScale)
130  {
131  m_ParentRel.put_Scale1(fScale);
132  // Apply scale to my children that use m_bFlagParentScale in UpdatePosition()
133  m_bParentRelChanged = true;
134  // virtual override to do other stuff if scale changes.
135  }
136 
137  const cVector3f& get_Center() const
138  {
139  // Get bsphere center in DX coords adjusted for rotation. not the same as feet position.
140  return m_BSphere.get_Center();
141  }
142  cPoint3f get_CenterW() const;
143 
144  const cVector3f& get_Position() const
145  {
147  return m_vPosition;
148  }
149  cPoint3f get_PosW() const; // true world position in map coords.
150  void put_Position(const cVector3f& vPos);
151 
153  {
154  return m_vPosition.y; // height in world coords.
155  }
156  void put_PositionHeight(MAP_METERf_t fGround);
157 
159  CMapMoverPtr get_Mover() const; // don't create mover. may be nullptr.
160  void StopMover();
161 
162  private:
163  cXObjectPtr m_pParentCont;
164  OBJ_SLOT_TYPE m_eParentSlot;
165  CMapMoverPtr m_pMover;
166 
167  public:
172 
173  public:
177  protected:
178 #ifdef USE_DEBUG_OFFSETTEST
179  cPoint3f m_PosWorld;
180  UINT m_dwPosFrameOffset;
181 #endif
182  };
183 
185 };
186 
187 #endif
#define GRAYMAPDATA_LINK
Definition: GrayMapData.h:13
#define MAKEFOURCC(ch0, ch1, ch2, ch3)
Definition: cFourCC.h:24
#define MAP_SIZE(lod)
size of a patch (in meters (MAP_METERI_t))
Definition: cMapBase.h:46
#define SMARTS_CAST(_DSTCLASS, p)
Definition: cPtrFacade.h:138
Definition: cMatrix.h:194
Definition: cMatrix.h:811
Definition: cSphere.h:20
Definition: cVector.h:94
Definition: cMapBase.h:188
Definition: cMapEntity.h:46
bool m_bFlagPhysics
(SAVED) This can/might move ? tho may be at rest now. dynamic objects not saved in map script ?
Definition: cMapEntity.h:70
bool m_bFlagInsubstantial
(SAVED) Can things pass through this? NOTE: use m_bFlagCollide to find if I collide with others when ...
Definition: cMapEntity.h:67
bool m_bFlagHover
(SAVED) Gravity DOES NOT act on this. (true=flying/swimming). NOT relative to height map.
Definition: cMapEntity.h:66
bool m_bFlagParentScale
(SAVED) Include my parents scaling matrix if i have a parent object. (offset+scale of parent) default...
Definition: cMapEntity.h:65
bool isSolid() const
Definition: cMapEntity.h:56
bool m_bFlagTerrainCut
(SAVED) Consider interior/children to carve in ground - disable terrain collision checks
Definition: cMapEntity.h:68
Definition: cMapEntity.h:76
cMatrixDecomp4 m_ParentRel
parent relative offset, rotation and scale. (SAVED)
Definition: cMapEntity.h:168
MAP_METER_t get_PositionHeight() const
Definition: cMapEntity.h:152
virtual void UpdatePosition()
virtual cXObjectPtr get_ContainerObject() const
Definition: cMapEntity.h:111
const cVector3f & get_Center() const
Definition: cMapEntity.h:137
cVector3f m_vPosition
computed DX World coords position. (feet/root/origin position is not the same as m_BSphere pos)
Definition: cMapEntity.h:174
cSpheref m_BSphere
bounding sphere is oriented, scaled, in world (translated by m_ParentRel * parent chain).
Definition: cMapEntity.h:175
MAP_METERI_t get_PatchSize() const
Definition: cMapEntity.h:96
cMatrix4x4f m_mWorld
location + scale + orientation in world.
Definition: cMapEntity.h:176
const cVector3f & get_Position() const
Definition: cMapEntity.h:144
virtual bool isPatchSaved() const
Definition: cMapEntity.h:101
cMapPatchPtr get_ParentPatch() const
Definition: cMapEntity.h:118
bool m_bParentRelChanged
Must call UpdatePosition() to recalc m_vPosition, m_BSphere, m_mWorld, etc. from m_ParentRel and all ...
Definition: cMapEntity.h:169
CMapMoverPtr get_Mover() const
cNewPtr< CMapMovable > m_pMoveable
params if this might move.
Definition: cMapEntity.h:171
CMapMoverPtr MakeMover()
virtual void put_Scale1(float fScale)
Definition: cMapEntity.h:129
virtual MAP_LOD_TYPE get_PatchLod() const
Definition: cMapEntity.h:90
virtual cMapBase * get_MapBase() const =0
OBJ_SAVE_TYPE m_eSaveType
How is the entity persisted ?
Definition: cMapEntity.h:170
Definition: cMapPatch.h:23
Definition: cIUnkPtr.h:32
Definition: cNewPtr.h:18
Definition: IScriptableObj.h:71
double MAP_METER_t
float meters for x,y,z, similar to MAP_METERI_t. also D3DVALUE or DVALUEDEF_t METERSf_t
Definition: cMapCommon.h:22
FOURCC XOBJTID_t
a unique FOURCC id for a type of XObject, 0=k_XOBJTID_NULL, MAKEFOURCC(a,b,c,d). Equiv to GUID for IU...
Definition: IXObject.h:42
Definition: GrayMapData.cpp:12
OBJ_SAVE_TYPE
Definition: cMapEntity.h:34
@ OBJ_SAVE_Server
Definition: cMapEntity.h:38
@ OBJ_SAVE_Temporary
Definition: cMapEntity.h:41
@ OBJ_SAVE_Script
Definition: cMapEntity.h:37
@ OBJ_SAVE_Multi
Definition: cMapEntity.h:40
@ OBJ_SAVE_QTY
Definition: cMapEntity.h:42
@ OBJ_SAVE_Template
Definition: cMapEntity.h:39
cIUnkPtr< cMapEntity > cMapEntityPtr
Definition: cMapEntity.h:184
MAP_LOD_TYPE
Definition: cMapBase.h:27
@ MAP_LOD_SECTOR
Definition: cMapBase.h:33
int MAP_METERI_t
integer meters for the location of a patch. MAP_METER_t
Definition: cMapKeys.h:16
cRefPtr< CMapMover > CMapMoverPtr
Definition: cMapEntity.h:30
float MAP_METERf_t
Height meters dont need double accuracy. MAP_METER_t.
Definition: cMapKeys.h:17