Main Page | Class List | Directories | File List | Class Members | File Members

Bridge Class Reference

Represents a bridge. More...

#include <bridge.h>

List of all members.

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).
vector2getStart (int index)
 Returns the position of the start vertex of edges[index].
vector2getEnd (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< vertexvertices
 The bridge vertices.
vector< edgeedges
 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.


Detailed Description

Represents a bridge.


Member Function Documentation

int Bridge::addEdge int  start,
int  end
 

Adds an edge to the bridge.

Has no effect if the same edge already exists.

Parameters:
start the index of the edge's start vertex
end the index of the end's start vertex
Returns:
the index of the newly added (or already present) edge

void Bridge::addInternalForces vector< vertex > &  v,
vector< edge > &  e,
component  stiffness,
bool  breakableEdges
 

Adds internal spring forces to vertices in a given vector.

Parameters:
v the vector of vertices to be processed
e the vector of edges to be processed
stiffness the spring stiffness
breakableEdges true iff the edges should be marked as broken when their relative deformation exceeds the deformation threshold

int Bridge::addVertex vertex  v  ) 
 

Adds a vertex to the bridge.

Has no effect if the same vertex already exists.

Parameters:
v the vertex to be added
Returns:
the index of the newly added (or already present) vertex
See also:
addVertex(int, int)

int Bridge::addVertex int  x,
int  y
 

Adds a vertex to the bridge.

Has no effect if the same vertex already exists.

Parameters:
x the x coordinate of the vertex to be added
y the y coordinate of the vertex to be added
Returns:
the index of the newly added (or already present) vertex
See also:
addVertex(vertex)

void Bridge::deleteEdge int  index  ) 
 

Deletes an edge from the bridge.

Afterwards, a call to optimize(0) is performed.

Parameters:
index the index of the edge to be deleted
See also:
optimize(int)

void Bridge::deleteVertex int  index  ) 
 

Deletes a vertex as well as all adjacent edges from the bridge.

Afterwards, a call to optimize(0) is performed.

Parameters:
index the index of the vertex to be deleted
See also:
optimize(int)

void Bridge::doPhysics component  timestep  ) 
 

Performs a step in the bridge simulation.

Parameters:
timestep the time step

vector2 & Bridge::getEnd int  index  ) 
 

Returns the position of the end vertex of edges[index].

Parameters:
index the index of the edge

int Bridge::getNearestEdge vector2 pos  ) 
 

Finds the index of the nearest edge as to a given position.

Parameters:
pos the position
Returns:
the index of the nearest edge or -1 if the distance is 'too large'

int Bridge::getNearestVertex vector2 pos  ) 
 

Finds the index of the nearest vertex as to a given position.

Parameters:
pos the position
Returns:
the index of the nearest vertex or -1 if the distance is greater than 1

bool Bridge::getRoad  ) 
 

Fills the road array (indices of the edges representing the horizontal end-to-end road from left to right).

Returns:
true iff valid road can be found

vector2 & Bridge::getStart int  index  ) 
 

Returns the position of the start vertex of edges[index].

Parameters:
index the index of the edge

void Bridge::initializePhysics  ) 
 

Initializes the bridge simulation.

Should be called before doPhysics(component).

void Bridge::optimize int  level  ) 
 

Removes unnecessary vertices and edges.

  • level 0: deletes vertices that are no longer connected
    • level 1: deletes vertices and edges that are not reachable from the ground ('flying' elements)
      Parameters:
      level the desired optimization level

void Bridge::setExternalForces vector< vertex > &  v  ) 
 

Sets external forces (gravity etc.

) for vertices in a given vector.

Parameters:
v the vector of vertices to be processed


The documentation for this class was generated from the following files:
Generated on Sun Jul 10 22:32:04 2005 for S12 by  doxygen 1.4.2