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


C++ PointLight类代码示例

本文整理汇总了C++中PointLight的典型用法代码示例。如果您正苦于以下问题:C++ PointLight类的具体用法?C++ PointLight怎么用?C++ PointLight使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PointLight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pointLightPass

void Scene::pointLightPass(RenderTarget *target)
{
    if(!this->pointLights.empty ())
    {
        for(int i =0;i<pointLights.size ();i++)
        {
            ShaderProgram * shader = ShaderPool::getInstance ()->get("point_light_pass");
            shader->use ();
            PointLight * light = this->pointLights[i];
            light->apply (shader,0);

            m_quad->setShaderProgram (shader);
            QMatrix4x4 m;
            m.setToIdentity ();
            auto camera = target->camera ();
            shader->setUniformMat4v ("g_MVP_matrix",m.data ());
            shader->setUniform2Float ("g_screen_size",1024,768);
            shader->setUniformInteger ("g_color_map",0);
            shader->setUniformInteger ("g_position_map",1);
            shader->setUniformInteger ("g_normal_map",2);
            shader->setUniform3Float ("g_eye_position",
                                      camera->pos ().x(),
                                      camera->pos ().y(),
                                      camera->pos ().z());
            m_quad->draw (true);
        }
    }
}
开发者ID:HeeroNight,项目名称:Cube-Engine,代码行数:28,代码来源:scene.cpp

示例2: Vector3

Vector3
Lambert::shade(const Ray& ray, const HitInfo& hit, const Scene& scene) const
{
	Vector3 L = Vector3(0.0f, 0.0f, 0.0f);

	const Vector3 viewDir = -ray.d; // d is a unit vector

	const Lights *lightlist = scene.lights();

	// loop over all of the lights
	Lights::const_iterator lightIter;
	for (lightIter = lightlist->begin(); lightIter != lightlist->end(); lightIter++)
	{
		PointLight* pLight = *lightIter;

		Vector3 l = pLight->position() - hit.P;

		// the inverse-squared falloff
		float falloff = l.length2();

		// normalize the light direction
		l /= sqrt(falloff);

		// get the irradiance
		Vector3 irradiance = (pLight->color() * pLight->wattage()) * std::max(0.0f, dot(hit.N, l)) / (4.0 * PI * falloff);

		L += irradiance * (m_kd / PI);
	}

	return L;
}
开发者ID:zanton,项目名称:miro,代码行数:31,代码来源:Lambert.cpp

示例3: makeSponzaScene

void
makeSponzaScene()
{
	g_camera = new Camera;
	g_scene = new Scene;
	g_image = new Image;

	g_image->resize(512, 512);

	// set up the camera
	g_camera->setBGColor(Vector3(0.0f, 0.0f, 0.2f));
	g_camera->setEye(Vector3(8, 1.5, 1));
	g_camera->setLookAt(Vector3(0, 2.5, -1));
	g_camera->setUp(Vector3(0, 1, 0));
	g_camera->setFOV(55);

	// create and place a point light source
	PointLight * light = new PointLight;
	light->setPosition(Vector3(0, 10.0, 0));
	light->setColor(Vector3(1, 1, 1));
	light->setWattage(4.0 * PI * 200);
	g_scene->addLight(light);

	Material* material = new Lambert(Vector3(1.0f));
	TriangleMesh * mesh = new TriangleMesh;
	mesh->load("sponza.obj");
	addMeshTrianglesToScene(mesh, material);
    
	// let objects do pre-calculations if needed
	g_scene->preCalc();
}
开发者ID:whirlp00l,项目名称:PhysicalbasedRendering,代码行数:31,代码来源:assignment1.cpp

示例4: RenderPointDepths

