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){