Planeshift

pseffectobjstar.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_STAR_HEADER
00021 #define PS_EFFECT_OBJ_STAR_HEADER
00022 
00023 #include "pseffectobj.h"
00024 #include <imesh/genmesh.h>
00025 
00026 class psEffect2DRenderer;
00027 
00032 class psEffectObjStar : public psEffectObj
00033 {
00034 public:
00035     struct MeshAnimControl : public scfImplementation1<MeshAnimControl, iGenMeshAnimationControl>
00036     {
00037     private:
00038         psEffectObjStar* parent;
00039 
00040     public:
00041         // genmesh animation control
00042         bool AnimatesVertices() const
00043         {
00044             return true;
00045         }
00046         bool AnimatesTexels() const
00047         {
00048             return false;
00049         }
00050         bool AnimatesNormals() const
00051         {
00052             return false;
00053         }
00054         bool AnimatesColors()const
00055         {
00056             return true;
00057         }
00058         bool AnimatesBBoxRadius() const
00059         {
00060             return false;
00061         }
00062 
00063         MeshAnimControl(psEffectObjStar* parent) : scfImplementationType(this)
00064         {
00065             this->parent = parent;
00066         }
00067         virtual ~MeshAnimControl()
00068         {
00069             parent = 0;
00070         }
00071 
00072         void Update(csTicks /*elapsed*/, int /*num_verts*/, uint32 /*version_id*/)
00073         {
00074         }
00075 
00076         const csBox3 &UpdateBoundingBox(csTicks /*current*/, uint32 /*version_id*/, const csBox3 &bbox)
00077         {
00078             return bbox;
00079         }
00080         const float UpdateRadius(csTicks /*current*/, uint32 /*version_id*/, const float radius)
00081         {
00082             return radius;
00083         }
00084         const csBox3* UpdateBoundingBoxes(csTicks /*current*/, uint32 /*version_id*/)
00085         {
00086             return nullptr;
00087         }
00088         const csVector3* UpdateVertices(csTicks current, const csVector3* verts, int num_verts, uint32 version_id);
00089         const csVector2* UpdateTexels(csTicks /*current*/, const csVector2* texels,
00090                                       int /*num_texels*/, uint32 /*version_id*/)
00091         {
00092             return texels;
00093         }
00094         const csVector3* UpdateNormals(csTicks /*current*/, const csVector3* normals,
00095                                        int /*num_normals*/, uint32 /*version_id*/)
00096         {
00097             return normals;
00098         }
00099         const csColor4* UpdateColors(csTicks current, const csColor4* colors, int num_colors, uint32 version_id);
00100     };
00101     csRef<MeshAnimControl> meshControl;
00102     friend struct MeshAnimControl;
00103 
00104     psEffectObjStar(iView* parentView, psEffect2DRenderer* renderer2d);
00105     ~psEffectObjStar();
00106 
00107     // inheritted function overloads
00108     bool Load(iDocumentNode* node, iLoaderContext* ldr_context);
00109     bool Render(const csVector3 &up);
00110     bool Update(csTicks elapsed);
00111     psEffectObj* Clone() const;
00112 
00113 private:
00114 
00117     void GenerateRays();
00118 
00122     bool PostSetup();
00123 
00124     csRef<iGeneralMeshState> genState;
00125 
00126     int segments;
00127 
00128     csVector3* rays;
00129     csVector3* perp;
00130 
00131     csVector3* vert;
00132     csColor4*   colour;
00133 };
00134 
00137 #endif