fisica
Class FConstantVolumeJoint

java.lang.Object
  extended by fisica.FJoint
      extended by fisica.FConstantVolumeJoint

public class FConstantVolumeJoint
extends FJoint

Represents constant volume joint that tries to keep the volume enclosed by a group of bodies constant. This joint is similar to connecting multiple springs between the bodies in order to maintain the volume inside their position constant. This is the joint used to create the FBlob body.


Constructor Summary
FConstantVolumeJoint()
          Constructs an constant volume joint.
 
Method Summary
 void addBody(FBody b)
          Adds a body to the joint.
 void attachImage(processing.core.PImage img)
          Attach an image to the object.
 void dettachImage()
          Dettach any image that has been attached to the object.
 void draw(processing.core.PApplet applet)
           
 void draw(processing.core.PGraphics applet)
          This method is called when calling world.draw().
 java.util.ArrayList getBodies()
          Return the group of bodies that are connected by this joint.
 float getImageAlpha()
          Get the opacity with which to draw the attached image.
 boolean isDrawable()
          Get whether the object must be drawn or not.
 void setDamping(float damping)
          Sets the damping of the springs used to maintain the volume defined by the vertices constant.
 void setDrawable(boolean drawable)
          Set whether the object must be drawn or not.
 void setFill(float g)
          Set the fill color of the object.
 void setFill(float g, float a)
          Set the fill color of the object.
 void setFill(float r, float g, float b)
          Set the fill color of the object.
 void setFill(float r, float g, float b, float a)
          Set the fill color of the object.
 void setFillColor(int col)
          Set the fill color of the object.
 void setFrequency(float frequency)
          Sets the frequency of the springs used to maintain the volume defined by the vertices constant.
 void setImageAlpha(float alpha)
          Set the opacity with which to draw the attached image.
 void setNoFill()
          Set that the object must be drawn without fill.
 void setNoStroke()
          Set that the object must be drawn without stroke.
 void setStroke(float g)
          Set the stroke color of the object.
 void setStroke(float g, float a)
          Set the stroke color of the object.
 void setStroke(float r, float g, float b)
          Set the stroke color of the object.
 void setStroke(float r, float g, float b, float a)
          Set the stroke color of the object.
 void setStrokeColor(int col)
          Set the stroke color of the object.
 void setStrokeWeight(float weight)
          Set the stroke weight of the object.
 
Methods inherited from class fisica.FJoint
getBody1, getBody2, getReactionForceX, getReactionForceY, getReactionTorque, setCollideConnected
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FConstantVolumeJoint

public FConstantVolumeJoint()
Constructs an constant volume joint. It creates an empty joint, before adding the joint to the world use addBody to add bodies to the joint and to define the initial and target volume of the joint.

Method Detail

addBody

public void addBody(FBody b)
Adds a body to the joint. This method must be called before adding the joint to the world.

Parameters:
b - body to be added

getBodies

public java.util.ArrayList getBodies()
Return the group of bodies that are connected by this joint.

Returns:
list of bodies (ArrayList of FBody) connected by the joint

setDamping

public void setDamping(float damping)
Sets the damping of the springs used to maintain the volume defined by the vertices constant. This method must be called before adding the joint to the world.

Parameters:
damping - the damping of the springs of the constant volume joint

setFrequency

public void setFrequency(float frequency)
Sets the frequency of the springs used to maintain the volume defined by the vertices constant. This method must be called before adding the joint to the world.

Parameters:
frequency - the frequency of the springs of the constant volume joint

draw

public void draw(processing.core.PGraphics applet)
This method is called when calling world.draw(). This method may be overriden to allow custom drawing of the object.

Parameters:
applet - the applet onto which the object must be drawn.

draw

public void draw(processing.core.PApplet applet)

attachImage

public void attachImage(processing.core.PImage img)
Attach an image to the object. This method allows to draw an image onto the screen instead of calling the draw(PApplet) method.

Parameters:
img - the PImage to attach to the object.

dettachImage

public void dettachImage()
Dettach any image that has been attached to the object.

See Also:
attachImage(PImage)

getImageAlpha

public float getImageAlpha()
Get the opacity with which to draw the attached image.

Returns:
the opacity, a value from 0.0 to 1.0 with which to draw the attached image
See Also:
attachImage(PImage), setImageAlpha(float)

setImageAlpha

public void setImageAlpha(float alpha)
Set the opacity with which to draw the attached image.

Parameters:
alpha - the opacity, a value from 0.0 to 1.0 with which to draw the attached image
See Also:
attachImage(PImage), getImageAlpha()

setDrawable

public void setDrawable(boolean drawable)
Set whether the object must be drawn or not.

Parameters:
drawable - if true the object will be drawn, else it will not
See Also:
isDrawable()

isDrawable

public boolean isDrawable()
Get whether the object must be drawn or not.

Returns:
drawable if true the object will be drawn, else it will not
See Also:
setDrawable(boolean)

setFillColor

public void setFillColor(int col)
Set the fill color of the object. This method must be used in conjunction with Processing's color(). In most cases users will find it more convenient to use the versions of setFill(float), setFill(float,float), setFill(float,float,float) or setFill(float,float,float,float)

Parameters:
col - a Processing color type. e.g. myBody.setFillColor(color(20,100,30,90));
See Also:
setNoFill(), setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setNoFill

public void setNoFill()
Set that the object must be drawn without fill.

See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setFill

public void setFill(float g)
Set the fill color of the object.

Parameters:
g - gray value
See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setFill

public void setFill(float g,
                    float a)
Set the fill color of the object.

Parameters:
g - gray value
a - alpha (opacity) value
See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setFill

public void setFill(float r,
                    float g,
                    float b)
Set the fill color of the object.

Parameters:
r - red value
g - green value
b - blue value
See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setFill

public void setFill(float r,
                    float g,
                    float b,
                    float a)
Set the fill color of the object.

Parameters:
r - red value
g - green value
b - blue value
a - alpha (opacity) value
See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setStrokeColor

public void setStrokeColor(int col)
Set the stroke color of the object. This method must be used in conjunction with Processing's color(). In most cases users will find it more convenient to use the versions of setStroke(float), setStroke(float,float), setStroke(float,float,float) or setStroke(float,float,float,float)

Parameters:
col - a Processing color type. e.g. myBody.setStrokeColor(color(20,100,30,90));
See Also:
setNoStroke(), setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setNoStroke

public void setNoStroke()
Set that the object must be drawn without stroke.

See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStroke

public void setStroke(float g)
Set the stroke color of the object.

Parameters:
g - gray value
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStroke

public void setStroke(float g,
                      float a)
Set the stroke color of the object.

Parameters:
g - gray value
a - alpha (opacity) value
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStroke

public void setStroke(float r,
                      float g,
                      float b)
Set the stroke color of the object.

Parameters:
r - red value
g - green value
b - blue value
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStroke

public void setStroke(float r,
                      float g,
                      float b,
                      float a)
Set the stroke color of the object.

Parameters:
r - red value
g - green value
b - blue value
a - alpha (opacity) value
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStrokeWeight

public void setStrokeWeight(float weight)
Set the stroke weight of the object.

Parameters:
weight - weight value in pixels
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)


processing library fisica by Ricard Marxer. (c) 2009