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


C++ BEZIER::CalculateMiddleRows方法代码示例

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


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

示例1: AutoTrace

void AutoTrace()
{
	if (activestrip != NULL)
	{
		BEZIER * lastbez = activestrip->GetLastPatch();
		if (lastbez != NULL && editordata.numbezinput == 4)
		{
			VERTEX tvec[4];
			/*VERTEX fl = lastbez->points[0][0];
			VERTEX fr = lastbez->points[0][3];
			VERTEX bl = lastbez->points[3][0];
			VERTEX br = lastbez->points[3][3];*/
			
			bool success(true);
			BEZIER patch;
			if (vertmode == TWOVERTS)
			{
				success = success && objects.AutoFindClosestVert(lastbez->points[0][0], lastbez->points[0][3], (lastbez->points[0][0]-lastbez->points[3][0]), tvec[0]);
				success = success && objects.AutoFindClosestVert(lastbez->points[0][3], lastbez->points[0][0], (lastbez->points[0][3]-lastbez->points[3][3]), tvec[1]);
				
				if (success)
				{
					patch.SetFromCorners(tvec[0], tvec[1], editordata.bezinput[0], editordata.bezinput[3]);
				}
			}
			else if (vertmode == THREEVERTS)
			{
				success = success && objects.AutoFindClosestVert(lastbez->points[0][0], lastbez->points[0][1], (lastbez->points[0][0]-lastbez->points[3][0]), tvec[0]);
				success = success && objects.AutoFindClosestVert(lastbez->points[0][1], lastbez->points[0][3], (lastbez->points[0][1]-lastbez->points[3][1]), tvec[1]);
				tvec[2] = tvec[1];
				success = success && objects.AutoFindClosestVert(lastbez->points[0][3], lastbez->points[0][1], (lastbez->points[0][3]-lastbez->points[3][3]), tvec[3]);
				
				if (success)
				{
					for (int i = 0; i < 4; i++)
						patch.points[3][i] = editordata.bezinput[i];
					for (int i = 0; i < 4; i++)
						patch.points[0][i] = tvec[i];
					patch.CalculateMiddleRows();
				}
			}
			else if (vertmode == FOURVERTS)
			{
				for (int i = 0; i < 4; i++)
				{
					int nextvert = i + 1;
					if (nextvert >= 4)
						nextvert = 2;
					success = success && objects.AutoFindClosestVert(lastbez->points[0][i], lastbez->points[0][nextvert], (lastbez->points[0][i]-lastbez->points[3][i]), tvec[i]);
				}
				
				if (success)
				{
					for (int i = 0; i < 4; i++)
						patch.points[3][i] = editordata.bezinput[i];
					for (int i = 0; i < 4; i++)
						patch.points[0][i] = tvec[i];
					patch.CalculateMiddleRows();
				}
			}
			else
				assert(0);
			
			if (success)
			{
				activestrip->Add(patch);
				
				editordata.numbezinput = 4;
				
				editordata.bezinput[0] = patch.points[0][0];
				editordata.bezinput[1] = patch.points[0][1];
				editordata.bezinput[2] = patch.points[0][2];
				editordata.bezinput[3] = patch.points[0][3];
				
				mq1.AddMessage("Auto-traced road");
			}
			else
			{
				mq1.AddMessage("Can't auto-trace road: found no candidate points");
			}
		}
		else
		{
			mq1.AddMessage("Can't auto-trace road: must start road first");
		}
	}
	else
	{
		mq1.AddMessage("Can't auto-trace road: no roads selected");
	}
}
开发者ID:VDrift,项目名称:trackeditor,代码行数:91,代码来源:main.cpp

示例2: drawGLScene


//.........这里部分代码省略.........
			{
				//create bezier patch
				BEZIER patch;
				
				if (vertmode == TWOVERTS)
					patch.SetFromCorners(editordata.bezinput[4], selvert, editordata.bezinput[0], editordata.bezinput[3]);
				else
				{
					//copy the front and back selected rows to the patch, then tell it to do the math to find the other points
					// plus center and radius calculations
					
					editordata.bezinput[7] = selvert;
					
					for (int i = 0; i < 4; i++)
						patch.points[3][i] = editordata.bezinput[i];
					for (int i = 0; i < 4; i++)
						patch.points[0][i] = editordata.bezinput[i+4];
					
					/*if (vertmode == THREEVERTS)
					{
						//recalculate the middle two verts
						for (int i = 0; i < 4; i += 3)
						{
							if ((patch.points[i][1] - patch.points[i][2]).len() < 0.0001)
							{
								VERTEX leftslope = patch.points[i][1] - patch.points[i][0];
								VERTEX rightslope = patch.points[i][2] - patch.points[i][3];
								patch.points[i][1] = patch.points[i][0] + leftslope.ScaleR(0.5);
								patch.points[i][2] = patch.points[i][3] + rightslope.ScaleR(0.5);
							}
						}
					}*/
					
					patch.CalculateMiddleRows();
				}
				
				if (activestrip == NULL)
				{
					activestrip = track.AddNewRoad();
					mq1.AddMessage("New road created to hold new patch.");
				}
				
				activestrip->Add(patch);
				
				//editordata.numbezinput = 0;
				editordata.numbezinput = 4;
				
				editordata.bezinput[0] = patch.points[0][0];
				editordata.bezinput[1] = patch.points[0][1];
				editordata.bezinput[2] = patch.points[0][2];
				editordata.bezinput[3] = patch.points[0][3];
			}
			else
			{
				editordata.bezinput[oldnumbezinput] = selvert;
				if (vertmode == THREEVERTS && (oldnumbezinput == 1 || oldnumbezinput == 5))
					editordata.bezinput[oldnumbezinput+1] = selvert;
			}
		}
		
		editordata.mousebounce[1] = mouse.ButtonDown(1);
		
		glPushAttrib(GL_ALL_ATTRIB_BITS);
		glDisable(GL_LIGHTING);
		glDisable(GL_TEXTURE_2D);
		glDisable(GL_DEPTH_TEST);
开发者ID:VDrift,项目名称:trackeditor,代码行数:67,代码来源:main.cpp


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