Archived

This topic is now archived and is closed to further replies.

flashlaser

code

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites