|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfisica.FBody
fisica.FBlob
public class FBlob
Represents a blob body that can be added to a world.
Blobs are soft bodies that are composed of vertices and tries to maintain constant the volume the vertices enclose.
Blobs can be created by adding vertices using the vertex
method in a similar way to FPoly
:
FBlob myBlob = new FBlob();
myBlob.vertex(40, 10);
myBlob.vertex(50, 20);
myBlob.vertex(60, 30);
myBlob.vertex(60, 40);
myBlob.vertex(50, 50);
myBlob.vertex(40, 60);
myBlob.vertex(30, 70);
myBlob.vertex(20, 60);
myBlob.vertex(10, 50);
myBlob.vertex(10, 40);
myBlob.vertex(20, 30);
myBlob.vertex(30, 20);
myBlob.vertex(40, 10);
world.add(myBlob);
or it may be initialized using the method setAsCircle
to set the initial shape as a circle:
FBlob myBlob = new FBlob();
myBlob.setAsCircle(40);
world.add(myBlob);
FBox
,
FCircle
,
FPoly
,
FLine
Constructor Summary | |
---|---|
FBlob()
Constructs a blob body that can be added to a world. |
Method Summary | |
---|---|
void |
addForce(float fx,
float fy)
Add a force applied on the center of the body. |
void |
addTorque(float t)
Add a rotation force (a torque) to the body. |
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() . |
float |
getImageAlpha()
Get the opacity with which to draw the attached image. |
float |
getVertexSize()
Returns the size of the circular vertices of the blob. |
boolean |
isDrawable()
Get whether the object must be drawn or not. |
void |
setAsCircle(float size)
Sets the initial shape of the blob to a circle. |
void |
setAsCircle(float x,
float y,
float size)
Sets the initial shape of the blob to a circle. |
void |
setAsCircle(float x,
float y,
float size,
int vertexCount)
Sets the initial shape of the blob to a circle. |
void |
setAsCircle(float size,
int vertexCount)
Sets the initial shape of the blob to a circle. |
void |
setBullet(boolean d)
Set whether the body is a bullet. |
void |
setDamping(float damping)
Sets the damping of the springs used to maintain the volume defined by the vertices constant. |
void |
setDensity(float d)
Set the density of the body. |
void |
setDrawable(boolean val)
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 |
setFriction(float d)
Set the friction of the body. |
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 |
setRestitution(float d)
Set the restitution of the body. |
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 col)
Set the stroke weight of the object. |
void |
setVertexSize(float size)
Sets the size of the circular vertices of the blob. |
void |
vertex(float x,
float y)
Adds a vertex to the initial shape of the blob. |
Methods inherited from class fisica.FBody |
---|
addForce, adjustAngularVelocity, adjustPosition, adjustRotation, adjustVelocity, getAngularVelocity, getContacts, getGroupIndex, getRotation, getTouching, getVelocityX, getVelocityY, getX, getY, isResting, isSensor, isStatic, isTouchingBody, resetForces, setAngularDamping, setAngularVelocity, setCategoryBits, setFilterBits, setForce, setGrabbable, setGroupIndex, setPosition, setRotatable, setRotation, setSensor, setStatic, setStaticBody, setVelocity |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FBlob()
vertex
or setAsCircle
to define the initial shape of the blob.
Method Detail |
---|
public void vertex(float x, float y)
x
- x coordinate of the vertex to be addedy
- y coordinate of the vertex to be addedpublic void setAsCircle(float x, float y, float size, int vertexCount)
vertex
. This method must be called before adding the body to the world.
x
- x coordinate of the position of the circley
- y coordinate of the position of the circlesize
- size of the circlevertexCount
- number of vertices of the circlepublic void setAsCircle(float x, float y, float size)
vertex
. This method must be called before adding the body to the world.
x
- x coordinate of the position of the circley
- y coordinate of the position of the circlesize
- size of the circlepublic void setAsCircle(float size)
vertex
. This method must be called before adding the body to the world.
size
- size of the circlepublic void setAsCircle(float size, int vertexCount)
vertex
. This method must be called before adding the body to the world.
size
- size of the circlevertexCount
- number of vertices of the circlepublic float getVertexSize()
public void setVertexSize(float size)
size
- size of the circular vertices of the blobpublic void setFrequency(float frequency)
frequency
- the frequency of the springs of the constant volume jointpublic void setDamping(float damping)
setDamping
in class FBody
damping
- the damping of the springs of the constant volume jointFBody.setAngularDamping(float)
public void addForce(float fx, float fy)
FBody
addForce
in class FBody
fx
- the x coordinate of the forcefy
- the y coordinate of the forceFBody.addTorque(float)
,
FBody.addForce(float,float,float,float)
public void addTorque(float t)
FBody
addTorque
in class FBody
t
- the value of the torqueFBody.addForce(float,float)
,
FBody.addForce(float,float,float,float)
public void setDensity(float d)
FBody
setDensity
in class FBody
d
- the density of the bodypublic void setFriction(float d)
FBody
setFriction
in class FBody
d
- a positive value. A value of 0 means no friction and thus the body will not be slown down if no other forces are appliedpublic void setRestitution(float d)
FBody
setRestitution
in class FBody
d
- a positive value. A value of 0 means no bounce after a collision, and a value of 1 means bounce with it's full speed from a collisionpublic void setBullet(boolean d)
FBody
setBullet
in class FBody
d
- if true
the body will be a bulletpublic void setNoStroke()
setStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setNoFill()
setFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setFillColor(int col)
setFill(float)
, setFill(float,float)
, setFill(float,float,float)
or setFill(float,float,float,float)
col
- a Processing color type. e.g. myBody.setFillColor(color(20,100,30,90));
setNoFill()
,
setFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setStrokeColor(int col)
setStroke(float)
, setStroke(float,float)
, setStroke(float,float,float)
or setStroke(float,float,float,float)
col
- a Processing color type. e.g. myBody.setStrokeColor(color(20,100,30,90));
setNoStroke()
,
setStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setStrokeWeight(float col)
col
- weight value in pixelssetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setDrawable(boolean val)
val
- if true
the object will be drawn, else it will notisDrawable()
public void draw(processing.core.PGraphics applet)
world.draw()
.
This method may be overriden to allow custom drawing of the object.
applet
- the applet onto which the object must be drawn.public void draw(processing.core.PApplet applet)
public void attachImage(processing.core.PImage img)
draw(PApplet)
method.
img
- the PImage to attach to the object.public void dettachImage()
attachImage(PImage)
public float getImageAlpha()
attachImage(PImage)
,
setImageAlpha(float)
public void setImageAlpha(float alpha)
alpha
- the opacity, a value from 0.0 to 1.0 with which to draw the attached imageattachImage(PImage)
,
getImageAlpha()
public boolean isDrawable()
true
the object will be drawn, else it will notsetDrawable(boolean)
public void setFill(float g)
g
- gray valuesetFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setFill(float g, float a)
g
- gray valuea
- alpha (opacity) valuesetFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setFill(float r, float g, float b)
r
- red valueg
- green valueb
- blue valuesetFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setFill(float r, float g, float b, float a)
r
- red valueg
- green valueb
- blue valuea
- alpha (opacity) valuesetFill(float)
,
setFill(float,float)
,
setFill(float,float,float)
,
setFill(float,float,float,float)
public void setStroke(float g)
g
- gray valuesetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setStroke(float g, float a)
g
- gray valuea
- alpha (opacity) valuesetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setStroke(float r, float g, float b)
r
- red valueg
- green valueb
- blue valuesetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
public void setStroke(float r, float g, float b, float a)
r
- red valueg
- green valueb
- blue valuea
- alpha (opacity) valuesetStroke(float)
,
setStroke(float,float)
,
setStroke(float,float,float)
,
setStroke(float,float,float,float)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |