routes
[carveJwlIkooP6JGAAIwe30JlM.git] / model.h
diff --git a/model.h b/model.h
index a65f11fd2ae20dcdde75ab1e72f6a50545af56f6..f8b09b85fcbdb2af8f8d5ae6f0753b6114bdc0dc 100644 (file)
--- a/model.h
+++ b/model.h
@@ -14,7 +14,7 @@ typedef struct mdl_header mdl_header;
 #define MDL_SIZE_MAX          0x1000000
 #define MDL_VERT_MAX          1000000
 #define MDL_INDICE_MAX        1000000
-#define MDL_MATERIAL_MAX      500
+#define MDL_MATERIAL_MAX      32
 #define MDL_NODE_MAX          4000
 #define MDL_SUBMESH_MAX       8000
 #define MDL_STRING_LENGTH_MAX 64
@@ -83,6 +83,7 @@ struct classtype_block
 struct classtype_gate
 {
    u32 target;
+   v3f dims;
 };
 
 struct classtype_spawn
@@ -100,6 +101,27 @@ struct classtype_car_path
    u32 target, target1;
 };
 
+struct classtype_instance
+{
+   u32 pstr_file;
+};
+
+struct classtype_capsule
+{
+   float height, radius;
+};
+
+struct classtype_route_node
+{
+   u32 target, target1;
+};
+
+struct classtype_route
+{
+   u32 pstr_name;
+   u32 id_start;
+};
+
 #pragma pack(pop)
 
 /*
@@ -411,5 +433,42 @@ static void *mdl_get_entdata( mdl_header *mdl, mdl_node *pnode )
    return mdl_baseptr( mdl, mdl->entdata_offset ) + pnode->offset;
 }
 
+static void mdl_link_materials( mdl_header *root, mdl_header *child )
+{
+   u32 lookup[MDL_MATERIAL_MAX];
+   
+   for( int i=0; i<child->material_count; i++ )
+   {
+      mdl_material *mi = mdl_material_from_id( child, i );
+      const char *si = mdl_pstr( child, mi->pstr_name );
+
+      lookup[i] = 0;
+
+      for( int j=0; j<root->material_count; j++ )
+      {
+         mdl_material *mj = mdl_material_from_id( root, j );
+         const char *sj = mdl_pstr( root, mj->pstr_name );
+         
+         if( !strcmp( si, sj ) )
+         {
+            lookup[i] = j;
+            break;
+         }
+      }
+
+      if( lookup[i] == 0 && i != 0 )
+      {
+         vg_warn( "Could not link material '%s' (not present in root model)\n", 
+                   si );
+      }
+   }
+
+   for( int i=0; i<child->submesh_count; i++ )
+   {
+      mdl_submesh *sm = mdl_submesh_from_id( child, i );
+      sm->material_id = lookup[sm->material_id];
+   }
+}
+
 
 #endif