Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

CCameraPathInterpolator.h

Go to the documentation of this file.
00001 /*
00002  * CCameraPathInterpolator.h
00003  * $Id: 
00004  *
00005  * Copyright (C) 2001 Thomas Woerner, Michael Meissner
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 
00023 //  Description : Class CCameraPathInterpolator
00024 //  Purpose     : Provides funcionality
00025 
00026 
00027 
00028 #ifndef CCAMERA_PATH_INTERPOLATOR_H
00029 #define CCAMERA_PATH_INTERPOLATOR_H
00030 
00031 
00032 // Own
00034 #include "CList.h"
00035 #include "CCameraKeyPathPoint.h"
00036 
00037 
00038 
00049 class CCameraPathInterpolator {
00050 
00051    public:
00052     
00053       enum ShapeType { SHAPE_LINE = 0,
00054                        SHAPE_TCB = 1,
00055                        SHAPE_CATMULL_ROM = 2 };
00056 
00057       enum PathType { PATH_OPEN = 0,
00058                       PATH_CLOSED = 1 };
00059 
00061       CCameraPathInterpolator(CList<CCameraKeyPathPoint> path,
00062                               ShapeType nShapeType = SHAPE_LINE, 
00063                               PathType nPathType = PATH_OPEN)
00064          : keys(path) {
00065          m_nShapeType = nShapeType;
00066          m_nPathType  = nPathType;
00067          compute();
00068       }
00069 
00071       ~CCameraPathInterpolator() {}
00072     
00074       int getNumFrames() {
00075          return m_ShapeList.getNumObjects();
00076       }
00077     
00080        CCameraKeyPathPoint *getFrame(int nFrame) {
00081           if (nFrame >= 0 && nFrame < getNumFrames())
00082              return &m_ShapeList[nFrame];
00083           else
00084              return NULL;
00085        }
00086     
00088       CList<CCameraKeyPathPoint> getPath() {
00089          return m_ShapeList;
00090       }
00091     
00092    protected:
00093     
00095       void compute();
00096     
00098       CList<CCameraKeyPathPoint> keys;
00099     
00101       ShapeType m_nShapeType;
00102     
00104       PathType m_nPathType;
00105     
00107       CList<CCameraKeyPathPoint> m_ShapeList;
00108 
00112       CCamera add(const CCamera &c1, const CCamera &c2) const {
00113          CCamera cam(c1);
00114          cam.setEyePos(c1.getEyePos() + c2.getEyePos());
00115          cam.setRefPoint(c1.getRefPoint() + c2.getRefPoint());
00116          cam.setViewUp(c1.getViewUp() + c2.getViewUp());
00117          cam.setRatio(c1.getRatio() + c2.getRatio());
00118          cam.setFovy(c1.getFovy() + c2.getFovy());
00119          cam.setVPHeight(c1.getVPHeight() + c2.getVPHeight());
00120 
00121          return cam;
00122       }
00123 
00127       CCamera sub(const CCamera &c1, const CCamera &c2) const {
00128          CCamera cam(c1);
00129          cam.setEyePos(c1.getEyePos() + c2.getEyePos() * -1);
00130          cam.setRefPoint(c1.getRefPoint() + c2.getRefPoint() * -1);
00131          cam.setViewUp(c1.getViewUp() + c2.getViewUp() * -1);
00132          cam.setRatio(c1.getRatio() - c2.getRatio());
00133          cam.setFovy(c1.getFovy() - c2.getFovy());
00134          cam.setVPHeight(c1.getVPHeight() - c2.getVPHeight());
00135 
00136          return cam;
00137       }
00138 
00142       CCamera mul(const CCamera &c, const double d) const {
00143          CCamera cam(c);
00144          cam.setEyePos(c.getEyePos() * d);
00145          cam.setRefPoint(c.getRefPoint() * d);
00146          cam.setViewUp(c.getViewUp() * d);
00147          cam.setRatio(c.getRatio() * d);
00148          cam.setFovy(c.getFovy() * d);
00149          cam.setVPHeight((int)((double) c.getVPHeight() * d));
00150 
00151          return cam;
00152       }
00153 };
00154 
00155 #endif /* CCAMERA_PATH_INTERPOLATOR_H */

Generated at Thu Oct 4 17:17:25 2001 for QGLViewer by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001