Planeshift
pseffectobjtrail.h
Go to the documentation of this file.
1 /*
2  * Author: Andrew Robberts
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PS_EFFECT_OBJ_TRAIL_HEADER
21 #define PS_EFFECT_OBJ_TRAIL_HEADER
22 
23 #include "pseffectobj.h"
24 #include <imesh/genmesh.h>
25 #include <csgeom/spline.h>
26 
27 class psEffect2DRenderer;
28 
34 {
35 public:
36  struct MeshAnimControl : public scfImplementation1<MeshAnimControl, iGenMeshAnimationControl>
37  {
38  private:
39  psEffectObjTrail* parent;
40 
41  public:
42  // genmesh animation control
43  bool AnimatesVertices() const
44  {
45  return true;
46  }
47  bool AnimatesTexels() const
48  {
49  return false;
50  }
51  bool AnimatesNormals() const
52  {
53  return false;
54  }
55  bool AnimatesColors()const
56  {
57  return true;
58  }
59  bool AnimatesBBoxRadius() const
60  {
61  return false;
62  }
63 
64  MeshAnimControl(psEffectObjTrail* parent) : scfImplementationType(this)
65  {
66  this->parent = parent;
67  }
68  virtual ~MeshAnimControl()
69  {
70  parent = 0;
71  }
72 
73  void Update(csTicks /*current*/, int /*num_verts*/, uint32 /*version_id*/)
74  {
75  }
76 
77  const csBox3 &UpdateBoundingBox(csTicks /*current*/, uint32 /*version_id*/, const csBox3 &bbox)
78  {
79  return bbox;
80  }
81  const float UpdateRadius(csTicks /*current*/, uint32 /*version_id*/, const float radius)
82  {
83  return radius;
84  }
85  const csBox3* UpdateBoundingBoxes(csTicks /*current*/, uint32 /*version_id*/)
86  {
87  return nullptr;
88  }
89  const csVector3* UpdateVertices(csTicks current, const csVector3* verts, int num_verts, uint32 version_id);
90  const csVector2* UpdateTexels(csTicks /*current*/, const csVector2* texels,
91  int /*num_texels*/, uint32 /*version_id*/)
92  {
93  return texels;
94  }
95  const csVector3* UpdateNormals(csTicks /*current*/, const csVector3* normals,
96  int /*num_normals*/, uint32 /*version_id*/)
97  {
98  return normals;
99  }
100  const csColor4* UpdateColors(csTicks current, const csColor4* colors, int num_colors, uint32 version_id);
101  };
102  csRef<MeshAnimControl> meshControl;
103  friend struct MeshAnimControl;
104 
105  psEffectObjTrail(iView* parentView, psEffect2DRenderer* renderer2d);
107 
108  // inheritted function overloads
109  bool Load(iDocumentNode* node, iLoaderContext* ldr_context);
110  bool Render(const csVector3 &up);
111  bool Update(csTicks elapsed);
112  psEffectObj* Clone() const;
113 
114 
115 private:
116 
120  bool PostSetup();
121 
122  csRef<iGeneralMeshState> genState;
123 
124  int segments;
125 
126  csVector3* vert;
127  csColor4* colour;
128  bool* missingUpdate;
129 
130  int currSegment;
131  bool setMesh;
132 
133  float updateLen;
134  float updateTotal;
135  float updateLeft;
136 
137  csCatmullRomSpline* spline[2];
138 
139  float alpha;
140 
141  bool useMid;
142 };
143 
146 #endif
psEffectObj * Clone() const
Clones the effect object.
The manager of all 2D effect elements.
bool Load(iDocumentNode *node, iLoaderContext *ldr_context)
Loads the effect object from an xml node.
csRef< MeshAnimControl > meshControl
const csBox3 * UpdateBoundingBoxes(csTicks, uint32)
const csVector2 * UpdateTexels(csTicks, const csVector2 *texels, int, uint32)
const float UpdateRadius(csTicks, uint32, const float radius)
const csBox3 & UpdateBoundingBox(csTicks, uint32, const csBox3 &bbox)
const csVector3 * UpdateVertices(csTicks current, const csVector3 *verts, int num_verts, uint32 version_id)
An effect is not much more than a collection of effect objects.
Definition: pseffectobj.h:207
const csVector3 * UpdateNormals(csTicks, const csVector3 *normals, int, uint32)
const csColor4 * UpdateColors(csTicks current, const csColor4 *colors, int num_colors, uint32 version_id)
MeshAnimControl(psEffectObjTrail *parent)
bool Render(const csVector3 &up)
Renders the effect.
psEffectObjTrail(iView *parentView, psEffect2DRenderer *renderer2d)
void Update(csTicks, int, uint32)
psEffect2DRenderer * renderer2d
Definition: pseffectobj.h:529