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

  1. #ifndef _LIPSYNC_H_INC_
  2. #define _LIPSYNC_H_INC_
  3.  
  4. // Possible TBDs
  5. // Auto head swapping from simple to lip sync head
  6. // Return time of sound from the speak call for the script to wait
  7. // Set emotion directly without encoding it into the string
  8.  
  9. class rvViseme
  10. {
  11. public:
  12.                 rvViseme( void ) {}
  13.                 ~rvViseme( void ) { phoneme.Clear(); }
  14.  
  15.     void        Init( idStr &phon, int f, int bt );
  16.  
  17.     int            GetFrame( void ) const { return( frame ); }
  18.     int            GetBlendTime( void ) const { return( blendTime ); }
  19.  
  20. private:
  21.     idStr        phoneme;
  22.     int            frame;
  23.     int            blendTime;
  24. };
  25.  
  26. #define FAS_NEW_VISEME        BIT( 0 )
  27. #define FAS_NEW_PHRASE        BIT( 1 )
  28. #define FAS_NEW_EMOTION        BIT( 2 )
  29. #define FAS_ENDED            BIT( 3 )
  30.  
  31. class rvLipSyncData
  32. {
  33. public:
  34.                     rvLipSyncData(  const rvDeclLipSync *ls, int time );
  35.                     ~rvLipSyncData( void ) {}
  36.  
  37.     bool            Ready( int time ) { return( time >= mNextTokenTime ); }
  38.  
  39.     int                ReadToken( idToken *token ) { return( mLexer.ReadToken( token ) ); }
  40.     int                ExpectTokenString( const char *str ) { return( mLexer.ExpectTokenString( str ) ); }
  41.     void            SetNextTokenTime( int time ) { mNextTokenTime += time; }
  42.     
  43.     void            ClearFlags( void ) { mFlags = 0; }
  44.     void            SetFlags( int flags ) { mFlags |= flags; }
  45.     bool            HasNewPhoneme( void ) const { return( !!( mFlags & FAS_NEW_VISEME ) ); }
  46.     bool            HasNewPhrase( void ) const { return( !!( mFlags & FAS_NEW_PHRASE ) ); }
  47.     bool            HasNewEmotion( void ) const { return( !!( mFlags & FAS_NEW_EMOTION ) ); }
  48.     bool            HasEnded( void ) const { return( !!( mFlags & FAS_ENDED ) ); }
  49.  
  50.     void            SetFrame( int frame );
  51.     int                GetFrame( void ) const { return( mFrame ); }
  52.     int                GetLastFrame( void ) { return( mLastFrame ); }
  53.  
  54.     void            SetBlendTime( int bt ) { mBlendTime = bt; }
  55.     int                GetBlendTime( void ) const { return( mBlendTime ); }
  56.  
  57.     float            GetFrontLerp( void );
  58.  
  59.     void            SetEmotion( idStr &str ) { mEmotion = str; }
  60.     const idStr        &GetEmotion( void ) const { return( mEmotion ); }
  61.  
  62.     void            SetLastPhrase( idStr &str ) { mLastPhrase = str; }
  63.     const idStr        &GetLastPhrase( void ) const { return( mLastPhrase ); }
  64.  
  65. private:
  66.     int                mNextTokenTime;
  67.     int                mFlags;
  68.     int                mFrame;
  69.     int                mLastFrame;
  70.     int                mVisemeStartTime;
  71.     int                mBlendTime;
  72.     idStr            mEmotion;
  73.     idStr            mLastPhrase;
  74.     idLexer            mLexer;
  75. };
  76.  
  77. bool FAS_Init( const char *visemes );
  78. void FAS_Shutdown( void );
  79.  
  80. void FAS_ExtractViseme( class rvLipSyncData *lsd, int time );
  81. class rvLipSyncData *FAS_StartVisemeExtraction( const rvDeclLipSync *ls, int time );
  82. void FAS_EndVisemeExtraction( class rvLipSyncData *lsd );
  83.  
  84. extern idCVar fas_debug;
  85. extern idCVar fas_timeOffset;
  86.  
  87. #endif // _LIPSYNC_H_INC_
  88.