home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / Camera.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  8KB  |  297 lines

  1.  
  2. #ifndef __GAME_CAMERA_H__
  3. #define __GAME_CAMERA_H__
  4.  
  5. /*
  6. ===============================================================================
  7.  
  8. Camera providing an alternative view of the level.
  9.  
  10. ===============================================================================
  11. */
  12.  
  13. class idCamera : public idEntity {
  14. public:
  15.     ABSTRACT_PROTOTYPE( idCamera );
  16.  
  17.     void                    Spawn( void );
  18.     virtual void            GetViewParms( renderView_t *view ) = 0;
  19.     virtual renderView_t *    GetRenderView();
  20.     virtual void            Stop( void ){} ;
  21. };
  22.  
  23. /*
  24. ===============================================================================
  25.  
  26. idCameraView
  27.  
  28. ===============================================================================
  29. */
  30.  
  31. extern const idEventDef EV_SetFOV;
  32. extern const idEventDef EV_Camera_Start;
  33. extern const idEventDef EV_Camera_Stop;
  34.  
  35. class idCameraView : public idCamera {
  36. public:
  37.     CLASS_PROTOTYPE( idCameraView );
  38.                              idCameraView();
  39.                              
  40.     // save games
  41.     void                    Save( idSaveGame *savefile ) const;                // archives object for save game file
  42.     void                    Restore( idRestoreGame *savefile );                // unarchives object from save game file
  43.  
  44.     void                    Spawn( );
  45.     virtual void            GetViewParms( renderView_t *view );
  46.     virtual void            Stop( void );
  47.  
  48. protected:
  49.     void                    Event_Activate( idEntity *activator );
  50.     void                    Event_SetAttachments();
  51.     void                    SetAttachment( idEntity **e, const char *p );
  52. // RAVEN BEGIN
  53. // bdube: changed fov to interpolated value
  54.     idInterpolate<float>    fov;
  55. // RAVEN END
  56.     idEntity                *attachedTo;
  57.     idEntity                *attachedView;
  58.  
  59. // RAVEN BEGIN
  60. // bdube: added setfov event
  61.     void                    Event_SetFOV        ( float fov );
  62.     void                    Event_BlendFOV        ( float beginFOV, float endFOV, float blendTime );
  63.     void                    Event_GetFOV        ( void );
  64. // RAVEN END
  65. };
  66.  
  67.  
  68.  
  69. /*
  70. ===============================================================================
  71.  
  72. A camera which follows a path defined by an animation.
  73.  
  74. ===============================================================================
  75. */
  76.  
  77. // RAVEN BEGIN
  78. // rjohnson: camera is now contained in a def for frame commands
  79.  
  80. /*
  81. ==============================================================================================
  82.  
  83.     rvCameraAnimation
  84.  
  85. ==============================================================================================
  86. */
  87. class idDeclCameraDef;
  88.  
  89. typedef struct {
  90.     idCQuat                q;
  91.     idVec3                t;
  92.     float                fov;
  93. } cameraFrame_t;
  94.  
  95. class rvCameraAnimation {
  96. private:
  97.     idList<int>                    cameraCuts;
  98.     idList<cameraFrame_t>        camera;
  99.     idList<frameLookup_t>        frameLookup;
  100.     idList<frameCommand_t>        frameCommands;
  101.     int                            frameRate;
  102.     idStr                        name;
  103.     idStr                        realname;
  104.  
  105. public:
  106.                                 rvCameraAnimation();
  107.                                 rvCameraAnimation( const idDeclCameraDef *cameraDef, const rvCameraAnimation *anim );
  108.                                 ~rvCameraAnimation();
  109.  
  110.     void                        SetAnim( const idDeclCameraDef *cameraDef, const char *sourcename, const char *animname, idStr filename );
  111.     const char                    *Name( void ) const;
  112.     const char                    *FullName( void ) const;
  113.     int                            NumFrames( void ) const;
  114.     const cameraFrame_t *        GetAnim( int index ) const;
  115.     int                            NumCuts( void ) const;
  116.     const int                    GetCut( int index ) const;
  117.     const int                    GetFrameRate( void ) const;
  118.  
  119.     const char                    *AddFrameCommand( const class idDeclCameraDef *cameraDef, const idList<int>& frames, idLexer &src, const idDict *def );
  120.     void                        CallFrameCommands( idEntity *ent, int from, int to ) const;
  121.     void                        CallFrameCommandSound ( const frameCommand_t& command, idEntity* ent, const s_channelType channel ) const;
  122. };
  123.  
  124. ID_INLINE const cameraFrame_t *rvCameraAnimation::GetAnim( int index ) const {
  125.     return &camera[ index ];
  126. }
  127.  
  128. ID_INLINE const int rvCameraAnimation::GetCut( int index ) const {
  129.     return cameraCuts[ index ];
  130. }
  131.  
  132. ID_INLINE const int rvCameraAnimation::GetFrameRate( void ) const {
  133.     return frameRate;
  134. }
  135.  
  136. /*
  137. ==============================================================================================
  138.  
  139.     idDeclCameraDef
  140.  
  141. ==============================================================================================
  142. */
  143. // RAVEN BEGIN
  144. // jsinger: added to support serialization/deserialization of binary decls
  145. #ifdef RV_BINARYDECLS
  146. class idDeclCameraDef : public idDecl, public Serializable<'IDCD'> {
  147. public:
  148.                                 idDeclCameraDef( SerialInputStream &stream );
  149.                                 
  150.     virtual void                Write( SerialOutputStream &stream ) const;
  151.     virtual void                AddReferences() const;
  152. #else
  153. class idDeclCameraDef : public idDecl {
  154. #endif
  155. // RAVEN END
  156. public:
  157.                                 idDeclCameraDef();
  158.                                 ~idDeclCameraDef();
  159.  
  160.     virtual size_t                Size( void ) const;
  161.     virtual const char *        DefaultDefinition( void ) const;
  162.     virtual bool                Parse( const char *text, const int textLength, bool noCaching );
  163.     virtual void                FreeData( void );
  164.  
  165. // RAVEN BEGIN
  166. // jscott: to prevent a recursive crash
  167.     virtual    bool                RebuildTextSource( void ) { return( false ); }
  168. // scork: for detailed error-reporting
  169.     virtual bool                Validate( const char *psText, int iTextLength, idStr &strReportTo ) const;
  170. // RAVEN END
  171.  
  172.     void                        Touch( void ) const;
  173.  
  174.     int                            NumAnims( void ) const;
  175.     const rvCameraAnimation *    GetAnim( int index ) const;
  176.     int                            GetSpecificAnim( const char *name ) const;
  177.     int                            GetAnim( const char *name ) const;
  178.     bool                        HasAnim( const char *name ) const;
  179.     
  180. private:
  181.     void                        CopyDecl( const idDeclCameraDef *decl );
  182.     bool                        ParseAnim( idLexer &src, int numDefaultAnims );
  183.  
  184. private:
  185.     idList<rvCameraAnimation *>    anims;
  186. };
  187.  
  188. ID_INLINE const rvCameraAnimation *idDeclCameraDef::GetAnim( int index ) const {
  189.     if ( ( index < 1 ) || ( index > anims.Num() ) ) {
  190.         return NULL;
  191.     }
  192.     return anims[ index - 1 ];
  193. }
  194.  
  195. /*
  196. ==============================================================================================
  197.  
  198.     idCameraAnim
  199.  
  200. ==============================================================================================
  201. */
  202. class idCameraAnim : public idCamera {
  203. public:
  204.     CLASS_PROTOTYPE( idCameraAnim );
  205.  
  206.                             idCameraAnim();
  207.                             ~idCameraAnim();
  208.  
  209.     // save games
  210.     void                    Save( idSaveGame *savefile ) const;                // archives object for save game file
  211.     void                    Restore( idRestoreGame *savefile );                // unarchives object from save game file
  212.  
  213.     void                    Spawn( void );
  214.     virtual void            GetViewParms( renderView_t *view );
  215.  
  216. private:
  217.     int                        threadNum;
  218.     idVec3                    offset;
  219.     int                        starttime;
  220.     int                        cycle;
  221.     const idDeclCameraDef    *cameraDef;
  222.     int                        lastFrame;
  223.     idEntityPtr<idEntity>    activator;
  224.  
  225.     void                    Start( void );
  226.     void                    Stop( void );
  227.     void                    Think( void );
  228.  
  229.     void                    LoadAnim( void );
  230.     void                    Event_Start( void );
  231.     void                    Event_Stop( void );
  232.     void                    Event_SetCallback( void );
  233.     void                    Event_Activate( idEntity *activator );
  234.  
  235. // RAVEN BEGIN
  236. // mekberg: wait support
  237.     void                    Event_IsActive( );
  238.  
  239.     idList<dword>            imageTable;
  240.     idList<int>                imageCmds;
  241. // RAVEN END
  242. };
  243. // RAVEN END
  244.  
  245. // RAVEN BEGIN
  246. /*
  247. ===============================================================================
  248.  
  249. rvCameraPortalSky
  250.  
  251. ===============================================================================
  252. */
  253. // jscott: for portal skies
  254. class rvCameraPortalSky : public idCamera {
  255. public:
  256.     CLASS_PROTOTYPE( rvCameraPortalSky );
  257.  
  258.                             rvCameraPortalSky( void ) {}
  259.                             ~rvCameraPortalSky( void ) {}
  260.  
  261.     // save games
  262.     void                    Save( idSaveGame *savefile ) const;                // archives object for save game file
  263.     void                    Restore( idRestoreGame *savefile );                // unarchives object from save game file
  264.  
  265.     void                    Spawn( void );
  266.     virtual void            GetViewParms( renderView_t *view );
  267. };
  268.  
  269. /*
  270. ===============================================================================
  271.  
  272. rvCameraPlayback
  273.  
  274. ===============================================================================
  275. */
  276. class rvCameraPlayback : public idCamera {
  277. public:
  278.     CLASS_PROTOTYPE( rvCameraPlayback );
  279.  
  280.                             rvCameraPlayback( void ) {}
  281.                             ~rvCameraPlayback( void ) {}
  282.  
  283.     // save games
  284.     void                    Save( idSaveGame *savefile ) const;                // archives object for save game file
  285.     void                    Restore( idRestoreGame *savefile );                // unarchives object from save game file
  286.  
  287.     void                    Spawn( void );
  288.     virtual void            GetViewParms( renderView_t *view );
  289.  
  290. private:
  291.     int                        startTime;
  292.     const rvDeclPlayback    *playback;
  293. };
  294. // RAVEN END
  295.  
  296. #endif /* !__GAME_CAMERA_H__ */
  297.