manim-meshes


Namemanim-meshes JSON
Version 0.0.8 PyPI version JSON
download
home_pagehttps://github.com/bmmtstb/manim-meshes
Summaryrendering 2D and 3D Meshes with manim for displaying and educational Purposes.
upload_time2023-10-24 09:44:38
maintainer
docs_urlNone
authorBrizar
requires_python==3.8.18
licenseMIT
keywords animation manim trimeshes mesh
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Python Test and Lint](https://github.com/bmmtstb/manim-meshes/actions/workflows/python_ci_test.yaml/badge.svg)](https://github.com/bmmtstb/manim-meshes/actions/workflows/python_ci_test.yaml) [![CodeQL](https://github.com/bmmtstb/manim-meshes/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/bmmtstb/manim-meshes/actions/workflows/codeql-analysis.yml)
# Manim for Meshes

> ⚠️ not fully optimal - but fine for smaller meshes
> 
> Manim and the OpenGL renderer are not really friends right now, therefore most of the code runs terribly slow for larger meshes. In Addition to the small educational meshes we present a faster mesh that uses a custom shader but this requires manipulating the manim library.
>
> Stay tuned or feel free to assist. Either here or directly in the manim OpenGL part. Not necessarily everything is a Bézier curve... 

Manim-Trimeshes implements manim functionalities for different types of meshes using either basic node-face data structures or by importing meshes from the python [trimesh](https://pypi.org/project/trimesh/ "trimesh on pypi") library.

It is mainly developed as a Project for Interactive Graphics Systems Group (GRIS) at TU Darmstadt University, but is made publicly available for everyone interested in rendering and animating meshes.

## Installation

Manim-meshes has been published to [pypi](https://pypi.org/project/manim-meshes/) and therefore can be easily installed using:

``pip install manim-meshes``

## Usage

``from manim_meshes import *``

While executing a commandline manim script, make sure to set the `--renderer=opengl` flag, the Cairo renderer will ins most cases not work.

The basic `ManimMesh` and `Manim2DMesh` from `manim_models/basic_mesh` can currently only be used for smaller meshes (<1k Nodes), because it is dependent on the manim internal shaders which are not really implemented optimally. This type of mesh can be easily used for 2D and smaller 3D explanatory videos, not for high resolution rendering. Both these classes should give manim-functionalities like shift, rotate and scale. But due to the sheer amount of MObject functions we can not implement all of them, so make sure the renderer has overwritten the method you are trying to use if something does not look right.

The `TriangleManim2DMesh` from `triangle_mesh` implements further functions that are only reasonable for two-dimensional triangle meshes. (e.g. Delaunay) This was designed for educational purposes. There is also a package
`delaunay` containing multiple useful functions regarding delaunay triangulations, e.g. Voronoi diagrams, checking the delaunay criterion or a divide & conquer algorithm.

The more advanced `FastManimMesh` from `opengl_mesh` uses a custom shader which needs to be inserted into the base manim implementation at this time! But therefore it can render enormous meshes fast. Sadly rendering is kind of everything this renderer is capable of at the moment.

All these Mesh-Renders reference a mesh based on the `Mesh`-Class, in `data_models`, which should implement a multitude of basic Mesh-functions.

## Example

![Static image of a cone, to show the rendering capabilities](docs/images/ConeScene_v0.16.0.post0.png)

With active poetry venv Run one of the minimal test examples: `manim --renderer=opengl tests/test_scene.py ConeScene`.

Multiple other examples can be found in the `tests/test_scene.py` file.

[![see the PyramidScene for basic manim mesh uses](docs/images/PyramidScene.png)](https://user-images.githubusercontent.com/1500595/193240449-5978f46f-68b0-4d08-bf37-4ff1fea54f28.mp4)

The general procedure is like in manim, create a class with a construct method. Then create and add the instance of the renderable mesh you like to use. This mesh will receive the real node-face mesh and manipulate it. 
You can shift (translate) and scale the whole mesh or single vertices. Additionally most of the manim functions are available as coloring single objects. Somehow Rotate does not work, because it only updates the copy of the rotation and therefore our own mesh class does not get updated.

### Parameters
As parameters got a little overwhelming, there are a few default parameters for the meshes in `params.py`. You just need to pass kwargs that you want to change while creating the mesh.

## Development
In PyCharm set `./src/`-folder as project sources root and `./tests/`-folder as tests sources root if necessary.

Install poetry according to your likings.

Activate the poetry venv: `cd ./manim_meshes/`, then `poetry shell`

Install: `poetry install`
If you get errors, it is possible that you have to pip install `pycairo` and or `manimpango` manually (globally?), depending on your setup. Make sure to run `poetry install` until there are no more errors!

After updating packages make sure to update poetry and your git .lock file: `poetry update`

If you implemented some features, update version using the matching poetry command: `poetry version prerelease|patch|minor|major`
See the Poetry [Documentation](https://python-poetry.org/docs/cli/#version).
If the CI works properly, Publishing to pypi on master branch is automatically, it can be done manually with the correct privileges: `poetry publish --build`. Don't hesitate to contact any of the developers or open issues.

### Debugging
Like with basic manim, create an executable Python file with something around:

```python
from tests.test_scene import SnapToGridScene
if __name__ == "__main__":
    scene = SnapToGridScene()
    scene.render()
```

Then debug the file and place breakpoints as expected. May not work with the "renderer=opengl" flag that is necessary for some scripts. Please update this example if you found out how to do it.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/bmmtstb/manim-meshes",
    "name": "manim-meshes",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "==3.8.18",
    "maintainer_email": "",
    "keywords": "animation,manim,trimeshes,mesh",
    "author": "Brizar",
    "author_email": "martin.steinborn@stud.tu-darmstadt.de",
    "download_url": "https://files.pythonhosted.org/packages/a4/3b/6b8490cfbbca228d75922b108c8674a184b403b3b641180d70971f555d94/manim-meshes-0.0.8.tar.gz",
    "platform": null,
    "description": "[![Python Test and Lint](https://github.com/bmmtstb/manim-meshes/actions/workflows/python_ci_test.yaml/badge.svg)](https://github.com/bmmtstb/manim-meshes/actions/workflows/python_ci_test.yaml) [![CodeQL](https://github.com/bmmtstb/manim-meshes/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/bmmtstb/manim-meshes/actions/workflows/codeql-analysis.yml)\n# Manim for Meshes\n\n> \u26a0\ufe0f not fully optimal - but fine for smaller meshes\n> \n> Manim and the OpenGL renderer are not really friends right now, therefore most of the code runs terribly slow for larger meshes. In Addition to the small educational meshes we present a faster mesh that uses a custom shader but this requires manipulating the manim library.\n>\n> Stay tuned or feel free to assist. Either here or directly in the manim OpenGL part. Not necessarily everything is a B\u00e9zier curve... \n\nManim-Trimeshes implements manim functionalities for different types of meshes using either basic node-face data structures or by importing meshes from the python [trimesh](https://pypi.org/project/trimesh/ \"trimesh on pypi\") library.\n\nIt is mainly developed as a Project for Interactive Graphics Systems Group (GRIS) at TU Darmstadt University, but is made publicly available for everyone interested in rendering and animating meshes.\n\n## Installation\n\nManim-meshes has been published to [pypi](https://pypi.org/project/manim-meshes/) and therefore can be easily installed using:\n\n``pip install manim-meshes``\n\n## Usage\n\n``from manim_meshes import *``\n\nWhile executing a commandline manim script, make sure to set the `--renderer=opengl` flag, the Cairo renderer will ins most cases not work.\n\nThe basic `ManimMesh` and `Manim2DMesh` from `manim_models/basic_mesh` can currently only be used for smaller meshes (<1k Nodes), because it is dependent on the manim internal shaders which are not really implemented optimally. This type of mesh can be easily used for 2D and smaller 3D explanatory videos, not for high resolution rendering. Both these classes should give manim-functionalities like shift, rotate and scale. But due to the sheer amount of MObject functions we can not implement all of them, so make sure the renderer has overwritten the method you are trying to use if something does not look right.\n\nThe `TriangleManim2DMesh` from `triangle_mesh` implements further functions that are only reasonable for two-dimensional triangle meshes. (e.g. Delaunay) This was designed for educational purposes. There is also a package\n`delaunay` containing multiple useful functions regarding delaunay triangulations, e.g. Voronoi diagrams, checking the delaunay criterion or a divide & conquer algorithm.\n\nThe more advanced `FastManimMesh` from `opengl_mesh` uses a custom shader which needs to be inserted into the base manim implementation at this time! But therefore it can render enormous meshes fast. Sadly rendering is kind of everything this renderer is capable of at the moment.\n\nAll these Mesh-Renders reference a mesh based on the `Mesh`-Class, in `data_models`, which should implement a multitude of basic Mesh-functions.\n\n## Example\n\n![Static image of a cone, to show the rendering capabilities](docs/images/ConeScene_v0.16.0.post0.png)\n\nWith active poetry venv Run one of the minimal test examples: `manim --renderer=opengl tests/test_scene.py ConeScene`.\n\nMultiple other examples can be found in the `tests/test_scene.py` file.\n\n[![see the PyramidScene for basic manim mesh uses](docs/images/PyramidScene.png)](https://user-images.githubusercontent.com/1500595/193240449-5978f46f-68b0-4d08-bf37-4ff1fea54f28.mp4)\n\nThe general procedure is like in manim, create a class with a construct method. Then create and add the instance of the renderable mesh you like to use. This mesh will receive the real node-face mesh and manipulate it. \nYou can shift (translate) and scale the whole mesh or single vertices. Additionally most of the manim functions are available as coloring single objects. Somehow Rotate does not work, because it only updates the copy of the rotation and therefore our own mesh class does not get updated.\n\n### Parameters\nAs parameters got a little overwhelming, there are a few default parameters for the meshes in `params.py`. You just need to pass kwargs that you want to change while creating the mesh.\n\n## Development\nIn PyCharm set `./src/`-folder as project sources root and `./tests/`-folder as tests sources root if necessary.\n\nInstall poetry according to your likings.\n\nActivate the poetry venv: `cd ./manim_meshes/`, then `poetry shell`\n\nInstall: `poetry install`\nIf you get errors, it is possible that you have to pip install `pycairo` and or `manimpango` manually (globally?), depending on your setup. Make sure to run `poetry install` until there are no more errors!\n\nAfter updating packages make sure to update poetry and your git .lock file: `poetry update`\n\nIf you implemented some features, update version using the matching poetry command: `poetry version prerelease|patch|minor|major`\nSee the Poetry [Documentation](https://python-poetry.org/docs/cli/#version).\nIf the CI works properly, Publishing to pypi on master branch is automatically, it can be done manually with the correct privileges: `poetry publish --build`. Don't hesitate to contact any of the developers or open issues.\n\n### Debugging\nLike with basic manim, create an executable Python file with something around:\n\n```python\nfrom tests.test_scene import SnapToGridScene\nif __name__ == \"__main__\":\n    scene = SnapToGridScene()\n    scene.render()\n```\n\nThen debug the file and place breakpoints as expected. May not work with the \"renderer=opengl\" flag that is necessary for some scripts. Please update this example if you found out how to do it.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "rendering 2D and 3D Meshes with manim for displaying and educational Purposes.",
    "version": "0.0.8",
    "project_urls": {
        "Homepage": "https://github.com/bmmtstb/manim-meshes",
        "Repository": "https://github.com/bmmtstb/manim-meshes"
    },
    "split_keywords": [
        "animation",
        "manim",
        "trimeshes",
        "mesh"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "14d9b20cd2be9ea7f6fc6d678359d815c42c09192db5a75482a0a104c80621d4",
                "md5": "b55bb913392429b7c44b46a66561da02",
                "sha256": "4d2c6f58dfc7d2e718b82574064f3b47e0c16d90410d28096f176ad447ba57fd"
            },
            "downloads": -1,
            "filename": "manim_meshes-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b55bb913392429b7c44b46a66561da02",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "==3.8.18",
            "size": 1792427,
            "upload_time": "2023-10-24T09:44:41",
            "upload_time_iso_8601": "2023-10-24T09:44:41.167709Z",
            "url": "https://files.pythonhosted.org/packages/14/d9/b20cd2be9ea7f6fc6d678359d815c42c09192db5a75482a0a104c80621d4/manim_meshes-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a43b6b8490cfbbca228d75922b108c8674a184b403b3b641180d70971f555d94",
                "md5": "cda740e85b4764888b0a0dc1a79ce1d1",
                "sha256": "a28332fc152eb7f411549d97d2ae90957fcc3283988ff1996311f7fbbe9570b0"
            },
            "downloads": -1,
            "filename": "manim-meshes-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "cda740e85b4764888b0a0dc1a79ce1d1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "==3.8.18",
            "size": 1782539,
            "upload_time": "2023-10-24T09:44:38",
            "upload_time_iso_8601": "2023-10-24T09:44:38.227961Z",
            "url": "https://files.pythonhosted.org/packages/a4/3b/6b8490cfbbca228d75922b108c8674a184b403b3b641180d70971f555d94/manim-meshes-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-24 09:44:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bmmtstb",
    "github_project": "manim-meshes",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "manim-meshes"
}
        
Elapsed time: 0.13617s