CrystalSpace

Public API Reference

ivideo/rendermesh.h
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2002 by Marten Svanfeldt
00003                         Anders Stenberg
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_RENDERMESH_H__
00021 #define __CS_IVIDEO_RENDERMESH_H__
00022 
00031 #include "csgeom/box.h"
00032 #include "csgeom/transfrm.h"
00033 #include "csgeom/vector3.h"
00034 
00035 #include "iengine/material.h"
00036 #include "ivideo/graph3d.h"
00037 #include "ivideo/shader/shader.h"
00038 
00039 struct iPortalContainer;
00040 
00041 namespace CS
00042 {
00043 namespace Graphics
00044 {
00046   class RenderPriority
00047   {
00048     uint value;
00049   public:
00050     RenderPriority () : value (uint (~0)) {}
00051     explicit RenderPriority (uint value) : value (value) {}
00052     CS_DEPRECATED_METHOD_MSG("Please use CS::Graphics::RenderPriority to store render priorities")
00053     RenderPriority (long value) : value (value) {}
00054     CS_DEPRECATED_METHOD_MSG("Please use CS::Graphics::RenderPriority to store render priorities")
00055     RenderPriority (int value) : value (value) {}
00056     
00057     bool IsValid() const { return value != uint (~0); }
00058     operator uint () const { return value; }
00059   };
00060 
00062   enum MeshCullMode
00063   {
00064     cullNormal,    
00065     cullFlipped,   
00066     cullDisabled   
00067   };
00068   
00074   static inline MeshCullMode GetFlippedCullMode (MeshCullMode cullMode)
00075   {
00076     switch (cullMode)
00077     {
00078       case cullNormal:
00079         return cullFlipped;
00080       case cullFlipped:
00081         return cullNormal;
00082       case cullDisabled: 
00083         return cullDisabled;
00084     }
00085     // Should not happen ...
00086     return cullNormal;
00087   }
00088   
00096   enum AlphaTestFunction
00097   {
00102     atfGreaterEqual,
00107     atfGreater,
00112     atfLowerEqual,
00117     atfLower
00118   };
00119   
00129   struct AlphaTestOptions
00130   {
00135     float threshold;
00140     AlphaTestFunction func;
00141     
00142     AlphaTestOptions() : threshold (0.5f), func (atfGreaterEqual) {}
00143   };
00144 
00151   struct RenderMeshModes
00152   {
00153     RenderMeshModes () : z_buf_mode ((csZBufMode)~0), mixmode (CS_FX_COPY),
00154       alphaToCoverage (false), atcMixmode (CS_MIXMODE_BLEND (ONE, ZERO)),
00155       cullMode (cullNormal),
00156       alphaType (csAlphaMode::alphaNone), zoffset (false), doInstancing (false),
00157       instParams (nullptr), instParamBuffers (nullptr)
00158     {
00159     }
00160 
00161     RenderMeshModes (RenderMeshModes const& x) :
00162       z_buf_mode (x.z_buf_mode),
00163       mixmode (x.mixmode),
00164       alphaToCoverage (x.alphaToCoverage),
00165       atcMixmode (x.atcMixmode),
00166       renderPrio (x.renderPrio),
00167       cullMode (x.cullMode),
00168       alphaType (x.alphaType),
00169       alphaTest (x.alphaTest),
00170       zoffset (x.zoffset),
00171       buffers (x.buffers),
00172       doInstancing (x.doInstancing),
00173       instParamNum (x.instParamNum),
00174       instParamsTargets (x.instParamsTargets),
00175       instanceNum (x.instanceNum),
00176       instParams (x.instParams),
00177       instParamBuffers (x.instParamBuffers)
00178     {
00179     }
00180 
00181     ~RenderMeshModes () { }
00182 
00184     csZBufMode z_buf_mode;
00185 
00187     uint mixmode;
00188     
00196     bool alphaToCoverage;
00198     uint atcMixmode;
00199     
00201     RenderPriority renderPrio;
00202 
00204     MeshCullMode cullMode;
00205 
00215     csAlphaMode::AlphaType alphaType;
00216     
00218     AlphaTestOptions alphaTest;
00219     
00221     bool zoffset;
00222 
00224     csRef<csRenderBufferHolder> buffers;
00225 
00227     bool doInstancing; 
00229     size_t instParamNum; 
00231     const csVertexAttrib* instParamsTargets; 
00233     size_t instanceNum;
00241     csShaderVariable** const * instParams;
00253     iRenderBuffer** instParamBuffers;
00254   };
00255 
00261   struct RenderMeshIndexRange
00262   {
00264     unsigned int start;
00266     unsigned int end;
00267   };
00268 
00272   struct CoreRenderMesh
00273   {
00278     const char* db_mesh_name;
00279 
00280     CoreRenderMesh () : db_mesh_name ("<unknown>"), clip_portal (0), 
00281       clip_plane (0), clip_z_plane (0), do_mirror (false),
00282       multiRanges (0), rangesNum (0), indexstart (0), indexend (0)
00283     {
00284     }
00285 
00286     ~CoreRenderMesh () {}
00287 
00289     int clip_portal;
00290 
00292     int clip_plane;
00293 
00295     int clip_z_plane;
00296 
00297     // @@@ FIXME: should prolly be handled by component managing rendering
00314     bool do_mirror;
00315 
00317     csRenderMeshType meshtype;
00322     RenderMeshIndexRange* multiRanges;
00324     size_t rangesNum;
00325 
00332     unsigned int indexstart;
00333     unsigned int indexend;
00340     iMaterialWrapper* material;
00341 
00346     csReversibleTransform object2world;
00347     
00349     csBox3 bbox;
00350   };
00351 
00356   struct RenderMesh : public CoreRenderMesh, public RenderMeshModes
00357   {
00358     RenderMesh () : geometryInstance (0), portal (0)
00359     {
00360     }
00361 
00362     ~RenderMesh () {}
00363 
00369     void *geometryInstance;
00370 
00372     iPortalContainer* portal;
00373 
00375     csRef<iShaderVariableContext> variablecontext;
00376 
00378     csVector3 worldspace_origin;
00379   };
00380 
00381 } // namespace Graphics
00382 } // namespace CS
00383 
00384 typedef CS::Graphics::RenderMeshModes csRenderMeshModes;
00385 typedef CS::Graphics::CoreRenderMesh csCoreRenderMesh;
00386 typedef CS::Graphics::RenderMesh csRenderMesh;
00387 
00390 #endif // __CS_IVIDEO_RENDERMESH_H__

Generated for Crystal Space 2.0 by doxygen 1.7.6.1