6) Are the normals stored with the Z-axis as the up-vector?

7) This is not directly a SDK related question: How are you calculating the center of a model in MED (Edit\Transform Global\Center Model)? --- I wrote for my dll a function for that and I simply sum up the vertex positions and divide by the number of vertices; but the model is still moved around when I hit the "center model" button in MED...

Here is some code:

Code:
DLLFUNC VECTOR* mdl_center (Mdl* m, BOOL centerx, BOOL centery, BOOL centerz)
{
    if (m)
    {
        int n = 0;

        VECTOR sum;
        vec_fill(&sum, 0);

        for (int i = 0; i < mdl_groups(m); i++)
        {
            MdlGroup* g = mdl_group(m, i);
            for (int j = 0; j < mdl_groupvertices(g); j++)
            {
                MdlVertex* v = mdl_groupvertex(g, j);
                vec_add(&sum, mdl_vertexpos(v));

                n++;
            }
        }

        if (n > 0)
        {
            sum.x = _VAR(_FLOAT(sum.x) / (float)n);
            sum.y = _VAR(_FLOAT(sum.y) / (float)n);
            sum.z = _VAR(_FLOAT(sum.z) / (float)n);

            mdl_move(m, centerx ? -_FLOAT(sum.x) : 0,
                        centery ? -_FLOAT(sum.y) : 0,
                        centerz ? -_FLOAT(sum.z) : 0);

            return(vector(sum.x, sum.y, sum.z));
        }
        else
            return(NULL);
    }
    else
        return(NULL);
}



Last edited by HeelX; 02/19/12 19:32.