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


C++ Mat3::Rotate方法代码示例

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


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

示例1: DrawAgent

void SpriteBatch::DrawAgent(Agent* a_agent)
{

	Vec2 pos = a_agent->m_pos;

	float width		= (float)m_agentWidth;
	float height	= (float)m_agentHeight;

	int xOff = (int)width	/ 2;
	int yOff = (int)height	/ 2;

	Vec2 tl = Vec2(-xOff,			-yOff);
	Vec2 tr = Vec2(xOff ,			-yOff);
	Vec2 br = Vec2(-xOff,			yOff);
	Vec2 bl = Vec2(xOff ,			yOff);	

	float rot = Vec2(0,1).GetAngleBetween(a_agent->m_heading);

	//create matrix for start point
	Mat3 rotMat; 	
	rotMat.Rotate(rot + 3.141592654);
	rotMat.SetTranslation(pos);


	//set the 4 vert points to correct rotation
	tl = rotMat.TransformPoint(tl);
	tr = rotMat.TransformPoint(tr);
	br = rotMat.TransformPoint(br);
	bl = rotMat.TransformPoint(bl);	


	processSprite(&tl, &tr, &bl, &br, m_agentIBO, m_agentVBO, m_texID_agent, SPRITE_COLOUR_WHITE);
}
开发者ID:cazBlue,项目名称:AIEYearOneProjects,代码行数:33,代码来源:SpriteBatch.cpp

示例2: DrawLine

//Draw Line
void SpriteBatch::DrawLine(Vec2 a_start, Vec2 a_end, SPRITE_COLOUR a_col, float a_width)
{
	//width used to offsetting
	float width;

	if(a_width > 0)
		width = a_width;
	else
		width = (float)m_line_width / 2;	

	//width override for debugging
	//width = 50;

	float size = (a_start - a_end).Length();

	Vec2 origin = Vec2(-width / 2, 0);

	//set the line around the zero point with the pivot
	//at the top center (0,0)
	//oriented for rotation zero along the x axis
	Vec2 tl = Vec2(0,					0) + origin;
	Vec2 tr = Vec2(width,				0) + origin;
	Vec2 br = Vec2(0,				size)  + origin;
	Vec2 bl = Vec2(width,			size)  + origin;

	//get difference normalised
//	Vec2 diff = Vec2(a_end.x - a_start.x, a_end.y - a_start.y).GetNormalised();

	Vec2 diff = (a_start - a_end).GetNormalised();


	float rot = Vec2(0,1).GetAngleBetween(diff);

	//create matrix for start point
	Mat3 rotMat; 	
	rotMat.Rotate(rot + 3.141592654);
	rotMat.SetTranslation(a_start);
		

	//transform line start point
	tl = rotMat.TransformPoint(tl);
	tr = rotMat.TransformPoint(tr);

	//transform line end point
	br = rotMat.TransformPoint(br);
	bl = rotMat.TransformPoint(bl);

	processSprite(&tl, &tr, &bl, &br, m_lineIBO, m_lineVBO, m_texID_line, a_col);
}
开发者ID:cazBlue,项目名称:AIEYearOneProjects,代码行数:50,代码来源:SpriteBatch.cpp


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