Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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  * As a special exception to the GPL, the QGLViewer authors (Markus
00022  * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas
00023  * Woerner) give permission to link this program with Qt (non-)commercial
00024  * edition, and distribute the resulting executable, without including
00025  * the source code for the Qt (non-)commercial edition in the source
00026  * distribution.
00027  *
00028  */
00029 
00030 //  Description : Class CCameraPathInterpolator
00031 //  Purpose     : Provides funcionality
00032 
00033 
00034 
00035 #ifndef CCAMERA_PATH_INTERPOLATOR_H
00036 #define CCAMERA_PATH_INTERPOLATOR_H
00037 
00038 
00039 // Own
00041 #include "CList.h"
00042 #include "CCameraKeyPathPoint.h"
00043 
00044 
00045 
00056 class CCameraPathInterpolator {
00057 
00058    public:
00059     
00060       enum ShapeType { SHAPE_LINE = 0,
00061                        SHAPE_TCB = 1,
00062                        SHAPE_CATMULL_ROM = 2 };
00063 
00064       enum PathType { PATH_OPEN = 0,
00065                       PATH_CLOSED = 1 };
00066 
00068       CCameraPathInterpolator(CList<CCameraKeyPathPoint> path,
00069                               ShapeType nShapeType = SHAPE_LINE, 
00070                               PathType nPathType = PATH_OPEN)
00071          : keys(path) {
00072          m_nShapeType = nShapeType;
00073          m_nPathType  = nPathType;
00074          compute();
00075       }
00076 
00078       ~CCameraPathInterpolator() {}
00079     
00081       int getNumFrames() {
00082          return m_ShapeList.getNumObjects();
00083       }
00084     
00087        CCameraKeyPathPoint *getFrame(int nFrame) {
00088           if (nFrame >= 0 && nFrame < getNumFrames())
00089              return &m_ShapeList[nFrame];
00090           else
00091              return NULL;
00092        }
00093     
00095       CList<CCameraKeyPathPoint> getPath() {
00096          return m_ShapeList;
00097       }
00098     
00099    protected:
00100     
00102       void compute();
00103     
00105       CList<CCameraKeyPathPoint> keys;
00106     
00108       ShapeType m_nShapeType;
00109     
00111       PathType m_nPathType;
00112     
00114       CList<CCameraKeyPathPoint> m_ShapeList;
00115 
00119       CCamera add(const CCamera &c1, const CCamera &c2) const {
00120          CCamera cam(c1);
00121          cam.setEyePos(c1.getEyePos() + c2.getEyePos());
00122          cam.setRefPoint(c1.getRefPoint() + c2.getRefPoint());
00123          cam.setViewUp(c1.getViewUp() + c2.getViewUp());
00124          cam.setRatio(c1.getRatio() + c2.getRatio());
00125          cam.setFovy(c1.getFovy() + c2.getFovy());
00126          cam.setVPHeight(c1.getVPHeight() + c2.getVPHeight());
00127 
00128          return cam;
00129       }
00130 
00134       CCamera sub(const CCamera &c1, const CCamera &c2) const {
00135          CCamera cam(c1);
00136          cam.setEyePos(c1.getEyePos() + c2.getEyePos() * -1);
00137          cam.setRefPoint(c1.getRefPoint() + c2.getRefPoint() * -1);
00138          cam.setViewUp(c1.getViewUp() + c2.getViewUp() * -1);
00139          cam.setRatio(c1.getRatio() - c2.getRatio());
00140          cam.setFovy(c1.getFovy() - c2.getFovy());
00141          cam.setVPHeight(c1.getVPHeight() - c2.getVPHeight());
00142 
00143          return cam;
00144       }
00145 
00149       CCamera mul(const CCamera &c, const double d) const {
00150          CCamera cam(c);
00151          cam.setEyePos(c.getEyePos() * d);
00152          cam.setRefPoint(c.getRefPoint() * d);
00153          cam.setViewUp(c.getViewUp() * d);
00154          cam.setRatio(c.getRatio() * d);
00155          cam.setFovy(c.getFovy() * d);
00156          cam.setVPHeight((int)((double) c.getVPHeight() * d));
00157 
00158          return cam;
00159       }
00160 };
00161 
00162 #endif /* CCAMERA_PATH_INTERPOLATOR_H */

Generated on Wed Oct 22 07:07:33 2003 for QGLViewer by doxygen 1.3.4