Cosmic BunnyΒΆ

../../_images/bunny_cosmic.png

In this case, random values were assigned to the vertices for the Stanford bunny vertex data. Geometric and color smoothing were used for the visualization, with colormapping using the following colormap:

../../_images/cmap_cosmic.png
import numpy as np
import matplotlib.pyplot as plt
import s3dlib.surface as s3d
import s3dlib.cmap_utilities as cmu

# Cosmic Bunny using Obj datafile with geometric/color smoothing

# Setup surface ................................................
cmap = cmu.hue_cmap(smooth=.5,name='cosmic')
surface = s3d.get_surfgeom_from_obj("data/bunny.obj")

# add some random vertex values and apply a colormap
np.random.seed(5)
vertVals = np.random.uniform(0,1,len(surface.vertices.T))
surface.set_vertvals(vertVals)
surface.triangulate(3)
surface.map_cmap_from_vertvals( cmap )

# Construct figure, add surface, plot ..........................

fig = plt.figure(figsize=plt.figaspect(1), facecolor='k')
fig.text(0.1,0.03,'* assigned random vertex values', color='w')
ax = plt.axes(projection='3d', aspect='equal', facecolor='k')
s3d.auto_scale(ax,surface,uscale=.8)
ax.set_axis_off()
surface.shade(flat=False).hilite(flat=False,focus=1.5)
ax.add_collection3d(surface)

fig.tight_layout(pad=0)

plt.show()