Planeshift
pseffectobjquad.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_QUAD_HEADER
21 #define PS_EFFECT_OBJ_QUAD_HEADER
22 
23 #include "pseffectobj.h"
24 #include <imesh/genmesh.h>
25 #include <csutil/cscolor.h>
26 
27 class psEffect2DRenderer;
28 
30 {
31 public:
32  struct MeshAnimControl : public scfImplementation1<MeshAnimControl, iGenMeshAnimationControl>
33  {
34  private:
35  psEffectObjQuad* parent;
36 
37  public:
38  MeshAnimControl(psEffectObjQuad* parent) : scfImplementationType(this)
39  {
40  this->parent = parent;
41  }
42 
43  virtual ~MeshAnimControl()
44  {
45  parent = 0;
46  }
47 
48  void Update(csTicks /*elapsed*/, int /*num_verts*/, uint32 /*version_id*/)
49  {
50  }
51 
52  // genmesh animation control
53  bool AnimatesVertices() const
54  {
55  return false;
56  }
57  bool AnimatesTexels() const
58  {
59  return true;
60  }
61  bool AnimatesNormals() const
62  {
63  return false;
64  }
65  bool AnimatesColors() const
66  {
67  return false;
68  }
69  bool AnimatesBBoxRadius() const
70  {
71  return false;
72  }
73 
74  const csBox3 &UpdateBoundingBox(csTicks /*current*/, uint32 /*version_id*/, const csBox3 &bbox)
75  {
76  return bbox;
77  }
78  const float UpdateRadius(csTicks /*current*/, uint32 /*version_id*/, const float radius)
79  {
80  return radius;
81  }
82  const csBox3* UpdateBoundingBoxes(csTicks /*current*/, uint32 /*version_id*/)
83  {
84  return nullptr;
85  }
86  const csVector3* UpdateVertices(csTicks current, const csVector3* verts, int num_verts, uint32 version_id);
87  const csVector2* UpdateTexels(csTicks current, const csVector2* texels, int num_texels, uint32 version_id);
88  const csVector3* UpdateNormals(csTicks /*current*/, const csVector3* normals, int /*num_normals*/,
89  uint32 /*version_id*/)
90  {
91  return normals;
92  }
93  const csColor4* UpdateColors(csTicks /*current*/, const csColor4* colors, int /*num_colors*/,
94  uint32 /*version_id*/)
95  {
96  return colors;
97  }
98  };
99  csRef<MeshAnimControl> meshControl;
100  friend struct MeshAnimControl;
101 
102  psEffectObjQuad(iView* parentView, psEffect2DRenderer* renderer2d);
103  virtual ~psEffectObjQuad();
104 
105  // inheritted function overloads
106  virtual bool Load(iDocumentNode* node, iLoaderContext* ldr_context);
107  virtual bool Render(const csVector3 &up);
108  virtual bool Update(csTicks elapsed);
109  virtual void CloneBase(psEffectObj* newObj) const;
110  virtual psEffectObj* Clone() const;
111 
112 
113 protected:
114 
118  virtual bool PostSetup();
119 
122  virtual bool CreateMeshFact();
123 
128  virtual bool UseUniqueMeshFact() const;
129 
130  csRef<iGeneralMeshState> genState;
131 
132  csVector3 vert[4];
133  csVector2 texel[4];
134 
135  csRef<iMaterialWrapper> mat;
136 
137  float quadAspect;
138 };
139 
140 #endif
const float UpdateRadius(csTicks, uint32, const float radius)
virtual void CloneBase(psEffectObj *newObj) const
Convenience function to clone the base member variables.
virtual bool UseUniqueMeshFact() const
Decides whether or not this quad will have a unique mesh factory per effect instance.
void Update(csTicks, int, uint32)
virtual ~psEffectObjQuad()
csRef< iGeneralMeshState > genState
csVector3 vert[4]
The manager of all 2D effect elements.
csVector2 texel[4]
MeshAnimControl(psEffectObjQuad *parent)
const csBox3 * UpdateBoundingBoxes(csTicks, uint32)
virtual bool Render(const csVector3 &up)
Renders the effect.
virtual bool CreateMeshFact()
Creates a mesh factory for this quad.
const csVector3 * UpdateVertices(csTicks current, const csVector3 *verts, int num_verts, uint32 version_id)
const csVector2 * UpdateTexels(csTicks current, const csVector2 *texels, int num_texels, uint32 version_id)
const csColor4 * UpdateColors(csTicks, const csColor4 *colors, int, uint32)
psEffectObjQuad(iView *parentView, psEffect2DRenderer *renderer2d)
An effect is not much more than a collection of effect objects.
Definition: pseffectobj.h:207
const csBox3 & UpdateBoundingBox(csTicks, uint32, const csBox3 &bbox)
csRef< iMaterialWrapper > mat
const csVector3 * UpdateNormals(csTicks, const csVector3 *normals, int, uint32)
virtual bool Load(iDocumentNode *node, iLoaderContext *ldr_context)
Loads the effect object from an xml node.
csRef< MeshAnimControl > meshControl
virtual bool PostSetup()
performs the post setup (after the effect obj has been loaded).
virtual psEffectObj * Clone() const
Clones the effect object.
psEffect2DRenderer * renderer2d
Definition: pseffectobj.h:529