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 boolean
altDown
static int
CMD
protected boolean
ctrlDown
protected boolean
disableSelectionTool
protected boolean
grouping
protected boolean
isDragging
int
MODE
static int
MODE_CALIBRATE
static int
MODE_RENDER
protected processing.core.PVector
prevMouse
protected ArrayList<SuperSurface>
selectedSurfaces
protected Rectangle
selectionTool
protected boolean
snap
protected processing.core.PVector
startPos
protected ArrayList<SuperSurface>
surfaces
String
VERSION
-
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 void
addEventHandler(Object object, String methodName)
void
addSelectedSurface(SuperSurface cps)
Add a surface to selected surfacesSuperSurface
addSurface(SuperSurface superSurface)
Add a surface to surfaceMappervoid
bringBackSurface()
void
bringFrontSurface()
void
bringSurfaceToFront(int index)
Places the surface last in the surfaces array, i.e.void
clearSelectedSurfaces()
Clears the arraylist of selected surfaces.void
clearSurfaces()
Remove all surfacesSuperSurface
createBezierSurface(int res)
Creates a Bezier surface with perspective transform.SuperSurface
createBezierSurface(int res, int x, int y)
Creates a Bezier surface at X/Y with perspective transform.SuperSurface
createQuadSurface(int res)
Creates a Quad surface with perspective transform.SuperSurface
createQuadSurface(int res, int x, int y)
Creates a Quad surface at X/Y with perspective transform.void
disableMouseEvents()
Unregisters Mouse Event listener for the SurfaceMappervoid
enableMouseEvents()
Registers Mouse Event listener for the SurfaceMapperboolean
findActiveBezierSurface(float mX, float mY)
Check if coordinates is inside any of the bezier surfaces.boolean
findActiveQuadSurface(float mX, float mY)
Check if coordinates is inside any of the quad surfaces.boolean
findActiveSurface(float mX, float mY)
Check if coordinates is inside any of the surfaces.void
fireEvent(int id)
Fire event to objectint[]
getColor()
Returns the array of colors used in calibration mode for coloring the surfaces.boolean
getDebug()
See if debug mode is on.boolean
getDisableSelectionTool()
Is the selection tool disabled?processing.core.PFont
getIdFont()
Get font for drawing textint
getMode()
Check which mode is enabled (render or calibrate)int
getNumAddedSurfaces()
processing.core.PVector
getPrevMouse()
Get previous mouse positionArrayList<SuperSurface>
getSelectedSurfaces()
Get the selected surfacesint
getSelectionDistance()
Get current max distance for an object to be selectedint
getSelectionMouseColor()
Rectangle
getSelectionTool()
Returns the rectangle used for selecting surfacesList<Sketch>
getSketchList()
boolean
getSnap()
See if snap mode is usedint
getSnapDistance()
See the snap distanceSuperSurface
getSurfaceById(int id)
Get surface by Id.ArrayList<SuperSurface>
getSurfaces()
Get all surfacesboolean
isAllowUserInput()
Check if any user event is allowedboolean
isAltDown()
Is ALT pressed?boolean
isCtrlDown()
Is CTRL pressed?boolean
isDragging()
boolean
isEnableSelectionMouse()
boolean
isGrouping()
Check if multiple surfaces are being manipulatedboolean
isUsingBackground()
Boolean used to know if the background image should be rendered in calibration mode.void
keyEvent(processing.event.KeyEvent k)
KeyEvent methodvoid
ksMouseEvent(processing.event.MouseEvent e)
MouseEvent method.void
load(File file)
Load projection map from filevoid
mouseEvent(processing.event.MouseEvent e)
MouseEvent method.void
movePoint(SuperSurface ss, int x, int y)
Move a point of a surfacestatic <T> void
removeDuplicates(ArrayList<T> list)
void
removeSelectedSurfaces()
Delete the selected surfacesvoid
render(processing.core.PGraphics glos)
Render method used when calibrating.void
save(File file)
Save all projection mapping data to filevoid
save(processing.data.XML root)
Puts all projection mapping data in the XMLElementvoid
selectSurfaces(int mX, int mY)
void
setAllowUserInput(boolean allowUserInput)
Set if any user event is allowedvoid
setBackground(processing.core.PImage tex)
Optionally set a background image in calibration mode.void
setColor(int[] ccolor)
Set the array of colors used in calibration mode for coloring the surfaces.void
setCtrlDown(boolean pressed)
Set CTRL pressedvoid
setDebug(boolean debug)
Manually set debug mode.void
setDisableSelectionTool(boolean disableSelectionTool)
Enable/disable selection toolvoid
setEnableSelectionMouse(boolean enableSelectionMouse)
void
setGrouping(boolean grouping)
Set if multiple surfaces are being manipulatedvoid
setIsDragging(boolean isDragging)
void
setModeCalibrate()
Set mode to calibratevoid
setModeRender()
Set mode to rendervoid
setNumAddedSurfaces(int numAddedSurfaces)
void
setPrevMouse(float x, float y)
Set previous mouse positionvoid
setSelectedSurface(SuperSurface cps)
Select the surface.void
setSelectionDistance(int selectionDistance)
Set the max distance for an object to be selectedvoid
setSelectionMouseColor(int selectionMouseColor)
void
setSelectionTool(int x, int y, int width, int height)
Set the selection toolvoid
setSelectionTool(Rectangle r)
Set the selection toolvoid
setShakeAll(int strength, int speed, int fallOfSpeed)
Shake all surfaces with max Z-displacement strength, vibration-speed speed, and shake decline fallOfSpeed.void
setSketchList(List<Sketch> sketchList)
void
setSnap(boolean snap)
Manually set corner snap modevoid
setSnapDistance(int snapDistance)
Set corner snap distancevoid
setUsingBackground(boolean val)
Set if background image should rendered in calibration modevoid
shake()
Update shaking for all surfacesvoid
toggleCalibration()
Toggle the modevoid
toggleSnap()
Toggle if corner snapping is usedString
version()
-
-
-
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()
-
-