本文整理汇总了C++中LightList::NumLights方法的典型用法代码示例。如果您正苦于以下问题:C++ LightList::NumLights方法的具体用法?C++ LightList::NumLights怎么用?C++ LightList::NumLights使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LightList
的用法示例。
在下文中一共展示了LightList::NumLights方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glPushAttrib
void
avtOpenGL3DTextureVolumeRenderer::Render(
const avtVolumeRendererImplementation::RenderProperties &props,
const avtVolumeRendererImplementation::VolumeData &volume)
{
static bool haveIssuedWarning = false;
#ifdef HAVE_LIBGLEW
if(!(avt::glew::supported("GL_VERSION_1_2") ||
avt::glew::supported("GL_EXT_texture3D")))
#endif
{
if(!haveIssuedWarning)
{
avtCallback::IssueWarning("Volume rendering based on 3D textures "
"is not supported on your GPU.");
haveIssuedWarning = true;
}
return;
}
// save state of what we will modify
glPushAttrib(GL_COLOR_BUFFER_BIT|GL_TEXTURE_BIT|
GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT);
// Get the transfer function
int ncolors=256;
int nopacities=256;
unsigned char rgba[256*4];
props.atts.GetTransferFunction(rgba);
// Get the dimensions
int dims[3];
vtkRectilinearGrid *grid = (vtkRectilinearGrid *)volume.grid;
grid->GetDimensions(dims);
int nx=dims[0];
int ny=dims[1];
int nz=dims[2];
// Find the smallest power of two in each dimension
// that will accomodate this data set
int newnx = MAX(int(pow(2.0,1+int(log(double(nx-1))/log(2.0)))),1);
int newny = MAX(int(pow(2.0,1+int(log(double(ny-1))/log(2.0)))),1);
int newnz = MAX(int(pow(2.0,1+int(log(double(nz-1))/log(2.0)))),1);
// Get the new lighting parameters
LightList lights = avtCallback::GetCurrentLightList();
// Determine if we need to invalidate the old texture
if (volumetex && (props.atts != oldAtts || lights != oldLights))
{
glDeleteTextures(1, (GLuint*)&volumetexId);
volumetexId = 0;
delete[] volumetex;
volumetex = NULL;
}
oldAtts = props.atts;
oldLights = lights;
//
// Extract the lighting information from the actual light list
//
float light[4] = {0,0,1, 0};
float ambient = 0.0;
// Find an ambient light
int i;
for (i=0; i<lights.NumLights(); i++)
{
const LightAttributes &l = lights.GetLight(i);
if (l.GetEnabledFlag() && l.GetType()==LightAttributes::Ambient)
{
// Take it's overall brightness
double rgba[4];
l.GetColor().GetRgba(rgba);
ambient = l.GetBrightness() * (rgba[0]+rgba[1]+rgba[2])/3.;
break;
}
}
// Find a directional (object or camera) light
for (i=0; i<lights.NumLights(); i++)
{
const LightAttributes &l = lights.GetLight(i);
if (l.GetEnabledFlag() && l.GetType()!=LightAttributes::Ambient)
{
// Take it's direction
const double *dir = l.GetDirection();
light[0] = dir[0];
light[1] = dir[1];
light[2] = dir[2];
break;
}
}
// If we want to transform the light so it is attached to the camera:
//I->MultiplyPoint(light, light);
//.........这里部分代码省略.........