how to get bounding box

This topic contains 1 reply, has 2 voices, and was last updated by  dgu 3 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #31604

    blamejane
    Member

    Hey guys, hoping someone can help here…

    I’m trying to get the center of a mesh bounding box. I see these functions:

    PVRTBoundingBoxCompute()
    PVRTBoundingBoxComputeInterleaved()

    But I can’t figure out how to call them. That is, I’m using Xcode, objective-c for ios app. Here’s how I call this function in my code:

    CPVRTResourceFile::SetReadPath([readPath UTF8String]);

    Just wondering if I don’t have access to the PVRTBoundingBoxCompute calls?

    Thanks

    Valerie

    #38364

    dgu
    Member

    Hello

    about boundingBox :
    PVRTVec3 vBoundingBoxMin, vBoundingBoxMax;

    // calculate bounding box for mesh 0
    float* pfData = (float*)Mesh.pInterleaved;
    vBoundingBoxMin.x = vBoundingBoxMax.x = pfData[0];
    vBoundingBoxMin.y = vBoundingBoxMax.y = pfData[1];
    vBoundingBoxMin.z = vBoundingBoxMax.z = pfData[2];

    for(unsigned int i = 1; i < Mesh.nNumVertex; ++i)
    {
    pfData = (float*)(((char*)pfData) + Mesh.sVertex.nStride);

    vBoundingBoxMin.x = PVRT_MIN(vBoundingBoxMin.x, pfData[0]);
    vBoundingBoxMin.y = PVRT_MIN(vBoundingBoxMin.y, pfData[1]);
    vBoundingBoxMin.z = PVRT_MIN(vBoundingBoxMin.z, pfData[2]);
    vBoundingBoxMax.x = PVRT_MAX(vBoundingBoxMax.x, pfData[0]);
    vBoundingBoxMax.y = PVRT_MAX(vBoundingBoxMax.y, pfData[1]);
    vBoundingBoxMax.z = PVRT_MAX(vBoundingBoxMax.z, pfData[2]);
    }

    for (int i = 0; i < 8; ++i)
    {
    m_avBoundingBox.x = (i & 1) ? vBoundingBoxMin.x : vBoundingBoxMax.x;
    m_avBoundingBox
    .y = (i & 2) ? vBoundingBoxMin.y : vBoundingBoxMax.y;
    m_avBoundingBox
    .z = (i & 4) ? vBoundingBoxMin.z : vBoundingBoxMax.z;
    m_avBoundingBox
    .w = 1.0f;
    }

    regards
    david

Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.