Allow to move the attached camera to all AI karts in profile mode
(press keys '1' to '9' to move the camera to kart 0 - 8). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9963 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
|
||||
AlignedArray<Camera::EndCameraInformation> Camera::m_end_cameras;
|
||||
|
||||
Camera::Camera(int camera_index, const Kart* kart)
|
||||
Camera::Camera(int camera_index, Kart* kart)
|
||||
{
|
||||
m_mode = CM_NORMAL;
|
||||
m_index = camera_index;
|
||||
@@ -83,6 +83,17 @@ Camera::~Camera()
|
||||
irr_driver->removeCameraSceneNode(m_camera);
|
||||
} // ~Camera
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Changes the owner of this camera to the new kart.
|
||||
* \param new_kart The new kart to use this camera.
|
||||
*/
|
||||
void Camera::changeOwner(Kart *new_kart)
|
||||
{
|
||||
m_kart->setCamera(NULL);
|
||||
m_kart = new_kart;
|
||||
new_kart->setCamera(this);
|
||||
} // changeOwner
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** This function clears all end camera data structure. This is necessary
|
||||
* since all end cameras are shared between all camera instances (i.e. are
|
||||
|
||||
@@ -88,8 +88,9 @@ private:
|
||||
/** Factor of the effects of steering in camera aim. */
|
||||
float m_rotation_range;
|
||||
|
||||
/** The kart that the camera follows. */
|
||||
const Kart *m_kart;
|
||||
/** The kart that the camera follows. It can't be const,
|
||||
* since in profile mode the camera might change its owner. */
|
||||
Kart *m_kart;
|
||||
|
||||
/** The list of viewports for this cameras. */
|
||||
core::recti m_viewport;
|
||||
@@ -167,6 +168,7 @@ private:
|
||||
bool isReached(const Vec3 &xyz)
|
||||
{ return (xyz-m_position).length2() < m_distance2; }
|
||||
}; // EndCameraInformation
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** List of all end camera information. This information is shared
|
||||
* between all cameras, so it's static. */
|
||||
@@ -190,7 +192,7 @@ private:
|
||||
void positionCamera(float dt, float above_kart, float cam_angle,
|
||||
float side_way, float distance, float smoothing);
|
||||
public:
|
||||
Camera (int camera_index, const Kart* kart);
|
||||
Camera (int camera_index, Kart* kart);
|
||||
~Camera ();
|
||||
static void readEndCamera(const XMLNode &root);
|
||||
static void clearEndCameras();
|
||||
@@ -202,24 +204,27 @@ public:
|
||||
void setInitialTransform();
|
||||
void activate();
|
||||
void update (float dt);
|
||||
void changeOwner (Kart *new_kart);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the ambient light for this camera. */
|
||||
void setAmbientLight(const video::SColor &color) { m_ambient_light=color; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current ambient light. */
|
||||
const video::SColor &getAmbientLight() const {return m_ambient_light; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the viewport of this camera. */
|
||||
const core::recti& getViewport() const {return m_viewport; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the scaling in x/y direction for this camera. */
|
||||
const core::vector2df& getScaling() const {return m_scaling; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the camera scene node. */
|
||||
scene::ICameraSceneNode *getCameraSceneNode()
|
||||
{
|
||||
return m_camera;
|
||||
}
|
||||
scene::ICameraSceneNode *getCameraSceneNode() { return m_camera; }
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "modes/profile_world.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "race/history.hpp"
|
||||
#include "states_screens/kart_selection.hpp"
|
||||
@@ -88,6 +89,34 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
|
||||
switch (key)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
// Special debug options for profile mode: switch the
|
||||
// camera to show a different kart.
|
||||
case KEY_KEY_1:
|
||||
case KEY_KEY_2:
|
||||
case KEY_KEY_3:
|
||||
case KEY_KEY_4:
|
||||
case KEY_KEY_5:
|
||||
case KEY_KEY_6:
|
||||
case KEY_KEY_7:
|
||||
case KEY_KEY_8:
|
||||
case KEY_KEY_9:
|
||||
{
|
||||
if(!ProfileWorld::isProfileMode()) break;
|
||||
int kart_id = key - KEY_KEY_1;
|
||||
if(kart_id<0 || kart_id>=(int)world->getNumKarts()) break;
|
||||
for(unsigned int i=0; i<world->getNumKarts(); i++)
|
||||
{
|
||||
if(world->getKart(i)->getCamera())
|
||||
{
|
||||
world->getKart(i)->getCamera()
|
||||
->changeOwner(world->getKart(kart_id));
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case KEY_CONTROL:
|
||||
case KEY_RCONTROL:
|
||||
case KEY_LCONTROL:
|
||||
|
||||
Reference in New Issue
Block a user