1) Started to add split screen (though not all parts of the race gui are displayed correctly yet).
2) The name of an AI kart will now only get the AI name added if it's profile mode (to prevent the name with AI name to be displayed in game) 3) Some code cleanup. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4226 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
f80dc3a26b
commit
a5a90be806
@ -34,7 +34,7 @@ Camera::Camera(int camera_index, const Kart* kart)
|
||||
{
|
||||
m_mode = CM_NORMAL;
|
||||
m_index = camera_index;
|
||||
m_camera = irr_driver->addCamera();
|
||||
m_camera = irr_driver->addCameraSceneNode();
|
||||
m_distance = kart->getKartProperties()->getCameraDistance() * 0.5f;
|
||||
m_kart = kart;
|
||||
m_angle_up = 0.0f;
|
||||
@ -49,63 +49,15 @@ Camera::Camera(int camera_index, const Kart* kart)
|
||||
m_target_speed = 10.0f;
|
||||
m_rotation_range = 0.4f;
|
||||
|
||||
// TODO: Set fog distance and clipping planes
|
||||
setScreenPosition(camera_index);
|
||||
} // Camera
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Removes the camera scene node from the scene.
|
||||
*/
|
||||
Camera::~Camera()
|
||||
{
|
||||
irr_driver->removeCamera(m_camera);
|
||||
m_camera=NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void Camera::setScreenPosition(int camera_index)
|
||||
{
|
||||
const int num_players = race_manager->getNumLocalPlayers();
|
||||
assert(camera_index >= 0 && camera_index <= 3);
|
||||
|
||||
if (num_players == 1)
|
||||
{
|
||||
// m_camera->setFOV( DEGREE_TO_RAD(75.0f) ) ;
|
||||
m_x = 0.0f; m_y = 0.0f; m_w = 1.0f; m_h = 1.0f ;
|
||||
}
|
||||
else if (num_players == 2)
|
||||
{
|
||||
// m_context -> setFOV ( 85.0f, 85.0f*3.0f/8.0f ) ;
|
||||
switch ( camera_index )
|
||||
{
|
||||
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 1.0f; m_h = 0.5f; break;
|
||||
case 1 : m_x = 0.0f; m_y = 0.0f; m_w = 1.0f; m_h = 0.5f; break;
|
||||
}
|
||||
}
|
||||
else if (num_players == 3)
|
||||
{
|
||||
// m_context -> setFOV ( 50.0f, 0.0f );
|
||||
switch ( camera_index )
|
||||
{
|
||||
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
||||
case 1 : m_x = 0.5f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
||||
case 2 : m_x = 0.0f; m_y = 0.0f; m_w = 1.0f; m_h = 0.5f;
|
||||
// m_context -> setFOV ( 85.0f, 85.0f*3.0f/8.0f );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (num_players == 4)
|
||||
{
|
||||
// m_context -> setFOV ( 50.0f, 0.0f );
|
||||
|
||||
switch ( camera_index )
|
||||
{
|
||||
case 0 : m_x = 0.0f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
||||
case 1 : m_x = 0.5f; m_y = 0.5f; m_w = 0.5f; m_h = 0.5f; break;
|
||||
case 2 : m_x = 0.0f; m_y = 0.0f; m_w = 0.5f; m_h = 0.5f; break;
|
||||
case 3 : m_x = 0.5f; m_y = 0.0f; m_w = 0.5f; m_h = 0.5f; break;
|
||||
}
|
||||
}
|
||||
} // setScreenPosition
|
||||
irr_driver->removeCamera(this);
|
||||
} // ~Camera
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Camera::setMode(Mode mode)
|
||||
|
@ -58,8 +58,6 @@ private:
|
||||
float m_target_speed; // The speed at which the camera changes targets
|
||||
float m_rotation_range; // Factor of the effects of steering in camera aim
|
||||
|
||||
float m_x, m_y, m_w, m_h;
|
||||
|
||||
const Kart *m_kart; // The kart that the camera follows
|
||||
|
||||
private:
|
||||
@ -69,10 +67,13 @@ public:
|
||||
~Camera ();
|
||||
void setMode (Mode mode_); /** Set the camera to the given mode */
|
||||
Mode getMode();
|
||||
void setScreenPosition (int pos);
|
||||
void reset ();
|
||||
void setInitialTransform();
|
||||
void update (float dt);
|
||||
scene::ICameraSceneNode *getCameraSceneNode()
|
||||
{
|
||||
return m_camera;
|
||||
}
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
@ -28,6 +28,7 @@
|
||||
#endif
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
@ -40,6 +41,7 @@
|
||||
#include "items/projectile_manager.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
|
||||
using namespace irr::core;
|
||||
using namespace irr::scene;
|
||||
@ -488,10 +490,43 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<std::string> &texture_
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Adds a camera to the scene.
|
||||
*/
|
||||
scene::ICameraSceneNode *IrrDriver::addCamera()
|
||||
scene::ICameraSceneNode *IrrDriver::addCameraSceneNode()
|
||||
{
|
||||
return m_scene_manager->addCameraSceneNode();
|
||||
} // addCamera
|
||||
} // addCameraSceneNode
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Adds a camera (as in STK Camera object, not an irrlicht camera). The number
|
||||
* of cameras determines e.g. if split screen is used.
|
||||
*/
|
||||
Camera *IrrDriver::addCamera(unsigned int index, Kart *kart)
|
||||
{
|
||||
Camera *camera = new Camera(index, kart);
|
||||
m_stk_cameras.push_back(camera);
|
||||
m_viewports.push_back(core::recti());
|
||||
m_scaling.push_back(core::vector2df());
|
||||
m_fov.push_back(DEGREE_TO_RAD*75.0f);
|
||||
m_aspect.push_back(((float)UserConfigParams::m_width)/UserConfigParams::m_height);
|
||||
setupViewports();
|
||||
return camera;
|
||||
} // addCamera
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void IrrDriver::removeCamera(Camera *camera)
|
||||
{
|
||||
unsigned index;
|
||||
for(index=0; index<m_stk_cameras.size(); index++)
|
||||
{
|
||||
if(m_stk_cameras[index]==camera) break;
|
||||
}
|
||||
assert(index!=m_stk_cameras.size());
|
||||
m_stk_cameras.erase(m_stk_cameras.begin()+index);
|
||||
m_viewports.erase(m_viewports.begin()+index);
|
||||
m_scaling.erase(m_scaling.begin()+index);
|
||||
m_fov.erase(m_fov.begin()+index);
|
||||
m_aspect.erase(m_aspect.begin()+index);
|
||||
removeCameraSceneNode(camera->getCameraSceneNode());
|
||||
} // removeCamera
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Removes a camera. This can't be done with removeNode() since the camera
|
||||
@ -500,12 +535,12 @@ scene::ICameraSceneNode *IrrDriver::addCamera()
|
||||
* a camera is added), it's a bit cleaner and easier to check for memory
|
||||
* leaks, since the scene root should now always be empty.
|
||||
*/
|
||||
void IrrDriver::removeCamera(scene::ICameraSceneNode *camera)
|
||||
void IrrDriver::removeCameraSceneNode(scene::ICameraSceneNode *camera)
|
||||
{
|
||||
if(camera==m_scene_manager->getActiveCamera())
|
||||
m_scene_manager->setActiveCamera(NULL); // basically causes a drop
|
||||
camera->remove();
|
||||
} // removeCamera
|
||||
} // removeCameraSceneNode
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Loads a texture from a file and returns the texture object.
|
||||
@ -516,6 +551,88 @@ video::ITexture *IrrDriver::getTexture(const std::string &filename)
|
||||
return m_scene_manager->getVideoDriver()->getTexture(filename.c_str());
|
||||
} // getTexture
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Determines the viewports and scaling for the cameras.
|
||||
*/
|
||||
void IrrDriver::setupViewports()
|
||||
{
|
||||
assert(m_stk_cameras.size()==m_viewports.size());
|
||||
switch(m_stk_cameras.size())
|
||||
{
|
||||
case 1: m_viewports[0] = core::recti(0, 0,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height);
|
||||
m_scaling[0] = core::vector2df(1.0f, 1.0f);
|
||||
break;
|
||||
case 2: m_viewports[0] = core::recti(0, 0,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height>>1);
|
||||
m_scaling[0] = core::vector2df(1.0f, 0.5f);
|
||||
m_aspect[0] *= 2.0f;
|
||||
m_fov[0] = DEGREE_TO_RAD*85.0f;
|
||||
m_viewports[1] = core::recti(0, UserConfigParams::m_height>>1,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height);
|
||||
m_scaling[1] = core::vector2df(1.0f, 0.5f);
|
||||
m_aspect[1] *= 2.0f;
|
||||
m_fov[1] = DEGREE_TO_RAD*85.0f;
|
||||
break;
|
||||
case 3: m_viewports[0] = core::recti(0, 0,
|
||||
UserConfigParams::m_width>>1,
|
||||
UserConfigParams::m_height>>1);
|
||||
m_scaling[0] = core::vector2df(0.5f, 0.5f);
|
||||
m_fov[1] = DEGREE_TO_RAD*50.0f;
|
||||
m_viewports[1] = core::recti(UserConfigParams::m_width>>1,
|
||||
0,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height>>1);
|
||||
m_scaling[1] = core::vector2df(0.5f, 0.5f);
|
||||
m_fov[1] = DEGREE_TO_RAD*50.0f;
|
||||
m_viewports[2] = core::recti(0, UserConfigParams::m_height>>1,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height);
|
||||
m_scaling[2] = core::vector2df(1.0f, 0.5f);
|
||||
m_fov[1] = DEGREE_TO_RAD*85.0f;
|
||||
m_aspect[2] *= 2.0f;
|
||||
break;
|
||||
case 4: m_viewports[0] = core::recti(0, 0,
|
||||
UserConfigParams::m_width>>1,
|
||||
UserConfigParams::m_height>>1);
|
||||
m_scaling[0] = core::vector2df(0.5f, 0.5f);
|
||||
m_fov[0] = DEGREE_TO_RAD*50.0f;
|
||||
m_viewports[1] = core::recti(UserConfigParams::m_width>>1,
|
||||
0,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height>>1);
|
||||
m_scaling[1] = core::vector2df(0.5f, 0.5f);
|
||||
m_fov[1] = DEGREE_TO_RAD*50.0f;
|
||||
m_viewports[2] = core::recti(0, UserConfigParams::m_height>>1,
|
||||
UserConfigParams::m_width>>1,
|
||||
UserConfigParams::m_height);
|
||||
m_scaling[2] = core::vector2df(0.5f, 0.5f);
|
||||
m_fov[2] = DEGREE_TO_RAD*50.0f;
|
||||
m_viewports[3] = core::recti(UserConfigParams::m_width>>1,
|
||||
UserConfigParams::m_height>>1,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height);
|
||||
m_scaling[3] = core::vector2df(0.5f, 0.5f);
|
||||
m_fov[3] = DEGREE_TO_RAD*50.0f;
|
||||
break;
|
||||
default:fprintf(stderr, "Incorrect number of players: '%d' - assuming 1.\n",
|
||||
m_stk_cameras.size());
|
||||
m_viewports[0] = core::recti(0, 0,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height);
|
||||
m_scaling[0] = core::vector2df(1.0f, 1.0f);
|
||||
break;
|
||||
} // switch
|
||||
for(unsigned int i=0; i<m_stk_cameras.size(); i++)
|
||||
{
|
||||
m_stk_cameras[i]->getCameraSceneNode()->setFOV(m_fov[i]);
|
||||
m_stk_cameras[i]->getCameraSceneNode()->setAspectRatio(m_aspect[i]);
|
||||
}
|
||||
} // setupViewports
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sets the ambient light.
|
||||
* \param light The colour of the light to set.
|
||||
@ -625,15 +742,20 @@ void IrrDriver::displayFPS()
|
||||
*/
|
||||
void IrrDriver::update(float dt)
|
||||
{
|
||||
// First update all cameras
|
||||
std::vector<Camera*>::iterator i;
|
||||
for(i=m_stk_cameras.begin(); i!=m_stk_cameras.end(); i++)
|
||||
(*i)->update(dt);
|
||||
|
||||
if(!m_device->run()) return;
|
||||
|
||||
m_device->getVideoDriver()->beginScene(false, true, video::SColor(255,100,101,140));
|
||||
|
||||
{ // just to mark the beding/end scene block
|
||||
{ // Just to mark the beding/end scene block
|
||||
GUIEngine::GameState state = StateManager::get()->getGameState();
|
||||
if (state != GUIEngine::GAME)
|
||||
{
|
||||
// this code needs to go outside beginScene() / endScene() since
|
||||
// This code needs to go outside beginScene() / endScene() since
|
||||
// the model view widget will do off-screen rendering there
|
||||
const int updateAmount = GUIEngine::needsUpdate.size();
|
||||
for(int n=0; n<updateAmount; n++)
|
||||
@ -651,21 +773,32 @@ void IrrDriver::update(float dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scene_manager->drawAll();
|
||||
}
|
||||
RaceGUI *rg = RaceManager::getWorld()->getRaceGUI();
|
||||
for(unsigned int i=0; i<m_stk_cameras.size(); i++)
|
||||
{
|
||||
m_scene_manager->setActiveCamera(m_stk_cameras[i]->getCameraSceneNode());
|
||||
m_video_driver->setViewPort(m_viewports[i]);
|
||||
m_scene_manager->drawAll();
|
||||
}
|
||||
// To draw the race gui we set the viewport back to the full
|
||||
// screen.
|
||||
m_video_driver->setViewPort(core::recti(0, 0,
|
||||
UserConfigParams::m_width,
|
||||
UserConfigParams::m_height));
|
||||
for(unsigned int i=0; i<m_stk_cameras.size(); i++)
|
||||
{
|
||||
rg->renderPlayerView(i, m_viewports[i], m_scaling[i]);
|
||||
} // for i <m_stk_cameras.size()
|
||||
} // !bullet_debug
|
||||
}
|
||||
|
||||
if (inRace || GUIEngine::getCurrentScreen()->needs3D())
|
||||
else
|
||||
{
|
||||
// render 3D stuff in cutscenes too
|
||||
m_scene_manager->drawAll();
|
||||
}
|
||||
|
||||
// GUI is active
|
||||
//if (!inRace || GUIEngine::ModalDialog::isADialogActive())
|
||||
{
|
||||
GUIEngine::render(dt);
|
||||
}
|
||||
// Either render the gui, or the global elements of the race gui.
|
||||
GUIEngine::render(dt);
|
||||
|
||||
// draw FPS if enabled
|
||||
if ( UserConfigParams::m_display_fps ) displayFPS();
|
||||
|
@ -29,6 +29,9 @@
|
||||
#include "irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
class Camera;
|
||||
class Kart;
|
||||
|
||||
struct VideoMode
|
||||
{
|
||||
int width, height;
|
||||
@ -48,13 +51,28 @@ private:
|
||||
/** Irrlicht race font. */
|
||||
irr::gui::IGUIFont *m_race_font;
|
||||
|
||||
/** The list of all cameras. */
|
||||
std::vector<Camera*> m_stk_cameras;
|
||||
|
||||
/** The list of viewports for all cameras. */
|
||||
std::vector<core::recti> m_viewports;
|
||||
|
||||
/** The scaling necessary for each axis for each camera. */
|
||||
std::vector<core::vector2df> m_scaling;
|
||||
|
||||
/** Field of view for camera. */
|
||||
std::vector<float> m_fov;
|
||||
|
||||
/** Aspect ratio for camera. */
|
||||
std::vector<float> m_aspect;
|
||||
|
||||
void setAllMaterialFlags(scene::IAnimatedMesh *mesh) const;
|
||||
std::vector<VideoMode> m_modes;
|
||||
|
||||
void renderBulletDebugView();
|
||||
void displayFPS();
|
||||
video::E_DRIVER_TYPE getEngineDriverType(int index);
|
||||
void renderBulletDebugView();
|
||||
void displayFPS();
|
||||
void setupViewports();
|
||||
video::E_DRIVER_TYPE getEngineDriverType(int index);
|
||||
public:
|
||||
IrrDriver();
|
||||
~IrrDriver();
|
||||
@ -102,8 +120,10 @@ public:
|
||||
scene::IAnimatedMeshSceneNode
|
||||
*addAnimatedMesh(scene::IAnimatedMesh *mesh);
|
||||
scene::ICameraSceneNode
|
||||
*addCamera();
|
||||
void removeCamera(scene::ICameraSceneNode *camera);
|
||||
*addCameraSceneNode();
|
||||
Camera *addCamera(unsigned int index, Kart *kart);
|
||||
void removeCameraSceneNode(scene::ICameraSceneNode *camera);
|
||||
void removeCamera(Camera *camera);
|
||||
void update(float dt);
|
||||
|
||||
void changeResolution();
|
||||
|
@ -236,9 +236,10 @@ void render(float elapsed_time)
|
||||
}
|
||||
else
|
||||
{
|
||||
RaceManager::getWorld()->getRaceGUI()->render();
|
||||
RaceManager::getWorld()->getRaceGUI()->renderGlobal(elapsed_time);
|
||||
}
|
||||
}
|
||||
} // render
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
Widget* getWidget(const char* name)
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/coord.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
|
@ -34,14 +34,7 @@ public:
|
||||
Kart(kart_name, position, init_pos) {}
|
||||
|
||||
bool isPlayerKart() const {return false;}
|
||||
virtual const irr::core::stringw& getName() const
|
||||
{
|
||||
// Static to avoid returning the address of a temporary
|
||||
// string.
|
||||
static irr::core::stringw name = Kart::getName()+"(auto)";
|
||||
return name;
|
||||
} // getName
|
||||
};
|
||||
}; // AutoKart
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/player.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "items/item.hpp"
|
||||
#include "modes/world.hpp"
|
||||
@ -39,7 +40,7 @@ PlayerKart::PlayerKart(const std::string& kart_name, int position,
|
||||
{
|
||||
m_player = player;
|
||||
m_penalty_time = 0.0f;
|
||||
m_camera = RaceManager::getWorld()->getRaceGUI()->addCamera(player_index, this);
|
||||
m_camera = irr_driver->addCamera(player_index, this);
|
||||
m_camera->setMode(Camera::CM_NORMAL);
|
||||
|
||||
m_bzzt_sound = sfx_manager->newSFX(SFXManager::SOUND_BZZT );
|
||||
@ -54,6 +55,7 @@ PlayerKart::PlayerKart(const std::string& kart_name, int position,
|
||||
//-----------------------------------------------------------------------------
|
||||
PlayerKart::~PlayerKart()
|
||||
{
|
||||
irr_driver->removeCamera(m_camera);
|
||||
sfx_manager->deleteSFX(m_bzzt_sound);
|
||||
sfx_manager->deleteSFX(m_wee_sound );
|
||||
sfx_manager->deleteSFX(m_ugh_sound );
|
||||
|
@ -87,7 +87,7 @@ Kart *ProfileWorld::createKart(const std::string &kart_ident, int index,
|
||||
{
|
||||
// The pointer to the camera does not have to be stored, since it
|
||||
// the camera for robots is not modified.
|
||||
RaceManager::getWorld()->getRaceGUI()->addCamera(index, newkart);
|
||||
irr_driver->addCamera(index, newkart);
|
||||
}
|
||||
//m_local_player_karts[index] = static_cast<PlayerKart*>(newkart);
|
||||
//m_player_karts[index] = static_cast<PlayerKart*>(newkart);
|
||||
|
@ -316,16 +316,6 @@ void World::resetAllKarts()
|
||||
m_player_karts[i]->getCamera()->setInitialTransform();
|
||||
} // resetAllKarts
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called during rendering. In this function direct calls to the graphics
|
||||
* are possible, e.g. using an irrlicht font object to directly print to
|
||||
* the screen, ...
|
||||
*/
|
||||
void World::render()
|
||||
{
|
||||
m_race_gui->render();
|
||||
} // render
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void World::update(float dt)
|
||||
{
|
||||
@ -362,7 +352,6 @@ void World::update(float dt)
|
||||
m_track->update(dt);
|
||||
|
||||
projectile_manager->update(dt);
|
||||
m_race_gui->update(dt);
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -128,7 +128,6 @@ public:
|
||||
|
||||
virtual ~World();
|
||||
virtual void update(float delta);
|
||||
virtual void render();
|
||||
/** Returns true if the race is over. Must be defined by all modes. */
|
||||
virtual bool isRaceOver() = 0;
|
||||
virtual void restartRace();
|
||||
|
@ -30,6 +30,7 @@ using namespace irr;
|
||||
#include "io/xml_node.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/coord.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define HEADER_DEFAULT_HPP
|
||||
|
||||
#include "karts/auto_kart.hpp"
|
||||
#include "modes/profile_world.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
/* third coord won't be used */
|
||||
@ -194,8 +195,12 @@ public:
|
||||
virtual void crashed (Kart *k) {if(k) m_collided = true;};
|
||||
virtual const irr::core::stringw& getName() const
|
||||
{
|
||||
// Static to avoid returning the address of a temporary string
|
||||
static irr::core::stringw name=m_kart_properties->getName()+"(default)";
|
||||
// Static to avoid returning the address of a temporary stringq
|
||||
static irr::core::stringw name=m_kart_properties->getName();
|
||||
// Add the name of the AI in case of profile mode, to make it
|
||||
// easier to compare AIs
|
||||
if(ProfileWorld::isProfileMode())
|
||||
name+="(default)";
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ void FeatureUnlockedCutScene::init()
|
||||
m_sky = irr_driver->addSkyDome(file_manager->getTextureFile("lscales.png"), 16 /* hori_res */, 16 /* vert_res */,
|
||||
1.0f /* texture_percent */, 2.0f /* sphere_percent */);
|
||||
|
||||
m_camera = irr_driver->addCamera();
|
||||
m_camera = irr_driver->addCameraSceneNode();
|
||||
m_camera->setPosition( core::vector3df(0.0, 30.0f, 70.0f) );
|
||||
m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) );
|
||||
m_camera->setTarget( core::vector3df(0, 10, 0.0f) );
|
||||
@ -92,7 +92,7 @@ void FeatureUnlockedCutScene::tearDown()
|
||||
irr_driver->removeNode(m_sky);
|
||||
m_sky = NULL;
|
||||
|
||||
irr_driver->removeCamera(m_camera);
|
||||
irr_driver->removeCameraSceneNode(m_camera);
|
||||
m_camera = NULL;
|
||||
|
||||
irr_driver->removeNode(m_chest);
|
||||
|
@ -90,7 +90,7 @@ void RaceGUI::createMarkerTexture()
|
||||
m_marker_rendered_size),
|
||||
"RaceGUI::markers");
|
||||
#endif
|
||||
scene::ICameraSceneNode *camera = irr_driver->addCamera();
|
||||
scene::ICameraSceneNode *camera = irr_driver->addCameraSceneNode();
|
||||
core::matrix4 projection;
|
||||
projection.buildProjectionMatrixOrthoLH((float)(m_marker_rendered_size*npower2),
|
||||
(float)(m_marker_rendered_size), -1.0f, 1.0f);
|
||||
@ -128,7 +128,7 @@ void RaceGUI::createMarkerTexture()
|
||||
}
|
||||
|
||||
m_marker = rttProvider.renderToTexture(-1, /*is_2d_render*/true);
|
||||
irr_driver->removeCamera(camera);
|
||||
irr_driver->removeCameraSceneNode(camera);
|
||||
} // createMarkerTexture
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -155,43 +155,94 @@ void RaceGUI::createRegularPolygon(unsigned int n, float radius,
|
||||
}
|
||||
} // createRegularPolygon
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Adds a camera. The number of cameras determines e.g. if split screen is
|
||||
* used.
|
||||
*/
|
||||
Camera *RaceGUI::addCamera(unsigned int index, Kart *kart)
|
||||
{
|
||||
Camera *camera = new Camera(index, kart);
|
||||
m_cameras.push_back(camera);
|
||||
return camera;
|
||||
} // addCamera
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called before rendering, so no direct output to the screen can be done
|
||||
* here.
|
||||
* \param dt Time step size.
|
||||
/** Render all global parts of the race gui, i.e. things that are only
|
||||
* displayed once even in splitscreen.
|
||||
* \param dt Timestep sized.
|
||||
*/
|
||||
void RaceGUI::update(float dt)
|
||||
void RaceGUI::renderGlobal(float dt)
|
||||
{
|
||||
std::vector<Camera*>::iterator i;
|
||||
for(i=m_cameras.begin(); i!=m_cameras.end(); i++)
|
||||
(*i)->update(dt);
|
||||
cleanupMessages(dt);
|
||||
} // update
|
||||
|
||||
assert(RaceManager::getWorld() != NULL);
|
||||
if(RaceManager::getWorld()->getPhase() >= READY_PHASE &&
|
||||
RaceManager::getWorld()->getPhase() <= GO_PHASE )
|
||||
{
|
||||
drawGlobalReadySetGo();
|
||||
}
|
||||
|
||||
// The penalty message needs to be displayed for up to one second
|
||||
// after the start of the race, otherwise it disappears if
|
||||
// "Go" is displayed and the race starts
|
||||
if(RaceManager::getWorld()->isStartPhase() ||
|
||||
RaceManager::getWorld()->getTime()<1.0f)
|
||||
{
|
||||
displayPenaltyMessages();
|
||||
}
|
||||
// Timer etc. are not displayed unless the game is actually started.
|
||||
if(!RaceManager::getWorld()->isRacePhase()) return;
|
||||
|
||||
drawGlobalTimer();
|
||||
if(RaceManager::getWorld()->getPhase() == GO_PHASE ||
|
||||
RaceManager::getWorld()->getPhase() == MUSIC_PHASE)
|
||||
{
|
||||
drawGlobalMusicDescription();
|
||||
}
|
||||
|
||||
drawGlobalMiniMap();
|
||||
RaceGUI::KartIconDisplayInfo* info = RaceManager::getWorld()->getKartsDisplayInfo();
|
||||
drawGlobalPlayerIcons(info);
|
||||
} // renderGlobal
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Render the race gui. Direct access to the screen is possible here, since
|
||||
* this is called during irrlicht rendering.
|
||||
/** Render the details for a single player, i.e. speed, energy,
|
||||
* collectibles, ...
|
||||
* \param player_id Player id.
|
||||
* \param viewport Viewport to use (already set in the camera).
|
||||
* \param scaling Scaling to use.
|
||||
*/
|
||||
void RaceGUI::render()
|
||||
void RaceGUI::renderPlayerView(unsigned int player_id,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
drawStatusText();
|
||||
} // render
|
||||
if(!RaceManager::getWorld()->isRacePhase()) return;
|
||||
|
||||
RaceGUI::KartIconDisplayInfo* info = RaceManager::getWorld()->getKartsDisplayInfo();
|
||||
|
||||
Kart* player_kart = RaceManager::getWorld()->getLocalPlayerKart(player_id);
|
||||
drawPowerupIcons (player_kart, viewport, scaling);
|
||||
drawEnergyMeter (player_kart, viewport, scaling);
|
||||
drawSpeed (player_kart, viewport, scaling);
|
||||
drawLap (info, player_kart, viewport, scaling);
|
||||
drawAllMessages (player_kart, viewport, scaling);
|
||||
if(player_kart->hasViewBlockedByPlunger())
|
||||
{
|
||||
int offset_x = viewport.UpperLeftCorner.X;
|
||||
int offset_y = viewport.UpperLeftCorner.Y;
|
||||
float split_screen_ratio_x = scaling.X;
|
||||
float split_screen_ratio_y = scaling.Y;
|
||||
|
||||
const int screen_width = viewport.LowerRightCorner.X-viewport.UpperLeftCorner.X;
|
||||
const int plunger_size = viewport.UpperLeftCorner.Y-viewport.LowerRightCorner.Y;
|
||||
int plunger_x = viewport.UpperLeftCorner.X + screen_width/2 - plunger_size/2;
|
||||
|
||||
video::ITexture *t=m_plunger_face->getTexture();
|
||||
core::rect<s32> dest(plunger_x, offset_y,
|
||||
plunger_x+plunger_size, offset_y+plunger_size);
|
||||
const core::rect<s32> source(core::position2d<s32>(0,0), t->getOriginalSize());
|
||||
|
||||
static const video::SColor white = video::SColor(255, 255, 255, 255);
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(t, dest, source, 0,
|
||||
&white, true);
|
||||
}
|
||||
} // renderPlayerView
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Displays the racing time on the screen.s
|
||||
*/
|
||||
void RaceGUI::drawTimer ()
|
||||
void RaceGUI::drawGlobalTimer()
|
||||
{
|
||||
assert(RaceManager::getWorld() != NULL);
|
||||
|
||||
@ -204,12 +255,12 @@ void RaceGUI::drawTimer ()
|
||||
UserConfigParams::m_width, 50);
|
||||
gui::IGUIFont* font = irr_driver->getRaceFont();
|
||||
font->draw(sw.c_str(), pos, time_color);
|
||||
} // drawTimer
|
||||
} // DRAWGLOBALTimer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Draws the mini map and the position of all karts on it.
|
||||
*/
|
||||
void RaceGUI::drawMiniMap()
|
||||
void RaceGUI::drawGlobalMiniMap()
|
||||
{
|
||||
// arenas currently don't have a map.
|
||||
if(RaceManager::getTrack()->isArena()) return;
|
||||
@ -241,11 +292,11 @@ void RaceGUI::drawMiniMap()
|
||||
lower_y -(int)(draw_at.getY()-marker_half_size));
|
||||
irr_driver->getVideoDriver()->draw2DImage(m_marker, position, source, NULL, NULL, true);
|
||||
} // for i<getNumKarts
|
||||
} // drawMap
|
||||
} // drawGlobalMiniMap
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Draw players icons and their times (if defined in the current mode).
|
||||
void RaceGUI::drawPlayerIcons (const KartIconDisplayInfo* info)
|
||||
void RaceGUI::drawGlobalPlayerIcons(const KartIconDisplayInfo* info)
|
||||
{
|
||||
assert(RaceManager::getWorld() != NULL);
|
||||
|
||||
@ -301,12 +352,12 @@ void RaceGUI::drawPlayerIcons (const KartIconDisplayInfo* info)
|
||||
|
||||
} // next kart
|
||||
|
||||
} // drawPlayerIcons
|
||||
} // drawGlobalPlayerIcons
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceGUI::drawPowerupIcons(Kart* player_kart, int offset_x,
|
||||
int offset_y, float ratio_x,
|
||||
float ratio_y )
|
||||
void RaceGUI::drawPowerupIcons(Kart* player_kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
// If player doesn't have anything, do nothing.
|
||||
Powerup* powerup=player_kart->getPowerup();
|
||||
@ -315,18 +366,18 @@ void RaceGUI::drawPowerupIcons(Kart* player_kart, int offset_x,
|
||||
if(n<1) return; // shouldn't happen, but just in case
|
||||
if(n>5) n=5; // Display at most 5 items
|
||||
|
||||
// Originally the hardcoded sizes were 320-32 and 400
|
||||
int x1 = (int)((UserConfigParams::m_width/2-32) * ratio_x) + offset_x;
|
||||
int y1 = (int)(20 * ratio_y) + offset_y;
|
||||
|
||||
int nSize=(int)(64.0f*std::min(ratio_x, ratio_y));
|
||||
int nSize=(int)(64.0f*std::min(scaling.X, scaling.Y));
|
||||
int x1 = (int)((UserConfigParams::m_width/2-32) * scaling.X)
|
||||
+ viewport.UpperLeftCorner.X;
|
||||
int y1 = UserConfigParams::m_height - viewport.LowerRightCorner.Y
|
||||
+ (int)(20 * scaling.Y)+nSize;
|
||||
|
||||
video::ITexture *t=powerup->getIcon()->getTexture();
|
||||
core::rect<s32> rect(core::position2di(0, 0), t->getOriginalSize());
|
||||
|
||||
for ( int i = 0 ; i < n ; i++ )
|
||||
{
|
||||
core::rect<s32> pos(x1+i*30, y1, x1+i*30+nSize, y1+nSize);
|
||||
core::rect<s32> pos(x1+i*30, y1-nSize, x1+i*30+nSize, y1);
|
||||
irr_driver->getVideoDriver()->draw2DImage(t, pos, rect, NULL,
|
||||
NULL, true);
|
||||
} // for i
|
||||
@ -334,14 +385,16 @@ void RaceGUI::drawPowerupIcons(Kart* player_kart, int offset_x,
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/* Energy meter that gets filled with coins */
|
||||
void RaceGUI::drawEnergyMeter ( Kart *player_kart, int offset_x, int offset_y,
|
||||
float ratio_x, float ratio_y )
|
||||
void RaceGUI::drawEnergyMeter (Kart *player_kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
float state = (float)(player_kart->getEnergy()) / MAX_ITEMS_COLLECTED;
|
||||
int x = (int)((UserConfigParams::m_width-24) * ratio_x) + offset_x;
|
||||
int y = (int)(250 * ratio_y) + offset_y;
|
||||
int w = (int)(16 * ratio_x);
|
||||
int h = (int)(UserConfigParams::m_height/4 * ratio_y);
|
||||
int x = (int)((UserConfigParams::m_width-24) * scaling.X) + viewport.UpperLeftCorner.X;
|
||||
//int y = (int)(250 * scaling.Y) + viewport.UpperLeftCorner.Y;
|
||||
int y = UserConfigParams::m_height - (int)(250 * scaling.Y) - viewport.UpperLeftCorner.Y;
|
||||
int w = (int)(16 * scaling.X);
|
||||
int h = (int)(UserConfigParams::m_height/4 * scaling.Y);
|
||||
float coin_target = (float)race_manager->getCoinTarget();
|
||||
int th = (int)(h*(coin_target/MAX_ITEMS_COLLECTED));
|
||||
|
||||
@ -393,22 +446,25 @@ void RaceGUI::drawEnergyMeter ( Kart *player_kart, int offset_x, int offset_y,
|
||||
} // drawEnergyMeter
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
||||
float ratio_x, float ratio_y )
|
||||
void RaceGUI::drawSpeed(Kart* kart, const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
|
||||
float minRatio = std::min(ratio_x, ratio_y);
|
||||
const int SPEEDWIDTH = 128;
|
||||
int meter_width = (int)(SPEEDWIDTH*minRatio);
|
||||
int meter_height = (int)(SPEEDWIDTH*minRatio);
|
||||
offset_x += (int)((UserConfigParams::m_width-10)*ratio_x) - meter_width;
|
||||
offset_y += (int)(10*ratio_y);
|
||||
float minRatio = std::min(scaling.X, scaling.Y);
|
||||
const int SPEEDWIDTH = 128;
|
||||
int meter_width = (int)(SPEEDWIDTH*minRatio);
|
||||
int meter_height = (int)(SPEEDWIDTH*minRatio);
|
||||
core::vector2di offset = viewport.UpperLeftCorner;
|
||||
offset.X += (int)((UserConfigParams::m_width-10)*scaling.X) - meter_width;
|
||||
offset.Y += (int)(10*scaling.Y);
|
||||
|
||||
// First draw the meter (i.e. the background which contains the numbers etc.
|
||||
// -------------------------------------------------------------------------
|
||||
video::IVideoDriver *video = irr_driver->getVideoDriver();
|
||||
const core::rect<s32> meter_pos(offset_x, UserConfigParams::m_height-offset_y-meter_height,
|
||||
offset_x+meter_width, UserConfigParams::m_height-offset_y);
|
||||
const core::rect<s32> meter_pos(offset.X,
|
||||
UserConfigParams::m_height-offset.Y-meter_height,
|
||||
offset.X+meter_width,
|
||||
UserConfigParams::m_height-offset.Y);
|
||||
video::ITexture *meter_texture = m_speed_meter_icon->getTexture();
|
||||
const core::rect<s32> meter_texture_coords(core::position2d<s32>(0,0),
|
||||
meter_texture->getOriginalSize());
|
||||
@ -419,10 +475,10 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
||||
if ( !kart->isOnGround() )
|
||||
{
|
||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
||||
core::rect<s32> pos(offset_x-(int)(30*minRatio),
|
||||
UserConfigParams::m_height-(offset_y-(int)(10*minRatio)),
|
||||
offset_x-(int)(30*minRatio),
|
||||
UserConfigParams::m_height-(offset_y-(int)(10*minRatio)) );
|
||||
core::rect<s32> pos(offset.X-(int)(30*minRatio),
|
||||
UserConfigParams::m_height-(offset.Y-(int)(10*minRatio)),
|
||||
offset.X-(int)(30*minRatio),
|
||||
UserConfigParams::m_height-(offset.Y-(int)(10*minRatio)) );
|
||||
irr_driver->getRaceFont()->draw(core::stringw("!").c_str(), pos, color);
|
||||
}
|
||||
|
||||
@ -462,13 +518,13 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
||||
{
|
||||
count = 4;
|
||||
vertices[2].TCoords = core::vector2df(0,0);
|
||||
vertices[2].Pos = core::vector3df((float)offset_x,
|
||||
(float)(UserConfigParams::m_height-offset_y-meter_height),
|
||||
0);
|
||||
vertices[2].Pos = core::vector3df((float)offset.X,
|
||||
(float)(UserConfigParams::m_height-offset.Y-meter_height),
|
||||
0);
|
||||
vertices[3].TCoords = core::vector2df(2*speed_ratio-1.0f, 0);
|
||||
vertices[3].Pos = core::vector3df(offset_x+2*(speed_ratio-0.5f)*meter_width,
|
||||
(float)(UserConfigParams::m_height-offset_y-meter_height),
|
||||
0);
|
||||
vertices[3].Pos = core::vector3df(offset.X+2*(speed_ratio-0.5f)*meter_width,
|
||||
(float)(UserConfigParams::m_height-offset.Y-meter_height),
|
||||
0);
|
||||
}
|
||||
short int index[4];
|
||||
for(unsigned int i=0; i<count; i++)
|
||||
@ -479,6 +535,7 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
||||
video::SMaterial m;
|
||||
m.setTexture(0, m_speed_bar_icon->getTexture());
|
||||
irr_driver->getVideoDriver()->setMaterial(m);
|
||||
#define DOES_NOT_WORK_ATM
|
||||
#ifdef DOES_NOT_WORK_ATM
|
||||
irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, count,
|
||||
index, count-2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN);
|
||||
@ -486,24 +543,28 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
||||
} // drawSpeed
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceGUI::drawLap(const KartIconDisplayInfo* info, Kart* kart, int offset_x,
|
||||
int offset_y, float ratio_x, float ratio_y )
|
||||
void RaceGUI::drawLap(const KartIconDisplayInfo* info, Kart* kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
// Don't display laps in follow the leader mode
|
||||
if(!RaceManager::getWorld()->raceHasLaps()) return;
|
||||
|
||||
const int lap = info[kart->getWorldKartId()].lap;
|
||||
|
||||
if(lap<0) return; // don't display 'lap 0/...', or do nothing if laps are disabled (-1)
|
||||
float minRatio = std::min(ratio_x, ratio_y);
|
||||
offset_x += (int)(120*ratio_x);
|
||||
offset_y += (int)(UserConfigParams::m_height*5/6*minRatio);
|
||||
|
||||
gui::IGUIFont* font = irr_driver->getRaceFont();
|
||||
if(lap<0) return; // don't display 'lap 0/...'
|
||||
float minRatio = std::min(scaling.X, scaling.Y);
|
||||
core::recti pos;
|
||||
pos.UpperLeftCorner.X = viewport.UpperLeftCorner.X
|
||||
+ (int)(0.15f*UserConfigParams::m_width*scaling.X);
|
||||
pos.UpperLeftCorner.Y = UserConfigParams::m_height - viewport.LowerRightCorner.Y;
|
||||
//pos.UpperLeftCorner.Y += (int)(UserConfigParams::m_height*5/6*minRatio);
|
||||
pos.UpperLeftCorner.Y += (int)(40*minRatio);
|
||||
pos.LowerRightCorner = pos.UpperLeftCorner;
|
||||
gui::IGUIFont* font = irr_driver->getRaceFont();
|
||||
if(kart->hasFinishedRace())
|
||||
{
|
||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
||||
core::rect<s32> pos(offset_x, offset_y, offset_x, offset_y);
|
||||
//I18N: Shown at the end of a race
|
||||
core::stringw s=_("Finished");
|
||||
font->draw(s.c_str(), pos, color);
|
||||
@ -511,14 +572,13 @@ void RaceGUI::drawLap(const KartIconDisplayInfo* info, Kart* kart, int offset_x,
|
||||
else
|
||||
{
|
||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
||||
core::rect<s32> pos(offset_x, offset_y, offset_x, offset_y);
|
||||
core::stringw s = _("Lap");
|
||||
font->draw(core::stringw(_("Lap")).c_str(), pos, color);
|
||||
|
||||
char str[256];
|
||||
sprintf(str, "%d/%d", lap+1, race_manager->getNumLaps());
|
||||
pos.UpperLeftCorner.Y += (int)(40*ratio_y);
|
||||
pos.LowerRightCorner.Y += (int)(40*ratio_y);
|
||||
pos.UpperLeftCorner.Y += (int)(40*scaling.Y);
|
||||
pos.LowerRightCorner.Y += (int)(40*scaling.Y);
|
||||
font->draw(core::stringw(str).c_str(), pos, color);
|
||||
}
|
||||
} // drawLap
|
||||
@ -548,13 +608,14 @@ void RaceGUI::cleanupMessages(const float dt)
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Displays all messages in the message queue
|
||||
**/
|
||||
void RaceGUI::drawAllMessages(Kart* player_kart, int offset_x, int offset_y,
|
||||
float ratio_x, float ratio_y )
|
||||
void RaceGUI::drawAllMessages(Kart* player_kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
int y;
|
||||
// First line of text somewhat under the top of the screen. For now
|
||||
// start just under the timer display
|
||||
y = (int)(ratio_y*164+offset_y);
|
||||
y = (int)(scaling.Y*164+viewport.UpperLeftCorner.Y);
|
||||
// The message are displayed in reverse order, so that a multi-line
|
||||
// message (addMessage("1", ...); addMessage("2",...) is displayed
|
||||
// in the right order: "1" on top of "2"
|
||||
@ -578,7 +639,7 @@ void RaceGUI::drawAllMessages(Kart* player_kart, int offset_x, int offset_y,
|
||||
* certain amount of time (unless time<0, then the message is displayed
|
||||
* once).
|
||||
**/
|
||||
void RaceGUI::addMessage(const irr::core::stringw &msg, const Kart *kart, float time,
|
||||
void RaceGUI::addMessage(const core::stringw &msg, const Kart *kart, float time,
|
||||
int font_size, const video::SColor &color)
|
||||
{
|
||||
m_messages.push_back(TimedMessage(msg, kart, time, font_size, color));
|
||||
@ -587,7 +648,7 @@ void RaceGUI::addMessage(const irr::core::stringw &msg, const Kart *kart, float
|
||||
//-----------------------------------------------------------------------------
|
||||
// Displays the description given for the music currently being played -
|
||||
// usually the title and composer.
|
||||
void RaceGUI::drawMusicDescription()
|
||||
void RaceGUI::drawGlobalMusicDescription()
|
||||
{
|
||||
if (!UserConfigParams::m_music) return; // show no music description when it's off
|
||||
|
||||
@ -659,10 +720,12 @@ void RaceGUI::drawMusicDescription()
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(t, dest, source, NULL, NULL, true);
|
||||
|
||||
} // drawMusicDescription
|
||||
} // drawGlobalMusicDescription
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceGUI::drawStatusText()
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Draws the ready-set-go message on the screen.
|
||||
*/
|
||||
void RaceGUI::drawGlobalReadySetGo()
|
||||
{
|
||||
assert(RaceManager::getWorld() != NULL);
|
||||
switch (RaceManager::getWorld()->getPhase())
|
||||
@ -703,14 +766,11 @@ void RaceGUI::drawStatusText()
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
} // drawGlobalReadySetGo
|
||||
|
||||
float split_screen_ratio_x, split_screen_ratio_y;
|
||||
split_screen_ratio_x = split_screen_ratio_y = 1.0;
|
||||
if(race_manager->getNumLocalPlayers() >= 2)
|
||||
split_screen_ratio_y = 0.5;
|
||||
if(race_manager->getNumLocalPlayers() >= 3)
|
||||
split_screen_ratio_x = 0.5;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void RaceGUI::displayPenaltyMessages()
|
||||
{
|
||||
// The penalty message needs to be displayed for up to one second
|
||||
// after the start of the race, otherwise it disappears if
|
||||
// "Go" is displayed and the race starts
|
||||
@ -731,88 +791,4 @@ void RaceGUI::drawStatusText()
|
||||
} // if penalty
|
||||
} // for i < getNum_players
|
||||
} // if not RACE_PHASE
|
||||
|
||||
|
||||
if(!RaceManager::getWorld()->isRacePhase()) return;
|
||||
|
||||
|
||||
RaceGUI::KartIconDisplayInfo* info = RaceManager::getWorld()->getKartsDisplayInfo();
|
||||
|
||||
for(unsigned int pla = 0; pla < num_players; pla++)
|
||||
{
|
||||
int offset_x = 0;
|
||||
int offset_y = 0;
|
||||
|
||||
if(num_players == 2)
|
||||
{
|
||||
if(pla == 0) offset_y = UserConfigParams::m_height/2;
|
||||
}
|
||||
else if (num_players == 3)
|
||||
{
|
||||
if (pla == 0 || pla == 1)
|
||||
offset_y = UserConfigParams::m_height/2;
|
||||
else
|
||||
{
|
||||
// Fixes width for player 3
|
||||
split_screen_ratio_x = 1.0;
|
||||
}
|
||||
|
||||
if (pla == 1)
|
||||
offset_x = UserConfigParams::m_width/2;
|
||||
|
||||
}
|
||||
else if(num_players == 4)
|
||||
{
|
||||
if(pla == 0 || pla == 1)
|
||||
offset_y = UserConfigParams::m_height/2;
|
||||
|
||||
if((pla == 1) || pla == 3)
|
||||
offset_x = UserConfigParams::m_width/2;
|
||||
}
|
||||
|
||||
Kart* player_kart = RaceManager::getWorld()->getLocalPlayerKart(pla);
|
||||
drawPowerupIcons(player_kart, offset_x, offset_y,
|
||||
split_screen_ratio_x, split_screen_ratio_y );
|
||||
drawEnergyMeter (player_kart, offset_x, offset_y,
|
||||
split_screen_ratio_x, split_screen_ratio_y );
|
||||
drawSpeed (player_kart, offset_x, offset_y,
|
||||
split_screen_ratio_x, split_screen_ratio_y );
|
||||
drawLap (info, player_kart, offset_x, offset_y,
|
||||
split_screen_ratio_x, split_screen_ratio_y );
|
||||
drawAllMessages (player_kart, offset_x, offset_y,
|
||||
split_screen_ratio_x, split_screen_ratio_y );
|
||||
|
||||
if(player_kart->hasViewBlockedByPlunger())
|
||||
{
|
||||
const int screen_width = (num_players > 2) ? UserConfigParams::m_width/2 : UserConfigParams::m_width;
|
||||
const int plunger_size = (num_players > 1) ? UserConfigParams::m_height/2 : UserConfigParams::m_height;
|
||||
int plunger_x = offset_x + screen_width/2 - plunger_size/2;
|
||||
|
||||
if (num_players == 3 && pla > 1)
|
||||
plunger_x = offset_x + UserConfigParams::m_width/2 - plunger_size/2;
|
||||
|
||||
video::ITexture *t=m_plunger_face->getTexture();
|
||||
core::rect<s32> dest(plunger_x, offset_y,
|
||||
plunger_x+plunger_size, offset_y+plunger_size);
|
||||
const core::rect<s32> source(core::position2d<s32>(0,0), t->getOriginalSize());
|
||||
|
||||
static const video::SColor white = video::SColor(255, 255, 255, 255);
|
||||
|
||||
irr_driver->getVideoDriver()->draw2DImage(t, dest, source, 0,
|
||||
&white,
|
||||
true);
|
||||
}
|
||||
} // next player
|
||||
|
||||
drawTimer();
|
||||
|
||||
if(RaceManager::getWorld()->getPhase() == GO_PHASE ||
|
||||
RaceManager::getWorld()->getPhase() == MUSIC_PHASE)
|
||||
{
|
||||
drawMusicDescription();
|
||||
}
|
||||
|
||||
drawMiniMap();
|
||||
drawPlayerIcons(info);
|
||||
|
||||
} // drawStatusText
|
||||
} // displayPenaltyMessage
|
||||
|
@ -30,7 +30,6 @@ using namespace irr;
|
||||
|
||||
#include "config/player.hpp"
|
||||
|
||||
class Camera;
|
||||
class InputMap;
|
||||
class Kart;
|
||||
class Material;
|
||||
@ -130,43 +129,43 @@ private:
|
||||
/** Distance of map from bottom of screen. */
|
||||
int m_map_bottom;
|
||||
|
||||
/** The list of all cameras. */
|
||||
std::vector<Camera*> m_cameras;
|
||||
|
||||
void createMarkerTexture();
|
||||
void createRegularPolygon(unsigned int n, float radius,
|
||||
const core::vector2df ¢er,
|
||||
const video::SColor &color,
|
||||
video::S3DVertex *v, unsigned short int *index);
|
||||
|
||||
/* Display informat on screen */
|
||||
void drawStatusText ();
|
||||
/* Display informat for one player on the screen. */
|
||||
void drawEnergyMeter (Kart *player_kart,
|
||||
int offset_x, int offset_y,
|
||||
float ratio_x, float ratio_y );
|
||||
void drawPowerupIcons (Kart* player_kart,
|
||||
int offset_x, int offset_y,
|
||||
float ratio_x, float ratio_y );
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawPowerupIcons (Kart* player_kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawAllMessages (Kart* player_kart,
|
||||
int offset_x, int offset_y,
|
||||
float ratio_x, float ratio_y );
|
||||
void drawPlayerIcons (const KartIconDisplayInfo* info);
|
||||
void oldDrawPlayerIcons ();
|
||||
void drawMiniMap ();
|
||||
void drawTimer ();
|
||||
void drawMusicDescription ();
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawSpeed (Kart* kart, const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawLap (const KartIconDisplayInfo* info, Kart* kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
void drawGlobalPlayerIcons (const KartIconDisplayInfo* info);
|
||||
/** Display items that are shown once only (for all karts). */
|
||||
void drawGlobalMiniMap ();
|
||||
void drawGlobalTimer ();
|
||||
void drawGlobalMusicDescription();
|
||||
void cleanupMessages (const float dt);
|
||||
void drawSpeed (Kart* kart, int offset_x, int offset_y,
|
||||
float ratio_x, float ratio_y );
|
||||
void drawLap (const KartIconDisplayInfo* info, Kart* kart, int offset_x,
|
||||
int offset_y, float ratio_x, float ratio_y );
|
||||
void drawGlobalReadySetGo ();
|
||||
void displayPenaltyMessages();
|
||||
public:
|
||||
|
||||
RaceGUI();
|
||||
~RaceGUI();
|
||||
void render();
|
||||
void update(float dt);
|
||||
Camera *addCamera(unsigned int index, Kart *kart);
|
||||
void renderGlobal(float dt);
|
||||
void renderPlayerView(unsigned int player_id, const core::recti &viewport,
|
||||
const core::vector2df &scaling);
|
||||
|
||||
void addMessage(const irr::core::stringw &m, const Kart *kart, float time,
|
||||
int fonst_size,
|
||||
const video::SColor &color=video::SColor(255, 255, 0, 255));
|
||||
|
@ -489,7 +489,7 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2di &dimension,
|
||||
|
||||
// Add the camera:
|
||||
// ---------------
|
||||
scene::ICameraSceneNode *camera = irr_driver->addCamera();
|
||||
scene::ICameraSceneNode *camera = irr_driver->addCameraSceneNode();
|
||||
Vec3 bb_min, bb_max;
|
||||
m_all_quads->getBoundingBox(&bb_min, &bb_max);
|
||||
Vec3 center = (bb_max+bb_min)*0.5f;
|
||||
@ -505,7 +505,7 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2di &dimension,
|
||||
video::ITexture *texture = rttProvider.renderToTexture();
|
||||
|
||||
cleanupDebugMesh();
|
||||
irr_driver->removeCamera(camera);
|
||||
irr_driver->removeCameraSceneNode(camera);
|
||||
m_min_coord = bb_min;
|
||||
m_scaling.setX(dimension.Width/(bb_max.getX()-bb_min.getX()));
|
||||
m_scaling.setY(dimension.Width/(bb_max.getY()-bb_min.getY()));
|
||||
|
@ -50,6 +50,7 @@ using namespace irr;
|
||||
#include "tracks/check_manager.hpp"
|
||||
#include "tracks/quad_graph.hpp"
|
||||
#include "tracks/quad_set.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
|
@ -37,16 +37,6 @@
|
||||
|
||||
#define KILOMETERS_PER_HOUR (KILOMETER/HOUR)
|
||||
|
||||
// Zipper related constants:
|
||||
// =========================
|
||||
#define ZIPPER_ANGLE 45.0
|
||||
#define ZIPPER_TIME 1.0f /* Seconds */
|
||||
#define ZIPPER_VELOCITY (100.0f * KILOMETERS_PER_HOUR )
|
||||
|
||||
// Traffic (not used at this time)
|
||||
// ===============================
|
||||
#define TRAFFIC_VELOCITY ( 20.0f * KILOMETERS_PER_HOUR )
|
||||
|
||||
/* M$ compilers don't define M_PI... */
|
||||
|
||||
#ifndef M_PI
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include "LinearMath/btTransform.h"
|
||||
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
/** A class that stores a translation and rotation. It is used to convert
|
||||
@ -37,19 +36,6 @@ private:
|
||||
/** Rotation as Eulerian HPR value. */
|
||||
Vec3 m_hpr;
|
||||
|
||||
//sgCoord m_coord;
|
||||
|
||||
/** Sets the sgCoord data structures (and converts radians to degrees). */
|
||||
/*
|
||||
void setSgCoord()
|
||||
{
|
||||
sgSetCoord(&m_coord, m_xyz.toFloat(), m_hpr.toFloat());
|
||||
// Convert hpr in radians to degrees, which sg needs.
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
m_coord.hpr[i] = RAD_TO_DEGREE(m_coord.hpr[i]);
|
||||
}
|
||||
}*/
|
||||
|
||||
public:
|
||||
/** Constructor.
|
||||
|
Loading…
x
Reference in New Issue
Block a user