vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
player.h
Go to the documentation of this file.
1 /* player - player for collection of gestures (lists of mvectors)
2 * Ludek Pokluda, xpokluda@fi.muni.cz
3 * v0.0.3 30.03.2005
4 *
5 * Delta changed -> compute exact delta time //nothing changed in this file, only in cpp
6 *
7 * v0.0.4 10.10.2005
8 * Step is split in
9 * Step_forward, Step_backward
10 */
11 #ifndef _PLAYER_
12 #define _PLAYER_
13 
14 #include "collection.h"
15 #include <vector>
16 
17 
18 namespace mv{
19 #define DEFAULT_FREQ 5000
20 
21 //enum DirT={BACKWARD,FORWARD};
22 
23 class CPlayer{
24  //MVectList *ActList; //actual list of mvectors
25  //CCollection *ActCollection; //actual list of gestures
26  //CMVect *ActVect; //actual mvector
27  long int ActGesture; //actual
28  long int ActVect; //actual mvector
29  gmVector3 ActPos; //actual position
30  gmVector3 ActVel; //actual velocity, actual only in start or end of vect, user for smooth connection of mvectors
31  gmVector3 StartPos; //starting position on actual vector (for recomputing relative position)
32  double ActT; //actual time on vector
33  bool Loop; //play in loop
34  bool All; //play all/one
35  bool Play; //true for play, false for stop
36  bool Pause; //simply pause playing
37  bool Force; //true for return force, false for return position
38  bool Direction; //true for forward, false for backward
39  unsigned int Freq; //playing frequency
40  double Delta; //playing time - we can compute it from frequency, but better is to measure it
41 
42 public:
43  std::vector <CGesture *> ActCollection; //actual list of gestures
44 
45  CPlayer();
46 // CPlayer(CCollection *newcollection);
47  ~CPlayer();
48 
49 // void addCollection(CCollection *newcollection);
50 // void removeCollection();
51  void addGesture(CGesture *newgesture);
52  void delGesture();
53  void delAllGestures();
54 
55 // void delAllVect();
56 // void delVectFromActToEnd();
57 // void delVectFromActToHead();
58 // void splitVect(); //create two vector from act vector
59 
60 // CMVect *getActVect();
61 // CCollection *getActCollection() {return ActCollection;};
62  gmVector3 getActPos() {return ActPos;}
63  gmVector3 getActVel() {return ActVel;}
64  unsigned int getActGesture() {return ActGesture;}; //info only
65  unsigned int getActVect() {return ActVect;}; //info only
66  double getActT() {return ActT;}; //info only
67  bool getLoop() {return Loop;} std::vector <CGesture *>::iterator i;
68 
69  void setLoop(bool val) {Loop = val;}
70  bool getAll() {return All;}
71  void setAll(bool val) {All = val;}
72  bool getPlay() {return Play;}
73  void setPlay(bool val) {Play = val;}
74  bool getPause() {return Pause;}
75  void setPause(bool val) {Pause = val;}
76  bool getForce() {return Force;}
77  void setForce(bool val) {Force = val;}
78  bool getDirection() {return Direction;}
79  //void setDirection(DirT val) {Direction = val;}
80  void setDirection(bool val) {Direction = val;}
81 
82 
83  gmVector3 ControlPosition(gmVector3 Pos); //control if Pos is in workspace, return projection to workspace
84  gmVector3 ComputeForce(gmVector3 DevicePos, gmVector3 DeviceVel, gmVector3 Pos); //compute force from device position and velocity and act position on mvector
85 
86  gmVector3 Step_forward(gmVector3 &r,double &wtime,bool &rflag,double &p,double &v0, double &v1, double &l); //go to next vector, gesture
87  gmVector3 Step_backward(gmVector3 &r,double &wtime,bool &rflag,double &p,double &v0, double &v1, double &l); //go to previous vector, gesture
88  gmVector3 Step(); //return only pos //for animation
89  gmVector3 Step(gmVector3 DevicePos,gmVector3 DeviceVel); //return position or force
90 
91 /*
92  gmVector3 PosPlayAll(); //go through whole list of mvector, return position
93  gmVector3 PosPlayAct(); //play only act mvector, return position
94  gmVector3 ForcePlayAll(); //go through whole list of mvector, return force
95  gmVector3 ForcePlayAct(); //play only act mvector, return force
96  */
97 
98 };
99 
100 double ActTtoP(double t,double v0, double v1,double l); //from ActT (actual time on vector) to param in <0,1>
101 
102 double PtoActT(double p,double v0, double v1,double l); //form param in <0,1> to ActT (actual time on vector)
103 
104 }//namespace mv
105 #endif