本文整理汇总了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);
}
示例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);
}