Positional Spherical Mapping?

BlitzMax Forums/BlitzMax Programming/Positional Spherical Mapping?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Thanks Ant,

I got some C++ code, I think this will do the job. Tell me if I'm wrong.

// determine extents
D3DXVECTOR3 vMin,vMax;
D3DXComputeBoundingBox(pVerts,numVerts,FVF_VERTEX,&vMin,&vMax);

// calculate center
D3DXVECTOR3 vCent;
vCent=(vMax+vMin)*0.5f;

// loop through the vertices
for (i=0;i<numVerts;i++) {

    // calculate normalized offset from center
    D3DXVECTOR3 v;
    v=pVerts->pos-vCent;
    D3DXVec3Normalize(&v,&v);

    // calculate texture coordinates
    pVerts->tu=asinf(v.x)/D3DX_PI+0.5f;
    pVerts->tv=asinf(v.y)/D3DX_PI+0.5f;

    // go to next vertex
    pVerts++;
}