Mapping multiple objects
Shape Mapper allows you to map two physical objects separately.
Write the Processing sketch
Starting from the code in the Getting Started tutorial, we need to make a couple of modifications.
-
In addition to importing the main
ShapeMapper
class, you'll also need to import two other classes,MappedShape
andMapping
: -
We'll need to store references to two
PShape
s at the top level of our sketch. In addition, we'll also need to store references to twoMappedShape
s. -
Modify the setup function to add the shapes with the
addShape(...)
method. -
Now modify the draw function with this code:
-
Putting it all together:
import spacefiller.shapemapper.ShapeMapper; import spacefiller.shapemapper.MappedShape; import spacefiller.shapemapper.Mapping; ShapeMapper mapper; PShape box; PShape sphere; MappedShape mappedBox; MappedShape mappedSphere; void setup() { fullScreen(P3D); box = createShape(BOX, 150); sphereDetail(8); sphere = createShape(SPHERE, 150); mapper = new ShapeMapper(this); mappedBox = mapper.addShape("box", box); mappedSphere = mapper.addShape("sphere", sphere); } void draw() { background(0); mappedBox.beginMapping(); shape(box); mappedBox.endMapping(); mappedSphere.beginMapping(); shape(sphere); mappedSphere.endMapping(); }
Calibrate the projection mapping
- Run the sketch.
- Hit
Space
to switch fromRender
mode toCalibrate
mode. - Click a point on your model to select it.
- Hit
Tab
to switch to mapping mode. -
Look at your object in physical space and move your mouse so that the crosshairs are centered on the corresponding vertex of the physical object. Click to create a point in the projected space.
-
Hit
Tab
to switch back to point selection. Choose another point and repeat the process. - After mapping 6 points, a full calibration will be automatically estimated.
- Now press
Down ↓
to switch to the next shape. - Repeat steps 3-7 for your second shape.