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


C++ StelProjectorP::forward方法代码示例

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


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

示例1: calc

void StelViewportDistorterFisheyeToSphericMirror::generateDistortion
	(const QSettings& conf, const StelProjectorP& proj, 
	 const double distorterMaxFOV, StelRenderer* renderer)
{
	double gamma;
	loadGenerationParameters(conf, gamma);

	const int cols = maxGridX + 1;
	const int rows = maxGridY + 1;
	
	const float viewScale = 0.5 * newProjectorParams.viewportFovDiameter /
	                        proj->fovToViewScalingFactor(distorterMaxFOV*(M_PI/360.0));

	texCoordGrid = new Vec2f[cols * rows];
	float* heightGrid = new float[cols * rows];
  
	float maxHeight = 0;
	SphericMirrorCalculator calc(conf);
	           
	// Generate grid vertices/texcoords.
	for (int row = 0; row <= maxGridY; row++)
	{
		for (int col = 0; col <= maxGridX; col++)
		{
			Vertex vertex;
			float &height(heightGrid[row * cols + col]);
			
			// Clamp to screen extents.
			vertex.position[0] = (col == 0)        ? 0.f : 
			                     (col == maxGridX) ? screenWidth : 
			                                         (col - 0.5f * (row & 1)) * stepX;
			vertex.position[1] = row * stepY;
			Vec3f v,vX,vY;
			bool rc = calc.retransform((vertex.position[0]-0.5f*screenWidth) / screenHeight,
			                           (vertex.position[1]-0.5f*screenHeight) / screenHeight,
			                           v,vX,vY);

			rc &= proj->forward(v);
			const float x = newProjectorParams.viewportCenter[0] + v[0] * viewScale;
			const float y = newProjectorParams.viewportCenter[1] + v[1] * viewScale;
			height = rc ? (vX^vY).length() : 0.0;

			// sharp image up to the border of the fisheye image, at the cost of
			// accepting clamping artefacts. You can get rid of the clamping
			// artefacts by specifying a viewport size a little less then
			// (1<<n)*(1<<n), for instance 1022*1022. With a viewport size of
			// 512*512 and viewportFovDiameter=512 you will get clamping artefacts
			// in the 3 otherwise black hills on the bottom of the image.

			//      if (x < 0.f) {x=0.f;height=0;}
			//      else if (x > newProjectorParams.viewportXywh[2])
			//          {x=newProjectorParams.viewportXywh[2];height=0;}
			//      if (y < 0.f) {y=0.f;height=0;}
			//      else if (y > newProjectorParams.viewportXywh[3])
			//          {y=newProjectorParams.viewportXywh[3];height=0;}

			vertex.texCoord[0] = x / texture_w;
			vertex.texCoord[1] = y / texture_h;

			texCoordGrid[row * cols + col] = vertex.texCoord;

			vertexGrid->addVertex(vertex);
			maxHeight = qMax(height, maxHeight);
		}
	}
	
	// Generate grid colors. (Separate from previous loop as we need max height)
	for (int row = 0; row <= maxGridY; row++)
	{
		for (int col = 0; col <= maxGridX; col++)
		{
			const int cell = row * cols + col;

			// Getting/setting each vertex is not that efficient, but we only do this 
			// at startup.
			Vertex vertex = vertexGrid->getVertex(cell);
			Vec4f &color(vertex.color);
			const float height = heightGrid[cell];
			const float gray = (height <= 0.0) ? 0.0 : exp(gamma * log(height / maxHeight));
			color[0] = color[1] = color[2] = gray;
			color[3] = 1.0f; 

			vertexGrid->setVertex(cell, vertex);
		}
	}

	constructVertexBuffer(renderer);
	
	delete[] heightGrid;
	
	// FIXME: Comment out with /**/ after testing. --BM
	qDebug() << "StelViewportDistorterFisheyeToSphericMirror():" 
	         << "screen_w:" << this->screenWidth
	         << "screen_h:" << this->screenHeight << endl
	         << "originalProjectorParams.viewportXywh:" 
	         << originalProjectorParams.viewportXywh[0] 
	         << originalProjectorParams.viewportXywh[1] 
	         << originalProjectorParams.viewportXywh[2] 
	         << originalProjectorParams.viewportXywh[3] << endl
	         << "newProjectorParams.viewportXywh:"
//.........这里部分代码省略.........
开发者ID:incadoi,项目名称:stellarium-1,代码行数:101,代码来源:StelViewportEffect.cpp


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