DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

Cinematic.h (3926B)


      1 /*
      2 ===========================================================================
      3 
      4 Doom 3 BFG Edition GPL Source Code
      5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 
      6 
      7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").  
      8 
      9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
     10 it under the terms of the GNU General Public License as published by
     11 the Free Software Foundation, either version 3 of the License, or
     12 (at your option) any later version.
     13 
     14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
     15 but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 GNU General Public License for more details.
     18 
     19 You should have received a copy of the GNU General Public License
     20 along with Doom 3 BFG Edition Source Code.  If not, see <http://www.gnu.org/licenses/>.
     21 
     22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code.  If not, please request a copy in writing from id Software at the address below.
     23 
     24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
     25 
     26 ===========================================================================
     27 */
     28 
     29 #ifndef __CINEMATIC_H__
     30 #define __CINEMATIC_H__
     31 
     32 /*
     33 ===============================================================================
     34 
     35 	cinematic
     36 
     37 	Multiple idCinematics can run simultaniously.
     38 	A single idCinematic can be reused for multiple files if desired.
     39 
     40 ===============================================================================
     41 */
     42 
     43 // cinematic states
     44 typedef enum {
     45 	FMV_IDLE,
     46 	FMV_PLAY,			// play
     47 	FMV_EOF,			// all other conditions, i.e. stop/EOF/abort
     48 	FMV_ID_BLT,
     49 	FMV_ID_IDLE,
     50 	FMV_LOOPED,
     51 	FMV_ID_WAIT
     52 } cinStatus_t;
     53 
     54 class idImage;
     55 
     56 // a cinematic stream generates an image buffer, which the caller will upload to a texture
     57 typedef struct {
     58 	int					imageWidth;
     59 	int					imageHeight;	// will be a power of 2
     60 	idImage*			imageY;
     61 	idImage*			imageCr;
     62 	idImage*			imageCb;
     63 	int					status;
     64 } cinData_t;
     65 
     66 class idCinematic {
     67 public:
     68 	// initialize cinematic play back data
     69 	static void			InitCinematic( void );
     70 
     71 	// shutdown cinematic play back data
     72 	static void			ShutdownCinematic( void );
     73 
     74 	// allocates and returns a private subclass that implements the methods
     75 	// This should be used instead of new
     76 	static idCinematic	*Alloc();
     77 
     78 	// frees all allocated memory
     79 	virtual				~idCinematic();
     80 
     81 	// returns false if it failed to load
     82 	virtual bool		InitFromFile( const char *qpath, bool looping );
     83 
     84 	// returns the length of the animation in milliseconds
     85 	virtual int			AnimationLength();
     86 
     87 	// the pointers in cinData_t will remain valid until the next UpdateForTime() call
     88 	virtual cinData_t	ImageForTime( int milliseconds );
     89 
     90 	// closes the file and frees all allocated memory
     91 	virtual void		Close();
     92 
     93 	// sets the cinematic to start at that time (can be in the past)
     94 	virtual void		ResetTime(int time);
     95 
     96 	// gets the time the cinematic started
     97 	virtual int			GetStartTime();
     98 
     99 	virtual void		ExportToTGA( bool skipExisting = true );
    100 
    101 	virtual float		GetFrameRate() const;
    102 };
    103 
    104 /*
    105 ===============================================
    106 
    107 	Sound meter.
    108 
    109 ===============================================
    110 */
    111 
    112 class idSndWindow : public idCinematic {
    113 public:
    114 	
    115 						idSndWindow() { showWaveform = false; }
    116 						~idSndWindow() {}
    117 
    118 	bool				InitFromFile( const char *qpath, bool looping );
    119 	cinData_t			ImageForTime( int milliseconds );
    120 	int					AnimationLength();
    121 
    122 private:
    123 	bool				showWaveform;
    124 };
    125 
    126 #endif /* !__CINEMATIC_H__ */