mirror of https://github.com/CGAL/cgal
added transformation of normals
This commit is contained in:
parent
89d3d74865
commit
4fe88f8b49
|
|
@ -614,12 +614,20 @@ endPointSet(const QMatrix4x4& transform_matrix)
|
|||
Point_set* new_ps = new_item->point_set();
|
||||
CGAL::qglviewer::Vec c = aff_transformed_item->center();
|
||||
|
||||
QMatrix3x3 normal_matrix = transform_matrix.normalMatrix();
|
||||
|
||||
for(Point_set::Index idx : *new_ps)
|
||||
{
|
||||
QVector3D vec = transform_matrix.map(QVector3D(new_ps->point(idx).x() - c.x,
|
||||
new_ps->point(idx).y() - c.y,
|
||||
new_ps->point(idx).z() - c.z));
|
||||
new_ps->point(idx) = Kernel::Point_3(vec.x(), vec.y(), vec.z());
|
||||
if (new_ps->has_normal_map()) {
|
||||
QVector3D n(new_ps->normal(idx).x(), new_ps->normal(idx).y(), new_ps->normal(idx).z());
|
||||
new_ps->normal(idx) = Kernel::Vector_3(normal_matrix(0, 0) * n[0] + normal_matrix(0, 1) * n[1] + normal_matrix(0, 2) * n[2],
|
||||
normal_matrix(1, 0) * n[0] + normal_matrix(1, 1) * n[1] + normal_matrix(1, 2) * n[2],
|
||||
normal_matrix(2, 0) * n[0] + normal_matrix(2, 1) * n[1] + normal_matrix(2, 2) * n[2]);
|
||||
}
|
||||
}
|
||||
|
||||
new_item->setName(aff_transformed_item->name());
|
||||
|
|
|
|||
Loading…
Reference in New Issue