00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _OBJECTMANAGER_
00018 #define _OBJECTMANAGER_
00019
00020 #include <objframe.hpp>
00021 #include <time.h>
00022 #include <camera.hpp>
00023 #include <stopwatch.hpp>
00024
00025 class ObjectManager : public Object
00026 {
00027 private:
00028
00029 int RecordingOn, PlaybackOn;
00030 FILE *RecordPlaybackFP;
00031
00032 void AddObjectFrame(Object *Obj);
00033 void DeleteObjectFrame(int iObjInstances);
00034
00035 clock_t PlaybackTime;
00036 Stopwatch watch;
00037 float markedTime;
00038
00039 public:
00040
00041 int ObjectDrawingOn;
00042 int SelectionBoxDrawingOn;
00043
00044
00045 ObjectFrame* *ObjInstances;
00046 int NumObjInstances, NumObjInstancesAlloced;
00047 int *IsSelected;
00048
00049
00050 Object* *Objects;
00051 int NumObjects, NumObjectsAlloced;
00052
00053 ObjectManager();
00054 ~ObjectManager();
00055
00056 void AddObject(Object *Obj);
00057 void DeleteObject(int iObjInstance);
00058 void CopyObject(int iObjInstance);
00059
00060 void UpdatePathRecPlayback();
00061
00062 virtual void UpdateMinMax();
00063 virtual void Display(unsigned int Attribs=OBJ_ALL);
00064 void ToggleObjectDrawing();
00065 void ToggleSelectionBoxDrawing();
00066
00067 int SelectObject(Vec3f &Start, Vec3f &Dir, Vec3f *HitPt=NULL, float *HitDist=NULL);
00068 void Select(int iObj);
00069 int IsAlreadySelected(int iObj);
00070 void DeselectAll();
00071 void ToggleSelect(int iObj);
00072
00073 void RotateSelected(float Ang, Vec3f &Axis);
00074 void TranslateSelected(Vec3f &T);
00075 void ScaleSelected(float S);
00076 void DeleteSelected();
00077 void CopySelected();
00078
00079 Vec3f ObjCntr(int iObj);
00080
00081 void StartRecording(char *FileName);
00082 void EndRecording();
00083 void StartPlayback(char *FileName);
00084 void EndPlayback();
00085 void StopRecordingPlayback();
00086
00087 int ReadInstancesFromFile(FILE *fp);
00088 void WriteInstancesToFile(FILE *fp);
00089
00090 void GetMinMax(Vec3f &Min, Vec3f &Max);
00091
00092
00093 void ResetTime() { markedTime = 0; watch.Reset(); }
00094 void ApplyGravity(int whichObject);
00095 void UpdatePosition(int whichObject);
00096 void UpdateAllPositions();
00097 bool CollisionTest(GLfloat *depth, const GLint vp[4],
00098 GLdouble modelview[16], GLdouble projection[16],
00099 int whichObject, Vec3f &collisionPt,
00100 const GLint Buffer=GL_BACK);
00101
00102
00103 };
00104
00105 #endif
00106