#include <bridge.h>
Public Member Functions | |
void | optimize (int level) |
Removes unnecessary vertices and edges. | |
int | getNearestVertex (vector2 &pos) |
Finds the index of the nearest vertex as to a given position. | |
int | getNearestEdge (vector2 &pos) |
Finds the index of the nearest edge as to a given position. | |
bool | getRoad () |
Fills the road array (indices of the edges representing the horizontal end-to-end road from left to right). | |
int | addVertex (int x, int y) |
Adds a vertex to the bridge. | |
int | addVertex (vertex v) |
Adds a vertex to the bridge. | |
int | addEdge (int start, int end) |
Adds an edge to the bridge. | |
void | deleteVertex (int index) |
Deletes a vertex as well as all adjacent edges from the bridge. | |
void | deleteEdge (int index) |
Deletes an edge from the bridge. | |
void | clear () |
Clears the bridge (removes all vertices and edges). | |
vector2 & | getStart (int index) |
Returns the position of the start vertex of edges[index]. | |
vector2 & | getEnd (int index) |
Returns the position of the end vertex of edges[index]. | |
void | setExternalForces (vector< vertex > &v) |
Sets external forces (gravity etc. | |
void | addInternalForces (vector< vertex > &v, vector< edge > &e, component stiffness, bool breakableEdges) |
Adds internal spring forces to vertices in a given vector. | |
void | initializePhysics () |
Initializes the bridge simulation. | |
void | doPhysics (component timestep) |
Performs a step in the bridge simulation. | |
Public Attributes | |
vector< vertex > | vertices |
The bridge vertices. | |
vector< edge > | edges |
The bridge edges. | |
Puff | puff |
The "puff" particle system (to animate broken edges). | |
vector< int > | road |
The indices of the edges composing the horizontal end-to-end road from left to right. | |
int | roadStartVertex |
The index of the road's start vertex. | |
int | roadEndVertex |
The index of the road's end vertex. |
|
Adds an edge to the bridge. Has no effect if the same edge already exists.
|
|
Adds internal spring forces to vertices in a given vector.
|
|
Adds a vertex to the bridge. Has no effect if the same vertex already exists.
|
|
Adds a vertex to the bridge. Has no effect if the same vertex already exists.
|
|
Deletes an edge from the bridge.
Afterwards, a call to
|
|
Deletes a vertex as well as all adjacent edges from the bridge.
Afterwards, a call to
|
|
Performs a step in the bridge simulation.
|
|
Returns the position of the end vertex of edges[index].
|
|
Finds the index of the nearest edge as to a given position.
|
|
Finds the index of the nearest vertex as to a given position.
|
|
Fills the road array (indices of the edges representing the horizontal end-to-end road from left to right).
|
|
Returns the position of the start vertex of edges[index].
|
|
Initializes the bridge simulation. Should be called before doPhysics(component). |
|
Removes unnecessary vertices and edges.
|
|
Sets external forces (gravity etc. ) for vertices in a given vector.
|