void RenderController::RenderPointLight(PointLightSource *lightSourcePtr) {
	// Implement a solution for the Deferred Renderer Lab
	//RenderPointLightSolution(lightSourcePtr);

	DepthStencilStateManager::GetReference().ApplyState(DepthStencilStateManager::DSS_NoDepth);
	BlendStateManager::GetReference().ApplyState(BlendStateManager::BS_Additive);
	gBufferRT.ActivateSRVs(GBufferStartSlot);
	if ( lightSourcePtr->GetShadows() == EDGameCore::ILight::SOFT ) {
		PointLight *pointLight = lightSourcePtr->GetLightPtr();
		PointLightWithShadow *pointLightWithShadow = (PointLightWithShadow*)pointLight;
		RenderPointDepths(pointLightWithShadow);
		sceneTarget.ActivateTarget();
		sceneTarget.ClearDepthStencilView(D3D11_CLEAR_STENCIL);
		pointLightWithShadow->ActivateShadowTexture();
		pointLightWithShadowsContextHandle.GetContent()->RenderProcess();
		pointLightWithShadow->RevertShadowTexture();
		pointLightWithShadowsContextHandle.GetContent()->ClearRenderSet();

	} else {
		PointLight *pointLight = lightSourcePtr->GetLightPtr();
		pointLight->ApplyLight();
		sceneTarget.ActivateTarget();
		sceneTarget.ClearDepthStencilView(D3D11_CLEAR_STENCIL);
		pointLightContextHandle.GetContent()->RenderProcess();
		pointLightContextHandle.GetContent()->ClearRenderSet();
	}

	gBufferRT.DeactivateSRVs(GBufferStartSlot);
}
开发者ID:paspy,项目名称:FSGameEngine,代码行数:29,代码来源:RenderController.cpp

示例5: Color

/* LOADERS */
void EditorLoader::AddPointLight()
{
	Vector3 look = m_pRenderContext->GetCamera()->GetLook();
	look.Normalize();

	PointLightDesc pDesc;

	pDesc.position = (m_pRenderContext->GetCamera()->GetPosition() + look * 2);

	BYTE r = 180;
	BYTE g = 180;
	BYTE b = 200;
    BYTE a = 255;

	pDesc.color = Color(r, g, b, a);
	pDesc.multiplier = 2.0f;
	pDesc.attenuationStart = 0;
	pDesc.attenuationEnd = 5;
            
	PointLight* pl = new PointLight(pDesc);
	pl->InitEditor();

	m_pRenderContext->GetLightController()->AddLight(pl);

	cout << "Added pointlight\n";
}
开发者ID:BillyKim,项目名称:jello-man,代码行数:27,代码来源:EditorLoader.cpp

示例6: printf

void
Scene::preCalc()
{
    Objects::iterator it;
    for (it = m_objects.begin(); it != m_objects.end(); it++)
    {
        Object* pObject = *it;
        pObject->preCalc();
    }
    Lights::iterator lit;
    float total_wattage = 0.f;
    for (lit = m_lights.begin(); lit != m_lights.end(); lit++)
    {
        PointLight* pLight = *lit;
        pLight->preCalc();
        total_wattage += pLight->wattage();
    }

    m_bvh.build(&m_objects);

    delete g_global_illum_map;
    g_global_illum_map = new Photon_map(m_global_photons);
    delete g_caustics_map;
    g_caustics_map = new Photon_map(m_caustics_photons);
    g_caustics_map->setCaustics(true);

    printf("Caustics map:\n");
    sampleMap(g_caustics_map, m_caustics_photons, total_wattage);
    printf("Global illum map:\n");
    sampleMap(g_global_illum_map, m_global_photons, total_wattage);
}
开发者ID:anhuin69,项目名称:Raytracer,代码行数:31,代码来源:Scene.cpp

示例7: glFinish

