コード例 #1
0
ファイル: model_dump.c プロジェクト: dfyockey/vulcan
void
model_dump(FILE *out, const char *model_name, const struct model *model)
{
	fprintf(out, "model \"%s\" {\n", model_name);

	mesh_dump(out, model->mesh);

	fprintf(out, "\tvolume {\n");
	bsp_tree_dump(out, model->bsp_tree);
	bounding_sphere_dump(out, &model->bounding_sphere);
	fprintf(out, "\t}\n");

	fprintf(out, "}\n");
}
コード例 #2
0
ファイル: 3dsdump.c プロジェクト: julianlai777/COMP371
int
main(int argc, char **argv) {
    FILE *file;
    Lib3dsFile *f = 0;
    Lib3dsIo io;
    int result;
    int i;

    parse_args(argc, argv);

    file = fopen(filename, "rb");
    if (!file) {
        fprintf(stderr, "***ERROR***\nFile not found: %s\n", filename);
        exit(1);
    }

    f = lib3ds_file_new();

    memset(&io, 0, sizeof(io));
    io.self = file;
    io.seek_func = fileio_seek_func;
    io.tell_func = fileio_tell_func;
    io.read_func = fileio_read_func;
    io.write_func = fileio_write_func;
    io.log_func = fileio_log_func;

    result =  lib3ds_file_read(f, &io);

    fclose(file);

    if (!result) {
        fprintf(stderr, "***ERROR***\nLoading file failed: %s\n", filename);
        exit(1);
    }

    if (flags & LIB3DSDUMP_MATERIALS) {
        printf("Dumping materials:\n");
        for (i = 0; i < f->nmaterials; ++i) material_dump(f->materials[i]);
        printf("\n");
    }
    if (flags & LIB3DSDUMP_TRIMESHES) {
        printf("Dumping meshes:\n");
        for (i = 0; i < f->nmeshes; ++i) mesh_dump(f->meshes[i]);
        printf("\n");
    }
    if (flags & LIB3DSDUMP_INSTANCES) {
        Lib3dsNode *p;
        printf("Dumping instances:\n");
        for (p = f->nodes; p != 0; p = p->next) {
            dump_instances(p, "");
        }
        printf("\n");
    }
    if (flags & LIB3DSDUMP_CAMERAS) {
        printf("Dumping cameras:\n");
        for (i = 0; i < f->ncameras; ++i) camera_dump(f->cameras[i]);
        printf("\n");
    }
    if (flags & LIB3DSDUMP_LIGHTS) {
        printf("Dumping lights:\n");
        for (i = 0; i < f->nlights; ++i) light_dump(f->lights[i]);
        printf("\n");
    }
    if (flags & LIB3DSDUMP_NODES) {
        Lib3dsNode *p;
        printf("Dumping node hierarchy:\n");
        for (p = f->nodes; p != 0; p = p->next) {
            node_dump(p, 1);
        }
        printf("\n");
    }
    if (output) {
        if (!lib3ds_file_save(f, output)) {
            printf("***ERROR**** Writing %s\n", output);
        }
    }

    lib3ds_file_free(f);
    return 0;
}