1 #include <Base/Math/Vector3.hh>
2 #include <Base/Geometry/RMatrixBase.hh>
3 #include <Base/Geometry/Quaternion.hh>
4 #include "AutoControl.hh"
6 #include <Gui/biasgl.h>
17 InitializedSector_ = -1;
23 if (PoseList_.size() > 1)
25 InitializedSector_ = Sector_;
36 StepSizeC_ = VecC_.
Length() / NumberOfSteps_;
37 VecUp_ = toUp - fromUp;
38 StepSizeUp_ = VecUp_.
Length() / NumberOfSteps_;
39 VecPoI_ = toPoI - fromPoI;
40 StepSizePoI_ = VecPoI_.
Length() / NumberOfSteps_;
46 if (PoseList_.size() <= 1) {
47 BIASERR(
"Not enough camera poses defined.")
51 if (Sector_ + 2 >= PoseList_.size() && Step_ >= NumberOfSteps_){
57 if (Step_ < NumberOfSteps_-1) {
61 if (Sector_ < PoseList_.size() - 2) {
64 }
else if (Sector_ + 2 == PoseList_.size() ) {
72 return GoTo(Step_, Sector_);
78 if (PoseList_.size() ==0)
return -1;
79 if (step > NumberOfSteps_) {
80 BIASERR(
"Specified parameter out of range: Step " << step);
83 if (sector >= PoseList_.size() - 1) {
84 BIASERR(
"Specified parameter out of range: Sector " << sector);
90 if ((
int)Sector_ != InitializedSector_) {
100 if (!VecC_.IsZero()) {
103 delta *= (StepSizeC_ * Step_);
107 if (!VecPoI_.IsZero()) {
110 delta *= (StepSizePoI_ * Step_);
114 if (!VecUp_.IsZero()) {
117 delta *= (StepSizeUp_ * Step_);
122 int res = controlledObject_->SetExtrinsics(fromC, fromPoI, fromUp);
123 Context_->Redisplay();
129 if ((
int)(PoseList_.size()) < pose+1) {
130 BIASERR(
"Specified parameter is out of range!");
136 int res = controlledObject_->SetExtrinsics(PoseList_[pose].C,
139 Context_->Redisplay();
150 PoseList_.push_back(newPose);
157 if (PoseList_.size() == 2)
167 controlledObject_->GetExtrinsics(C, up);
168 RMatrix R = controlledObject_->GetMyselfAsProjectionParameterBase()->GetR();
179 if (PoseList_.size() <2)
return;
182 InitializedSector_ = -1;
188 if (PoseList_.size() == 0)
190 BIASERR(
"No poses in list.")
194 PoseList_.pop_back();
202 if (PoseList_.size() == 0)
204 BIASERR(
"No poses in list.")
209 vector<CameraPose>::iterator iter=PoseList_.begin();
210 for(
int i=0; i<pose; i++) {
213 PoseList_.erase(iter);
234 cout<<
"NextStep"<<endl;
239 cout<<
"Rewind"<<endl;
244 cout<<
"Last added pose deleted."<<endl;
261 ofstream ofs(file.c_str());
263 perror(file.c_str());
267 for (
unsigned int i=0;i<PoseList_.size(); i++) {
269 A = PoseList_[i].PoI;
270 up = PoseList_[i].up;
271 ofs << C[0]<<
" "<<C[1]<<
" "<<C[2]<<
" ";
272 ofs << A[0]<<
" "<<A[1]<<
" "<<A[2]<<
" ";
273 ofs << up[0]<<
" "<<up[1]<<
" "<<up[2]<<endl;
285 InitializedSector_ = -1;
286 ifstream ifs(file.c_str());
288 perror(file.c_str());
294 ifs >> C[0]>>C[1]>>C[2];
295 ifs >> A[0]>>A[1]>>A[2];
296 ifs >> up[0]>>up[1]>>up[2];
297 if (ifs) AddPose(C,A,up);
303 InitializedSector_ = -1;
306 return PoseList_.size();
311 bool didsomething =
false;
314 int res = NextStep();
316 if (res<0) Active_ =
false;
double Length() const
returns the Euclidean Length of the Vector
int NextStep()
Goes to the next calculated pose.
BIAS::Vector3< double > C
void SetContext(RenderContextBase *context)
void DeleteLast()
Deletes the last added pose and resets the autopilot F4.
void AddPose()
Adds the current pose of ControldObject to the autopilot at the end of PoseList_ F1.
void DeletePose(int pose)
Deletes the defined pose and resets the autopilot F4.
int SaveToFile(const std::string &file)
int LoadFromFile(const std::string &file)
void Init()
Initialisizes the autopilot.
bool TimerExpired()
this function is called by RenderContextBase when timer is expired Overwrite and implement to do some...
int GoToPose(int pose)
Goes to the defined pose.
int GoTo(unsigned int step, unsigned int sector)
Goes to the defined step and sector.
void DeleteAll()
Deletes all poses in PoseList_ and resets autopilot.
void Rewind()
Sets the autopilot to start point.
BIAS::Vector3< double > up
Vector3< T > & Normalize()
normalize this vector to length 1
BIAS::Vector3< double > PoI
bool SpecialKeyPressed(int key)
Handles special key events.
Base for all classes creating interface between GL and "window manager".