void
Scene::raytraceImage(Camera *cam, Image *img)
{
    Ray ray;
    HitInfo hitInfo;
    Vector3 shadeResult;
    bIntersect = 0;
    tIntersect = 0;
    bool useShadows = false;

    // loop over all pixels in the image
    for (int j = 0; j < img->height(); ++j)
    {
        for (int i = 0; i < img->width(); ++i)
        {
            ray = cam->eyeRay(i, j, img->width(), img->height());
            hitInfo.boxHit = 0;
            hitInfo.triHit = 0;
            if (trace(hitInfo, ray))
            {
                // printf("Traced...\n");
                hitInfo.u = i;
                hitInfo.v = j;
                const Material * mat = hitInfo.material;
                shadeResult = mat->shade(ray, hitInfo, *this);
                if (useShadows) {
                    Lights::const_iterator lightIter;
                    ray.o = hitInfo.P;
                    for (lightIter = m_lights.begin(); lightIter != m_lights.end(); lightIter++)
                    {
                        PointLight* pLight = *lightIter;
                        ray.d = pLight->position() - hitInfo.P;
                        ray.d.normalize();
                        ray.o = ray.o + ray.d * epsilon;
                        if (trace(hitInfo, ray)) {
                            if (hitInfo.t > EPSILON) {
                                shadeResult = Vector3(0);
                                break;
                            }
                        }
                    }
                }
                img->setPixel(i, j, shadeResult);
            }
            // bIntersect += hitInfo.boxHit;
            tIntersect += hitInfo.triHit;
            bIntersect += hitInfo.boxHit;
        }
        img->drawScanline(j);
        glFinish();
        // printf("Rendering Progress: %.3f%%\r", j/float(img->height())*100.0f);
        fflush(stdout);
    }

    printf("Rendering Progress: 100.000%\n");
    debug("done Raytracing!\n");
    printStats();
}
开发者ID:klwolfe365,项目名称:cse168,代码行数:58,代码来源:Scene.cpp

示例8:

Light<real>* SceneImporter<real>::ReadPointLight( std::istream& stream, const std::string& name )
{
	PointLight<real>* light = new PointLight<real>;
	light->SetName( name );

	ReadLightHeader( stream, light );

	return light;
}
开发者ID:gnuvince,项目名称:ift3355-tp2,代码行数:9,代码来源:SceneImporter.cpp

示例9: project1

void project1() {
	// Create scene
	Scene scn;
	scn.SetSkyColor(Color(0.8f, 0.9f, 1.0f));

	// Create boxes
    LambertMaterial lambert1;
    lambert1.SetDiffuseColor(Color(0.3f,0.3f,0.3f));

	MeshObject box1;
	box1.MakeBox(5.0f,0.1f,5.0f, &lambert1);
	scn.AddObject(box1);
    
    
    LambertMaterial lambert2;
    lambert2.SetDiffuseColor(Color(0.7f,0.7f,0.7f));
	MeshObject box2;
	box2.MakeBox(1.0f,1.0f,1.0f, &lambert2);
    
	InstanceObject inst1(box2);
	Matrix34 mtx;
	mtx.MakeRotateX(0.5f);
	mtx.d.y=1.0f;
	inst1.SetMatrix(mtx);
	scn.AddObject(inst1);
    
	InstanceObject inst2(box2);
	mtx.MakeRotateY(1.0f);
	mtx.d.Set(-1.0f,0.0f,1.0f);
	inst2.SetMatrix(mtx);
	scn.AddObject(inst2);
    
	// Create lights
	DirectLight sunlgt;
	sunlgt.SetBaseColor(Color(1.0f, 1.0f, 0.9f));
	sunlgt.SetIntensity(0.5f);
	sunlgt.SetDirection(Vector3(-0.5f, -1.0f, -0.5f));
	scn.AddLight(sunlgt);
    
	PointLight redlgt;
	redlgt.SetBaseColor(Color(1.0f, 0.2f, 0.2f));
	redlgt.SetIntensity(2.0f);
	redlgt.SetPosition(Vector3(2.0f, 2.0f, 0.0f));
	scn.AddLight(redlgt);
    
	// Create camera
	Camera cam;
	cam.LookAt(Vector3(2.0f,2.0f,5.0f), Vector3(0.0f,0.0f,0.0f));
	cam.SetResolution(800,600);
	cam.SetFOV(40.0f);
	cam.SetAspect(1.33f);
    
	// Render image
	cam.Render(scn);
	cam.SaveBitmap("project1.bmp");
}
开发者ID:petrosferdinand,项目名称:CSE168,代码行数:56,代码来源:Main.cpp

示例10: pointlightRenderLeave

