forked from mirror/openmw-tes3mp
spherical mapping
This commit is contained in:
parent
4761a3d98b
commit
5f36518181
1 changed files with 12 additions and 1 deletions
|
@ -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…
Reference in a new issue