Test on game level v1.

This commit is contained in:
William Moberg
2016-01-25 10:55:05 +01:00
parent f1343e2f82
commit 3389b965eb
2 changed files with 87 additions and 0 deletions
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Collidable/>
<c:Model>
<Resource>../assets\Models/MapVersion1.obj</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="0" Z="-0.313012958"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:AABB/>
<c:Collidable/>
<c:Model>
<Resource>../assets/Models/Core/UnitCube.obj</Resource>
</c:Model>
<c:Physics>
<Gravity>false</Gravity>
</c:Physics>
<c:Player/>
<c:Transform>
<Position X="-2.88221216" Y="7.13004351" Z="54.4666595"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:DirectionalLight/>
<c:Transform>
<Orientation X="3.80300021" Y="1.37800002" Z="4.10000038"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+44
View File
@@ -403,6 +403,50 @@ bool AABBvsTriangles(const AABB& box, const std::vector<RawModel::Vertex>& model
newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size());
}
}
//outResolutionVector = glm::vec3(INFINITY);
//std::stack<AABB> testBoxes;
//std::stack<int> resolveIndices;
//std::stack<glm::vec3> resolveVectors;
//resolveVectors.push(glm::vec3(0.f));
//resolveIndices.push(0);
//testBoxes.push(box);
//do {
// int i = resolveIndices.top();
// resolveIndices.pop();
// while (i < modelIndices.size()) {
// std::array<glm::vec3, 3> triVertices = {
// Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
// Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
// Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix)
// };
// glm::vec3 outVec;
// bool test = AABBvsTriangle(testBoxes.top(), triVertices, outVec);
// if (test) {
// hit = true;
// //emplace?
// resolveIndices.push(i);
// testBoxes.push(AABB::FromOriginSize(box.Origin() + outVec, box.Size()));
// resolveVectors.top() += outVec;
// }
// }
// testBoxes.pop();
// resolveVectors.push(glm::vec3(0.f));
//} while (!resolveIndices.empty());
//if (hit) {
// if (!resolveVectors.empty()) {
// while (!resolveVectors.empty()) {
// if (glm::length2(resolveVectors.top()) < glm::length2(outResolutionVector)) {
// outResolutionVector = resolveVectors.top();
// }
// resolveVectors.pop();
// }
// } else {
// //TODO: This won't happen.
// ImGui::Text("Collision, but not resolved.");
// }
// return true;
//}
return hit;
}