Autoloading Lightmaps for meshs

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
fishy417
Posts: 11
Joined: Wed Jan 30, 2008 4:35 am
Location: Australia

Autoloading Lightmaps for meshs

Post by fishy417 »

Hi i'm not sure if this is a really noob question or not, i'm search the forums a bit and wasn't able to find a decent or compelete answer.

I'm make a space strategy game and when loading the models i'm trying to get it to automatically search though all textures and then search for any textures with the same name but have an extra L.bmp at the end.

Example is the BlitzMax code that i've done so far, but currently i only seem to be able to get the layer 0 texture to work as a lightmap as well as the color map, can't seem to color with layer 0 and light with layer 1 texture?

Code: Select all

Local MC:Int
		
		For Mc = 0 To ISceneNode.GetMaterialCount() - 1
			Local Mat:SMaterial = ISceneNode.GetMaterial(Mc) 
			Local Tes:ITexture = Mat.getTexture(0) 

			' Find the texture name and look for any light maps for it
			Local LightMap:ITexture = MyDriver.getTexture(Left(Tes.getName(), Len(Tes.getName()) - 4) + "L.bmp") 

			If LightMap <> Null
				Local NMat:SMaterial = ISceneNode.GetMaterial(Mc) 
				' 

			'	Local MBuffer:IMeshBuffer = CMesh.getMesh(0).getMeshBuffer(0) 
				'NMat = MBuffer.getMaterial() 
				
				NMat.setTexture(0, Tes) 
				NMat.setTexture(1, LightMap) 
				NMat.setMaterialType(EMT_LIGHTMAP_ADD) 
				'NMat.setMaterialTypeParam(2) 
								
				
			End If
		Next
Sorry if i'm not wording this correctly, if i havn't explain correctly please just ask for more details. On a side note does irrlicht support specular maps? ultimatly i want the have it search for any lightmaps, specular maps and normal maps just looking for similiar named textures in the same directory as the model.

Any help would be very appreciated,
thanks
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

In case those variables are references or pointers it should work as you did it. At least that's how it work in C++. BTW: Do you really need NMat, it should be the same as Mat.
fishy417
Posts: 11
Joined: Wed Jan 30, 2008 4:35 am
Location: Australia

Post by fishy417 »

Thanks for your reply, yeah your right i didn't need NMat, that was just left over when testing if i needed mesh buffers or not.

Now overall the result with what i have here isn't what i want, it finds the L.bmp textures, loads and applys them to the right material. Just the result isn't what i want. I either get it full black or it uses the color map as the lightmap as well. also i'm not sure if calling it a lightmap is correct, i mean self illumination maps, to display window lights, engine glows etc...

Any other ideas on how to get this to work and do i need setmaterialparam() for anything?

thanks,
Post Reply