Closed KenKenhehe closed 1 year ago
That is correct. For any type of model, you can transform it similarly. Below is an example:
template<typename MODEL>
void translate(MODEL* model, const vec3& p) {
auto points = model->template get_vertex_property<vec3>("v:point");
for (auto v : model->vertices())
points[v] -= p;
}
Thanks for getting back, what about rotation?
It is similar, e.g.,
template<typename MODEL>
void translate(MODEL* model, const mat4& R) { // R is the rotation matrix
auto points = model->template get_vertex_property<vec3>("v:point");
for (auto v : model->vertices())
points[v] = R * points[v]; // apply R to every vertex
}
If you are visualizing the model using the Easy3D viewer, don't forget to call the following functions to update the viewer:
model->renderer()->update();
viewer->update();
Hi, thanks for the answers.
Is there a easy way to convert euler angles(x, y, z) to a rotation matrix?
How can I change the position of a loaded model (Surfacemesh, pointcloud), for example, mesh.x += ..., mesh.y += ..., mesh.z += ...