Text archives Help
- From: brownlee@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r2198 - in trunk: Model/Materials Model/Readers scenes scenes/csafe/python scenes/csafe/src
- Date: Wed, 16 Apr 2008 00:26:58 -0600 (MDT)
Author: brownlee
Date: Wed Apr 16 00:26:55 2008
New Revision: 2198
Added:
trunk/Model/Readers/UDAReader.cc
trunk/Model/Readers/UDAReader.h
Modified:
trunk/Model/Materials/AmbientOcclusion.h
trunk/Model/Materials/Volume.cc
trunk/Model/Materials/Volume.h
trunk/Model/Readers/CMakeLists.txt
trunk/Model/Readers/VolumeNRRD.h
trunk/scenes/csafe/python/Histogram.py
trunk/scenes/csafe/python/SceneInfo.py
trunk/scenes/csafe/python/SceneMenus.py
trunk/scenes/csafe/python/TransferF.py
trunk/scenes/csafe/python/csafe_demo.py
trunk/scenes/csafe/src/CDGridSpheres.cc
trunk/scenes/csafe/src/CDGridSpheres.h
trunk/scenes/csafe/src/CDTest.h
trunk/scenes/volumeTest.cc
Log:
added uda reader, preset transfer functions, abillity to turnonoffsphere,
ambient occlusion, other fixes
Modified: trunk/Model/Materials/AmbientOcclusion.h
==============================================================================
--- trunk/Model/Materials/AmbientOcclusion.h (original)
+++ trunk/Model/Materials/AmbientOcclusion.h Wed Apr 16 00:26:55 2008
@@ -21,7 +21,8 @@
~AmbientOcclusion();
void generateDirections(int num_directions);
-
+ void setCutoffDistance(float dist) { cutoff = dist; }
+ void setNumRays(int num_dirs) { inv_num_directions = 1.0/num_dirs;
generateDirections(num_dirs); }
// generate the directions
void shade(const RenderContext& context, RayPacket& rays) const;
private:
Modified: trunk/Model/Materials/Volume.cc
==============================================================================
--- trunk/Model/Materials/Volume.cc (original)
+++ trunk/Model/Materials/Volume.cc Wed Apr 16 00:26:55 2008
@@ -353,37 +353,10 @@
void RGBAColorMap::scaleAlphas(float t) {
_colorScaled = true;
- cout << "t, oldt: " << t << " " << oldTInc << endl;
// the ratio of values as explained in rescale_alphas
float d2_div_d1 = t/oldTInc;
- // loop over the alpha values and fill in the array
for (int a_index = 0; a_index < int(_slices.size()); a_index++) {
- // the start has already been computed, so you need to figure out
- // the end.
- /*end = (int)(_slices[a_index+1].value * nindex);
- float val = _slices[a_index].color.a;
- float val_inc = (_slices[a_index+1].val - val) / (end - start);
- for (int i = start; i <= end; i++) {
- // cout << "val = "<<val<<", ";
- alpha_stripes[i] = val;
- // apply the alpha scaling.
- //
- // Here we have to be careful with powf. It doesn't like values
- // that equal 0. I tried just comparing val to 1, but that
- // didn't work I'm assuming because of floating point precision
- // problems. I tried comparing 1-val to zero, but that failed
- // for the same reasons. I finally tried comparing to some
- // epsilon. That is what you see below.
- float one_minus_val = 1.0f - val;
- if (one_minus_val >= 1e-6f)
- alpha_transform[i] = 1 - powf(one_minus_val, d2_div_d1);
- else
- alpha_transform[i] = 1;
- // cout <<"alpha_transform[i="<<i<<"] =
"<<alpha_transform[i]<<"\n";
- val += val_inc;
- }
- start = end;*/
float val = _slices[a_index].color.a;
float one_minus_val = 1.0f - val;
if (one_minus_val >= 1e-6f)
Modified: trunk/Model/Materials/Volume.h
==============================================================================
--- trunk/Model/Materials/Volume.h (original)
+++ trunk/Model/Materials/Volume.h Wed Apr 16 00:26:55 2008
@@ -24,15 +24,16 @@
#include <Interface/RayPacket.h>
#include <Interface/SampleGenerator.h>
#include <Interface/Scene.h>
-
+#include <Model/Readers/ParticleNRRD.h>
#include <Model/Materials/OpaqueShadower.h>
-#include <Model/Readers/VolumeNRRD.h>
#include <cassert>
#include <float.h>
+#include <vector>
#include <assert.h>
//#include "SIMD.hxx"
+using namespace std;
namespace Manta
{
@@ -233,7 +234,7 @@
vector<mcT> cellVector_mc; // color hashes
// float cellStepSize, float metersPerUnit);
- Volume(string dataNrrd, RGBAColorMap* colorMap, const Vector&
minBound, const Vector& maxBound, double cellStepSize, double metersPerUnit,
int depth, double forceDataMin = -FLT_MAX, double forceDataMax = -FLT_MAX);
+ Volume(GridArray3<T>* data, RGBAColorMap* colorMap, const Vector&
minBound, const Vector& maxBound, double cellStepSize, double metersPerUnit,
int depth, double forceDataMin = -FLT_MAX, double forceDataMax = -FLT_MAX);
virtual ~Volume();
void getMinMax(double* min, double* max){ *min = _dataMin; *max =
_dataMax; }
@@ -282,13 +283,10 @@
};
template<class T>
- Volume<T>::Volume(string dataNrrd, RGBAColorMap* colorMap, const Vector&
minBound, const Vector& maxBound, double cellStepSize, double metersPerUnit,
int depth, double forceDataMin, double forceDataMax)
+ Volume<T>::Volume(GridArray3<T>* dataNrrd, RGBAColorMap* colorMap, const
Vector& minBound, const Vector& maxBound, double cellStepSize, double
metersPerUnit, int depth, double forceDataMin, double forceDataMax)
:_colorMap(colorMap)
{
- //_data = new GridArray3<double>();
- _data = loadNRRDToGrid<T>(dataNrrd);
- //_emittedLight = new GridArray3<float>();
- //loadNrrd(emittedLightNrrdFile, _emittedLight);
+ _data = dataNrrd;
_minBound = minBound;
_maxBound = maxBound;
@@ -833,9 +831,6 @@
template<class T>
void Volume<T>::shade(const RenderContext & context, RayPacket& rays)
const
{
- bool BITMASK_VERSION = true;
- if (BITMASK_VERSION)
- {
rays.normalizeDirections();
float t_inc = _stepSize;
@@ -1009,449 +1004,8 @@
totals[i] += bgColor*(1.-alphas[i]);
rays.setColor(i, totals[i]);
}
- return;
- }
-
- rays.normalizeDirections();
- float t_inc = _stepSize;
- //t_inc = 0.003;
- Vector diag = (_maxBound - _minBound);
- Vector inv_diag (1.0f/diag.x(), 1.0f/diag.y(), 1.0f/diag.z());
- GridArray3<T>& data = *_data;
- int nx = data.getNx();
- int ny = data.getNy();
- int nz = data.getNz();
- RayPacketData rpData1;
- RayPacket lRays1(rpData1, RayPacket::SquarePacket, rays.begin(),
rays.end(), rays.getDepth()+1,
- RayPacket::NormalizedDirections);
- float tMins[rays.end()];
- float tMaxs[rays.end()];
- float alphas[rays.end()];
- Color totals[rays.end()];
- for(int rayIndex = rays.begin(); rayIndex < rays.end(); rayIndex++)
- {
- lRays1.setRay(rayIndex, Ray(rays.getOrigin(rayIndex)+
rays.getMinT(rayIndex)*rays.getDirection(rayIndex),
rays.getDirection(rayIndex)));
- tMins[rayIndex] = rays.getMinT(rayIndex);
- alphas[rayIndex] = 0;
- }
- lRays1.resetHits();
- context.scene->getObject()->intersect(context, lRays1);
- for(int i = rays.begin(); i < rays.end(); i++)
- {
- tMaxs[i] = lRays1.getMinT(i);
- if (lRays1.wasHit(i))
- tMaxs[i] = lRays1.getMinT(i)+ tMins[i];
- else
- tMaxs[i] = -1;
- totals[i] = Color(RGB(0,0,0));
- }
-
-
- for(int rayIndex = rays.begin(); rayIndex < rays.end(); rayIndex++)
- {
- Ray ray = rays.getRay(rayIndex);
-
- for(float t = tMins[rayIndex]; t < tMaxs[rayIndex]; t+= t_inc)
- {
- if (alphas[rayIndex] < RAY_TERMINATION)
- {
- Vector current_p =
rays.getOrigin(rayIndex)+rays.getDirection(rayIndex)*t-_minBound;
-
////////////////////////////////////////////////////////////
- // interpolate the point
-
- // get the indices and weights for the indicies
- double norm = current_p.x() * inv_diag.x();
- double step = norm * (nx - 1);
- int x_low = Clamp((int)step, 0, nx-2);
- float x_weight_high = step - x_low;
-
- norm = current_p.y() * inv_diag.y();
- step = norm * (ny - 1);
- int y_low = Clamp((int)step, 0, ny-2);
- float y_weight_high = step - y_low;
-
- norm = current_p.z() * inv_diag.z();
- step = norm * (nz - 1);
- int z_low = Clamp((int)step, 0, nz-2);
- float z_weight_high = step - z_low;
-
-
- float a,b,c,d,e,f,g,h;
- a = data(x_low, y_low, z_low);
- b = data(x_low, y_low, z_low+1);
- c = data(x_low, y_low+1, z_low);
- d = data(x_low, y_low+1, z_low+1);
- e = data(x_low+1, y_low, z_low);
- f = data(x_low+1, y_low, z_low+1);
- g = data(x_low+1, y_low+1, z_low);
- h = data(x_low+1, y_low+1, z_low+1);
-
- float lz1, lz2, lz3, lz4, ly1, ly2, value;
- lz1 = a * (1 - z_weight_high) + b * z_weight_high;
- lz2 = c * (1 - z_weight_high) + d * z_weight_high;
- lz3 = e * (1 - z_weight_high) + f * z_weight_high;
- lz4 = g * (1 - z_weight_high) + h * z_weight_high;
-
- ly1 = lz1 * (1 - y_weight_high) + lz2 * y_weight_high;
- ly2 = lz3 * (1 - y_weight_high) + lz4 * y_weight_high;
-
- value = ly1 * (1 - x_weight_high) + ly2 * x_weight_high;
- //nmormalize
- value = (value - _dataMin)*_colorScalar;
- RGBAColor color = _colorMap->GetColor(value);
- float alpha_factor = color.a*(1.0-alphas[rayIndex]);
- if (alpha_factor >0.001)
- {
- //TODO: lighting?
- totals[rayIndex] += color.color*(alpha_factor);
- alphas[rayIndex] += alpha_factor;
- }
- else
- continue;
- }
- }
-
- }
-
- for(int i = rays.begin(); i < rays.end(); i++)
- {
- if (alphas[i] < RAY_TERMINATION)
- {
- Ray ray;
- ray = rays.getRay(i);
- if (lRays1.getHitMaterial(i) == this || tMaxs[i] == -1)
- {
- lRays1.setRay(i, Ray(ray.origin() +
ray.direction()*tMaxs[i], ray.direction()));
- if (tMaxs[i] == -1)
- lRays1.setRay(i,
Ray(ray.origin()+ray.direction()*(tMins[i]+0.0001f), ray.direction()));
- }
- else
- lRays1.setRay(i,
Ray(ray.origin()+ray.direction()*(tMins[i]), ray.direction()));
- }
- }
- bool depth = (rays.getDepth() <
context.scene->getRenderParameters().maxDepth);
- context.sample_generator->setupChildPacket(context, rays, lRays1);
- context.renderer->traceRays(context, lRays1);
- for(int i = rays.begin(); i < rays.end(); i++)
- {
- Color bgColor(RGB(0,0,0));
- if (depth)
- bgColor = lRays1.getColor(i);
- totals[i] += bgColor*(1.-alphas[i]);
- rays.setColor(i, totals[i]);
- }
- return;
-
-
-#ifndef CD_SSE
- for( int rayIndex = rays.begin(); rayIndex < rays.end()-3; rayIndex+=4)
- {
- float minTsF[4];
- float maxTsF[4];
- float currTsF[4];
- float alphas[4] = {0,0,0,0};
-
- Color accumColors[4];
- float accumTransmittances[4];
-
- Vector steps[4];
- Vector latticePositions[4];
- RayPacketData rpData;
- RayPacket lRays(rpData, RayPacket::SquarePacket, 0, 4,
rays.getDepth()+1,
- RayPacket::NormalizedDirections);
-
- for(int i = 0; i < 4; i++)
- {
- Vector temp(_cellSize);
- Ray ray = rays.getRay(rayIndex+i);
- steps[i] = ray.direction()*_stepSize/temp;
- accumColors[i] = Color(RGB(0,0,0));
- accumTransmittances[i] = 1.0f;
- minTsF[i] = rays.getMinT(rayIndex+i);
- currTsF[i] = 0.0f;
- Ray lRay;
- lRay.set(ray.origin() + minTsF[i]*ray.direction(),
ray.direction());
- lRays.setRay(i, lRay);
- }
- lRays.resetHits();
- context.scene->getObject()->intersect(context, lRays);
- for(int i = 0; i < 4; i++)
- {
- if (lRays.wasHit(i))
- maxTsF[i] = lRays.getMinT(i);
- else
- maxTsF[i] = 0.0;
- Vector hitPosition = lRays.getOrigin(i);
- latticePositions[i] = ((hitPosition - _minBound) / _cellSize);
- }
- while (currTsF[0] < maxTsF[0] || currTsF[1] < maxTsF[1] ||
currTsF[2] < maxTsF[2] || currTsF[3] < maxTsF[3])
- {
-
- for(int i = 0; i < 4; i++)
- {
- float hitLatticef[3] = {latticePositions[i].x(),
latticePositions[i].y(), latticePositions[i].z() };
- int hitLattice[3] =
{static_cast<int>(floor(hitLatticef[0])),
static_cast<int>(floor(hitLatticef[1])),
static_cast<int>(floor(hitLatticef[2]))};
- //check bounds
- if (currTsF[i] <= maxTsF[i] && 0 <= hitLattice[0] &&
hitLattice[0] < (int)_data->getNx() - 2 &&
- 0 <= hitLattice[1] && hitLattice[1] <
(int)_data->getNy() - 2 &&
- 0 <= hitLattice[2] && hitLattice[2] <
(int)_data->getNz() - 2 )
- {
- float wx, wy, wz, wx1, wy1, wz1, absCoeff = 0.0;
- Color sourceColor;
- float tIntegration;
-
- wx = hitLatticef[0] - (float)hitLattice[0];
- wy = hitLatticef[1] - (float)hitLattice[1];
- wz = hitLatticef[2] - (float)hitLattice[2];
- wx1 = 1.0f-wx;
- wy1 = 1.0f-wy;
- wz1 = 1.0f-wz;
-
- tIntegration = maxTsF[i]-currTsF[i];
- if (tIntegration > _stepSize)
- tIntegration = _stepSize;
- if (_data)
- absCoeff = wx1 * ( wy1 * ( wz1 *
(*_data)(hitLattice[0] , hitLattice[1] , hitLattice[2] ) +
- wz *
(*_data)(hitLattice[0] , hitLattice[1] , hitLattice[2]+1) ) +
- wy * ( wz1 *
(*_data)(hitLattice[0] , hitLattice[1]+1, hitLattice[2] ) +
- wz *
(*_data)(hitLattice[0] , hitLattice[1]+1, hitLattice[2]+1) ) ) +
- wx * ( wy1 * ( wz1 * (*_data)(hitLattice[0]+1,
hitLattice[1] , hitLattice[2] ) +
- wz * (*_data)(hitLattice[0]+1,
hitLattice[1] , hitLattice[2]+1) ) +
- wy * ( wz1 * (*_data)(hitLattice[0]+1,
hitLattice[1]+1, hitLattice[2] ) +
- wz * (*_data)(hitLattice[0]+1,
hitLattice[1]+1, hitLattice[2]+1) ) ) ;
- else
- absCoeff = 0.0f;
- float val = (absCoeff - _dataMin)/(_dataMax-_dataMin);
- if (val > 1.0)
- cout << "OVER" << val << endl;
- if (val < 0.0)
- cout << "UNDER" << val << " " << absCoeff << endl;
-
- RGBAColor color = _colorMap->GetColor(val);
- sourceColor = color.color;
- float alpha_factor = color.a*(1.0-alphas[i]);
- if (alpha_factor > 0.001)
- accumColors[i] += sourceColor*alpha_factor;
- alphas[i] += alpha_factor;
-
- }
- latticePositions[i] += steps[i];
- currTsF[i] += _stepSize;
- }
- }
- lRays.resetHits();
- context.sample_generator->setupChildPacket(context, rays, lRays1);
- context.renderer->traceRays(context, lRays);
- for(int i = 0; i < 4; i++)
- {
- rays.setColor(rayIndex+i, accumColors[i]);
- //}
- }
- }
-#else
- //SSE
- static sse_t absCoeffNx = set4((int)_data->getNx() - 1);
- static sse_t absCoeffNy = set4((int)_data->getNy() - 1);
- static sse_t absCoeffNz = set4((int)_data->getNz() - 1);
- static sse_t zeros = set4(0);
- static sse_t ones = set4(1);
- static Vector _cellSizeInv(1.0f/_cellSize.x(), 1.0f/_cellSize.y(),
1.0f/_cellSize.z());
- for( int rayIndex = rays.begin(); rayIndex < rays.end()-3; rayIndex+=4)
- {
- Ray rays4[4] = { rays.getRay(rayIndex), rays.getRay(rayIndex+1),
rays.getRay(rayIndex+2), rays.getRay(rayIndex+3) };
- sse_t dir_x = set44(rays4[0].direction().x(),
rays4[1].direction().x(),
- rays4[2].direction().x()
,rays4[3].direction().x());
- sse_t dir_y = set44(rays4[0].direction().y(),
rays4[1].direction().y(),
- rays4[2].direction().y()
,rays4[3].direction().y());
- sse_t dir_z = set44(rays4[0].direction().z(),
rays4[1].direction().z(),
- rays4[2].direction().z()
,rays4[3].direction().z());
-
- sse_t steps_x = set4(_cellSizeInv.x());
- sse_t steps_y = set4(_cellSizeInv.y());
- sse_t steps_z = set4(_cellSizeInv.z());
- sse_t stepSize4 = set4(_stepSize);
- steps_x = mul4(steps_x, dir_x); steps_x = mul4(steps_x, stepSize4);
- steps_y = mul4(steps_y, dir_y); steps_y = mul4(steps_y, stepSize4);
- steps_z = mul4(steps_z, dir_z); steps_z = mul4(steps_z, stepSize4);
-
- float minTsF[4] = {0.1, 0.1, 0.1, 0.1};
- float maxTsF[4] = {0,0,0,0};
- float currTsF[4] = {minTsF[0], minTsF[1], minTsF[2], minTsF[3]};
- float alphas[4] = {0,0,0,0};
- sse_t currTsF4 = set44(minTsF[0], minTsF[1], minTsF[2], minTsF[3]);
-
- Color accumColors[4];
- float accumTransmittances[4];
-
- RayPacketData rpData;
- RayPacket lRays(rpData, RayPacket::SquarePacket, 0, 4,
rays.getDepth()+1, RayPacket::NormalizedDirections);
-
- for(int i = 0; i < 4; i++)
- {
- //cout << steps[i] << endl;
- accumColors[i] = Color(RGB(0,0,0));
- accumTransmittances[i] = 1.0;
- Ray ray = rays.getRay(rayIndex+i);
- minTsF[i] = rays.getMinT(rayIndex+i);
- //currTsF[i] = 0.0f;
- Ray lRay;
- lRay.set(ray.origin() + minTsF[i]*ray.direction(),
ray.direction());
- lRays.setRay(i, lRay);
- }
- sse_t minTsF4 = set44(minTsF[0], minTsF[1], minTsF[2], minTsF[3]);
- lRays.resetHits();
- context.scene->getObject()->intersect(context, lRays);
- sse_t origins_x = set44(lRays.getOrigin(0).x(),
lRays.getOrigin(1).x(), lRays.getOrigin(2).x(), lRays.getOrigin(3).x());
- sse_t origins_y = set44(lRays.getOrigin(0).y(),
lRays.getOrigin(1).y(), lRays.getOrigin(2).y(), lRays.getOrigin(3).y());
- sse_t origins_z = set44(lRays.getOrigin(0).z(),
lRays.getOrigin(1).z(), lRays.getOrigin(2).z(), lRays.getOrigin(3).z());
- sse_t minBound_x = set44(_minBound.x(), _minBound.x(),
_minBound.x(), _minBound.x());
- sse_t minBound_y = set44(_minBound.y(), _minBound.y(),
_minBound.y(), _minBound.y());
- sse_t minBound_z = set44(_minBound.z(), _minBound.z(),
_minBound.z(), _minBound.z());
- sse_t cellSizeInv_x = set44(_cellSizeInv.x(), _cellSizeInv.x(),
_cellSizeInv.x(), _cellSizeInv.x());
- sse_t cellSizeInv_y = set44(_cellSizeInv.y(), _cellSizeInv.y(),
_cellSizeInv.y(), _cellSizeInv.y());
- sse_t cellSizeInv_z = set44(_cellSizeInv.z(), _cellSizeInv.z(),
_cellSizeInv.z(), _cellSizeInv.z());
- for(int i = 0; i < 4; i++)
- {
- if (lRays.wasHit(i))
- maxTsF[i] = lRays.getMinT(i);
- else
- maxTsF[i] = 0.0;
- }
- sse_t maxTsF4 = set44(maxTsF[0], maxTsF[1], maxTsF[2], maxTsF[3]);
- sse_t latticePositions_x = latticePositions_x = sub4(origins_x,
minBound_x);
- latticePositions_x = mul4(latticePositions_x, cellSizeInv_x);
- sse_t latticePositions_y = latticePositions_y = sub4(origins_y,
minBound_y);
- latticePositions_y = mul4(latticePositions_y, cellSizeInv_y);
- sse_t latticePositions_z = latticePositions_z = sub4(origins_z,
minBound_z);
- latticePositions_z = mul4(latticePositions_z, cellSizeInv_z);
- while ((bool)getmask4(cmp4_lt(currTsF4, maxTsF4)))
- {
- sse_union hitLatticef_x; hitLatticef_x.sse =
latticePositions_x;
- sse_union hitLatticef_y; hitLatticef_y.sse =
latticePositions_y;
- sse_union hitLatticef_z; hitLatticef_z.sse =
latticePositions_z;
- int hitLattice_x3[4] = {hitLatticef_x.f[0],
hitLatticef_x.f[1], hitLatticef_x.f[2], hitLatticef_x.f[3]};
- int hitLattice_y3[4] = {hitLatticef_y.f[0],
hitLatticef_y.f[1], hitLatticef_y.f[2], hitLatticef_y.f[3]};
- int hitLattice_z3[4] = {hitLatticef_z.f[0],
hitLatticef_z.f[1], hitLatticef_z.f[2], hitLatticef_z.f[3]};
-
- sse_t hitLattice_x = hitLatticef_x.sse; cast_f2i(hitLattice_x);
- sse_t hitLattice_y = hitLatticef_y.sse; cast_f2i(hitLattice_y);
- sse_t hitLattice_z = hitLatticef_z.sse;
- cast_f2i(hitLattice_z);
-
- sse_t absorptionCoeffs[8];
- float absorptionCoeffsTemp[4][8];
- //CHECK BOUNDS
- //LOAD COEFFS
- float coeffsTemp[4] = {0,0,0,0};
- sse_union bounds;
- bounds.sse = cmp4_le(currTsF4, maxTsF4);
- bounds.sse = and4(bounds.sse, cmp4_le(zeros, hitLattice_x));
- bounds.sse = and4(bounds.sse, cmp4_lt(hitLattice_x,
absCoeffNx));
- bounds.sse = and4(bounds.sse, cmp4_le(zeros, hitLattice_y));
- bounds.sse = and4(bounds.sse, cmp4_lt(hitLattice_y,
absCoeffNy));
- bounds.sse = and4(bounds.sse, cmp4_le(zeros, hitLattice_z));
- bounds.sse = and4(bounds.sse, cmp4_lt(hitLattice_z,
absCoeffNz));
- for(int i = 0; i < 4; i++)
- {
- if (bounds.f[i])
- {
- absorptionCoeffsTemp[i][0] = (*_data)(hitLattice_x3[i]
, hitLattice_y3[i] , hitLattice_z3[i] );
- absorptionCoeffsTemp[i][1] = (*_data)(hitLattice_x3[i]
, hitLattice_y3[i] , hitLattice_z3[i]+1 );
- absorptionCoeffsTemp[i][2] = (*_data)(hitLattice_x3[i]
, hitLattice_y3[i]+1 , hitLattice_z3[i] );
- absorptionCoeffsTemp[i][3] = (*_data)(hitLattice_x3[i]
, hitLattice_y3[i]+1 , hitLattice_z3[i] +1 );
- absorptionCoeffsTemp[i][4] =
(*_data)(hitLattice_x3[i]+1 , hitLattice_y3[i] , hitLattice_z3[i] );
- absorptionCoeffsTemp[i][5] =
(*_data)(hitLattice_x3[i]+1 , hitLattice_y3[i] , hitLattice_z3[i]+1 );
- absorptionCoeffsTemp[i][6] =
(*_data)(hitLattice_x3[i]+1 , hitLattice_y3[i]+1 , hitLattice_z3[i] );
- absorptionCoeffsTemp[i][7] =
(*_data)(hitLattice_x3[i]+1 , hitLattice_y3[i]+1 , hitLattice_z3[i]+1 );
- }
- else
- {
- absorptionCoeffsTemp[i][0] = 0;
- absorptionCoeffsTemp[i][1] = 0;
- absorptionCoeffsTemp[i][2] = 0;
- absorptionCoeffsTemp[i][3] = 0;
- absorptionCoeffsTemp[i][4] = 0;
- absorptionCoeffsTemp[i][5] = 0;
- absorptionCoeffsTemp[i][6] = 0;
- absorptionCoeffsTemp[i][7] = 0;
- }
- }
- for(int i = 0; i <8;i++)
- absorptionCoeffs[i] = set44(absorptionCoeffsTemp[0][i],
absorptionCoeffsTemp[1][i], absorptionCoeffsTemp[2][i],
absorptionCoeffsTemp[3][i]);
- sse_t wxs = sub4(hitLatticef_x.sse, hitLattice_x);
- sse_t wys = sub4(hitLatticef_y.sse, hitLattice_y);
- sse_t wzs = sub4(hitLatticef_z.sse, hitLattice_z);
-
- sse_t wx1s = sub4(ones, wxs);
- sse_t wy1s = sub4(ones, wys);
- sse_t wz1s = sub4(ones, wzs);
-
- sse_t c[15];
- c[0] = mul4(wz1s, absorptionCoeffs[0]);
- c[1] = mul4(wzs, absorptionCoeffs[1]);
- c[2] = add4(c[0], c[1]); c[2] = mul4(c[2], wy1s);
-
- c[3] = mul4(wz1s, absorptionCoeffs[2]);
- c[4] = mul4(wzs, absorptionCoeffs[3]);
- c[5] = add4(c[3], c[4]); c[5] = mul4(c[5], wys);
-
- c[6] = mul4(wz1s, absorptionCoeffs[4]);
- c[7] = mul4(wzs, absorptionCoeffs[5]);
- c[8] = add4(c[6], c[7]); c[8] = mul4(c[8], wy1s);
-
- c[9] = mul4(wz1s, absorptionCoeffs[6]);
- c[10] = mul4(wzs, absorptionCoeffs[7]);
- c[11] = add4(c[9], c[10]); c[11] = mul4(c[11], wys);
-
- c[12] = add4(c[2], c[5]); c[12] = mul4(c[12], wx1s);
- c[13] = add4(c[8], c[11]); c[13] = mul4(c[13], wxs);
- sse_union absCoeffs; absCoeffs.sse =
absorptionCoeffs[0];//add4(c[12], c[13]);
-
-
-
- for(int i = 0; i < 4; i++)
- {
- if (!bounds.f[i])
- continue;
- if (alphas[i] > 0.9f)
- continue;
- if (absCoeffs.f[i] == 1.0) //TODO: FIX THIS CHEAP HACK
THAT SOLVES A BANDING ISSUE!
- continue;
- if (absCoeffs.f[i] == 0) //TODO: also get rid of this
- continue;
- float val = (absCoeffs.f[i] - _dataMin)/(_dataMax -
_dataMin);
- if (val > 1.0)
- cout << "OVER" << val << endl;
- if (val < 0.0)
- cout << "UNDER" << val << " " << absCoeffs.f[i] << endl;
- RGBAColor color = _colorMap->GetColor(val);
- Color sourceColor = color.color;
- float alpha_factor = color.a * (1.0 - alphas[i]);
- if (alpha_factor > 0.001)
- {
- accumColors[i] += sourceColor*alpha_factor;
- }
- alphas[i] += alpha_factor;
- }
-
- currTsF4 = add4(currTsF4, stepSize4);
- latticePositions_x = add4(latticePositions_x, steps_x);
- latticePositions_y = add4(latticePositions_y, steps_y);
- latticePositions_z = add4(latticePositions_z, steps_z);
- }
- lRays.resetHits();
- context.sample_generator->setupChildPacket(context, rays, lRays1);
- context.renderer->traceRays(context, lRays);
- for(int i = 0; i < 4; i++)
- {
- accumColors[i] += lRays.getColor(i)*(1.0 - alphas[i]);
- rays.setColor(rayIndex+i, accumColors[i]);
- }
- }
-
-#endif
- }
+}
template<class T>
void Volume<T>::computeHistogram(int numBuckets, int* histValues)
Modified: trunk/Model/Readers/CMakeLists.txt
==============================================================================
--- trunk/Model/Readers/CMakeLists.txt (original)
+++ trunk/Model/Readers/CMakeLists.txt Wed Apr 16 00:26:55 2008
@@ -7,7 +7,16 @@
Readers/PlyReader.cc
Readers/V3C1.h
Readers/V3C1.cc
+ Readers/UDAReader.h
)
+
+IF (LIBXML2_INCLUDE)
+ SET (Manta_Readers_SRCS ${Manta_Readers_SRCS}
+ Readers/UDAReader.cc
+ )
+ INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE})
+ENDIF (LIBXML2_INCLUDE)
+
# Apple places malloc.h in /usr/include/malloc/malloc.h
IF (APPLE)
Added: trunk/Model/Readers/UDAReader.cc
==============================================================================
--- (empty file)
+++ trunk/Model/Readers/UDAReader.cc Wed Apr 16 00:26:55 2008
@@ -0,0 +1,260 @@
+#include <Model/Readers/UDAReader.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <iostream>
+
+using namespace std;
+using namespace Manta;
+
+void parseTimestepFile(string);
+void parseDataFile(string filename);
+void parseLevel(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep);
+void parsePatch(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep);
+
+string parseXMLString(string st)
+{
+ for (unsigned int i=0;i<st.length();i++)
+ {
+ if (st[i] == '[' || st[i] == ']' || st[i] == ',')
+ st[i] = ' ';
+ }
+ return st;
+}
+
+void UDAReader::ReadUDA(string directory)
+ {
+ string filename;
+ assert(directory.length());
+ if (directory[directory.length()-1] != '/')
+ directory = directory + string("/");
+ filename = directory + string("index.xml");
+ cout << "UDAReader, reading: " << filename << endl;
+ xmlDocPtr doc;
+ xmlNodePtr cur;
+ doc = xmlParseFile(filename.c_str());
+ if (doc == NULL ) {
+ cerr << "Document not parsed successfully. \n";
+ return;
+ }
+ cur = xmlDocGetRootElement(doc);
+ if (cur == NULL) {
+ fprintf(stderr,"empty document\n");
+ xmlFreeDoc(doc);
+ return;
+ }
+ if (xmlStrcmp(cur->name, (const xmlChar *) "Uintah_DataArchive")) {
+ cerr << "document of the wrong type, root node !=
Uintah_specification";
+ xmlFreeDoc(doc);
+ return;
+ }
+ cur = cur->xmlChildrenNode;
+ while (cur != NULL)
+ {
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"timesteps")))
+ {
+ xmlNodePtr t = cur->xmlChildrenNode;
+ while (t != NULL)
+ {
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"timestep")))
+ {
+ parseTimestepFile((const char*)xmlGetProp(t,(const
xmlChar*)"href"));
+ }
+ t = t->next;
+ }
+ }
+ cur = cur->next;
+ }
+ xmlFreeDoc(doc);
+ }
+
+ void parseTimestepFile(string filename)
+ {
+ UDAReader::Timestep timestep;
+ cout << "Parsing Timestep: " << filename << "\n";
+ xmlDocPtr doc;
+ xmlNodePtr cur;
+ doc = xmlParseFile(filename.c_str());
+ if (doc == NULL ) {
+ cerr << "Document not parsed successfully. \n";
+ return;
+ }
+ cur = xmlDocGetRootElement(doc);
+ if (cur == NULL) {
+ fprintf(stderr,"empty document\n");
+ xmlFreeDoc(doc);
+ return;
+ }
+ if (xmlStrcmp(cur->name, (const xmlChar *) "Uintah_timestep")) {
+ cerr << "document of the wrong type, root node !=
Uintah_specification";
+ xmlFreeDoc(doc);
+ return;
+ }
+ cur = cur->xmlChildrenNode;
+ while (cur != NULL)
+ {
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Grid")))
+ {
+ xmlNodePtr t = cur->xmlChildrenNode;
+ while (t != NULL)
+ {
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"Level")))
+ {
+ parseLevel(doc, t, timestep);
+ }
+ t = t->next;
+ }
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Data")))
+ {
+ xmlNodePtr t = cur->xmlChildrenNode;
+ while (t != NULL)
+ {
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"datafile")))
+ {
+ parseDataFile((const char*)xmlGetProp(t,(const
xmlChar*)"href"));
+ }
+ t = t->next;
+ }
+ }
+ cur = cur->next;
+ }
+ xmlFreeDoc(doc);
+ }
+ void parseDataFile(string filename)
+ {
+ xmlDocPtr doc;
+ xmlNodePtr cur;
+ doc = xmlParseFile(filename.c_str());
+ if (doc == NULL ) {
+ cerr << "Document not parsed successfully. \n";
+ return;
+ }
+ cur = xmlDocGetRootElement(doc);
+ if (cur == NULL) {
+ fprintf(stderr,"empty document\n");
+ xmlFreeDoc(doc);
+ return;
+ }
+ if (xmlStrcmp(cur->name, (const xmlChar *) "Uintah_Output")) {
+ cerr << "document of the wrong type, root node !=
Uintah_specification";
+ xmlFreeDoc(doc);
+ return;
+ }
+ cur = cur->xmlChildrenNode;
+ while (cur != NULL)
+ {
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Variable")))
+ {
+ UDAReader::VarInfo v;
+ xmlNodePtr t = cur->xmlChildrenNode;
+ while (t != NULL)
+ {
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"variable")))
+ {
+ v.name = string((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
+ }
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"index")))
+ {
+ stringstream s((const char*)xmlNodeListGetString(doc,
cur->xmlChildrenNode, 1));
+ s >> v.index; }
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"start")))
+ {
+ }
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"end")))
+ {
+ }
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"filename")))
+ {
+ }
+ t = t->next;
+ }
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Data")))
+ {
+ xmlNodePtr t = cur->xmlChildrenNode;
+ while (t != NULL)
+ {
+ if ((!xmlStrcmp(t->name, (const xmlChar*)"datafile")))
+ {
+ parseDataFile((const char*)xmlGetProp(t,(const
xmlChar*)"href"));
+ }
+ t = t->next;
+ }
+ }
+ cur = cur->next;
+ }
+ xmlFreeDoc(doc);
+ }
+
+
+ void parseLevel(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep)
+ {
+ cout << "Parsing Level\n";
+ cur = cur->xmlChildrenNode;
+ while (cur != NULL)
+ {
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"numpatches")))
+ {
+ int numpatches;
+ stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
+ s >> numpatches;
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"cellspacing")))
+ {
+ int x, y, z;
+ stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
+ s >> x >> y >> z;
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Patch")))
+ {
+ parsePatch(doc, cur, timestep);
+ }
+ cur = cur->next;
+ }
+ }
+ void parsePatch(xmlDocPtr doc, xmlNodePtr cur, UDAReader::Timestep&
timestep)
+ {
+ cout << "Parsing Patch\n";
+ UDAReader::Patch patch;
+ cur = cur->xmlChildrenNode;
+ while (cur != NULL)
+ {
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"id")))
+ {
+ stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
+ s >> patch._id;
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"lower")))
+ {
+ stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
+ s >> patch.lower[0] >> patch.lower[1] >> patch.lower[2];
+ timestep.lower[0] = max(patch.lower[0],timestep.lower[0]);
+ timestep.lower[1] = max(patch.lower[1],timestep.lower[1]);
+ timestep.lower[2] = max(patch.lower[2],timestep.lower[2]);
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"upper")))
+ {
+ stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
+ s >> patch.upper[0] >> patch.upper[1] >> patch.upper[2];
+ timestep.upper[0] = max(patch.upper[0],timestep.upper[0]);
+ timestep.upper[1] = max(patch.upper[1],timestep.upper[1]);
+ timestep.upper[2] = max(patch.upper[2],timestep.upper[2]);
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"interiorLowIndex")))
+ {
+ stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
+ s >> patch.lowIndex[0] >> patch.lowIndex[1] >>
patch.lowIndex[2];
+ }
+ if ((!xmlStrcmp(cur->name, (const xmlChar
*)"interiorHighIndex")))
+ {
+ stringstream s(parseXMLString((const
char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)));
+ s >> patch.highIndex[0] >> patch.highIndex[1] >>
patch.highIndex[2];
+ timestep.indices[0] =
max(patch.highIndex[0],timestep.indices[0]);
+ timestep.indices[1] =
max(patch.highIndex[1],timestep.indices[1]);
+ timestep.indices[2] =
max(patch.highIndex[2],timestep.indices[2]);
+ }
+ cur = cur->next;
+ }
+ }
+
+
Added: trunk/Model/Readers/UDAReader.h
==============================================================================
--- (empty file)
+++ trunk/Model/Readers/UDAReader.h Wed Apr 16 00:26:55 2008
@@ -0,0 +1,49 @@
+/*
+ * UDAReaher.h: Parse a subset of UDA XML files to load in volume/sphere
data
+ *
+ * Written by:
+ * Carson Brownlee
+ * Department of Computer Science
+ * University of Utah
+ * April 2008
+ *
+ * Copyright (C) 2008 U of U
+ */
+#ifndef UDAREADER_H
+#define UDAREADER_H
+
+#include <Core/Geometry/Vector.h>
+
+#include <vector>
+#include <string>
+#include <sstream>
+using namespace std;
+
+namespace Manta
+{
+
+class UDAReader
+{
+public:
+ UDAReader() {}
+ void ReadUDA(string directory);
+ struct Timestep
+ {
+ Vector lower, upper, indices;
+ };
+ struct VarInfo
+ {
+ string name;
+ int start, end, index, patchId, type;
+ };
+ struct Patch
+ {
+ int _id;
+ Vector lower, upper, lowIndex, highIndex;
+ };
+private:
+};
+
+}
+
+#endif
\ No newline at end of file
Modified: trunk/Model/Readers/VolumeNRRD.h
==============================================================================
--- trunk/Model/Readers/VolumeNRRD.h (original)
+++ trunk/Model/Readers/VolumeNRRD.h Wed Apr 16 00:26:55 2008
@@ -94,6 +94,7 @@
// if (new_nrrd->type == nrrdTypeULong)
// (*grid)(k,j,i) = ((unsigned
long*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
}
+ nrrdNuke(new_nrrd);
cout << "done\n";
return grid;
}
Modified: trunk/scenes/csafe/python/Histogram.py
==============================================================================
--- trunk/scenes/csafe/python/Histogram.py (original)
+++ trunk/scenes/csafe/python/Histogram.py Wed Apr 16 00:26:55 2008
@@ -156,7 +156,6 @@
self.draggingRight = False
self.cropMin = pos
self.UpdateDMinMax()
- print "clicked"
def OnLeftUp(self, evt):
pos = float(evt.GetPosition().x -
self.paddingW/2.0)/float(self.width)
Modified: trunk/scenes/csafe/python/SceneInfo.py
==============================================================================
--- trunk/scenes/csafe/python/SceneInfo.py (original)
+++ trunk/scenes/csafe/python/SceneInfo.py Wed Apr 16 00:26:55 2008
@@ -22,3 +22,8 @@
self.loop = True
self.repeatLastFrame = 0.0
self.mantaFrame = None
+ self.useAO = False
+ self.aoCutoff = 0.01
+ self.aoNum = 10
+ self.showSpheres = True
+ self.showVolume = True
Modified: trunk/scenes/csafe/python/SceneMenus.py
==============================================================================
--- trunk/scenes/csafe/python/SceneMenus.py (original)
+++ trunk/scenes/csafe/python/SceneMenus.py Wed Apr 16 00:26:55 2008
@@ -6,14 +6,14 @@
import wxManta
from manta import *
from csafe import *
-
+import wx.lib.scrolledpanel as scrolled
class AddRemoveFilesFrame(wx.Frame):
def __init__(self, parent, id, title, scene):
wx.Frame.__init__(self, parent, id, title, None, (700, 700))
self.scene = scene
self.parent = parent;
- panel = wx.Panel(self, -1)
+ panel = scrolled.ScrolledPanel(self,-1, style= wx.TAB_TRAVERSAL)
self.lb1 = wx.ListBox(panel, -1, (0, 0), (600, 200), [],
wx.LB_EXTENDED)
@@ -46,13 +46,12 @@
hSizer2.Add(self.cancelButton, 0, wx.ALL, 3)
sizer.Add(hSizer2, 0, wx.ALL|wx.ALIGN_CENTER, 5)
+ sizer.Layout()
panel.SetSizer(sizer)
-
- selfSizer = wx.BoxSizer()
- selfSizer.Add(panel, 1, wx.EXPAND)
- self.SetSizer(selfSizer)
- self.SetAutoLayout(True)
-
+ panel.SetupScrolling()
+ panel.Refresh()
+ self.Refresh()
+
self.Bind(wx.EVT_BUTTON, self.OnClickOk, self.okButton)
self.Bind(wx.EVT_BUTTON, self.OnClickAdd, self.addButton)
self.Bind(wx.EVT_BUTTON, self.OnClickAdd2, self.addButton2)
@@ -154,10 +153,10 @@
class ScenePropertiesFrame(wx.Frame):
def __init__(self, parent, id, title, scene):
- wx.Frame.__init__(self, parent, id, title, None, (700, 500))
+ wx.Frame.__init__(self, parent, id, title, None, (700, 600))
self.scene = scene
self.parent = parent;
- panel = wx.Panel(self, -1)
+ panel = scrolled.ScrolledPanel(self,-1, style= wx.TAB_TRAVERSAL)
sizer = wx.BoxSizer(wx.VERTICAL)
self.frameText = wx.StaticText(panel,-1, "Go to time: ")
@@ -222,6 +221,14 @@
hSizer10.Add(self.repeatButton, 0, wx.ALL, 3)
hSizer10.Add(self.repeatTcl, 0, wx.ALL, 3)
sizer.Add(hSizer10, 0 , wx.ALL|wx.ALIGN_CENTER,5 )
+
+ self.showSpheresCB = wx.CheckBox(panel, -1, "Show Sphere Data")
+ self.showSpheresCB.SetValue(self.scene.showSpheres)
+ sizer.Add(self.showSpheresCB,0,wx.ALL|wx.ALIGN_CENTER,5)
+
+ self.showVolumeCB = wx.CheckBox(panel, -1, "Show Volume Data")
+ self.showVolumeCB.SetValue(self.scene.showVolume)
+ sizer.Add(self.showVolumeCB,0,wx.ALL|wx.ALIGN_CENTER,5)
hSizer4 = wx.BoxSizer(wx.HORIZONTAL)
self.ridxText = wx.StaticText(panel, -1, "Radius Index (-1 to use one
radius): ")
@@ -231,7 +238,7 @@
sizer.Add(hSizer4,0,wx.ALL|wx.ALIGN_CENTER,5)
hSizer5 = wx.BoxSizer(wx.HORIZONTAL)
- self.radText = wx.StaticText(panel, -1, "default radius: ")
+ self.radText = wx.StaticText(panel, -1, "Default Radius: ")
self.radTcl = wx.TextCtrl(panel,-1,str(scene.radius),size=(125,-1))
hSizer5.Add(self.radText,0,wx.ALL,3)
hSizer5.Add(self.radTcl,0,wx.ALL,3)
@@ -244,21 +251,26 @@
hSizer6.Add(self.cidxTcl,0,wx.ALL,3)
sizer.Add(hSizer6,0,wx.ALL|wx.ALIGN_CENTER,5)
+ aoCtrlTitle = wx.StaticBox(panel, -1, "Ambient Occlusion")
+ aoCtrlSizer = wx.StaticBoxSizer(aoCtrlTitle, wx.VERTICAL)
+ self.aoCB = wx.CheckBox(panel, -1, "Use Ambient Occlusion")
+ self.aoCB.SetValue(self.scene.useAO)
+ aoCtrlSizer.Add(self.aoCB,0,wx.ALL|wx.ALIGN_CENTER,5)
+
hSizer7 = wx.BoxSizer(wx.HORIZONTAL)
- self.npText = wx.StaticText(panel, -1, "Num threads: ")
- numThreads = int(SWIGIFYGetNumWorkers(self.scene.engine))
- self.text = wx.TextCtrl(self, -1, str(numThreads), (30, 50), (60, -1))
- h = self.text.GetSize().height
- w = self.text.GetSize().width + self.text.GetPosition().x + 2
- hSizer7.Add(self.npText, 0, wx.ALL,3)
- hSizer7.Add(self.text,0, wx.ALL, 3)
- self.npSP = wx.SpinButton(panel, -1, (w,50), (h*2/3,h),
wx.SP_VERTICAL)
- self.npSP.SetValue(numThreads)
- #self.npSP.SetValue(1)
- self.npSP.SetRange(1, 100)
- hSizer7.Add(self.npSP,0,wx.ALL,3)
- sizer.Add(hSizer7,0,wx.ALL|wx.ALIGN_CENTER,5)
-
+ self.aoCutoffTcl =
wx.TextCtrl(panel,-1,str(scene.aoCutoff),size=(125,-1))
+ hSizer7.Add(wx.StaticText(panel, -1, "Cutoff Distance: "),0,wx.ALL,3)
+ hSizer7.Add(self.aoCutoffTcl,0,wx.ALL,3)
+ aoCtrlSizer.Add(hSizer7,0,wx.ALL|wx.ALIGN_CENTER,5)
+
+ hSizer8 = wx.BoxSizer(wx.HORIZONTAL)
+ self.aoNumTcl = wx.TextCtrl(panel,-1,str(scene.aoNum),size=(125,-1))
+ hSizer8.Add(wx.StaticText(panel, -1, "Number of Rays: "),0,wx.ALL,3)
+ hSizer8.Add(self.aoNumTcl,0,wx.ALL,3)
+ aoCtrlSizer.Add(hSizer8,0,wx.ALL|wx.ALIGN_CENTER,5)
+
+ sizer.Add(aoCtrlSizer,0,wx.ALL|wx.ALIGN_CENTER, 5)
+
self.okButton = wx.Button(panel, wx.ID_OK)
self.cancelButton = wx.Button(panel, wx.ID_CANCEL)
@@ -269,10 +281,7 @@
panel.SetSizer(sizer)
- selfSizer = wx.BoxSizer()
- selfSizer.Add(panel, 1, wx.EXPAND)
- self.SetSizer(selfSizer)
- self.SetAutoLayout(True)
+ panel.SetupScrolling()
self.Bind(wx.EVT_BUTTON, self.OnClickTime, self.frameButton)
self.Bind(wx.EVT_BUTTON, self.OnClickGoToFrame, self.frameButton2)
@@ -282,9 +291,13 @@
self.Bind(wx.EVT_BUTTON, self.OnClickOK, self.okButton)
self.Bind(wx.EVT_BUTTON, self.OnClickCancel, self.cancelButton)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
- self.Bind(wx.EVT_SPIN, self.OnSpinNP, self.npSP)
self.Bind(wx.EVT_CHECKBOX, self.OnClickLockFrames, self.checkBox)
self.Bind(wx.EVT_CHECKBOX, self.OnClickLoop, self.checkBox2)
+ self.Bind(wx.EVT_CHECKBOX, self.OnClickAO, self.aoCB)
+
+ def OnClickAO(self, evt):
+ self.scene.test.useAO(evt.IsChecked())
+ self.scene.useAO = evt.IsChecked()
def OnClickRepeatLastFrame(self, evt):
self.scene.repeatLastFrame = float(self.repeatTcl.GetValue())
@@ -308,18 +321,13 @@
frame = int(self.frameTcl2.GetValue())
self.scene.test.gotoFrame(frame)
- def OnSpinNP(self, evt):
- self.text.SetValue(str(evt.GetPosition()))
- self.scene.engine.changeNumWorkers(int(evt.GetPosition()))
- print "num worker threads: " +
str(SWIGIFYGetNumWorkers(self.scene.engine))
- self.scene.numThreads = evt.GetPosition()
-
def ApplySettings(self):
self.scene.radius = float(self.radTcl.GetValue())
self.scene.ridx = float(self.ridxTcl.GetValue())
self.scene.cidx = float(self.cidxTcl.GetValue())
- self.scene.numThreads = int(self.text.GetValue())
- self.scene.engine.changeNumWorkers(int(self.text.GetValue()))
+ self.scene.aoCutoff = float(self.aoCutoffTcl.GetValue())
+ self.scene.aoNum = int(float(self.aoNumTcl.GetValue()))
+ self.scene.test.setAOVars(self.scene.aoCutoff, self.scene.aoNum)
print "ridx set to: " + str(self.scene.ridx)
def OnClickOK(self, evt):
Modified: trunk/scenes/csafe/python/TransferF.py
==============================================================================
--- trunk/scenes/csafe/python/TransferF.py (original)
+++ trunk/scenes/csafe/python/TransferF.py Wed Apr 16 00:26:55 2008
@@ -84,20 +84,6 @@
blowuphorribly
self.colors[index] = c
-# if (len(color) == 3):
-# print "setcolor"
-# print self.colors[1][1]
-# self.colors[index][1] = color[0]
-# self.colors[index][2] = color[1]
-# self.colors[index][3] = color[2]
-# self.colors[index][4] = 1.0
-# elif (len(color) == 4):
-# self.colors[index][1] = color[0]
-# self.colors[index][2] = color[1]
-# self.colors[index][3] = color[2]
-# self.colors[index][4] = color[3]
-# else:
-# blowuphorribly
def GetColor(self, pos): #color at position pos, in range [0,1]
@@ -325,7 +311,7 @@
bly = 0.0 + self.height + self.barWidth/2.0 - 2.0 + self.paddingH/2.0
self.lines = []
- for i in range(0, width):
+ for i in range(0, int(width)):
color = self.transferF.GetColor( float(i)/float(width) )
self.lines.append( (color, ( blx + i*self.barWidth, bly, blx +
i*self.barWidth, (bly - height) ) ) )
self.parentC.Refresh()
@@ -400,8 +386,8 @@
dc.SetClippingRegion(self.paddingW/2.0,self.paddingH/2.0
,self.width-1, self.height)
imgWidth = self.backgroundIMG.GetWidth()
imgHeight = self.backgroundIMG.GetHeight()
- for x in range(self.paddingW/2.0 + 1, (self.width ), imgWidth):
- for y in range(self.paddingH/2.0 +2, self.height ,
imgHeight):
+ for x in range(int(self.paddingW/2) + 1, int(self.width ),
int(imgWidth)):
+ for y in range(int(self.paddingH/2.0) +2, int(self.height) ,
int(imgHeight)):
dc.DrawBitmap(self.backgroundIMG,x,y, True)
#dc.SetClippingRegion(0-self.paddingW/2.0,0-self.paddingH/2.0,originalSize.width,
originalSize.height)
try:
@@ -435,7 +421,7 @@
dc.DrawRectangle(x,y - color[3]*self.height + recWidth/2.0,
recWidth, recWidth)
class TransferFGroup(wx.Panel):
- def __init__(self, parent, width, height, transferF, title):
+ def __init__(self, parent, width, height, transferF, title, scene):
self.parentC = parent
self.height = height
self.width = width
@@ -447,6 +433,7 @@
box1 = self.box1 = wx.StaticBoxSizer( self.box1_title, wx.VERTICAL )
self.gbs = gbs = wx.GridBagSizer(5,5)
self.sizer = box1
+ self.scene = scene
gbs.Add(self.transferFPanel,(0, 0), (5, 2) )
@@ -456,9 +443,11 @@
self.newColorB = wx.BitmapButton(self, -1, bmpNew, (0,0),
style=wx.NO_BORDER)
self.delColorB = wx.BitmapButton(self, -1, bmpDel, (0,0),
style=wx.NO_BORDER)
self.modifyColorB = wx.BitmapButton(self, -1, bmpMod, (0,0),
style=wx.NO_BORDER)
+ self.presetsB = wx.BitmapButton(self, -1, bmpMod, (0,0),
style=wx.NO_BORDER)
gbs.Add( self.newColorB, (0, 2) )
gbs.Add( self.delColorB, (1, 2) )
gbs.Add( self.modifyColorB, (2, 2) )
+ gbs.Add( self.presetsB, (3,2) )
gbs.Layout()
@@ -473,6 +462,45 @@
self.Bind(wx.EVT_BUTTON, self.OnClickNew, self.newColorB)
self.Bind(wx.EVT_BUTTON, self.OnClickDelete, self.delColorB)
self.Bind(wx.EVT_BUTTON, self.OnClickModify, self.modifyColorB)
+ self.Bind(wx.EVT_BUTTON, self.OnClickPresets, self.presetsB)
+
+ def OnClickPresets(self, evt):
+
+ menu = wx.Menu()
+ self.ids = []
+ for i in range (len(self.scene.frame.transferFunctions)):
+ popupID = wx.NewId()
+ menu.Append(popupID, self.scene.frame.transferFunctions[i].label)
+ self.Bind(wx.EVT_MENU, self.OnPopUp, id=popupID)
+ self.ids.append(popupID)
+ self.puNewID = wx.NewId()
+ menu.Append(self.puNewID, "New...")
+ self.Bind(wx.EVT_MENU, self.OnPopUp, id=self.puNewID)
+ self.PopupMenu(menu)
+ menu.Destroy()
+
+ def OnPopUp(self, evt):
+ print "popup"
+ if evt.GetId() == self.puNewID:
+ dlg = wx.TextEntryDialog(self, 'Set Name of new TF:', 'TF', 'TF')
+ dlg.SetValue('Untitled')
+ if dlg.ShowModal() == wx.ID_OK:
+ name = dlg.GetValue()
+ colors = []
+ index = len(self.scene.frame.transferFunctions)
+ slices = manta_new(vector_ColorSlice());
+ for i in range(len(self.transferF.colors)):
+ c = self.transferF.colors[i]
+
slices.push_back(ColorSlice(c[0],RGBAColor(Color(RGBColor(c[1],c[2],c[3])),
c[4])))
+ colors.append(c)
+ cmap =
self.scene.frame.sphereVolCMaps.append(manta_new(RGBAColorMap(slices, 64)))
+ t = TransferF(self.parentC, colors, index, name, cmap)
+ self.scene.frame.transferFunctions.append(t)
+ self.SetTransferF(t)
+ else:
+ for i in range(len(self.ids)):
+ if evt.GetId() == self.ids[i]:
+ self.SetTransferF(self.scene.frame.transferFunctions[i])
def OnClickNew(self, evt):
self.transferFPanel.AddNewColor()
@@ -487,7 +515,9 @@
self.box1_title.SetLabel(label)
def SetTransferF(self, transferF):
+ self.transferF = transferF
self.transferFPanel.SetTransferF(transferF)
+ self.SetLabel(transferF.label)
def SetUpdateFunction(self, function):
- print "temporary"
+ print ""
Modified: trunk/scenes/csafe/python/csafe_demo.py
==============================================================================
--- trunk/scenes/csafe/python/csafe_demo.py (original)
+++ trunk/scenes/csafe/python/csafe_demo.py Wed Apr 16 00:26:55 2008
@@ -263,7 +263,6 @@
def UpdateColorMap(self, transferF):
- print "UPDATECOLORMAP"
cmap = transferF.cmap
t = transferF
slices = vector_ColorSlice()
@@ -273,6 +272,7 @@
t.colors[i][2], t.colors[i][3])), t.colors[i][4])))
if (cmap != None):
cmap.SetColors(slices)
+ self.volCMap.scaleAlphas(0.00125)
def OnClick(self, evt):
print "clicked main"
@@ -298,47 +298,6 @@
def InitializeScene(self,frame, engine):
self.scene.mantaFrame = frame
-# menuBar = frame.menuBar
-#
-# menuFile = frame.file_menu
-# dialog_id = wx.NewId()
-# menuFile.Append(dialog_id, "&About", "")
-# self.Bind(wx.EVT_MENU, self.Menu101, id=dialog_id)
-# menuFile.Append(102, "&Save", "")
-# menuFile.Append(103, "Save As...", "")
-# dialog_id = wx.NewId()
-# menuFile.Append(dialog_id, "Load", "")
-# self.Bind(wx.EVT_MENU, self.Menu104, id=dialog_id)
-# menuFile.Append(107, "Import NrrdList")
-# menuFile.Append(108, "Export NrrdList")
-# menuFile.Append(106, "Import Transfer Function")
-# menuFile.Append(105, "Export Transfer Function")
-# menuFile.Append(109, "&Quit", "")
-# #menuBar.Append(menuFile, "File")
-#
-# menuScene = wx.Menu()
-# menuScene.Append(201, "&Add/Remove Files", "Add and remove Nrrd
files to the scene")
-# menuScene.Append(204, "Add &Histogram", "Add a histogram to the
panel")
-# menuScene.Append(202, "Scene Preferences")
-# menuScene.Append(203, "&Generate")
-# menuBar.Append(menuScene, "Scene")
-#
-# menuHelp = wx.Menu()
-# menuBar.Append(menuHelp, "Help")
-## self.SetMenuBar(menuBar)
-#
-#
-# self.Bind(wx.EVT_MENU, self.Menu102, id=102)
-# self.Bind(wx.EVT_MENU, self.Menu103, id=103)
-# self.Bind(wx.EVT_MENU, self.Menu105, id=105)
-# self.Bind(wx.EVT_MENU, self.Menu106, id=106)
-# self.Bind(wx.EVT_MENU, self.Menu201, id=201)
-# self.Bind(wx.EVT_MENU, self.Menu202, id=202)
-# self.Bind(wx.EVT_MENU, self.Menu107, id=107)
-# self.Bind(wx.EVT_MENU, self.Menu108, id=108)
-# self.Bind(wx.EVT_MENU, self.Menu109, id=109)
-# self.Bind(wx.EVT_MENU, self.Menu203, id=203)
-# self.Bind(wx.EVT_MENU, self.Menu204, id=204)
self.SetBackgroundColour(self.scene.bgColor)
@@ -353,6 +312,7 @@
engine.getCamera(0).setBasicCameraData(data)
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
engine.setShadowAlgorithm(manta_new(NoShadows()))
+ #engine.selectShadowAlgorithm("noshadows")
# Create the checker textures.
@@ -375,6 +335,11 @@
Vector(40,0,0), Vector(0,40,0)))
uniformmap = manta_new(UniformMapper())
floor.setTexCoordMapper(uniformmap)
+ world.add(floor)
+ material = manta_new(Lambertian(Color(RGBColor(1,0,0))))
+ world.add(manta_new(Sphere(material, Vector(0,0,1.2), 1.0)))
+ scene.setObject(world)
+
self.colorMap1 = colorMap1 = manta_new(RGBAColorMap())
slices = manta_new(vector_ColorSlice());
@@ -418,7 +383,6 @@
scene.getRenderParameters().maxDepth = 5
-
engine.setScene( scene )
#################init the GUI######################
@@ -440,7 +404,7 @@
self.transferFunctions = []
self.transferFunctions.append(self.t0)
- self.tPanel = tPanel = TransferF.TransferFGroup(self.panel, 300, 100,
self.defaultTransferF, "empty")
+ self.tPanel = tPanel = TransferF.TransferFGroup(self.panel, 300, 100,
self.defaultTransferF, "empty", self.scene)
self.scene.tPanel = tPanel
tPanel.SetBackgroundColour(self.scene.bgColor)
self.Bind(wx.EVT_LEFT_DOWN, self.OnKeyDown)
@@ -566,6 +530,7 @@
Configuration.ReadNRRDList(frame1.scene, setup.nrrdlist)
if (setup.generate == True):
frame1.BuildScene()
+ frame.StartEngine()
def usage():
@@ -602,6 +567,7 @@
print "generating scene on startup"
else:
print "unable to understand command: " + str(args[i])
+ usage()
except :
print "Inorrect commandline usage"
usage()
Modified: trunk/scenes/csafe/src/CDGridSpheres.cc
==============================================================================
--- trunk/scenes/csafe/src/CDGridSpheres.cc (original)
+++ trunk/scenes/csafe/src/CDGridSpheres.cc Wed Apr 16 00:26:55 2008
@@ -29,14 +29,16 @@
int cidx) :
spheres(spheres), nspheres(nspheres), nvars(nvars),
radius(radius), ridx(ridx), ncells(ncells), depth(depth),
-cmap(cmap), cidx(cidx)
+cmap(cmap), cidx(cidx), _useAmbientOcclusion(false)
{
cerr<<"Initializing GridSpheres\n";
if (radius <= 0) {
if (ridx <= 0)
+ {
cerr<<"Resetting default radius to 1\n";
- radius=1;
+ radius=1;
+ }
}
// Compute inverses
@@ -344,6 +346,9 @@
}
cerr<<"Done building GridSpheres\n";
+
+ _ao = new AmbientOcclusion(Color(RGB(1,1,1)), 0.01f, 10);
+ _ao->preprocess(context);
}
void CDGridSpheres::computeBounds(const PreprocessContext& context,
@@ -611,13 +616,27 @@
}
}
} while(!shadowState.done());
-
- // Sum up diffuse/specular contributions
- for (int i=rays.begin(); i < rays.end(); ++i) {
- Color result;
- for (int j=0;j<Color::NumComponents; ++j)
- result[j]=totalLight[j][i]*diffuse.colordata[j][i];
- rays.setColor(i, result);
+ if (_useAmbientOcclusion)
+ {
+ //ambient occlusion
+ _ao->shade(context, rays);
+ // Sum up diffuse/specular contributions
+ for (int i=rays.begin(); i < rays.end(); ++i) {
+ Color result;
+ for (int j=0;j<Color::NumComponents; ++j)
+
result[j]=totalLight[j][i]*diffuse.colordata[j][i];
+ rays.setColor(i, result*rays.getColor(i));
+ }
+ }
+ else
+ {
+ // Sum up diffuse/specular contributions
+ for (int i=rays.begin(); i < rays.end(); ++i) {
+ Color result;
+ for (int j=0;j<Color::NumComponents; ++j)
+
result[j]=totalLight[j][i]*diffuse.colordata[j][i];
+ rays.setColor(i, result);
+ }
}
}
Modified: trunk/scenes/csafe/src/CDGridSpheres.h
==============================================================================
--- trunk/scenes/csafe/src/CDGridSpheres.h (original)
+++ trunk/scenes/csafe/src/CDGridSpheres.h Wed Apr 16 00:26:55 2008
@@ -1,6 +1,6 @@
//! Filename: CDGridSpheres.h
/*!
- same as Grispheres, but with small changes to incorporate csafe demo.
TODO: incorporate changes into main Gridspheres file
+ same as Gridspheres, but with small changes to incorporate csafe demo.
TODO: incorporate changes into main Gridspheres file
*/
#ifndef Manta_Model_CDGridSpheres_h
@@ -13,6 +13,7 @@
#include <Interface/Texture.h>
#include <Model/Primitives/PrimitiveCommon.h>
#include <Model/Materials/LitMaterial.h>
+#include <Model/Materials/AmbientOcclusion.h>
#include <Model/Materials/Volume.h>
#define USE_OPTIMIZED_FCNS
@@ -57,6 +58,9 @@
clipMins[index] = clipMin;
clipMaxs[index] = clipMax;
}
+ void useAmbientOcclusion(bool st) { _useAmbientOcclusion = st; }
+ void setAmbientOcclusionVariables(float cutoff, int numDirs) { if
(_ao) { _ao->setCutoffDistance(cutoff); _ao->setNumRays(numDirs); } }
+
protected:
#ifdef USE_OPTIMIZED_FCNS
typedef void (CDGridSpheres::*SphereIntersectFcn)(RayPacket&,
int, int,
@@ -104,7 +108,8 @@
void lambertianShade(const RenderContext& context, RayPacket&
rays,
ColorArray&
totalLight) const;
-
+
+protected:
float* spheres;
int nspheres;
int nvars;
@@ -134,6 +139,8 @@
RGBAColorMap* cmap;
int cidx;
+ AmbientOcclusion* _ao;
+ bool _useAmbientOcclusion;
};
}
Modified: trunk/scenes/csafe/src/CDTest.h
==============================================================================
--- trunk/scenes/csafe/src/CDTest.h (original)
+++ trunk/scenes/csafe/src/CDTest.h Wed Apr 16 00:26:55 2008
@@ -38,6 +38,8 @@
#include <Model/Primitives/Cube.h>
#include <Model/Materials/Lambertian.h>
#include <teem/nrrd.h>
+#include <Model/Readers/VolumeNRRD.h>
+#include <Model/Readers/UDAReader.h>
#include <vector>
#include <string>
@@ -74,6 +76,7 @@
_manta_interface = interface;
_forceDataMin = -FLT_MAX;
_forceDataMax = -FLT_MAX;
+ _useAO = false;
}
//! sets the scene object, necessary for initializing scene
and loading spheres/volume
@@ -91,7 +94,7 @@
void initScene()
{
_world = new Group();
- _scene->setBackground(new
ConstantBackground(Color(RGB(0, 0, 0))));
+ _scene->setBackground(new
ConstantBackground(Color(RGB(.5, .5, .5))));
_scene->setObject(_world);
LightSet* lights = new LightSet();
@@ -121,26 +124,27 @@
_minBound = Vector(-0.001, -0.101, -0.001);
_maxBound = Vector( 0.101, 0.201, 0.101);
-
- vector<ColorSlice> slices;
- float div = 1.0/255.0;
- float a = 0.1;
- slices.push_back(ColorSlice(0.0f,
RGBAColor(Color(RGB(0, 0, 0)) * div, 0*a)));
- slices.push_back(ColorSlice(0.109804f,
RGBAColor(Color(RGB(52, 0, 0)) * div, 0*a)));
- slices.push_back(ColorSlice(0.01f,
RGBAColor(Color(RGB(102, 2, 0)) * div, 0.1*a)));
- slices.push_back(ColorSlice(0.328571f,
RGBAColor(Color(RGB(153, 18, 0)) * div, 0.216667*a)));
- slices.push_back(ColorSlice(0.4f,
RGBAColor(Color(RGB(200, 41, 0)) * div, 0.23*a)));
- slices.push_back(ColorSlice(0.5f,
RGBAColor(Color(RGB(230, 71, 0)) * div, 0.27*a)));
- slices.push_back(ColorSlice(0.618367f,
RGBAColor(Color(RGB(255, 120, 0)) * div, 0.3375*a)));
- slices.push_back(ColorSlice(0.68f,
RGBAColor(Color(RGB(255, 163, 20)) * div, 0.35*a)));
- slices.push_back(ColorSlice(0.72f,
RGBAColor(Color(RGB(255, 204, 55)) * div, 0.37*a)));
- slices.push_back(ColorSlice(0.79f,
RGBAColor(Color(RGB(255, 228, 80)) * div, 0.39*a)));
- slices.push_back(ColorSlice(0.85f,
RGBAColor(Color(RGB(255, 247, 120)) * div, 0.43*a)));
- slices.push_back(ColorSlice(0.92f,
RGBAColor(Color(RGB(255, 255, 180)) * div, 0.47*a)));
- slices.push_back(ColorSlice(1.0f,
RGBAColor(Color(RGB(255, 255, 255)) * div, 0.5*a)));
- if (_volCMap)
- delete _volCMap;
- _volCMap = new RGBAColorMap(slices, 64);
+ if (!_volCMap)
+ {
+ vector<ColorSlice> slices;
+ float div = 1.0/255.0;
+ float a = 0.1;
+ slices.push_back(ColorSlice(0.0f, RGBAColor(Color(RGB(0, 0,
0)) * div, 0*a)));
+ slices.push_back(ColorSlice(0.109804f,
RGBAColor(Color(RGB(52, 0, 0)) * div, 0*a)));
+ slices.push_back(ColorSlice(0.01f, RGBAColor(Color(RGB(102,
2, 0)) * div, 0.1*a)));
+ slices.push_back(ColorSlice(0.328571f,
RGBAColor(Color(RGB(153, 18, 0)) * div, 0.216667*a)));
+ slices.push_back(ColorSlice(0.4f, RGBAColor(Color(RGB(200,
41, 0)) * div, 0.23*a)));
+ slices.push_back(ColorSlice(0.5f, RGBAColor(Color(RGB(230,
71, 0)) * div, 0.27*a)));
+ slices.push_back(ColorSlice(0.618367f,
RGBAColor(Color(RGB(255, 120, 0)) * div, 0.3375*a)));
+ slices.push_back(ColorSlice(0.68f, RGBAColor(Color(RGB(255,
163, 20)) * div, 0.35*a)));
+ slices.push_back(ColorSlice(0.72f, RGBAColor(Color(RGB(255,
204, 55)) * div, 0.37*a)));
+ slices.push_back(ColorSlice(0.79f, RGBAColor(Color(RGB(255,
228, 80)) * div, 0.39*a)));
+ slices.push_back(ColorSlice(0.85f, RGBAColor(Color(RGB(255,
247, 120)) * div, 0.43*a)));
+ slices.push_back(ColorSlice(0.92f, RGBAColor(Color(RGB(255,
255, 180)) * div, 0.47*a)));
+ slices.push_back(ColorSlice(1.0f, RGBAColor(Color(RGB(255,
255, 255)) * div, 0.5*a)));
+
+ _volCMap = new RGBAColorMap(slices, 64);
+ }
}
@@ -199,12 +203,12 @@
_spherePNrrds.push_back(pnrrd);
Group* group = new Group();
RGBAColorMap* cmap = new RGBAColorMap(1);
- CDGridSpheres* grid = new
CDGridSpheres(pnrrd->getParticleData(), pnrrd->getNParticles(),
pnrrd->getNVars(), 6, 2,0.0001, _ridx, cmap , _cidx);
- grid->setCMinMax(4, 299.50411987304688,
500.59423828125);
+ CDGridSpheres* grid = new
CDGridSpheres(pnrrd->getParticleData(), pnrrd->getNParticles(),
pnrrd->getNVars(), 6, 2,_radius, _ridx, cmap , _cidx);
+ //grid->setCMinMax(4, 299.50411987304688,
500.59423828125);
//TODO: unhardcode this!
- cout << "reprocess\n";
- grid->preprocess(context);
- cout << "donepreprocess\n";
+ //cout << "reprocess\n";
+ //grid->preprocess(context);
+ //cout << "donepreprocess\n";
group->add(grid);
_sphereGrids.push_back(grid);
if (pnrrd->getNVars() > _sphereMins.size())
@@ -258,7 +262,7 @@
{
cout << "Loading Nrrd file: " << *i <<
"...\n";
Group* group = new Group();
- Volume<float>* mat = new Volume<float>(*i,
_volCMap, _minBound, _maxBound, 0.00125, 10, 3, _forceDataMin, _forceDataMax);
+ Volume<float>* mat = new
Volume<float>(loadNRRDToGrid<float>(*i), _volCMap, _minBound, _maxBound,
0.00125, 10, 3, _forceDataMin, _forceDataMax);
Primitive* vol = new Cube(mat, _minBound -
Vector(0.001, 0.001, 0.001), _maxBound + Vector(0.001, 0.001, 0.001));
group->add(vol);
_volAnimation->push_back(group);
@@ -290,19 +294,19 @@
*/
void reloadData()
{
- _scene = new Scene();
+ //_scene = new Scene();
//TODO: i don't delete the old scene object... I don't want to
to do a recursive delete
- _manta_interface->setScene(_scene);
- initScene();
- _volsOld = _vols;
- _sphereGridsOld = _sphereGrids;
- _spherePNrrdsOld = _spherePNrrds;
- _vols.clear();
- _spherePNrrds.clear();
- _sphereGrids.clear();
+ //_manta_interface->setScene(_scene);
+ //initScene();
+ //_volsOld = _vols;
+ //_sphereGridsOld = _sphereGrids;
+ //_spherePNrrdsOld = _spherePNrrds;
+ //_vols.clear();
+ //_spherePNrrds.clear();
+ //_sphereGrids.clear();
loadSphereNrrds();
loadVolNrrds();
- _manta_interface->addOneShotCallback(MantaInterface::Relative,
2, Callback::create(this, &CDTest::reloadDataHelper));
+ //_manta_interface->addOneShotCallback(MantaInterface::Relative,
2, Callback::create(this, &CDTest::reloadDataHelper));
}
@@ -619,6 +623,27 @@
*/
int getCidx() { return _cidx; }
+ //! set to use ambient occlusion on spheres
+ void useAO(bool st)
+ {
+ if (st == _useAO)
+ return;
+ _useAO = st;
+ for(int i = 0; i < int(_sphereGrids.size()); i++)
+ _sphereGrids[i]->useAmbientOcclusion(st);
+ }
+
+ //! set the cutoff distance and number of generated rays
+ /*!
+ \param cutoff distance, distance to check if rays hit objects
+ \param number of generated rays
+ */
+ void setAOVars(float cutoff, int numDirs)
+ {
+ for(int i = 0; i < int(_sphereGrids.size()); i++)
+ _sphereGrids[i]->setAmbientOcclusionVariables(cutoff,
numDirs);
+ }
+
protected:
//! called by reloadData
/*!
@@ -665,6 +690,7 @@
KeyFrameAnimation* _sphereAnimation;
KeyFrameAnimation* _volAnimation;
int _startFrame, _endFrame, _clipFrames;
+ bool _useAO;
};
#endif
Modified: trunk/scenes/volumeTest.cc
==============================================================================
--- trunk/scenes/volumeTest.cc (original)
+++ trunk/scenes/volumeTest.cc Wed Apr 16 00:26:55 2008
@@ -51,10 +51,7 @@
#include <Model/TexCoordMappers/SphericalMapper.h>
#include <Model/TexCoordMappers/UniformMapper.h>
#include <Model/Textures/CheckerTexture.h>
-#include <Model/Textures/MarbleTexture.h>
-#include <Model/Textures/OakTexture.h>
-#include <Model/Textures/WoodTexture.h>
-//#include <Model/Readers/ParticleNRRD.h>
+#include <Model/Readers/VolumeNRRD.h>
//#include <Model/Textures/NormalTexture.h>
#include <iostream>
@@ -232,7 +229,7 @@
cMap->scaleAlphas(t_inc);
-Volume<float>* mat = new Volume<float>(volFile, cMap, minBound, maxBound,
t_inc, 10.0, depth, dataMin, dataMax);
+Volume<float>* mat = new Volume<float>(loadNRRDToGrid<float>(volFile), cMap,
minBound, maxBound, t_inc, 10.0, depth, dataMin, dataMax);
//double min, max;
//mat->getMinMax(&min, &max);
//cmap2->setMinMax(min, max);
- [Manta] r2198 - in trunk: Model/Materials Model/Readers scenes scenes/csafe/python scenes/csafe/src, brownlee, 04/16/2008
Archive powered by MHonArc 2.6.16.