mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-08-16 18:57:55 +02:00
trying to get the resulting model to line up with the originals
This commit is contained in:
parent
a8698c2fbc
commit
750b7192af
2 changed files with 10 additions and 7 deletions
|
@ -1738,7 +1738,7 @@ glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) {
|
|||
glm::mat4 rotation = glm::mat4_cast(entity->getRotation());
|
||||
glm::mat4 registration = glm::translate(ENTITY_ITEM_DEFAULT_REGISTRATION_POINT -
|
||||
entity->getRegistrationPoint());
|
||||
result = translation * rotation * registration;
|
||||
result = translation * rotation /* * registration */;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -473,11 +473,16 @@ bool Model::getMeshes(MeshProxyList& result) {
|
|||
|
||||
Transform offset;
|
||||
offset.setScale(_scale);
|
||||
// not set -- far to the right
|
||||
// offset.postTranslate(_offset); // far to right
|
||||
// offset.postTranslate(-_offset); // a bit to left
|
||||
// offset.postTranslate(_offset);
|
||||
glm::mat4 offsetMat = offset.getMatrix();
|
||||
|
||||
Extents modelExtents = getUnscaledMeshExtents();
|
||||
glm::vec3 dimensions = modelExtents.maximum - modelExtents.minimum;
|
||||
|
||||
const glm::vec3 DEFAULT_ENTITY_REGISTRATION_POINT = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
glm::vec3 regis = (DEFAULT_ENTITY_REGISTRATION_POINT - _registrationPoint);
|
||||
glm::vec3 regisOffset = dimensions * regis;
|
||||
|
||||
for (std::shared_ptr<const model::Mesh> mesh : meshes) {
|
||||
if (!mesh) {
|
||||
continue;
|
||||
|
@ -485,9 +490,7 @@ bool Model::getMeshes(MeshProxyList& result) {
|
|||
|
||||
MeshProxy* meshProxy = new SimpleMeshProxy(
|
||||
mesh->map([=](glm::vec3 position) {
|
||||
const glm::vec3 DEFAULT_ENTITY_REGISTRATION_POINT = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
glm::vec3 regis = _registrationPoint - DEFAULT_ENTITY_REGISTRATION_POINT;
|
||||
return glm::vec3(offsetMat * glm::vec4(position + _offset, 1.0f)) + regis; // very close
|
||||
return glm::vec3(offsetMat * glm::vec4(position, 1.0f));
|
||||
},
|
||||
[=](glm::vec3 normal){ return glm::normalize(glm::vec3(offsetMat * glm::vec4(normal, 0.0f))); },
|
||||
[&](uint32_t index){ return index; }));
|
||||
|
|
Loading…
Reference in a new issue