1 | #pragma once
|
---|
2 | #include "Node.h"
|
---|
3 | #include "Vector.h"
|
---|
4 | #include "NxPhysics.h"
|
---|
5 | #include <string>
|
---|
6 |
|
---|
7 | class Sprite :
|
---|
8 | public Node
|
---|
9 | {
|
---|
10 | public:
|
---|
11 | Sprite(void);
|
---|
12 | ~Sprite(void);
|
---|
13 |
|
---|
14 | void setDimension(float _width, float _height);
|
---|
15 | virtual void update(float dt);
|
---|
16 | virtual void generatePhysicMesh(int type=0);
|
---|
17 |
|
---|
18 | virtual Node* clone();
|
---|
19 |
|
---|
20 | void setLookAtCamera(bool _lookAtCamera);
|
---|
21 | void setTexture(std::string _textureName);
|
---|
22 | void setFPS(int _fps);
|
---|
23 | void setFrameCount(int _frameCount);
|
---|
24 | void setRowColumnCount(int _nbRows, int _nbColumns);
|
---|
25 | void setLoopAnimation(bool _loopAnimation);
|
---|
26 |
|
---|
27 | void setAlpha(float _alpha);
|
---|
28 | float getMinDim();
|
---|
29 |
|
---|
30 | static const int KEY_START = 0;
|
---|
31 | static const int KEY_MIDDLE = 1;
|
---|
32 | static const int KEY_END = 2;
|
---|
33 | void setKeyFrame(int _keyFrame, float alpha, float red, float green, float blue, float width, float height, float time);
|
---|
34 |
|
---|
35 | void setSphereSizeFactor(float _sphereSizeFactor);
|
---|
36 | float currentValues[7];
|
---|
37 | IDirect3DTexture9* texture;
|
---|
38 | bool firstRendering;
|
---|
39 |
|
---|
40 | static const int KF_RED = 0;
|
---|
41 | static const int KF_GREEN = 1;
|
---|
42 | static const int KF_BLUE = 2;
|
---|
43 | static const int KF_ALPHA = 3;
|
---|
44 | static const int KF_HWIDTH = 4;
|
---|
45 | static const int KF_HHEIGHT = 5;
|
---|
46 | static const int KF_TIME = 6;
|
---|
47 |
|
---|
48 | bool animatedSprite;
|
---|
49 | int activeFrame;
|
---|
50 | float invRows;
|
---|
51 | float invColumns;
|
---|
52 | int nbRows;
|
---|
53 | int nbColumns;
|
---|
54 |
|
---|
55 | protected:
|
---|
56 |
|
---|
57 | float keyFrame[3][7];
|
---|
58 |
|
---|
59 |
|
---|
60 | void calcCurrentValues(float age);
|
---|
61 |
|
---|
62 | int fps;
|
---|
63 | float invFps;
|
---|
64 | float animationDuration;
|
---|
65 | float maxDuration;
|
---|
66 | float sphereSizeFactor;
|
---|
67 | int nbFrames;
|
---|
68 | bool loopAnimation;
|
---|
69 |
|
---|
70 |
|
---|
71 | bool firstTime;
|
---|
72 | bool lookAtCamera;
|
---|
73 | NxSphereShapeDesc sphereDesc;
|
---|
74 | float halfWidth;
|
---|
75 | float halfHeight;
|
---|
76 | Vector rightVec;
|
---|
77 | Vector upVec;
|
---|
78 | virtual void calcPhysicWorldMatrix(D3DXMATRIX &pMatWorld);
|
---|
79 | std::string textureName;
|
---|
80 |
|
---|
81 | struct Vertex
|
---|
82 | {
|
---|
83 | Vertex(float _x, float _y, float _z, float _u, float _v)
|
---|
84 | {
|
---|
85 | x = _x;
|
---|
86 | y = _y;
|
---|
87 | z = _z;
|
---|
88 | u = _u;
|
---|
89 | v = _v;
|
---|
90 | }
|
---|
91 |
|
---|
92 | Vertex(Vector vec, float _u, float _v)
|
---|
93 | {
|
---|
94 | x = vec.x;
|
---|
95 | y = vec.y;
|
---|
96 | z = vec.z;
|
---|
97 | u = _u;
|
---|
98 | v = _v;
|
---|
99 | }
|
---|
100 |
|
---|
101 | float x, y, z, u, v;
|
---|
102 | };
|
---|
103 |
|
---|
104 | const static DWORD FVF_Flags = D3DFVF_XYZ | D3DFVF_TEX1;
|
---|
105 |
|
---|
106 | float alpha;
|
---|
107 | };
|
---|