Action::ResultE ShadingCallbacks::pointlightRenderLeave(CNodePtr &pNode, 
                                                        Action   *action)
{
    PointLight *pPl = dynamic_cast<PointLight *>(pNode.getCPtr());

    if(pPl->getOn() == false)
        return Action::Continue;

    return lightRenderLeave(pPl, action);
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:10,代码来源:OSGShadingCallbacks.cpp

示例11: render

void LegacyRenderer::render(const ICamera<float>& camera, const PointLight<float>& light, const TriangleBuffer& buffer)
{
	const auto& positions = buffer.getPositions().get();// buffers[0].get();
	const auto& normals = buffer.getNormals().get();//buffers[1].get();

	if (positions.empty()) {
		return;
	}

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);

	const auto& projectionMatrix = camera.getProjectionMatrix();
	const auto& modelviewMatrix = camera.getModelviewMatrix();;

	std::vector<float> lightPos = { light.getPos().getX(), light.getPos().getY(), light.getPos().getZ(), 1.0 };
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos.data());
	glLightfv(GL_LIGHT0, GL_DIFFUSE, light.getDiffuse().toArray4().data());
//	glLightfv(GL_LIGHT0, GL_SPECULAR, light.getSpecular().toArray4().data());
	glLightfv(GL_LIGHT0, GL_AMBIENT, white);


	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glLoadMatrixf(projectionMatrix.toArray().data());

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glLoadMatrixf(modelviewMatrix.toArray().data());


	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, yellow);

	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, positions.data());

	glEnableClientState(GL_NORMAL_ARRAY);
	glNormalPointer(GL_FLOAT, 0, normals.data());

	//glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(positions.size()) / 3);
	for (const auto& b : buffer.getBlocks()) {
		const auto& indices = b.getIndices();
		glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(indices.size()), GL_UNSIGNED_INT, indices.data());
	}

	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);

	glDisable(GL_LIGHTING);
	glDisable(GL_LIGHT0);
	glDisable(GL_DEPTH_TEST);

}
开发者ID:SatoshiMabuchi,项目名称:CGLib,代码行数:54,代码来源:LegacyRenderer.cpp

示例12: dir

/*! 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;
    }
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:61,代码来源:OSGDeferredShadingStage.cpp

示例13: EditorPointLight

void MainForm::OnAddPointLight_Click(wxMouseEvent & evt)
{
	PointLightPtr ptr = scene->AddPointLight();
	PointLight * p = ptr.Get();
	p->SetPosition(0.0f, 0.0f, 0.0f);
	p->SetDiffuse(1.0f,1.0f,1.0f,1.0f);
	p->SetRange(100.0f);

	EditorPointLight * pl = new EditorPointLight(ptr);
	EditorSceneObjectsManager::GetPtr()->AddElement(pl);

	ActiveTool::Set(new SelectTool());
}
开发者ID:dgi09,项目名称:D3D,代码行数:13,代码来源:MainForm.cpp

示例14: pointlightRenderEnter

Action::ResultE ShadingCallbacks::pointlightRenderEnter(CNodePtr &pNode, 
                                                        Action   *action)
{
    PointLight *pPl = dynamic_cast<PointLight *>(pNode.getCPtr());

    if(pPl->getOn() == false)
        return Action::Continue;

    DrawActionBase *da    = dynamic_cast<DrawActionBase *>(action);

    da->getStatistics()->getElem(PointLight::statNPointLights)->inc();

    return lightRenderEnter(pPl, action);
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:14,代码来源:OSGShadingCallbacks.cpp

示例15: Entity

Entity* BlenderSceneExporter::instantiatePointLight( const TamyLight& exportedLightEntity )
{
   Entity* lightEntity = new Entity( exportedLightEntity.name );
   PointLight* light = new PointLight();
   lightEntity->addChild( light );

   light->m_color = exportedLightEntity.lightColor;
   light->m_strength = exportedLightEntity.energy;
   light->m_radius = exportedLightEntity.distance;
   light->m_falloff = exportedLightEntity.quadraticAttenuation;
   light->setShadowsCaster( exportedLightEntity.castShadows );

   return lightEntity;
}
开发者ID:dabroz,项目名称:Tamy,代码行数:14,代码来源:BlenderSceneExporter.cpp


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