spherical mapping

0.6.3
Miloslav Číž 7 years ago
parent 4761a3d98b
commit 5f36518181

@ -644,7 +644,7 @@ namespace MWRender
for (int j = 0; j < h; ++j)
for (int i = 0; i < w; ++i)
dest->setColor(getColorByDirection(cylindricalCoords(i / ((float) w), j / ((float) h))),i,j);
dest->setColor(getColorByDirection(sphericalCoords(i / ((float) w), j / ((float) h))),i,j);
}
osg::Vec3d cylindricalCoords(double x, double y)
@ -654,6 +654,17 @@ namespace MWRender
return result;
}
osg::Vec3d sphericalCoords(double x, double y)
{
x = x * 2 * osg::PI;
y = (y - 0.5) * osg::PI;
osg::Vec3 result = osg::Vec3(0.0,cos(y),sin(y));
result = osg::Vec3(cos(x) * result.y(),sin(x) * result.y(),result.z());
return result;
}
osg::Vec4 getColorByDirection(osg::Vec3d d)
{
double x, y;

Loading…
Cancel
Save