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(); } } } } } }
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(); } } } }
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(); } } }
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(); //} } }