2011-02-22 12:42:55 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2011-02-22 12:42:55 +00:00
|
|
|
|
|
|
|
|
/** \file RAS_OpenGLRasterizer.h
|
|
|
|
|
* \ingroup bgerastogl
|
|
|
|
|
*/
|
|
|
|
|
|
2012-02-23 10:41:31 +00:00
|
|
|
#ifndef __RAS_OPENGLRASTERIZER_H__
|
|
|
|
|
#define __RAS_OPENGLRASTERIZER_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-10-15 02:15:07 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
# pragma warning (disable:4786)
|
2002-10-12 11:37:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "MT_CmMatrix4x4.h"
|
|
|
|
|
#include <vector>
|
2015-07-27 10:58:19 +02:00
|
|
|
#include <map>
|
2002-10-12 11:37:38 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
#include "RAS_IRasterizer.h"
|
|
|
|
|
#include "RAS_MaterialBucket.h"
|
2013-11-04 19:22:10 +00:00
|
|
|
#include "RAS_IPolygonMaterial.h"
|
|
|
|
|
|
BGE : Collision mask support in raycast + and raycast cleanup.
I have removed the m_pHitObject, m_xray and m_testPropName and replace them by a temporary struct "RayCastData" which contains these datas and a collision mask. Finally i add a collision mask argument in the python function "rayCast" :
```
rayCast(to, from, dist, prop, face, xray, poly, mask)
```
It can be useful to hit only object which are on the right colision layer. for example if you have hitbox for a charater or vehicle you don't want to hit it with raycast.
test file : {F237337}
left mouse click on two planes and see console messages.
Somewhat more elaborate test file by @sybren: {F237779}
Look around and click on the cubes. One cube lamp responds, the other doesn't, based on their collision groups.
Reviewers: moguri, hg1, agoose77, campbellbarton, sybren
Reviewed By: agoose77, campbellbarton, sybren
Subscribers: campbellbarton, sergey, blueprintrandom, sybren
Projects: #game_engine, #game_physics
Differential Revision: https://developer.blender.org/D1239
2015-10-07 22:14:43 +02:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2013-11-04 19:22:10 +00:00
|
|
|
class RAS_IStorage;
|
|
|
|
|
class RAS_ICanvas;
|
2014-03-27 22:32:06 -07:00
|
|
|
class RAS_OpenGLLight;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
#define RAS_MAX_TEXCO 8 /* match in BL_Material */
|
|
|
|
|
#define RAS_MAX_ATTRIB 16 /* match in BL_BlenderShader */
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2013-11-04 19:22:10 +00:00
|
|
|
enum RAS_STORAGE_TYPE {
|
|
|
|
|
RAS_AUTO_STORAGE,
|
|
|
|
|
RAS_VA,
|
2013-12-24 05:44:54 +11:00
|
|
|
RAS_VBO,
|
2013-11-04 19:22:10 +00:00
|
|
|
};
|
|
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
struct OglDebugShape
|
2005-07-27 09:30:53 +00:00
|
|
|
{
|
2010-06-10 00:25:04 +00:00
|
|
|
enum SHAPE_TYPE{
|
2013-12-24 05:44:54 +11:00
|
|
|
LINE,
|
|
|
|
|
CIRCLE,
|
2010-06-10 00:25:04 +00:00
|
|
|
};
|
2013-12-24 05:44:54 +11:00
|
|
|
SHAPE_TYPE m_type;
|
|
|
|
|
MT_Vector3 m_pos;
|
|
|
|
|
MT_Vector3 m_param;
|
|
|
|
|
MT_Vector3 m_param2;
|
|
|
|
|
MT_Vector3 m_color;
|
2005-07-27 09:30:53 +00:00
|
|
|
};
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
|
* 3D rendering device context.
|
|
|
|
|
*/
|
|
|
|
|
class RAS_OpenGLRasterizer : public RAS_IRasterizer
|
|
|
|
|
{
|
2013-12-24 05:44:54 +11:00
|
|
|
RAS_ICanvas *m_2DCanvas;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
/* fogging vars */
|
|
|
|
|
bool m_fogenabled;
|
2015-03-23 22:49:38 +01:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
float m_redback;
|
|
|
|
|
float m_greenback;
|
|
|
|
|
float m_blueback;
|
|
|
|
|
float m_alphaback;
|
2006-01-06 03:46:54 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
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;
|
BGE: Various render improvements.
bge.logic.setRender(flag) to enable/disable render.
The render pass is enabled by default but it can be disabled with
bge.logic.setRender(False).
Once disabled, the render pass is skipped and a new logic frame starts
immediately. Note that VSync no longer limits the fps when render is off
but the 'Use Frame Rate' option in the Render Properties still does.
To run as many frames as possible, untick the option
This function is useful when you don't need the default render, e.g.
when doing offscreen render to an alternate device than the monitor.
Note that without VSync, you must limit the frame rate by other means.
fbo = bge.render.offScreenCreate(width,height,[,samples=0][,target=bge.render.RAS_OFS_RENDER_BUFFER])
Use this method to create an offscreen buffer of given size, with given MSAA
samples and targetting either a render buffer (bge.render.RAS_OFS_RENDER_BUFFER)
or a texture (bge.render.RAS_OFS_RENDER_TEXTURE). Use the former if you want to
retrieve the frame buffer on the host and the latter if you want to pass the render
to another context (texture are proper OGL object, render buffers aren't)
The object created by this function can only be used as a parameter of the
bge.texture.ImageRender() constructor to send the the render to the FBO rather
than to the frame buffer. This is best suited when you want to create a render
of specific size, or if you need an image with an alpha channel.
bge.texture.<imagetype>.refresh(buffer=None, format="RGBA", ts=-1.0)
Without arg, the refresh method of the image objects is pretty much a no-op, it
simply invalidates the image so that on next texture refresh, the image will
be recalculated.
It is now possible to pass an optional buffer object to transfer the image (and
recalculate it if it was invalid) to an external object. The object must implement
the 'buffer protocol'. The image will be transfered as "RGBA" or "BGRA" pixels
depending on format argument (only those 2 formats are supported) and ts is an
optional timestamp in the image depends on it (e.g. VideoFFmpeg playing a video file).
With this function you don't need anymore to link the image object to a Texture
object to use: the image object is self-sufficient.
bge.texture.ImageRender(scene, camera, fbo=None)
Render to buffer is possible by passing a FBO object (see offScreenCreate).
bge.texture.ImageRender.render()
Allows asynchronous render: call this method to render the scene but without
extracting the pixels yet. The function returns as soon as the render commands
have been send to the GPU. The render will proceed asynchronously in the GPU
while the host can perform other tasks.
To complete the render, you can either call refresh() directly of refresh the texture
to which this object is the source. Asynchronous render is useful to achieve optimal
performance: call render() on frame N and refresh() on frame N+1 to give as much as
time as possible to the GPU to render the frame while the game engine can perform other tasks.
Support negative scale on camera.
Camera scale was previously ignored in the BGE.
It is now injected in the modelview matrix as a vertical or horizontal flip
of the scene (respectively if scaleY<0 and scaleX<0).
Note that the actual value of the scale is not used, only the sign.
This allows to flip the image produced by ImageRender() without any performance
degradation: the flip is integrated in the render itself.
Optimized image transfer from ImageRender to buffer.
Previously, images that were transferred to the host were always going through
buffers in VideoTexture. It is now possible to transfer ImageRender
images to external buffer without intermediate copy (i.e. directly from OGL to buffer)
if the attributes of the ImageRender objects are set as follow:
flip=False, alpha=True, scale=False, depth=False, zbuff=False.
(if you need to flip the image, use camera negative scale)
2016-06-09 23:56:45 +02:00
|
|
|
bool m_camnegscale;
|
2013-12-24 05:44:54 +11:00
|
|
|
|
|
|
|
|
StereoMode m_stereomode;
|
|
|
|
|
StereoEye m_curreye;
|
|
|
|
|
float m_eyeseparation;
|
|
|
|
|
float m_focallength;
|
|
|
|
|
bool m_setfocallength;
|
|
|
|
|
int m_noOfScanlines;
|
|
|
|
|
|
|
|
|
|
short m_prevafvalue;
|
|
|
|
|
|
|
|
|
|
/* motion blur */
|
|
|
|
|
int m_motionblur;
|
|
|
|
|
float m_motionblurvalue;
|
2007-09-29 18:51:01 +00:00
|
|
|
|
2013-01-12 20:01:58 +00:00
|
|
|
bool m_usingoverrideshader;
|
|
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
/* Render tools */
|
|
|
|
|
void *m_clientobject;
|
|
|
|
|
void *m_auxilaryClientInfo;
|
2014-03-27 22:32:06 -07:00
|
|
|
std::vector<RAS_OpenGLLight *> m_lights;
|
2013-12-24 05:44:54 +11:00
|
|
|
int m_lastlightlayer;
|
|
|
|
|
bool m_lastlighting;
|
|
|
|
|
void *m_lastauxinfo;
|
2013-11-04 19:21:07 +00:00
|
|
|
unsigned int m_numgllights;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
protected:
|
2013-12-24 05:44:54 +11:00
|
|
|
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. */
|
2002-10-12 11:37:38 +00:00
|
|
|
RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo;
|
|
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
/* Making use of a Strategy design pattern for storage behavior.
|
2013-02-02 04:48:21 +00:00
|
|
|
* Examples of concrete strategies: Vertex Arrays, VBOs, Immediate Mode*/
|
2013-12-24 05:44:54 +11:00
|
|
|
int m_storage_type;
|
|
|
|
|
RAS_IStorage *m_storage;
|
2012-12-18 20:56:25 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
public:
|
|
|
|
|
double GetTime();
|
2015-12-06 15:24:55 -08:00
|
|
|
RAS_OpenGLRasterizer(RAS_ICanvas *canv, RAS_STORAGE_TYPE storage);
|
2002-10-12 11:37:38 +00:00
|
|
|
virtual ~RAS_OpenGLRasterizer();
|
|
|
|
|
|
2004-08-10 11:34:12 +00:00
|
|
|
/*enum DrawType
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
KX_BOUNDINGBOX = 1,
|
|
|
|
|
KX_WIREFRAME,
|
|
|
|
|
KX_SOLID,
|
|
|
|
|
KX_SHADED,
|
2004-03-22 22:02:18 +00:00
|
|
|
KX_TEXTURED
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
2004-08-10 11:34:12 +00:00
|
|
|
enum DepthMask
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
KX_DEPTHMASK_ENABLED =1,
|
|
|
|
|
KX_DEPTHMASK_DISABLED,
|
2004-08-10 11:34:12 +00:00
|
|
|
};*/
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SetDepthMask(DepthMask depthmask);
|
|
|
|
|
|
|
|
|
|
virtual bool SetMaterial(const RAS_IPolyMaterial &mat);
|
|
|
|
|
virtual bool Init();
|
|
|
|
|
virtual void Exit();
|
2014-03-24 20:11:11 -07:00
|
|
|
virtual bool BeginFrame(double time);
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void ClearColorBuffer();
|
|
|
|
|
virtual void ClearDepthBuffer();
|
|
|
|
|
virtual void ClearCachingInfo(void);
|
|
|
|
|
virtual void EndFrame();
|
|
|
|
|
virtual void SetRenderArea();
|
|
|
|
|
|
|
|
|
|
virtual void SetStereoMode(const StereoMode stereomode);
|
2011-10-06 22:04:01 +00:00
|
|
|
virtual RAS_IRasterizer::StereoMode GetStereoMode();
|
2013-12-24 05:44:54 +11:00
|
|
|
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();
|
BGE: Various render improvements.
bge.logic.setRender(flag) to enable/disable render.
The render pass is enabled by default but it can be disabled with
bge.logic.setRender(False).
Once disabled, the render pass is skipped and a new logic frame starts
immediately. Note that VSync no longer limits the fps when render is off
but the 'Use Frame Rate' option in the Render Properties still does.
To run as many frames as possible, untick the option
This function is useful when you don't need the default render, e.g.
when doing offscreen render to an alternate device than the monitor.
Note that without VSync, you must limit the frame rate by other means.
fbo = bge.render.offScreenCreate(width,height,[,samples=0][,target=bge.render.RAS_OFS_RENDER_BUFFER])
Use this method to create an offscreen buffer of given size, with given MSAA
samples and targetting either a render buffer (bge.render.RAS_OFS_RENDER_BUFFER)
or a texture (bge.render.RAS_OFS_RENDER_TEXTURE). Use the former if you want to
retrieve the frame buffer on the host and the latter if you want to pass the render
to another context (texture are proper OGL object, render buffers aren't)
The object created by this function can only be used as a parameter of the
bge.texture.ImageRender() constructor to send the the render to the FBO rather
than to the frame buffer. This is best suited when you want to create a render
of specific size, or if you need an image with an alpha channel.
bge.texture.<imagetype>.refresh(buffer=None, format="RGBA", ts=-1.0)
Without arg, the refresh method of the image objects is pretty much a no-op, it
simply invalidates the image so that on next texture refresh, the image will
be recalculated.
It is now possible to pass an optional buffer object to transfer the image (and
recalculate it if it was invalid) to an external object. The object must implement
the 'buffer protocol'. The image will be transfered as "RGBA" or "BGRA" pixels
depending on format argument (only those 2 formats are supported) and ts is an
optional timestamp in the image depends on it (e.g. VideoFFmpeg playing a video file).
With this function you don't need anymore to link the image object to a Texture
object to use: the image object is self-sufficient.
bge.texture.ImageRender(scene, camera, fbo=None)
Render to buffer is possible by passing a FBO object (see offScreenCreate).
bge.texture.ImageRender.render()
Allows asynchronous render: call this method to render the scene but without
extracting the pixels yet. The function returns as soon as the render commands
have been send to the GPU. The render will proceed asynchronously in the GPU
while the host can perform other tasks.
To complete the render, you can either call refresh() directly of refresh the texture
to which this object is the source. Asynchronous render is useful to achieve optimal
performance: call render() on frame N and refresh() on frame N+1 to give as much as
time as possible to the GPU to render the frame while the game engine can perform other tasks.
Support negative scale on camera.
Camera scale was previously ignored in the BGE.
It is now injected in the modelview matrix as a vertical or horizontal flip
of the scene (respectively if scaleY<0 and scaleX<0).
Note that the actual value of the scale is not used, only the sign.
This allows to flip the image produced by ImageRender() without any performance
degradation: the flip is integrated in the render itself.
Optimized image transfer from ImageRender to buffer.
Previously, images that were transferred to the host were always going through
buffers in VideoTexture. It is now possible to transfer ImageRender
images to external buffer without intermediate copy (i.e. directly from OGL to buffer)
if the attributes of the ImageRender objects are set as follow:
flip=False, alpha=True, scale=False, depth=False, zbuff=False.
(if you need to flip the image, use camera negative scale)
2016-06-09 23:56:45 +02:00
|
|
|
virtual RAS_IOffScreen *CreateOffScreen(int width, int height, int samples, int target);
|
|
|
|
|
virtual RAS_ISync *CreateSync(int type);
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SwapBuffers();
|
|
|
|
|
|
|
|
|
|
virtual void IndexPrimitives(class RAS_MeshSlot &ms);
|
|
|
|
|
virtual void IndexPrimitives_3DText(class RAS_MeshSlot &ms, class RAS_IPolyMaterial *polymat);
|
2015-12-06 15:24:55 -08:00
|
|
|
virtual void DrawDerivedMesh(class RAS_MeshSlot &ms);
|
2013-12-24 05:44:54 +11:00
|
|
|
|
|
|
|
|
virtual void SetProjectionMatrix(MT_CmMatrix4x4 &mat);
|
|
|
|
|
virtual void SetProjectionMatrix(const MT_Matrix4x4 &mat);
|
BGE: Various render improvements.
bge.logic.setRender(flag) to enable/disable render.
The render pass is enabled by default but it can be disabled with
bge.logic.setRender(False).
Once disabled, the render pass is skipped and a new logic frame starts
immediately. Note that VSync no longer limits the fps when render is off
but the 'Use Frame Rate' option in the Render Properties still does.
To run as many frames as possible, untick the option
This function is useful when you don't need the default render, e.g.
when doing offscreen render to an alternate device than the monitor.
Note that without VSync, you must limit the frame rate by other means.
fbo = bge.render.offScreenCreate(width,height,[,samples=0][,target=bge.render.RAS_OFS_RENDER_BUFFER])
Use this method to create an offscreen buffer of given size, with given MSAA
samples and targetting either a render buffer (bge.render.RAS_OFS_RENDER_BUFFER)
or a texture (bge.render.RAS_OFS_RENDER_TEXTURE). Use the former if you want to
retrieve the frame buffer on the host and the latter if you want to pass the render
to another context (texture are proper OGL object, render buffers aren't)
The object created by this function can only be used as a parameter of the
bge.texture.ImageRender() constructor to send the the render to the FBO rather
than to the frame buffer. This is best suited when you want to create a render
of specific size, or if you need an image with an alpha channel.
bge.texture.<imagetype>.refresh(buffer=None, format="RGBA", ts=-1.0)
Without arg, the refresh method of the image objects is pretty much a no-op, it
simply invalidates the image so that on next texture refresh, the image will
be recalculated.
It is now possible to pass an optional buffer object to transfer the image (and
recalculate it if it was invalid) to an external object. The object must implement
the 'buffer protocol'. The image will be transfered as "RGBA" or "BGRA" pixels
depending on format argument (only those 2 formats are supported) and ts is an
optional timestamp in the image depends on it (e.g. VideoFFmpeg playing a video file).
With this function you don't need anymore to link the image object to a Texture
object to use: the image object is self-sufficient.
bge.texture.ImageRender(scene, camera, fbo=None)
Render to buffer is possible by passing a FBO object (see offScreenCreate).
bge.texture.ImageRender.render()
Allows asynchronous render: call this method to render the scene but without
extracting the pixels yet. The function returns as soon as the render commands
have been send to the GPU. The render will proceed asynchronously in the GPU
while the host can perform other tasks.
To complete the render, you can either call refresh() directly of refresh the texture
to which this object is the source. Asynchronous render is useful to achieve optimal
performance: call render() on frame N and refresh() on frame N+1 to give as much as
time as possible to the GPU to render the frame while the game engine can perform other tasks.
Support negative scale on camera.
Camera scale was previously ignored in the BGE.
It is now injected in the modelview matrix as a vertical or horizontal flip
of the scene (respectively if scaleY<0 and scaleX<0).
Note that the actual value of the scale is not used, only the sign.
This allows to flip the image produced by ImageRender() without any performance
degradation: the flip is integrated in the render itself.
Optimized image transfer from ImageRender to buffer.
Previously, images that were transferred to the host were always going through
buffers in VideoTexture. It is now possible to transfer ImageRender
images to external buffer without intermediate copy (i.e. directly from OGL to buffer)
if the attributes of the ImageRender objects are set as follow:
flip=False, alpha=True, scale=False, depth=False, zbuff=False.
(if you need to flip the image, use camera negative scale)
2016-06-09 23:56:45 +02:00
|
|
|
virtual void SetViewMatrix(
|
|
|
|
|
const MT_Matrix4x4 &mat,
|
|
|
|
|
const MT_Matrix3x3 &ori,
|
|
|
|
|
const MT_Point3 &pos,
|
|
|
|
|
const MT_Vector3 &scale,
|
|
|
|
|
bool perspective);
|
2013-12-24 05:44:54 +11:00
|
|
|
|
|
|
|
|
virtual const MT_Point3& GetCameraPosition();
|
|
|
|
|
virtual bool GetCameraOrtho();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-03-23 22:49:38 +01:00
|
|
|
virtual void SetFog(short type, float start, float dist, float intensity, float color[3]);
|
2015-03-23 21:36:08 +01:00
|
|
|
virtual void EnableFog(bool enable);
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void DisplayFog();
|
|
|
|
|
|
2015-03-23 22:49:38 +01:00
|
|
|
virtual void SetBackColor(float color[3]);
|
|
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SetDrawingMode(int drawingmode);
|
|
|
|
|
virtual int GetDrawingMode();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SetCullFace(bool enable);
|
|
|
|
|
virtual void SetLines(bool enable);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
virtual MT_Matrix4x4 GetFrustumMatrix(
|
2013-12-24 05:44:54 +11:00
|
|
|
float left, float right, float bottom, float top,
|
|
|
|
|
float frustnear, float frustfar,
|
|
|
|
|
float focallength, bool perspective);
|
2009-06-08 20:08:19 +00:00
|
|
|
virtual MT_Matrix4x4 GetOrthoMatrix(
|
2013-12-24 05:44:54 +11:00
|
|
|
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 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);
|
|
|
|
|
|
2015-03-23 22:49:38 +01:00
|
|
|
virtual void SetAmbientColor(float color[3]);
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SetAmbient(float factor);
|
|
|
|
|
|
|
|
|
|
virtual void SetPolygonOffset(float mult, float add);
|
|
|
|
|
|
2015-07-27 10:58:19 +02:00
|
|
|
virtual void FlushDebugShapes(SCA_IScene *scene);
|
2013-12-24 05:44:54 +11:00
|
|
|
|
2015-07-27 10:58:19 +02:00
|
|
|
virtual void DrawDebugLine(SCA_IScene *scene, const MT_Vector3 &from,const MT_Vector3 &to, const MT_Vector3 &color)
|
2005-07-27 09:30:53 +00:00
|
|
|
{
|
2011-02-16 17:07:18 +00:00
|
|
|
OglDebugShape line;
|
|
|
|
|
line.m_type = OglDebugShape::LINE;
|
|
|
|
|
line.m_pos= from;
|
|
|
|
|
line.m_param = to;
|
2005-07-27 09:30:53 +00:00
|
|
|
line.m_color = color;
|
2015-07-27 10:58:19 +02:00
|
|
|
m_debugShapes[scene].push_back(line);
|
2011-02-16 17:07:18 +00:00
|
|
|
}
|
|
|
|
|
|
2015-07-27 10:58:19 +02:00
|
|
|
virtual void DrawDebugCircle(SCA_IScene *scene, const MT_Vector3 ¢er, const MT_Scalar radius,
|
|
|
|
|
const MT_Vector3 &color, const MT_Vector3 &normal, int nsector)
|
2011-02-16 17:07:18 +00:00
|
|
|
{
|
|
|
|
|
OglDebugShape line;
|
|
|
|
|
line.m_type = OglDebugShape::CIRCLE;
|
|
|
|
|
line.m_pos= center;
|
|
|
|
|
line.m_param = normal;
|
2012-09-16 04:58:18 +00:00
|
|
|
line.m_color = color;
|
2011-02-16 17:07:18 +00:00
|
|
|
line.m_param2.x() = radius;
|
|
|
|
|
line.m_param2.y() = (float) nsector;
|
2015-07-27 10:58:19 +02:00
|
|
|
m_debugShapes[scene].push_back(line);
|
2005-07-27 09:30:53 +00:00
|
|
|
}
|
2010-06-10 00:25:04 +00:00
|
|
|
|
2015-07-27 10:58:19 +02:00
|
|
|
// We store each debug shape by scene.
|
|
|
|
|
std::map<SCA_IScene *, std::vector<OglDebugShape> > m_debugShapes;
|
2005-07-27 09:30:53 +00:00
|
|
|
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
virtual void SetTexCoordNum(int num);
|
|
|
|
|
virtual void SetAttribNum(int num);
|
|
|
|
|
virtual void SetTexCoord(TexCoGen coords, int unit);
|
2013-03-01 20:45:42 +00:00
|
|
|
virtual void SetAttrib(TexCoGen coords, int unit, int layer = 0);
|
Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
FreeBSD, Irix, and Solaris. There might still be platform specific
issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
custom opengl extensions code that was there. Removes a lot of
#ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
work around a specific bug and only disabled multitexturing anyway.
It might also have caused a slowdown since it was retrieving the
environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
arrays too, removing some specific immediate mode drawing functions
for this that only did extra normal calculation. Now it always splits
vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
attributes for vertex arrays. These were not being enabled/disabled
correct according to the opengl spec, leading to crashes. Also tangent
attributes used an immediate mode call for vertex arrays, which can't
work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void TexCoord(const RAS_TexVert &tv);
|
2006-02-13 05:45:32 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
const MT_Matrix4x4 &GetViewMatrix() const;
|
|
|
|
|
const MT_Matrix4x4 &GetViewInvMatrix() const;
|
2007-09-29 18:51:01 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
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)
|
2007-09-29 18:51:01 +00:00
|
|
|
{
|
2012-07-21 22:58:08 +00:00
|
|
|
if (newstate < 0)
|
2007-09-29 18:51:01 +00:00
|
|
|
m_motionblur = 0;
|
2012-07-21 22:58:08 +00:00
|
|
|
else if (newstate > 2)
|
2007-09-29 18:51:01 +00:00
|
|
|
m_motionblur = 2;
|
|
|
|
|
else
|
|
|
|
|
m_motionblur = newstate;
|
2013-12-24 05:44:54 +11:00
|
|
|
}
|
2008-07-29 15:48:31 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SetAlphaBlend(int alphablend);
|
|
|
|
|
virtual void SetFrontFace(bool ccw);
|
2009-08-18 15:37:31 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SetAnisotropicFiltering(short level);
|
|
|
|
|
virtual short GetAnisotropicFiltering();
|
2012-06-25 09:14:37 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SetMipmapping(MipmapOption val);
|
2013-04-14 00:40:24 +00:00
|
|
|
virtual MipmapOption GetMipmapping();
|
|
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
virtual void SetUsingOverrideShader(bool val);
|
|
|
|
|
virtual bool GetUsingOverrideShader();
|
2012-06-25 09:14:37 +00:00
|
|
|
|
2013-11-04 19:21:07 +00:00
|
|
|
/**
|
|
|
|
|
* Render Tools
|
|
|
|
|
*/
|
2013-12-24 05:44:54 +11:00
|
|
|
void EnableOpenGLLights();
|
|
|
|
|
void DisableOpenGLLights();
|
|
|
|
|
void ProcessLighting(bool uselights, const MT_Transform &viewmat);
|
2013-11-04 19:21:07 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
void RenderBox2D(int xco, int yco, int width, int height, float percentage);
|
|
|
|
|
void RenderText3D(int fontid, const char *text, int size, int dpi,
|
2015-12-13 21:19:45 -05:00
|
|
|
const float color[4], const float mat[16], float aspect);
|
2013-12-24 05:44:54 +11:00
|
|
|
void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char *text,
|
|
|
|
|
int xco, int yco, int width, int height);
|
2013-11-04 19:21:07 +00:00
|
|
|
|
2015-12-13 02:01:28 +01:00
|
|
|
void applyTransform(float *oglmatrix, int objectdrawmode);
|
2013-11-04 19:21:07 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
void PushMatrix();
|
|
|
|
|
void PopMatrix();
|
2013-11-04 19:21:07 +00:00
|
|
|
|
BGE : Collision mask support in raycast + and raycast cleanup.
I have removed the m_pHitObject, m_xray and m_testPropName and replace them by a temporary struct "RayCastData" which contains these datas and a collision mask. Finally i add a collision mask argument in the python function "rayCast" :
```
rayCast(to, from, dist, prop, face, xray, poly, mask)
```
It can be useful to hit only object which are on the right colision layer. for example if you have hitbox for a charater or vehicle you don't want to hit it with raycast.
test file : {F237337}
left mouse click on two planes and see console messages.
Somewhat more elaborate test file by @sybren: {F237779}
Look around and click on the cubes. One cube lamp responds, the other doesn't, based on their collision groups.
Reviewers: moguri, hg1, agoose77, campbellbarton, sybren
Reviewed By: agoose77, campbellbarton, sybren
Subscribers: campbellbarton, sergey, blueprintrandom, sybren
Projects: #game_engine, #game_physics
Differential Revision: https://developer.blender.org/D1239
2015-10-07 22:14:43 +02:00
|
|
|
/// \see KX_RayCast
|
2015-12-13 02:01:28 +01:00
|
|
|
bool RayHit(struct KX_ClientObjectInfo *client, class KX_RayCast *result, float *oglmatrix);
|
BGE : Collision mask support in raycast + and raycast cleanup.
I have removed the m_pHitObject, m_xray and m_testPropName and replace them by a temporary struct "RayCastData" which contains these datas and a collision mask. Finally i add a collision mask argument in the python function "rayCast" :
```
rayCast(to, from, dist, prop, face, xray, poly, mask)
```
It can be useful to hit only object which are on the right colision layer. for example if you have hitbox for a charater or vehicle you don't want to hit it with raycast.
test file : {F237337}
left mouse click on two planes and see console messages.
Somewhat more elaborate test file by @sybren: {F237779}
Look around and click on the cubes. One cube lamp responds, the other doesn't, based on their collision groups.
Reviewers: moguri, hg1, agoose77, campbellbarton, sybren
Reviewed By: agoose77, campbellbarton, sybren
Subscribers: campbellbarton, sergey, blueprintrandom, sybren
Projects: #game_engine, #game_physics
Differential Revision: https://developer.blender.org/D1239
2015-10-07 22:14:43 +02:00
|
|
|
/// \see KX_RayCast
|
|
|
|
|
bool NeedRayCast(struct KX_ClientObjectInfo *, void *UNUSED(data)) { return true; }
|
2013-11-04 19:21:07 +00:00
|
|
|
|
2014-03-27 22:32:06 -07:00
|
|
|
RAS_ILightObject* CreateLight();
|
|
|
|
|
void AddLight(RAS_ILightObject* lightobject);
|
|
|
|
|
|
|
|
|
|
void RemoveLight(RAS_ILightObject* lightobject);
|
|
|
|
|
int ApplyLights(int objectlayer, const MT_Transform& viewmat);
|
2013-11-04 19:21:07 +00:00
|
|
|
|
|
|
|
|
void MotionBlur();
|
|
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
void SetClientObject(void *obj);
|
2013-11-04 19:21:07 +00:00
|
|
|
|
2013-12-24 05:44:54 +11:00
|
|
|
void SetAuxilaryClientInfo(void *inf);
|
2013-11-04 19:21:07 +00:00
|
|
|
|
2014-03-30 18:35:02 -07:00
|
|
|
/**
|
|
|
|
|
* Prints information about what the hardware supports.
|
|
|
|
|
*/
|
|
|
|
|
virtual void PrintHardwareInfo();
|
2013-11-04 19:21:07 +00:00
|
|
|
|
2009-08-18 15:37:31 +00:00
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
2012-06-25 09:14:37 +00:00
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_OpenGLRasterizer")
|
2009-08-18 15:37:31 +00:00
|
|
|
#endif
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
2012-10-09 13:36:42 +00:00
|
|
|
#endif /* __RAS_OPENGLRASTERIZER_H__ */
|