Planeshift

pseffectobjtrail.h

Go to the documentation of this file.
00001 /*
00002  * Author: Andrew Robberts
00003  *
00004  * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
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  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef PS_EFFECT_OBJ_TRAIL_HEADER
00021 #define PS_EFFECT_OBJ_TRAIL_HEADER
00022 
00023 #include "pseffectobj.h"
00024 #include <imesh/genmesh.h>
00025 #include <csgeom/spline.h>
00026 
00027 class psEffect2DRenderer;
00028 
00033 class psEffectObjTrail : public psEffectObj
00034 {
00035 public:
00036     struct MeshAnimControl : public scfImplementation1<MeshAnimControl, iGenMeshAnimationControl>
00037     {
00038     private:
00039         psEffectObjTrail* parent;
00040 
00041     public:
00042         // genmesh animation control
00043         bool AnimatesVertices() const
00044         {
00045             return true;
00046         }
00047         bool AnimatesTexels() const
00048         {
00049             return false;
00050         }
00051         bool AnimatesNormals() const
00052         {
00053             return false;
00054         }
00055         bool AnimatesColors()const
00056         {
00057             return true;
00058         }
00059         bool AnimatesBBoxRadius() const
00060         {
00061             return false;
00062         }
00063 
00064         MeshAnimControl(psEffectObjTrail* parent) : scfImplementationType(this)
00065         {
00066             this->parent = parent;
00067         }
00068         virtual ~MeshAnimControl()
00069         {
00070             parent = 0;
00071         }
00072 
00073         void Update(csTicks /*current*/, int /*num_verts*/, uint32 /*version_id*/)
00074         {
00075         }
00076 
00077         const csBox3 &UpdateBoundingBox(csTicks /*current*/, uint32 /*version_id*/, const csBox3 &bbox)
00078         {
00079             return bbox;
00080         }
00081         const float UpdateRadius(csTicks /*current*/, uint32 /*version_id*/, const float radius)
00082         {
00083             return radius;
00084         }
00085         const csBox3* UpdateBoundingBoxes(csTicks /*current*/, uint32 /*version_id*/)
00086         {
00087             return nullptr;
00088         }
00089         const csVector3* UpdateVertices(csTicks current, const csVector3* verts, int num_verts, uint32 version_id);
00090         const csVector2* UpdateTexels(csTicks /*current*/, const csVector2* texels,
00091                                       int /*num_texels*/, uint32 /*version_id*/)
00092         {
00093             return texels;
00094         }
00095         const csVector3* UpdateNormals(csTicks /*current*/, const csVector3* normals,
00096                                        int /*num_normals*/, uint32 /*version_id*/)
00097         {
00098             return normals;
00099         }
00100         const csColor4* UpdateColors(csTicks current, const csColor4* colors, int num_colors, uint32 version_id);
00101     };
00102     csRef<MeshAnimControl> meshControl;
00103     friend struct MeshAnimControl;
00104 
00105     psEffectObjTrail(iView* parentView, psEffect2DRenderer* renderer2d);
00106     ~psEffectObjTrail();
00107 
00108     // inheritted function overloads
00109     bool Load(iDocumentNode* node, iLoaderContext* ldr_context);
00110     bool Render(const csVector3 &up);
00111     bool Update(csTicks elapsed);
00112     psEffectObj* Clone() const;
00113 
00114 
00115 private:
00116 
00120     bool PostSetup();
00121 
00122     csRef<iGeneralMeshState> genState;
00123 
00124     int segments;
00125 
00126     csVector3* vert;
00127     csColor4* colour;
00128     bool* missingUpdate;
00129 
00130     int currSegment;
00131     bool setMesh;
00132 
00133     float updateLen;
00134     float updateTotal;
00135     float updateLeft;
00136 
00137     csCatmullRomSpline* spline[2];
00138 
00139     float alpha;
00140 
00141     bool useMid;
00142 };
00143 
00146 #endif