CrystalSpace

Public API Reference

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

ivideo/polyrender.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2003 by Jorrit Tyberghein
00003               (C) 2003 by Frank Richter
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_IVIDEO_POLYRENDER_H__
00021 #define __CS_IVIDEO_POLYRENDER_H__
00022 
00030 #include "csutil/scf.h"
00031 #include "csgeom/plane3.h"
00032 #include "csgeom/matrix3.h"
00033 #include "csgeom/vector3.h"
00034 
00035 class csVector3;
00036 class csMatrix3;
00037 struct csRenderMesh;
00038 
00043 struct csPolyTextureMapping
00044 {
00045 private:
00047   csMatrix3 m_obj2tex;
00049   csVector3 v_obj2tex;
00050 
00051   float fdu, fdv;
00052 
00058   int Imin_u, Imin_v;
00059 
00061   float Fmin_u, Fmin_v, Fmax_u, Fmax_v;
00062 
00064   uint16 shf_u;
00065 
00067   int w; //@@@ renderer specific
00068 
00070   int h; //@@@ renderer specific 
00071 
00073   int w_orig;  //@@@ renderer specific
00074 
00078   float lmu1, lmv1, lmu2, lmv2;
00079 
00080 public:
00081   csPolyTextureMapping() : fdu(0.0f), fdv(0.0f), Imin_u(0), Imin_v(0),
00082     Fmin_u(0.0f), Fmin_v(0.0f), Fmax_u(0.0f), Fmax_v(0.0f), shf_u(0),
00083     w(0), h(0), w_orig(0), 
00084     lmu1(0.0f), lmv1(0.0f), lmu2(0.0f), lmv2(0.0f)
00085   {
00086   }
00087 
00088   const csMatrix3& GetO2T () const { return m_obj2tex; }
00089   csMatrix3& GetO2T () { return m_obj2tex; }
00090   const csVector3& GetO2TTranslation () const { return v_obj2tex; }
00091   csVector3& GetO2TTranslation () { return v_obj2tex; }
00092   void SetO2T (const csMatrix3& m) { m_obj2tex = m; }
00093   void SetO2TTranslation (const csVector3& v) { v_obj2tex = v; }
00094 
00095   csPolyTextureMapping& operator= (const csPolyTextureMapping& other)
00096   {
00097     m_obj2tex = other.m_obj2tex;
00098     v_obj2tex = other.v_obj2tex;
00099     fdu = other.fdu;
00100     fdv = other.fdv;
00101     Imin_u = other.Imin_u;
00102     Imin_v = other.Imin_v;
00103     Fmin_u = other.Fmin_u;
00104     Fmin_v = other.Fmin_v;
00105     Fmax_u = other.Fmax_u;
00106     Fmax_v = other.Fmax_v;
00107     shf_u = other.shf_u;
00108     w = other.w;
00109     h = other.h;
00110     w_orig = other.w_orig;
00111     lmu1 = other.lmu1;
00112     lmv1 = other.lmv1;
00113     lmu2 = other.lmu2;
00114     lmv2 = other.lmv2;
00115     return *this;
00116   }
00117 
00123   int GetShiftU () const { return shf_u; }
00125   void SetShiftU (int su) { shf_u = su; }
00126 
00128   int GetIMinU () const { return Imin_u; }
00130   int GetIMinV () const { return Imin_v; }
00135   void SetIMinUV (int u, int v) { Imin_u = u; Imin_v = v; }
00137   void GetTextureBox (float& fMinU, float& fMinV,
00138     float& fMaxU, float& fMaxV) const
00139   {
00140     fMinU = Fmin_u;
00141     fMaxU = Fmax_u;
00142     fMinV = Fmin_v;
00143     fMaxV = Fmax_v;
00144   }
00146   void SetTextureBox (float fMinU, float fMinV,
00147     float fMaxU, float fMaxV)
00148   {
00149     Fmin_u = fMinU;
00150     Fmax_u = fMaxU;
00151     Fmin_v = fMinV;
00152     Fmax_v = fMaxV;
00153   }
00154 
00156   float GetFDU () const { return fdu; }
00158   float GetFDV () const { return fdv; }
00163   void SetFDUV (float u, float v) { fdu = u; fdv = v; }
00164 
00166   void SetLitWidth (int w)
00167   {
00168     csPolyTextureMapping::w = w;
00169   }
00171   void SetLitHeight (int h)
00172   {
00173     csPolyTextureMapping::h = h;
00174   }
00176   void SetLitOriginalWidth (int w_orig)
00177   {
00178     csPolyTextureMapping::w_orig = w_orig;
00179   }
00181   int GetLitWidth () const { return w; }
00183   int GetLitHeight () const { return h; }
00184 
00186   int GetLitOriginalWidth () const { return w_orig; }
00187 
00189   void GetCoordsOnSuperLM (float& lmu1, float& lmv1,
00190         float& lmu2, float& lmv2) const
00191   {
00192     lmu1 = csPolyTextureMapping::lmu1;
00193     lmv1 = csPolyTextureMapping::lmv1;
00194     lmu2 = csPolyTextureMapping::lmu2;
00195     lmv2 = csPolyTextureMapping::lmv2;
00196   }
00198   void SetCoordsOnSuperLM (float lmu1, float lmv1,
00199         float lmu2, float lmv2)
00200   {
00201     csPolyTextureMapping::lmu1 = lmu1;
00202     csPolyTextureMapping::lmv1 = lmv1;
00203     csPolyTextureMapping::lmu2 = lmu2;
00204     csPolyTextureMapping::lmv2 = lmv2;
00205   }
00206 };
00207 
00212 struct csPolygonRenderData
00213 {
00215   csPlane3 plane_obj;
00217   csPolyTextureMapping* tmapping;
00219   int num_vertices;
00221   int* vertices;
00225   csVector3** p_obj_verts;
00227   bool useLightmap;
00231   csVector3** objNormals;
00232 };
00233 
00234 
00235 
00236 SCF_VERSION (iPolygonRenderer, 0, 1, 0);
00237 
00238 // @@@ Document me.
00239 struct iPolygonRenderer : public iBase
00240 {
00241   virtual void PrepareRenderMesh (csRenderMesh& mesh) = 0;
00242   
00243   virtual void Clear () = 0;
00244   virtual void AddPolygon (csPolygonRenderData* poly) = 0;
00245 };
00246 
00249 #endif // __CS_IVIDEO_POLYRENDER_H__
00250 

Generated for Crystal Space by doxygen 1.2.18