Style cleanup: BGE

This commit is contained in:
2013-12-24 05:44:54 +11:00
committed by Campbell Barton
parent 0a5e00e8e8
commit d94db03ac8
7 changed files with 412 additions and 583 deletions

View File

@@ -64,22 +64,19 @@
/* end of blender include block */
BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World* blenderworld)
BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World *blenderworld)
{
if (blenderworld)
{
if (blenderworld) {
m_hasworld = true;
// do we have mist?
if ((blenderworld->mode) & WO_MIST)
{
if ((blenderworld->mode) & WO_MIST) {
m_hasmist = true;
m_miststart = blenderworld->miststa;
m_mistdistance = blenderworld->mistdist;
copy_v3_v3(m_mistcolor, &blenderworld->horr);
}
else
{
else {
m_hasmist = false;
m_miststart = 0.0;
m_mistdistance = 0.0;
@@ -95,53 +92,39 @@ BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World* ble
linearrgb_to_srgb_v3_v3(m_ambientcolor, m_ambientcolor);
}
}
else
{
else {
m_hasworld = false;
}
}
BlenderWorldInfo::~BlenderWorldInfo()
{
}
bool BlenderWorldInfo::hasWorld()
{
return m_hasworld;
}
bool BlenderWorldInfo::hasMist()
{
return m_hasmist;
}
float BlenderWorldInfo::getBackColorRed()
{
return m_backgroundcolor[0];
}
float BlenderWorldInfo::getBackColorGreen()
{
return m_backgroundcolor[1];
}
}
float BlenderWorldInfo::getBackColorBlue()
{
return m_backgroundcolor[2];
}
}
float BlenderWorldInfo::getAmbientColorRed()
{
@@ -163,28 +146,20 @@ float BlenderWorldInfo::getMistStart()
return m_miststart;
}
float BlenderWorldInfo::getMistDistance()
{
return m_mistdistance;
}
float BlenderWorldInfo::getMistColorRed()
{
return m_mistcolor[0];
}
float BlenderWorldInfo::getMistColorGreen()
{
return m_mistcolor[1];
}
}
float BlenderWorldInfo::getMistColorBlue()
{
@@ -198,41 +173,27 @@ void BlenderWorldInfo::setBackColor(float r, float g, float b)
m_backgroundcolor[2] = b;
}
void
BlenderWorldInfo::setMistStart(
float d
) {
void BlenderWorldInfo::setMistStart(float d)
{
m_miststart = d;
}
void
BlenderWorldInfo::setMistDistance(
float d
) {
void BlenderWorldInfo::setMistDistance(float d)
{
m_mistdistance = d;
}
void
BlenderWorldInfo::setMistColorRed(
float d
) {
void BlenderWorldInfo::setMistColorRed(float d)
{
m_mistcolor[0] = d;
}
void
BlenderWorldInfo::setMistColorGreen(
float d
) {
void BlenderWorldInfo::setMistColorGreen(float d)
{
m_mistcolor[1] = d;
}
void
BlenderWorldInfo::setMistColorBlue(
float d
) {
void BlenderWorldInfo::setMistColorBlue(float d)
{
m_mistcolor[2] = d;
}

View File

@@ -36,68 +36,44 @@
class BlenderWorldInfo : public KX_WorldInfo
{
bool m_hasworld;
float m_backgroundcolor[3];
bool m_hasworld;
float m_backgroundcolor[3];
bool m_hasmist;
float m_miststart;
float m_mistdistance;
float m_mistcolor[3];
bool m_hasmist;
float m_miststart;
float m_mistdistance;
float m_mistcolor[3];
float m_ambientcolor[3];
float m_ambientcolor[3];
public:
BlenderWorldInfo(struct Scene *blenderscene, struct World* blenderworld);
BlenderWorldInfo(struct Scene *blenderscene, struct World *blenderworld);
~BlenderWorldInfo();
bool hasWorld();
bool hasMist();
float getBackColorRed();
float getBackColorGreen();
float getBackColorBlue();
float getAmbientColorRed();
float getAmbientColorGreen();
float getAmbientColorBlue();
bool hasWorld();
bool hasMist();
float getBackColorRed();
float getBackColorGreen();
float getBackColorBlue();
float getMistStart();
float getMistDistance();
float getMistColorRed();
float getMistColorGreen();
float getMistColorBlue();
float getAmbientColorRed();
float getAmbientColorGreen();
float getAmbientColorBlue();
void
setBackColor(
float r,
float g,
float b
);
void
setMistStart(
float d
);
float getMistStart();
float getMistDistance();
float getMistColorRed();
float getMistColorGreen();
float getMistColorBlue();
void
setMistDistance(
float d
);
void setBackColor(float r, float g, float b);
void setMistStart(float d);
void setMistDistance(float d);
void setMistColorRed(float d);
void setMistColorGreen(float d);
void setMistColorBlue(float d);
void
setMistColorRed(
float d
);
void
setMistColorGreen(
float d
);
void
setMistColorBlue(
float d
);
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:BlenderWorldInfo")
#endif

View File

@@ -34,32 +34,33 @@
#include "KX_Python.h"
#include "STR_String.h"
#include "MT_Vector3.h"
typedef enum {
psl_Lowest = 0,
psl_Highest
psl_Highest,
} TPythonSecurityLevel;
extern bool gUseVisibilityTemp;
#ifdef WITH_PYTHON
PyObject* initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene* ketsjiscene);
PyObject* initGameKeys();
PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas);
PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie, int argc, char** argv);
PyObject* initVideoTexture(void);
void exitGamePlayerPythonScripting();
PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, struct Main *maggie);
void exitGamePythonScripting();
PyObject *initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene *ketsjiscene);
PyObject *initGameKeys();
PyObject *initRasterizer(class RAS_IRasterizer *rasty,class RAS_ICanvas *canvas);
PyObject *initGamePlayerPythonScripting(const STR_String &progname, TPythonSecurityLevel level,
struct Main *maggie, int argc, char **argv);
PyObject *initVideoTexture(void);
PyObject *initGamePythonScripting(const STR_String &progname, TPythonSecurityLevel level, struct Main *maggie);
void exitGamePlayerPythonScripting();
void exitGamePythonScripting();
void setupGamePython(KX_KetsjiEngine *ketsjiengine, KX_Scene *startscene, Main *blenderdata,
PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv);
void setGamePythonPath(const char *path);
void resetGamePythonPath();
void pathGamePythonConfig( char *path );
int saveGamePythonConfig( char **marshal_buffer);
int loadGamePythonConfig(char *marshal_buffer, int marshal_length);
PyObject *pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char **argv);
void setGamePythonPath(const char *path);
void resetGamePythonPath();
void pathGamePythonConfig(char *path);
int saveGamePythonConfig(char **marshal_buffer);
int loadGamePythonConfig(char *marshal_buffer, int marshal_length);
#endif
void addImportMain(struct Main *maggie);
@@ -68,9 +69,9 @@ void removeImportMain(struct Main *maggie);
class KX_KetsjiEngine;
class KX_Scene;
void KX_SetActiveScene(class KX_Scene* scene);
class KX_Scene* KX_GetActiveScene();
class KX_KetsjiEngine* KX_GetActiveEngine();
void KX_SetActiveScene(class KX_Scene *scene);
class KX_Scene *KX_GetActiveScene();
class KX_KetsjiEngine *KX_GetActiveEngine();
typedef int (*PyNextFrameFunc)(void *);
@@ -82,11 +83,9 @@ struct PyNextFrameState {
};
extern struct PyNextFrameState pynextframestate;
#include "MT_Vector3.h"
void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color);
void KX_RasterizerDrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
const MT_Vector3& normal, int nsector);
void KX_RasterizerDrawDebugLine(const MT_Vector3 &from,const MT_Vector3 &to,const MT_Vector3 &color);
void KX_RasterizerDrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
const MT_Vector3 &normal, int nsector);
#endif /* __KX_PYTHONINIT_H__ */

