home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / shareware / crystalppc / csobject.h < prev    next >
C/C++ Source or Header  |  1998-06-08  |  2KB  |  91 lines

  1. #ifndef CSOBJECT_H
  2. #define CSOBJECT_H
  3.  
  4. #ifndef MATH3D_H
  5. #include "math3d.h"
  6. #endif
  7.  
  8. #ifndef SCRIPT_H
  9. #include "script.h"
  10. #endif
  11.  
  12. class Polygon3D;
  13. class Sector;
  14. class World;
  15. class Camera;
  16. class ViewPolygon;
  17. class Textures;
  18.  
  19. // Crystal Space object:
  20. #define CS_SECTOR 0
  21. #define CS_THING 1
  22. #define CS_COLLECTION 2
  23.  
  24. // CsObject is the toplevel class for all objects in the Crystal
  25. // Space engine that can be manipulated by scripts. Currently the
  26. // supported CsObjects are sectors, things and collections.
  27. //
  28. // CsObjects have names and a type (one of CS_...).
  29. // Activate triggers are supported for CsObjects.
  30. //
  31. // All this is not proper object oriented design. CsObject should
  32. // be implemented with virtual functions. But I'm a bit worried that
  33. // this may cause a slowdown. After all these objects are going to
  34. // be used in rather time-critical situations. Maybe I'm worrying
  35. // for nothing.
  36.  
  37. class CsObject
  38. {
  39. protected:
  40.   char name[30];
  41.   int type;        // Type (CS_...).
  42.  
  43.   TriggerList activate_triggers;
  44.  
  45. public:
  46.   CsObject (char* name, int type);
  47.   ~CsObject ();
  48.  
  49.   int get_type () { return type; }
  50.   char* get_name () { return name; }
  51.  
  52.   void new_activate_trigger (Script* script, CsObject* ob = NULL);
  53.   void do_activate_triggers (World* w);
  54. };
  55.  
  56. // A collection object is for conveniance of the script language.
  57. // Objects are (currently) not really hierarchical in Crystal Space.
  58. // A collection simulates a hierarchy. The script can then perform
  59. // operations like 'move' and 'transform' on all the objects in
  60. // the collection together.
  61.  
  62. class Collection : public CsObject
  63. {
  64. private:
  65.   Collection* next;
  66.   CsObject** objects;
  67.   int num_objects;
  68.  
  69. public:
  70.   Collection (char* name);
  71.   ~Collection ();
  72.  
  73.   void set_next (Collection* n) { next = n; }
  74.   Collection* get_next () { return next; }
  75.  
  76.   void set_move (Sector* home, Vector3& v) { set_move (home, v.x, v.y, v.z); }
  77.   void set_move (Sector* home, float x, float y, float z);
  78.   void set_transform (Matrix3& matrix);
  79.   void move (float dx, float dy, float dz);
  80.   void move (Vector3& v) { move (v.x, v.y, v.z); }
  81.   void transform (Matrix3& matrix);
  82.   void transform ();
  83.  
  84.   CsObject* find_object (char* name);
  85.  
  86.   void save (FILE* fp, int indent);
  87.   void load (World* w, char** buf);
  88. };
  89.  
  90. #endif /*CSOBJECT_H*/
  91.