/* ================ idCollisionModelManagerLocal::WriteBrushes ================ */ void idCollisionModelManagerLocal::WriteBrushes( idFile *fp, cm_node_t *node ) { cm_brushRef_t *bref; cm_brush_t *b; int i; for ( bref = node->brushes; bref; bref = bref->next ) { b = bref->b; if ( b->checkcount == checkCount ) { continue; } b->checkcount = checkCount; fp->WriteFloatString( "\t%d {\n", b->numPlanes ); for ( i = 0; i < b->numPlanes; i++ ) { fp->WriteFloatString( "\t\t( %f %f %f ) %f\n", b->planes[i].Normal()[0], b->planes[i].Normal()[1], b->planes[i].Normal()[2], b->planes[i].Dist() ); } fp->WriteFloatString( "\t} ( %f %f %f )", b->bounds[0][0], b->bounds[0][1], b->bounds[0][2] ); fp->WriteFloatString( " ( %f %f %f ) \"%s\"\n", b->bounds[1][0], b->bounds[1][1], b->bounds[1][2], StringFromContents( b->contents ) ); } if ( node->planeType != -1 ) { WriteBrushes( fp, node->children[0] ); WriteBrushes( fp, node->children[1] ); } }
/* ================ idCollisionModelManagerLocal::WriteCollisionModel ================ */ void idCollisionModelManagerLocal::WriteCollisionModel( idFile *fp, cm_model_t *model ) { int i, polygonMemory, brushMemory; fp->WriteFloatString( "collisionModel \"%s\" {\n", model->name.c_str() ); // vertices fp->WriteFloatString( "\tvertices { /* numVertices = */ %d\n", model->numVertices ); for( i = 0; i < model->numVertices; i++ ) { fp->WriteFloatString( "\t/* %d */ (%f %f %f)\n", i, model->vertices[i].p[0], model->vertices[i].p[1], model->vertices[i].p[2] ); } fp->WriteFloatString( "\t}\n" ); // edges fp->WriteFloatString( "\tedges { /* numEdges = */ %d\n", model->numEdges ); for( i = 0; i < model->numEdges; i++ ) { fp->WriteFloatString( "\t/* %d */ (%d %d) %d %d\n", i, model->edges[i].vertexNum[0], model->edges[i].vertexNum[1], model->edges[i].internal, model->edges[i].numUsers ); } fp->WriteFloatString( "\t}\n" ); // nodes fp->WriteFloatString( "\tnodes {\n" ); WriteNodes( fp, model->node ); fp->WriteFloatString( "\t}\n" ); // polygons checkCount++; polygonMemory = CountPolygonMemory( model->node ); fp->WriteFloatString( "\tpolygons /* polygonMemory = */ %d {\n", polygonMemory ); checkCount++; WritePolygons( fp, model->node ); fp->WriteFloatString( "\t}\n" ); // brushes checkCount++; brushMemory = CountBrushMemory( model->node ); fp->WriteFloatString( "\tbrushes /* brushMemory = */ %d {\n", brushMemory ); checkCount++; WriteBrushes( fp, model->node ); fp->WriteFloatString( "\t}\n" ); // closing brace fp->WriteFloatString( "}\n" ); }