Removed scene.?pp (which didn't do much anyway except for

handling the cameras, which can as easily be handled by
player karts instead).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3883 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2009-08-19 04:03:25 +00:00
parent 271a157c6c
commit 63e16e3e8a
23 changed files with 93 additions and 228 deletions

View File

@ -64,8 +64,6 @@ supertuxkart_SOURCES = \
graphics/moving_texture.hpp \
graphics/nitro.cpp \
graphics/nitro.hpp \
graphics/scene.cpp \
graphics/scene.hpp \
graphics/shadow.cpp \
graphics/shadow.hpp \
graphics/skid_marks.cpp \

View File

@ -244,9 +244,3 @@ void Camera::update(float dt)
} // update
//-----------------------------------------------------------------------------
void Camera::apply ()
{
} // apply

View File

@ -73,7 +73,6 @@ public:
void reset ();
void setInitialTransform();
void update (float dt);
void apply ();
} ;
#endif

View File

@ -24,7 +24,6 @@
#include "graphics/irr_driver.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/scene.hpp"
#include "items/projectile_manager.hpp"
#include "utils/vec3.hpp"

View File

@ -1,79 +0,0 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/scene.hpp"
#include "btBulletDynamicsCommon.h"
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
Scene *stk_scene = 0;
Scene::Scene()
{
}
//-----------------------------------------------------------------------------
Scene::~Scene ()
{
}
//-----------------------------------------------------------------------------
void Scene::clear ()
{
for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
delete *i;
m_cameras.clear();
}
//-----------------------------------------------------------------------------
Camera *Scene::createCamera(int playerId, const Kart* kart)
{
Camera *cam = new Camera(playerId, kart);
m_cameras.push_back(cam);
return cam;
}
//-----------------------------------------------------------------------------
void Scene::reset()
{
/** Note: the cameras are reset in player_kart. This is necessary since
* the camera needs the correct starting position and rotation of the
* kart (to avoid that the camera jumps in the first frame). */
} // reset
//-----------------------------------------------------------------------------
void Scene::draw(float dt)
{
const Track* TRACK = RaceManager::getTrack();
for (Cameras::iterator i = m_cameras.begin(); i != m_cameras.end(); ++i)
{
(*i)->update(dt);
(*i)->apply ();
} // for cameras
}

View File

@ -1,45 +0,0 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_SCENE_HPP
#define HEADER_SCENE_HPP
//FIXME: make the camera a pointer to vector so it can be forward declared.
#include <vector>
#include "LinearMath/btVector3.h"
class Camera;
class Kart;
class Scene
{
typedef std::vector<Camera*> Cameras;
Cameras m_cameras;
public:
Scene ();
~Scene ();
void reset();
void clear();
void draw(float dt);
Camera *createCamera(int playerId, const Kart* kart);
};
extern Scene *stk_scene;
#endif

View File

@ -517,7 +517,7 @@
>
</File>
<File
RelativePath="..\..\graphics\explosion.hpp"
RelativePath="..\..\graphics\explosion.cpp"
>
</File>
<File
@ -544,10 +544,6 @@
RelativePath="..\..\graphics\nitro.cpp"
>
</File>
<File
RelativePath="..\..\graphics\scene.cpp"
>
</File>
<File
RelativePath="..\..\graphics\shadow.cpp"
>
@ -1267,7 +1263,7 @@
>
</File>
<File
RelativePath="..\..\graphics\explosion.cpp"
RelativePath="..\..\graphics\explosion.hpp"
>
</File>
<File
@ -1294,10 +1290,6 @@
RelativePath="..\..\graphics\nitro.hpp"
>
</File>
<File
RelativePath="..\..\graphics\scene.hpp"
>
</File>
<File
RelativePath="..\..\graphics\shadow.hpp"
>

View File

@ -26,7 +26,6 @@
#include "graphics/irr_driver.hpp"
#include "graphics/mesh_tools.hpp"
#include "graphics/scene.hpp"
#include "items/projectile_manager.hpp"
#include "karts/kart.hpp"
#include "modes/world.hpp"

View File

@ -20,7 +20,6 @@
#include "items/item.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/scene.hpp"
#include "karts/kart.hpp"
#include "utils/coord.hpp"
#include "utils/vec3.hpp"

View File

