Advice needed on LightMesh

Blitz3D Forums/Blitz3D Programming/Advice needed on LightMesh

Newbunkle(Posted 2007) [#1]
I'm having a few problems with LightMesh. My code is too long to copy and paste here, so I'll just give a quick run down of what I'm trying to do, and what I'm observing.

I've written a program that randomly generates the inside of a building. Its very rough at the moment and looks like a maze, but I hope to make it generate proper rooms eventually. Anyway, that's besides the point.

The structure is a single mesh, with its origin point at the centre. If I place the camera at (0,0,0), I'd be in the centre of the mesh. Everything was working fine, and if I put in some lights using CreateLight() it works perfectly.

However, I want to use LightMesh due to the number of small lights, and this is where I've hit a problem. From what I understand, the command works like this:

LightMesh mesh,red,green,blue,range,x,y,z

I believe the x,y and z co-ordinates are relative to the position of the mesh, not the world. My mesh has its centre at (0,0,0) and is sitting at (0,0,0), so shouldn't world co-ordinates work? I mean, if I put a lamp object at (-20,20,-20) and use lightmesh with those same co-ordinates, then the light should be placed properly, right?

What I'm actually seeing is that the mesh doesn't get lit at all, unless I increase the range by a lot. Even then, it appears that the light is coming from somewhere outside the mesh. If I increase the range to a few hundred, the east and south walls are completely black, but the north and west walls are well lit.

Why would it be placing the light outside of the mesh, when the co-ordinates I've given should be inside?


Mortiis(Posted 2007) [#2]
Try an "UpdateNormals YourMesh" in your main loop. I haven't tried it but it may work. Also did you set "EntityFX YourMesh,2" ? If not, you need to state it so your mesh will use vertex colors...


puki(Posted 2007) [#3]
The number of verts in the mesh will make a difference - ie the more there are, the more accurate/realistic the lighting will be.

Any mesh's origin is not always central by default - if you have internally created this mesh with it's centre at 0,0,0 (which you have to calculate in advance) then Blitz3D does not require you to specify coordinates to LightMesh as Blitz3D will assume this is what you want to do by default - the light coordinates are optional - try your code without supplying coordinates.