From d331cf7f60eb2baf01bcd5306295467c99244efb Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 9 Feb 2012 17:50:38 +0000 Subject: [PATCH] Added OrientedDisk creation method. and a missing "clear()" --- vcg/complex/algorithms/create/platonic.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vcg/complex/algorithms/create/platonic.h b/vcg/complex/algorithms/create/platonic.h index f4321caf..4c3ce8d1 100644 --- a/vcg/complex/algorithms/create/platonic.h +++ b/vcg/complex/algorithms/create/platonic.h @@ -721,9 +721,11 @@ void FaceGrid(MeshType & in, const std::vector &grid, int w, int h) } } + template void Disk(MeshType & m, int slices) { + m.Clear(); typename MeshType::VertexIterator vi = vcg::tri::Allocator::AddVertices(m,slices+1); (*vi).P() = typename MeshType::CoordType(0,0,0); ++vi; @@ -749,6 +751,20 @@ void Disk(MeshType & m, int slices) } } +template +void OrientedDisk(MeshType &m, int slices, Point3f center, Point3f norm, float radius) +{ + Disk(m,slices); + tri::UpdatePosition::Scale(m,radius); + float angleRad = Angle(Point3f(0,0,1),norm); + Point3f axis = Point3f(0,0,1)^norm; + + Matrix44f rotM; + rotM.SetRotateRad(angleRad,axis); + tri::UpdatePosition::Matrix(m,rotM); + tri::UpdatePosition::Translate(m,center); +} + template void Cylinder(int slices, int stacks, MeshType & m){