#pragma once #include "Node.h" #include "Vector.h" #include "NxPhysics.h" #include class Sprite : public Node { public: Sprite(void); ~Sprite(void); void setDimension(float _width, float _height); virtual void update(float dt); virtual void generatePhysicMesh(int type=0); virtual Node* clone(); void setLookAtCamera(bool _lookAtCamera); void setTexture(std::string _textureName); void setFPS(int _fps); void setFrameCount(int _frameCount); void setRowColumnCount(int _nbRows, int _nbColumns); void setLoopAnimation(bool _loopAnimation); void setAlpha(float _alpha); float getMinDim(); static const int KEY_START = 0; static const int KEY_MIDDLE = 1; static const int KEY_END = 2; void setKeyFrame(int _keyFrame, float alpha, float red, float green, float blue, float width, float height, float time); void setSphereSizeFactor(float _sphereSizeFactor); float currentValues[7]; IDirect3DTexture9* texture; bool firstRendering; static const int KF_RED = 0; static const int KF_GREEN = 1; static const int KF_BLUE = 2; static const int KF_ALPHA = 3; static const int KF_HWIDTH = 4; static const int KF_HHEIGHT = 5; static const int KF_TIME = 6; bool animatedSprite; int activeFrame; float invRows; float invColumns; int nbRows; int nbColumns; protected: float keyFrame[3][7]; void calcCurrentValues(float age); int fps; float invFps; float animationDuration; float maxDuration; float sphereSizeFactor; int nbFrames; bool loopAnimation; bool firstTime; bool lookAtCamera; NxSphereShapeDesc sphereDesc; float halfWidth; float halfHeight; Vector rightVec; Vector upVec; virtual void calcPhysicWorldMatrix(D3DXMATRIX &pMatWorld); std::string textureName; struct Vertex { Vertex(float _x, float _y, float _z, float _u, float _v) { x = _x; y = _y; z = _z; u = _u; v = _v; } Vertex(Vector vec, float _u, float _v) { x = vec.x; y = vec.y; z = vec.z; u = _u; v = _v; } float x, y, z, u, v; }; const static DWORD FVF_Flags = D3DFVF_XYZ | D3DFVF_TEX1; float alpha; };