This Java+Scala code was used to render the ShapeNet model screenshots and thumbnails. It can handle loading of OBJ+MTL, COLLADA DAE, KMZ, and PLY format 3D meshes.
Java JDK 1.8 is required. Make sure the JDK paths are added to the system path. Please also ensure that the following commands are in your path:
For compilation on Linux, just run
WORK_DIR(where output screenshots are saved) and
SHAPENET_VIEWER_DIR(to shapenet-viewer checkout) as needed.
scripts/viewer.shto start the viewer. Look in
config/viewer.conffor general settings and
config/screenshots.conffor screenshot generation settings used for ShapeNet thumbnails.
Once the viewer has started, press
F1to bring up the help screen, and
F4to bring up the command console. The
helpcommand can give you an overview, and tab completion is a good way to get a feel for all available options.
Before you use the viewer you must register a local copy of ShapeNetCore by specifying the path to the root directory of the extracted ShapeNetCore archive using:
After registering the path to your local ShapeNet, you can display models by running one of the following commands:
load model load model 3dw.1a04e3eab45ca15dd86060f189eb133 load model random load model random 3dw chair
Note that the bicycle synset comes from
yobi3d, and to display a model from the bicycle synset you would do
load model yobi3d.0Ap5HKn9y3 load model random yobi3d bicycle
We do not currently have textures for the
You can also load models directly from the file system or the web using
load model load model
You can save screenshots for the currently loaded model using:
save model screenshots
Or you can start a batch process to render all screenshots using:
save model screenshots all 3dw
wherecan optionally specify a specific category subset (e.g.,
All screenshots are saved to
$WORK_DIR/screenshots/modelsByCategory/if the category specifier was used. If you want to manually specify the base output directory for screenshots use the command:
save model screenshotscommands will save files under the given path.
Ordering of models rendered in a batch is randomized by default, and existing screenshots are not re-rendered (so it is safe to restart the process without regnerating existing screenshots). A few important parameters that control the screenshot rendering are given below (along with their default values). These can be set using the command
setor by adding
viewer. =to the
nImagesPerModel = 8: how many equally-spaced turntable positions (increments of the camera azimuth angle) to render
cameraAngleFromHorizontal = 30: camera elevation in degrees from horizontal (ground) plane
includeCanonicalViews = true: whether to render top, bottom, left, right, front and back views in addition to turntable views
cameraPositionStrategy = fit: options are
distance(set camera distance from closest object bounding box edge to be equal to
modelDistanceScale * maxModelDimension) or
fit(translate camera so that model fits within frame) or
distance_to_centroid(set camera distance from object centroid to be equal to
modelDistanceScale * maxModelDimension)
addFloor = false: whether a floor plane should be added below the model
The viewer caches loaded models in memory so if you modify a model and would like to reload it from disk, use the
If you would like to switch to loading
KMZmodels from the ShapeNet web server to compare with the
OBJ+MTLmodels, use the command
set loadFormat kmz(and
set loadFormat objto revert to default local loading). The ShapeNet website thumbnails were all rendered from the
You can also register a local copy of ShapeNetSem by specifying the path to the root directory containing all downloaded and extracted ShapeNetSem files:
The directory structure of ShapeNetSem should look something like this:
/metadata.csv /COLLADA/... /models/... /textures/...
You can display ShapeNetSem models using the
load model wss.1a4216ac5ffbf1e89c7ce4b816b39bd0 load model random wss chair
The viewer can take in scripts in a given
.conffile to perform batch rendering tasks. See the examples in the
confdirectory, and particulary the
Please feel free to contact us if you have any questions about the viewer framework. Issue reports or pull requests with improvements are welcome! If you use this framework in your research please cite the ShapeNet report.