本文整理汇总了C++中PointLight::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ PointLight::getPosition方法的具体用法?C++ PointLight::getPosition怎么用?C++ PointLight::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointLight
的用法示例。
在下文中一共展示了PointLight::getPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyLight
void OpenGLShaderPointLight::copyLight(PointLight &light)
{
setParamValue("position", light.getPosition());
setParamValue("ambient", light.getAmbient());
setParamValue("diffuse", light.getDiffuse());
setParamValue("specular", light.getSpecular());
setParamValue("attenuation", light.getAttenuation());
setParamValue("cutoff", light.getCutoff());
bind();
}
示例2: updateLightChunk
/*! Sets the \a lightChunk fields based on light.
\dev
DeferredShadingStage can not use the light's own chunk, because
it computes the light position based on DrawEnv::getCameraViewing(),
which is just the ortho camera for rendering the full screen quads, not
the perspective camera used during the gbuffer pass.
\enddev
*/
void DeferredShadingStage::updateLightChunk(
DSLightChunk *lightChunk, Light *light)
{
lightChunk->setBeacon (light->getBeacon ());
lightChunk->setAmbient (light->getAmbient ());
lightChunk->setDiffuse (light->getDiffuse ());
lightChunk->setSpecular(light->getSpecular());
if(light->getType() == DirectionalLight::getClassType())
{
DirectionalLight *dirL = static_cast<DirectionalLight *>(light);
Vec4f dir(dirL->getDirection());
dir[3] = 0.f;
lightChunk->setPosition(dir);
}
else if(light->getType() == PointLight::getClassType())
{
PointLight *pointL = static_cast<PointLight *>(light);
Vec4f pos(pointL->getPosition());
pos[3] = 1.f;
lightChunk->setPosition (pos );
lightChunk->setConstantAttenuation (pointL->getConstantAttenuation ());
lightChunk->setLinearAttenuation (pointL->getLinearAttenuation ());
lightChunk->setQuadraticAttenuation(pointL->getQuadraticAttenuation());
lightChunk->setCutoff (180.f );
}
else if(light->getType() == SpotLight::getClassType())
{
SpotLight *spotL = static_cast<SpotLight *>(light);
Vec4f pos(spotL->getPosition());
pos[3] = 1.f;
lightChunk->setPosition (pos );
lightChunk->setConstantAttenuation (spotL->getConstantAttenuation ());
lightChunk->setLinearAttenuation (spotL->getLinearAttenuation ());
lightChunk->setQuadraticAttenuation(spotL->getQuadraticAttenuation());
lightChunk->setDirection (spotL->getDirection ());
lightChunk->setExponent (spotL->getSpotExponent ());
lightChunk->setCutoff (
osgRad2Degree(spotL->getSpotCutOff()));
}
else
{
SWARNING << "DeferredShadingStage::updateLightChunk: "
<< "Unknown light type." << endLog;
}
}
示例3: createShadowMapsFBO
void VarianceShadowMapHandler::createShadowMapsFBO(RenderAction *a,
DrawEnv *pEnv)
{
UInt32 mSize = _pStage->getMapSize();
if(mSize > 2048)
mSize = 2048;
//------Setting up Window to fit size of ShadowMap----------------
// disable all lights more speed
std::vector<bool> vLocalLightStates;
const ShadowStageData::LightStore &vLights =
_pStageData->getLights();
const ShadowStageData::LStateStore &vLightStates =
_pStageData->getLightStates();
const ShadowStageData::CamStore &vLCams =
_pStageData->getLightCameras();
const ShadowStageData::StatusStore &vExclActive =
_pStageData->getExcludeNodeActive();
for(UInt32 i = 0;i < vLights.size();++i)
{
// store old states.
vLocalLightStates.push_back(vLights[i].second->getOn());
vLights[i].second->setOn(false);
}
// activate exclude nodes:
for(UInt32 i = 0;i < _pStage->getMFExcludeNodes()->size();++i)
{
Node *exnode = _pStage->getExcludeNodes(i);
if(exnode != NULL)
{
if(vExclActive[i])
{
exnode->setTravMask(0);
}
}
}
UInt32 uiActiveLightCount = 0;
ShadowStageData::ShadowMapStore &vShadowMaps = _pStageData->getShadowMaps();
for(UInt32 i = 0;i < vLights.size();++i)
{
if(vLightStates[i] != 0)
{
if(_pStage->getGlobalShadowIntensity() != 0.0 ||
vLights[i].second->getShadowIntensity() != 0.0)
{
GLenum *buffers = NULL;
buffers = new GLenum[1];
buffers[0] = GL_COLOR_ATTACHMENT0_EXT;
Pnt3f lPos;
bool isDirLight;
Real32 sceneDiagLength;
if(vLights[i].second->getType() == PointLight::getClassType())
{
PointLight *tmpPoint;
tmpPoint =
dynamic_cast<PointLight *>(vLights[i].second.get());
lPos = tmpPoint->getPosition();
if(tmpPoint->getBeacon() != NULL)
{
Matrix m = tmpPoint->getBeacon()->getToWorld();
m.mult(lPos, lPos);
}
isDirLight = false;
Pnt3f center;
_pStageData->getLightRoot(i)->getVolume().getCenter(center);
Vec3f dir = lPos - center;
Real32 dirLength = dir.length();
Vec3f diff =
(_pStageData->getLightRoot(i)->getVolume().getMax() -
center);
Real32 diffLength = diff.length();
sceneDiagLength = dirLength + diffLength;
}
else if(vLights[i].second->getType() ==
SpotLight::getClassType())
{
SpotLight *tmpSpot;
//.........这里部分代码省略.........
示例4: createShadowFactorMapFBO
//.........这里部分代码省略.........
Real32 texFactor;
if(vLights[num].second->getType() == SpotLight ::getClassType() ||
vLights[num].second->getType() == PointLight::getClassType())
{
texFactor = Real32(_width) / Real32(_height);
}
else
{
texFactor = 1.0;
}
Matrix shadowMatrix = LPM;
shadowMatrix.mult(LVM);
shadowMatrix.mult(iCVM);
Matrix shadowMatrix2 = LVM;
shadowMatrix2.mult(iCVM);
Real32 xFactor = 1.0;
Real32 yFactor = 1.0;
Pnt3f lPos;
bool isDirLight;
Real32 sceneDiagLength;
if(vLights[num].second->getType() == PointLight::getClassType())
{
PointLight *tmpPoint;
tmpPoint = dynamic_cast<PointLight *>(
vLights[num].second.get());
lPos = tmpPoint->getPosition();
if(tmpPoint->getBeacon() != NULL)
{
Matrix m = tmpPoint->getBeacon()->getToWorld();
m.mult(lPos, lPos);
}
isDirLight = false;
Pnt3f center;
_pStageData->getLightRoot(num)->getVolume().getCenter(center);
Vec3f dir = lPos - center;
Real32 dirLength = dir.length();
Vec3f diff = (_pStageData->getLightRoot(num)->getVolume
().getMax() - center);
Real32 diffLength = diff.length();
sceneDiagLength = dirLength + diffLength;
}
else if(vLights[num].second->getType() == SpotLight::getClassType())
{
SpotLight *tmpSpot;
tmpSpot = dynamic_cast<SpotLight *>(
vLights[num].second.get());
lPos = tmpSpot->getPosition();
if(tmpSpot->getBeacon() != NULL)
{
示例5: setupLightChunk
void VRShadowEngine::setupLightChunk(Light *pLight,
LightTypeE eType,
RenderAction *pAction,
EngineDataPtr pEngineData)
{
if(eType == Directional)
{
DirectionalLight *pDLight =
dynamic_cast<DirectionalLight *>(pLight);
LightChunkUnrecPtr pChunk = pEngineData->getLightChunk();
if(pChunk == NULL)
{
pChunk = LightChunk::createLocal();
pEngineData->setLightChunk(pChunk);
}
Color4f tmpVal(0.0, 0.0, 0.0, 1.0);
pChunk->setSpecular(tmpVal);
tmpVal.setValuesRGBA(0.2f, 0.2f, 0.2f, 1.0f);
pChunk->setDiffuse (tmpVal);
tmpVal.setValuesRGBA(0.0, 0.0, 0.0, 1.0);
pChunk->setAmbient (tmpVal);
Vec4f dir(pDLight->getDirection());
dir[3] = 0;
pChunk->setPosition(dir);
pChunk->setBeacon(pLight->getBeacon());
}
else if(eType == Point)
{
PointLight *pPLight = dynamic_cast<PointLight *>(pLight);
LightChunkUnrecPtr pChunk = pEngineData->getLightChunk();
if(pChunk == NULL)
{
pChunk = LightChunk::createLocal();
pEngineData->setLightChunk(pChunk);
}
Color4f tmpVal(0.0, 0.0, 0.0, 1.0);
pChunk->setSpecular(tmpVal);
tmpVal.setValuesRGBA(this->getShadowColor()[0],
this->getShadowColor()[1],
this->getShadowColor()[2],
this->getShadowColor()[3]);
pChunk->setDiffuse (tmpVal);
tmpVal.setValuesRGBA(0.0, 0.0, 0.0, 1.0);
pChunk->setAmbient (tmpVal);
Vec4f pos(pPLight->getPosition());
pos[3] = 1;
pChunk->setPosition(pos);
pChunk->setBeacon(pLight->getBeacon());
}
}
示例6: setupCamera
void VRShadowEngine::setupCamera(Light *pLight,
LightTypeE eType,
RenderAction *pAction,
EngineDataPtr pEngineData)
{
if(eType == Directional)
{
DirectionalLight *pDLight =
dynamic_cast<DirectionalLight *>(pLight);
MatrixCameraUnrecPtr pCam =
dynamic_cast<MatrixCamera *>(pEngineData->getCamera());
if(pCam == NULL)
{
pCam = MatrixCamera::createLocal();
pEngineData->setCamera(pCam);
}
Vec3f diff;
Pnt3f center;
Matrix transMatrix;
Node *pNode = pAction->getActNode();
// tmpDir = DirectionalLightPtr::dcast(_lights[i]);
diff = (pNode->getVolume().getMax() -
pNode->getVolume().getMin());
Real32 sceneWidth = diff.length() * 0.5f;
// Not final values. May get tweaked in the future
Real32 sceneHeight = diff.length() * 0.5f;
pNode->getVolume().getCenter(center);
Vec3f lightdir = pDLight->getDirection();
if(pLight->getBeacon() != NULL)
{
Matrix m = pLight->getBeacon()->getToWorld();
m.mult(lightdir, lightdir);
}
MatrixLookAt(transMatrix,
center + lightdir,
center,
Vec3f(0,1,0));
transMatrix.invert();
Matrix proMatrix;
proMatrix.setIdentity();
MatrixOrthogonal( proMatrix,
-sceneWidth, sceneWidth, -sceneHeight,
sceneHeight, -sceneWidth, sceneWidth);
pCam->setProjectionMatrix(proMatrix );
pCam->setModelviewMatrix (transMatrix);
}
else if(eType == Point)
{
PointLight *pPLight = dynamic_cast<PointLight *>(pLight);
MatrixCameraUnrecPtr pCam =
dynamic_cast<MatrixCamera *>(pEngineData->getCamera());
if(pCam == NULL)
{
pCam = MatrixCamera::createLocal();
pEngineData->setCamera(pCam);
}
Real32 angle;
Vec3f dist;
Pnt3f center;
Vec3f diff;
Matrix transMatrix;
Node *pNode = pAction->getActNode();
pNode->getVolume().getCenter(center);
Pnt3f lightpos = pPLight->getPosition();
if(pLight->getBeacon() != NULL)
{
Matrix m = pLight->getBeacon()->getToWorld();
m.mult(lightpos, lightpos);
}
//.........这里部分代码省略.........