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


C++ Objects::createNewPlane方法代码示例

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


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

示例1: init

void init(void)
{
	float seconds = glutGet(GLUT_ELAPSED_TIME);

	 Objects obj;

	 float raysPerPixel = 9.0f;
	 int rays = int(raysPerPixel);

	float X =2;
	float Y =2;
	float Z =0;
	float cornellDepth = 5.0f;
	
	 //CornellBox Walls
	 obj.createNewPlane(glm::vec3(-X,-Y,Z),glm::vec3(X,-Y,Z),glm::vec3(X,Y,Z),glm::vec3(-X,Y,Z));
	 obj.createNewPlane(glm::vec3(-X,-Y,Z+cornellDepth),glm::vec3(-X,-Y,Z),glm::vec3(-X,Y,Z),glm::vec3(-X,Y,Z+cornellDepth));
	 obj.createNewPlane(glm::vec3(-X,-Y,Z+cornellDepth),glm::vec3(X,-Y,Z+cornellDepth),glm::vec3(X,-Y,Z),glm::vec3(-X,-Y,Z));
	 obj.createNewPlane(glm::vec3(X,-Y,Z),glm::vec3(X,-Y,Z+cornellDepth),glm::vec3(X,Y,Z+cornellDepth),glm::vec3(X,Y,Z));
	 obj.createNewPlane(glm::vec3(-X,Y,Z),glm::vec3(X,Y,Z),glm::vec3(X,Y,Z+cornellDepth),glm::vec3(-X,Y,Z+cornellDepth));
	 //And their Colors
	 obj.shapes[0]->material.color = GREEN;
	 obj.shapes[1]->material.color = MAGENTA;
	 obj.shapes[2]->material.color = YELLOW;
	 obj.shapes[3]->material.color = BLUE;
	 obj.shapes[4]->material.color = RED;
	 
	 //Box made up of 6 planes
	 float boxY = 0.525;
	 obj.createNewPlane(glm::vec3(-1.587,-2.0,1.819),glm::vec3(-0.361,-2.000,2.120),glm::vec3(-0.361,0.525,2.120),glm::vec3(-1.587,0.525,1.819));
	 obj.createNewPlane(glm::vec3(-0.361,-2.0,2.120),glm::vec3(-0.060,-2.000,0.894),glm::vec3(-0.060,0.525,0.894),glm::vec3(-0.361,0.525,2.120));
	 obj.createNewPlane(glm::vec3(-0.060,-2.0,0.894),glm::vec3(-1.286,-2.000,0.593),glm::vec3(-1.286,0.525,0.593),glm::vec3(-0.060,0.525,0.894));
	 obj.createNewPlane(glm::vec3(-1.286,-2.0,0.593),glm::vec3(-1.587,-2.000,1.819),glm::vec3(-1.587,0.525,1.819),glm::vec3(-1.286,0.525,0.593));
	 //top
	 obj.createNewPlane(glm::vec3(-1.587,0.525,1.819),glm::vec3(-0.361,0.525,2.120),glm::vec3(-0.060,0.525,0.894),glm::vec3(-1.286,0.525,0.593));
	 float SphereRadius = 0.80;
	 obj.createNewSphere(glm::mat4(0.0),glm::vec3(0.7,-2.0+SphereRadius,Z+3.0),SphereRadius);

	 obj.shapes[5]->material.color = BLUE;
	 obj.shapes[6]->material.color = RED;
	 obj.shapes[7]->material.color = YELLOW;
	 obj.shapes[8]->material.color = MAGENTA;
	 obj.shapes[9]->material.color = CYAN;

	 obj.shapes[10]->material.isDiffuse = false;
	 obj.shapes[10]->material.isRefractive = true;
	obj.shapes[10]->material.refractiveIndex = 1.5f; //Originally 1.33f
	 obj.shapes[10]->material.color = YELLOW;

	  obj.createNewPlane(glm::vec3(-X*20,-Y*20,Z+7.7),glm::vec3(-X*20,Y*20,Z+7.7),glm::vec3(X*20,Y*20,Z+7.7),glm::vec3(X*20,-Y*20,Z+7.7));

	  obj.shapes[11]->material.color = CYAN;

	 obj.shapes[5]->material.isDiffuse = false;
	 obj.shapes[6]->material.isDiffuse = false;
	 obj.shapes[7]->material.isDiffuse = false;
	 obj.shapes[8]->material.isDiffuse = false;
	 obj.shapes[9]->material.isDiffuse = false;



	 obj.createNewSphere(glm::mat4(0.0),glm::vec3(-1.0,-2.0+0.6,Z+3.0),0.6);
	 obj.shapes[12]->material.isDiffuse = false;


	//======== Main RayTracing Loop ========
		glm::vec3 renderColor,pixelColor = BLACK;
		glm::vec3 lightSource =glm::vec3(0,1.75,2);

		float yFov = 0.5*renderHeight / (camera.position.z*sin(FieldOfView/2.0));
		float xFov = 0.5*renderWidth / (camera.position.z*sin(FieldOfView*(renderWidth/renderHeight)/2.0));

		float maxT = -10.0;
			float minT = 9999999.9;


		float SSx [9];
			
		SSx[0] = -1.0/3.0;
		SSx[1] = 0.0;
		SSx[2] = 1.0/3.0;
		SSx[3] = -1.0/3.0;
		SSx[4] = 0.0;
		SSx[5] = 1.0/3.0;
		SSx[6] = -1.0/3.0;
		SSx[7] = 0.0;
		SSx[8] = 1.0/3.0;


		float SSy [9];

		SSy[0] = 1.0/3.0;
		SSy[1] = 1.0/3.0;
		SSy[2] = 1.0/3.0;
		SSy[3] = 0.0;
		SSy[4] = 0.0;
		SSy[5] = 0.0;
		SSy[6] = -1.0/3.0;
		SSy[7] = -1.0/3.0;
		SSy[8] = -1.0/3.0;
//.........这里部分代码省略.........
开发者ID:RasmusKarlsson,项目名称:Raytracer,代码行数:101,代码来源:main.cpp


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