Package ixagon.surface.mapper
Class SurfaceMapper
- java.lang.Object
-
- ixagon.surface.mapper.SurfaceMapper
-
public class SurfaceMapper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanaltDownstatic intCMDprotected booleanctrlDownprotected booleandisableSelectionToolprotected booleangroupingprotected booleanisDraggingintMODEstatic intMODE_CALIBRATEstatic intMODE_RENDERprotected processing.core.PVectorprevMouseprotected ArrayList<SuperSurface>selectedSurfacesprotected RectangleselectionToolprotected booleansnapprotected processing.core.PVectorstartPosprotected ArrayList<SuperSurface>surfacesStringVERSION
-
Constructor Summary
Constructors Constructor Description SurfaceMapper(processing.core.PApplet parent, int width, int height)Create instance of IxKeystone
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEventHandler(Object object, String methodName)voidaddSelectedSurface(SuperSurface cps)Add a surface to selected surfacesSuperSurfaceaddSurface(SuperSurface superSurface)Add a surface to surfaceMappervoidbringBackSurface()voidbringFrontSurface()voidbringSurfaceToFront(int index)Places the surface last in the surfaces array, i.e.voidclearSelectedSurfaces()Clears the arraylist of selected surfaces.voidclearSurfaces()Remove all surfacesSuperSurfacecreateBezierSurface(int res)Creates a Bezier surface with perspective transform.SuperSurfacecreateBezierSurface(int res, int x, int y)Creates a Bezier surface at X/Y with perspective transform.SuperSurfacecreateQuadSurface(int res)Creates a Quad surface with perspective transform.SuperSurfacecreateQuadSurface(int res, int x, int y)Creates a Quad surface at X/Y with perspective transform.voiddisableMouseEvents()Unregisters Mouse Event listener for the SurfaceMappervoidenableMouseEvents()Registers Mouse Event listener for the SurfaceMapperbooleanfindActiveBezierSurface(float mX, float mY)Check if coordinates is inside any of the bezier surfaces.booleanfindActiveQuadSurface(float mX, float mY)Check if coordinates is inside any of the quad surfaces.booleanfindActiveSurface(float mX, float mY)Check if coordinates is inside any of the surfaces.voidfireEvent(int id)Fire event to objectint[]getColor()Returns the array of colors used in calibration mode for coloring the surfaces.booleangetDebug()See if debug mode is on.booleangetDisableSelectionTool()Is the selection tool disabled?processing.core.PFontgetIdFont()Get font for drawing textintgetMode()Check which mode is enabled (render or calibrate)intgetNumAddedSurfaces()processing.core.PVectorgetPrevMouse()Get previous mouse positionArrayList<SuperSurface>getSelectedSurfaces()Get the selected surfacesintgetSelectionDistance()Get current max distance for an object to be selectedintgetSelectionMouseColor()RectanglegetSelectionTool()Returns the rectangle used for selecting surfacesList<Sketch>getSketchList()booleangetSnap()See if snap mode is usedintgetSnapDistance()See the snap distanceSuperSurfacegetSurfaceById(int id)Get surface by Id.ArrayList<SuperSurface>getSurfaces()Get all surfacesbooleanisAllowUserInput()Check if any user event is allowedbooleanisAltDown()Is ALT pressed?booleanisCtrlDown()Is CTRL pressed?booleanisDragging()booleanisEnableSelectionMouse()booleanisGrouping()Check if multiple surfaces are being manipulatedbooleanisUsingBackground()Boolean used to know if the background image should be rendered in calibration mode.voidkeyEvent(processing.event.KeyEvent k)KeyEvent methodvoidksMouseEvent(processing.event.MouseEvent e)MouseEvent method.voidload(File file)Load projection map from filevoidmouseEvent(processing.event.MouseEvent e)MouseEvent method.voidmovePoint(SuperSurface ss, int x, int y)Move a point of a surfacestatic <T> voidremoveDuplicates(ArrayList<T> list)voidremoveSelectedSurfaces()Delete the selected surfacesvoidrender(processing.core.PGraphics glos)Render method used when calibrating.voidsave(File file)Save all projection mapping data to filevoidsave(processing.data.XML root)Puts all projection mapping data in the XMLElementvoidselectSurfaces(int mX, int mY)voidsetAllowUserInput(boolean allowUserInput)Set if any user event is allowedvoidsetBackground(processing.core.PImage tex)Optionally set a background image in calibration mode.voidsetColor(int[] ccolor)Set the array of colors used in calibration mode for coloring the surfaces.voidsetCtrlDown(boolean pressed)Set CTRL pressedvoidsetDebug(boolean debug)Manually set debug mode.voidsetDisableSelectionTool(boolean disableSelectionTool)Enable/disable selection toolvoidsetEnableSelectionMouse(boolean enableSelectionMouse)voidsetGrouping(boolean grouping)Set if multiple surfaces are being manipulatedvoidsetIsDragging(boolean isDragging)voidsetModeCalibrate()Set mode to calibratevoidsetModeRender()Set mode to rendervoidsetNumAddedSurfaces(int numAddedSurfaces)voidsetPrevMouse(float x, float y)Set previous mouse positionvoidsetSelectedSurface(SuperSurface cps)Select the surface.voidsetSelectionDistance(int selectionDistance)Set the max distance for an object to be selectedvoidsetSelectionMouseColor(int selectionMouseColor)voidsetSelectionTool(int x, int y, int width, int height)Set the selection toolvoidsetSelectionTool(Rectangle r)Set the selection toolvoidsetShakeAll(int strength, int speed, int fallOfSpeed)Shake all surfaces with max Z-displacement strength, vibration-speed speed, and shake decline fallOfSpeed.voidsetSketchList(List<Sketch> sketchList)voidsetSnap(boolean snap)Manually set corner snap modevoidsetSnapDistance(int snapDistance)Set corner snap distancevoidsetUsingBackground(boolean val)Set if background image should rendered in calibration modevoidshake()Update shaking for all surfacesvoidtoggleCalibration()Toggle the modevoidtoggleSnap()Toggle if corner snapping is usedStringversion()
-
-
-
Field Detail
-
MODE_RENDER
public static final int MODE_RENDER
- See Also:
- Constant Field Values
-
MODE_CALIBRATE
public static final int MODE_CALIBRATE
- See Also:
- Constant Field Values
-
CMD
public static final int CMD
- See Also:
- Constant Field Values
-
VERSION
public final String VERSION
- See Also:
- Constant Field Values
-
MODE
public int MODE
-
surfaces
protected ArrayList<SuperSurface> surfaces
-
selectedSurfaces
protected ArrayList<SuperSurface> selectedSurfaces
-
snap
protected boolean snap
-
prevMouse
protected processing.core.PVector prevMouse
-
ctrlDown
protected boolean ctrlDown
-
altDown
protected boolean altDown
-
grouping
protected boolean grouping
-
selectionTool
protected Rectangle selectionTool
-
startPos
protected processing.core.PVector startPos
-
isDragging
protected boolean isDragging
-
disableSelectionTool
protected boolean disableSelectionTool
-
-
Method Detail
-
removeDuplicates
public static <T> void removeDuplicates(ArrayList<T> list)
-
addSelectedSurface
public void addSelectedSurface(SuperSurface cps)
Add a surface to selected surfaces- Parameters:
cps-
-
addSurface
public SuperSurface addSurface(SuperSurface superSurface)
Add a surface to surfaceMapper- Parameters:
superSurface-- Returns:
-
bringSurfaceToFront
public void bringSurfaceToFront(int index)
Places the surface last in the surfaces array, i.e. on top.- Parameters:
index-
-
clearSelectedSurfaces
public void clearSelectedSurfaces()
Clears the arraylist of selected surfaces.
-
clearSurfaces
public void clearSurfaces()
Remove all surfaces
-
bringFrontSurface
public void bringFrontSurface()
-
bringBackSurface
public void bringBackSurface()
-
createBezierSurface
public SuperSurface createBezierSurface(int res)
Creates a Bezier surface with perspective transform. Res is the amount of subdivisioning. Returns the surface after it has been created.- Parameters:
res-- Returns:
-
createBezierSurface
public SuperSurface createBezierSurface(int res, int x, int y)
Creates a Bezier surface at X/Y with perspective transform. Res is the amount of subdivisioning. Returns the surface after it has been created.- Parameters:
res-x-y-- Returns:
-
createQuadSurface
public SuperSurface createQuadSurface(int res)
Creates a Quad surface with perspective transform. Res is the amount of subdivisioning. Returns the surface after it has been created.- Parameters:
res-- Returns:
-
createQuadSurface
public SuperSurface createQuadSurface(int res, int x, int y)
Creates a Quad surface at X/Y with perspective transform. Res is the amount of subdivisioning. Returns the surface after it has been created.- Parameters:
res-x-y-- Returns:
-
disableMouseEvents
public void disableMouseEvents()
Unregisters Mouse Event listener for the SurfaceMapper
-
enableMouseEvents
public void enableMouseEvents()
Registers Mouse Event listener for the SurfaceMapper
-
findActiveBezierSurface
public boolean findActiveBezierSurface(float mX, float mY)Check if coordinates is inside any of the bezier surfaces.- Parameters:
mX-mY-- Returns:
-
findActiveQuadSurface
public boolean findActiveQuadSurface(float mX, float mY)Check if coordinates is inside any of the quad surfaces.- Parameters:
mX-mY-- Returns:
-
findActiveSurface
public boolean findActiveSurface(float mX, float mY)Check if coordinates is inside any of the surfaces.- Parameters:
mX-mY-- Returns:
-
fireEvent
public void fireEvent(int id)
Fire event to object
-
getColor
public int[] getColor()
Returns the array of colors used in calibration mode for coloring the surfaces.- Returns:
-
getDebug
public boolean getDebug()
See if debug mode is on.- Returns:
-
getDisableSelectionTool
public boolean getDisableSelectionTool()
Is the selection tool disabled?- Returns:
-
getIdFont
public processing.core.PFont getIdFont()
Get font for drawing text- Returns:
-
getMode
public int getMode()
Check which mode is enabled (render or calibrate)- Returns:
-
getNumAddedSurfaces
public int getNumAddedSurfaces()
-
getPrevMouse
public processing.core.PVector getPrevMouse()
Get previous mouse position- Returns:
-
getSelectedSurfaces
public ArrayList<SuperSurface> getSelectedSurfaces()
Get the selected surfaces- Returns:
-
getSelectionDistance
public int getSelectionDistance()
Get current max distance for an object to be selected- Returns:
-
getSelectionMouseColor
public int getSelectionMouseColor()
-
getSelectionTool
public Rectangle getSelectionTool()
Returns the rectangle used for selecting surfaces- Returns:
-
getSnap
public boolean getSnap()
See if snap mode is used- Returns:
-
getSnapDistance
public int getSnapDistance()
See the snap distance- Returns:
-
getSurfaceById
public SuperSurface getSurfaceById(int id)
Get surface by Id.- Parameters:
id-- Returns:
-
getSurfaces
public ArrayList<SuperSurface> getSurfaces()
Get all surfaces- Returns:
- surfaces
-
isAllowUserInput
public boolean isAllowUserInput()
Check if any user event is allowed- Returns:
-
isAltDown
public boolean isAltDown()
Is ALT pressed?- Returns:
-
isCtrlDown
public boolean isCtrlDown()
Is CTRL pressed?- Returns:
-
isDragging
public boolean isDragging()
- Returns:
-
isEnableSelectionMouse
public boolean isEnableSelectionMouse()
-
isGrouping
public boolean isGrouping()
Check if multiple surfaces are being manipulated- Returns:
-
isUsingBackground
public boolean isUsingBackground()
Boolean used to know if the background image should be rendered in calibration mode.- Returns:
-
keyEvent
public void keyEvent(processing.event.KeyEvent k)
KeyEvent method- Parameters:
k-
-
ksMouseEvent
public void ksMouseEvent(processing.event.MouseEvent e)
MouseEvent method.- Parameters:
e-
-
load
public void load(File file)
Load projection map from file- Parameters:
file-
-
mouseEvent
public void mouseEvent(processing.event.MouseEvent e)
MouseEvent method. Forwards the MouseEvent to ksMouseEvent if user input is allowed- Parameters:
e-
-
movePoint
public void movePoint(SuperSurface ss, int x, int y)
Move a point of a surface- Parameters:
ss-x-y-
-
removeSelectedSurfaces
public void removeSelectedSurfaces()
Delete the selected surfaces
-
render
public void render(processing.core.PGraphics glos)
Render method used when calibrating. Shouldn't be used for final rendering.- Parameters:
glos-
-
save
public void save(processing.data.XML root)
Puts all projection mapping data in the XMLElement- Parameters:
root-
-
save
public void save(File file)
Save all projection mapping data to file- Parameters:
file-
-
selectSurfaces
public void selectSurfaces(int mX, int mY)
-
setAllowUserInput
public void setAllowUserInput(boolean allowUserInput)
Set if any user event is allowed- Parameters:
allowUserInput-
-
setBackground
public void setBackground(processing.core.PImage tex)
Optionally set a background image in calibration mode.- Parameters:
tex-
-
setColor
public void setColor(int[] ccolor)
Set the array of colors used in calibration mode for coloring the surfaces.- Parameters:
ccolor-
-
setCtrlDown
public void setCtrlDown(boolean pressed)
Set CTRL pressed- Parameters:
pressed-
-
setDebug
public void setDebug(boolean debug)
Manually set debug mode. (debug mode will print more to console)- Parameters:
debug-
-
setDisableSelectionTool
public void setDisableSelectionTool(boolean disableSelectionTool)
Enable/disable selection tool- Parameters:
disableSelectionTool-
-
setEnableSelectionMouse
public void setEnableSelectionMouse(boolean enableSelectionMouse)
-
setGrouping
public void setGrouping(boolean grouping)
Set if multiple surfaces are being manipulated- Parameters:
grouping-
-
setIsDragging
public void setIsDragging(boolean isDragging)
- Parameters:
isDragging-
-
setModeCalibrate
public void setModeCalibrate()
Set mode to calibrate
-
setModeRender
public void setModeRender()
Set mode to render
-
setNumAddedSurfaces
public void setNumAddedSurfaces(int numAddedSurfaces)
-
setPrevMouse
public void setPrevMouse(float x, float y)Set previous mouse position- Parameters:
x-y-
-
setSelectedSurface
public void setSelectedSurface(SuperSurface cps)
Select the surface. Deselects all previously selected surfaces.- Parameters:
cps-
-
setSelectionDistance
public void setSelectionDistance(int selectionDistance)
Set the max distance for an object to be selected- Parameters:
selectionDistance-
-
setSelectionMouseColor
public void setSelectionMouseColor(int selectionMouseColor)
-
setSelectionTool
public void setSelectionTool(Rectangle r)
Set the selection tool- Parameters:
r-
-
setSelectionTool
public void setSelectionTool(int x, int y, int width, int height)Set the selection tool- Parameters:
x-y-width-height-
-
setShakeAll
public void setShakeAll(int strength, int speed, int fallOfSpeed)Shake all surfaces with max Z-displacement strength, vibration-speed speed, and shake decline fallOfSpeed. (min 0, max 1000 (1000 = un-ending shaking))- Parameters:
strength-speed-fallOfSpeed-
-
setSnap
public void setSnap(boolean snap)
Manually set corner snap mode- Parameters:
snap-
-
setSnapDistance
public void setSnapDistance(int snapDistance)
Set corner snap distance- Parameters:
snapDistance-
-
setUsingBackground
public void setUsingBackground(boolean val)
Set if background image should rendered in calibration mode- Parameters:
val-
-
shake
public void shake()
Update shaking for all surfaces
-
toggleCalibration
public void toggleCalibration()
Toggle the mode
-
toggleSnap
public void toggleSnap()
Toggle if corner snapping is used
-
version
public String version()
-
-