Text archives Help
- From: boulos@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1802 - in trunk: Image Model/Backgrounds
- Date: Fri, 2 Nov 2007 13:23:03 -0600 (MDT)
Author: boulos
Date: Fri Nov 2 13:23:01 2007
New Revision: 1802
Modified:
trunk/Image/RGBEFile.cc
trunk/Model/Backgrounds/EnvMapBackground.cc
trunk/Model/Backgrounds/EnvMapBackground.h
Log:
Image/RGBEFile.cc
Adding an output error for writeRGBE as Bigler suggested.
Model/Backgrounds/EnvMapBackground.cc
Model/Backgrounds/EnvMapBackground.h
Fleshing out an implementation of LatLonMapping.
Modified: trunk/Image/RGBEFile.cc
==============================================================================
--- trunk/Image/RGBEFile.cc (original)
+++ trunk/Image/RGBEFile.cc Fri Nov 2 13:23:01 2007
@@ -4,6 +4,7 @@
#include <Image/Pixel.h>
#include <Image/SimpleImage.h>
#include <SCIRun/Core/Exceptions/InternalError.h>
+#include <Core/Exceptions/OutputError.h>
#include <stdio.h>
#include <stdlib.h>
@@ -66,4 +67,9 @@
}
delete[] image;
return result;
+}
+
+void Manta::writeRGBE(Image const *image, std::string const &filename,
+ int which) {
+ throw OutputError( "RGBE writing not yet supported.");
}
Modified: trunk/Model/Backgrounds/EnvMapBackground.cc
==============================================================================
--- trunk/Model/Backgrounds/EnvMapBackground.cc (original)
+++ trunk/Model/Backgrounds/EnvMapBackground.cc Fri Nov 2 13:23:01 2007
@@ -35,7 +35,7 @@
void EnvMapBackground::shade(const RenderContext& context, RayPacket& rays)
const {
switch (map_type) {
case LatLon:
- throw InternalError("LatLon not finished", __FILE__, __LINE__);
+ LatLonMapping(context, rays);
break;
case CylindricalEqualArea:
CylindricalEqualAreaMapping(context, rays);
@@ -59,6 +59,32 @@
for (int i=rays.begin(); i<rays.end(); ++i)
rays.setColor(i, colors.get(i));
+}
+
+void EnvMapBackground::LatLonMapping(const RenderContext& context,
RayPacket& rays) const {
+ rays.normalizeDirections();
+ // In standard "globe" coordinates we have:
+ //
+ // x = cos ( longitude ) * cos (latitude)
+ // y = sin ( longitude ) * cos (latitude)
+ // z = sin ( latitude )
+ //
+ // In relation to standard spherical coordinates, the only
+ // difference is that while longitude = theta, latitude = \pi/2 -
+ // phi. From trig: sin(\pi/2 - phi) = cos(phi)
+ for (int i = rays.begin(); i < rays.end(); i++) {
+ Vector local_dir(Dot(rays.getDirection(i), U),
+ Dot(rays.getDirection(i), V),
+ Dot(rays.getDirection(i), W));
+
+ Real latitude = .5 * M_PI + Asin(local_dir[2]); // [-PI/2, PI/2] + PI/2
-> [0, PI]
+ Real longitude = Atan2(local_dir[1], local_dir[0]);
+ if (longitude < 0) longitude += 2. * M_PI;
+ // longitude is now [0, 2PI), so map this to u
+ Real index_u = longitude * OneOverTwoPi;
+ Real index_v = latitude * OneOverPi;
+ rays.setTexCoords(i, VectorT<Real, 2>(index_u, index_v));
+ }
}
void EnvMapBackground::CylindricalEqualAreaMapping(const RenderContext&
context, RayPacket& rays) const {
Modified: trunk/Model/Backgrounds/EnvMapBackground.h
==============================================================================
--- trunk/Model/Backgrounds/EnvMapBackground.h (original)
+++ trunk/Model/Backgrounds/EnvMapBackground.h Fri Nov 2 13:23:01 2007
@@ -24,6 +24,7 @@
virtual void preprocess(const PreprocessContext& context);
virtual void shade(const RenderContext& context, RayPacket& rays) const;
+ void LatLonMapping(const RenderContext& context, RayPacket& rays) const;
void CylindricalEqualAreaMapping(const RenderContext& context,
RayPacket& rays) const;
void OldBehaviorMapping(const RenderContext& context, RayPacket& rays)
const;
void DebevecMapping(const RenderContext& context, RayPacket& rays) const;
- [Manta] r1802 - in trunk: Image Model/Backgrounds, boulos, 11/02/2007
Archive powered by MHonArc 2.6.16.