Game Development Community

Map2Dif: Shot in the dark

by FruitBatInShades · in Torque Game Engine · 09/28/2004 (10:52 am) · 10 replies

Hi guys, I'm still having probs with map2dif and light leaks. I have now got the code, unfortunately its not commented and I have zero experience of the techniques used :o( I have been trying to narrow down the problem and have found out that the leaks seem to start when a floor is composed of different pieces that do not match up to the wall pieces.
Read this and this thread for background info.
I'm guessing its a floating point or rounding issue but am not experienced in c++ or torque, hence the shot in the dark title. I noticed that in most of the routines the lightmap scale is used in calculations whilst in editfloorplanres.cc there is a hard coded 32. Is this correct and would changing it make any difference?
// Build the index remap tables while copying over the point and plane
   //    vector data into the FloorPlanResource.  
   for( i = 0, mPointTable.reserve(points.size()); i < points.size(); i++ )
   {        
      Point3D  point = gWorkingGeometry->getPoint(points[i]) / 32.0; 
      mPointTable.push_back( Point3F(point.x,point.y,point.z) );
      remapPoints[ points[i] ] = i;
   }
   for( i = 0, mPlaneTable.reserve(planes.size()); i < planes.size(); i++ )
   {
      PlaneEQ  pl64 = gWorkingGeometry->getPlaneEQ(planes[i]);
      Point3F  norm ( pl64.normal.x, pl64.normal.y, pl64.normal.z );
      F64      dist ( pl64.dist / 32.0 );
      mPlaneTable.push_back( PlaneF(norm.x, norm.y, norm.z, dist) );
      remapPlanes[ planes[i] ] = i;
   }

#1
09/28/2004 (12:41 pm)
Hi,

We had this problem as well. We solved it by making sure that the building is perfectly square (no half squares) and all wall must be 6 blocks thick. This also had an added benifit in that we were able to make actual textured doors that look real. Ken my artist had to go back and completely redoo our buildings, but it worked.

Marrion Cox
#2
09/29/2004 (1:34 am)
@Katrina: thanks for the tip but that isn't a solution for me. Square buildings are no good.

The problem comes down to when sunlight is allowed into the building, then the seams show up. If the building is sealed then there are no leaks which is fine for most buildings, but when you've got a hole in the roof or need to let sunlight in to affect the model (bright red sun in one mission) this is where it falls down.
#3
09/30/2004 (6:41 am)
OK, i'll ask another question. Is there any documentation for map2dif. I can't find it in the engine docs?
#4
09/30/2004 (2:11 pm)
...
#5
09/30/2004 (2:47 pm)
Id no-one is sure how it works why don't we switch over to MAP format and solve lots of problems at once. Theres loads of free map parser code out there.
#6
09/30/2004 (3:01 pm)
...
#7
09/30/2004 (11:40 pm)
Sigh! I shall have to do a microsoft customer and wait till someone fixes it somewhere down the line. It's just annoying that models that work in other engines don't work in Torque just because of the lightmap errors.
I wish I understood a bit more but the maths and theory is beyond me at the moment.
#8
10/01/2004 (6:51 am)
FruitBat:

If you know how to compile map2dif and have the tools... you could try (carefully) fudging with that value and see what happens. Just backup your work and you have nothing to worry about. I don't know what context the function above is used in, so I can't tell what it's really doing, but it does appear just from that code that those 32s are sort of magic numbers. If that's the default lightmap resolution, then I'm even more inclined to think so. Try changing them both to 8 or 16, and also setting your lightmap resolution to that. Or just try changing the values and see what happens. Also try changing them to 64. You might get really weird results that don't make any sense... but as long as you have the original copy backed up, no harm done.
#9
11/14/2004 (4:12 pm)
Is that code actually used? i just did quick search for "foorPlan" and the only spot is see that data actually used is:

// Test writing the resource
mEditFloorPlanRes.constructFloorPlan();
FileStream fws;
fws.open("sample.flr", FileStream::Write);
mEditFloorPlanRes.write(fws);
fws.close();

but is the file "sample.flr" ever used. i'm not sure what the navgraph stuff is but it sure doesn't look like it has to do with lighting... anybody know for sure?
#10
11/14/2004 (10:17 pm)
The floorplan stuff is there to help with AI... not used at the moment but we don't want to rip it out, as it might be useful.

map2dif is a mess and I have no idea what in specifics is going on. The good news is we are taking steps to get it cleaned up. :)