[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42338] branches/ge_harmony/source: Lamp textures now work with VideoTexture.

Mitchell Stokes mogurijin at gmail.com
Fri Dec 2 10:13:48 CET 2011


Revision: 42338
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42338
Author:   moguri
Date:     2011-12-02 09:13:42 +0000 (Fri, 02 Dec 2011)
Log Message:
-----------
Lamp textures now work with VideoTexture.

Modified Paths:
--------------
    branches/ge_harmony/source/blender/gpu/intern/gpu_material.c
    branches/ge_harmony/source/gameengine/Ketsji/KX_Light.cpp
    branches/ge_harmony/source/gameengine/Ketsji/KX_Light.h
    branches/ge_harmony/source/gameengine/VideoTexture/Texture.cpp

Modified: branches/ge_harmony/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/ge_harmony/source/blender/gpu/intern/gpu_material.c	2011-12-02 07:13:48 UTC (rev 42337)
+++ branches/ge_harmony/source/blender/gpu/intern/gpu_material.c	2011-12-02 09:13:42 UTC (rev 42338)
@@ -627,10 +627,9 @@
 		mtex = lamp->la->mtex[i];
 
 		if (mtex && mtex->tex->type & TEX_IMAGE	&& mtex->tex->ima) {
-			GPUTexture* cookie = GPU_texture_from_blender(mtex->tex->ima, &mtex->tex->iuser, 1.0, 0);
 			GPU_link(mat, "shade_light_cookie",
 				GPU_builtin(GPU_VIEW_POSITION),
-				GPU_dynamic_texture(cookie,  GPU_DYNAMIC_SAMPLER_2DIMAGE, lamp->ob),
+				GPU_image(mtex->tex->ima, &mtex->tex->iuser),
 				GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
 				&cookie_rgb);
 			texture_rgb_blend(mat, cookie_rgb, *rgb, GPU_uniform(&one), GPU_uniform(&mtex->colfac), mtex->blendtype, rgb); 

Modified: branches/ge_harmony/source/gameengine/Ketsji/KX_Light.cpp
===================================================================
--- branches/ge_harmony/source/gameengine/Ketsji/KX_Light.cpp	2011-12-02 07:13:48 UTC (rev 42337)
+++ branches/ge_harmony/source/gameengine/Ketsji/KX_Light.cpp	2011-12-02 09:13:42 UTC (rev 42338)
@@ -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 @@
 	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					                                 */

Modified: branches/ge_harmony/source/gameengine/Ketsji/KX_Light.h
===================================================================
--- branches/ge_harmony/source/gameengine/Ketsji/KX_Light.h	2011-12-02 07:13:48 UTC (rev 42337)
+++ branches/ge_harmony/source/gameengine/Ketsji/KX_Light.h	2011-12-02 09:13:42 UTC (rev 42338)
@@ -66,6 +66,7 @@
 	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;}

Modified: branches/ge_harmony/source/gameengine/VideoTexture/Texture.cpp
===================================================================
--- branches/ge_harmony/source/gameengine/VideoTexture/Texture.cpp	2011-12-02 07:13:48 UTC (rev 42337)
+++ branches/ge_harmony/source/gameengine/VideoTexture/Texture.cpp	2011-12-02 09:13:42 UTC (rev 42338)
@@ -30,6 +30,7 @@
 #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 @@
 
 // Blender GameObject type
 BlendType<KX_GameObject> gameObjectType ("KX_GameObject");
+BlendType<KX_LightObject> lightObjectType ("KX_LightObject");
 
 
 // load texture
@@ -105,7 +107,17 @@
 	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 @@
 		{
 			// 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 @@
 					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




More information about the Bf-blender-cvs mailing list