CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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/matrix3.h"
00032 #include "csgeom/plane3.h"
00033 #include "csgeom/vector3.h"
00034 
00035 struct csRenderMesh;
00036 struct iUserRenderBufferIterator;
00037 
00042 struct csPolyTextureMapping
00043 {
00044 private:
00046   csMatrix3 m_obj2tex;
00048   csVector3 v_obj2tex;
00049 
00050   float fdu, fdv;
00051 
00057   int Imin_u, Imin_v;
00058 
00060   float Fmin_u, Fmin_v, Fmax_u, Fmax_v;
00061 
00063   uint16 shf_u;
00064 
00066   int w; //@@@ renderer specific
00067 
00069   int h; //@@@ renderer specific 
00070 
00072   int w_orig;  //@@@ renderer specific
00073 
00077   float lmu1, lmv1, lmu2, lmv2;
00078 public:
00079   csPolyTextureMapping() :
00080     fdu(0.0f), fdv(0.0f), Imin_u(0), Imin_v(0),
00081     Fmin_u(0.0f), Fmin_v(0.0f), Fmax_u(0.0f), Fmax_v(0.0f), shf_u(0),
00082     w(0), h(0), w_orig(0), 
00083     lmu1(0.0f), lmv1(0.0f), lmu2(0.0f), lmv2(0.0f)
00084   {
00085   }
00086 
00087   const csMatrix3& GetO2T () const { return m_obj2tex; }
00088   csMatrix3& GetO2T () { return m_obj2tex; }
00089   const csVector3& GetO2TTranslation () const { return v_obj2tex; }
00090   csVector3& GetO2TTranslation () { return v_obj2tex; }
00091   void SetO2T (const csMatrix3& m) { m_obj2tex = m; }
00092   void SetO2TTranslation (const csVector3& v) { v_obj2tex = v; }
00093 
00094   csPolyTextureMapping& operator= (const csPolyTextureMapping& other)
00095   {
00096     m_obj2tex = other.m_obj2tex;
00097     v_obj2tex = other.v_obj2tex;
00098     fdu = other.fdu;
00099     fdv = other.fdv;
00100     Imin_u = other.Imin_u;
00101     Imin_v = other.Imin_v;
00102     Fmin_u = other.Fmin_u;
00103     Fmin_v = other.Fmin_v;
00104     Fmax_u = other.Fmax_u;
00105     Fmax_v = other.Fmax_v;
00106     shf_u = other.shf_u;
00107     w = other.w;
00108     h = other.h;
00109     w_orig = other.w_orig;
00110     lmu1 = other.lmu1;
00111     lmv1 = other.lmv1;
00112     lmu2 = other.lmu2;
00113     lmv2 = other.lmv2;
00114     return *this;
00115   }
00116 
00122   int GetShiftU () const { return shf_u; }
00124   void SetShiftU (int su) { shf_u = su; }
00125 
00127   int GetIMinU () const { return Imin_u; }
00129   int GetIMinV () const { return Imin_v; }
00134   void SetIMinUV (int u, int v) { Imin_u = u; Imin_v = v; }
00136   void GetTextureBox (float& fMinU, float& fMinV,
00137     float& fMaxU, float& fMaxV) const
00138   {
00139     fMinU = Fmin_u;
00140     fMaxU = Fmax_u;
00141     fMinV = Fmin_v;
00142     fMaxV = Fmax_v;
00143   }
00145   void SetTextureBox (float fMinU, float fMinV,
00146     float fMaxU, float fMaxV)
00147   {
00148     Fmin_u = fMinU;
00149     Fmax_u = fMaxU;
00150     Fmin_v = fMinV;
00151     Fmax_v = fMaxV;
00152   }
00153 
00155   float GetFDU () const { return fdu; }
00157   float GetFDV () const { return fdv; }
00162   void SetFDUV (float u, float v) { fdu = u; fdv = v; }
00163 
00165   void SetLitWidth (int w)
00166   {
00167     csPolyTextureMapping::w = w;
00168   }
00170   void SetLitHeight (int h)
00171   {
00172     csPolyTextureMapping::h = h;
00173   }
00175   void SetLitOriginalWidth (int w_orig)
00176   {
00177     csPolyTextureMapping::w_orig = w_orig;
00178   }
00180   int GetLitWidth () const { return w; }
00182   int GetLitHeight () const { return h; }
00183 
00185   int GetLitOriginalWidth () const { return w_orig; }
00187   void GetCoordsOnSuperLM (float& lmu1, float& lmv1,
00188         float& lmu2, float& lmv2) const
00189   {
00190     lmu1 = csPolyTextureMapping::lmu1;
00191     lmv1 = csPolyTextureMapping::lmv1;
00192     lmu2 = csPolyTextureMapping::lmu2;
00193     lmv2 = csPolyTextureMapping::lmv2;
00194   }
00196   void SetCoordsOnSuperLM (float lmu1, float lmv1,
00197         float lmu2, float lmv2)
00198   {
00199     csPolyTextureMapping::lmu1 = lmu1;
00200     csPolyTextureMapping::lmv1 = lmv1;
00201     csPolyTextureMapping::lmu2 = lmu2;
00202     csPolyTextureMapping::lmv2 = lmv2;
00203   }
00204 };
00205 
00210 struct csPolygonRenderData
00211 {
00213   csPlane3 plane_obj;
00215   csPolyTextureMapping* tmapping;
00217   int num_vertices;
00219   int* vertices;
00223   csVector3** p_obj_verts;
00225   bool useLightmap;
00229   csVector3** objNormals;
00230 };
00231 
00232 
00233 
00234 SCF_VERSION (iPolygonRenderer, 0, 1, 0);
00235 
00236 // @@@ Document me.
00237 struct iPolygonRenderer : public iBase
00238 {
00239   virtual void PrepareRenderMesh (csRenderMesh& mesh) = 0;
00240   
00241   virtual void Clear () = 0;
00242   virtual void AddPolygon (csPolygonRenderData* poly, 
00243     iUserRenderBufferIterator* extraBuffers) = 0;
00244 };
00245 
00248 #endif // __CS_IVIDEO_POLYRENDER_H__
00249 

Generated for Crystal Space by doxygen 1.4.4