19#ifndef HEADER_DRIVE_GRAPH_HPP
20#define HEADER_DRIVE_GRAPH_HPP
25#include "tracks/graph.hpp"
26#include "utils/aligned_array.hpp"
27#include "utils/cpp2011.hpp"
29#include "LinearMath/btTransform.h"
61 void addSuccessor(
unsigned int from,
unsigned int to);
63 void load(
const std::string &quad_file_name,
const std::string &filename);
72 virtual bool hasLapLine() const OVERRIDE;
74 virtual
void differentNodeColor(
int n, video::SColor* c) const OVERRIDE;
80 const std::string &graph_file_name,
const bool reverse);
84 void getSuccessors(
int node_number, std::vector<unsigned int>& succ,
85 bool for_ai=
false)
const;
90 unsigned int karts_per_row,
91 float forwards_distance = 1.5f,
92 float sidewards_distance = 1.5f,
93 float upwards_distance=0.0f)
const;
121 bool isReverse()
const {
return m_reverse; }
A graph made from driveline.
Definition: drive_graph.hpp:39
void setDefaultSuccessors()
This function sets a default successor for all graph nodes that currently don't have a successor defi...
Definition: drive_graph.cpp:370
int getNumberOfSuccessors(int n) const
Returns the number of successors of a node n.
Definition: drive_graph.cpp:719
void getSuccessors(int node_number, std::vector< unsigned int > &succ, bool for_ai=false) const
Returns the list of successors or a node.
Definition: drive_graph.cpp:477
void getPoint(const XMLNode *xml, const std::string &attribute_name, Vec3 *result) const
This function interprets a point specification as an attribute in the xml quad file.
Definition: drive_graph.cpp:66
unsigned int getStartNode() const
Returns the index of the first graph node (i.e.
Definition: drive_graph.cpp:274
float m_lap_length
The length of the first loop.
Definition: drive_graph.hpp:42
void computeChecklineRequirements()
Sets the checkline requirements for all nodes in the graph.
Definition: drive_graph.cpp:283
bool m_reverse
Wether the graph should be reverted or not.
Definition: drive_graph.hpp:48
void load(const std::string &quad_file_name, const std::string &filename)
Loads a drive graph from a file.
Definition: drive_graph.cpp:92
void determineDirection(unsigned int current, unsigned int succ_index)
Determines the direction of the drive graph when driving to the specified successor.
Definition: drive_graph.cpp:635
float normalizeAngle(float f)
Adjust the given angle to be in [-PI, PI].
Definition: drive_graph.cpp:612
void spatialToTrack(Vec3 *dst, const Vec3 &xyz, const int sector) const
This function takes absolute coordinates (coordinates in OpenGL space) and transforms them into coord...
Definition: drive_graph.cpp:694
float getDistanceToNext(int n, int j) const
Return the distance to the j-th successor of node n.
Definition: drive_graph.cpp:707
DriveNode * getNode(unsigned int j) const
Returns the quad that belongs to a graph node.
Definition: drive_graph.cpp:744
float getLapLength() const
Returns the length of the main driveline.
Definition: drive_graph.hpp:119
float getDistanceFromStart(int j) const
Returns the distance from the start to the beginning of a quad.
Definition: drive_graph.cpp:725
std::string m_quad_filename
Stores the filename - just used for error messages.
Definition: drive_graph.hpp:45
void updateDistancesForAllSuccessors(unsigned int indx, float delta, unsigned int count)
Increases the distance from start for all nodes that are directly or indirectly a successor of the gi...
Definition: drive_graph.cpp:546
void computeDistanceFromStart(unsigned int start_node, float distance)
Recursively determines the distance the beginning (lower end) of the quads have from the start of the...
Definition: drive_graph.cpp:497
void setDefaultStartPositions(AlignedArray< btTransform > *start_transforms, unsigned int karts_per_row, float forwards_distance=1.5f, float sidewards_distance=1.5f, float upwards_distance=0.0f) const
Sets all start positions depending on the drive graph.
Definition: drive_graph.cpp:401
void setupPaths()
This function defines the "path-to-nodes" for each graph node that has more than one successor.
Definition: drive_graph.cpp:358
void computeDirectionData()
Computes the direction (straight, left, right) of all graph nodes and the lastest graph node that is ...
Definition: drive_graph.cpp:595
float getAngleToNext(int n, int j) const
Returns the angle of the line between node n and its j-th.
Definition: drive_graph.cpp:713
This class stores a node of the drive graph, i.e.
Definition: drive_node.hpp:32
This class stores a graph of quads.
Definition: graph.hpp:53
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48