Update to CMake, tweaks & dds
[convexer.git] / cxr / cxr.h
index a6643131f6f26656657e7e6441c9311c96531944..1f1c649d88b533e95e32c895d1f1be6d76bca4b2 100644 (file)
--- a/cxr/cxr.h
+++ b/cxr/cxr.h
@@ -99,6 +99,7 @@ typedef struct cxr_tri_mesh cxr_tri_mesh;
 #ifdef CXR_VALVE_MAP_FILE
  typedef struct cxr_vdf cxr_vdf;
  typedef struct cxr_texinfo cxr_texinfo;
+ typedef struct cxr_visgroup cxr_visgroup;
  typedef struct cxr_vmf_context cxr_vmf_context;
 #endif /* CXR_VALVE_MAP_FILE */
 
@@ -242,6 +243,11 @@ struct cxr_texinfo
    double winding;
 };
 
+struct cxr_visgroup
+{
+   const char *name;
+};
+
 /* 
  * Simplified VDF writing interface. No allocations or nodes, just write to file
  */
@@ -259,10 +265,14 @@ struct cxr_vmf_context
               *detailvbsp,
               *detailmaterial;
 
+   cxr_visgroup *visgroups;
+   i32 visgroup_count;
+
    /* Transform settings */
    double scale;
    v3f offset;
-   i32 lightmap_scale;
+   i32 lightmap_scale,
+       visgroupid;
 
    /* Current stats */
    i32 brush_count,
@@ -3076,6 +3086,8 @@ static int cxr_write_disp( cxr_mesh *mesh, cxr_world *world,
             v3_muladds( face_center, refn, 1.5, pn );
             v3_muladds( face_center, refv, 1.5, pv );
             v3_muladds( face_center, refu, 1.5, pu );
+
+            v3_muladds( face_center, refn, 2.0, face_center );
          }
 
          /* Create world coordinates */
@@ -3239,7 +3251,8 @@ static int cxr_write_disp( cxr_mesh *mesh, cxr_world *world,
          cxr_vdf_node( output, "editor");
          cxr_vdf_colour255( output, "color", 
                colours_random[cxr_range(ctx->brush_count,8)]);
-
+         
+         cxr_vdf_ki32( output, "visgroupid", ctx->visgroupid );
          cxr_vdf_ki32( output, "visgroupshown",1);
          cxr_vdf_ki32( output, "visgroupautoshown",1);
          cxr_vdf_edon( output );
@@ -3269,6 +3282,15 @@ CXR_API void cxr_begin_vmf( cxr_vmf_context *ctx, cxr_vdf *output )
    cxr_vdf_edon( output );
 
    cxr_vdf_node( output, "visgroups" );
+
+   for( int i=0; i<ctx->visgroup_count; i++ )
+   {
+      cxr_vdf_node( output, "visgroup" );
+      cxr_vdf_kv( output, "name", ctx->visgroups[i].name );
+      cxr_vdf_ki32( output, "visgroupid", i+1 );
+      cxr_vdf_edon( output );
+   }
+
    cxr_vdf_edon( output );
 
    cxr_vdf_node( output, "viewsettings" );
@@ -3373,6 +3395,7 @@ CXR_API void cxr_push_world_vmf( cxr_world *world, cxr_vmf_context *ctx,
       cxr_vdf_colour255( output, "color", 
             colours_random[cxr_range(ctx->brush_count,8)]);
 
+      cxr_vdf_ki32( output, "visgroupid", ctx->visgroupid );
       cxr_vdf_ki32( output, "visgroupshown", 1 );
       cxr_vdf_ki32( output, "visgroupautoshown", 1 );
       cxr_vdf_edon( output );