Blender V2.61 - r43446

RAS_IRasterizer.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef __RAS_IRASTERIZER
00033 #define __RAS_IRASTERIZER
00034 
00035 #if defined(WIN32) && !defined(FREE_WINDOWS)
00036 #pragma warning (disable:4786)
00037 #endif
00038 
00039 #include "STR_HashedString.h"
00040 
00041 #include "MT_CmMatrix4x4.h"
00042 #include "MT_Matrix4x4.h"
00043 
00044 #include "RAS_TexVert.h"
00045 
00046 #include <vector>
00047 using namespace std;
00048 
00049 #ifdef WITH_CXX_GUARDEDALLOC
00050 #include "MEM_guardedalloc.h"
00051 #endif
00052 
00053 class RAS_ICanvas;
00054 class RAS_IPolyMaterial;
00055 
00056 typedef vector<unsigned short> KX_IndexArray;
00057 typedef vector<RAS_TexVert> KX_VertexArray;
00058 typedef vector< KX_VertexArray* >  vecVertexArray;
00059 typedef vector< KX_IndexArray* > vecIndexArrays;
00060 
00064 class RAS_IRasterizer
00065 {
00066 public:
00067     RAS_IRasterizer(RAS_ICanvas* canv){};
00068     virtual ~RAS_IRasterizer(){};
00069 
00073     enum DrawType {
00074             KX_BOUNDINGBOX = 1,
00075             KX_WIREFRAME,
00076             KX_SOLID,
00077             KX_SHADED,
00078             KX_TEXTURED,
00079             KX_SHADOW
00080     };
00081 
00086     enum DrawMode {
00087         KX_MODE_LINES = 1,
00088         KX_MODE_TRIANGLES,
00089         KX_MODE_QUADS
00090     };
00091 
00095     enum DepthMask {
00096             KX_DEPTHMASK_ENABLED =1,
00097             KX_DEPTHMASK_DISABLED
00098     };
00099 
00102     enum    {    
00103             RAS_RENDER_3DPOLYGON_TEXT = 64, /* GEMAT_TEXT */
00104             KX_BACKCULL = 16,       /* GEMAT_BACKCULL */
00105             KX_TEX = 4096,          /* GEMAT_TEX */
00106             KX_LINES = 32768     
00107     };
00108 
00112     enum StereoMode {
00113             RAS_STEREO_NOSTEREO = 1,
00114             RAS_STEREO_QUADBUFFERED,
00115             RAS_STEREO_ABOVEBELOW,
00116             RAS_STEREO_INTERLACED,
00117             RAS_STEREO_ANAGLYPH,
00118             RAS_STEREO_SIDEBYSIDE,
00119             RAS_STEREO_VINTERLACE,
00120             RAS_STEREO_DOME,
00121             
00122             RAS_STEREO_MAXSTEREO
00123     };
00124 
00128     enum TexCoGen {
00129         RAS_TEXCO_GEN,      //< GPU will generate texture coordinates
00130         RAS_TEXCO_ORCO,     //< Vertex coordinates (object space)
00131         RAS_TEXCO_GLOB,     //< Vertex coordinates (world space)
00132         RAS_TEXCO_UV1,      //< UV coordinates
00133         RAS_TEXCO_OBJECT,   //< Use another object's position as coordinates
00134         RAS_TEXCO_LAVECTOR, //< Light vector as coordinates
00135         RAS_TEXCO_VIEW,     //< View vector as coordinates
00136         RAS_TEXCO_STICKY,   //< Sticky coordinates
00137         RAS_TEXCO_WINDOW,   //< Window coordinates
00138         RAS_TEXCO_NORM,     //< Normal coordinates 
00139         RAS_TEXTANGENT,     //<
00140         RAS_TEXCO_UV2,      //<
00141         RAS_TEXCO_VCOL,     //< Vertex Color
00142         RAS_TEXCO_DISABLE   //< Disable this texture unit (cached)
00143     };
00144 
00148     enum StereoEye {
00149             RAS_STEREO_LEFTEYE = 1,
00150             RAS_STEREO_RIGHTEYE
00151     };
00152 
00157     virtual void    SetDepthMask(DepthMask depthmask)=0;
00163     virtual bool    SetMaterial(const RAS_IPolyMaterial& mat)=0;
00167     virtual bool    Init()=0;
00171     virtual void    Exit()=0;
00175     virtual bool    BeginFrame(int drawingmode, double time)=0;
00179     virtual void    ClearColorBuffer()=0;
00183     virtual void    ClearDepthBuffer()=0;
00187     virtual void    ClearCachingInfo(void)=0;
00191     virtual void    EndFrame()=0;
00196     virtual void    SetRenderArea()=0;
00197 
00198     // Stereo Functions
00202     virtual void    SetStereoMode(const StereoMode stereomode)=0;
00207     virtual bool    Stereo()=0;
00208     virtual StereoMode GetStereoMode()=0;
00209     virtual bool    InterlacedStereo()=0;
00213     virtual void    SetEye(const StereoEye eye)=0;
00214     virtual StereoEye   GetEye()=0;
00218     virtual void    SetEyeSeparation(const float eyeseparation)=0;
00219     virtual float   GetEyeSeparation() = 0;
00223     virtual void    SetFocalLength(const float focallength)=0;
00224     virtual float   GetFocalLength() = 0;
00228     virtual void    SwapBuffers()=0;
00229     
00230     // Drawing Functions
00234     virtual void IndexPrimitives(class RAS_MeshSlot& ms)=0;
00235     virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms)=0;
00236 
00241     virtual void    IndexPrimitives_3DText(class RAS_MeshSlot& ms,
00242                             class RAS_IPolyMaterial* polymat,
00243                             class RAS_IRenderTools* rendertools)=0;
00244 
00245     virtual void    SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0;
00246     /* This one should become our final version, methinks. */
00252     virtual void    SetProjectionMatrix(const MT_Matrix4x4 & mat)=0;
00256     virtual void    SetViewMatrix(const MT_Matrix4x4 & mat,
00257                                 const MT_Matrix3x3 & ori,
00258                                 const MT_Point3 & pos,
00259                                 bool perspective)=0;
00262     virtual const   MT_Point3& GetCameraPosition()=0;
00263     virtual bool    GetCameraOrtho()=0;
00264 
00267     virtual void    SetFog(float start,
00268                            float dist,
00269                            float r,
00270                            float g,
00271                            float b)=0;
00272     
00273     virtual void    SetFogColor(float r,
00274                                 float g,
00275                                 float b)=0;
00276 
00277     virtual void    SetFogStart(float start)=0;
00280     virtual void    SetFogEnd(float end)=0;
00283     virtual void    DisplayFog()=0;
00286     virtual void    DisableFog()=0;
00287     virtual bool    IsFogEnabled()=0;
00288 
00289     virtual void    SetBackColor(float red,
00290                                  float green,
00291                                  float blue,
00292                                  float alpha)=0;
00293     
00297     virtual void    SetDrawingMode(int drawingmode)=0;
00301     virtual int GetDrawingMode()=0;
00305     virtual void    SetCullFace(bool enable)=0;
00309     virtual void    SetLines(bool enable)=0;
00312     virtual double  GetTime()=0;
00323     virtual MT_Matrix4x4 GetFrustumMatrix(
00324         float left,
00325         float right,
00326         float bottom,
00327         float top,
00328         float frustnear,
00329         float frustfar,
00330         float focallength = 0.0f,
00331         bool perspective = true
00332     )=0;
00333 
00344     virtual MT_Matrix4x4 GetOrthoMatrix(
00345         float left,
00346         float right,
00347         float bottom,
00348         float top,
00349         float frustnear,
00350         float frustfar
00351     )=0;
00352 
00356     virtual void    SetSpecularity(float specX,
00357                                    float specY,
00358                                    float specZ,
00359                                    float specval)=0;
00360     
00364     virtual void    SetShinyness(float shiny)=0;
00368     virtual void    SetDiffuse(float difX,
00369                                float difY,
00370                                float difZ,
00371                                float diffuse)=0;
00375     virtual void    SetEmissive(float eX,
00376                                 float eY,
00377                                 float eZ,
00378                                 float e
00379                                )=0;
00380     
00381     virtual void    SetAmbientColor(float red, float green, float blue)=0;
00382     virtual void    SetAmbient(float factor)=0;
00383 
00387     virtual void    SetPolygonOffset(float mult, float add) = 0;
00388     
00389     virtual void    DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)=0;
00390     virtual void    DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
00391                                     const MT_Vector3& normal, int nsector)=0;
00392     virtual void    FlushDebugShapes()=0;
00393     
00394 
00395 
00396     virtual void    SetTexCoordNum(int num) = 0;
00397     virtual void    SetAttribNum(int num) = 0;
00398     virtual void    SetTexCoord(TexCoGen coords, int unit) = 0;
00399     virtual void    SetAttrib(TexCoGen coords, int unit) = 0;
00400 
00401     virtual const MT_Matrix4x4& GetViewMatrix() const = 0;
00402     virtual const MT_Matrix4x4& GetViewInvMatrix() const = 0;
00403 
00404     virtual bool    QueryLists(){return false;}
00405     virtual bool    QueryArrays(){return false;}
00406     
00407     virtual void    EnableMotionBlur(float motionblurvalue)=0;
00408     virtual void    DisableMotionBlur()=0;
00409     
00410     virtual float   GetMotionBlurValue()=0;
00411     virtual int     GetMotionBlurState()=0;
00412     virtual void    SetMotionBlurState(int newstate)=0;
00413 
00414     virtual void    SetAlphaBlend(int alphablend)=0;
00415     virtual void    SetFrontFace(bool ccw)=0;
00416 
00417     virtual void    SetAnisotropicFiltering(short level)=0;
00418     virtual short   GetAnisotropicFiltering()=0;
00419     
00420     
00421 #ifdef WITH_CXX_GUARDEDALLOC
00422 public:
00423     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IRasterizer"); }
00424     void operator delete( void *mem ) { MEM_freeN(mem); }
00425 #endif
00426 };
00427 
00428 #endif //__RAS_IRASTERIZER
00429 
00430