Obstacle

This topic contains 3 replies, has 3 voices, and was last updated by  Joe Davis 3 years, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31676

    aicha11
    Member

    Can I detect the obstacle with this sdk for example I want to move a wheelechair in a house and ithere is a wall ,the wheelchair should stop
    thinks for your answer

    #38645

    dgu
    Member

    It s not the goal of the sdk but you can calculate the bouding box collision detection of the meshes and apply a simple translation in the oposite direction 🙂
    the beauty of this sdk is the ease of manipulation of meshes and shaders…..
    for instance :

    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;
    }

    or use a real collision detection engine , there is plenty on the net.

    Kind regards
    david

    #38646

    aicha11
    Member

    I don’t understand
    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;

    m_avBoundingBox refer to what?

    #38647

    Joe Davis
    Member

    Hi,

    As David has mentioned, the aim of the SDK is to provide optimized graphics rendering examples along with the basic building blocks for writing a graphics application (PVRShell & PVRTools). To ensure it’s streamlined for its primary purpose, the SDK does not include collision detection, physics, networking and a variety of other technologies you will most likely need for a production ready application.
    David’s example is a simple mechanism for generating bounding boxes so his application can efficiently test for collisions.

    I’ve used Bullet physics with the SDK before for collision detection & response. Depending on your use case, a simpler framework like Box2D may be more suitable though.

    Regards,
    Joe

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