for( int ix=0; ix<m_nPoints; ix++ )
{
// Convert to polar coordinates (1.0, phi, theta)
phi = atan2( m_rgNormal[ix].x, m_rgNormal[ix].z ) + M_PI; // Range 0..2PI
double dist = sqrt( m_rgNormal[ix].x*m_rgNormal[ix].x + m_rgNormal[ix].z*m_rgNormal[ix].z);
theta = atan2( m_rgNormal[ix].y, dist );
// Now convert to u,v
u = 64 * (phi/(2*M_PI));
v = 64 * (theta/M_PI);
// Set the texture coord at that point...
m_rgTextureCoords[ix].Set( u, v );
}
Spherical texture mapping help
Hi,
So I''m trying to manually map a 64x64 texture onto an arbitrary shape using spherical mapping. (Not using OGL/DX)
I''m converting the unit normals (x,y,z) of each vertex in the shape to polar coordinates (1.0,phi,theta).
I''m then trying to map phi and theta back into the texture. Unfortunately I can''t seem to get it right. Can anyone help??
Thanks,
Karen
Here''s some bad code I wrote:
here is example using spherical texture mapping:
http://www.dev-gallery.com/programming/opengl/index.htm
Dave007
dave007@volny.cz
http://www.dev-gallery.com/programming/opengl/index.htm
Dave007
dave007@volny.cz
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement