Planeshift

pseffectobjspire.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_SPIRE_HEADER
00021 #define PS_EFFECT_OBJ_SPIRE_HEADER
00022 
00023 #include "pseffectobj.h"
00024 #include <imesh/genmesh.h>
00025 
00026 class psEffect2DRenderer;
00027 
00032 class psEffectObjSpire : public psEffectObj
00033 {
00034 public:
00035     struct MeshAnimControl : public scfImplementation1<MeshAnimControl, iGenMeshAnimationControl>
00036     {
00037     private:
00038         psEffectObjSpire* parent;
00039 
00040     public:
00041         MeshAnimControl(psEffectObjSpire* parent) : scfImplementationType(this)
00042         {
00043             this->parent = parent;
00044         }
00045 
00046         virtual ~MeshAnimControl()
00047         {
00048             parent = 0;
00049         }
00050 
00051         void Update(csTicks /*current*/, int /*num_verts*/, uint32 /*version_id*/)
00052         {
00053         }
00054 
00055         // genmesh animation control
00056         bool AnimatesVertices() const
00057         {
00058             return true;
00059         }
00060         bool AnimatesTexels() const
00061         {
00062             return true;
00063         }
00064         bool AnimatesNormals() const
00065         {
00066             return false;
00067         }
00068         bool AnimatesColors()const
00069         {
00070             return true;
00071         }
00072         bool AnimatesBBoxRadius() const
00073         {
00074             return false;
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, int num_texels, uint32 version_id);
00091         const csVector3* UpdateNormals(csTicks /*current*/, const csVector3* normals,
00092                                        int /*num_normals*/, uint32 /*version_id*/)
00093         {
00094             return normals;
00095         }
00096         const csColor4* UpdateColors(csTicks current, const csColor4* colors, int num_colors, uint32 version_id);
00097     };
00098     csRef<MeshAnimControl> meshControl;
00099     friend struct MeshAnimControl;
00100 
00101 
00102 
00103     psEffectObjSpire(iView* parentView, psEffect2DRenderer* renderer2d);
00104     virtual ~psEffectObjSpire();
00105 
00106     // inheritted function overloads
00107     bool Load(iDocumentNode* node, iLoaderContext* ldr_context);
00108     bool Render(const csVector3 &up);
00109     bool Update(csTicks elapsed);
00110     psEffectObj* Clone() const;
00111 
00112 
00113     enum SPI_SHAPE
00114     {
00115         SPI_CIRCLE = 0,
00116         SPI_CYLINDER,
00117         SPI_ASTERIX,
00118         SPI_STAR,
00119         SPI_LAYERED,
00120 
00121         SPI_COUNT
00122     };
00123 
00124 private:
00125 
00135     static void CalculateData(int shape, int segments, csVector3* verts, csVector2* texels, float topScale=1, float height=1, float padding=1);
00136 
00140     bool PostSetup();
00141 
00142     csRef<iGeneralMeshState> genState;
00143 
00144     int shape;
00145     int segments;
00146 
00147     csVector3* vert;
00148     csVector2* texel;
00149     csColor4*   colour;
00150     int vertCount;
00151 };
00152 
00155 #endif