ZoriaRPG

polygon3d_base.cpp

Jun 24th, 2017
97
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef struct V3D
  2.       {
  3.          fixed x, y, z;       - position
  4.          fixed u, v;          - texture map coordinates
  5.          int c;               - color
  6.       } V3D;
  7.      
  8. void do_polygon3dr(BITMAP *bmp, int i, int *sdci, int xoffset, int yoffset)
  9. {
  10.     //sdci[1]=layer
  11.     //sdci[2]=pos[12]
  12.     //sdci[3]=uv[8]
  13.     //sdci[4]=color[4]
  14.     //sdci[5]=size[2]
  15.     //sdci[6]=flip
  16.     //sdci[7]=tile/combo
  17.     //sdci[8]=polytype
  18.    
  19.     std::vector<long>* v_ptr = (std::vector<long>*)script_drawing_commands[i].GetPtr();
  20.    
  21.     if(!v_ptr)
  22.     {
  23.         al_trace("Quad3d: Vector pointer is null! Internal error. \n");
  24.         return;
  25.     }
  26.    
  27.     std::vector<long> &v = *v_ptr;
  28.    
  29.     if(v.empty())
  30.         return;
  31.        
  32.     long* pos = &v[0];
  33.     long* uv = &v[12];
  34.     long* col = &v[20];
  35.     long* size = &v[24];
  36.    
  37.     int w = size[0]; //magic numerical constants... yuck.
  38.     int h = size[1];
  39.     int flip = (sdci[6]/10000)&3;
  40.     int tile = sdci[7]/10000;
  41.     int polytype = sdci[8]/10000;
  42.    
  43.     polytype = vbound(polytype, 0, 14);
  44.    
  45.     if(((w-1) & w) != 0 || ((h-1) & h) != 0) return;   //non power of two error
  46.    
  47.     int tex_width = w*16;
  48.     int tex_height = h*16;
  49.    
  50.     bool mustDestroyBmp = false;
  51.     BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
  52.    
  53.     if(!tex)
  54.     {
  55.         mustDestroyBmp = true;
  56.         tex = create_bitmap_ex(8, tex_width, tex_height);
  57.         clear_bitmap(tex);
  58.     }
  59.    
  60.     if(tile > 0)   // TILE
  61.     {
  62.         TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
  63.     }
  64.     else        // COMBO
  65.     {
  66.         const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
  67.         const int tiletodraw = combo_tile(c, 0, 0);
  68.         flip = flip ^ c.flip;
  69.        
  70.         TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
  71.     }
  72.    
  73.     V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]),  static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
  74.     V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]),  static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
  75.     V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]),  static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
  76.     V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
  77.    
  78.     quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
  79.    
  80.     if(mustDestroyBmp)
  81.         destroy_bitmap(tex);
  82.        
  83. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×