Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Object.h

Go to the documentation of this file.
00001 #ifndef _OBJECT_H_
00002 #define _OBJECT_H_
00003 
00004 // some standard includes everything will need
00005 #include <iostream>
00006 #include <fstream>
00007 #include <string>
00008 #include <vector>
00009 #include <cmath>
00010 using namespace std;
00011 
00012 #include <GL/gl.h>
00013 #include <GL/glu.h>
00014 #include <GL/glext.h>
00015 
00016 #include <AL/al.h>
00017 
00018 #include "Audio.h"
00019 #include "GLExtensions.h"
00020 #include "Vector2.h"
00021 #include "Vector3.h"
00022 #include "FileLoader.h"
00023 #include "ObjectFactory.h"
00024 #include "ObjLoader.h"
00025 #include "Texture.h"
00026 
00032 class Object
00033 {
00034  public:
00035   Object(string filename = "");
00036   virtual ~Object();
00037 
00038   virtual void draw();
00039 
00040   virtual void setInitialTranslate(Vector3 translate) { _initialTranslate = translate; }
00041   Vector3 getInitialTranslate() { return _initialTranslate; }
00042   double getInitialTranslateX() { return _initialTranslate.getX(); }
00043   double getInitialTranslateZ() { return _initialTranslate.getZ(); }
00044   void translate(Vector3 translate) { _currentTranslate = translate; }
00045   Vector3 getTranslate() { return _currentTranslate; }
00046   void translateY(double y) { _currentTranslate.setY(y); }
00047   void translateZ(double z) { _currentTranslate.setZ(z); }
00048   double getTranslateX() { return _currentTranslate.getX(); }
00049   double getAllTranslateX() { return _currentTranslate.getX() + _initialTranslate.getX(); }
00050   double getTranslateY() { return _currentTranslate.getY(); }
00051   double getTranslateZ() { return _currentTranslate.getZ(); }
00052   double getAllTranslateZ() { return _currentTranslate.getZ() + _initialTranslate.getZ(); }
00053   Vector3 getAllTranslate() { return _currentTranslate + _initialTranslate; }
00054 
00055   void rotate(Vector3 rotate) { _currentRotate = rotate; }
00056   void rotateX(double x) { _currentRotate.setX(x); }
00057   void rotateY(double y) { _currentRotate.setY(y); }
00058   void rotateZ(double z) { _currentRotate.setZ(z); }
00059   double getRotateX() { return _currentRotate.getX(); }
00060   double getRotateY() { return _currentRotate.getY(); }
00061   double getRotateZ() { return _currentRotate.getZ(); }
00062 
00063   void scale(Vector3 scale) { _currentScale = scale; }
00064 
00065   long getID() { return _id; }
00066   void setName(string s) { _name = s; }
00067   string getName() { return _name; }
00068 
00069   static vector < Object * > getAllObjects() { return _allObjects; }
00070   static void addObject(Object *t) { _allObjects.push_back(t); _currentID++; }
00071   static void removeObject(long id);
00072 
00073   void loadObject(string filename);
00074   void loadTexture(string filename);
00075   void loadSound(string filename, Vector3 position, Vector3 velocity);
00076   void loadSound(string filename);
00077 
00085   void changeSize(int size);
00086   virtual void setScaleSize(int i) { _scaleSize = i; }
00087 
00088   virtual void nextTexture() { _currentTexture++; if (_currentTexture >= _numTextures) _currentTexture = 0; }
00089 
00090   double getCollisionRadius() { return _collisionRadius; }
00091 
00096   vector < string > getActionList() { return _actionList; }
00100   void addAction(string t) { _actionList.push_back(t); }
00101 
00102  protected:
00103   Vector3 findClosestPositionX(Vector3 position);
00104 
00105   void createDisplayList();
00106 
00107   string _filename;
00108   FileLoader *_fileLoader;
00109 
00110   // textures
00111   static Texture _texture;
00112   GLuint _textureList[100];
00113   int _numTextures;
00114   int _currentTexture;
00115   
00116   // display list
00117   bool _hasGLList;
00118   GLuint _glList[1];
00119 
00120   // audio
00121   static Audio _audio;
00122   ALuint _soundList[100];
00123   int _numSounds;
00124   OggStream *_oggStream;
00125 
00126   vector < Vector3 > _faces;
00127   vector < Vector3 > _normals;
00128   vector < Vector2 > _textures;
00129  
00130   Vector3 _initialTranslate;
00131   Vector3 _initialRotate;
00132   Vector3 _initialScale;
00133 
00134   Vector3 _currentTranslate;
00135   Vector3 _currentRotate;
00136   Vector3 _currentScale;
00137 
00138   // used to hold all the possible
00139   //  actions this object is
00140   //  capable of
00141   vector < string > _actionList;
00142 
00143   // collision detection using a bounding sphere
00144   double _collisionRadius;
00145 
00146   int _scaleSize;
00147   long _id;
00148   string _name;
00149 
00150   // map info
00151   static vector < Object * > _allObjects;
00152   static long _currentID;
00153 };
00154 
00155 #endif

Generated on Wed Apr 21 11:10:53 2004 for naturecalls by doxygen1.2.18