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


C++ Sphere::SetLightIntensity方法代码示例

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


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

示例1: setupScene

void setupScene()
{
	raytracer = new Raytracer();

	cam = new Camera();
	cam->MoveTo(Vector(0.0f, 0.5f, 5.0f));
	cam->LookAt(Vector(0.0f, -1.0f, 0.5f));
	raytracer->SetCamera(cam);

	target = new RenderSurface(SCREEN_WIDTH, SCREEN_HEIGHT);
	raytracer->SetTarget(target);

	raytracer->SetProgressUpdater(new PercentMonitor());

	scene = new Scene(8);

	SDFScene *sdf = new SDFScene();
	sdf->GetMaterial().SetColor(Color::white);
	sdf->GetMaterial().SetDiffuse(1.0f);
	sdf->GetMaterial().SetSpecular(0.0f);
	scene->AddObject(sdf);

	Sphere *light = new Sphere(Vector(-4.0f, 4.0f, 3.0f), 1.0f);
	light->SetLight(true);
	light->SetLightIntensity(1.0f);
	light->GetMaterial().SetColor(Color::white);
	scene->AddObject(light);

	Sphere *ball = new Sphere(Vector(0.0f, 0.5f, 0.0f), 1.5f);
	ball->GetMaterial().SetColor(Color::white);
	ball->GetMaterial().SetDiffuse(0.0f);
	ball->GetMaterial().SetReflectivity(1.0f);
	scene->AddObject(ball);

   Sphere *r = new Sphere(Vector(-2.0f, -1.5f, 2.0f), 0.5f);
   r->GetMaterial().SetColor(Color::red);
   r->GetMaterial().SetDiffuse(1.0f);
   r->GetMaterial().SetSpecular(1.0f);
   scene->AddObject(r);

   Sphere *g = new Sphere(Vector(0.0f, -1.5f, 2.0f), 0.5f);
   g->GetMaterial().SetColor(Color::green);
   g->GetMaterial().SetDiffuse(1.0f);
   g->GetMaterial().SetSpecular(1.0f);
   scene->AddObject(g);

   Sphere *b = new Sphere(Vector(2.0f, -1.5f, 2.0f), 0.5f);
   b->GetMaterial().SetColor(Color::blue);
   b->GetMaterial().SetDiffuse(1.0f);
   b->GetMaterial().SetSpecular(1.0f);
   scene->AddObject(b);

	Plane *floor = new Plane(Vector(0.0f, 1.0f, 0.0f), 2.0f);
	floor->GetMaterial().SetColor(Color::white);
	floor->GetMaterial().SetDiffuse(1.0f);
	//scene->AddObject(floor);

	raytracer->SetScene(scene);

	//unthinkable without multithreading
	raytracer->SetShadowQuality(32);
	raytracer->SetMultisampling(8);
	raytracer->SetReflectionBlur(1);
	raytracer->SetOcclusion(0);
}
开发者ID:ReaperUnreal,项目名称:Raytracer,代码行数:65,代码来源:main.cpp

示例2: test2

void test2()
{
	Vector o(0, 0, 5);
	Vector d(0, 0, -1);
	Ray r(o, d);
	Vector dx(1.0f / 6.0f, 0, 0);
	Vector dy(1.0f / 6.0f, 0, 0);

	raytracer = new Raytracer();

	cam = new Camera();
	cam->MoveTo(Vector(0.0f, 0.0f, 5.0f));
	cam->LookAt(Vector(0.0f, 0.0f, 0.0f));
	raytracer->SetCamera(cam);

	target = new RenderSurface(SCREEN_WIDTH, SCREEN_HEIGHT);
	raytracer->SetTarget(target);

	scene = new Scene(8);

	//Sphere *sphere = new Sphere(Vector(0, 0, 0), 2.0f);
	SDFScene *sdf = new SDFScene();
	sdf->GetMaterial().SetColor(Color::white);
	sdf->GetMaterial().SetDiffuse(1.0f);
	sdf->GetMaterial().SetSpecular(0.0f);
	scene->AddObject(sdf);

	Sphere *light = new Sphere(Vector(0.0f, 0.0f, 7.0f), 1.0f);
	light->SetLight(true);
	light->SetLightIntensity(1.0f);
	light->GetMaterial().SetColor(Color::white);
	scene->AddObject(light);

	raytracer->SetScene(scene);

	//unthinkable without multithreading
	raytracer->SetShadowQuality(1);
	raytracer->SetMultisampling(1);
	raytracer->SetReflectionBlur(1);
	raytracer->SetOcclusion(0);

	for(int i = 0; i < 10000000; ++i)
	{
		Color pixel = Color::black;
		float mindist = MAX_DIST;
		float u = (lrflti(rand()) * MAX_RAND_DIVIDER) - 0.5f;
		float v = (lrflti(rand()) * MAX_RAND_DIVIDER) - 0.5f;
		Vector dir = d + (dx * u) + (dy * v);
		dir.Normalize();
		r.direction = dir;
		Geometry *geom = raytracer->Raytrace(r, pixel, 0, mindist);
		if(geom != sdf)
		{
			printf("No hit! d = <%0.1f, %0.1f, %0.1f> mindist = %0.1f\n", r.direction.xv(), r.direction.yv(), r.direction.zv(), mindist);
			break;
		}
		if((pixel.rv() < 0.05f) && (pixel.gv() < 0.05f) && (pixel.bv() < 0.05f))
		{
			printf("Black! c = <%0.1f, %0.1f, %0.1f> d = <%0.1f, %0.1f, %0.1f> mindist = %0.1f\n", pixel.rv(), pixel.gv(), pixel.bv(), r.direction.xv(), r.direction.yv(), r.direction.zv(), mindist);
			break;
		}
	}
}
开发者ID:ReaperUnreal,项目名称:Raytracer,代码行数:63,代码来源:main.cpp


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