00001 // SimpleFacialExpression.h: interface for the SimpleFacialExpression class. 00002 // 00003 ////////////////////////////////////////////////////////////////////// 00004 00005 #if !defined(AFX_SIMPLEFACIALEXPRESSION_H__67DD0330_73DE_463B_8A4E_2D67FF18DF78__INCLUDED_) 00006 #define AFX_SIMPLEFACIALEXPRESSION_H__67DD0330_73DE_463B_8A4E_2D67FF18DF78__INCLUDED_ 00007 00008 #if _MSC_VER > 1000 00009 #pragma once 00010 #endif // _MSC_VER > 1000 00011 00012 #include "FbaAction.h" 00013 00014 #ifdef VISAGE_STATIC 00015 #define FAPLAYER_API 00016 #else 00017 #ifdef FAPLAYER_EXPORTS 00018 #define FAPLAYER_API __declspec(dllexport) 00019 #else 00020 #define FAPLAYER_API __declspec(dllimport) 00021 #endif 00022 #endif 00023 00024 /** 00025 * A basic facial expression action. 00026 * This is a simple implementation of an FbaAction, implemention the basic facial expression action. The expression 00027 * can be one of the universal expressions - joy, sadness, anger, fear, disgust or surprise. It is set by passing 00028 * the name of the desired expression to the constructor. The other parameter to be set is the duration time 00029 * of the expression, in milliseconds. 00030 * 00031 * SimpleFacialExpression uses a simple expression dynamics scheme with attack, sustain and decay phases. 00032 * In the attack phase the intensity grows linearly; in the sustain phase 00033 * it stays at the maximum; in the decay phase it falls linearly to 0. 00034 * 00035 * Much more elaborate expression dynamic schemes can be implemented. 00036 * 00037 * @see FbaAction 00038 */ 00039 class FAPLAYER_API SimpleFacialExpression : public FbaAction 00040 { 00041 public: 00042 /** 00043 * Constructor. 00044 * Construct a simple facial expression by choosing one of the standard expressions by name, and setting its duration time. 00045 * 00046 * @param expressionName the name of the expression: joy, sadness, anger, fear, or surprise. Any other string will result in neutral expression. The expression name is not case sensitive. 00047 * @param expressionDuration the total duration time of the expression, in milliseconds 00048 * @param expressionIntensity the maximum intensity of the expression, 1.0 being the default expression intensity, higher values bringing more intense expressions 00049 */ 00050 SimpleFacialExpression(char *expressionName, long expressionDuration, float expressionIntensity); 00051 ~SimpleFacialExpression(); 00052 00053 00054 /** 00055 * Start the action. 00056 * This function is called by the FAPlayer when the playing starts. 00057 * 00058 * @param globalTime the reference time when the action is started, in milliseconds 00059 */ 00060 void SimpleFacialExpression::start(long globalTime); 00061 00062 /** 00063 * Get FBAPs. This function returns the Face and Body Animation Parameters (FBAPs) 00064 * for the time t. This function is called by the FAPlayer when the FbaAction is played in the FAPlayer. 00065 * This implementation implements a simple expression dynamics scheme with attack, sustain and decay phases. 00066 * In the attack phase the intensity grows linearly; in the sustain phase 00067 * it stays at the maximum; in the decay phase it falls linearly to 0. 00068 * 00069 * @param globalTime the time for which the FBAPs are requested, in milliseconds 00070 * @param lastFBAPs the final FBAPs from the previous frame of animation; in this implementation we ignore this parameter 00071 * @param afm the Animatable Face and Body Model currently used in the player; in this implementation we ignore this parameter 00072 * @return the Face and Body Animation Parameters (FBAPs) for the requested time 00073 */ 00074 FBAPs * SimpleFacialExpression::getFBAPs(long globalTime, FBAPs *lastFBAPs, AFM *afm); 00075 00076 /** 00077 * Stop playing tracks. Reset the face animation track. 00078 */ 00079 void SimpleFacialExpression::stop(); 00080 00081 /** 00082 * Return the name of the action type. 00083 * 00084 * @return the name of the action type. 00085 */ 00086 char* SimpleFacialExpression::actionTypeName() {return "SimpleFacialExpression";}; 00087 00088 long globalStartTime; 00089 float intensity; 00090 float maxIntensity; 00091 FBAPs *fbaps; 00092 FBAPs *expFbaps; 00093 long lastTimeMs; 00094 double attack_time; // the duration of the attack phase, in milliseconds 00095 double sustain_time; // the duration of the sustain phase, in milliseconds 00096 double decay_time; // the duration of the decay phase, in milliseconds 00097 int currentExpression; 00098 long duration; 00099 int playing; 00100 }; 00101 00102 #endif // !defined(AFX_SIMPLEFACIALEXPRESSION_H__67DD0330_73DE_463B_8A4E_2D67FF18DF78__INCLUDED_)