本文整理汇总了C++中EntityManager::GetEntities方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::GetEntities方法的具体用法?C++ EntityManager::GetEntities怎么用?C++ EntityManager::GetEntities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::GetEntities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
inline void PhysicsSystem::Update(DeltaTime deltaTime) {
std::vector<std::shared_ptr<Entity>> entities = _entityManager->GetEntities();
for (auto it = entities.begin(); it != entities.end(); it++) {
auto transformable = it->get()->GetComponent<Transform>();
auto renderable = it->get()->GetComponent<Render>();
auto aabb = it->get()->GetComponent<AABB>();
if (transformable != nullptr && renderable != nullptr && aabb != nullptr) {
glm::mat4 scale = glm::mat4(1);
glm::mat4 rotation = glm::mat4(1);
glm::mat4 position = glm::mat4(1);
std::vector<glm::vec3> vertexData = renderable->GetVertexData();
std::vector<glm::vec4> transVertDat;
scale = glm::scale(scale, transformable->GetScale());
rotation = glm::rotate(rotation, transformable->GetRotationRad().x, glm::vec3(1.0f, 0.0f, 0.0f));
rotation = glm::rotate(rotation, transformable->GetRotationRad().y, glm::vec3(0.0f, 1.0f, 0.0f));
rotation = glm::rotate(rotation, transformable->GetRotationRad().z, glm::vec3(0.0f, 0.0f, 1.0f));
glm::mat4 trans;
trans = rotation * scale;
for (size_t i = 0; i < vertexData.size(); i++) {
if (i % 3 == 0) {
transVertDat.push_back(trans * glm::vec4(vertexData[i], 1));
}
}
glm::vec3 min = glm::vec3(transVertDat[0].x, transVertDat[0].y, transVertDat[0].z);
glm::vec3 max = glm::vec3(transVertDat[0].x, transVertDat[0].y, transVertDat[0].z);
for (size_t i = 0; i < transVertDat.size(); i++) {
if (transVertDat[i].x < min.x) { min.x = transVertDat[i].x; }
if (transVertDat[i].y < min.y) { min.y = transVertDat[i].y; }
if (transVertDat[i].z < min.z) { min.z = transVertDat[i].z; }
if (transVertDat[i].x > max.x) { max.x = transVertDat[i].x; }
if (transVertDat[i].y > max.y) { max.y = transVertDat[i].y; }
if (transVertDat[i].z > max.z) { max.z = transVertDat[i].z; }
} //for (size_t i = 0; i < transVertDat.size(); i++)
aabb->UpdateAABB(min, max);
} //if (transformable != nullptr && renderable != nullptr)
} //for (auto it = entities.begin(); it != entities.end(); it++)
};