Text archives Help
- From: vpegorar@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1362 - in branches/fire: Core/Math Core/Util Model/Materials scenes
- Date: Mon, 30 Apr 2007 15:43:12 -0600 (MDT)
Author: vpegorar
Date: Mon Apr 30 15:43:03 2007
New Revision: 1362
Modified:
branches/fire/Core/Math/Physics.cc
branches/fire/Core/Math/Physics.h
branches/fire/Core/Util/ColorMap.cc
branches/fire/Model/Materials/InhomogeneousParticipatingMedium.cc
branches/fire/Model/Materials/InhomogeneousParticipatingMedium.h
branches/fire/scenes/primtest.cc
Log:
Just cleaning up a bit
Modified: branches/fire/Core/Math/Physics.cc
==============================================================================
--- branches/fire/Core/Math/Physics.cc (original)
+++ branches/fire/Core/Math/Physics.cc Mon Apr 30 15:43:03 2007
@@ -25,132 +25,62 @@
//
--------------------------------------------------------------------------------------
-// --- Compute a color chosen from the rainbow colors
-// --- depending on the value t provided between 0 (purple) and 1 (red)
-// --- The RGBA graphs are defined as below :
-// --- _
-// --- Red : \__/
-// --- __
-// --- Green : _/ \
-// --- __
-// --- Blue : \__
-// --- ____
-// --- Alpha : /
+// -- Compute a color chosen from the visible color spectrum
+// -- depending on the value t provided between 0 (purple) and 1 (red)
+// -- The RGB graphs are defined as below :
+// -- __
+// -- Red : \__/
+// -- __
+// -- Green : _/ \_
+// -- __
+// -- Blue : \__/
//
--------------------------------------------------------------------------------------
-void RainbowColors(float t, float color[4], float * expScale)
+void RainbowColors(float t, float color[3], bool cyclic, bool sinVSlinear)
{
- if (t < 0.2f) color[0] = (0.2f - t) / 0.2f;
- else if (t < 0.6f) color[0] = 0.0f;
- else if (t < 0.8f) color[0] = (t - 0.6f) / 0.2f;
- else color[0] = 1.0f;
+ t *= cyclic ? 6.0 : 5.0;
- if (t < 0.2f) color[1] = 0.0f;
- else if (t < 0.4f) color[1] = (t - 0.2f) / 0.2f;
- else if (t < 0.8f) color[1] = 1.0f;
- else color[1] = (1.0f - t) / 0.2f;
-
- if (t < 0.4f) color[2] = 1.0f;
- else if (t < 0.6f) color[2] = (0.6f - t) / 0.2f;
- else color[2] = 0.0f;
-
- if (expScale) color[3] = 1.0f - expf(-t * (*expScale));
- else color[3] = t;
-}
-
-
-//
--------------------------------------------------------------------------------------
-// -- Return the compressibility
-// -- temperature : Kelvin
-// -- pressure : Pascal
-// -- waterVaporMolarFraction : [0-1]
-//
--------------------------------------------------------------------------------------
-double Compressibility(double temperature, double pressure, double
waterVaporMolarFraction)
-{
- double a0, a1, a2, b0, b1, c0, c1, d, e, z, pt, tC;
-
- a0 = 1.58123e-6;
- a1 = -2.9331e-8;
- a2 = 1.1043e-10;
- b0 = 5.707e-6;
- b1 = -2.051e-8;
- c0 = 1.9898e-4;
- c1 = -2.376e-6;
- d = 1.83e-11;
- e = -0.765e-8;
-
- pt = pressure / temperature;
- tC = temperature - 273.15; // Temperature in Celcius
-
- z = 1.0 + pt * (pt * (d +
e*waterVaporMolarFraction*waterVaporMolarFraction)
- - (a0 + (a1 + a2*tC)*tC + ((b0 +
b1*tC) + (c0 + c1*tC)*waterVaporMolarFraction) * waterVaporMolarFraction));
-
- return z;
-}
-
-
-//
--------------------------------------------------------------------------------------
-// -- Compute the dryAirComponent and waterVaporComponent of the density
-// -- temperature : Kelvin
-// -- pressure : Pascal
-// -- waterVaporMolarFraction : [0-1]
-// -- co2ppm : parts per million
-//
--------------------------------------------------------------------------------------
-void Density(double temperature, double pressure, double
waterVaporMolarFraction, double co2ppm, double * dryAirComponent, double *
waterVaporComponent)
-{
- double pzrt, Ma, Mw, z;
-
- Mw = 0.018015;
// Molar mass of water vapor
- Ma = 0.0289635 + 12.011e-9 * (co2ppm - 400.0); // Molar mass of dry
air containing co2 ppm
-
- z = Compressibility(temperature, pressure, waterVaporMolarFraction);
-
- pzrt = pressure / (z * GASCONSTANT * temperature);
-
- if (dryAirComponent)
- *dryAirComponent = pzrt * Ma * (1.0 -
waterVaporMolarFraction);
-
- if (waterVaporComponent)
- *waterVaporComponent = pzrt * Mw * (
waterVaporMolarFraction);
-}
-
-
-//
--------------------------------------------------------------------------------------
-// -- Return the refractive index of air for the given parameters
-// -- temperature : Kelvin
-// -- pressure : Pascal
-// -- relativeHumidity : [0-1]
-// -- co2ppm : parts per million
-// -- wavelength : nanometer
-//
--------------------------------------------------------------------------------------
-double AirRefractiveIndex(double temperature, double pressure, double
relativeHumidity, double co2ppm, double wavelength)
-{
- // Saturation vapor pressure of water vapor in air
- double svp = exp((1.2378847e-5*temperature -
1.9121316e-2)*temperature + 33.93711047 - 6.3431645e3/temperature);
-
- // Enhancement factor of water vapor in air
- double f, tC = temperature - 273.15;
- f = 1.00062 + 3.14e-8*pressure + 5.6e-7*tC*tC;
-
- // Molar fraction of water vapor
- double xw = relativeHumidity * f * svp / pressure;
-
- double paxs, pws, pa, pw;
- Density( 288.15, 101325.0, 0.0, co2ppm, &paxs, NULL); //
Density of standard dry air
- Density( 293.15, 1333.0, 1.0, co2ppm, NULL, &pws); //
Density of standard water vapor
- Density(temperature, pressure, xw, co2ppm, &pa, &pw); //
Density of moist air
-
- double waveNumber, waveNumber2;
- waveNumber = 1000.0 / wavelength; // nanometer to micrometer
- waveNumber2 = waveNumber * waveNumber;
-
- // Refractivity of standard air (15 C, 101325 Pascal, 0% humidity,
450 ppm of CO2)
- double nas1 = (5792105.0 / (238.0185 - waveNumber2) + 167917.0 /
(57.362 - waveNumber2)) * 1.0e-8;
-
- // Refractivity of standard air with co2 ppm
- double naxs1 = nas1 * (1.0 + 0.534e-6 * (co2ppm - 450.0));
-
- // Refractivity of standard water vapor (20 C, 1333 Pascal, 100%
humidity)
- double nws1 = 1.022e-8 * (295.235 + (2.6422 - (0.03238 +
0.004028*waveNumber2) * waveNumber2) * waveNumber2);
-
- return 1.0 + naxs1 * pa / paxs + nws1 * pw / pws;
+ if (t < 1.0)
+ {
+ color[0] = 1.0 - t;
+ color[1] = 0.0;
+ color[2] = 1.0;
+ }
+ else if (t < 2.0)
+ {
+ color[0] = 0.0;
+ color[1] = t - 1.0;
+ color[2] = 1.0;
+ }
+ else if (t < 3.0)
+ {
+ color[0] = 0.0;
+ color[1] = 1.0;
+ color[2] = 3.0 - t;
+ }
+ else if (t < 4.0)
+ {
+ color[0] = t - 3.0;
+ color[1] = 1.0;
+ color[2] = 0.0;
+ }
+ else if (t < 5.0)
+ {
+ color[0] = 1.0;
+ color[1] = 5.0 - t;
+ color[2] = 0.0;
+ }
+ else
+ {
+ color[0] = 1.0;
+ color[1] = 0.0;
+ color[2] = t - 5.0;
+ }
+
+ if (sinVSlinear)
+ {
+ float halfPI = M_PI * 0.5;
+ color[0] = sinf(color[0] * halfPI);
+ color[1] = sinf(color[1] * halfPI);
+ color[2] = sinf(color[2] * halfPI);
+ }
}
Modified: branches/fire/Core/Math/Physics.h
==============================================================================
--- branches/fire/Core/Math/Physics.h (original)
+++ branches/fire/Core/Math/Physics.h Mon Apr 30 15:43:03 2007
@@ -7,12 +7,8 @@
#define PLANCKSCONSTANT 6.62606876e-34
#define SPEEDOFLIGHTINVACUUM 299792458.0
#define BOLTZMANNSCONSTANT 1.3806503e-23
-#define GASCONSTANT 8.31451
extern void BlackbodyEmission(double temperature, double
refractiveIndex, float spectrum[FULL_SPECTRUM_SIZE]);
-extern void RainbowColors(float t, float color[4], float *
expScale = NULL);
-extern double Compressibility(double temperature, double pressure, double
waterVaporMolarFraction);
-extern void Density(double temperature, double pressure, double
waterVaporMolarFraction, double co2ppm, double * dryAirComponent, double *
waterVaporComponent);
-extern double AirRefractiveIndex(double temperature, double pressure,
double relativeHumidity, double co2ppm, double wavelength);
+extern void RainbowColors(float t, float color[3], bool cyclic,
bool sinVSlinear = true);
#endif
Modified: branches/fire/Core/Util/ColorMap.cc
==============================================================================
--- branches/fire/Core/Util/ColorMap.cc (original)
+++ branches/fire/Core/Util/ColorMap.cc Mon Apr 30 15:43:03 2007
@@ -35,14 +35,14 @@
if (mode == RAINBOW_COLORS)
{
- float color[4];
- RainbowColors(ratio, color);
+ float color[3];
+ RainbowColors(ratio, color, false, true);
d.color = Color(RGB(color[0], color[1], color[2]));
}
else if (mode == BLACK_BODY_RADIATION)
{
float spectrum[FULL_SPECTRUM_SIZE], x, y, z, r, g, b;
- BlackbodyEmission((double)d.value,
AirRefractiveIndex((double)d.value, 101325.0, 0.0, 450.0, 600.0), spectrum);
+ BlackbodyEmission((double)d.value, 1.0, spectrum);
SpectrumToXYZ(spectrum, true, &x, &y, &z);
XYZtoRGB(x, y, z, &r, &g, &b);
d.color = Color(RGB(r, g, b));
Modified: branches/fire/Model/Materials/InhomogeneousParticipatingMedium.cc
==============================================================================
--- branches/fire/Model/Materials/InhomogeneousParticipatingMedium.cc
(original)
+++ branches/fire/Model/Materials/InhomogeneousParticipatingMedium.cc Mon
Apr 30 15:43:03 2007
@@ -1,7 +1,6 @@
#include <math.h>
#include <Model/Materials/InhomogeneousParticipatingMedium.h>
-#include <Model/Readers/VolumeReader.h>
#include <Core/Color/Colorimetry.h>
#include <Interface/Scene.h>
#include <Interface/Renderer.h>
@@ -16,46 +15,25 @@
//
--------------------------------------------------------------------------------------
// --- Constructor
//
--------------------------------------------------------------------------------------
-InhomogeneousParticipatingMedium::InhomogeneousParticipatingMedium( const
char * absorptionCoefficientFileName,
-
const char *
emittedLightFileName,
-
ColorMap *
emittedLightColorMap,
-
const char *
refractiveIndexFileName,
+InhomogeneousParticipatingMedium::InhomogeneousParticipatingMedium(
Array3<float> * absorptionCoefficient,
+
Array3<float> *
emittedLight,
+
ColorMap *
emittedLightColorMap,
+
Array3<float> *
refractiveIndex,
const Point &
minBound, const Point & maxBound,
double
cellStepSize, double metersPerUnit,
float
adaptationLevelScale)
{
- m_DefaultVolume = NULL;
-
- if (absorptionCoefficientFileName)
- {
- m_AbsorptionCoefficient = new Array3<float>();
- ReadVolumeFile(absorptionCoefficientFileName,
*m_AbsorptionCoefficient);
- m_DefaultVolume = m_AbsorptionCoefficient;
- }
- else
- m_AbsorptionCoefficient = NULL;
-
- if (emittedLightFileName)
- {
- m_EmittedLight = new Array3<float>();
- ReadVolumeFile(emittedLightFileName, *m_EmittedLight);
- m_DefaultVolume = m_EmittedLight;
- }
- else
- m_EmittedLight = NULL;
+ m_AbsorptionCoefficient = absorptionCoefficient;
+ m_EmittedLight = emittedLight;
+ m_EmittedLightColorMap = m_EmittedLight ? emittedLightColorMap : NULL;
+ m_RefractiveIndex = refractiveIndex;
+ if (m_AbsorptionCoefficient) m_DefaultVolume =
m_AbsorptionCoefficient;
+ else if (m_EmittedLight) m_DefaultVolume =
m_EmittedLight;
#ifndef DISABLE_REFRACTION
- if (refractiveIndexFileName)
- {
- m_RefractiveIndex = new Array3<float>();
- ReadVolumeFile(refractiveIndexFileName, *m_RefractiveIndex);
- m_DefaultVolume = m_RefractiveIndex;
- }
- else
+ else if (m_RefractiveIndex) m_DefaultVolume =
m_RefractiveIndex;
#endif
- m_RefractiveIndex = NULL;
-
- if (!m_DefaultVolume)
+ else
{
fprintf(stderr, "Error :
InhomogeneousParticipatingMedium::InhomogeneousParticipatingMedium() : no
volume provided\n");
exit(0);
@@ -79,26 +57,9 @@
m_WorldStepSize = cellStepSize * m_CellSize.length() / sqrt(3.0);
m_MetersPerUnit = metersPerUnit;
-
- if (m_EmittedLight)
- {
- if (emittedLightColorMap)
- m_EmittedLightColorMap = emittedLightColorMap;
- else
- {
- float min, max;
- m_EmittedLight->getMinMax(&min, &max);
- m_EmittedLightColorMap = new ColorMap(RAINBOW_COLORS,
min, max);
- }
- if (adaptationLevelScale > 0.0f) m_AdaptationLevelLMS
= adaptationLevelScale * AverageLMS(*m_EmittedLight, *m_EmittedLightColorMap)
* (float)m_MetersPerUnit;
- else
m_AdaptationLevelLMS = -1.0f;
- }
- else
- {
- m_EmittedLightColorMap = NULL;
- m_AdaptationLevelLMS = -1.0f;
- }
+ if (adaptationLevelScale > 0.0f) m_AdaptationLevelLMS =
adaptationLevelScale * AverageLMS(*m_EmittedLight, *m_EmittedLightColorMap) *
(float)m_MetersPerUnit;
+ else
m_AdaptationLevelLMS = -1.0f;
}
Modified: branches/fire/Model/Materials/InhomogeneousParticipatingMedium.h
==============================================================================
--- branches/fire/Model/Materials/InhomogeneousParticipatingMedium.h
(original)
+++ branches/fire/Model/Materials/InhomogeneousParticipatingMedium.h Mon
Apr 30 15:43:03 2007
@@ -28,10 +28,10 @@
public:
-
InhomogeneousParticipatingMedium( const char *
absorptionCoefficientFileName,
-
const char * emittedLightFileName,
-
ColorMap * emittedLightColorMap,
-
const char *
refractiveIndexFileName,
+
InhomogeneousParticipatingMedium( Array3<float> * absorptionCoefficient,
+
Array3<float> * emittedLight,
+
ColorMap *
emittedLightColorMap,
+
Array3<float> * refractiveIndex,
const Point & minBound, const Point
& maxBound,
double cellStepSize, double
metersPerUnit,
float adaptationLevelScale = -1.0f);
Modified: branches/fire/scenes/primtest.cc
==============================================================================
--- branches/fire/scenes/primtest.cc (original)
+++ branches/fire/scenes/primtest.cc Mon Apr 30 15:43:03 2007
@@ -36,6 +36,7 @@
#include <Model/Textures/CheckerTexture.h>
#include <Model/Textures/MarbleTexture.h>
#include <Model/Readers/PlyReader.h>
+#include <Model/Readers/VolumeReader.h>
#include <Model/Textures/WoodTexture.h>
#include <Model/Textures/OakTexture.h>
#include <Core/Math/MinMax.h>
@@ -257,12 +258,17 @@
prim->setTexCoordMapper( mapr );
group->add(prim);
} else if (primtype == "volume") {
- char * abso = "../Data/heptane/abskgIN_M00_0450.nrrd";
- char * temp = "../Data/heptane/tempIN_M00_0450.nrrd";
- char * refr = NULL;//"../Data/heptane/refrIN_M00_0450_100X.nrrd";
+ Array3<float> * absorptionCoefficient = new Array3<float>();
ReadVolumeFile("../Data/heptane/abskgIN_M00_0450.nrrd",
*absorptionCoefficient);
+ Array3<float> * emittedLight = new Array3<float>();
ReadVolumeFile("../Data/heptane/tempIN_M00_0450.nrrd", *emittedLight);
+ Array3<float> * refractiveIndex = 0;//new Array3<float>();
ReadVolumeFile("../Data/heptane/refrIN_M00_0450_100X.nrrd", *refractiveIndex);
- ColorMap * colorMap = new ColorMap(BLACK_BODY_RADIATION, 298.0f,
2234.0f);
- Material * matIPM = new InhomogeneousParticipatingMedium(abso, temp,
colorMap, refr, Point(-0.205, -0.205, 0.195), Point(0.205, 0.205, 0.605),
1.0, 10.0, 0.3f);
+ bool fireVSrainbow = 1;
+
+ float min, max;
+ emittedLight->getMinMax(&min, &max);
+ ColorMap * colorMap = new ColorMap(fireVSrainbow ?
BLACK_BODY_RADIATION : RAINBOW_COLORS, min, max);
+
+ Material * matIPM = new
InhomogeneousParticipatingMedium(absorptionCoefficient, emittedLight,
colorMap, refractiveIndex, Point(-0.205, -0.205, 0.195), Point(0.205, 0.205,
0.605), 1.0, 10.0, fireVSrainbow ? 0.3f : -1.0f);
Primitive * primC = new Cube(matIPM, Point(-0.2, -0.2, 0.2), 0.4,
0.4, 0.4);
group->add(primC);
- [MANTA] r1362 - in branches/fire: Core/Math Core/Util Model/Materials scenes, vpegorar, 04/30/2007
Archive powered by MHonArc 2.6.16.