864c1d6fff
graph related functions from Track to QuadGraph, removed plib usage. The AI is now able to drive a loop (re-using the same quad, before continuing on the original path). The beack track currently defines a simple look at the first right hand turn (the AI will drive down the hill, then up again and then keep on going). 2) During the conversion process some AI called function were significanly sped up, but it has to be tested if this has any ill effects for certain tracks or certain karts. 3) Tried to add support for moving sky domes, but that doesn't work yet. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3527 178a84e3-b1eb-0310-8ba1-8eac791a3b58
80 lines
2.5 KiB
C++
80 lines
2.5 KiB
C++
// $Id: moving_texture.cpp 796 2006-09-27 07:06:34Z hiker $
|
|
//
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
// Copyright (C) 2006 Joerg Henrichs
|
|
//
|
|
// 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/moving_texture.hpp"
|
|
#include "io/xml_node.hpp"
|
|
|
|
/** Constructor for an animated texture.
|
|
* \param matrix The texture matrix to modify.
|
|
* \param node An XML node containing dx and dy attributes to set the
|
|
* speed of the animation.
|
|
*/
|
|
MovingTexture::MovingTexture(core::matrix4 *matrix, const XMLNode &node)
|
|
: m_matrix(matrix)
|
|
{
|
|
m_dx = 0.0f;
|
|
m_dy = 0.0f;
|
|
core::vector3df v = m_matrix->getTranslation();
|
|
m_x = v.X;
|
|
m_y = v.Y;
|
|
|
|
node.get("dx", &m_dx);
|
|
node.get("dy", &m_dy);
|
|
} // MovingTexture
|
|
|
|
//-----------------------------------------------------------------------------
|
|
/** Constructor for an animated texture, specifying the speed of the animation
|
|
* directly.
|
|
* \param matrix The texture matrix to modify.
|
|
* \param dx Speed of the animation in X direction.
|
|
* \param dy Speed of the animation in Y direction.
|
|
*/
|
|
MovingTexture::MovingTexture(core::matrix4 *matrix, float dx, float dy)
|
|
: m_matrix(matrix)
|
|
{
|
|
m_dx = dx;
|
|
m_dy = dy;
|
|
core::vector3df v = m_matrix->getTranslation();
|
|
m_x = v.X;
|
|
m_y = v.Y;
|
|
} // Moving Texture
|
|
|
|
//-----------------------------------------------------------------------------
|
|
/** Destructor for an animated texture.
|
|
*/
|
|
MovingTexture::~MovingTexture()
|
|
{
|
|
} // ~MovingTexture
|
|
|
|
//-----------------------------------------------------------------------------
|
|
/** Updates the transform of an animated texture.
|
|
* \param dt Time step size.
|
|
*/
|
|
void MovingTexture::update(float dt)
|
|
{
|
|
m_x = m_x + dt*m_dx;
|
|
m_y = m_y + dt*m_dy;
|
|
if(m_x>1.0f) m_x = fmod(m_x, 1.0f);
|
|
if(m_y>1.0f) m_y = fmod(m_y, 1.0f);
|
|
|
|
m_matrix->setTextureTranslate(m_x, m_y);
|
|
} // update
|
|
|
|
|