当前位置: 首页>>代码示例>>C++>>正文


C++ LightPtr类代码示例

本文整理汇总了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);
    }
}
开发者ID:BrettKercher,项目名称:Shader,代码行数:33,代码来源:main.cpp

示例2: createInstance

GameObjectPtr LightType::createInstance(void)
{
	LightPtr newLight = new Light;
	if(!newLight)
		return(nullptr);
	newLight->init(true, this);
	return(newLight);
}
开发者ID:BobrDobr69,项目名称:mechcommander2,代码行数:8,代码来源:light.cpp

示例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);
			}
		}
	}
开发者ID:RonenNess,项目名称:ness-engine,代码行数:11,代码来源:light_node.cpp

示例4: GetNextAffectingLight

	void LightManager::RenderLights()
	{
		LightPtr pLight = GetNextAffectingLight(LightPtr(), ViewFrustum());
		while(pLight)
		{
			if(pLight->GetEnabled())
			{
				pLight->RenderLight(m_pRenderSystem);
			}
			pLight = GetNextAffectingLight(pLight, ViewFrustum());
		}
	}
开发者ID:lythm,项目名称:orb3d,代码行数:12,代码来源:LightManager.cpp

示例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());
		}
	}
开发者ID:johndragon,项目名称:ld3d,代码行数:12,代码来源:LightManager.cpp

示例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();
	}
开发者ID:lythm,项目名称:orb3d,代码行数:15,代码来源:LightManager.cpp

示例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;
	}
开发者ID:lythm,项目名称:orb3d,代码行数:15,代码来源:LightManager.cpp

示例8: addLight

void GraphicsView::addLight(LightPtr light)
{
	if (!light) return;

	lightList_.push_back(light);
	light->initializeConfiguration();
}
开发者ID:tsumeguruma,项目名称:TinyGraphicsLibrary,代码行数:7,代码来源:GraphicsView.cpp

示例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();
    }
开发者ID:helloweishi,项目名称:Brayns,代码行数:47,代码来源:Brayns.cpp

示例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;
}
开发者ID:IrmatDen,项目名称:sfge,代码行数:47,代码来源:main.cpp

示例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);
}
开发者ID:BrettKercher,项目名称:Shader,代码行数:45,代码来源:main.cpp

示例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;
}
开发者ID:CRiant,项目名称:gaffer,代码行数:43,代码来源:RendererAlgo.cpp

示例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);
}
开发者ID:ufz-vislab,项目名称:vislab,代码行数:39,代码来源:SkyBackgroundPluginForm.cpp

示例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 );
	}
}
开发者ID:7on7on,项目名称:gaffer,代码行数:65,代码来源:Render.cpp

示例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();
}
开发者ID:qq573011406,项目名称:softrender,代码行数:98,代码来源:main.cpp


注:本文中的LightPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。