PolyEntity.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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(float x, float y, float z);
  42. void setPositionX(float x);
  43. void setPositionY(float y);
  44. void setPositionZ(float z);
  45. void setScaleX(float x);
  46. void setScaleY(float y);
  47. void setScaleZ(float z);
  48. void setPosition(Vector3 posVec);
  49. void Translate(float x, float y, float z);
  50. void Translate(Vector3 tVec);
  51. void Scale(float x, float y, float z);
  52. void setScale(float x, float y, float z);
  53. Vector3 getScale();
  54. Vector3 getCombinedPosition();
  55. float getCombinedPitch();
  56. float getCombinedYaw();
  57. float getCombinedRoll();
  58. void setParentEntity(Entity *entity);
  59. Entity *getParentEntity();
  60. void rebuildRotation();
  61. void dirtyMatrix(bool val);
  62. void setPitch(float pitch);
  63. void setYaw(float yaw);
  64. void setRoll(float roll);
  65. void Roll(float roll);
  66. void Yaw(float roll);
  67. void Pitch(float roll);
  68. float getPitch();
  69. float getYaw();
  70. float getRoll();
  71. void setRotationQuat(float w, float x, float y, float z);
  72. Quaternion getRotationQuat();
  73. Matrix4 getTransformMatrix();
  74. Matrix4 getConcatenatedMatrix();
  75. Matrix4 getConcatenatedRollMatrix();
  76. void setTransformByMatrix(Matrix4 matrix);
  77. void setRenderer(Renderer *renderer);
  78. Color getCombinedColor();
  79. void setColor(float r, float g, float b, float a);
  80. void setColorInt(int r, int g, int b, int a);
  81. void setColor(Color color);
  82. void recalculateBBox();
  83. float getBBoxRadius();
  84. float getCompoundBBoxRadius();
  85. void setBBoxRadius(float rad);
  86. void setBlendingMode(int newBlendingMode);
  87. Vector3 getChildCenter();
  88. void setDepthWrite(bool val);
  89. void doUpdates();
  90. void lookAt(const Vector3 &loc, const Vector3 &upVector = Vector3(0,1,0));
  91. void lookAtEntity(Entity *entity, const Vector3 &upVector = Vector3(0,1,0));
  92. Matrix4 getLookAtMatrix(const Vector3 &loc, const Vector3 &upVector = Vector3(0,1,0));
  93. virtual Matrix4 buildPositionMatrix();
  94. virtual void adjustMatrixForChildren(){}
  95. void setMask(Entity *mask);
  96. void clearMask();
  97. Vector3 getCompoundScale();
  98. String custEntityType;
  99. vector <EntityProp> entityProps;
  100. String getEntityProp(String propName);
  101. Vector3 bBox;
  102. bool billboardMode;
  103. bool billboardRoll;
  104. bool alphaTest;
  105. bool backfaceCulled;
  106. bool renderWireframe;
  107. Color color;
  108. bool enabled;
  109. bool visible;
  110. bool colorAffectsChildren;
  111. bool depthOnly;
  112. // deprecated, remove!
  113. bool maskByZbuffer;
  114. bool isMask;
  115. protected:
  116. vector<Entity*> children;
  117. int blendingMode;
  118. Vector3 childCenter;
  119. float bBoxRadius;
  120. Vector3 position;
  121. Vector3 scale;
  122. bool hasMask;
  123. bool lockMatrix;
  124. bool matrixDirty;
  125. Matrix4 transformMatrix;
  126. float matrixAdj;
  127. float pitch;
  128. float yaw;
  129. float roll;
  130. Entity *parentEntity;
  131. Quaternion qYaw;
  132. Quaternion qPitch;
  133. Quaternion qRoll;
  134. Quaternion rotationQuat;
  135. Entity *maskEntity;
  136. bool depthWrite;
  137. Renderer *renderer;
  138. };
  139. }