Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r992 - trunk/Model/Groups
- Date: Thu, 23 Mar 2006 01:51:52 -0700 (MST)
Author: bigler
Date: Thu Mar 23 01:51:51 2006
New Revision: 992
Modified:
trunk/Model/Groups/KDTreeLoaderIW.cc
Log:
I think I'm parsing the bsp file correctly. Now all I have to do is
get the conversion from the internal representation to the KDTree
format done properly.
Modified: trunk/Model/Groups/KDTreeLoaderIW.cc
==============================================================================
--- trunk/Model/Groups/KDTreeLoaderIW.cc (original)
+++ trunk/Model/Groups/KDTreeLoaderIW.cc Thu Mar 23 01:51:51 2006
@@ -276,11 +276,14 @@
IWNode* top = head;
while((getline(&bline, &bline_len, bspf)) != -1) {
+ // fprintf (stderr, "line(%u): %s\n", bline_len, bline);
// Check the first token
- char token;
- sscanf(bline, "% c", &token);
- if (token == 'N') {
+ char token[2];
+ int num = sscanf(bline, "%1s", token);
+ // fprintf(stderr, "num = %d, token = %s\n", num, token);
+ if (strcmp(token, "N") == 0) {
num_nodes ++;
+ // fprintf(stderr, "Node %u found\n", num_nodes);
IWNode* node = new IWNode(top);
// Is this the first node?
@@ -298,20 +301,21 @@
top = node;
char axis_c;
- sscanf(bline, "% c=%f,d=%*", &axis_c, &(node->split));
+ sscanf(bline, "%*s %c=%f,d=%*d", &axis_c, &(node->split));
+ // fprintf(stderr, "axis = %c, split = %g\n", axis_c,
node->split);
switch (axis_c) {
case 'x': node->flags |= 0; break;
case 'y': node->flags |= 1; break;
case 'z': node->flags |= 2; break;
}
- } else if (token == 'L') {
+ } else if (strcmp(token, "L") == 0) {
IWNode* node = new IWNode(top);
if (top->left) {
top->setRight(node);
// Finish up this level
- while (top->right) {
+ while (top && top->right) {
top = top->parent;
}
} else {
@@ -319,16 +323,25 @@
}
// Grab how many objects we have
- sscanf(bline, "%u", &(node->num_tris));
+ sscanf(bline, "%*s %u", &(node->num_tris));
+ // fprintf(stderr, "L %u\n", node->num_tris);
num_tri_indicies += node->num_tris;
if (node->num_tris) {
num_nodes++;
// If you ever change what type triIndices is you will need to
- // update this bit of code.
+ // update this bit of code for the right type.
int* tri_ids_p = node->tri_ids = new int[node->num_tris];
+ int pos = 0; // Where to pick up parsing next. This will give
+ // us an offset to our token string, so that we
+ // can grab the next integer one at a time.
+ sscanf(bline, "%*s %*u %n", &pos);
+ // fprintf(stderr, "pos = %d\n", pos);
+ char* bline_p = bline+pos;
for(unsigned int i = 0; i < node->num_tris; ++i) {
- sscanf(bline, "%d", tri_ids_p);
+ sscanf(bline_p, "%d %n", tri_ids_p, &pos);
+ // fprintf(stderr, "pos = %d, %d\n", pos, *tri_ids_p);
+ bline_p += pos;
++tri_ids_p;
}
}
- [MANTA] r992 - trunk/Model/Groups, bigler, 03/23/2006
Archive powered by MHonArc 2.6.16.