Commit 4aa948c1 authored by hrchilds's avatar hrchilds

Update from October 24, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@346 18c085ea-50e0-402c-830e-de6fd14e8384
parent e2c35547
This diff is collapsed.
......@@ -15,7 +15,7 @@
// Notes: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed May 12 07:29:22 PDT 2004
// Creation: Sun Oct 24 07:27:47 PDT 2004
//
// Modifications:
//
......@@ -75,6 +75,8 @@ public:
void SetSpecularCoeff(float specularCoeff_);
void SetSpecularPower(float specularPower_);
void SetSpecularColor(const ColorAttribute &specularColor_);
void SetDoShadowing(bool doShadowing_);
void SetShadowStrength(double shadowStrength_);
// Property getting methods
bool GetAntialiasing() const;
......@@ -90,6 +92,8 @@ public:
float GetSpecularPower() const;
const ColorAttribute &GetSpecularColor() const;
ColorAttribute &GetSpecularColor();
bool GetDoShadowing() const;
double GetShadowStrength() const;
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -133,6 +137,8 @@ private:
float specularCoeff;
float specularPower;
ColorAttribute specularColor;
bool doShadowing;
double shadowStrength;
};
#endif
......@@ -54,6 +54,12 @@
255
255
</Field>
<Field name="doShadowing" label="Do Shadowing" type="bool">
false
</Field>
<Field name="shadowStrength" label="Shadow Strength" type="double">
0.500000
</Field>
<Function name="GetEffectiveScalableThreshold" user="true" member="true">
</Function>
<Constant name="DEFAULT_SCALABLE_AUTO_THRESHOLD" member="false">
......
......@@ -1409,6 +1409,10 @@ avtDatabase::GetExtentsFromAuxiliaryData(avtDataSpecification_p spec,
avtIntervalTree *tree = (avtIntervalTree *) *(list.list[0]);
float fextents[6];
tree->GetExtents(fextents);
int nvals = 2;
if (strcmp(type, AUXILIARY_DATA_SPATIAL_EXTENTS) == 0)
nvals = 6;
for (int i = 0; i < 6; i++)
extents[i] = fextents[i];
......
......@@ -147,6 +147,9 @@
# Brad Whitlock, Thu Apr 22 17:14:16 PST 2004
# Added more libraries so we can prelink on MacOS X.
#
# Hank Childs, Sun Oct 24 08:17:46 PDT 2004
# Added avtSoftwareShader.
#
##############################################################################
##
......@@ -169,7 +172,7 @@ SRC=avtLegend.C avtVariableLegend.C avtGeometryDrawable.C avtActor.C \
avtLineoutActor.C avtTransparencyActor.C avtLabelActor.C \
avtDecorationsDrawable.C avtDecorationsMapper.C avtLabeledCurveMapper.C \
avtExternallyRenderedImagesActor.C avtTensorGlyphMapper.C avtDrawable.C \
avtPointGlyphMapper.C
avtPointGlyphMapper.C avtSoftwareShader.C
......
This diff is collapsed.
// ************************************************************************* //
// avtSoftwareShader //
// ************************************************************************* //
#ifndef AVT_SOFTWARE_SHADER_H
#define AVT_SOFTWARE_SHADER_H
#include <avtImage.h>
class LightAttributes;
class avtView3D;
// ****************************************************************************
// Class: avtSoftwareShader
//
// Purpose:
// Does shadows in software.
//
// Programmer: Hank Childs
// Creation: October 24, 2004
//
// ****************************************************************************
class avtSoftwareShader
{
public:
static bool GetLightDirection(const LightAttributes &, const avtView3D &,
double *);
static void AddShadows(avtImage_p, avtImage_p, avtView3D &, avtView3D &,
double, double);
};
#endif
......@@ -1852,6 +1852,9 @@ avtSAMRAIFileFormat::ConvertMassFractionFields(vector<int> matIds,
// I modified the way the routine built the interval tree from the
// extents associated with a vector.
//
// Mark C. Miller, Thu Oct 21 22:11:28 PDT 2004
// Fixed spatail extents for ALE mesh
//
// ****************************************************************************
void *
......@@ -1863,8 +1866,17 @@ avtSAMRAIFileFormat::GetAuxiliaryData(const char *var, int patch,
void *rv = NULL;
avtIntervalTree *itree = NULL;
if (strcmp(type, AUXILIARY_DATA_DATA_EXTENTS) == 0) {
//
// For an ale grid, a spatial extents query is *really* a data extents
// query on the "Coords" variable
//
if ((strcmp(type, AUXILIARY_DATA_DATA_EXTENTS) == 0) ||
((strcmp(type, AUXILIARY_DATA_SPATIAL_EXTENTS) == 0) &&
(grid_type == "ALE" || grid_type == "DEFORMED"))) {
if (strcmp(type, AUXILIARY_DATA_SPATIAL_EXTENTS) == 0)
name = "Coords";
debug5 << "avtSAMRAIFileFormat::GetAuxiliaryData getting DATA_EXTENTS" << endl;
std::map<std::string, var_t>::const_iterator cur_var;
......
This diff is collapsed.
......@@ -93,6 +93,9 @@ typedef struct
// Mark C. Miller, Thu Oct 14 15:18:31 PDT 2004
// Added GetSpatialExtents and GetDataExtents
//
// Mark C. Miller, Thu Oct 21 22:11:28 PDT 2004
// Added arbMeshZoneRangesToSkip to support DBzonelists with arb. zones.
//
// ****************************************************************************
class avtSiloFileFormat : public avtSTMDFileFormat
......@@ -150,6 +153,8 @@ class avtSiloFileFormat : public avtSTMDFileFormat
GroupInfo groupInfo;
std::map<std::string, std::vector<int> > arbMeshZoneRangesToSkip;
DBfile *GetFile(int);
DBfile *OpenFile(int, bool skipGlobalInfo = false);
......@@ -177,7 +182,8 @@ class avtSiloFileFormat : public avtSTMDFileFormat
vtkDataSet *GetUnstructuredMesh(DBfile *, const char *,
int, const char *);
void ReadInConnectivity(vtkUnstructuredGrid *,
DBzonelist *, int);
DBzonelist *, int,
std::vector<int>&);
void GetConnectivityAndGroupInformation(DBfile *);
void GetConnectivityAndGroupInformationFromFile(DBfile *,
int &, int *&,int *&,int &,int *&,int &,int *&);
......@@ -187,7 +193,7 @@ class avtSiloFileFormat : public avtSTMDFileFormat
int &, int *&, int &, int *&, bool, bool);
avtFacelist *CalcExternalFacelist(DBfile *, char *);
avtMaterial *CalcMaterial(DBfile *, char *, int dom);
avtMaterial *CalcMaterial(DBfile *, char *, const char *, int dom);
avtSpecies *CalcSpecies(DBfile *, char *);
vtkDataArray *GetGlobalNodeIds(int, const char *);
vtkDataArray *GetGlobalZoneIds(int, const char *);
......
......@@ -41,6 +41,7 @@
#include <avtPickByZoneQuery.h>
#include <avtZonePickQuery.h>
#include <avtCurvePickQuery.h>
#include <avtSoftwareShader.h>
#include <avtSourceFromAVTImage.h>
#include <avtSourceFromImage.h>
#include <avtSourceFromNullData.h>
......@@ -1453,6 +1454,9 @@ NetworkManager::GetOutput(bool respondWithNullData, bool calledForRender,
// Forced the second pass to turn off gradient backgrounds before rendering.
// It was causing erasing of the first-pass results.
//
// Hank Childs, Sat Oct 23 14:06:21 PDT 2004
// Added support for shadows. Also cleaned up memory leak.
//
// ****************************************************************************
avtDataObjectWriter_p
NetworkManager::Render(intVector plotIds, bool getZBuffer, int annotMode)
......@@ -1629,13 +1633,14 @@ NetworkManager::Render(intVector plotIds, bool getZBuffer, int annotMode)
annotationObjectList, visualCueList,
frameAndState, annotMode);
debug5 << "Rendering " << viswin->GetNumTriangles() << " triangles. "
<< "Balanced speedup = " << RenderBalance(viswin->GetNumTriangles())
<< "x" << endl;
debug5 << "Rendering " << viswin->GetNumTriangles()
<< " triangles. Balanced speedup = "
<< RenderBalance(viswin->GetNumTriangles()) << "x" << endl;
//
// Determine if we need to go for two passes
//
bool doShadows = windowAttributes.GetRenderAtts().GetDoShadowing();
bool two_pass_mode = false;
#ifdef PARALLEL
if (viswin->GetWindowMode() == WINMODE_3D)
......@@ -1667,17 +1672,22 @@ NetworkManager::Render(intVector plotIds, bool getZBuffer, int annotMode)
if (dumpRenders)
DumpImage(theImage, "before_ImageCompositer");
avtWholeImageCompositer *imageCompositer;
if (viswin->GetWindowMode() == WINMODE_3D)
{
imageCompositer = new avtWholeImageCompositerWithZ();
imageCompositer->SetShouldOutputZBuffer(getZBuffer ||
two_pass_mode);
two_pass_mode ||
doShadows);
}
else
{
imageCompositer = new avtWholeImageCompositerNoZ();
// we have to use z-buffer in 2D windows with gradient background
if (viswin->GetBackgroundMode() == 0)
imageCompositer = new avtWholeImageCompositerNoZ();
else
imageCompositer = new avtWholeImageCompositerWithZ();
imageCompositer->SetShouldOutputZBuffer(two_pass_mode);
}
//
......@@ -1760,6 +1770,71 @@ NetworkManager::Render(intVector plotIds, bool getZBuffer, int annotMode)
visitTimer->StopTimer(t2, "tiled image compositor execute");
}
//
// Do shadows if appropriate.
//
if (doShadows)
{
avtView3D cur_view = viswin->GetView3D();
avtView3D light_view = cur_view;
//
// Figure out which direction the light is pointing.
//
const LightList *light_list = viswin->GetLightList();
const LightAttributes &la = light_list->GetLight0();
double light_dir[3];
bool canShade = avtSoftwareShader::GetLightDirection(la,
cur_view, light_dir);
if (canShade)
{
//
// Now create a new image from the light source.
//
light_view.normal[0] = light_dir[0];
light_view.normal[1] = light_dir[1];
light_view.normal[2] = light_dir[2];
viswin->SetView3D(light_view);
avtImage_p myLightImage =
viswin->ScreenCapture(viewportedMode,true);
avtWholeImageCompositer *wic =
new avtWholeImageCompositerWithZ();
wic->SetShouldOutputZBuffer(true);
int imageRows, imageCols;
myLightImage->GetSize(&imageCols, &imageRows);
wic->SetOutputImageSize(imageRows, imageCols);
wic->AddImageInput(myLightImage, 0, 0);
wic->SetShouldOutputZBuffer(1);
wic->SetAllProcessorsNeedResult(false);
//
// Do the parallel composite using a 1 stage pipeline
//
wic->Execute();
avtImage_p lightImage = wic->GetTypedOutput();
viswin->SetView3D(cur_view);
avtImage_p compositedImage;
CopyTo(compositedImage, compositedImageAsDataObject);
int width, height;
viswin->GetSize(width, height);
double aspect = ((double) width) / ((double) height);
double strength =
windowAttributes.GetRenderAtts().GetShadowStrength();
#ifdef PARALLEL
if (PAR_Rank() == 0)
#endif
{
avtSoftwareShader::AddShadows(lightImage,
compositedImage, light_view,
cur_view, aspect, strength);
}
delete wic;
}
}
//
// If the engine is doing more than just 3D attributes,
// post-process the composited image.
......@@ -1781,11 +1856,10 @@ NetworkManager::Render(intVector plotIds, bool getZBuffer, int annotMode)
writer = compositedImageAsDataObject->InstantiateWriter();
writer->SetInput(compositedImageAsDataObject);
if (dumpRenders)
DumpImage(compositedImageAsDataObject,
"after_ImageCompositer", false);
delete imageCompositer;
}
delete [] cellCounts;
......
......@@ -115,6 +115,9 @@ QvisRenderingWindow::~QvisRenderingWindow()
// Changed scalable rendering controls to use activation mode and auto
// threshold
//
// Hank Childs, Sun Oct 24 07:36:18 PDT 2004
// Added shadow options.
//
// ****************************************************************************
void
......@@ -129,7 +132,7 @@ QvisRenderingWindow::CreateWindowContents()
QVBoxLayout *spacer = new QVBoxLayout(options);
spacer->addSpacing(10);
QGridLayout *oLayout = new QGridLayout(spacer, 14, 4);
QGridLayout *oLayout = new QGridLayout(spacer, 16, 4);
oLayout->setSpacing(5);
oLayout->setMargin(10);
......@@ -250,6 +253,23 @@ QvisRenderingWindow::CreateWindowContents()
oLayout->addWidget(specularPowerLabel, 13,1);
oLayout->addMultiCellWidget(specularPowerSlider, 13,13, 2,3);
// Create the shadow lighting options
shadowToggle = new QCheckBox("Shadows", options,
"shadowToggle");
connect(shadowToggle, SIGNAL(toggled(bool)),
this, SLOT(shadowToggled(bool)));
oLayout->addMultiCellWidget(shadowToggle, 14, 14, 0,3);
shadowStrengthSlider = new QvisOpacitySlider(0, 100, 10, 60, options,
"shadowStrengthSlider", NULL);
shadowStrengthSlider->setTickInterval(25);
connect(shadowStrengthSlider, SIGNAL(valueChanged(int, const void*)),
this, SLOT(shadowStrengthChanged(int, const void*)));
shadowStrengthLabel = new QLabel(shadowStrengthSlider, "Strength",
options, "shadowStrengthLabel");
oLayout->addWidget(shadowStrengthLabel, 15,1);
oLayout->addMultiCellWidget(shadowStrengthSlider, 15,15, 2,3);
//
// Create the renderer information group.
......@@ -375,6 +395,9 @@ QvisRenderingWindow::UpdateWindow(bool doAll)
// Changed scalable rendering controls to use activation mode and auto
// threshold
//
// Hank Childs, Sun Oct 24 07:36:18 PDT 2004
// Added shadow options.
//
// ****************************************************************************
void
......@@ -451,6 +474,9 @@ QvisRenderingWindow::UpdateOptions(bool doAll)
else
scalrenActivationMode->setButton(0);
scalrenActivationMode->blockSignals(false);
shadowToggle->setEnabled(itmp == RenderingAttributes::Always);
if (itmp != RenderingAttributes::Always)
shadowStrengthSlider->setEnabled(false);
break;
case 8: //specularFlag
specularToggle->blockSignals(true);
......@@ -474,6 +500,18 @@ QvisRenderingWindow::UpdateOptions(bool doAll)
case 11: //specularColor
// Not user-modifiable at this time
break;
case 12: //shadowFlag
shadowToggle->blockSignals(true);
shadowToggle->setChecked(renderAtts->GetDoShadowing());
shadowToggle->blockSignals(false);
shadowStrengthSlider->setEnabled(renderAtts->GetDoShadowing());
shadowStrengthLabel->setEnabled(renderAtts->GetDoShadowing());
break;
case 13: //shadowStrength
shadowStrengthSlider->blockSignals(true);
shadowStrengthSlider->setValue(int(renderAtts->GetShadowStrength()*100.));
shadowStrengthSlider->blockSignals(false);
break;
}
}
}
......@@ -987,6 +1025,52 @@ QvisRenderingWindow::scalrenAutoThresholdChanged(int val)
Apply();
}
// ****************************************************************************
// Method: QvisRenderingWindow::shadowToggled
//
// Purpose:
// Callback for the shadow toggle button
//
// Arguments:
// val true to enable shadow
//
// Programmer: Hank Childs
// Creation: October 24, 2004
//
// ****************************************************************************
void
QvisRenderingWindow::shadowToggled(bool val)
{
renderAtts->SetDoShadowing(val);
shadowStrengthSlider->setEnabled(renderAtts->GetDoShadowing());
shadowStrengthLabel->setEnabled(renderAtts->GetDoShadowing());
SetUpdate(false);
Apply();
}
// ****************************************************************************
// Method: QvisRenderingWindow::shadowStrengthChanged
//
// Purpose:
// Callback for the shadow coefficient slider
//
// Arguments:
// val the new coefficient
//
// Programmer: Hank Childs
// Creation: October 24, 2004
//
// ****************************************************************************
void
QvisRenderingWindow::shadowStrengthChanged(int val, const void*)
{
renderAtts->SetShadowStrength(float(val)/100.);
SetUpdate(false);
Apply();
}
// ****************************************************************************
// Method: QvisRenderingWindow::specularToggled
//
......
......@@ -42,6 +42,9 @@ class QvisOpacitySlider;
// Hank Childs, Sun May 9 15:54:29 PDT 2004
// Add support for multiple display list modes.
//
// Hank Childs, Sun Oct 24 07:34:09 PDT 2004
// Add shadows.
//
// ****************************************************************************
class GUI_API QvisRenderingWindow : public QvisPostableWindowSimpleObserver
......@@ -76,6 +79,8 @@ private slots:
void specularToggled(bool);
void specularStrengthChanged(int, const void*);
void specularPowerChanged(int, const void*);
void shadowToggled(bool);
void shadowStrengthChanged(int, const void*);
private:
RenderingAttributes *renderAtts;
WindowInformation *windowInfo;
......@@ -101,6 +106,9 @@ private:
QvisOpacitySlider *specularStrengthSlider;
QLabel *specularPowerLabel;
QvisOpacitySlider *specularPowerSlider;
QCheckBox *shadowToggle;
QLabel *shadowStrengthLabel;
QvisOpacitySlider *shadowStrengthSlider;
// Labels to display renderer information.
QLabel *scalrenUsingLabel;
......
......@@ -191,6 +191,9 @@ static void RotateAroundY(const avtView3D&, double, avtView3D&);
// Mark C. Miller, Tue Oct 19 20:18:22 PDT 2004
// Added code to manage name of last color table to change
//
// Hank Childs, Sun Oct 24 13:39:57 PDT 2004
// Initialize doShading.
//
// ****************************************************************************
ViewerWindow::ViewerWindow(int windowIndex)
......@@ -309,6 +312,8 @@ ViewerWindow::ViewerWindow(int windowIndex)
//
actionMgr = new ViewerActionManager(this);
doShading = false;
shadingStrength = 0.5;
}
// ****************************************************************************
......@@ -2062,6 +2067,9 @@ ViewerWindow::InvertBackgroundColor()
// Modified scalable rendering controls to use activation mode and auto
// threshold
//
// Hank Childs, Sun Oct 24 13:39:57 PDT 2004
// Add shading.
//
// ****************************************************************************
void
......@@ -2081,6 +2089,7 @@ ViewerWindow::CopyGeneralAttributes(const ViewerWindow *source)
source->GetSpecularCoeff(),
source->GetSpecularPower(),
source->GetSpecularColor());
SetShadingProperties(source->GetDoShading(), source->GetShadingStrength());
//
// Set window mode flags.
......@@ -5001,6 +5010,9 @@ ViewerWindow::SetLargeIcons(bool val)
// Modified scalable rendering controls to use activation mode and auto
// threshold
//
// Hank Childs, Sun Oct 24 13:39:57 PDT 2004
// Add shading.
//
// ****************************************************************************
WindowAttributes
......@@ -5076,6 +5088,10 @@ ViewerWindow::GetWindowAttributes() const
renderAtts.SetSpecularCoeff(GetSpecularCoeff());
renderAtts.SetSpecularPower(GetSpecularPower());
renderAtts.SetSpecularColor(GetSpecularColor());
renderAtts.SetDoShadowing(GetDoShading());
renderAtts.SetShadowStrength(GetShadingStrength());
winAtts.SetRenderAtts(renderAtts);
//
......@@ -5880,6 +5896,68 @@ ViewerWindow::GetSurfaceRepresentation() const
return visWindow->GetSurfaceRepresentation();
}
// ****************************************************************************
// Method: ViewerWindow::GetDoShading
//
// Purpose:
// Returns the window's shading flag.
//
// Arguments:
// none
//
// Programmer: Hank Childs
// Creation: October 24, 2004
//
// ****************************************************************************
bool
ViewerWindow::GetDoShading() const
{
return doShading;
}
// ****************************************************************************
// Method: ViewerWindow::GetShadingStrength
//
// Purpose:
// Returns the window's shading strength.
//
// Arguments:
// none
//
// Programmer: Hank Childs
// Creation: October 24, 2004
//
// ****************************************************************************
double
ViewerWindow::GetShadingStrength() const
{
return shadingStrength;
}
// ****************************************************************************
// Method: ViewerWindow::SetShadingProperties
//
// Purpose:
// Sets the window's shading properites.
//
// Arguments:
// flag : the new shading flag
// str : the new shading strength
//
// Programmer: Hank Childs
// Creation: October 24, 2004
//
// ****************************************************************************
void
ViewerWindow::SetShadingProperties(bool flag, double str)
{
doShading = flag;
shadingStrength = str;
}
// ****************************************************************************
// Method: ViewerWindow::GetSpecularFlag
//
......@@ -6378,6 +6456,9 @@ ViewerWindow::SetPopupEnabled(bool val)
// Kathleen Bonnell, Thu Aug 19 14:23:18 PDT 2004
// Added InteractorAttributes.
//
// Hank Childs, Sun Oct 24 13:39:57 PDT 2004
// Save out shading properties.
//
// ****************************************************************************
void
......@@ -6458,6 +6539,8 @@ ViewerWindow::CreateNode(DataNode *parentNode, bool detailed)
windowNode->AddNode(new DataNode("specularPower", GetSpecularPower()));
ColorAttribute specColor(GetSpecularColor());
specColor.CreateNode(windowNode, true, true);
windowNode->AddNode(new DataNode("doShading", GetDoShading()));
windowNode->AddNode(new DataNode("shadingStrength", GetShadingStrength()));
//
// View
......@@ -6576,6 +6659,9 @@ ViewerWindow::CreateNode(DataNode *parentNode, bool detailed)
// Kathleen Bonnell, Thu Aug 19 14:23:18 PDT 2004
// Added InteractorAttributes.
//
// Hank Childs, Sun Oct 24 13:39:57 PDT 2004
// Read in shading properties.
//
// ****************************************************************************
void
......@@ -6839,6 +6925,24 @@ ViewerWindow::SetFromNode(DataNode *parentNode)
tmpSpecularPower, tmpSpecularColor);
}
numParamsSaved = 0;
bool tmpDoShading = false;
bool tmpShadingStrength = false;
if((node = windowNode->GetNode("doShading")) != 0)
{
tmpDoShading = node->AsBool();
numParamsSaved++;
}
if((node = windowNode->GetNode("shadingStrength")) != 0)
{
tmpShadingStrength = node->AsDouble();
numParamsSaved++;
}
if (numParamsSaved == 2)
{
SetShadingProperties(tmpDoShading, tmpShadingStrength);
}
//
// Read in and set the annotation attributes.
//
......
......@@ -333,6 +333,9 @@ class ViewerToolbar;
// Kathleen Bonnell, Tue Oct 12 16:31:46 PDT 2004
// Added GlyphPick method.
//
// Hank Childs, Sun Oct 24 13:39:57 PDT 2004
// Added shading.
//
// ****************************************************************************
class VIEWER_API ViewerWindow
......@@ -541,6 +544,9 @@ public:
float GetSpecularCoeff() const;
float GetSpecularPower() const;
const ColorAttribute &GetSpecularColor() const;
void SetShadingProperties(bool,double);
bool GetDoShading() const;
double GetShadingStrength() const;
void Lineout(const bool);
......@@ -646,6 +652,11 @@ private:
static bool doNoWinMode;
// Note: since these aren't stored in VisWindow, this seems like a fine
// place to put them. If the shading ever is stored in VisWindow, this
// should be removed.
bool doShading;
double shadingStrength;
};
#endif
......@@ -2388,6 +2388,10 @@ ViewerWindowManager::SetViewExtentsType(avtExtentType viewType,
// Mark C. Miller, Tue May 11 20:21:24 PDT 2004
// Modified calls to set scalable controls to accomdate scalable activaation
// mode and scalable auto threshold
//
// Hank Childs, Sun Oct 24 13:39:57 PDT 2004
// Added shading properties.
//
// ****************************************************************************
void
......@@ -2439,6 +2443,14 @@ ViewerWindowManager::SetRenderingAttributes(int windowIndex)
renderAtts->GetSpecularColor());
}
if (windows[index]->GetDoShading() != renderAtts->GetDoShadowing() ||
windows[index]->GetShadingStrength() !=
renderAtts->GetShadowStrength())
{
windows[index]->SetShadingProperties(renderAtts->GetDoShadowing(),
renderAtts->GetShadowStrength());
}