PolyEntity.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 setTransformByMatrixPure(Matrix4 matrix);
  78. void setRenderer(Renderer *renderer);
  79. Color getCombinedColor();
  80. void setColor(float r, float g, float b, float a);
  81. void setColorInt(int r, int g, int b, int a);
  82. void setColor(Color color);
  83. void recalculateBBox();
  84. float getBBoxRadius();
  85. float getCompoundBBoxRadius();
  86. void setBBoxRadius(float 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 colorAffectsChildren;
  112. bool depthOnly;
  113. // deprecated, remove!
  114. bool maskByZbuffer;
  115. bool isMask;
  116. protected:
  117. vector<Entity*> children;
  118. int blendingMode;
  119. Vector3 childCenter;
  120. float bBoxRadius;
  121. Vector3 position;
  122. Vector3 scale;
  123. bool hasMask;
  124. bool lockMatrix;
  125. bool matrixDirty;
  126. Matrix4 transformMatrix;
  127. float matrixAdj;
  128. float pitch;
  129. float yaw;
  130. float roll;
  131. Entity *parentEntity;
  132. Quaternion qYaw;
  133. Quaternion qPitch;
  134. Quaternion qRoll;
  135. Quaternion rotationQuat;
  136. Entity *maskEntity;
  137. bool depthWrite;
  138. Renderer *renderer;
  139. };
  140. }