本文整理汇总了C++中LightPtr类的典型用法代码示例。如果您正苦于以下问题:C++ LightPtr类的具体用法?C++ LightPtr怎么用?C++ LightPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LightPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: motion
void motion(int x, int y)
{
if (moving_eye) {
scene->view.spinDegrees(-0.2*(x-begin_x));
scene->view.lift(0.02*(y-begin_y));
glutPostRedisplay();
begin_x = x;
begin_y = y;
}
if (moving_light) {
LightPtr light = scene->light_list[0];
light->spinDegrees(0.2*(x-begin_light_x));
light->lift(-0.02*(y-begin_light_y));
glutPostRedisplay();
begin_light_x = x;
begin_light_y = y;
}
if (spin_object) {
trackball(lastquat,
(2.0 * begin_spin_x - window_widthf) / window_widthf,
(window_heightf - 2.0 * begin_spin_y) / window_heightf,
(2.0 * x - window_widthf) / window_widthf,
(window_heightf - 2.0 * y) / window_heightf
);
begin_spin_x = x;
begin_spin_y = y;
animate_object_spinning = true;
glutIdleFunc(spin_animate);
}
}
示例2: createInstance
GameObjectPtr LightType::createInstance(void)
{
LightPtr newLight = new Light;
if(!newLight)
return(nullptr);
newLight->init(true, this);
return(newLight);
}
示例3: get_lights_in_screen
void LightNode::get_lights_in_screen(Containers::Vector<LightPtr>& out_list, const CameraApiPtr& camera) const
{
for (unsigned int i = 0; i < m_entities.size(); i++)
{
LightPtr curr = ness_ptr_cast<Light>(m_entities[i]);
if (curr->is_really_visible_const(camera))
{
out_list.push_back(curr);
}
}
}
示例4: GetNextAffectingLight
void LightManager::RenderLights()
{
LightPtr pLight = GetNextAffectingLight(LightPtr(), ViewFrustum());
while(pLight)
{
if(pLight->GetEnabled())
{
pLight->RenderLight(m_pRenderSystem);
}
pLight = GetNextAffectingLight(pLight, ViewFrustum());
}
}
示例5: GetNextAffectingLight
void LightManager::RenderShadowMaps(CameraPtr pCamera)
{
LightPtr pLight = GetNextAffectingLight(LightPtr(), pCamera->GetViewFrustum());
while(pLight)
{
if(pLight->GetCastShadow())
{
pLight->RenderShadowMap(m_pRenderManager);
}
pLight = GetNextAffectingLight(pLight, pCamera->GetViewFrustum());
}
}
示例6: while
void LightManager::Release()
{
LightPtr pNode = m_pList;
while(pNode)
{
LightPtr pDel = pNode;
pNode = pNode->m_pNext;
pDel->m_pNext = LightPtr();
pDel->m_pPrev = LightPtr();
pDel->Release();
}
m_pList.reset();
}
示例7: GetNextLight
LightPtr LightManager::GetNextAffectingLight(LightPtr pLight, const ViewFrustum& frustum)
{
LightPtr pNode = GetNextLight(pLight);
while(pNode)
{
if(pNode->IsAffecting(frustum))
{
return pNode;
}
pNode = GetNextLight(pNode);
}
return pNode;
}
示例8: addLight
void GraphicsView::addLight(LightPtr light)
{
if (!light) return;
lightList_.push_back(light);
light->initializeConfiguration();
}
示例9: render
void render( const RenderInput& renderInput,
RenderOutput& renderOutput )
{
reshape( renderInput.windowSize );
_engine->preRender();
_engine->getCamera()->set(
renderInput.position, renderInput.target, renderInput.up );
#if(BRAYNS_USE_DEFLECT || BRAYNS_USE_REST)
if( !_extensionPluginFactory )
_intializeExtensionPluginFactory( );
_extensionPluginFactory->execute( );
#endif
ScenePtr scene = _engine->getScene();
CameraPtr camera = _engine->getCamera();
FrameBufferPtr frameBuffer = _engine->getFrameBuffer();
const Vector2i& frameSize = frameBuffer->getSize();
if( _parametersManager->getRenderingParameters().getSunOnCamera() )
{
LightPtr sunLight = scene->getLight( 0 );
DirectionalLight* sun =
dynamic_cast< DirectionalLight* > ( sunLight.get() );
if( sun )
{
sun->setDirection( camera->getTarget() - camera->getPosition() );
scene->commitLights();
}
}
camera->commit();
_render( );
uint8_t* colorBuffer = frameBuffer->getColorBuffer( );
size_t size =
frameSize.x( ) * frameSize.y( ) * frameBuffer->getColorDepth( );
renderOutput.colorBuffer.assign( colorBuffer, colorBuffer + size );
float* depthBuffer = frameBuffer->getDepthBuffer( );
size = frameSize.x( ) * frameSize.y( );
renderOutput.depthBuffer.assign( depthBuffer, depthBuffer + size );
_engine->postRender();
}
示例10: handleEvents
bool handleEvents(Window &wnd, LightPtr light)
{
Event evt;
while (wnd.pollEvent(evt))
{
switch(evt.type)
{
case Event::Closed:
return true;
break;
case Event::KeyPressed:
switch(evt.key.code)
{
case Keyboard::Escape:
return true;
break;
case Keyboard::F1:
DemoSettings::DrawOccluders = !DemoSettings::DrawOccluders;
break;
case Keyboard::F2:
DemoSettings::EnableLightsDebugDraw = !DemoSettings::EnableLightsDebugDraw;
break;
case Keyboard::F3:
DemoSettings::EnableShadowsOutline = !DemoSettings::EnableShadowsOutline;
break;
}
break;
case Event::MouseMoved:
if (DemoSettings::EnableManualLight || DemoSettings::EnableOnlyManualLight)
light->setPosition(Vector2f(static_cast<float>(evt.mouseMove.x),
static_cast<float>(evt.mouseMove.y)));
break;
case Event::MouseWheelMoved:
if (DemoSettings::EnableManualLight || DemoSettings::EnableOnlyManualLight)
light->getRadius() += evt.mouseWheel.delta * DemoSettings::WheelFactorToLightRad;
break;
}
}
return false;
}
示例11: initGraphics
void initGraphics()
{
trackball(curquat, 0.0, 0.0, 0.0, 0.0);
#ifdef __APPLE__
// Seems to be needed on Apple platforms using Intel
// integrated graphics but not elsewhere
// If you're getting unexpected seg faults on Apple,
// comment this out and recompile
// If you're not seeing the mesh on a Windows box that
// uses Intel integrated graphics, try enabling this
// for your machine
glEnableClientState(GL_COLOR_ARRAY);
#endif
glEnableClientState(GL_VERTEX_ARRAY);
glEnable(GL_DEPTH_TEST);
glPixelStorei(GL_PACK_ALIGNMENT, 1); // avoid GL's dumb default of 4
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // avoid GL's dumb default of 4
glClearColor(0.1, 0.1, 0.2, 0.0);
scene = ScenePtr(new Scene(Camera(40, 1, 0.1, 100),
View(eye_vector,
at_vector,
up_vector)));
material = MaterialPtr(new Material());
// A little hacky - pick initial values from menu items
materialMenu(0);
bumpyMenu(0);
decalMenu(0);
envMapMenu(0);
Mesh2DPtr mesh2d = Mesh2DPtr(new Mesh2D(float2(0,0), float2(1,1), int2(4,4)));
TorusPtr torus = TorusPtr(new Torus(Transform(), material));
scene->addObject(torus);
light = LightPtr(new Light());
light->setCenter(float3(0,0,0));
light->setRadius(3.5);
light->setAngleInDegrees(60.0);
// A little hacky - pick initial value from menu item
lightMenu(1);
scene->addLight(light);
}
示例12: outputLight
bool outputLight( const ScenePlug *scene, const ScenePlug::ScenePath &path, IECore::Renderer *renderer )
{
IECore::ConstLightPtr constLight = runTimeCast<const IECore::Light>( scene->object( path ) );
if( !constLight )
{
return false;
}
if( !visible( scene, path ) )
{
/// \todo Since both visible() and fullAttributes() perform similar work,
/// we may want to combine them into one query if we see this function
/// being a significant fraction of render time. Maybe something like
/// `fullAttributes( returnNullIfInvisible = true )`? It probably also
/// makes sense to migrate all the convenience functions from ScenePlug
/// into SceneAlgo.
return false;
}
ConstCompoundObjectPtr attributes = scene->fullAttributes( path );
const M44f transform = scene->fullTransform( path );
std::string lightHandle;
ScenePlug::pathToString( path, lightHandle );
LightPtr light = constLight->copy();
light->setHandle( lightHandle );
{
AttributeBlock attributeBlock( renderer );
renderer->setAttribute( "name", new StringData( lightHandle ) );
outputAttributes( attributes.get(), renderer );
renderer->concatTransform( transform );
light->render( renderer );
}
renderer->illuminate( lightHandle, true );
return true;
}
示例13: setLightSettings
void SkyBackgroundPluginForm::setLightSettings( LightPtr light, LightSettingsHandler &handler )
{
beginEditCP(light);
light->setAmbient(handler.ambient);
light->setDiffuse(handler.diffuse);
light->setSpecular(handler.specular);
endEditCP(light);
NodePtr beacon = light->getBeacon();
if (beacon == NullFC)
{
TransformPtr beaconTransform = Transform::create();
beacon = Node::create();
beginEditCP(beacon);
beacon->setCore(beaconTransform);
endEditCP(beacon);
}
TransformPtr transform = TransformPtr::dcast(beacon->getCore());
if (transform == NullFC)
{
TransformPtr beaconTransform = Transform::create();
beginEditCP(beacon);
beacon->setCore(beaconTransform);
endEditCP(beacon);
transform = beaconTransform;
}
Matrix m;
float transFactor = LightDistanceExSlider->value();
Vec3f translate = Vec3f(handler.direction.x() * transFactor, handler.direction.y() * transFactor,
handler.direction.z() * transFactor);
if (zUpCheckBox->isChecked())
m.setTranslate(translate.x(), translate.y(), translate.z());
else
m.setTranslate(translate.x(), translate.z(), -translate.y());
beginEditCP(transform);
transform->setMatrix(m);
endEditCP(transform);
}
示例14: outputLights
void Render::outputLights( const ScenePlug *scene, const IECore::CompoundObject *globals, IECore::Renderer *renderer ) const
{
const CompoundData *forwardDeclarations = globals->member<CompoundData>( "gaffer:forwardDeclarations" );
if( !forwardDeclarations )
{
return;
}
CompoundDataMap::const_iterator it, eIt;
for( it = forwardDeclarations->readable().begin(), eIt = forwardDeclarations->readable().end(); it != eIt; it++ )
{
const CompoundData *declaration = runTimeCast<const CompoundData>( it->second.get() );
if( !declaration )
{
continue;
}
const IECore::TypeId type = (IECore::TypeId)declaration->member<IntData>( "type", true )->readable();
if( type != IECore::LightTypeId )
{
continue;
}
ScenePlug::ScenePath path;
ScenePlug::stringToPath( it->first.string(), path );
IECore::ConstLightPtr constLight = runTimeCast<const IECore::Light>( scene->object( path ) );
if( !constLight )
{
continue;
}
ConstCompoundObjectPtr attributes = scene->fullAttributes( path );
const BoolData *visibilityData = attributes->member<BoolData>( "gaffer:visibility" );
if( visibilityData && !visibilityData->readable() )
{
continue;
}
M44f transform = scene->fullTransform( path );
LightPtr light = constLight->copy();
light->setHandle( it->first.string() );
{
AttributeBlock attributeBlock( renderer );
renderer->setAttribute( "name", new StringData( it->first ) );
CompoundObject::ObjectMap::const_iterator aIt, aeIt;
for( aIt = attributes->members().begin(), aeIt = attributes->members().end(); aIt != aeIt; aIt++ )
{
if( const Data *attribute = runTimeCast<const Data>( aIt->second.get() ) )
{
renderer->setAttribute( aIt->first.string(), attribute );
}
}
renderer->concatTransform( transform );
light->render( renderer );
}
renderer->illuminate( light->getHandle(), true );
}
}
示例15: MainLoop
void MainLoop()
{
static bool isInitilized = false;
static Transform objectTrans;
static Transform cameraTrans;
static TransformController objectCtrl;
static MeshWrapper<Vertex> meshW;
static ShaderPtr forwardBaseShader;
static ShaderPtr forwardAdditionShader;
static LightPtr lightRed;
static LightPtr lightBlue;
if (!isInitilized)
{
isInitilized = true;
auto camera = CameraPtr(new Camera());
camera->SetPerspective(60.f, 1.33333f, 0.3f, 2000.f);
camera->transform.position = Vector3(0.f, 0.f, -2.f);
SoftRender::camera = camera;
lightRed = LightPtr(new Light());
lightRed->type = Light::LightType_Point;
lightRed->color = Color::red;
lightRed->transform.position = Vector3(-0.5f, 1.f, 0.f);
lightRed->transform.rotation = Quaternion(Vector3(90.f,0.f, 0.f));
lightRed->intensity = 2.f;
lightRed->range = 5.f;
lightRed->atten0 = 0.1f;
lightRed->atten1 = 5.0f;
lightRed->atten2 = 2.0f;
lightRed->theta = 30.f;
lightRed->phi = 45.f;
lightRed->Initilize();
lightBlue = LightPtr(new Light());
lightBlue->type = Light::LightType_Point;
lightBlue->color = Color::blue;
lightBlue->transform.position = Vector3(0.5f, 1.f, 0.f);
lightBlue->transform.rotation = Quaternion(Vector3(90.f, 0.f, 0.f));
lightBlue->intensity = 3.f;
lightBlue->range = 5.f;
lightBlue->atten0 = 0.1f;
lightBlue->atten1 = 5.0f;
lightBlue->atten2 = 2.0f;
lightBlue->theta = 30.f;
lightBlue->phi = 45.f;
lightBlue->Initilize();
auto shader0 = std::make_shared<ForwardBaseShader>();
forwardBaseShader = shader0;
auto shader1 = std::make_shared<ForwardAdditionShader>();
forwardAdditionShader = shader1;
std::vector<MeshPtr> meshes;
meshes.push_back(CreatePlane());
objectTrans.position.y = 0.f;
meshW.vertices.clear();
meshW.indices.clear();
for (int meshID = 0; meshID < (int)meshes.size(); ++meshID)
{
auto& mesh = meshes[meshID];
int meshOffset = (int)meshW.vertices.size();
int vertexCount = mesh->GetVertexCount();
int indexCount = mesh->indices.size();
for (int i = 0; i < vertexCount; ++i)
{
meshW.vertices.emplace_back(Vertex{ mesh->vertices[i], mesh->normals[i] });
}
for (int i = 0; i < indexCount; ++i)
{
meshW.indices.emplace_back(mesh->indices[i] + meshOffset);
}
}
}
SoftRender::Clear(true, true, Color(1.f, 0.19f, 0.3f, 0.47f));
objectCtrl.MouseRotate(objectTrans, false);
SoftRender::modelMatrix = objectTrans.localToWorldMatrix();
SoftRender::renderData.AssignVertexBuffer(meshW.vertices);
SoftRender::renderData.AssignIndexBuffer(meshW.indices);
SoftRender::light = lightRed;
SoftRender::renderState.alphaBlend = false;
SoftRender::SetShader(forwardBaseShader);
SoftRender::Submit();
SoftRender::light = lightBlue;
SoftRender::renderState.alphaBlend = true;
SoftRender::renderState.srcFactor = RenderState::BlendFactor_One;
SoftRender::renderState.dstFactor = RenderState::BlendFactor_One;
SoftRender::SetShader(forwardAdditionShader);
SoftRender::Submit();
SoftRender::Present();
}