Make the graphical y offset configurable (and basically disable

it for now by setting it to 0).
This commit is contained in:
hiker 2014-08-21 17:28:06 +10:00
parent 171b442ae6
commit 15cccf9301
7 changed files with 47 additions and 24 deletions

View File

@ -155,12 +155,13 @@
otherwise obstricts too much of the view. -->
<camera distance="1.5" forward-up-angle="15"
backward-up-angle="30"/>
<!-- Additional offset to move graphical chassis with regards to the physics. -->
<graphics y-offset="0.0"/>
<!-- Jump animation related values:
animation-time: only if the estimated time for a jump is larger
than this value will the jump animation being
shown. -->
<jump animation-time="0.5" />
<!-- Jump animation related values:
animation-time: only if the estimated time for a jump is larger
than this value will the jump animation being shown. -->
<jump animation-time="0.5" />
<!-- Skidding: increase: multiplicative increase of skidding factor in each frame.
decrease: multiplicative decrease of skidding factor in each frame.

View File

@ -24,7 +24,8 @@
#include <ISceneNode.h>
Shadow::Shadow(video::ITexture *texture, scene::ISceneNode *node,
float scale = 1.0, float xOffset = 0.0, float yOffset = 0.0)
float scale = 1.0, float x_offset = 0.0, float y_offset = 0.0,
float z_offset = 0.0)
{
video::SMaterial m;
m.setTexture(0, texture);
@ -34,10 +35,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 = -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].Pos.X = -scale+x_offset; v[0].Pos.Z = scale+z_offset; v[0].Pos.Y = 0.01f-y_offset;
v[1].Pos.X = scale+x_offset; v[1].Pos.Z = scale+z_offset; v[1].Pos.Y = 0.01f-y_offset;
v[2].Pos.X = scale+x_offset; v[2].Pos.Z = -scale+z_offset; v[2].Pos.Y = 0.01f-y_offset;
v[3].Pos.X = -scale+x_offset; v[3].Pos.Z = -scale+z_offset; v[3].Pos.Y = 0.01f-y_offset;
v[0].TCoords = core::vector2df(0,0);
v[1].TCoords = core::vector2df(1,0);
v[2].TCoords = core::vector2df(1,1);
@ -50,7 +51,6 @@ Shadow::Shadow(video::ITexture *texture, scene::ISceneNode *node,
buffer->recalculateBoundingBox();
m_node = irr_driver->addMesh(m_mesh);
m_node->setPosition(core::vector3df(0, 0.0f, 0));
#ifdef DEBUG
m_node->setName("shadow");
#endif

View File

@ -46,9 +46,8 @@ private:
/** The scene node of the kart to which this shadow belongs. */
scene::ISceneNode *m_parent_kart_node;
public:
Shadow(video::ITexture *texture,
scene::ISceneNode *node,
float scale, float xOffset, float yOffset);
Shadow(video::ITexture *texture, scene::ISceneNode *node,
float scale, float x_offset, float y_offset,float z_offset);
~Shadow();
void enableShadow();
void disableShadow();

View File

@ -2379,7 +2379,8 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
m_node,
m_kart_properties->getShadowScale(),
m_kart_properties->getShadowXOffset(),
m_kart_properties->getShadowYOffset());
m_kart_properties->getGraphicalYOffset(),
m_kart_properties->getShadowZOffset());
World::getWorld()->kartAdded(this, m_node);
} // loadData
@ -2429,7 +2430,8 @@ void Kart::kartIsInRestNow()
f += wi.m_chassisConnectionPointCS.getY()
- wi.m_raycastInfo.m_suspensionLength - wi.m_wheelsRadius;
}
m_graphical_y_offset = f/m_vehicle->getNumWheels() + 0.0f;
m_graphical_y_offset = f/m_vehicle->getNumWheels()
+ getKartProperties()->getGraphicalYOffset();
m_kart_model->setDefaultSuspension();
} // kartIsInRestNow

View File

@ -540,8 +540,14 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
: -0.5f*m_kart_length);
}
}
for(unsigned int i=0; i<4; i++)
m_wheel_graphics_position[i].setY(m_wheel_graphics_position[i].getY()-0.0f);
float y_off = kart_properties.getGraphicalYOffset();
if(y_off!=0)
{
for (unsigned int i = 0; i < 4; i++)
m_wheel_graphics_position[i].setY(
m_wheel_graphics_position[i].getY() - y_off);
}
// Load the wheel models. This can't be done early, since the default
// values for the graphical position must be defined, which in turn

View File

@ -57,7 +57,7 @@ KartProperties::KartProperties(const std::string &filename)
m_shadow_file = "";
m_shadow_scale = 1.0f;
m_shadow_x_offset = 0.0f;
m_shadow_y_offset = 0.0f;
m_shadow_z_offset = 0.0f;
m_groups.clear();
m_custom_sfx_id.resize(SFXManager::NUM_CUSTOMS);
@ -92,7 +92,8 @@ KartProperties::KartProperties(const std::string &filename)
m_squash_duration = m_downward_impulse_factor =
m_bubblegum_fade_in_time = m_bubblegum_speed_fraction =
m_bubblegum_time = m_bubblegum_torque = m_jump_animation_time =
m_smooth_flying_impulse = m_physical_wheel_position =
m_smooth_flying_impulse = m_physical_wheel_position =
m_graphical_y_offset =
UNDEFINED;
m_engine_power.resize(RaceManager::DIFFICULTY_COUNT, UNDEFINED);
@ -322,7 +323,7 @@ void KartProperties::getAllData(const XMLNode * root)
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 );
root->get("shadow-z-offset", &m_shadow_z_offset );
root->get("type", &m_kart_type );
@ -615,6 +616,11 @@ void KartProperties::getAllData(const XMLNode * root)
startup_node->get("boost", &m_startup_boost);
}
if(const XMLNode *graphics_node = root->getNode("graphics"))
{
graphics_node->get("y-offset", &m_graphical_y_offset);
}
if(m_kart_model)
m_kart_model->loadInfo(*root);
} // getAllData
@ -735,7 +741,7 @@ void KartProperties::checkAllSet(const std::string &filename)
CHECK_NEG(m_explosion_invulnerability_time,
"explosion invulnerability-time");
CHECK_NEG(m_explosion_radius, "explosion radius" );
CHECK_NEG(m_graphical_y_offset, "graphics y-offset" );
for(unsigned int i=RaceManager::DIFFICULTY_FIRST;
i<=RaceManager::DIFFICULTY_LAST; i++)
{

View File

@ -112,7 +112,7 @@ private:
* 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
float m_shadow_z_offset; /**< Z 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
@ -204,6 +204,10 @@ private:
std::string m_wheel_filename[4];
/** Radius of the graphical wheels. */
float m_wheel_graphics_radius[4];
/** An additional Y offset added to the y position of the graphical
* chassis. Useful for karts that don't have enough space for suspension
* compression. */
float m_graphical_y_offset;
/** If the kart is supposed to have random wheel rotation at start. */
bool m_has_rand_wheels;
/** Max. length of plunger rubber band. */
@ -568,6 +572,11 @@ public:
/** Returns wheel radius. */
float getWheelRadius () const {return m_wheel_radius; }
// ------------------------------------------------------------------------
/** Return the additional Y offset added to the y position of the graphical
* chassis. Useful for karts that don't have enough space for suspension
* compression. */
float getGraphicalYOffset() const {return m_graphical_y_offset; }
// ------------------------------------------------------------------------
/** Returns parameters for the speed-weighted objects */
const SpeedWeightedObject::Properties& getSpeedWeightedObjectProperties() const
@ -831,7 +840,7 @@ public:
// ------------------------------------------------------------------------
/** Returns the scale factor by which the shadow plane
* had to be set. */
float getShadowYOffset () const {return m_shadow_y_offset; }
float getShadowZOffset () const {return m_shadow_z_offset; }
// ------------------------------------------------------------------------
/** Returns a pointer to the skidding properties. */