code

Started by
2 comments, last by flashlaser 22 years, 5 months ago
I got this code for computing a Oriented Bounding Box from www.magic-software.com. Can someone explain to me whats happening and how to use this function.

void Box2::ComputeVertices (Vector2 akVertex[4]) const
{
    Vector2 akEAxis[2] =
    {
        m_afExtent[0]*m_akAxis[0],
        m_afExtent[1]*m_akAxis[1]
    };

    akVertex[0] = m_kCenter - akEAxis[0] - akEAxis[1];
    akVertex[1] = m_kCenter + akEAxis[0] - akEAxis[1];
    akVertex[2] = m_kCenter + akEAxis[0] + akEAxis[1];
    akVertex[3] = m_kCenter - akEAxis[0] + akEAxis[1];
}
 
The code is called MgcBox2.cpp under 2d core.
Advertisement
Not that i''m a good c++ programmer, but to me it looks like the code takes for vertices and makes a box out of them.
Can you be more specific?
Ok i''ll try... It was two years since i last touched c++ though.

You give the function an array of four vertices "Vector2 akVertex[4]", then the function takes these vertices and arranges them a set distance from the objects (Box2) center.

You MUST pass an array to the function.

This topic is closed to new replies.

Advertisement