PolyEntity.h 3.9 KB

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