CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

halo.h

00001 /*
00002     Copyright (C) 1998-2001 by Jorrit Tyberghein
00003     Copyright (C) 2001 by W.C.A. Wijngaards
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library 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 GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_HALO_H__
00021 #define __CS_HALO_H__
00022 
00023 #include "csgeom/math3d.h"
00024 #include "csengine/light.h"
00025 #include "ivideo/halo.h"
00026 #include "iengine/halo.h"
00027 
00028 class csEngine;
00029 struct iMaterialWrapper;
00030 
00035 class csHalo : public iBaseHalo
00036 {
00038   float Intensity;
00039 
00040 public:
00042   csHaloType Type;
00043 
00045   csHalo (csHaloType iType);
00047   virtual ~csHalo ();
00048 
00050   virtual unsigned char *Generate (int Size) = 0;
00051 
00053   virtual float GetIntensity () { return Intensity; }
00055   virtual void SetIntensity (float iInt) { Intensity = iInt; }
00056 
00057   SCF_DECLARE_IBASE;
00058 };
00059 
00063 class csCrossHalo : public csHalo
00064 {
00065 public:
00067   float IntensityFactor;
00069   float CrossFactor;
00070 
00072   csCrossHalo (float intensity_factor, float cross_factor);
00073 
00075   virtual unsigned char *Generate (int Size);
00076 
00077   //------------------------ iCrossHalo ------------------------------------
00078   SCF_DECLARE_IBASE_EXT (csHalo);
00080   struct CrossHalo : public iCrossHalo
00081   {
00082     SCF_DECLARE_EMBEDDED_IBASE (csCrossHalo);
00083     virtual void SetIntensityFactor (float i)
00084     { scfParent->IntensityFactor = i; }
00085     virtual float GetIntensityFactor ()
00086     { return scfParent->IntensityFactor; }
00087     virtual void SetCrossFactor (float i)
00088     { scfParent->CrossFactor = i; }
00089     virtual float GetCrossFactor ()
00090     { return scfParent->CrossFactor; }
00091   } scfiCrossHalo;
00092   friend struct CrossHalo;
00093 };
00094 
00096 class csNovaHalo : public csHalo
00097 {
00098 public:
00100   int Seed;
00102   int NumSpokes;
00104   float Roundness;
00105 
00107   csNovaHalo (int seed, int num_spokes, float roundness);
00108 
00110   virtual unsigned char *Generate (int Size);
00111 
00112   //------------------------ iNovaHalo ------------------------------------
00113   SCF_DECLARE_IBASE_EXT (csHalo);
00115   struct NovaHalo : public iNovaHalo
00116   {
00117     SCF_DECLARE_EMBEDDED_IBASE (csNovaHalo);
00118     virtual void SetRandomSeed (int s)
00119     { scfParent->Seed = s; }
00120     virtual int GetRandomSeed ()
00121     { return scfParent->Seed; }
00122     virtual void SetSpokeCount (int s)
00123     { scfParent->NumSpokes = s; }
00124     virtual int GetSpokeCount ()
00125     { return scfParent->NumSpokes; }
00126     virtual void SetRoundnessFactor (float r)
00127     { scfParent->Roundness = r; }
00128     virtual float GetRoundnessFactor ()
00129     { return scfParent->Roundness; }
00130   } scfiNovaHalo;
00131   friend struct NovaHalo;
00132 };
00133 
00134 
00136 struct csFlareComponent {
00138   float position;
00140   float width, height;
00142   iMaterialWrapper *image;
00144   uint mixmode;
00146   csFlareComponent *next;
00147 };
00148 
00152 class csFlareHalo : public csHalo
00153 {
00154 private:
00156   csFlareComponent *components;
00158   csFlareComponent *last;
00159 public:
00161   csFlareHalo();
00163   ~csFlareHalo();
00169   void AddComponent(float pos, float w, float h, uint mode,
00170     iMaterialWrapper *image);
00172   csFlareComponent *GetComponents() const {return components;}
00178   virtual unsigned char *Generate (int Size);
00179 
00180   //------------------------ iFlareHalo ------------------------------------
00181   SCF_DECLARE_IBASE_EXT (csHalo);
00183   struct FlareHalo : public iFlareHalo
00184   {
00185     SCF_DECLARE_EMBEDDED_IBASE (csFlareHalo);
00186     virtual void AddComponent (float pos, float w, float h, uint mode,
00187       iMaterialWrapper *image)
00188     {
00189       scfParent->AddComponent (pos, w, h, mode, image);
00190     }
00191   } scfiFlareHalo;
00192   friend struct FlareHalo;
00193 };
00194 
00205 class csLightHalo
00206 {
00207 public:
00209   csLight *Light;
00210 
00212   iHalo *Handle;
00213 
00215   csTicks LastTime;
00216 
00218   csLightHalo (csLight *iLight, iHalo *iHandle);
00219 
00221   virtual ~csLightHalo ();
00222 
00229   virtual bool Process (csTicks ElapsedTime, csEngine const&);
00230 
00235   bool IsVisible(csEngine const& engine, csVector3& v);
00236 
00244   bool ComputeNewIntensity(csTicks ElapsedTime, float& hintensity,
00245     bool halo_vis);
00246 };
00247 
00252 class csLightFlareHalo : public csLightHalo
00253 {
00255   int halosize;
00257   csFlareHalo *flare;
00258 public:
00263   csLightFlareHalo(csLight *light, csFlareHalo *halo, int iHaloSize);
00265   virtual ~csLightFlareHalo();
00266 
00268   virtual bool Process (csTicks elapsed_time, csEngine const& engine);
00270   void ProcessFlareComponent(csEngine const& engine, csFlareComponent *comp,
00271     csVector2 const& start, csVector2 const& deltapos);
00272 };
00273 
00274 #endif // __CS_HALO_H__

Generated for Crystal Space by doxygen 1.2.14