@ -23,7 +23,6 @@
#include "items/plunger.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/scene.hpp"
#include "items/rubber_band.hpp"
#include "items/projectile_manager.hpp"
#include "karts/player_kart.hpp"

View File

@ -20,7 +20,6 @@
#include "items/projectile_manager.hpp"
#include "graphics/explosion.hpp"
#include "graphics/scene.hpp"
#include "items/bowling.hpp"
#include "items/cake.hpp"
#include "items/plunger.hpp"

View File

@ -21,7 +21,6 @@
#include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/scene.hpp"
#include "items/plunger.hpp"
#include "items/projectile_manager.hpp"
#include "karts/kart.hpp"

View File

@ -24,7 +24,6 @@
#include "audio/sfx_manager.hpp"
#include "config/player.hpp"
#include "graphics/camera.hpp"
#include "graphics/scene.hpp"
#include "states_screens/race_gui.hpp"
#include "input/input_manager.hpp"
#include "items/item.hpp"
@ -39,7 +38,7 @@ PlayerKart::PlayerKart(const std::string& kart_name, int position, ActivePlayer
{
m_player = player;
m_penalty_time = 0.0f;
m_camera = stk_scene->createCamera(player_index, this);
m_camera = new Camera(player_index, this);
m_camera->setMode(Camera::CM_NORMAL);
m_bzzt_sound = sfx_manager->newSFX(SFXManager::SOUND_BZZT );
@ -216,6 +215,7 @@ void PlayerKart::steer(float dt, int steer_val)
//-----------------------------------------------------------------------------
void PlayerKart::update(float dt)
{
m_camera->update(dt);
// Don't do steering if it's replay. In position only replay it doesn't
// matter, but if it's physics replay the gradual steering causes
// incorrect results, since the stored values are already adjusted.

View File

@ -48,7 +48,6 @@
#include "config/player.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/scene.hpp"
#include "guiengine/engine.hpp"
#include "states_screens/state_manager.hpp"
#include "io/file_manager.hpp"
@ -536,7 +535,6 @@ void cleanTuxKart()
if(unlock_manager) delete unlock_manager;
if(translations) delete translations;
if(file_manager) delete file_manager;
if(stk_scene) delete stk_scene;
if(irr_driver) delete irr_driver;
}
@ -594,7 +592,6 @@ int main(int argc, char *argv[] )
powerup_manager -> loadPowerups ();
item_manager -> loadDefaultItems();
attachment_manager -> loadModels ();
stk_scene = new Scene();
// Init GUI prepare main menu
IrrlichtDevice* device = irr_driver->getDevice();

View File

@ -25,7 +25,6 @@
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/scene.hpp"
#include "guiengine/engine.hpp"
#include "states_screens/state_manager.hpp"
#include "input/input_manager.hpp"
@ -123,9 +122,6 @@ void MainLoop::updateRace(float dt)
if(!race_manager->getWorld()->isFinishPhase())
network_manager->sendUpdates();
if(UserConfigParams::m_profile) dt=1.0f/60.0f;
// In the first call dt might be large (includes loading time),
// which can cause the camera to significantly tilt
stk_scene->draw(RaceManager::getWorld()->getPhase()==SETUP_PHASE ? 0.0f : dt);
// Again, only receive updates if the race isn't over - once the
// race results are displayed (i.e. game is in finish phase)

View File

@ -31,7 +31,6 @@
#include "challenges/unlock_manager.hpp"
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/scene.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/race_gui.hpp"
#include "io/file_manager.hpp"
@ -105,7 +104,6 @@ void World::init()
for(unsigned int i=0; i<race_manager->getNumKarts(); i++)
{
int position = i+1; // position start with 1
btTransform init_pos=m_track->getStartTransform(i);
Kart* newkart;
const std::string& kart_ident = race_manager->getKartIdent(i);
@ -113,44 +111,17 @@ void World::init()
int global_player_id = race_manager->getKartGlobalPlayerId(i);
if(UserConfigParams::m_profile)
{
// In profile mode, load only the old kart
newkart = new DefaultRobot(kart_ident, position, init_pos, m_track);
// Create a camera for the last kart (since this way more of the
// karts can be seen.
if(i==race_manager->getNumKarts()-1)
{
stk_scene->createCamera(local_player_id, newkart);
m_local_player_karts[0] = static_cast<PlayerKart*>(newkart);
}
newkart = new DefaultRobot(kart_ident, i+1, init_pos, m_track,
(i==race_manager->getNumKarts()-1) ? 0 : -1);
// FIXME: does this actually work???
m_local_player_karts[0] = static_cast<PlayerKart*>(newkart);
}
else
{
switch(race_manager->getKartType(i))
{
case RaceManager::KT_PLAYER:
std::cout << "===== World : creating player kart for kart #" << i << " which has local_player_id " << local_player_id << " ===========\n";
newkart = new PlayerKart(kart_ident, position,
StateManager::get()->getActivePlayer(local_player_id),
init_pos, local_player_id);
m_player_karts[global_player_id] = (PlayerKart*)newkart;
m_local_player_karts[local_player_id] = static_cast<PlayerKart*>(newkart);
break;
case RaceManager::KT_NETWORK_PLAYER:
newkart = new NetworkKart(kart_ident, position, init_pos,
global_player_id);
m_network_karts[global_player_id] = static_cast<NetworkKart*>(newkart);
m_player_karts[global_player_id] = (PlayerKart*)newkart;
break;
case RaceManager::KT_AI:
std::cout << "===== World : creating AI kart for #" << i << "===========\n";
newkart = loadRobot(kart_ident, position, init_pos);
break;
case RaceManager::KT_GHOST:
break;
case RaceManager::KT_LEADER:
break;
}
newkart = createKart(kart_ident, i, local_player_id,
global_player_id, init_pos);
} // if !UserConfigParams::m_profile
m_kart.push_back(newkart);
newkart->setWorldKartId(m_kart.size()-1);
@ -168,7 +139,75 @@ void World::init()
} // World
//-----------------------------------------------------------------------------
World::~World()
/** Creates a kart, having a certain position, starting location, and local
* and global player id (if applicable).
* \param kart_ident Identifier of the kart to create.
* \param index Index of the kart.
* \param local_player_id If the kart is a player kart this is the index of
* this player on the local machine.
* \param global_player_id If the akrt is a player kart this is the index of
* this player globally (i.e. including network players).
* \param init_pos The start XYZ coordinates.
*/
Kart *World::createKart(const std::string &kart_ident, int index,
int local_player_id, int global_player_id,
const btTransform &init_pos)
{
Kart *newkart = NULL;
int position = index+1;
switch(race_manager->getKartType(index))
{
case RaceManager::KT_PLAYER:
std::cout << "===== World : creating player kart for kart #" << index << " which has local_player_id " << local_player_id << " ===========\n";
newkart = new PlayerKart(kart_ident, position,
StateManager::get()->getActivePlayer(local_player_id),
init_pos, local_player_id);
m_player_karts[global_player_id] = (PlayerKart*)newkart;
m_local_player_karts[local_player_id] = static_cast<PlayerKart*>(newkart);
break;
case RaceManager::KT_NETWORK_PLAYER:
newkart = new NetworkKart(kart_ident, position, init_pos,
global_player_id);
m_network_karts[global_player_id] = static_cast<NetworkKart*>(newkart);
m_player_karts[global_player_id] = (PlayerKart*)newkart;
break;
case RaceManager::KT_AI:
std::cout << "===== World : creating AI kart for #" << index << "===========\n";
newkart = loadRobot(kart_ident, position, init_pos);
break;
case RaceManager::KT_GHOST:
break;
case RaceManager::KT_LEADER:
break;
}
return newkart;
} // createKart
//-----------------------------------------------------------------------------
Kart* World::loadRobot(const std::string& kart_name, int position,
const btTransform& init_pos)
{
Kart* currentRobot;
const int NUM_ROBOTS = 1;
switch(m_random.get(NUM_ROBOTS))
{
case 0:
currentRobot = new DefaultRobot(kart_name, position, init_pos, m_track);
break;
default:
std::cerr << "Warning: Unknown robot, using default." << std::endl;
currentRobot = new DefaultRobot(kart_name, position, init_pos, m_track);
break;
}
return currentRobot;
} // loadRobot
//-----------------------------------------------------------------------------
World::~World()
{
delete m_race_gui;
delete race_state;
@ -479,33 +518,8 @@ void World::restartRace()
projectile_manager->cleanup();
race_manager->reset();
// Resets the cameras in case that they are pointing too steep up or down
stk_scene->reset();
} // restartRace
//-----------------------------------------------------------------------------
Kart* World::loadRobot(const std::string& kart_name, int position,
const btTransform& init_pos)
{
Kart* currentRobot;
const int NUM_ROBOTS = 1;
switch(m_random.get(NUM_ROBOTS))
{
case 0:
currentRobot = new DefaultRobot(kart_name, position, init_pos, m_track);
break;
default:
std::cerr << "Warning: Unknown robot, using default." << std::endl;
currentRobot = new DefaultRobot(kart_name, position, init_pos, m_track);
break;
}
return currentRobot;
}
//-----------------------------------------------------------------------------
void World::pause()
{

View File

@ -110,6 +110,10 @@ protected:
void printProfileResultAndExit();
void estimateFinishTimes();
virtual Kart *createKart(const std::string &kart_ident, int index,
int local_player_id, int global_player_id,
const btTransform &init_pos);
/** Pointer to the track. The track is managed by world. */
Track* m_track;

View File

@ -26,7 +26,6 @@ using namespace irr;
#include "graphics/irr_driver.hpp"
#include "graphics/mesh_tools.hpp"
#include "graphics/scene.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "modes/world.hpp"

View File

@ -24,7 +24,6 @@
#include "challenges/unlock_manager.hpp"
#include "config/user_config.hpp"
#include "config/stk_config.hpp"
#include "graphics/scene.hpp"
#include "states_screens/kart_selection.hpp"
#include "states_screens/state_manager.hpp"
#include "input/device_manager.hpp"
@ -290,7 +289,6 @@ void RaceManager::next()
network_manager->beginReadySetGoBarrier();
else
network_manager->setState(NetworkManager::NS_WAIT_FOR_RACE_DATA);
stk_scene->clear();
startNextRace();
}
else
@ -387,7 +385,6 @@ void RaceManager::exitRace()
// FIXME - back to main menu
// menu_manager->switchToMainMenu();
}
stk_scene->clear();
delete world;
world = 0;
m_track_number = 0;

View File

@ -21,7 +21,6 @@
#include "replay/replay_player.hpp"
#include "graphics/scene.hpp"
#include "karts/kart_properties_manager.hpp"
#include "karts/kart_properties.hpp"

View File

@ -37,7 +37,7 @@
#ifdef AI_DEBUG
#include "graphics/irr_driver.hpp"
#endif
#include "graphics/scene.hpp"
#include "graphics/camera.hpp"
#include "modes/linear_world.hpp"
#include "network/network_manager.hpp"
#include "race/race_manager.hpp"
@ -47,9 +47,10 @@
DefaultRobot::DefaultRobot(const std::string& kart_name,
int position, const btTransform& init_pos,
const Track *track ) :
const Track *track, int camera_number ) :
AutoKart( kart_name, position, init_pos )
{
m_camera = camera_number >=0 ? new Camera(camera_number, this) : NULL;
m_kart_length = m_kart_properties->getKartModel()->getLength();
m_kart_width = m_kart_properties->getKartModel()->getWidth();
m_track = RaceManager::getTrack();

View File

@ -28,6 +28,7 @@ class Track;
class LinearWorld;
class QuadGraph;
class irr::scene::ISceneNode;
class Camera;
class DefaultRobot : public AutoKart
{
@ -153,6 +154,10 @@ private:
* is targeting at. */
irr::scene::ISceneNode *m_debug_sphere;
/** A camera that can be attached to a robot. This is mainly a debugging
* tool, used in working on the AI and in doing profile runs. Otherwise
* this variable is not used. */
Camera *m_camera;
/** The minimum steering angle at which the AI adds skidding. Lower values
* tend to improve the line the AI is driving. This is used to adjust for
* different AI levels.
@ -187,7 +192,8 @@ private:
public:
DefaultRobot(const std::string& kart_name, int position,
const btTransform& init_pos, const Track *track);
const btTransform& init_pos, const Track *track,
int camera_number=-1);
~DefaultRobot();
void update (float delta) ;
void reset ();

View File

@ -34,7 +34,6 @@ using namespace irr;
#include "graphics/material_manager.hpp"
#include "graphics/mesh_tools.hpp"
#include "graphics/moving_texture.hpp"
#include "graphics/scene.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "items/item.hpp"