View File

@@ -46,29 +46,29 @@ public:
KX_WorldInfo() {}
virtual ~KX_WorldInfo();
virtual bool hasWorld()=0;
virtual bool hasMist()=0;
virtual float getBackColorRed()=0;
virtual float getBackColorGreen()=0;
virtual float getBackColorBlue()=0;
virtual float getMistStart()=0;
virtual float getMistDistance()=0;
virtual float getMistColorRed()=0;
virtual float getMistColorGreen()=0;
virtual float getMistColorBlue()=0;
virtual bool hasWorld() = 0;
virtual bool hasMist() = 0;
virtual float getBackColorRed() = 0;
virtual float getBackColorGreen() = 0;
virtual float getBackColorBlue() = 0;
virtual float getMistStart() = 0;
virtual float getMistDistance() = 0;
virtual float getMistColorRed() = 0;
virtual float getMistColorGreen() = 0;
virtual float getMistColorBlue() = 0;
virtual float getAmbientColorRed() = 0;
virtual float getAmbientColorGreen() = 0;
virtual float getAmbientColorBlue() = 0;
virtual void setBackColor(float, float, float) = 0;
virtual void setMistStart(float) = 0;
virtual void setMistDistance(float) = 0;
virtual void setMistColorRed(float) = 0;
virtual void setMistColorGreen(float) = 0;
virtual void setMistColorBlue(float) = 0;
virtual float getAmbientColorRed()=0;
virtual float getAmbientColorGreen()=0;
virtual float getAmbientColorBlue()=0;
virtual void setBackColor(float,float,float)=0;
virtual void setMistStart(float)=0;
virtual void setMistDistance(float)=0;
virtual void setMistColorRed(float)=0;
virtual void setMistColorGreen(float)=0;
virtual void setMistColorBlue(float)=0;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:KX_WorldInfo")
#endif

View File

