Commit e05e5646 authored by Dario Seyb's avatar Dario Seyb

added another example

parent 53ca907d
include README.rst
include README.md
# MeshVis
## Setup
- Clone the repository
- pip install -e .
## Dependencies
- [pythreejs](https://github.com/jovyan/pythreejs/) 1.0.0-beta4
- [openmesh-python](https://graphics.rwth-aachen.de:9000/adielen/openmesh-python) latest
## Example
```python
import meshvis
m = om.TriMesh()
om.read_mesh(m, '/home/dseyb/git/openmesh-python/tests/TestFiles/cube-minimal-normals.ply')
meshvis.display_openmesh(m)
meshvis.display_file('/home/dseyb/git/openmesh-python/tests/TestFiles/square_material_texture.obj')
```
```python
import meshvis
import openmesh as om
import numpy as np
# Load Mesh
m = om.TriMesh()
om.read_mesh(m, "./mouse.obj")
# Create Context
ctx = meshvis.Context(width=640, height=480)
# Get vertices and faces from the mesh
vertices = m.points()
faces = m.face_vertex_indices()
# We don't have normals, calculate them
normals = meshvis.calculateFaceNormals(m.points(), m.face_vertex_indices())
# Choose a random color for each face
colors = meshvis.FaceAttribute(np.random.rand(len(faces), 3))
# Draw the mesh with flat shading
ctx.draw_faces(vertices, faces,
normals = normals,
colors = colors,
shading = 'flat')
# Draw edges on top with random colors
ctx.draw_edges(vertices, m.ev_indices(),
colors = meshvis.FaceAttribute(np.random.rand(len(m.ev_indices()), 3)),
linewidth=3)
# Calculate data to display normals as edges
normal_vis_verts, normal_vis_edges = meshvis.calculateNormalEdges(vertices, faces, normals, length=0.05)
# Draw the normals in
ctx.draw_edges(normal_vis_verts, normal_vis_edges, colors = colors)
# Draw a point for each vertex
ctx.draw_vertices(vertices, point_size=4, colors='red')
# Finally display it
ctx.display()
```
![mouse](./docs/images/mouse.png)
\ No newline at end of file
# MeshVis
## Setup
- Clone the repository
- pip install -e .
## Dependencies
- [pythreejs](https://github.com/jovyan/pythreejs/) 0.4.x
- [openmesh-python] (https://graphics.rwth-aachen.de:9000/adielen/openmesh-python)
## Example
```
import meshvis
m = om.TriMesh()
om.read_mesh(m, '/home/dseyb/git/openmesh-python/tests/TestFiles/cube-minimal-normals.ply')
meshvis.display_openmesh(m)
meshvis.display_file('/home/dseyb/git/openmesh-python/tests/TestFiles/square_material_texture.obj')
```
\ No newline at end of file
from setuptools import setup
def readme():
with open('README.rst') as f:
with open('README.md') as f:
return f.read()
setup(name='meshvis',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment