Applied Narann's patch for scaling and moving shadows of karts.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9240 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <ISceneNode.h>
|
||||
|
||||
Shadow::Shadow(video::ITexture *texture, scene::ISceneNode *node)
|
||||
Shadow::Shadow(video::ITexture *texture, scene::ISceneNode *node, float scale = 1.0, float xOffset = 0.0, float yOffset = 0.0)
|
||||
{
|
||||
video::SMaterial m;
|
||||
m.setTexture(0, texture);
|
||||
@@ -33,10 +33,10 @@ Shadow::Shadow(video::ITexture *texture, scene::ISceneNode *node)
|
||||
m_mesh = irr_driver->createQuadMesh(&m, /*create_one_quad*/true);
|
||||
scene::IMeshBuffer *buffer = m_mesh->getMeshBuffer(0);
|
||||
irr::video::S3DVertex* v=(video::S3DVertex*)buffer->getVertices();
|
||||
v[0].Pos.X = -1.0f; v[0].Pos.Z = 1.0f; v[0].Pos.Y = 0.01f;
|
||||
v[1].Pos.X = 1.0f; v[1].Pos.Z = 1.0f; v[1].Pos.Y = 0.01f;
|
||||
v[2].Pos.X = 1.0f; v[2].Pos.Z = -1.0f; v[2].Pos.Y = 0.01f;
|
||||
v[3].Pos.X = -1.0f; v[3].Pos.Z = -1.0f; v[3].Pos.Y = 0.01f;
|
||||
v[0].Pos.X = -scale+xOffset; v[0].Pos.Z = scale+yOffset; v[0].Pos.Y = 0.01f;
|
||||
v[1].Pos.X = scale+xOffset; v[1].Pos.Z = scale+yOffset; v[1].Pos.Y = 0.01f;
|
||||
v[2].Pos.X = scale+xOffset; v[2].Pos.Z = -scale+yOffset; v[2].Pos.Y = 0.01f;
|
||||
v[3].Pos.X = -scale+xOffset; v[3].Pos.Z = -scale+yOffset; v[3].Pos.Y = 0.01f;
|
||||
v[0].TCoords = core::vector2df(0,0);
|
||||
v[1].TCoords = core::vector2df(1,0);
|
||||
v[2].TCoords = core::vector2df(1,1);
|
||||
|
||||
@@ -48,7 +48,8 @@ private:
|
||||
scene::ISceneNode *m_parent_kart_node;
|
||||
public:
|
||||
Shadow(video::ITexture *texture,
|
||||
scene::ISceneNode *node);
|
||||
scene::ISceneNode *node,
|
||||
float scale, float xOffset, float yOffset);
|
||||
~Shadow();
|
||||
void enableShadow();
|
||||
void disableShadow();
|
||||
|
||||
@@ -1807,7 +1807,10 @@ void Kart::loadData(RaceManager::KartType type, bool is_first_kart,
|
||||
}
|
||||
|
||||
m_shadow = new Shadow(m_kart_properties->getShadowTexture(),
|
||||
m_node);
|
||||
m_node,
|
||||
m_kart_properties->getShadowScale(),
|
||||
m_kart_properties->getShadowXOffset(),
|
||||
m_kart_properties->getShadowYOffset());
|
||||
} // loadData
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -50,6 +50,9 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
m_ident = "NONAME";
|
||||
m_icon_file = "";
|
||||
m_shadow_file = "";
|
||||
m_shadow_scale = 1.0f;
|
||||
m_shadow_x_offset = 0.0f;
|
||||
m_shadow_y_offset = 0.0f;
|
||||
|
||||
m_groups.clear();
|
||||
m_custom_sfx_id.resize(SFXManager::NUM_CUSTOMS);
|
||||
@@ -241,6 +244,10 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
|
||||
root->get("random-wheel-rot", &m_has_rand_wheels );
|
||||
|
||||
root->get("shadow-scale", &m_shadow_scale );
|
||||
root->get("shadow-x-offset", &m_shadow_x_offset );
|
||||
root->get("shadow-y-offset", &m_shadow_y_offset );
|
||||
|
||||
if(const XMLNode *dimensions_node = root->getNode("center"))
|
||||
dimensions_node->get("gravity-shift", &m_gravity_center_shift);
|
||||
|
||||
|
||||
@@ -97,6 +97,12 @@ private:
|
||||
* character select screen. */
|
||||
std::string m_shadow_file; /**< Filename of the image file that
|
||||
* contains the shadow for this kart.*/
|
||||
float m_shadow_scale; /**< Scale of the shadow plane
|
||||
* for this kart.*/
|
||||
float m_shadow_x_offset; /**< X offset of the shadow plane
|
||||
* for this kart.*/
|
||||
float m_shadow_y_offset; /**< Y offset of the shadow plane
|
||||
* for this kart.*/
|
||||
video::ITexture *m_shadow_texture;/**< The texture with the shadow. */
|
||||
video::SColor m_color; /**< Color the represents the kart in the
|
||||
* status bar and on the track-view. */
|
||||
@@ -568,7 +574,19 @@ public:
|
||||
/** Returns the maximum factor by which the steering angle
|
||||
* can be increased. */
|
||||
float getMaxSkid () const {return m_skid_max; }
|
||||
|
||||
|
||||
/** Returns the scale factor by which the shadow plane
|
||||
* had to be set. */
|
||||
float getShadowScale () const {return m_shadow_scale; }
|
||||
|
||||
/** Returns the scale factor by which the shadow plane
|
||||
* had to be set. */
|
||||
float getShadowXOffset () const {return m_shadow_x_offset; }
|
||||
|
||||
/** Returns the scale factor by which the shadow plane
|
||||
* had to be set. */
|
||||
float getShadowYOffset () const {return m_shadow_y_offset; }
|
||||
|
||||
/** Returns the factor by which m_skidding is multiplied when the kart is
|
||||
* skidding to increase it to the maximum. */
|
||||
float getSkidIncrease () const {return m_skid_increase; }
|
||||
|
||||
Reference in New Issue
Block a user