Subversion Repositories Games.Carmageddon

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #include "modrend.h"
  2. #include "dbsetup.h"
  3. #include "harness/hooks.h"
  4. #include "harness/trace.h"
  5.  
  6. render_style_cbfn RenderStyleCalls[8] = {
  7.     renderFaces,             /* BR_RSTYLE_DEFAULT                       */
  8.     nullRender,              /* BR_RSTYLE_NONE                          */
  9.     renderPoints,            /* BR_RSTYLE_POINTS                                */
  10.     renderEdges,             /* BR_RSTYLE_EDGES                         */
  11.     renderFaces,             /* BR_RSTYLE_FACES                         */
  12.     boundingBoxRenderPoints, /* BR_RSTYLE_BOUNDING_POINTS       */
  13.     boundingBoxRenderEdges,  /* BR_RSTYLE_BOUNDING_EDGES                */
  14.     boundingBoxRenderFaces,  /* BR_RSTYLE_BOUNDING_FACES                */
  15. };
  16.  
  17. v11face bounds_faces[12] = {
  18.     { { 5, 6, 7 }, { 0, 13, 14 }, { { 1.0f, 0.0f, 0.0f, 1.0f } } },
  19.     { { 5, 4, 6 }, { 3, 4, 0 }, { { 1.0f, 0.0f, 0.0f, 1.0f } } },
  20.     { { 7, 6, 2 }, { 13, 6, 0 }, { { 0.0f, 1.0f, 0.0f, 1.0f } } },
  21.     { { 7, 2, 3 }, { 0, 5, 16 }, { { 0.0f, 1.0f, 0.0f, 1.0f } } },
  22.     { { 1, 5, 7 }, { 11, 14, 0 }, { { 0.0f, 0.0f, 1.0f, 1.0f } } },
  23.     { { 1, 7, 3 }, { 0, 16, 12 }, { { 0.0f, 0.0f, 1.0f, 1.0f } } },
  24.     { { 3, 0, 1 }, { 0, 8, 12 }, { { -1.0f, 0.0f, 0.0f, 1.0f } } },
  25.     { { 3, 2, 0 }, { 5, 1, 0 }, { { -1.0f, 0.0f, 0.0f, 1.0f } } },
  26.     { { 1, 0, 4 }, { 8, 9, 0 }, { { 0.0f, -1.0f, 0.0f, 1.0f } } },
  27.     { { 1, 4, 5 }, { 0, 3, 11 }, { { 0.0f, -1.0f, 0.0f, 1.0f } } },
  28.     { { 0, 6, 4 }, { 0, 4, 9 }, { { 0.0f, 0.0f, -1.0f, 1.0f } } },
  29.     { { 0, 2, 6 }, { 1, 6, 0 }, { { 0.0f, 0.0f, -1.0f, 1.0f } } },
  30. };
  31. br_colour bounds_colours[12] = { 0 };
  32. fmt_vertex bounds_vertices[8] = {
  33.     { { { -1.0f, -1.0f, -1.0f } }, { { 0.0f, 0.0f } }, { { -0.666f, -0.333f, -0.666f } } },
  34.     { { { -1.0f, -1.0f, 1.0f } }, { { 0.0f, 0.0f } }, { { -0.333f, -0.666f, 0.666f } } },
  35.     { { { -1.0f, 1.0f, -1.0f } }, { { 0.0f, 1.0f } }, { { -0.408f, 0.816f, -0.408f } } },
  36.     { { { -1.0f, 1.0f, 1.0f } }, { { 0.0f, 1.0f } }, { { -0.816f, 0.408f, 0.408f } } },
  37.     { { { 1.0f, -1.0f, -1.0f } }, { { 1.0f, 0.0f } }, { { 0.408f, -0.816f, -0.408f } } },
  38.     { { { 1.0f, -1.0f, 1.0f } }, { { 1.0f, 0.0f } }, { { 0.816f, -0.408f, 0.408f } } },
  39.     { { { 1.0f, 1.0f, -1.0f } }, { { 1.0f, 1.0f } }, { { 0.666f, 0.333f, -0.666f } } },
  40.     { { { 1.0f, 1.0f, 1.0f } }, { { 1.0f, 1.0f } }, { { 0.333f, 0.666f, 0.666f } } },
  41. };
  42. v11group bounds_face_groups[1] = {
  43.     { NULL, bounds_faces, bounds_colours, NULL, bounds_vertices, bounds_colours, NULL, BR_ASIZE(bounds_faces), BR_ASIZE(bounds_vertices), 18, NULL },
  44. };
  45. v11model bounds_prepared = { 0, 0, BR_ASIZE(bounds_face_groups), { { 0 } }, bounds_face_groups };
  46. br_model bounds_model = {
  47.     0,
  48.     "Bounds",
  49.     NULL,
  50.     NULL,
  51.     0,
  52.     0,
  53.     { { 0.f, 0.f, 0.f } },
  54.     0,
  55.     NULL,
  56.     NULL,
  57.     0,
  58.     0.f,
  59.     { { { 0.f, 0.f, 0.f } }, { { 0.f, 0.f, 0.f } } },
  60.     &bounds_prepared,
  61.     NULL,
  62. };
  63.  
  64. // IDA: void __usercall renderFaces(br_actor *actor@<EAX>, br_model *model@<EDX>, br_material *material@<EBX>, void *render_data@<ECX>, br_uint_8 style, int on_screen)
  65. void renderFaces(br_actor* actor, br_model* model, br_material* material, void* render_data, br_uint_8 style, int on_screen) {
  66.     LOG_TRACE9("(%p, %p, %p, %p, %d, %d)", actor, model, material, render_data, style, on_screen);
  67.     Harness_Hook_renderActor(actor, model, material, BRT_TRIANGLE);
  68. }
  69.  
  70. // IDA: void __usercall renderEdges(br_actor *actor@<EAX>, br_model *model@<EDX>, br_material *material@<EBX>, void *render_data@<ECX>, br_uint_8 style, int on_screen)
  71. void renderEdges(br_actor* actor, br_model* model, br_material* material, void* render_data, br_uint_8 style, int on_screen) {
  72.     LOG_TRACE("(%p, %p, %p, %p, %d, %d)", actor, model, material, render_data, style, on_screen);
  73.     Harness_Hook_renderActor(actor, model, material, BRT_LINE);
  74. }
  75.  
  76. // IDA: void __usercall renderPoints(br_actor *actor@<EAX>, br_model *model@<EDX>, br_material *material@<EBX>, void *render_data@<ECX>, br_uint_8 style, int on_screen)
  77. void renderPoints(br_actor* actor, br_model* model, br_material* material, void* render_data, br_uint_8 style, int on_screen) {
  78.     LOG_TRACE("(%p, %p, %p, %p, %d, %d)", actor, model, material, render_data, style, on_screen);
  79.     NOT_IMPLEMENTED();
  80. }
  81.  
  82. // IDA: void __usercall nullRender(br_actor *actor@<EAX>, br_model *model@<EDX>, br_material *material@<EBX>, void *render_data@<ECX>, br_uint_8 style, int on_screen)
  83. void nullRender(br_actor* actor, br_model* model, br_material* material, void* render_data, br_uint_8 style, int on_screen) {
  84.     LOG_TRACE("(%p, %p, %p, %p, %d, %d)", actor, model, material, render_data, style, on_screen);
  85. }
  86.  
  87. // IDA: br_model* __usercall makeMeshFromBounds@<EAX>(br_bounds *b@<EAX>)
  88. br_model* makeMeshFromBounds(br_bounds* b) {
  89.     int i;
  90.     LOG_TRACE("(%p)", b);
  91.  
  92.     // 1. Modify vertex points
  93.     bounds_vertices[0].p.v[0] = b->min.v[0];
  94.     bounds_vertices[0].p.v[1] = b->min.v[1];
  95.     bounds_vertices[0].p.v[2] = b->min.v[2];
  96.  
  97.     bounds_vertices[1].p.v[0] = b->min.v[0];
  98.     bounds_vertices[1].p.v[1] = b->min.v[1];
  99.     bounds_vertices[1].p.v[2] = b->max.v[2];
  100.  
  101.     bounds_vertices[2].p.v[0] = b->min.v[0];
  102.     bounds_vertices[2].p.v[1] = b->max.v[1];
  103.     bounds_vertices[2].p.v[2] = b->min.v[2];
  104.  
  105.     bounds_vertices[3].p.v[0] = b->min.v[0];
  106.     bounds_vertices[3].p.v[1] = b->max.v[1];
  107.     bounds_vertices[3].p.v[2] = b->max.v[2];
  108.  
  109.     bounds_vertices[4].p.v[0] = b->max.v[0];
  110.     bounds_vertices[4].p.v[1] = b->min.v[1];
  111.     bounds_vertices[4].p.v[2] = b->min.v[2];
  112.  
  113.     bounds_vertices[5].p.v[0] = b->max.v[0];
  114.     bounds_vertices[5].p.v[1] = b->min.v[1];
  115.     bounds_vertices[5].p.v[2] = b->max.v[2];
  116.  
  117.     bounds_vertices[6].p.v[0] = b->max.v[0];
  118.     bounds_vertices[6].p.v[1] = b->max.v[1];
  119.     bounds_vertices[6].p.v[2] = b->min.v[2];
  120.  
  121.     bounds_vertices[7].p.v[0] = b->max.v[0];
  122.     bounds_vertices[7].p.v[1] = b->max.v[1];
  123.     bounds_vertices[7].p.v[2] = b->max.v[2];
  124.  
  125.     // 2. Modify d in the face equation (a*x+b*y+c*y+d=0)
  126.     for (i = 0; i < BR_ASIZE(bounds_faces) / 4; i++) {
  127.         bounds_faces[2 * i + 0].eqn.v[3] = b->min.v[i];
  128.         bounds_faces[2 * i + 1].eqn.v[3] = b->min.v[i];
  129.         bounds_faces[2 * i + 6].eqn.v[3] = b->max.v[i];
  130.         bounds_faces[2 * i + 7].eqn.v[3] = b->max.v[i];
  131.     }
  132.  
  133.     // 3. Copy bounds
  134.     bounds_model.bounds = *b;
  135.  
  136.     return &bounds_model;
  137. }
  138.  
  139. // IDA: void __usercall boundingBoxRenderPoints(br_actor *actor@<EAX>, br_model *model@<EDX>, br_material *material@<EBX>, void *render_data@<ECX>, br_uint_8 style, int on_screen)
  140. void boundingBoxRenderPoints(br_actor* actor, br_model* model, br_material* material, void* render_data, br_uint_8 style, int on_screen) {
  141.     LOG_TRACE("(%p, %p, %p, %p, %d, %d)", actor, model, material, render_data, style, on_screen);
  142.     NOT_IMPLEMENTED();
  143. }
  144.  
  145. // IDA: void __usercall boundingBoxRenderEdges(br_actor *actor@<EAX>, br_model *model@<EDX>, br_material *material@<EBX>, void *render_data@<ECX>, br_uint_8 style, int on_screen)
  146. void boundingBoxRenderEdges(br_actor* actor, br_model* model, br_material* material, void* render_data, br_uint_8 style, int on_screen) {
  147.     LOG_TRACE("(%p, %p, %p, %p, %d, %d)", actor, model, material, render_data, style, on_screen);
  148.     NOT_IMPLEMENTED();
  149. }
  150.  
  151. // IDA: void __usercall boundingBoxRenderFaces(br_actor *actor@<EAX>, br_model *model@<EDX>, br_material *material@<EBX>, void *render_data@<ECX>, br_uint_8 style, int on_screen)
  152. void boundingBoxRenderFaces(br_actor* actor, br_model* model, br_material* material, void* render_data, br_uint_8 style, int on_screen) {
  153.     LOG_TRACE("(%p, %p, %p, %p, %d, %d)", actor, model, material, render_data, style, on_screen);
  154.     NOT_IMPLEMENTED();
  155. }
  156.