Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
threevis
threevis
Commits
a0f2da98
Commit
a0f2da98
authored
Apr 05, 2018
by
Janis Born
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use import threevis as tv in README.md examples
parent
db5ed605
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
README.md
README.md
+15
-16
No files found.
README.md
View file @
a0f2da98
...
...
@@ -14,53 +14,52 @@ A Python library for visualizing meshes, point clouds, and other geometry in Jup
### Quick Mesh Inspection
```
python
import
threevis
import
threevis
as
tv
import
openmesh
as
om
m
=
om
.
read_trimesh
(
'examples/models/bunny.obj'
)
threevis
.
display_openmesh
(
m
)
m
=
om
.
read_trimesh
(
'models/bunny.obj'
)
tv
.
display_openmesh
(
m
)
```
### Custom Rendering
```
python
import
threevis
import
threevis
as
tv
import
openmesh
as
om
import
numpy
as
np
# Load Mesh
m
=
om
.
read_trimesh
(
'mouse.obj'
)
m
=
om
.
read_trimesh
(
'
models/
mouse.obj'
)
# Create Context
ctx
=
t
hreevis
.
Context
(
width
=
640
,
height
=
480
)
ctx
=
t
v
.
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
=
t
hreevis
.
calculate_face_normals
(
m
.
points
(),
m
.
face_vertex_indices
())
normals
=
t
v
.
calculate_face_normals
(
m
.
points
(),
m
.
face_vertex_indices
())
# Choose a random color for each face
colors
=
t
hreevis
.
FaceAttribute
(
np
.
random
.
rand
(
len
(
faces
),
3
))
colors
=
t
v
.
FaceAttribute
(
np
.
random
.
rand
(
len
(
faces
),
3
))
# Draw the mesh with flat shading
ctx
.
draw_faces
(
vertices
,
faces
,
normals
=
normals
,
colors
=
colors
,
shading
=
'flat'
)
normals
=
normals
,
colors
=
colors
,
shading
=
'flat'
)
# Draw edges on top with random colors
ctx
.
draw_edges
(
vertices
,
m
.
ev_indices
(),
colors
=
threevis
.
FaceAttribute
(
np
.
random
.
rand
(
len
(
m
.
ev_indices
()),
3
)),
linewidth
=
3
)
colors
=
tv
.
FaceAttribute
(
np
.
random
.
rand
(
len
(
m
.
ev_indices
()),
3
)),
line
_
width
=
3
)
# Calculate data to display normals as edges
normal_vis_verts
,
normal_vis_edges
=
t
hreevis
.
calculate_normal_edges
(
vertices
,
faces
,
normals
,
length
=
0.05
)
normal_vis_verts
,
normal_vis_edges
=
t
v
.
calculate_normal_edges
(
vertices
,
faces
,
normals
,
length
=
0.05
)
# Draw the normals in
ctx
.
draw_edges
(
normal_vis_verts
,
normal_vis_edges
,
colors
=
colors
)
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'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment