diff options
author | Daniel Stokes <kupomail@gmail.com> | 2012-05-01 06:50:17 +0400 |
---|---|---|
committer | Daniel Stokes <kupomail@gmail.com> | 2012-05-01 06:50:17 +0400 |
commit | ae4fda82b026ae6e2b003c1105f329b7e76582b0 (patch) | |
tree | 1dfe2a3f3e1dd3dabe22c51a96ffdc07575f1bc5 /source/gameengine | |
parent | 7cb037db8628c0522fb8c143d461e2054b616771 (diff) |
Merging phase 1 of the BGE Harmony branch:
* Shadow color now usable in the BGE
* Simplified the shadow panel while "Blender Game" renderer is active
* Added variance shadow maps for the BGE
* Buffered shadows on sun lamps in the BGE (orthographic)
* Light textures in the BGE
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_Light.cpp | 17 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Light.h | 1 | ||||
-rw-r--r-- | source/gameengine/VideoTexture/Texture.cpp | 19 |
3 files changed, 37 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 7e9d95b37a2..5922e97aaf4 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -45,6 +45,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_lamp_types.h" #include "GPU_material.h" KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, @@ -267,6 +268,22 @@ void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras) GPU_lamp_shadow_buffer_unbind(lamp); } +struct Image *KX_LightObject::GetTextureImage(short texslot) +{ + Lamp *la = (Lamp*)GetBlenderObject()->data; + + if (texslot >= MAX_MTEX || texslot < 0) + { + printf("KX_LightObject::GetTextureImage(): texslot exceeds slot bounds (0-%d)\n", MAX_MTEX-1); + return NULL; + } + + if (la->mtex[texslot]) + return la->mtex[texslot]->tex->ima; + + return NULL; +} + #ifdef WITH_PYTHON /* ------------------------------------------------------------------------- */ /* Python Integration Hooks */ diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index c2815e7afaa..9fe13f471ba 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -66,6 +66,7 @@ public: int GetShadowLayer(); void BindShadowBuffer(class RAS_IRasterizer *ras, class KX_Camera *cam, class MT_Transform& camtrans); void UnbindShadowBuffer(class RAS_IRasterizer *ras); + struct Image *GetTextureImage(short texslot); void Update(); void UpdateScene(class KX_Scene *kxscene) {m_lightobj.m_scene = (void*)kxscene;} diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 40e9f899ef0..382d3d0bc32 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -30,6 +30,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include <structmember.h> #include <KX_GameObject.h> +#include <KX_Light.h> #include <RAS_MeshObject.h> #include <DNA_mesh_types.h> #include <DNA_meshdata_types.h> @@ -59,6 +60,7 @@ http://www.gnu.org/copyleft/lesser.txt. // Blender GameObject type BlendType<KX_GameObject> gameObjectType ("KX_GameObject"); +BlendType<KX_LightObject> lightObjectType ("KX_LightObject"); // load texture @@ -105,6 +107,16 @@ RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID) return NULL; } +// get pointer to a lamp +KX_LightObject * getLamp(PyObject *obj) +{ + // if object is available + if (obj == NULL) return NULL; + + // returns NULL if obj is not a KX_LightObject + return lightObjectType.checkType(obj); +} + // get material ID short getMaterialID(PyObject * obj, const char *name) @@ -206,6 +218,7 @@ int Texture_init (Texture *self, PyObject *args, PyObject *kwds) { // get pointer to texture image RAS_IPolyMaterial * mat = getMaterial(obj, matID); + KX_LightObject * lamp = getLamp(obj); if (mat != NULL) { // is it blender material or polygon material @@ -227,6 +240,12 @@ int Texture_init (Texture *self, PyObject *args, PyObject *kwds) self->m_useMatTexture = false; } } + else if (lamp != NULL) + { + self->m_imgTexture = lamp->GetTextureImage(texID); + self->m_useMatTexture = false; + } + // check if texture is available, if not, initialization failed if (self->m_imgTexture == NULL && self->m_matTexture == NULL) // throw exception if initialization failed |