Stellarium 0.12.0
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · Renderer · File Structure

TrailGroup.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2010 Fabien Chereau
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00018  */
00019 
00020 #ifndef TRAILGROUP_HPP
00021 #define TRAILGROUP_HPP
00022 
00023 #include "VecMath.hpp"
00024 #include "StelCore.hpp"
00025 #include "StelObjectType.hpp"
00026 
00027 
00028 class TrailGroup
00029 {
00030 public:
00031     TrailGroup(float atimeExtent);
00032 
00033     ~TrailGroup();
00034 
00035     void draw(StelCore* core, class StelRenderer* renderer);
00036 
00037     // Add 1 point to all the curves at current time and suppress too old points
00038     void update();
00039 
00040     // Set the matrix to use to post process J2000 positions before storing in the trail
00041     void setJ2000ToTrailNative(const Mat4d& m);
00042 
00043     void addObject(const StelObjectP&, const Vec3f* col=NULL);
00044 
00045     void setOpacity(float op) 
00046     {
00047         opacity = op;
00048     }
00049 
00051     void reset();
00052 
00053 private:
00055     struct ColoredVertex
00056     {
00057         Vec3f position;
00058         Vec4f color;
00059 
00060         ColoredVertex(){}
00061 
00062         VERTEX_ATTRIBUTES(Vec3f Position, Vec4f Color);
00063     };
00064 
00065     struct Trail
00066     {
00067         Trail(const StelObjectP& obj, const Vec3f& col) 
00068             : stelObject(obj), color(col), vertexBuffer(NULL) 
00069         {
00070         }
00071 
00072         StelObjectP stelObject;
00073 
00074         // Using QVector instead of QList.
00075         // QList is an array of pointers to elements, which are 8 byte on 64-bit,
00076         // while Vec3f is 12 byte, so not much space saved (or time, at popFront).
00077         // At the same time, it has a bad cache performance that slows down drawing.
00078 
00079         // All previous positions
00080         QVector<Vec3f> posHistory;
00081         Vec3f color;
00082         StelVertexBuffer<ColoredVertex>* vertexBuffer;
00083     };
00084 
00085     QList<Trail> allTrails;
00086 
00087     // Maximum time extent in days
00088     float timeExtent;
00089 
00090     QList<float> times;
00091 
00092     Mat4d j2000ToTrailNative;
00093     Mat4d j2000ToTrailNativeInverted;
00094 
00095     float opacity;
00096 
00100     double lastTimeInHistory;
00101 };
00102 
00103 #endif // TRAILMGR_HPP
Generated on Thu Jan 31 14:05:41 2013 for Stellarium by  doxygen 1.6.3