OSL::Matrix44 ShadingPoint::OSLObjectTransformInfo::get_inverse_transform() const { assert(!is_animated()); const Transformd& assembly_xform = m_assembly_instance_transform->get_earliest_transform(); const Transformd::MatrixType m( m_object_instance_transform->get_parent_to_local() * assembly_xform.get_parent_to_local()); return Matrix4f(transpose(m)); }
// ========================================================================== int main(int argc, char * argv[]) { BLOCK_S * block_ptr=NULL; BITMAP * pcxbmp = NULL; FILE * in, * out; char strtmp[256], pcxfilename[256], * ptr; long b, t, w, h; enum {PT_FA, PT_FS, PT_WU, PT_WD, PT_MAX}; int pcx_idx, i; struct { char * name; long w; long h; int col; } pcx[PT_MAX]; // header & syntaxe printf("DT1EXTR v 0.97 beta, by Paul Siramy, Freeware\n" "=============================================\n"); if (argc == 1) { printf("syntaxe : dt1extr <file.dt1> [-pal <file.dat>]\n"); exit(0); } // palette & atexit() if (strcmp(argv[2], "-pal") == 0) load_palette(argv[3]); else { printf("opening default palette\n "); load_palette("d2pal\\act1.dat"); } // dt1 file in = fopen(argv[1], "rb"); if (in == NULL) { printf("can't open %s\n", argv[1]); exit(1); } else printf("opening %s\n", argv[1]); read_dt1_header(in); read_blocks_headers(in); for (t=0; t<glb_block_number; t++) read_tiles_of_block(in, t); fclose(in); allegro_init(); set_color_depth(8); atexit(dt1con_exit); memset(pcx, 0, sizeof(pcx)); pcx[PT_FA].name = "fa"; // floor animated pcx[PT_FS].name = "fs"; // floor static pcx[PT_WU].name = "wu"; // walls up pcx[PT_WD].name = "wd"; // walls down ptr = argv[1]; i=strlen(ptr) - 1; while ((i >= 0) && ( * (ptr+i) != '\\') && ( * (ptr+i) != ':')) i--; if (i != 0) i++; strcpy(strtmp, ptr+i); strtmp[strlen(strtmp) - 4] = 0; strcat(strtmp, ".ini"); out = fopen(strtmp, "wt"); printf("saving %s\n", strtmp); strtmp[strlen(strtmp) - 4] = 0; // start of ini fprintf(out, "nb_blocks = %li\n\n", glb_block_number); // check the size of each pcx for (b=0; b<glb_block_number; b++) { block_ptr = glb_block + b; // set some flags if ( ((block_ptr->direction == 3) && (block_ptr->orientation == 0)) || ((block_ptr->direction == 5) && (block_ptr->orientation == 15)) ) { // floor set_floor(block_ptr->f); if (block_ptr->animated) { set_animated(block_ptr->f); } else set_static(block_ptr->f); } else { // wall set_wall(block_ptr->f); if (block_ptr->orientation & 0xF0) set_wall_down(block_ptr->f); else set_wall_up(block_ptr->f); } // boxsize h = block_ptr->ysize; if (h < 0) h = - h; if (is_wall(block_ptr->f)) h += 32; // 1 worldstone down wall need more border w = block_ptr->xsize; // place the block in the pcx pcx_idx = -1; if (is_floor(block_ptr->f)) { h = 80; if (is_static(block_ptr->f)) pcx_idx = PT_FS; else if (is_animated(block_ptr->f)) pcx_idx = PT_FA; } else if (is_wall(block_ptr->f)) { if (is_wall_up(block_ptr->f)) pcx_idx = PT_WU; else if (is_wall_down(block_ptr->f)) pcx_idx = PT_WD; } if (pcx_idx != -1) { block_ptr->pcx_n = pcx_idx; block_ptr->pcx_x = pcx[pcx_idx].w; if ( (pcx_idx == PT_FA) || (pcx_idx == PT_FS) ) { block_ptr->pcx_y = 80 * (block_ptr->pcx_x / 800); block_ptr->pcx_x = block_ptr->pcx_x % 800; } pcx[pcx_idx].w += 160; if (pcx[pcx_idx].h < h) pcx[pcx_idx].h = h; pcx[pcx_idx].col++; // ini fprintf(out, "block = %li\n", b); fprintf(out, "pcx_file = %s\n", pcx[pcx_idx].name); fprintf(out, "pcx_x = %i\n", block_ptr->pcx_x); fprintf(out, "pcx_y = %i\n", block_ptr->pcx_y); fprintf(out, "direction = %08lX\n", block_ptr->direction); // fprintf(out, "flags = %08lX\n", block_ptr->flags); fprintf(out, "y_delta = %i\n", block_ptr->y_delta); fprintf(out, "tile_sound = %i\n", block_ptr->tile_sound); fprintf(out, "animated = %i\n", block_ptr->animated); fprintf(out, "orientation = %08lX\n", block_ptr->orientation); fprintf(out, "main_index = %08lX\n", block_ptr->main_index); fprintf(out, "sub_index = %08lX\n", block_ptr->sub_index); fprintf(out, "frame = %08lX\n", block_ptr->frame); fprintf(out, "unknown = %08lX\n", block_ptr->unknown); fprintf(out, "floor_flag1 = %02X %02X %02X %02X %02X\n", block_ptr->sub_tiles_flags[20], block_ptr->sub_tiles_flags[21], block_ptr->sub_tiles_flags[22], block_ptr->sub_tiles_flags[23], block_ptr->sub_tiles_flags[24] ); fprintf(out, "floor_flag2 = %02X %02X %02X %02X %02X\n", block_ptr->sub_tiles_flags[15], block_ptr->sub_tiles_flags[16], block_ptr->sub_tiles_flags[17], block_ptr->sub_tiles_flags[18], block_ptr->sub_tiles_flags[19] ); fprintf(out, "floor_flag3 = %02X %02X %02X %02X %02X\n", block_ptr->sub_tiles_flags[10], block_ptr->sub_tiles_flags[11], block_ptr->sub_tiles_flags[12], block_ptr->sub_tiles_flags[13], block_ptr->sub_tiles_flags[14] ); fprintf(out, "floor_flag4 = %02X %02X %02X %02X %02X\n", block_ptr->sub_tiles_flags[5], block_ptr->sub_tiles_flags[6], block_ptr->sub_tiles_flags[7], block_ptr->sub_tiles_flags[8], block_ptr->sub_tiles_flags[9] ); fprintf(out, "floor_flag5 = %02X %02X %02X %02X %02X\n", block_ptr->sub_tiles_flags[0], block_ptr->sub_tiles_flags[1], block_ptr->sub_tiles_flags[2], block_ptr->sub_tiles_flags[3], block_ptr->sub_tiles_flags[4] ); fprintf(out, "\n"); } } for (i=0; i<PT_MAX; i++) { if (pcx[i].w > 0) { if ((i == PT_FA) || (i == PT_FS)) { if (pcx[i].w > 800) { pcx[i].h = 80 * (1 + pcx[i].w / 800); pcx[i].w = 800; } } pcxbmp = create_bitmap(pcx[i].w, pcx[i].h); clear(pcxbmp); if (pcxbmp != NULL) { for (b=0; b<glb_block_number; b++) { block_ptr = glb_block + b; if (block_ptr->pcx_n == i) { if (is_floor(block_ptr->f)) draw_block(pcxbmp, block_ptr->pcx_x, block_ptr->pcx_y, b); else { if (is_wall_up(block_ptr->f)) draw_block(pcxbmp, block_ptr->pcx_x, pcx[i].h, b); else draw_block(pcxbmp, block_ptr->pcx_x, 96, b); } } } } sprintf(pcxfilename, "%s-%s.pcx", strtmp, pcx[i].name); printf("saving %s\n", pcxfilename); save_pcx(pcxfilename, pcxbmp, & the_pal); destroy_bitmap(pcxbmp); } } fclose(out); // end printf("done\n"); return 0; }