Show
Ignore:
Timestamp:
04/13/10 17:06:34 (2 years ago)
Author:
Carsten
Message:

a) Changed the format of pts pointfiles to Lua. That is, pointfiles are now true, complete Lua programs:

  • CaBSP has been updated to write pointfiles in the new format as Lua programs,
  • CaWE has been updated to run pointfiles as Lua programs and to look into the generated Points table for the results.

b) Added a new recordPath() console function to the Cafu game client that allows recording the path of the player.

(This functionality has been asked for by Dennis Köhler from the FH Dortmund for running a new set of scientific tests.)
The recored paths are saved in the same pointfile format as those for leaks, and thus can uniformly be loaded into CaWE for visualization!

c) CaWE: Fixed occurrences of wxMessageBox(..., wxOK | wxICON_...) being called without the wxOK constant.

Some open issues for future consideration:
- Allow record-style initialization besides the existing list-style initialization.
- Support setting a custom line color in the pointfile.
- In CaWE, visualize not only the point coordinates, but also the time, heading, comments, ...

Example future pointfile:

Points=
{

-- color="blue", -- Any string that the wxColour() ctor recognizes.

-- Use record-style or list-style initialization.
{ 0; -1695, -498.692, -67.9358; 9874; "" },
{ 5.26625; -1697.05, -482.187, -67.9358; 64250; "" },
{ 5.77412; -1711.62, -364.583, -67.9358; 64250; "" },
{ t=6.30243; x=-1726.45, y=-243.117, z=-67.9358; hdg=64310; comment="" },
{ t=6.80414; -1740.28, -125.456, -43.9358; hdg=64640; "" }, -- mixed...

}

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/CaBSP/BspTreeBuilder/LeakDetection.cpp

    r36 r48  
    137137    Console->Print("\n### LEAK DETECTED! ###\n\n"); 
    138138    Console->Print("A leak is a hole in the world, where the inside of it is exposed to the\n"); 
    139     Console->Print("(unwanted) outside region. Thus, I generated a leak pointfile.\n"); 
    140     Console->Print("Load this file into your world editor, and find the beginning of the line.\n"); 
     139    Console->Print("(unwanted) outside region. Thus, a leak pointfile has been generated.\n"); 
     140    Console->Print("Load this file into the world editor CaWE, and find the beginning of the line.\n"); 
    141141    Console->Print("Hint: The beginning is always near one of the \"info_player_start\" entities.\n"); 
    142142    Console->Print("Then find and fix the leak by tracing the line until you reach the outside.\n"); 
    143     Console->Print("(I always take the shortest path, so this should be easy.)\n"); 
     143    Console->Print("(The line always takes the shortest path, so this should be easy.)\n"); 
    144144    Console->Print("\nNotes:\n"); 
    145145    Console->Print("- Leaks can be *very* small. Use a close-up view, if necessary.\n"); 
    146146    Console->Print("- Use the grid. The grid is useful to fix leaks + to avoid them from the start.\n"); 
    147147    Console->Print("- Make sure that *all* \"info_player_start\" entities are inside the world!\n"); 
    148     Console->Print("- The pointfile assumes that WcMap2Ca.exe scaled the world by factor 25.4.\n"); 
    149148    Console->Print("- Be aware that both the clip hull and the draw hull must be sealed.\n"); 
    150149    Console->Print("- Please refer to the documentation for additional information.\n"); 
     
    154153    ComputeLeakPathByBFS(InfoPlayerStartOrigin); 
    155154 
    156     FILE* PointFile=fopen(PointFileName.c_str(), "w"); 
     155    std::ofstream PointFile(PointFileName.c_str()); 
     156    unsigned long PointCount=0; 
     157 
    157158    if (!PointFile) Error("Could not open pointfile \"%s\" for writing!", PointFileName.c_str()); 
    158159 
    159     // The following is also possible in a single big for-loop that does not require the 'Points' array. 
    160     // However, it would then be much more complicated to consider all the special cases when something goes wrong (see below). 
    161     // Thus, for clarity, I keep it simple, even at the cost of sub-optimal efficiency. 
    162     ArrayT<VectorT> Points; 
     160    PointFile << "Points=\n"; 
     161    PointFile << "{\n"; 
    163162 
    164163    // Let "S" be the start leaf that contains the 'InfoPlayerStartOrigin'. 
    165     // The following loop puts all the path points into the 'Points' array, including the 'InfoPlayerStartOrigin' of leaf "S". 
    166     // Three cases are possible, and all of them are gracefully handled (that is much harder with a big loop!): 
     164    // The following loop writes all the path points, including the 'InfoPlayerStartOrigin' of leaf "S". 
     165    // Three cases are possible, and all of them are gracefully handled: 
    167166    // a) If "S" is NOT reachable from LeafNr, something is wrong (this is a bug!). 
    168167    //    The predecessor of LeafNr is -1, and therefore only a single point (0, 0, 0) gets written. 
     
    171170    // c) In the normal case, as least two points are written into the 'Points' array. 
    172171    for (unsigned long CurrentLeaf=LeafNr; CurrentLeaf!=(unsigned long)-1; CurrentLeaf=BFS_Tree[CurrentLeaf]) 
    173         Points.PushBack(scale(BFS_TreePoints[CurrentLeaf], 1.0/25.4)); 
    174  
    175     for (unsigned long PointNr=0; PointNr+1<Points.Size(); PointNr++) 
    176     { 
    177         VectorT V1=Points[PointNr  ]; 
    178         VectorT d =Points[PointNr+1]-V1; 
    179         double  l =length(d); 
    180  
    181         // Console->Print(cf::va("%5u %5u    %f %f %f   -   %f %f %f\n", CurrentLeaf, NextLeaf, V1.x, V1.y, V1.z, V2.x, V2.y, V2.z)); 
    182         if (l<1.0) continue; 
    183         d=scale(normalize(d, 0.0), 2.0); 
    184  
    185         while (l>=0.0) 
    186         { 
    187             fprintf(PointFile, "%f %f %f\n", V1.x, V1.y, V1.z); 
    188             V1=V1+d; 
    189             l-=2.0; 
    190         } 
    191     } 
    192  
    193     fclose(PointFile); 
    194  
    195     if (Points.Size()<2) 
     172    { 
     173        const Vector3dT Point=BFS_TreePoints[CurrentLeaf]/25.4; 
     174 
     175        PointFile << "  { "; 
     176        PointFile << PointCount << "; " << "  ";                    // Time 
     177        PointFile << Point.x    << ", "; 
     178        PointFile << Point.y    << ", "; 
     179        PointFile << Point.z    << "; " << "  "; 
     180        PointFile << 0          << "; ";                            // Heading 
     181        PointFile << "\"leaf " << int(CurrentLeaf) << "\" },\n";    // Comment 
     182 
     183        PointCount++; 
     184    } 
     185 
     186    PointFile << "}\n"; 
     187 
     188    if (PointCount<2) 
    196189    { 
    197190        Console->Print("\nSorry, I have ANOTHER WARNING:\n"); 
     
    199192        Console->Print(">> Did you really place all your \"info_player_start\" entities INSIDE the world?\n"); 
    200193        Console->Print("If you did, and you still see this message, please send an email to\n"); 
    201         Console->Print("CarstenFuchs@T-Online.de\n"); 
    202         Console->Print("Tell him about this message (best is to use copy & paste, or a screen-shot),\n"); 
     194        Console->Print("info@cafu.de\n"); 
     195        Console->Print("Tell them about this message (best is to use copy & paste, or a screen-shot),\n"); 
    203196        Console->Print("and ideally, include this map as an attachment.\n"); 
    204197    }