@@ -56,8 +56,8 @@ class RAS_MeshSlot;
typedef vector<unsigned short> KX_IndexArray;
typedef vector<RAS_TexVert> KX_VertexArray;
typedef vector< KX_VertexArray* > vecVertexArray;
typedef vector< KX_IndexArray* > vecIndexArrays;
typedef vector<KX_VertexArray *> vecVertexArray;
typedef vector<KX_IndexArray *> vecIndexArrays;
/**
* 3D rendering device context interface.
@@ -69,7 +69,7 @@ public:
RAS_TEXT_RENDER_NODEF = 0,
RAS_TEXT_NORMAL,
RAS_TEXT_PADDED,
RAS_TEXT_MAX
RAS_TEXT_MAX,
};
RAS_IRasterizer(RAS_ICanvas* canv) {};
@@ -79,12 +79,12 @@ public:
* Drawing types
*/
enum DrawType {
KX_BOUNDINGBOX = 1,
KX_WIREFRAME,
KX_SOLID,
KX_SHADED,
KX_TEXTURED,
KX_SHADOW
KX_BOUNDINGBOX = 1,
KX_WIREFRAME,
KX_SOLID,
KX_SHADED,
KX_TEXTURED,
KX_SHADOW,
};
/**
@@ -94,67 +94,67 @@ public:
enum DrawMode {
KX_MODE_LINES = 1,
KX_MODE_TRIANGLES,
KX_MODE_QUADS
KX_MODE_QUADS,
};
/**
* Valid SetDepthMask parameters
*/
enum DepthMask {
KX_DEPTHMASK_ENABLED =1,
KX_DEPTHMASK_DISABLED
KX_DEPTHMASK_ENABLED = 1,
KX_DEPTHMASK_DISABLED,
};
/**
*/
enum {
RAS_RENDER_3DPOLYGON_TEXT = 64, /* GEMAT_TEXT */
KX_BACKCULL = 16, /* GEMAT_BACKCULL */
KX_TEX = 4096, /* GEMAT_TEX */
KX_LINES = 32768
RAS_RENDER_3DPOLYGON_TEXT = 64, /* GEMAT_TEXT */
KX_BACKCULL = 16, /* GEMAT_BACKCULL */
KX_TEX = 4096, /* GEMAT_TEX */
KX_LINES = 32768,
};
/**
* Stereo mode types
*/
enum StereoMode {
RAS_STEREO_NOSTEREO = 1,
RAS_STEREO_QUADBUFFERED,
RAS_STEREO_ABOVEBELOW,
RAS_STEREO_INTERLACED,
RAS_STEREO_ANAGLYPH,
RAS_STEREO_SIDEBYSIDE,
RAS_STEREO_VINTERLACE,
RAS_STEREO_DOME,
RAS_STEREO_MAXSTEREO
RAS_STEREO_NOSTEREO = 1,
RAS_STEREO_QUADBUFFERED,
RAS_STEREO_ABOVEBELOW,
RAS_STEREO_INTERLACED,
RAS_STEREO_ANAGLYPH,
RAS_STEREO_SIDEBYSIDE,
RAS_STEREO_VINTERLACE,
RAS_STEREO_DOME,
RAS_STEREO_MAXSTEREO
};
/**
* Texture gen modes.
*/
enum TexCoGen {
RAS_TEXCO_GEN, //< GPU will generate texture coordinates
RAS_TEXCO_ORCO, //< Vertex coordinates (object space)
RAS_TEXCO_GLOB, //< Vertex coordinates (world space)
RAS_TEXCO_UV, //< UV coordinates
RAS_TEXCO_OBJECT, //< Use another object's position as coordinates
RAS_TEXCO_LAVECTOR, //< Light vector as coordinates
RAS_TEXCO_VIEW, //< View vector as coordinates
RAS_TEXCO_STICKY, //< Sticky coordinates
RAS_TEXCO_WINDOW, //< Window coordinates
RAS_TEXCO_NORM, //< Normal coordinates
RAS_TEXTANGENT, //<
RAS_TEXCO_VCOL, //< Vertex Color
RAS_TEXCO_DISABLE //< Disable this texture unit (cached)
RAS_TEXCO_GEN, /* < GPU will generate texture coordinates */
RAS_TEXCO_ORCO, /* < Vertex coordinates (object space) */
RAS_TEXCO_GLOB, /* < Vertex coordinates (world space) */
RAS_TEXCO_UV, /* < UV coordinates */
RAS_TEXCO_OBJECT, /* < Use another object's position as coordinates */
RAS_TEXCO_LAVECTOR, /* < Light vector as coordinates */
RAS_TEXCO_VIEW, /* < View vector as coordinates */
RAS_TEXCO_STICKY, /* < Sticky coordinates */
RAS_TEXCO_WINDOW, /* < Window coordinates */
RAS_TEXCO_NORM, /* < Normal coordinates */
RAS_TEXTANGENT, /* < */
RAS_TEXCO_VCOL, /* < Vertex Color */
RAS_TEXCO_DISABLE, /* < Disable this texture unit (cached) */
};
/**
* Render pass identifiers for stereo.
*/
enum StereoEye {
RAS_STEREO_LEFTEYE = 1,
RAS_STEREO_RIGHTEYE
RAS_STEREO_LEFTEYE = 1,
RAS_STEREO_RIGHTEYE,
};
/**
@@ -165,167 +165,170 @@ public:
RAS_MIPMAP_NEAREST,
RAS_MIPMAP_LINEAR,
RAS_MIPMAP_MAX, // Should always be last
RAS_MIPMAP_MAX, /* Should always be last */
};
/**
* SetDepthMask enables or disables writing a fragment's depth value
* to the Z buffer.
*/
virtual void SetDepthMask(DepthMask depthmask)=0;
virtual void SetDepthMask(DepthMask depthmask) = 0;
/**
* SetMaterial sets the material settings for subsequent primitives
* to be rendered with.
* The material will be cached.
*/
virtual bool SetMaterial(const RAS_IPolyMaterial& mat)=0;
virtual bool SetMaterial(const RAS_IPolyMaterial &mat) = 0;
/**
* Init initializes the renderer.
*/
virtual bool Init()=0;
virtual bool Init() = 0;
/**
* Exit cleans up the renderer.
*/
virtual void Exit()=0;
virtual void Exit() = 0;
/**
* BeginFrame is called at the start of each frame.
*/
virtual bool BeginFrame(int drawingmode, double time)=0;
virtual bool BeginFrame(int drawingmode, double time) = 0;
/**
* ClearColorBuffer clears the color buffer.
*/
virtual void ClearColorBuffer()=0;
virtual void ClearColorBuffer() = 0;
/**
* ClearDepthBuffer clears the depth buffer.
*/
virtual void ClearDepthBuffer()=0;
virtual void ClearDepthBuffer() = 0;
/**
* ClearCachingInfo clears the currently cached material.
*/
virtual void ClearCachingInfo(void)=0;
virtual void ClearCachingInfo(void) = 0;
/**
* EndFrame is called at the end of each frame.
*/
virtual void EndFrame()=0;
virtual void EndFrame() = 0;
/**
* SetRenderArea sets the render area from the 2d canvas.
* Returns true if only of subset of the canvas is used.
*/
virtual void SetRenderArea()=0;
virtual void SetRenderArea() = 0;
// Stereo Functions
/**
* SetStereoMode will set the stereo mode
*/
virtual void SetStereoMode(const StereoMode stereomode)=0;
virtual void SetStereoMode(const StereoMode stereomode) = 0;
/**
* Stereo can be used to query if the rasterizer is in stereo mode.
* \return true if stereo mode is enabled.
*/
virtual bool Stereo()=0;
virtual StereoMode GetStereoMode()=0;
virtual bool InterlacedStereo()=0;
virtual bool Stereo() = 0;
virtual StereoMode GetStereoMode() = 0;
virtual bool InterlacedStereo() = 0;
/**
* Sets which eye buffer subsequent primitives will be rendered to.
*/
virtual void SetEye(const StereoEye eye)=0;
virtual StereoEye GetEye()=0;
virtual void SetEye(const StereoEye eye) = 0;
virtual StereoEye GetEye() = 0;
/**
* Sets the distance between eyes for stereo mode.
*/
virtual void SetEyeSeparation(const float eyeseparation)=0;
virtual float GetEyeSeparation() = 0;
virtual void SetEyeSeparation(const float eyeseparation) = 0;
virtual float GetEyeSeparation() = 0;
/**
* Sets the focal length for stereo mode.
*/
virtual void SetFocalLength(const float focallength)=0;
virtual float GetFocalLength() = 0;
virtual void SetFocalLength(const float focallength) = 0;
virtual float GetFocalLength() = 0;
/**
* SwapBuffers swaps the back buffer with the front buffer.
*/
virtual void SwapBuffers()=0;
virtual void SwapBuffers() = 0;
// Drawing Functions
/**
* IndexPrimitives: Renders primitives from mesh slot.
*/
virtual void IndexPrimitives(class RAS_MeshSlot& ms)=0;
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms)=0;
virtual void IndexPrimitives(class RAS_MeshSlot &ms) = 0;
virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms) = 0;
/**
* IndexPrimitives_3DText will render text into the polygons.
*/
virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms,
class RAS_IPolyMaterial* polymat)=0;
virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat) = 0;
virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat) = 0;
virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0;
/* This one should become our final version, methinks. */
/**
* Set the projection matrix for the rasterizer. This projects
* from camera coordinates to window coordinates.
* \param mat The projection matrix.
*/
virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat)=0;
virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat) = 0;
/**
* Sets the modelview matrix.
*/
virtual void SetViewMatrix(const MT_Matrix4x4 & mat,
const MT_Matrix3x3 & ori,
const MT_Point3 & pos,
bool perspective)=0;
/**
*/
virtual const MT_Point3& GetCameraPosition()=0;
virtual bool GetCameraOrtho()=0;
virtual void SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Matrix3x3 &ori,
const MT_Point3 &pos, bool perspective) = 0;
/**
*/
virtual void SetFog(float start,
float dist,
float r,
float g,
float b)=0;
virtual void SetFogColor(float r,
float g,
float b)=0;
virtual const MT_Point3& GetCameraPosition() = 0;
virtual bool GetCameraOrtho() = 0;
virtual void SetFogStart(float start)=0;
/**
* Fog
*/
virtual void SetFogEnd(float end)=0;
/**
*/
virtual void DisplayFog()=0;
/**
*/
virtual void DisableFog()=0;
virtual bool IsFogEnabled()=0;
virtual void SetFog(float start, float dist, float r, float g, float b) = 0;
virtual void SetFogColor(float r, float g,float b) = 0;
virtual void SetFogStart(float start) = 0;
virtual void SetFogEnd(float end) = 0;
virtual void DisplayFog() = 0;
virtual void DisableFog() = 0;
virtual bool IsFogEnabled() = 0;
virtual void SetBackColor(float red,
float green,
float blue,
float alpha)=0;
virtual void SetBackColor(float red, float green, float blue, float alpha) = 0;
/**
* \param drawingmode = KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
*/
virtual void SetDrawingMode(int drawingmode)=0;
virtual void SetDrawingMode(int drawingmode) = 0;
/**
* \return the current drawing mode: KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
*/
virtual int GetDrawingMode()=0;
virtual int GetDrawingMode() = 0;
/**
* Sets face culling
*/
virtual void SetCullFace(bool enable)=0;
virtual void SetCullFace(bool enable) = 0;
/**
* Sets wireframe mode.
*/
virtual void SetLines(bool enable)=0;
virtual void SetLines(bool enable) = 0;
/**
*/
virtual double GetTime()=0;
virtual double GetTime() = 0;
/**
* Generates a projection matrix from the specified frustum.
* \param left the left clipping plane
@@ -337,15 +340,9 @@ public:
* \return a 4x4 matrix representing the projection transform.
*/
virtual MT_Matrix4x4 GetFrustumMatrix(
float left,
float right,
float bottom,
float top,
float frustnear,
float frustfar,
float focallength = 0.0f,
bool perspective = true
)=0;
float left, float right, float bottom, float top,
float frustnear, float frustfar,
float focallength = 0.0f, bool perspective = true) = 0;
/**
* Generates a orthographic projection matrix from the specified frustum.
@@ -358,91 +355,76 @@ public:
* \return a 4x4 matrix representing the projection transform.
*/
virtual MT_Matrix4x4 GetOrthoMatrix(
float left,
float right,
float bottom,
float top,
float frustnear,
float frustfar
)=0;
float left, float right, float bottom, float top,
float frustnear, float frustfar) = 0;
/**
* Sets the specular color component of the lighting equation.
*/
virtual void SetSpecularity(float specX,
float specY,
float specZ,
float specval)=0;
virtual void SetSpecularity(float specX, float specY, float specZ, float specval) = 0;
/**
* Sets the specular exponent component of the lighting equation.
*/
virtual void SetShinyness(float shiny)=0;
virtual void SetShinyness(float shiny) = 0;
/**
* Sets the diffuse color component of the lighting equation.
*/
virtual void SetDiffuse(float difX,
float difY,
float difZ,
float diffuse)=0;
virtual void SetDiffuse(float difX,float difY, float difZ, float diffuse) = 0;
/**
* Sets the emissive color component of the lighting equation.
*/
virtual void SetEmissive(float eX,
float eY,
float eZ,
float e
)=0;
virtual void SetEmissive(float eX, float eY, float eZ, float e) = 0;
virtual void SetAmbientColor(float red, float green, float blue)=0;
virtual void SetAmbient(float factor)=0;
virtual void SetAmbientColor(float red, float green, float blue) = 0;
virtual void SetAmbient(float factor) = 0;
/**
* Sets a polygon offset. z depth will be: z1 = mult*z0 + add
*/
virtual void SetPolygonOffset(float mult, float add) = 0;
virtual void DrawDebugLine(const MT_Vector3& from, const MT_Vector3& to, const MT_Vector3& color)=0;
virtual void DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
const MT_Vector3& normal, int nsector)=0;
virtual void FlushDebugShapes()=0;
virtual void DrawDebugLine(const MT_Vector3 &from, const MT_Vector3 &to, const MT_Vector3& color) = 0;
virtual void DrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
const MT_Vector3 &normal, int nsector) = 0;
virtual void FlushDebugShapes() = 0;
virtual void SetTexCoordNum(int num) = 0;
virtual void SetAttribNum(int num) = 0;
virtual void SetTexCoord(TexCoGen coords, int unit) = 0;
virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0) = 0;
virtual const MT_Matrix4x4 &GetViewMatrix() const = 0;
virtual const MT_Matrix4x4 &GetViewInvMatrix() const = 0;
virtual void SetTexCoordNum(int num) = 0;
virtual void SetAttribNum(int num) = 0;
virtual void SetTexCoord(TexCoGen coords, int unit) = 0;
virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0) = 0;
virtual const MT_Matrix4x4& GetViewMatrix() const = 0;
virtual const MT_Matrix4x4& GetViewInvMatrix() const = 0;
virtual bool QueryLists() { return false; }
virtual bool QueryArrays() { return false; }
virtual bool QueryLists() { return false; }
virtual bool QueryArrays() { return false; }
virtual void EnableMotionBlur(float motionblurvalue)=0;
virtual void DisableMotionBlur()=0;
virtual void EnableMotionBlur(float motionblurvalue) = 0;
virtual void DisableMotionBlur() = 0;
virtual float GetMotionBlurValue()=0;
virtual int GetMotionBlurState()=0;
virtual void SetMotionBlurState(int newstate)=0;
virtual float GetMotionBlurValue() = 0;
virtual int GetMotionBlurState() = 0;
virtual void SetMotionBlurState(int newstate) = 0;
virtual void SetAlphaBlend(int alphablend)=0;
virtual void SetFrontFace(bool ccw)=0;
virtual void SetAlphaBlend(int alphablend) = 0;
virtual void SetFrontFace(bool ccw) = 0;
virtual void SetAnisotropicFiltering(short level)=0;
virtual short GetAnisotropicFiltering()=0;
virtual void SetAnisotropicFiltering(short level) = 0;
virtual short GetAnisotropicFiltering() = 0;
virtual void SetMipmapping(MipmapOption val)=0;
virtual MipmapOption GetMipmapping()=0;
virtual void SetMipmapping(MipmapOption val) = 0;
virtual MipmapOption GetMipmapping() = 0;
virtual void SetUsingOverrideShader(bool val)=0;
virtual bool GetUsingOverrideShader()=0;
virtual void SetUsingOverrideShader(bool val) = 0;
virtual bool GetUsingOverrideShader() = 0;
/**
* Render Tools
*/
virtual void applyTransform(double* oglmatrix, int drawingmode)=0;
virtual void applyTransform(double *oglmatrix, int drawingmode) = 0;
/**
* Renders 2D boxes.
@@ -452,11 +434,7 @@ public:
* \param height Height of the canvas to draw to.
* \param percentage Percentage of bar.
*/
virtual void RenderBox2D(int xco,
int yco,
int width,
int height,
float percentage) = 0;
virtual void RenderBox2D(int xco, int yco, int width, int height, float percentage) = 0;
/**
* Renders 3D text string using BFL.
@@ -468,15 +446,9 @@ public:
* \param mat The Matrix of the text object.
* \param aspect A scaling factor to compensate for the size.
*/
virtual void RenderText3D(int fontid,
const char* text,
int size,
int dpi,
float* color,
double* mat,
float aspect
) = 0;
virtual void RenderText3D(
int fontid, const char *text, int size, int dpi,
const float color[4], const double mat[16], float aspect) = 0;
/**
* Renders 2D text string.
@@ -487,29 +459,25 @@ public:
* \param width Width of the canvas to draw to.
* \param height Height of the canvas to draw to.
*/
virtual void RenderText2D(RAS_TEXT_RENDER_MODE mode,
const char* text,
int xco,
int yco,
int width,
int height
) = 0;
virtual void RenderText2D(
RAS_TEXT_RENDER_MODE mode, const char *text,
int xco, int yco, int width, int height) = 0;
virtual void ProcessLighting(bool uselights, const MT_Transform& trans)=0;
virtual void ProcessLighting(bool uselights, const MT_Transform &trans) = 0;
virtual void PushMatrix()=0;
virtual void PushMatrix() = 0;
virtual void PopMatrix()=0;
virtual void PopMatrix() = 0;
virtual void AddLight(struct RAS_LightObject* lightobject)=0;
virtual void AddLight(struct RAS_LightObject *lightobject) = 0;
virtual void RemoveLight(struct RAS_LightObject* lightobject)=0;
virtual void RemoveLight(struct RAS_LightObject *lightobject) = 0;
virtual void MotionBlur()=0;
virtual void MotionBlur() = 0;
virtual void SetClientObject(void* obj)=0;
virtual void SetClientObject(void *obj) = 0;
virtual void SetAuxilaryClientInfo(void* inf)=0;
virtual void SetAuxilaryClientInfo(void *inf) = 0;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_IRasterizer")

