Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct V3D
- {
- fixed x, y, z; - position
- fixed u, v; - texture map coordinates
- int c; - color
- } V3D;
- void do_polygon3dr(BITMAP *bmp, int i, int *sdci, int xoffset, int yoffset)
- {
- //sdci[1]=layer
- //sdci[2]=pos[12]
- //sdci[3]=uv[8]
- //sdci[4]=color[4]
- //sdci[5]=size[2]
- //sdci[6]=flip
- //sdci[7]=tile/combo
- //sdci[8]=polytype
- std::vector<long>* v_ptr = (std::vector<long>*)script_drawing_commands[i].GetPtr();
- if(!v_ptr)
- {
- al_trace("Quad3d: Vector pointer is null! Internal error. \n");
- return;
- }
- std::vector<long> &v = *v_ptr;
- if(v.empty())
- return;
- long* pos = &v[0];
- long* uv = &v[12];
- long* col = &v[20];
- long* size = &v[24];
- int w = size[0]; //magic numerical constants... yuck.
- int h = size[1];
- int flip = (sdci[6]/10000)&3;
- int tile = sdci[7]/10000;
- int polytype = sdci[8]/10000;
- polytype = vbound(polytype, 0, 14);
- if(((w-1) & w) != 0 || ((h-1) & h) != 0) return; //non power of two error
- int tex_width = w*16;
- int tex_height = h*16;
- bool mustDestroyBmp = false;
- BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
- if(!tex)
- {
- mustDestroyBmp = true;
- tex = create_bitmap_ex(8, tex_width, tex_height);
- clear_bitmap(tex);
- }
- if(tile > 0) // TILE
- {
- TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
- }
- else // COMBO
- {
- const newcombo & c = combobuf[ vbound(abs(tile), 0, 0xffff) ];
- const int tiletodraw = combo_tile(c, 0, 0);
- flip = flip ^ c.flip;
- TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
- }
- 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] };
- 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] };
- 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] };
- 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] };
- quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
- if(mustDestroyBmp)
- destroy_bitmap(tex);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement