| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- /*
- * PolyEntity.h
- * Poly
- *
- * Created by Ivan Safrin on 1/18/09.
- * Copyright 2009 __MyCompanyName__. All rights reserved.
- *
- */
- // @package BasicTypes
- #pragma once
- #include "PolyString.h"
- #include "PolyLogger.h"
- #include "PolyGlobals.h"
- #include "PolyMatrix4.h"
- #include "PolyQuaternion.h"
- #include "PolyColor.h"
- #include "PolyRenderer.h"
- #include <vector>
- using std::vector;
- namespace Polycode {
-
-
- class _PolyExport EntityProp {
- public:
- String propName;
- String propValue;
- };
- class _PolyExport Entity {
- public:
- Entity();
- ~Entity();
- virtual void Render(){};
- virtual void Update(){};
- virtual void transformAndRender();
-
- void setMatrix(Matrix4 matrix);
- void rebuildTransformMatrix();
-
- void addEntity(Entity *newChild);
- void addChild(Entity *newChild);
- void removeChild(Entity *entityToRemove);
-
- void updateEntityMatrix();
- void renderChildren();
- Vector3 getPosition();
- void setPosition(Number x, Number y, Number z);
-
- void setPositionX(Number x);
- void setPositionY(Number y);
- void setPositionZ(Number z);
- void setScaleX(Number x);
- void setScaleY(Number y);
- void setScaleZ(Number z);
-
-
- void setPosition(Vector3 posVec);
-
- void Translate(Number x, Number y, Number z);
- void Translate(Vector3 tVec);
- void Scale(Number x, Number y, Number z);
- void setScale(Number x, Number y, Number z);
- Vector3 getScale();
-
- Vector3 getCombinedPosition();
- Number getCombinedPitch();
- Number getCombinedYaw();
- Number getCombinedRoll();
- void setParentEntity(Entity *entity);
- Entity *getParentEntity();
- void rebuildRotation();
- void dirtyMatrix(bool val);
-
- void setPitch(Number pitch);
- void setYaw(Number yaw);
- void setRoll(Number roll);
- void Roll(Number roll);
- void Yaw(Number roll);
- void Pitch(Number roll);
- Number getPitch();
- Number getYaw();
- Number getRoll();
-
- void setRotationQuat(Number w, Number x, Number y, Number z);
- Quaternion getRotationQuat();
-
- Matrix4 getTransformMatrix();
- Matrix4 getConcatenatedMatrix();
- Matrix4 getConcatenatedRollMatrix();
-
- void setTransformByMatrix(Matrix4 matrix);
- void setTransformByMatrixPure(Matrix4 matrix);
-
- void setRenderer(Renderer *renderer);
-
- Color getCombinedColor();
- void setColor(Number r, Number g, Number b, Number a);
- void setColorInt(int r, int g, int b, int a);
- void setColor(Color color);
-
- void recalculateBBox();
- Number getBBoxRadius();
- Number getCompoundBBoxRadius();
- void setBBoxRadius(Number rad);
- void setBlendingMode(int newBlendingMode);
- Vector3 getChildCenter();
-
- void setDepthWrite(bool val);
-
- void doUpdates();
-
- void lookAt(const Vector3 &loc, const Vector3 &upVector = Vector3(0,1,0));
- void lookAtEntity(Entity *entity, const Vector3 &upVector = Vector3(0,1,0));
- Matrix4 getLookAtMatrix(const Vector3 &loc, const Vector3 &upVector = Vector3(0,1,0));
-
- virtual Matrix4 buildPositionMatrix();
- virtual void adjustMatrixForChildren(){}
-
- void setMask(Entity *mask);
- void clearMask();
-
- Vector3 getCompoundScale();
-
- String custEntityType;
- vector <EntityProp> entityProps;
-
- String getEntityProp(String propName);
-
- Vector3 bBox;
- bool billboardMode;
- bool billboardRoll;
- bool alphaTest;
- bool backfaceCulled;
-
- bool renderWireframe;
-
- Color color;
- bool enabled;
- bool visible;
-
- bool depthWrite;
- bool depthTest;
-
- bool colorAffectsChildren;
- bool depthOnly;
-
- bool ignoreParentMatrix;
-
- // deprecated, remove!
- bool maskByZbuffer;
-
- bool isMask;
-
- protected:
- vector<Entity*> children;
- int blendingMode;
- Vector3 childCenter;
- Number bBoxRadius;
-
- Vector3 position;
- Vector3 scale;
-
- bool hasMask;
-
- bool lockMatrix;
- bool matrixDirty;
- Matrix4 transformMatrix;
-
- Number matrixAdj;
- Number pitch;
- Number yaw;
- Number roll;
-
- Entity *parentEntity;
-
- Quaternion qYaw;
- Quaternion qPitch;
- Quaternion qRoll;
- Quaternion rotationQuat;
-
- Entity *maskEntity;
-
-
- Renderer *renderer;
- };
- }
|