Go Back   AC3D Forums > General > AC3D Suggestions
Register FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Display Modes
Old 25th January 2022, 06:31 AM   #1
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,565
Default Re: Metasequoia (.mqo) export?

Wow! Most impressive. I think an AC3D plugin that exports the format you want would probably be less complicated.

Here is the main code for a simple exporter.It would be easy to transform coordinates, add texture info, etc.

Code:
static void sv_output_triangle(FILE *f, List *vertices, Surface *s)
{
SVertex *p1, *p2, *p3;
int col;
int id1, id2, id3; 

    // get SVertexes for this triangle
    // SVertex contains vertex pointer, texture cordinates and the normal

    p1 = (SVertex *)(s->vertlist->data);
    p2 = (SVertex *)(s->vertlist->next->data);
    p3 = (SVertex *)(s->vertlist->next->next->data);

    // get int positions of each vertex within the main object list
    id1 = list_index(vertices, p1->v);
    id2 = list_index(vertices, p2->v);
    id3 = list_index(vertices, p3->v);

    fprintf(f, "%d %d %d ", id1, id2, id3); 

    sv_output_col(f, s->col);
}

static void sv_output_surfaces(FILE *f, List *vertices, List *triangs)
{
    /** go through the triangle list and output each **/
    for (List *p = triangs; p != NULL; p = p->next)
        {
        Surface *s = (Surface *)p->data;
        sv_output_triangle(f, vertices, s);
        }
}


static void sv_output_object(FILE *f, ACObject *ob)
{
int numvert, numsurf, numkids;
List *vertices, *surfaces, *kids;
List *p;

    printf("outputing %s\n", ac_object_get_name(ob));

    ac_object_get_contents(ob, &numvert, &numsurf, &numkids,
        &vertices, &surfaces, &kids); 

    // we are only interested in triangles, so we a list of triangulated surfaces
    List *triangs = ac_object_get_triangle_surfaces(ob); // get list of triangles (ignores lines/polyline surfaces)

    int numtri = list_count(triangs);

    if (numtri > 0)
        {
        fprintf(f, "%d\n", numvert); // output number of vertices
        for (p = vertices; p != NULL; p = p->next) // output each vertex
            {
            Vertex *v = (Vertex *)p->data;

            fprintf(f, "%f %f %f\n", v->x, v->y, v->z);
            }
    
        fprintf(f, "%d\n", numtri); /** output the number of triangles **/
        sv_output_surfaces(f, vertices, triangs); // output number of surfaces and each surface
        }

    ac_surfacelist_free(&triangs); // important - free the surfaces (and list) created from ac_object_get_triangle_surfaces

    for (p = kids; p != NULL; p = p->next) // output any children objects
        sv_output_object(f, (ACObject *)p->data);
}
Andy is offline   Reply With Quote
Old 25th January 2022, 09:21 AM   #2
Tomkat
Member
Expert member
 
Join Date: Nov 2010
Posts: 79
Default Re: Metasequoia (.mqo) export?

Thank you very much! I will play around with that code when I get home!

Last edited by Tomkat; 25th January 2022 at 09:37 AM.
Tomkat is offline   Reply With Quote
Old 25th January 2022, 10:09 AM   #3
Tomkat
Member
Expert member
 
Join Date: Nov 2010
Posts: 79
Default Re: Metasequoia (.mqo) export?

Forgive me but... can you point me in the right direction?
Do I save this as a .pcl file, and put it in the plugins directory?
Or, is this a different type of code?
Tomkat is offline   Reply With Quote
Old 25th January 2022, 11:37 AM   #4
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,565
Default Re: Metasequoia (.mqo) export?

Sorry, it's a bit more complicated. It's C code and not a complete plugin. You need to know how to compile it.



I can send you the full plugin code and the SDK if you send me an email.
Andy is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 06:13 PM.


AC3D Forum
(C) Inivis Limited 2020