Blender  V2.59
RAS_IRasterizer.h
Go to the documentation of this file.
00001 /*
00002  * $Id: RAS_IRasterizer.h 35390 2011-03-07 19:14:17Z dfelinto $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00034 #ifndef __RAS_IRASTERIZER
00035 #define __RAS_IRASTERIZER
00036 
00037 #if defined(WIN32) && !defined(FREE_WINDOWS)
00038 #pragma warning (disable:4786)
00039 #endif
00040 
00041 #include "STR_HashedString.h"
00042 
00043 #include "MT_CmMatrix4x4.h"
00044 #include "MT_Matrix4x4.h"
00045 
00046 #include "RAS_TexVert.h"
00047 
00048 #include <vector>
00049 using namespace std;
00050 
00051 #ifdef WITH_CXX_GUARDEDALLOC
00052 #include "MEM_guardedalloc.h"
00053 #endif
00054 
00055 class RAS_ICanvas;
00056 class RAS_IPolyMaterial;
00057 
00058 typedef vector<unsigned short> KX_IndexArray;
00059 typedef vector<RAS_TexVert> KX_VertexArray;
00060 typedef vector< KX_VertexArray* >  vecVertexArray;
00061 typedef vector< KX_IndexArray* > vecIndexArrays;
00062 
00066 class RAS_IRasterizer
00067 {
00068 public:
00069         RAS_IRasterizer(RAS_ICanvas* canv){};
00070         virtual ~RAS_IRasterizer(){};
00073         enum    {
00074                         RAS_RENDER_3DPOLYGON_TEXT = 16384       /* TF_BMFONT */
00075         };
00079         enum DrawType {
00080                         KX_BOUNDINGBOX = 1,
00081                         KX_WIREFRAME,
00082                         KX_SOLID,
00083                         KX_SHADED,
00084                         KX_TEXTURED,
00085                         KX_SHADOW
00086         };
00087 
00092         enum DrawMode {
00093                 KX_MODE_LINES = 1,
00094                 KX_MODE_TRIANGLES,
00095                 KX_MODE_QUADS
00096         };
00097 
00101         enum DepthMask {
00102                         KX_DEPTHMASK_ENABLED =1,
00103                         KX_DEPTHMASK_DISABLED
00104         };
00105 
00108         enum    {        
00109                         KX_TEX = 4,                     /* TF_TEX */
00110                         KX_LIGHT = 16,          /* TF_LIGHT */
00111                         KX_TWOSIDE = 512,       /* TF_TWOSIDE */
00112                         KX_LINES = 32768         
00113         };
00114 
00118         enum StereoMode {
00119                         RAS_STEREO_NOSTEREO = 1,
00120                         RAS_STEREO_QUADBUFFERED,
00121                         RAS_STEREO_ABOVEBELOW,
00122                         RAS_STEREO_INTERLACED,
00123                         RAS_STEREO_ANAGLYPH,
00124                         RAS_STEREO_SIDEBYSIDE,
00125                         RAS_STEREO_VINTERLACE,
00126                         RAS_STEREO_DOME,
00127                         
00128                         RAS_STEREO_MAXSTEREO
00129         };
00130 
00134         enum TexCoGen {
00135                 RAS_TEXCO_GEN,          //< GPU will generate texture coordinates
00136                 RAS_TEXCO_ORCO,         //< Vertex coordinates (object space)
00137                 RAS_TEXCO_GLOB,         //< Vertex coordinates (world space)
00138                 RAS_TEXCO_UV1,          //< UV coordinates
00139                 RAS_TEXCO_OBJECT,       //< Use another object's position as coordinates
00140                 RAS_TEXCO_LAVECTOR,     //< Light vector as coordinates
00141                 RAS_TEXCO_VIEW,         //< View vector as coordinates
00142                 RAS_TEXCO_STICKY,       //< Sticky coordinates
00143                 RAS_TEXCO_WINDOW,       //< Window coordinates
00144                 RAS_TEXCO_NORM,         //< Normal coordinates 
00145                 RAS_TEXTANGENT,         //<
00146                 RAS_TEXCO_UV2,          //<
00147                 RAS_TEXCO_VCOL,         //< Vertex Color
00148                 RAS_TEXCO_DISABLE       //< Disable this texture unit (cached)
00149         };
00150 
00154         enum StereoEye {
00155                         RAS_STEREO_LEFTEYE = 1,
00156                         RAS_STEREO_RIGHTEYE
00157         };
00158 
00163         virtual void    SetDepthMask(DepthMask depthmask)=0;
00169         virtual bool    SetMaterial(const RAS_IPolyMaterial& mat)=0;
00173         virtual bool    Init()=0;
00177         virtual void    Exit()=0;
00181         virtual bool    BeginFrame(int drawingmode, double time)=0;
00185         virtual void    ClearColorBuffer()=0;
00189         virtual void    ClearDepthBuffer()=0;
00193         virtual void    ClearCachingInfo(void)=0;
00197         virtual void    EndFrame()=0;
00202         virtual void    SetRenderArea()=0;
00203 
00204         // Stereo Functions
00208         virtual void    SetStereoMode(const StereoMode stereomode)=0;
00213         virtual bool    Stereo()=0;
00214     virtual StereoMode GetStereoMode()=0;
00215         virtual bool    InterlacedStereo()=0;
00219         virtual void    SetEye(const StereoEye eye)=0;
00220         virtual StereoEye       GetEye()=0;
00224         virtual void    SetEyeSeparation(const float eyeseparation)=0;
00225         virtual float   GetEyeSeparation() = 0;
00229         virtual void    SetFocalLength(const float focallength)=0;
00230         virtual float   GetFocalLength() = 0;
00234         virtual void    SwapBuffers()=0;
00235         
00236         // Drawing Functions
00240         virtual void IndexPrimitives(class RAS_MeshSlot& ms)=0;
00241         virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms)=0;
00242 
00247         virtual void    IndexPrimitives_3DText(class RAS_MeshSlot& ms,
00248                                                         class RAS_IPolyMaterial* polymat,
00249                                                         class RAS_IRenderTools* rendertools)=0;
00250 
00251         virtual void    SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0;
00252         /* This one should become our final version, methinks. */
00258         virtual void    SetProjectionMatrix(const MT_Matrix4x4 & mat)=0;
00262         virtual void    SetViewMatrix(const MT_Matrix4x4 & mat,
00263                                                                 const MT_Matrix3x3 & ori,
00264                                                                 const MT_Point3 & pos,
00265                                                                 bool perspective)=0;
00268         virtual const   MT_Point3& GetCameraPosition()=0;
00269         virtual bool    GetCameraOrtho()=0;
00270 
00273         virtual void    SetFog(float start,
00274                                                    float dist,
00275                                                    float r,
00276                                                    float g,
00277                                                    float b)=0;
00278         
00279         virtual void    SetFogColor(float r,
00280                                                                 float g,
00281                                                                 float b)=0;
00282 
00283         virtual void    SetFogStart(float start)=0;
00286         virtual void    SetFogEnd(float end)=0;
00289         virtual void    DisplayFog()=0;
00292         virtual void    DisableFog()=0;
00293         virtual bool    IsFogEnabled()=0;
00294 
00295         virtual void    SetBackColor(float red,
00296                                                                  float green,
00297                                                                  float blue,
00298                                                                  float alpha)=0;
00299         
00303         virtual void    SetDrawingMode(int drawingmode)=0;
00307         virtual int     GetDrawingMode()=0;
00311         virtual void    SetCullFace(bool enable)=0;
00315         virtual void    SetLines(bool enable)=0;
00318         virtual double  GetTime()=0;
00329         virtual MT_Matrix4x4 GetFrustumMatrix(
00330                 float left,
00331                 float right,
00332                 float bottom,
00333                 float top,
00334                 float frustnear,
00335                 float frustfar,
00336                 float focallength = 0.0f,
00337                 bool perspective = true
00338         )=0;
00339 
00350         virtual MT_Matrix4x4 GetOrthoMatrix(
00351                 float left,
00352                 float right,
00353                 float bottom,
00354                 float top,
00355                 float frustnear,
00356                 float frustfar
00357         )=0;
00358 
00362         virtual void    SetSpecularity(float specX,
00363                                                                    float specY,
00364                                                                    float specZ,
00365                                                                    float specval)=0;
00366         
00370         virtual void    SetShinyness(float shiny)=0;
00374         virtual void    SetDiffuse(float difX,
00375                                                            float difY,
00376                                                            float difZ,
00377                                                            float diffuse)=0;
00381         virtual void    SetEmissive(float eX,
00382                                                                 float eY,
00383                                                                 float eZ,
00384                                                                 float e
00385                                                            )=0;
00386         
00387         virtual void    SetAmbientColor(float red, float green, float blue)=0;
00388         virtual void    SetAmbient(float factor)=0;
00389 
00393         virtual void    SetPolygonOffset(float mult, float add) = 0;
00394         
00395         virtual void    DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)=0;
00396         virtual void    FlushDebugLines()=0;
00397         
00398 
00399 
00400         virtual void    SetTexCoordNum(int num) = 0;
00401         virtual void    SetAttribNum(int num) = 0;
00402         virtual void    SetTexCoord(TexCoGen coords, int unit) = 0;
00403         virtual void    SetAttrib(TexCoGen coords, int unit) = 0;
00404 
00405         virtual const MT_Matrix4x4&     GetViewMatrix() const = 0;
00406         virtual const MT_Matrix4x4&     GetViewInvMatrix() const = 0;
00407 
00408         virtual bool    QueryLists(){return false;}
00409         virtual bool    QueryArrays(){return false;}
00410         
00411         virtual void    EnableMotionBlur(float motionblurvalue)=0;
00412         virtual void    DisableMotionBlur()=0;
00413         
00414         virtual float   GetMotionBlurValue()=0;
00415         virtual int             GetMotionBlurState()=0;
00416         virtual void    SetMotionBlurState(int newstate)=0;
00417 
00418         virtual void    SetBlendingMode(int blendmode)=0;
00419         virtual void    SetFrontFace(bool ccw)=0;
00420         
00421         
00422 #ifdef WITH_CXX_GUARDEDALLOC
00423 public:
00424         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_IRasterizer"); }
00425         void operator delete( void *mem ) { MEM_freeN(mem); }
00426 #endif
00427 };
00428 
00429 #endif //__RAS_IRASTERIZER
00430 
00431