View File

@@ -1439,13 +1439,9 @@ void RAS_OpenGLRasterizer::RenderBox2D(int xco,
glEnable(GL_DEPTH_TEST);
}
void RAS_OpenGLRasterizer::RenderText3D(int fontid,
const char* text,
int size,
int dpi,
float* color,
double* mat,
float aspect)
void RAS_OpenGLRasterizer::RenderText3D(
int fontid, const char *text, int size, int dpi,
const float color[4], const double mat[16], float aspect)
{
/* gl prepping */
DisableForText();
@@ -1464,17 +1460,16 @@ void RAS_OpenGLRasterizer::RenderText3D(int fontid,
BLF_size(fontid, size, dpi);
BLF_position(fontid, 0, 0, 0);
BLF_draw(fontid, (char *)text, 65535);
BLF_draw(fontid, text, 65535);
BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
}
void RAS_OpenGLRasterizer::RenderText2D(RAS_TEXT_RENDER_MODE mode,
const char* text,
int xco,
int yco,
int width,
int height)
void RAS_OpenGLRasterizer::RenderText2D(
RAS_TEXT_RENDER_MODE mode,
const char* text,
int xco, int yco,
int width, int height)
{
/* This is a rather important line :( The gl-mode hasn't been left
* behind quite as neatly as we'd have wanted to. I don't know
@@ -1497,14 +1492,14 @@ void RAS_OpenGLRasterizer::RenderText2D(RAS_TEXT_RENDER_MODE mode,
glColor3ub(0, 0, 0);
BLF_size(blf_mono_font, 11, 72);
BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f);
BLF_draw(blf_mono_font, (char *)text, 65535);/* XXX, use real len */
BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */
}
/* the actual drawing */
glColor3ub(255, 255, 255);
BLF_size(blf_mono_font, 11, 72);
BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
BLF_draw(blf_mono_font, (char *)text, 65535); /* XXX, use real len */
BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */
glMatrixMode(GL_PROJECTION);
glPopMatrix();

View File

@@ -47,26 +47,27 @@ using namespace std;
class RAS_IStorage;
class RAS_ICanvas;
#define RAS_MAX_TEXCO 8 // match in BL_Material
#define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader
#define RAS_MAX_TEXCO 8 /* match in BL_Material */
#define RAS_MAX_ATTRIB 16 /* match in BL_BlenderShader */
enum RAS_STORAGE_TYPE {
RAS_AUTO_STORAGE,
RAS_IMMEDIATE,
RAS_VA,
RAS_VBO
RAS_VBO,
};
struct OglDebugShape
struct OglDebugShape
{
enum SHAPE_TYPE{
LINE, CIRCLE
LINE,
CIRCLE,
};
SHAPE_TYPE m_type;
MT_Vector3 m_pos;
MT_Vector3 m_param;
MT_Vector3 m_param2;
MT_Vector3 m_color;
SHAPE_TYPE m_type;
MT_Vector3 m_pos;
MT_Vector3 m_param;
MT_Vector3 m_param2;
MT_Vector3 m_color;
};
/**
@@ -74,78 +75,76 @@ struct OglDebugShape
*/
class RAS_OpenGLRasterizer : public RAS_IRasterizer
{
RAS_ICanvas* m_2DCanvas;
RAS_ICanvas *m_2DCanvas;
// fogging vars
bool m_fogenabled;
float m_fogstart;
float m_fogdist;
float m_fogr;
float m_fogg;
float m_fogb;
/* fogging vars */
bool m_fogenabled;
float m_fogstart;
float m_fogdist;
float m_fogr;
float m_fogg;
float m_fogb;
float m_redback;
float m_greenback;
float m_blueback;
float m_alphaback;
float m_redback;
float m_greenback;
float m_blueback;
float m_alphaback;
float m_ambr;
float m_ambg;
float m_ambb;
double m_time;
MT_Matrix4x4 m_viewmatrix;
MT_Matrix4x4 m_viewinvmatrix;
MT_Point3 m_campos;
bool m_camortho;
float m_ambr;
float m_ambg;
float m_ambb;
double m_time;
MT_Matrix4x4 m_viewmatrix;
MT_Matrix4x4 m_viewinvmatrix;
MT_Point3 m_campos;
bool m_camortho;
StereoMode m_stereomode;
StereoEye m_curreye;
float m_eyeseparation;
float m_focallength;
bool m_setfocallength;
int m_noOfScanlines;
StereoMode m_stereomode;
StereoEye m_curreye;
float m_eyeseparation;
float m_focallength;
bool m_setfocallength;
int m_noOfScanlines;
short m_prevafvalue;
short m_prevafvalue;
//motion blur
int m_motionblur;
float m_motionblurvalue;
/* motion blur */
int m_motionblur;
float m_motionblurvalue;
bool m_usingoverrideshader;
// Render tools
void* m_clientobject;
void* m_auxilaryClientInfo;
std::vector<struct RAS_LightObject*> m_lights;
int m_lastlightlayer;
bool m_lastlighting;
void *m_lastauxinfo;
/* Render tools */
void *m_clientobject;
void *m_auxilaryClientInfo;
std::vector<struct RAS_LightObject *> m_lights;
int m_lastlightlayer;
bool m_lastlighting;
void *m_lastauxinfo;
unsigned int m_numgllights;
protected:
int m_drawingmode;
TexCoGen m_texco[RAS_MAX_TEXCO];
TexCoGen m_attrib[RAS_MAX_ATTRIB];
int m_attrib_layer[RAS_MAX_ATTRIB];
int m_texco_num;
int m_attrib_num;
//int m_last_alphablend;
bool m_last_frontface;
int m_drawingmode;
TexCoGen m_texco[RAS_MAX_TEXCO];
TexCoGen m_attrib[RAS_MAX_ATTRIB];
int m_attrib_layer[RAS_MAX_ATTRIB];
int m_texco_num;
int m_attrib_num;
/* int m_last_alphablend; */
bool m_last_frontface;
/** Stores the caching information for the last material activated. */
/* Stores the caching information for the last material activated. */
RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo;
/**
* Making use of a Strategy design pattern for storage behavior.
/* Making use of a Strategy design pattern for storage behavior.
* Examples of concrete strategies: Vertex Arrays, VBOs, Immediate Mode*/
int m_storage_type;
RAS_IStorage* m_storage;
RAS_IStorage* m_failsafe_storage; //So derived mesh can use immediate mode
int m_storage_type;
RAS_IStorage *m_storage;
RAS_IStorage *m_failsafe_storage; /* So derived mesh can use immediate mode */
public:
double GetTime();
RAS_OpenGLRasterizer(RAS_ICanvas* canv, int storage=RAS_AUTO_STORAGE);
RAS_OpenGLRasterizer(RAS_ICanvas *canv, int storage=RAS_AUTO_STORAGE);
virtual ~RAS_OpenGLRasterizer();
/*enum DrawType
@@ -162,130 +161,79 @@ public:
KX_DEPTHMASK_ENABLED =1,
KX_DEPTHMASK_DISABLED,
};*/
virtual void SetDepthMask(DepthMask depthmask);
virtual void SetDepthMask(DepthMask depthmask);
virtual bool SetMaterial(const RAS_IPolyMaterial& mat);
virtual bool Init();
virtual void Exit();
virtual bool BeginFrame(int drawingmode, double time);
virtual void ClearColorBuffer();
virtual void ClearDepthBuffer();
virtual void ClearCachingInfo(void);
virtual void EndFrame();
virtual void SetRenderArea();
virtual bool SetMaterial(const RAS_IPolyMaterial &mat);
virtual bool Init();
virtual void Exit();
virtual bool BeginFrame(int drawingmode, double time);
virtual void ClearColorBuffer();
virtual void ClearDepthBuffer();
virtual void ClearCachingInfo(void);
virtual void EndFrame();
virtual void SetRenderArea();
virtual void SetStereoMode(const StereoMode stereomode);
virtual void SetStereoMode(const StereoMode stereomode);
virtual RAS_IRasterizer::StereoMode GetStereoMode();
virtual bool Stereo();
virtual bool InterlacedStereo();
virtual void SetEye(const StereoEye eye);
virtual StereoEye GetEye();
virtual void SetEyeSeparation(const float eyeseparation);
virtual float GetEyeSeparation();
virtual void SetFocalLength(const float focallength);
virtual float GetFocalLength();
virtual bool Stereo();
virtual bool InterlacedStereo();
virtual void SetEye(const StereoEye eye);
virtual StereoEye GetEye();
virtual void SetEyeSeparation(const float eyeseparation);
virtual float GetEyeSeparation();
virtual void SetFocalLength(const float focallength);
virtual float GetFocalLength();
virtual void SwapBuffers();
virtual void SwapBuffers();
virtual void IndexPrimitives(class RAS_MeshSlot& ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms,
class RAS_IPolyMaterial* polymat);
virtual void IndexPrimitives(class RAS_MeshSlot &ms);
virtual void IndexPrimitivesMulti(class RAS_MeshSlot &ms);
virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat);
virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat);
virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat);
virtual void SetViewMatrix(
const MT_Matrix4x4 & mat,
const MT_Matrix3x3 & ori,
const MT_Point3 & pos,
bool perspective
);
virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat);
virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat);
virtual void SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Matrix3x3 &ori, const MT_Point3 &pos, bool perspective);
virtual const MT_Point3& GetCameraPosition();
virtual bool GetCameraOrtho();
virtual const MT_Point3& GetCameraPosition();
virtual bool GetCameraOrtho();
virtual void SetFog(
float start,
float dist,
float r,
float g,
float b
);
virtual void SetFog(float start, float dist, float r, float g, float b);
virtual void SetFogColor(float r, float g, float b);
virtual void SetFogStart(float fogstart);
virtual void SetFogEnd(float fogend);
void DisableFog();
virtual void DisplayFog();
virtual bool IsFogEnabled();
virtual void SetFogColor(
float r,
float g,
float b
);
virtual void SetFogStart(float fogstart);
virtual void SetFogEnd(float fogend);
void DisableFog();
virtual void DisplayFog();
virtual bool IsFogEnabled();
virtual void SetBackColor(
float red,
float green,
float blue,
float alpha
);
virtual void SetBackColor(float red, float green, float blue, float alpha);
virtual void SetDrawingMode(int drawingmode);
virtual int GetDrawingMode();
virtual void SetDrawingMode(int drawingmode);
virtual int GetDrawingMode();
virtual void SetCullFace(bool enable);
virtual void SetLines(bool enable);
virtual void SetCullFace(bool enable);
virtual void SetLines(bool enable);
virtual MT_Matrix4x4 GetFrustumMatrix(
float left,
float right,
float bottom,
float top,
float frustnear,
float frustfar,
float focallength,
bool perspective
);
float left, float right, float bottom, float top,
float frustnear, float frustfar,
float focallength, bool perspective);
virtual MT_Matrix4x4 GetOrthoMatrix(
float left,
float right,
float bottom,
float top,
float frustnear,
float frustfar
);
float left, float right, float bottom, float top,
float frustnear, float frustfar);
virtual void SetSpecularity(
float specX,
float specY,
float specZ,
float specval
);
virtual void SetSpecularity(float specX, float specY, float specZ, float specval);
virtual void SetShinyness(float shiny);
virtual void SetDiffuse(float difX, float difY, float difZ, float diffuse);
virtual void SetEmissive(float eX, float eY, float eZ, float e);
virtual void SetShinyness(float shiny);
virtual void SetDiffuse(
float difX,
float difY,
float difZ,
float diffuse
);
virtual void SetEmissive(float eX,
float eY,
float eZ,
float e
);
virtual void SetAmbientColor(float red, float green, float blue);
virtual void SetAmbient(float factor);
virtual void SetAmbientColor(float red, float green, float blue);
virtual void SetAmbient(float factor);
virtual void SetPolygonOffset(float mult, float add);
virtual void SetPolygonOffset(float mult, float add);
virtual void FlushDebugShapes();
virtual void FlushDebugShapes();
virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)
virtual void DrawDebugLine(const MT_Vector3 &from,const MT_Vector3 &to, const MT_Vector3 &color)
{
OglDebugShape line;
line.m_type = OglDebugShape::LINE;
@@ -295,8 +243,8 @@ public:
m_debugShapes.push_back(line);
}
virtual void DrawDebugCircle(const MT_Vector3& center, const MT_Scalar radius, const MT_Vector3& color,
const MT_Vector3& normal, int nsector)
virtual void DrawDebugCircle(const MT_Vector3 &center, const MT_Scalar radius, const MT_Vector3 &color,
const MT_Vector3 &normal, int nsector)
{
OglDebugShape line;
line.m_type = OglDebugShape::CIRCLE;
@@ -317,14 +265,14 @@ public:
void TexCoord(const RAS_TexVert &tv);
const MT_Matrix4x4& GetViewMatrix() const;
const MT_Matrix4x4& GetViewInvMatrix() const;
const MT_Matrix4x4 &GetViewMatrix() const;
const MT_Matrix4x4 &GetViewInvMatrix() const;
virtual void EnableMotionBlur(float motionblurvalue);
virtual void DisableMotionBlur();
virtual float GetMotionBlurValue() { return m_motionblurvalue; }
virtual int GetMotionBlurState() { return m_motionblur; }
virtual void SetMotionBlurState(int newstate)
virtual void EnableMotionBlur(float motionblurvalue);
virtual void DisableMotionBlur();
virtual float GetMotionBlurValue() { return m_motionblurvalue; }
virtual int GetMotionBlurState() { return m_motionblur; }
virtual void SetMotionBlurState(int newstate)
{
if (newstate < 0)
m_motionblur = 0;
@@ -332,68 +280,50 @@ public:
m_motionblur = 2;
else
m_motionblur = newstate;
};
}
virtual void SetAlphaBlend(int alphablend);
virtual void SetFrontFace(bool ccw);
virtual void SetAlphaBlend(int alphablend);
virtual void SetFrontFace(bool ccw);
virtual void SetAnisotropicFiltering(short level);
virtual short GetAnisotropicFiltering();
virtual void SetAnisotropicFiltering(short level);
virtual short GetAnisotropicFiltering();
virtual void SetMipmapping(MipmapOption val);
virtual void SetMipmapping(MipmapOption val);
virtual MipmapOption GetMipmapping();
virtual void SetUsingOverrideShader(bool val);
virtual bool GetUsingOverrideShader();
virtual void SetUsingOverrideShader(bool val);
virtual bool GetUsingOverrideShader();
/**
* Render Tools
*/
void EnableOpenGLLights();
void DisableOpenGLLights();
void ProcessLighting(bool uselights, const MT_Transform& viewmat);
void EnableOpenGLLights();
void DisableOpenGLLights();
void ProcessLighting(bool uselights, const MT_Transform &viewmat);
void RenderBox2D(int xco,
int yco,
int width,
int height,
float percentage);
void RenderBox2D(int xco, int yco, int width, int height, float percentage);
void RenderText3D(int fontid, const char *text, int size, int dpi,
const float color[4], const double mat[16], float aspect);
void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char *text,
int xco, int yco, int width, int height);
void applyTransform(double *oglmatrix, int objectdrawmode);
void RenderText3D(int fontid,
const char* text,
int size,
int dpi,
float* color,
double* mat,
float aspect);
void PushMatrix();
void PopMatrix();
void RenderText2D(RAS_TEXT_RENDER_MODE mode,
const char* text,
int xco,
int yco,
int width,
int height);
bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, void * const data);
bool NeedRayCast(struct KX_ClientObjectInfo *) { return true; }
void applyTransform(double* oglmatrix, int objectdrawmode);
void PushMatrix();
void PopMatrix();
bool RayHit(struct KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data);
bool NeedRayCast(struct KX_ClientObjectInfo*) { return true; }
void AddLight(struct RAS_LightObject* lightobject);
void RemoveLight(struct RAS_LightObject* lightobject);
int ApplyLights(int objectlayer, const MT_Transform& viewmat);
void AddLight(struct RAS_LightObject *lightobject);
void RemoveLight(struct RAS_LightObject *lightobject);
int ApplyLights(int objectlayer, const MT_Transform &viewmat);
void MotionBlur();
void SetClientObject(void* obj);
void SetClientObject(void *obj);
void SetAuxilaryClientInfo(void* inf);
void SetAuxilaryClientInfo(void *inf);
#ifdef WITH_CXX_GUARDEDALLOC