Added a getStartTransform function to World. Use this to change
the start position of the non-leader karts in a FTL race, so that those karts now start at the end of all start positions, and not directly behind the leader.
This commit is contained in:
@@ -77,13 +77,8 @@ void CutsceneWorld::init()
|
||||
|
||||
m_duration = -1.0f;
|
||||
|
||||
//const btTransform &s = getTrack()->getStartTransform(0);
|
||||
//const Vec3 &v = s.getOrigin();
|
||||
Camera* stk_cam = Camera::createCamera(NULL);
|
||||
m_camera = stk_cam->getCameraSceneNode();
|
||||
//m_camera = irr_driver->getSceneManager()
|
||||
// ->addCameraSceneNode(NULL, core::vector3df(0.0f, 0.0f, 0.0f),
|
||||
// core::vector3df(0.0f, 0.0f, 0.0f));
|
||||
m_camera->setFOV(0.61f);
|
||||
m_camera->bindTargetAndRotation(true); // no "look-at"
|
||||
|
||||
|
||||
@@ -101,11 +101,23 @@ int FollowTheLeaderRace::getScoreForPosition(int p)
|
||||
return m_score_for_position[p - 2];
|
||||
} // getScoreForPosition
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const btTransform &FollowTheLeaderRace::getStartTransform(int index)
|
||||
{
|
||||
if (index == 0) // Leader start position
|
||||
return m_track->getStartTransform(index);
|
||||
|
||||
// Otherwise the karts will start at the rear starting positions
|
||||
int start_index = stk_config->m_max_karts
|
||||
- race_manager->getNumberOfKarts() + index;
|
||||
return m_track->getStartTransform(start_index);
|
||||
} // getStartTransform
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the original time at which the countdown timer started. This is
|
||||
* used by the race_gui to display the music credits in FTL mode correctly.
|
||||
*/
|
||||
float FollowTheLeaderRace::getClockStartTime()
|
||||
float FollowTheLeaderRace::getClockStartTime() const
|
||||
{
|
||||
return m_leader_intervals[0];
|
||||
} // getClockStartTime
|
||||
|
||||
@@ -48,14 +48,19 @@ public:
|
||||
// overriding World methods
|
||||
virtual void reset() OVERRIDE;
|
||||
virtual const std::string& getIdent() const OVERRIDE;
|
||||
virtual float getClockStartTime();
|
||||
virtual bool useFastMusicNearEnd() const OVERRIDE { return false; }
|
||||
virtual const btTransform &getStartTransform(int index);
|
||||
virtual float getClockStartTime() const;
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
|
||||
virtual void init() OVERRIDE;
|
||||
virtual void terminateRace() OVERRIDE;
|
||||
virtual bool isRaceOver() OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if this type of race has laps. */
|
||||
virtual bool raceHasLaps() OVERRIDE { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if faster music should be used at the end. */
|
||||
virtual bool useFastMusicNearEnd() const OVERRIDE { return false; }
|
||||
}; // FollowTheLeader
|
||||
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ AbstractKart *ProfileWorld::createKart(const std::string &kart_ident, int index,
|
||||
RaceManager::KartType type,
|
||||
const PlayerDifficulty *difficulty)
|
||||
{
|
||||
btTransform init_pos = m_track->getStartTransform(index);
|
||||
btTransform init_pos = getStartTransform(index);
|
||||
|
||||
Kart *new_kart = new KartWithStats(kart_ident,
|
||||
/*world kart id*/ index,
|
||||
|
||||
@@ -336,7 +336,7 @@ void SoccerWorld::moveKartAfterRescue(AbstractKart* kart)
|
||||
{
|
||||
// no need for the overhead to compute exact distance with sqrt(),
|
||||
// so using the 'manhattan' heuristic which will do fine enough.
|
||||
const btTransform &s = world->getTrack()->getStartTransform(n);
|
||||
const btTransform &s = getStartTransform(n);
|
||||
const Vec3 &v=s.getOrigin();
|
||||
float accumulatedDistance = .0f;
|
||||
bool spawnPointClear = true;
|
||||
@@ -368,7 +368,7 @@ void SoccerWorld::moveKartAfterRescue(AbstractKart* kart)
|
||||
}
|
||||
|
||||
assert(furthest_id_found != -1);
|
||||
const btTransform &s = world->getTrack()->getStartTransform(furthest_id_found);
|
||||
const btTransform &s = getStartTransform(furthest_id_found);
|
||||
const Vec3 &xyz = s.getOrigin();
|
||||
kart->setXYZ(xyz);
|
||||
kart->setRotation(s.getRotation());
|
||||
@@ -481,7 +481,7 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
||||
if(index % 2 != 0) posIndex += 1;
|
||||
}
|
||||
|
||||
btTransform init_pos = m_track->getStartTransform(posIndex);
|
||||
btTransform init_pos = getStartTransform(posIndex);
|
||||
|
||||
AbstractKart *new_kart = new Kart(kart_ident, index, position, init_pos,
|
||||
difficulty);
|
||||
|
||||
@@ -497,7 +497,7 @@ unsigned int ThreeStrikesBattle::getRescuePositionIndex(AbstractKart *kart)
|
||||
|
||||
for(int n=0; n<start_spots_amount; n++)
|
||||
{
|
||||
const btTransform &s = getTrack()->getStartTransform(n);
|
||||
const btTransform &s = getStartTransform(n);
|
||||
const Vec3 &v=s.getOrigin();
|
||||
float accumulated_distance = .0f;
|
||||
bool spawn_point_clear = true;
|
||||
|
||||
@@ -305,9 +305,9 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
|
||||
const PlayerDifficulty *difficulty)
|
||||
{
|
||||
int position = index+1;
|
||||
btTransform init_pos = m_track->getStartTransform(index);
|
||||
btTransform init_pos = getStartTransform(index);
|
||||
AbstractKart *new_kart = new Kart(kart_ident, index, position, init_pos,
|
||||
difficulty);
|
||||
difficulty);
|
||||
new_kart->init(race_manager->getKartType(index));
|
||||
Controller *controller = NULL;
|
||||
switch(kart_type)
|
||||
@@ -337,6 +337,14 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
|
||||
return new_kart;
|
||||
} // createKart
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the start coordinates for a kart with a given index.
|
||||
* \param index Index of kart ranging from 0 to kart_num-1. */
|
||||
const btTransform &World::getStartTransform(int index)
|
||||
{
|
||||
return m_track->getStartTransform(index);
|
||||
} // getStartTransform
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Creates an AI controller for the kart.
|
||||
* \param kart The kart to be controlled by an AI.
|
||||
|
||||
@@ -294,6 +294,7 @@ public:
|
||||
PhysicalObject *object);
|
||||
AbstractKart* getPlayerKart(unsigned int player) const;
|
||||
AbstractKart* getLocalPlayerKart(unsigned int n) const;
|
||||
virtual const btTransform &getStartTransform(int index);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a pointer to the race gui. */
|
||||
RaceGUIBase *getRaceGUI() const { return m_race_gui;}
|
||||
|
||||
@@ -149,7 +149,7 @@ unsigned int WorldWithRank::getRescuePositionIndex(AbstractKart *kart)
|
||||
|
||||
for (int n=0; n<start_spots_amount; n++)
|
||||
{
|
||||
const btTransform &s = getTrack()->getStartTransform(n);
|
||||
const btTransform &s = getStartTransform(n);
|
||||
const Vec3 &v = s.getOrigin();
|
||||
|
||||
float abs_distance = (v - kart->getXYZ()).length();
|
||||
|
||||
@@ -1736,7 +1736,14 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
|
||||
|
||||
if (!m_is_arena && !m_is_soccer && !m_is_cutscene)
|
||||
{
|
||||
m_start_transforms.resize(race_manager->getNumberOfKarts());
|
||||
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
||||
{
|
||||
// In a FTL race the non-leader karts are placed at the end of the
|
||||
// field, so we need all start positions.
|
||||
m_start_transforms.resize(stk_config->m_max_karts);
|
||||
}
|
||||
else
|
||||
m_start_transforms.resize(race_manager->getNumberOfKarts());
|
||||
QuadGraph::get()->setDefaultStartPositions(&m_start_transforms,
|
||||
karts_per_row,
|
||||
forwards_distance,
|
||||
|
||||
@@ -523,7 +523,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the start coordinates for a kart with a given index.
|
||||
* \param index Index of kart ranging from 0 to kart_num-1. */
|
||||
btTransform getStartTransform (unsigned int index) const
|
||||
const btTransform& getStartTransform (unsigned int index) const
|
||||
{
|
||||
if (index >= m_start_transforms.size())
|
||||
Log::fatal("Track", "No start position for kart %i.", index);
|
||||
|
||||
Reference in New Issue
Block a user