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

Reply
 
Thread Tools Display Modes
Old 24th January 2022, 03:59 PM   #11
Tomkat
Member
Expert member
 
Join Date: Nov 2010
Posts: 68
Default Re: Metasequoia (.mqo) export?

If you refer to my original post...

The .mqo format is the CLOSEST format I have seen in terms of the data I need in the layout that I need it.

The vertices (and their coordinates) are grouped and listed in exact order.

The face data is clear, simple and concise and easy to "navigate" with a VBA script for importing the values with excel... but what I REALLY need is the M value for each face M(0), M(1), M(2), etc, as it is a NUMERIC, ordered reference to which texture bmp is mapped to each face.

Last edited by Tomkat; 24th January 2022 at 10:56 PM.
Tomkat is offline   Reply With Quote
Old 24th January 2022, 09:35 PM   #12
Tomkat
Member
Expert member
 
Join Date: Nov 2010
Posts: 68
Default Re: Metasequoia (.mqo) export?

Here's an .mqo file for a fairly simple 3d item.
It tells me EVERYTHING I need to know to create .3di file format...

Quote:
Metasequoia Document
Format Text Ver 1.0

Scene {
pos 0.0000 0.0000 1500.0000
lookat 0.0000 0.0000 0.0000
head -0.5236
pich 0.5236
ortho 0
zoom2 5.0000
amb 0.250 0.250 0.250
}
Material 2 {
"acmat_0" col(1.000000 1.000000 1.000000 1.000000) dif(1.000) amb(0.000) emi(0.250) spc(0.000) power(5.00) tex("CFtop0.bmp")
"acmat_1" col(1.000000 1.000000 1.000000 1.000000) dif(1.000) amb(0.000) emi(0.250) spc(0.000) power(5.00) tex("CFbtm0.bmp")
}
Object "g0" {
depth 0
folding 0
visible 15
locking 0
shading 1
facet 59.5
color 0.898 0.498 0.698
color_type 0
vertex 8 {
-0.000001 5.000000 -5.000000
-0.249999 -5.000000 -5.000000
-0.250001 5.000000 -5.000000
0.000001 -5.000000 -5.000000
0.000001 -5.000000 5.000000
-0.250001 5.000000 5.000000
-0.249999 -5.000000 5.000000
-0.000001 5.000000 5.000000
}
face 12 {
3 V(7 6 5) M(0) UV(0.431204 0.685504 -3.500000 0.587224 0.431204 0.587224)
3 V(7 4 6) M(0) UV(0.431204 0.685504 -3.500000 0.685504 -3.500000 0.587224)
3 V(3 2 1) M(0) UV(4.500000 0.685504 0.568796 0.587224 4.500000 0.587224)
3 V(3 0 2) M(0) UV(4.500000 0.685504 0.568796 0.685504 0.568796 0.587224)
3 V(0 5 2) M(0) UV(4.500000 0.921376 0.568796 0.823096 4.500000 0.823096)
3 V(0 7 5) M(0) UV(4.500000 0.921376 0.568796 0.921376 0.568796 0.823096)
3 V(4 1 6) M(0) UV(0.431204 0.921376 -3.500000 0.823096 0.431204 0.823096)
3 V(4 3 1) M(0) UV(0.431204 0.921376 -3.500000 0.921376 -3.500000 0.823096)
3 V(2 6 1) M(0) UV(2.005460 1.005674 -0.004858 -1.004640 -0.004858 1.005674)
3 V(2 5 6) M(0) UV(2.005460 1.005674 2.005460 -1.004640 -0.004858 -1.004640)
3 V(7 3 4) M(1) UV(2.005460 -1.004640 -0.004858 1.005674 -0.004858 -1.004640)
3 V(7 0 3) M(1) UV(2.005460 -1.004640 2.005460 1.005674 -0.004858 1.005674)
}
}
Eof
The "Material" section gives me a nice index list of each bitmap
M(0) = CFtop0.bmp
M(1) = CFbtm0.bmp
etc

The "Vertex" section also gives me a nice list of each (which I can easily number in Excel), and its X,Y,Z

The "Face" section also gives me a nice, ordered list (which I can number in Excel) and it also tells me...
How may vertices make up the face (3)
WHICH vertices make up each face (7 6 5) etc
The material/bitmap INDEX number M(0), M(1) etc
The UV coordinates for each face

Last edited by Tomkat; 24th January 2022 at 10:06 PM.
Tomkat is offline   Reply With Quote
Old 24th January 2022, 10:01 PM   #13
Tomkat
Member
Expert member
 
Join Date: Nov 2010
Posts: 68
Default Re: Metasequoia (.mqo) export?

I want go into exhaustive detail here but...
The first thing I have to do is convert/transpose vertex values (because 3di doesn't use the exact same coordinate reference - vertical is "Y" in AC3d, mqo, etc, but it's "Z" in 3di file format)



The red block of values at the end is everything converted to hex values that I need to copy/paste/build the file.

Luckily, the .mqo Face values are pretty straightforward to import



BUT... I have to do a LOT of excel calculations to calculate OTHER values that I need for each face, such as the values of the normals, among other things.
This is just Face 0. I have a separate tab/sheet for EACH face.



Again, I have to convert everything to hex values to use them.

So... since you asked and said you were "interested" - there you have it.
What you are looking at, is just a small snippet of YEARS of work to finally create a (clunky) method for converting the values I need.
Tomkat is offline   Reply With Quote
Old 25th January 2022, 06:31 AM   #14
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,486
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   #15
Tomkat
Member
Expert member
 
Join Date: Nov 2010
Posts: 68
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   #16
Tomkat
Member
Expert member
 
Join Date: Nov 2010
Posts: 68
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   #17
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,486
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

Thread Tools
Display Modes

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 03:37 PM.


AC3D Forum
(C) Inivis Limited 2020