Package ixagon.surface.mapper
Class QuadSurface
- java.lang.Object
-
- ixagon.surface.mapper.QuadSurface
-
- All Implemented Interfaces:
SuperSurface
public class QuadSurface extends Object implements SuperSurface
-
-
Field Summary
-
Fields inherited from interface ixagon.surface.mapper.SuperSurface
BEZIER, DEFAULT_SIZE, QUAD
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static float
CCW(Point3D p1, Point3D p2, Point3D p3)
Three points are a counter-clockwise turn if ccw > 0, clockwise if ccw < 0, and collinear if ccw = 0 because ccw is a determinant that gives the signed area of the triangle formed by p1, p2 and p3.void
clearSurfaceMask()
void
decreaseHorizontalForce()
Decrease the amount of horizontal displacement force used for spherical mapping for bezier surfaces.void
decreaseResolution()
Decrease the subdivisionvoid
decreaseVerticalForce()
Decrease the amount of horizontal displacement force used for spherical mapping for bezier surfaces.int
getActiveBezierPointIndex(int mX, int mY)
Returns index 0-7 if coordinates are on a bezier controlint
getActiveCornerPointIndex(int mX, int mY)
Checks if the coordinates is close to any of the corners, and if not, checks if the coordinates are inside the surface.int
getActivePoint()
Get the index of the active cornerdouble
getArea()
Calculate the area in squarepixelsPoint3D
getBezierPoint(int index)
Get target Bezier control pointfloat
getBlendLeftSize()
Get the width of the left edge blendfloat
getBlendRightSize()
Get the width of the right edge blendint
getBufferScreenWidth()
Point3D
getCenter()
Find the average position of all the control points, use that as the center point.int
getColor()
Get the fill color of the surface in calibration modePoint3D
getCornerPoint(int index)
Get a specific cornerPoint3D[]
getCornerPoints()
Get all cornersint
getHorizontalForce()
Get the amount of horizontal displacement force used for spherical mapping for bezier surfaces.int
getId()
Get the surfaces IDboolean
getLocked()
See if the surface is lockeddouble
getLongestSide()
Get the longest side as doubleFile
getMaskFile()
Polygon
getPolygon()
Get the surface as a polygonint
getRes()
Get the amount of subdivision used in the surfaceint
getSelectedBezierControl()
Get the currently selected bezier controlint
getSelectedCorner()
Get the currently selected cornerSketch
getSketch()
int
getSketchIndex()
Get the actual sketch index.processing.core.PImage
getSurfaceMask()
String
getSurfaceName()
int
getSurfaceType()
See which type this surface isprocessing.core.PVector[]
getTextureWindow()
int
getVerticalForce()
Get the amount of vertical displacement force used for spherical mapping for bezier surfaces.void
increaseHorizontalForce()
Increase the amount of horizontal displacement force used for spherical mapping for bezier surfaces.void
increaseResolution()
Increase the subdivisionvoid
increaseVerticalForce()
Increase the amount of vertical displacement force used for spherical mapping for bezier surfaces.boolean
isBlendLeft()
See if the surface has been set to blend on the leftboolean
isBlendRight()
See if the surface has been set to blend on the rightboolean
isCornerMovementAllowed()
See if we can move the cornerpoint of the surfaceboolean
isHidden()
See if the surface is hiddenboolean
isInside(float mX, float mY)
Check if coordinates are inside the surfaceboolean
isLocked()
See if the surface is lockedboolean
isSelected()
See if the surface is selectedboolean
isUsingEdgeBlend()
See if the surface is using edge blendboolean
isUsingSurfaceMask()
void
render(processing.core.PGraphics g)
Render method for rendering while in calibration modevoid
render(processing.core.PGraphics g, processing.core.PImage tex)
Render method for rendering in RENDER mode.void
rotateCornerPoints(int direction)
Rotate the cornerpoints in direction (0=ClockWise 1=CounterClockWise)Point3D
screenCoordinatesToQuad(float x, float y)
Translate a point on the screen into a point in the surface.void
setActivePoint(int activePoint)
Set index of which corner is activevoid
setBezierPoint(int pointIndex, float x, float y)
Set target bezier control point to coordinatesvoid
setBlendLeft(boolean blendLeft)
Set if the left side should be blendedvoid
setBlendLeftSize(float blendLeftSize)
Set the width of the left edge blendvoid
setBlendRight(boolean blendRight)
Set if the right side should be blendedvoid
setBlendRightSize(float blendRightSize)
Set the width of the right edge blendvoid
setBufferScreenWidth(int bufferScreenWidth)
Set the width of the buffer offscreenvoid
setColor(int ccolor)
Sets the fill color of the surface in calibration modevoid
setCornerPoint(int pointIndex, float inX, float inY)
Set the coordinates of one of the target corner points.void
setCornerPoints(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
Set all four corners of the surfacevoid
setHide(boolean hidden)
Set if the surface should be hiddenvoid
setId(int id)
Set the surfaces IDvoid
setLocked(boolean isLocked)
Set if the surface is lockedvoid
setMaskFile(File maskFile)
void
setModeCalibrate()
Set surface to calibration modevoid
setModeRender()
Set surface to render modevoid
setSelected(boolean selected)
Set if the surface is selectedvoid
setSelectedBezierControl(int selectedBezierControl)
Set target bezier control to selectedvoid
setSelectedCorner(int selectedCorner)
Set the currently selected cornervoid
setShake(int strength, int speed, int fallOfSpeed)
Set parameters for shaking the surface.void
setSketch(Sketch sketch)
void
setSketchIndex(int sketchIndex)
Set the actual sketch index.void
setSurfaceMask(processing.core.PImage mask)
void
setSurfaceName(String surfaceName)
Sets the name of the surfacevoid
setTextureWindow(float x, float y, float width, float height)
Manually set coordinates for mapping the texture.void
setZ(float currentZ)
Set Z-displacement for all coordinates of surfacevoid
shake()
Tells surface to shake (will only do something if setShake has been called quite recently)void
toggleLocked()
Toggle if surface is locked (a locked surface cannot be moved or manipulated in calibration mode, but other surfaces still snap to it)void
toggleMode()
Toggle surface mode
-
-
-
Method Detail
-
CCW
public static float CCW(Point3D p1, Point3D p2, Point3D p3)
Three points are a counter-clockwise turn if ccw > 0, clockwise if ccw < 0, and collinear if ccw = 0 because ccw is a determinant that gives the signed area of the triangle formed by p1, p2 and p3.
-
clearSurfaceMask
public void clearSurfaceMask()
- Specified by:
clearSurfaceMask
in interfaceSuperSurface
-
decreaseHorizontalForce
public void decreaseHorizontalForce()
Description copied from interface:SuperSurface
Decrease the amount of horizontal displacement force used for spherical mapping for bezier surfaces. (using orthographic projection)- Specified by:
decreaseHorizontalForce
in interfaceSuperSurface
-
decreaseResolution
public void decreaseResolution()
Decrease the subdivision- Specified by:
decreaseResolution
in interfaceSuperSurface
-
decreaseVerticalForce
public void decreaseVerticalForce()
Description copied from interface:SuperSurface
Decrease the amount of horizontal displacement force used for spherical mapping for bezier surfaces. (using orthographic projection)- Specified by:
decreaseVerticalForce
in interfaceSuperSurface
-
getActiveBezierPointIndex
public int getActiveBezierPointIndex(int mX, int mY)
Description copied from interface:SuperSurface
Returns index 0-7 if coordinates are on a bezier control- Specified by:
getActiveBezierPointIndex
in interfaceSuperSurface
- Returns:
-
getActiveCornerPointIndex
public int getActiveCornerPointIndex(int mX, int mY)
Checks if the coordinates is close to any of the corners, and if not, checks if the coordinates are inside the surface. Returns the index of the corner (0,1,2,3) or (4) if coordinates was inside the surface- Specified by:
getActiveCornerPointIndex
in interfaceSuperSurface
- Parameters:
mX
-mY
-- Returns:
-
getActivePoint
public int getActivePoint()
Get the index of the active corner- Specified by:
getActivePoint
in interfaceSuperSurface
- Returns:
-
getArea
public double getArea()
Calculate the area in squarepixels- Specified by:
getArea
in interfaceSuperSurface
- Returns:
- returns the area as N squarepixels
-
getBezierPoint
public Point3D getBezierPoint(int index)
Description copied from interface:SuperSurface
Get target Bezier control point- Specified by:
getBezierPoint
in interfaceSuperSurface
- Returns:
-
getBlendLeftSize
public float getBlendLeftSize()
Description copied from interface:SuperSurface
Get the width of the left edge blend- Specified by:
getBlendLeftSize
in interfaceSuperSurface
- Returns:
-
getBlendRightSize
public float getBlendRightSize()
Description copied from interface:SuperSurface
Get the width of the right edge blend- Specified by:
getBlendRightSize
in interfaceSuperSurface
- Returns:
-
getBufferScreenWidth
public int getBufferScreenWidth()
-
getCenter
public Point3D getCenter()
Find the average position of all the control points, use that as the center point.- Specified by:
getCenter
in interfaceSuperSurface
- Returns:
-
getColor
public int getColor()
Get the fill color of the surface in calibration mode- Specified by:
getColor
in interfaceSuperSurface
- Returns:
-
getCornerPoint
public Point3D getCornerPoint(int index)
Get a specific corner- Specified by:
getCornerPoint
in interfaceSuperSurface
- Parameters:
index
-- Returns:
-
getCornerPoints
public Point3D[] getCornerPoints()
Get all corners- Specified by:
getCornerPoints
in interfaceSuperSurface
- Returns:
-
getHorizontalForce
public int getHorizontalForce()
Description copied from interface:SuperSurface
Get the amount of horizontal displacement force used for spherical mapping for bezier surfaces.- Specified by:
getHorizontalForce
in interfaceSuperSurface
-
getId
public int getId()
Get the surfaces ID- Specified by:
getId
in interfaceSuperSurface
- Returns:
-
getLocked
public boolean getLocked()
See if the surface is locked- Returns:
-
getLongestSide
public double getLongestSide()
Get the longest side as double- Specified by:
getLongestSide
in interfaceSuperSurface
- Returns:
-
getMaskFile
public File getMaskFile()
- Specified by:
getMaskFile
in interfaceSuperSurface
-
getPolygon
public Polygon getPolygon()
Get the surface as a polygon- Specified by:
getPolygon
in interfaceSuperSurface
- Returns:
-
getRes
public int getRes()
Get the amount of subdivision used in the surface- Specified by:
getRes
in interfaceSuperSurface
- Returns:
-
getSelectedBezierControl
public int getSelectedBezierControl()
Get the currently selected bezier control- Specified by:
getSelectedBezierControl
in interfaceSuperSurface
- Returns:
-
getSelectedCorner
public int getSelectedCorner()
Get the currently selected corner- Specified by:
getSelectedCorner
in interfaceSuperSurface
- Returns:
-
getSketch
public Sketch getSketch()
- Specified by:
getSketch
in interfaceSuperSurface
-
getSurfaceMask
public processing.core.PImage getSurfaceMask()
- Specified by:
getSurfaceMask
in interfaceSuperSurface
-
getSurfaceName
public String getSurfaceName()
- Specified by:
getSurfaceName
in interfaceSuperSurface
-
getSurfaceType
public int getSurfaceType()
Description copied from interface:SuperSurface
See which type this surface is- Specified by:
getSurfaceType
in interfaceSuperSurface
- Returns:
-
getTextureWindow
public processing.core.PVector[] getTextureWindow()
- Specified by:
getTextureWindow
in interfaceSuperSurface
-
getVerticalForce
public int getVerticalForce()
Description copied from interface:SuperSurface
Get the amount of vertical displacement force used for spherical mapping for bezier surfaces.- Specified by:
getVerticalForce
in interfaceSuperSurface
-
increaseHorizontalForce
public void increaseHorizontalForce()
Description copied from interface:SuperSurface
Increase the amount of horizontal displacement force used for spherical mapping for bezier surfaces. (using orthographic projection)- Specified by:
increaseHorizontalForce
in interfaceSuperSurface
-
increaseResolution
public void increaseResolution()
Increase the subdivision- Specified by:
increaseResolution
in interfaceSuperSurface
-
increaseVerticalForce
public void increaseVerticalForce()
Description copied from interface:SuperSurface
Increase the amount of vertical displacement force used for spherical mapping for bezier surfaces. (using orthographic projection)- Specified by:
increaseVerticalForce
in interfaceSuperSurface
-
isBlendLeft
public boolean isBlendLeft()
Description copied from interface:SuperSurface
See if the surface has been set to blend on the left- Specified by:
isBlendLeft
in interfaceSuperSurface
- Returns:
-
isBlendRight
public boolean isBlendRight()
Description copied from interface:SuperSurface
See if the surface has been set to blend on the right- Specified by:
isBlendRight
in interfaceSuperSurface
- Returns:
-
isCornerMovementAllowed
public boolean isCornerMovementAllowed()
Description copied from interface:SuperSurface
See if we can move the cornerpoint of the surface- Specified by:
isCornerMovementAllowed
in interfaceSuperSurface
- Returns:
-
isHidden
public boolean isHidden()
See if the surface is hidden- Specified by:
isHidden
in interfaceSuperSurface
- Returns:
-
isInside
public boolean isInside(float mX, float mY)
Check if coordinates are inside the surface- Specified by:
isInside
in interfaceSuperSurface
- Parameters:
mX
-mY
-- Returns:
-
isLocked
public boolean isLocked()
Description copied from interface:SuperSurface
See if the surface is locked- Specified by:
isLocked
in interfaceSuperSurface
- Returns:
-
isSelected
public boolean isSelected()
See if the surface is selected- Specified by:
isSelected
in interfaceSuperSurface
- Returns:
-
isUsingEdgeBlend
public boolean isUsingEdgeBlend()
Description copied from interface:SuperSurface
See if the surface is using edge blend- Specified by:
isUsingEdgeBlend
in interfaceSuperSurface
- Returns:
-
isUsingSurfaceMask
public boolean isUsingSurfaceMask()
- Specified by:
isUsingSurfaceMask
in interfaceSuperSurface
-
render
public void render(processing.core.PGraphics g)
Render method for rendering while in calibration mode- Specified by:
render
in interfaceSuperSurface
- Parameters:
g
-
-
render
public void render(processing.core.PGraphics g, processing.core.PImage tex)
Render method for rendering in RENDER mode. Takes one GLGraphicsOffScreen and one GLTexture. The GLTexture is the texture used for the surface, and is drawn to the offscreen buffer.- Specified by:
render
in interfaceSuperSurface
- Parameters:
g
-tex
-
-
rotateCornerPoints
public void rotateCornerPoints(int direction)
Rotate the cornerpoints in direction (0=ClockWise 1=CounterClockWise)- Specified by:
rotateCornerPoints
in interfaceSuperSurface
- Parameters:
direction
-
-
screenCoordinatesToQuad
public Point3D screenCoordinatesToQuad(float x, float y)
Translate a point on the screen into a point in the surface.- Specified by:
screenCoordinatesToQuad
in interfaceSuperSurface
- Parameters:
x
-y
-- Returns:
-
setActivePoint
public void setActivePoint(int activePoint)
Set index of which corner is active- Specified by:
setActivePoint
in interfaceSuperSurface
- Parameters:
activePoint
-
-
setBezierPoint
public void setBezierPoint(int pointIndex, float x, float y)
Description copied from interface:SuperSurface
Set target bezier control point to coordinates- Specified by:
setBezierPoint
in interfaceSuperSurface
-
setBlendLeft
public void setBlendLeft(boolean blendLeft)
Description copied from interface:SuperSurface
Set if the left side should be blended- Specified by:
setBlendLeft
in interfaceSuperSurface
-
setBlendLeftSize
public void setBlendLeftSize(float blendLeftSize)
Description copied from interface:SuperSurface
Set the width of the left edge blend- Specified by:
setBlendLeftSize
in interfaceSuperSurface
-
setBlendRight
public void setBlendRight(boolean blendRight)
Description copied from interface:SuperSurface
Set if the right side should be blended- Specified by:
setBlendRight
in interfaceSuperSurface
-
setBlendRightSize
public void setBlendRightSize(float blendRightSize)
Description copied from interface:SuperSurface
Set the width of the right edge blend- Specified by:
setBlendRightSize
in interfaceSuperSurface
-
setBufferScreenWidth
public void setBufferScreenWidth(int bufferScreenWidth)
Description copied from interface:SuperSurface
Set the width of the buffer offscreen- Specified by:
setBufferScreenWidth
in interfaceSuperSurface
-
setColor
public void setColor(int ccolor)
Sets the fill color of the surface in calibration mode- Specified by:
setColor
in interfaceSuperSurface
- Parameters:
ccolor
-
-
setCornerPoint
public void setCornerPoint(int pointIndex, float inX, float inY)
Set the coordinates of one of the target corner points. But first check that all angles are clockwise, to avoid concave shapes (collinearity is not allowed either as it freaks out the matrix calculation)- Specified by:
setCornerPoint
in interfaceSuperSurface
- Parameters:
pointIndex
-
-
setCornerPoints
public void setCornerPoints(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
Set all four corners of the surface- Specified by:
setCornerPoints
in interfaceSuperSurface
- Parameters:
x0
-y0
-x1
-y1
-x2
-y2
-x3
-y3
-
-
setHide
public void setHide(boolean hidden)
Set if the surface should be hidden- Specified by:
setHide
in interfaceSuperSurface
- Parameters:
hidden
-
-
setId
public void setId(int id)
Set the surfaces ID- Specified by:
setId
in interfaceSuperSurface
- Parameters:
id
-
-
setLocked
public void setLocked(boolean isLocked)
Set if the surface is locked- Specified by:
setLocked
in interfaceSuperSurface
- Parameters:
isLocked
-
-
setMaskFile
public void setMaskFile(File maskFile)
- Specified by:
setMaskFile
in interfaceSuperSurface
-
setModeCalibrate
public void setModeCalibrate()
Description copied from interface:SuperSurface
Set surface to calibration mode- Specified by:
setModeCalibrate
in interfaceSuperSurface
-
setModeRender
public void setModeRender()
Description copied from interface:SuperSurface
Set surface to render mode- Specified by:
setModeRender
in interfaceSuperSurface
-
setSelected
public void setSelected(boolean selected)
Set if the surface is selected- Specified by:
setSelected
in interfaceSuperSurface
- Parameters:
selected
-
-
setSelectedBezierControl
public void setSelectedBezierControl(int selectedBezierControl)
Description copied from interface:SuperSurface
Set target bezier control to selected- Specified by:
setSelectedBezierControl
in interfaceSuperSurface
-
setSelectedCorner
public void setSelectedCorner(int selectedCorner)
Set the currently selected corner- Specified by:
setSelectedCorner
in interfaceSuperSurface
- Parameters:
selectedCorner
-
-
setShake
public void setShake(int strength, int speed, int fallOfSpeed)
Set parameters for shaking the surface. Strength == max Z-displacement, Speed == vibration speed, FallOfSpeed 1-1000 == how fast strength is diminished- Specified by:
setShake
in interfaceSuperSurface
- Parameters:
strength
-speed
-fallOfSpeed
-
-
setSketch
public void setSketch(Sketch sketch)
- Specified by:
setSketch
in interfaceSuperSurface
-
setSurfaceMask
public void setSurfaceMask(processing.core.PImage mask)
- Specified by:
setSurfaceMask
in interfaceSuperSurface
-
setSurfaceName
public void setSurfaceName(String surfaceName)
Description copied from interface:SuperSurface
Sets the name of the surface- Specified by:
setSurfaceName
in interfaceSuperSurface
-
setTextureWindow
public void setTextureWindow(float x, float y, float width, float height)
Manually set coordinates for mapping the texture. This allows for easy cropping and enables a single texture to span more than one surface. Use normalized values for the values! (i.e 0-1)- Specified by:
setTextureWindow
in interfaceSuperSurface
-
setZ
public void setZ(float currentZ)
Set Z-displacement for all coordinates of surface- Specified by:
setZ
in interfaceSuperSurface
- Parameters:
currentZ
-
-
getSketchIndex
public int getSketchIndex()
Description copied from interface:SuperSurface
Get the actual sketch index.- Specified by:
getSketchIndex
in interfaceSuperSurface
-
setSketchIndex
public void setSketchIndex(int sketchIndex)
Description copied from interface:SuperSurface
Set the actual sketch index.- Specified by:
setSketchIndex
in interfaceSuperSurface
-
shake
public void shake()
Tells surface to shake (will only do something if setShake has been called quite recently)- Specified by:
shake
in interfaceSuperSurface
-
toggleLocked
public void toggleLocked()
Toggle if surface is locked (a locked surface cannot be moved or manipulated in calibration mode, but other surfaces still snap to it)- Specified by:
toggleLocked
in interfaceSuperSurface
-
toggleMode
public void toggleMode()
Description copied from interface:SuperSurface
Toggle surface mode- Specified by:
toggleMode
in interfaceSuperSurface
-
-