Hemisphere generation...
Hello,
I just wondered if someone knows of an algorithm to create a hemisphere?
And if anyone knows a place with some nice sky textures?
Guess what I''m coding...
Greets Tobias
Heh same here! I''d also be interested in some Hemisphere code too....nice sky textures would''nt be a bad idea either
Generating the coords for a hemisphere should be quite simple..
Use the XY axis to strike one arc, from 3o''clock to 12o''clock (anti-clockwise), say, every 10 degrees.. Use the resulting X as a new radius..
With this new radius, find all the points around the XZ for a full circle (again pick an angle..)
Hey presto you''ll have X,Y & Z coords for a hemisphere.
You''ll still have to work on the normals, and apply spherical texture mapping though (that I''m afraid I can''t help you with - I''m still learning too!)
If you really need to see a code example of the coord generation routines, just say so..
Cheers
Matt
Check out my project at: www.btinternet.com/~Matthew.Bennett
Use the XY axis to strike one arc, from 3o''clock to 12o''clock (anti-clockwise), say, every 10 degrees.. Use the resulting X as a new radius..
With this new radius, find all the points around the XZ for a full circle (again pick an angle..)
Hey presto you''ll have X,Y & Z coords for a hemisphere.
You''ll still have to work on the normals, and apply spherical texture mapping though (that I''m afraid I can''t help you with - I''m still learning too!)
If you really need to see a code example of the coord generation routines, just say so..
Cheers
Matt
Check out my project at: www.btinternet.com/~Matthew.Bennett
Thanks 3dModelMan,
I stole this routine from Paul Bourke (I think), and
it works fine.
#define PI 3.141592654f
#define TWOPI 6.283185308f
void SphereMap( vec_t x, vec_t y, vec_t z, vec_t radius, vec_t *u, vec_t *v )
{
*v = (vec_t)acos(z/radius) / PI;
if (y >= 0.0f)
*u = (vec_t)acos(x/(radius * (vec_t)sin(PI*(*v)))) / TWOPI;
else
*u = (PI + (vec_t)acos(x/(radius * (vec_t)sin(PI*(*v))))) / (TWOPI*2.0f);
}
Greets Tobias
Edited by - Tobias on 4/10/00 1:10:40 PM
I stole this routine from Paul Bourke (I think), and
it works fine.
#define PI 3.141592654f
#define TWOPI 6.283185308f
void SphereMap( vec_t x, vec_t y, vec_t z, vec_t radius, vec_t *u, vec_t *v )
{
*v = (vec_t)acos(z/radius) / PI;
if (y >= 0.0f)
*u = (vec_t)acos(x/(radius * (vec_t)sin(PI*(*v)))) / TWOPI;
else
*u = (PI + (vec_t)acos(x/(radius * (vec_t)sin(PI*(*v))))) / (TWOPI*2.0f);
}
Greets Tobias
Edited by - Tobias on 4/10/00 1:10:40 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement