本文整理汇总了C++中IShader::SetWorldMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ IShader::SetWorldMatrix方法的具体用法?C++ IShader::SetWorldMatrix怎么用?C++ IShader::SetWorldMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShader
的用法示例。
在下文中一共展示了IShader::SetWorldMatrix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawWaypoints
void SceneManager::DrawWaypoints(IShader& shader)
{
std::map<unsigned int, AIPath>::iterator iter = m_AIPaths.begin();
for (iter; iter != m_AIPaths.end(); ++iter)
{
if (iter->second.IsVisible())
{
std::vector<glm::vec3> path = iter->second.GetWaypoints();
for (int i = 0; i < path.size(); ++i)
{
glm::mat4 translation;
translation = glm::translate(translation, path[i]);
shader.SetWorldMatrix(translation);
m_miscObjects["waypoint"]->Draw();
if (iter->second.IsClosed())
{
if (path.size() > 1 && (i - 1) < path.size())
{
glBegin(GL_LINES);
glm::vec3 cpos = path[i - 1];
glm::vec3 npos = path[i];
glm::vec3 min = cpos - npos;
glVertex3f(0, 5, 0);
glVertex3f(min.x, min.y + 5, min.z);
glEnd();
}
if (path.size() > 2 && (i) == path.size() - 1)
{
glBegin(GL_LINES);
glm::vec3 cpos = path[0];
glm::vec3 npos = path[path.size() - 1];
glm::vec3 min = cpos - npos;
glVertex3f(0, 5, 0);
glVertex3f(min.x, min.y + 5, min.z);
glEnd();
}
}
else
{
if (path.size() > 1 && (i - 1) < path.size())
{
glBegin(GL_LINES);
glm::vec3 cpos = path[i - 1];
glm::vec3 npos = path[i];
glm::vec3 min = cpos - npos;
glVertex3f(0, 5, 0);
glVertex3f(min.x, min.y + 5, min.z);
glEnd();
}
}
}
}
}
}
示例2: DrawTempWaypoints
void SceneManager::DrawTempWaypoints(IShader& shader, AIPath& tempPath)
{
std::vector<glm::vec3> path = tempPath.GetWaypoints();
for (int i = 0; i < path.size(); ++i)
{
glm::mat4 translation;
translation = glm::translate(translation, path[i]);
shader.SetWorldMatrix(translation);
m_miscObjects["waypoint"]->Draw();
if (tempPath.IsClosed())
{
if (path.size() > 1 && (i - 1) < path.size())
{
glBegin(GL_LINES);
glm::vec3 cpos = path[i - 1];
glm::vec3 npos = path[i];
glm::vec3 min = cpos - npos;
glVertex3f(0, 5, 0);
glVertex3f(min.x, min.y + 5, min.z);
glEnd();
}
if (path.size() > 2 && (i) == path.size()-1)
{
glBegin(GL_LINES);
glm::vec3 cpos = path[0];
glm::vec3 npos = path[path.size() - 1];
glm::vec3 min = cpos - npos;
glVertex3f(0, 5, 0);
glVertex3f(min.x, min.y + 5, min.z);
glEnd();
}
}
else
{
if (path.size() > 1 && (i - 1) < path.size())
{
glBegin(GL_LINES);
glm::vec3 cpos = path[i - 1];
glm::vec3 npos = path[i];
glm::vec3 min = cpos - npos;
glVertex3f(0, 5, 0);
glVertex3f(min.x, min.y + 5, min.z);
glEnd();
}
}
}
}
示例3: DrawBoundingBoxes
void SceneManager::DrawBoundingBoxes(IShader& shader)
{
std::map<unsigned int, StaticMesh*>::const_iterator iter = models.begin();
for (iter; iter != models.end(); ++iter)
{
if (iter->second->m_bDrawBoundingBox)
{
glm::mat4 worldM;
glm::vec3 rotation = iter->second->GetRotation();
glm::vec3 rotationInRadians = (rotation * glm::pi<float>()) / 180.0f;
worldM = glm::translate(worldM, iter->second->GetPosition());
worldM = glm::rotate(worldM, rotationInRadians.x, glm::vec3(1.0f, 0.0f, 0.0f));
worldM = glm::rotate(worldM, rotationInRadians.y, glm::vec3(0.0f, 1.0f, 0.0f));
worldM = glm::rotate(worldM, rotationInRadians.z, glm::vec3(0.0f, 0.0f, 1.0f));
shader.SetWorldMatrix(worldM);
iter->second->GetModelData()->boundingbox.Draw();
}
}
}
示例4: Draw
void SceneManager::Draw(IShader& shader)
{
std::map<unsigned int, StaticMesh*>::iterator iter = models.begin();
for (iter; iter != models.end(); ++iter)
{
BoundingBox transformedBox = iter->second->GetModelData()->boundingbox;
glm::vec3 objRot = iter->second->GetRotation();
glm::mat4 rotMat;
objRot = (objRot * glm::pi<float>()) / 180.0f;
rotMat = glm::rotate(rotMat, objRot.x, glm::vec3(1.0f, 0.0f, 0.0f));
rotMat = glm::rotate(rotMat, objRot.y, glm::vec3(0.0f, 1.0f, 0.0f));
rotMat = glm::rotate(rotMat, objRot.z, glm::vec3(0.0f, 0.0f, 1.0f));
glm::vec4 transformedMaxPoint = rotMat * glm::vec4(transformedBox.max, 0);
glm::vec4 transformedMinPoint = rotMat * glm::vec4(transformedBox.min, 0);
transformedBox.max = glm::vec3(transformedMaxPoint.x, transformedMaxPoint.y, transformedMaxPoint.z);
transformedBox.min = glm::vec3(transformedMinPoint.x, transformedMinPoint.y, transformedMinPoint.z);
transformedBox.max += iter->second->GetPosition();
transformedBox.min += iter->second->GetPosition();
//TestResult t = m_Frustum.Intersect(transformedBox);
//if (t != TEST_OUTSIDE)
//{
glm::mat4 worldM;
glm::vec3 rotation = iter->second->GetRotation();
glm::vec3 rotationInRadians = (rotation * glm::pi<float>()) / 180.0f;
worldM = glm::translate(worldM, iter->second->GetPosition());
worldM = glm::rotate(worldM, rotationInRadians.x, glm::vec3(1.0f, 0.0f, 0.0f));
worldM = glm::rotate(worldM, rotationInRadians.y, glm::vec3(0.0f, 1.0f, 0.0f));
worldM = glm::rotate(worldM, rotationInRadians.z, glm::vec3(0.0f, 0.0f, 1.0f));
shader.SetWorldMatrix(worldM);
iter->second->Draw();
//}
}
}