PolyEntity.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * PolyEntity.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 1/18/09.
  6. * Copyright 2009 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package BasicTypes
  10. #pragma once
  11. #include "PolyString.h"
  12. #include "PolyLogger.h"
  13. #include "PolyGlobals.h"
  14. #include "PolyMatrix4.h"
  15. #include "PolyQuaternion.h"
  16. #include "PolyColor.h"
  17. #include "PolyRenderer.h"
  18. #include <vector>
  19. using std::vector;
  20. namespace Polycode {
  21. class _PolyExport EntityProp {
  22. public:
  23. String propName;
  24. String propValue;
  25. };
  26. class _PolyExport Entity {
  27. public:
  28. Entity();
  29. ~Entity();
  30. virtual void Render(){};
  31. virtual void Update(){};
  32. virtual void transformAndRender();
  33. void setMatrix(Matrix4 matrix);
  34. void rebuildTransformMatrix();
  35. void addEntity(Entity *newChild);
  36. void addChild(Entity *newChild);
  37. void removeChild(Entity *entityToRemove);
  38. void updateEntityMatrix();
  39. void renderChildren();
  40. Vector3 getPosition();
  41. void setPosition(Number x, Number y, Number z);
  42. void setPositionX(Number x);
  43. void setPositionY(Number y);
  44. void setPositionZ(Number z);
  45. void setScaleX(Number x);
  46. void setScaleY(Number y);
  47. void setScaleZ(Number z);
  48. void setPosition(Vector3 posVec);
  49. void Translate(Number x, Number y, Number z);
  50. void Translate(Vector3 tVec);
  51. void Scale(Number x, Number y, Number z);
  52. void setScale(Number x, Number y, Number z);
  53. Vector3 getScale();
  54. Vector3 getCombinedPosition();
  55. Number getCombinedPitch();
  56. Number getCombinedYaw();
  57. Number getCombinedRoll();
  58. void setParentEntity(Entity *entity);
  59. Entity *getParentEntity();
  60. void rebuildRotation();
  61. void dirtyMatrix(bool val);
  62. void setPitch(Number pitch);
  63. void setYaw(Number yaw);
  64. void setRoll(Number roll);
  65. void Roll(Number roll);
  66. void Yaw(Number roll);
  67. void Pitch(Number roll);
  68. Number getPitch();
  69. Number getYaw();
  70. Number getRoll();
  71. void setRotationQuat(Number w, Number x, Number y, Number z);
  72. Quaternion getRotationQuat();
  73. Matrix4 getTransformMatrix();
  74. Matrix4 getConcatenatedMatrix();
  75. Matrix4 getConcatenatedRollMatrix();
  76. void setTransformByMatrix(Matrix4 matrix);
  77. void setTransformByMatrixPure(Matrix4 matrix);
  78. void setRenderer(Renderer *renderer);
  79. Color getCombinedColor();
  80. void setColor(Number r, Number g, Number b, Number a);
  81. void setColorInt(int r, int g, int b, int a);
  82. void setColor(Color color);
  83. void recalculateBBox();
  84. Number getBBoxRadius();
  85. Number getCompoundBBoxRadius();
  86. void setBBoxRadius(Number rad);
  87. void setBlendingMode(int newBlendingMode);
  88. Vector3 getChildCenter();
  89. void setDepthWrite(bool val);
  90. void doUpdates();
  91. void lookAt(const Vector3 &loc, const Vector3 &upVector = Vector3(0,1,0));
  92. void lookAtEntity(Entity *entity, const Vector3 &upVector = Vector3(0,1,0));
  93. Matrix4 getLookAtMatrix(const Vector3 &loc, const Vector3 &upVector = Vector3(0,1,0));
  94. virtual Matrix4 buildPositionMatrix();
  95. virtual void adjustMatrixForChildren(){}
  96. void setMask(Entity *mask);
  97. void clearMask();
  98. Vector3 getCompoundScale();
  99. String custEntityType;
  100. vector <EntityProp> entityProps;
  101. String getEntityProp(String propName);
  102. Vector3 bBox;
  103. bool billboardMode;
  104. bool billboardRoll;
  105. bool alphaTest;
  106. bool backfaceCulled;
  107. bool renderWireframe;
  108. Color color;
  109. bool enabled;
  110. bool visible;
  111. bool depthWrite;
  112. bool depthTest;
  113. bool colorAffectsChildren;
  114. bool depthOnly;
  115. bool ignoreParentMatrix;
  116. // deprecated, remove!
  117. bool maskByZbuffer;
  118. bool isMask;
  119. protected:
  120. vector<Entity*> children;
  121. int blendingMode;
  122. Vector3 childCenter;
  123. Number bBoxRadius;
  124. Vector3 position;
  125. Vector3 scale;
  126. bool hasMask;
  127. bool lockMatrix;
  128. bool matrixDirty;
  129. Matrix4 transformMatrix;
  130. Number matrixAdj;
  131. Number pitch;
  132. Number yaw;
  133. Number roll;
  134. Entity *parentEntity;
  135. Quaternion qYaw;
  136. Quaternion qPitch;
  137. Quaternion qRoll;
  138. Quaternion rotationQuat;
  139. Entity *maskEntity;
  140. Renderer *renderer;
  141. };
  142. }