{"id":16147479,"url":"https://github.com/edap/ofxlathemesh","last_synced_at":"2025-04-06T21:44:21.313Z","repository":{"id":145594133,"uuid":"164945979","full_name":"edap/ofxLatheMesh","owner":"edap","description":"mesh for lathe geometries","archived":false,"fork":false,"pushed_at":"2019-03-14T14:15:23.000Z","size":1203,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T03:47:25.329Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-09T22:09:47.000Z","updated_at":"2019-03-28T15:03:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e113c3c-f0f4-42d9-92a4-bbcfcd8d762a","html_url":"https://github.com/edap/ofxLatheMesh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edap%2FofxLatheMesh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edap%2FofxLatheMesh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edap%2FofxLatheMesh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edap%2FofxLatheMesh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edap","download_url":"https://codeload.github.com/edap/ofxLatheMesh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557797,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T00:25:25.068Z","updated_at":"2025-04-06T21:44:21.296Z","avatar_url":"https://github.com/edap.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ofxLatheMesh\n\n[![Build status](https://ci.appveyor.com/api/projects/status/hwecbliusfhxd5nf?svg=true)](https://ci.appveyor.com/project/edap/ofxlathemesh)\n[![Build Status](https://travis-ci.org/edap/ofxLatheMesh.svg?branch=master)](https://travis-ci.org/edap/ofxLatheMesh)\n\n![ofxLatheMesh](img/ofxLatheMesh.jpg)\n\nThis addon generates lathe geometries. [Lathe geometries](https://en.wikipedia.org/wiki/Lathe_(graphics)) are geometries produced by rotating some points around a fixed axis, in my addon and in many other similar program, the up axis.\n\nThis addon is very close to that one that comes from [THREE.js](https://threejs.org/docs/#api/en/geometries/LatheGeometry), and most of the code comes from there, but it has also some new features, as explained below\n\n\n## Usage example\n\nA lathe mesh comes with its default, this minimal example is enough to have a lathe geometry in your scene.\n\n```cpp\nvoid ofApp::setup(){\n    lathe.build();\n}\n\nvoid ofApp::setup(){\n    lathe.draw()\n}\n```\n\n## API\n\n### Public properties:\n\nThe public properties `segments`, `phiStart`, `phiLength` and `points` behave exactly as in this [demo](https://threejs.org/docs/#api/en/geometries/LatheGeometry).\n\n```\nofParameter\u003cint\u003e segments;\n```\n\nIt defines the number of segments that will compose the rotating geometry.\n\n---\n```\nofParameter\u003cfloat\u003e phiStart;\n```\n\nThe initial rotation angle.\n\n\n---\n```\nofParameter\u003cfloat\u003e phiLength;\n```\n\nThe upper limit of the rotation. A value TWO_PI, for example, means a complete rotation on the y axis\n\n\n---\n```\nofParameter\u003cbool\u003e closed = false;\n```\n\nWhen the first part of the rotating mesh and the last part are close to each other, the mesh will be perfectly closed.\n\n\n---\n```\nofParameter\u003cbool\u003e flipNormals = false;\n```\n\nDepending on the order on which the points are inserted, the face of the generated polygon maybe in the inverted direction as expected. This option flip the faces.\n\n\n---\n```\nofParameterGroup parameters;\n```\n\nContains all the parameter listed above.\n\n\n---\n```\nvector\u003cglm::vec2\u003e points;\n```\n\nThe vector containing the point that are going to be rotated around the y axis\n\n\n### Member methods\n\n\n```\nvoid setup(const vector\u003cglm::vec2\u003epoints, const int segments, const float phiStart, const float phiLength);\n```\n\nSetup a new geometry defining points, segments, phiStart and phiLength.\n\n\n---\n```\nvoid build();\n```\n\nIt builds a `ofVboMesh`.\n\n\n---\n```\nvoid clear();\n```\n\nIt clears the mesh.\n\n\n---\n```\nvoid setPoints(vector\u003cglm::vec2\u003e _points);\n```\n\nSet the points that are going to be rotated. Example:\n\n\n```cpp\nofxLathePrimitive lathe;\nvector\u003cglm::vec2\u003e points;\nfor ( int i = 0; i \u003c 12; i ++ ) {\n    points.push_back( glm::vec2( sin( i * 0.2 ) * 100 + 5, ( i + 2) * 20 ) );\n}\nlathe.setPoints(points);\nlathe.build();\n```\n\n\n---\n```\nvector\u003cglm::vec2\u003e getPoints() const;\n```\n\nReturns the points that are going to be rotated.\n\n\n---\n```\nvector\u003cglm::vec3\u003e getCurrentRotatingPoints() const;\n```\n\nLike `getPoints()`, but it returns the points at the last angle rotation. See the example `example-rotating-points`\n\n\n---\n```\nstd::function\u003cglm::vec3(float, int, int)\u003e addOffset;\n```\n\nLambda function that add an offset to the point position of each rotating point. For example, to add an offset to the y component of point depending on the rotation angle:\n\n```cpp\nlathe.addOffset = [](float angle, int segmentIndex, int pointIndex) {\n    auto y = sin(angle*3.0) * 9.0;\n    return glm::vec3(0,y,0);\n};\n```\n\n\n---\n```\nstd::function\u003cglm::vec2(const vector\u003cglm::vec2\u003e points, float, int, int)\u003e editPoint;\n```\n\nLambda function that changes the position of the point while rotating. Example:\n\n```cpp\nlathe.editPoint = [offset](const vector\u003cglm::vec2\u003e points, float angle, int segIndex, int pointIndex){\n    auto point = points.at(pointIndex);\n    glm::vec2 newPoint;\n\n    newPoint.x = point.x * cos(angle*4) * 0.3 + offset.x;\n    newPoint.y = point.y * sin(angle*2) * 0.3 + offset.y;\n\n    return newPoint;\n};\n```\n\nSee the example `example-funky-torus`.\n\n\n---\n```\nstd::function\u003cofColor(float, int, int)\u003e computeColor;\n```\n\nLambda function that changes the color of the point during the rotation. For example:\n\n```cpp\nint totPoints = lathe.points.size();\nlathe.computeColor = [totPoints](float angle, int segmentIter, int pointIter) {\n    float hue = ofMap(sin(angle*3.), -1, 1, 125, 200);\n    return ofColor().fromHsb(hue, 255, 255);\n};\n```\n\nSee the example `example-distorted`.\n\n\n## Examples\n\n*example-distorted*\n![example-distorted](img/example-distorted.jpg)\n\n*example-editor*\n![example-editor](img/example-editor.jpg)\n\n*example-rotating-points*\n![example-rotating-points](img/example-rotating-points.jpg)\n\n*example-funky-torus*\n![example-funky-torus](img/example-funky-torus.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedap%2Fofxlathemesh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedap%2Fofxlathemesh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedap%2Fofxlathemesh/lists"}