I am having trouble moving my mesh from my rigidbody's position.

It looks like there is an offset and i can't find how to calculate it.

For exemple:

My mesh is at (3.0, 2.0, 4.0)

But the rigidbody's transform is(9.0, 8.5, 12.0)

(My mesh size is 5)

Here is how i create my ridigBody:

Code: Select all

```
const std::vector<glm::vec3> dataSize = getBiggestHitBox();
this->size = dataSize[0] * glm::vec3(0.5);
this->center = dataSize[1];
boxCollisionShape = new btBoxShape(btVector3(size.x, size.y, size.z));
transform.setIdentity();
transform.setOrigin(btVector3(center.x, center.y, center.z));
motionState = new btDefaultMotionState(transform);
rigidBody = new btRigidBody(btRigidBody::btRigidBodyConstructionInfo(
weight,
motionState,
boxCollisionShape,
btVector3(0, 0, 0)
));
```

Code: Select all

```
GLfloat max_x, max_y, max_z;
GLfloat min_x = max_x = vertices[0].Position.x;
GLfloat min_y = max_y = vertices[0].Position.y;
GLfloat min_z = max_z = vertices[0].Position.z;
for (int i = 0; i < vertices.size(); i++) {
if (vertices[i].Position.x < min_x) min_x = vertices[i].Position.x;
if (vertices[i].Position.x > max_x) max_x = vertices[i].Position.x;
if (vertices[i].Position.y < min_y) min_y = vertices[i].Position.y;
if (vertices[i].Position.y > max_y) max_y = vertices[i].Position.y;
if (vertices[i].Position.z < min_z) min_z = vertices[i].Position.z;
if (vertices[i].Position.z > max_z) max_z = vertices[i].Position.z;
}
glm::vec3 size = glm::vec3(max_x - min_x, max_y - min_y, max_z - min_z);
glm::vec3 center = glm::vec3((min_x + max_x) / 2, (min_y + max_y) / 2, (min_z + max_z) / 2);
center += position * glm::vec3(2.0f);
std::vector<glm::vec3> ret;
ret.emplace_back(size);
ret.emplace_back(center);
return ret;
```