Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

objmngr.hpp

00001 //==========================================================================
00002 // objmngr.hpp : object manager class definition (integrated w/ Object class).
00003 //   The purpose of this class it to manage a list (dynamic array) of
00004 //   objects in a scene for display and manipulation. The following routines
00005 //   are provided:
00006 //   1) a global OpenGL display routine (display all objects).
00007 //   2) Object manipulation management routines:
00008 //      a) used to interpret mouse clicks and movements (NOT A MOUSE EVENT HANDLER)
00009 //      b) handles object selection
00010 //      c) handles object manipulation (trackball, translate, etc.).
00011 //      d) objects are manipulated as OBBs only. The object's display
00012 //         routine handles proper orientation of the actual object.
00013 //   3) handles insertion and deletion of new objects of various types.
00014 //   4) handles instancing of objects automatically.
00015 //==========================================================================
00016 
00017 #ifndef _OBJECTMANAGER_
00018 #define _OBJECTMANAGER_
00019 
00020 #include <objframe.hpp>   // OBJECT INSTANCE TYPE (COORD FRAME)
00021 #include <time.h>         // FOR TIMED OBJ ANIMATION PLAYBACK
00022 #include <camera.hpp>
00023 #include <stopwatch.hpp>
00024 
00025 class ObjectManager : public Object
00026 {
00027   private:
00028 
00029     int RecordingOn, PlaybackOn;      // OBJ INSTANCE RECORDING/PLAYBACK FLAGS
00030     FILE *RecordPlaybackFP;           // RECORDING/PLAYBACK FILE POINTER
00031 
00032     void AddObjectFrame(Object *Obj);
00033     void DeleteObjectFrame(int iObjInstances);
00034 
00035     clock_t PlaybackTime;             // FOR OBJ ANIMATION PLAYBACK TIMING
00036     Stopwatch watch;                  // For Physics timing
00037     float markedTime;
00038   
00039   public:
00040 
00041     int ObjectDrawingOn;              // GLOBAL DRAWING OF OBJECTS FLAG
00042     int SelectionBoxDrawingOn;        // DRAWING OF BOUNDING BOXES AROUND SELECTED OBJS
00043 
00044     // OBJECT INSTANCE ARRAY
00045     ObjectFrame* *ObjInstances;       // ARRAY OF PTRS TO INSTANCED OBJECT'S COORD FRAMES
00046     int NumObjInstances, NumObjInstancesAlloced;
00047     int *IsSelected;                  // SELECTION FLAGS FOR ALL OBJ INSTANCES
00048 
00049     // MAIN OBJECT LIST (INSTANCES HAVE PTRS TO OBJECTS IN HERE)
00050     Object* *Objects;                 // ARRAY OF PTRS TO OBJECTS (OBJS ARE ALLOCED BY USER)
00051     int NumObjects, NumObjectsAlloced;
00052 
00053     ObjectManager();
00054     ~ObjectManager();
00055 
00056     void AddObject(Object *Obj);      // USER ROUTINES TO ADD AND DELETE INSTANCES
00057     void DeleteObject(int iObjInstance);
00058     void CopyObject(int iObjInstance);
00059 
00060     void UpdatePathRecPlayback();     // CALLED AT BEGINNING OF EVERY FRAME FOR REC/PLAYBACK OF OBJS
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     // physics stuff
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 

Generated at Fri Oct 12 15:12:21 2001 for GLVU by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001