00001 #ifndef _ITEM_H
00002 #define _ITEM_H
00003
00004 #include "Skin.h"
00005 #include "math/matrix34.h"
00006 #include "math/vector3.h"
00007 #include "actor/Token.h"
00008 #include "opengl.h"
00009 #include "sceneManagement/sceneObject.h"
00010
00011 class Item : public SceneObject {
00012 public:
00013 Item() {}
00014 Item(int type, Vector3 &location) : sceneObjectType(type), showSkin(true) {
00015 if(type == felled_tree)
00016 {
00017
00018
00019 world.MakeRotateZ(M_PI/2.0f);
00020
00021 }
00022 else
00023 world.MakeRotateX(M_PI/2.0f);
00024 world.d = location;
00025 }
00026 virtual ~Item() {}
00027 int objectType() { return sceneObjectType; }
00028 void init() {}
00029 void Load(char *filename) {
00030 Tokenizer tokens;
00031 tokens.Open(filename);
00032 skin.Load(tokens);
00033 tokens.Close();
00034 skin.AllocateVertexArrays();
00035 for(int i = 0; i < skin.numVerts; i++)
00036 {
00037 skin.norms[i] = skin.skinVerts[i].normal;
00038 world.Transform3x3(skin.skinVerts[i].pos, skin.verts[i]);
00039 }
00040 }
00041 void update(float dt) {}
00042 void draw() {
00043 glPushMatrix();
00044 glTranslatef(world.d.x,world.d.y,world.d.z);
00045 if(showSkin)
00046 skin.Draw();
00047 glPopMatrix();
00048 }
00049 const Vector3& getPos() const { return world.d; }
00050 const float getBottom() const { return 0.0f; }
00051 const float getTop() const {
00052 if(sceneObjectType >= powerup_rapid_fire && sceneObjectType <= powerup_health) {
00053 return 3.0f;
00054 }
00055 return 0.5f;
00056 }
00057
00058 const float getRadius() const {
00059 if(sceneObjectType >= powerup_rapid_fire && sceneObjectType <= powerup_health) {
00060 return 5.0f;
00061 }
00062 return 0.5f;
00063 }
00064
00065 void ToggleSkin() { showSkin = !showSkin; }
00066 public:
00067 Skin skin;
00068 Matrix34 world;
00069 bool showSkin;
00070 int sceneObjectType;
00071
00072 };
00073 #endif //_ITEM_H