Scale bubble gum shield when karts are too large; loosely based uponpatch by deveee

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14309 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2013-10-25 22:57:46 +00:00
parent ee54d158c2
commit c04396e1c1
6 changed files with 22 additions and 4 deletions

View File

@@ -53,7 +53,9 @@ Attachment::Attachment(AbstractKart* kart)
m_bomb_sound = NULL;
m_bubble_explode_sound = NULL;
m_node_scale = 1.0f;
m_wanted_node_scale = std::max(1.0f, kart->getHighestPoint()*1.1f);
// If we attach a NULL mesh, we get a NULL scene node back. So we
// have to attach some kind of mesh, but make it invisible.
m_node = irr_driver->addAnimatedMesh(
@@ -387,10 +389,10 @@ void Attachment::update(float dt)
if(m_type==ATTACH_NOTHING) return;
m_time_left -=dt;
if (m_node_scale < 1.0f)
if (m_node_scale < m_wanted_node_scale)
{
m_node_scale += dt*1.5f;
if (m_node_scale > 1.0f) m_node_scale = 1.0f;
if (m_node_scale > m_wanted_node_scale) m_node_scale = m_wanted_node_scale;
m_node->setScale(core::vector3df(m_node_scale,m_node_scale,m_node_scale));
}

View File

@@ -80,6 +80,9 @@ private:
/** For zoom-in animation */
float m_node_scale;
/** Scale for bubblegum shield */
float m_wanted_node_scale;
/** Scene node of the attachment, which will be attached to the kart's
* scene node. */
scene::IAnimatedMeshSceneNode

View File

@@ -53,6 +53,7 @@ AbstractKart::AbstractKart(const std::string& ident,
m_kart_width = m_kart_model->getWidth();
m_kart_height = m_kart_model->getHeight();
m_kart_length = m_kart_model->getLength();
m_kart_highest_point = m_kart_model->getHighestPoint();
m_wheel_graphics_position = m_kart_model->getWheelsGraphicsPosition();
m_nitro_emitter_position = m_kart_model->getNitroEmittersPositon();
m_has_nitro_emitter = m_kart_model->hasNitroEmitters();

View File

@@ -51,6 +51,8 @@ private:
float m_kart_width;
/** Height of the kart, copy of the data from KartModel. */
float m_kart_height;
/** Coordinate on up axis */
float m_kart_highest_point;
/** The position of all four wheels in the 3d model */
const Vec3* m_wheel_graphics_position;
/** The position of all nitro emitters in the 3d model */
@@ -150,6 +152,9 @@ public:
// ------------------------------------------------------------------------
/** Returns the width of the kart. */
float getKartWidth() const {return m_kart_width; }
// ------------------------------------------------------------------------
/** Returns the highest point of the kart (coordinate on up axis) */
float getHighestPoint() const { return m_kart_highest_point; }
// ------------------------------------------------------------------------
/** Returns true if this kart has no wheels. */
bool isWheeless() const;

View File

@@ -249,6 +249,7 @@ KartModel* KartModel::makeCopy()
km->m_kart_width = m_kart_width;
km->m_kart_length = m_kart_length;
km->m_kart_height = m_kart_height;
km->m_kart_highest_point = m_kart_highest_point;
km->m_mesh = m_mesh;
km->m_model_filename = m_model_filename;
km->m_animation_speed = m_animation_speed;
@@ -421,6 +422,8 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
Vec3 kart_min, kart_max;
MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), &kart_min, &kart_max);
m_kart_highest_point = kart_max.getY();
// Load the speed weighted object models. We need to do that now because it can affect the dimensions of the kart
for(size_t i=0 ; i < m_speed_weighted_objects.size() ; i++)
{
@@ -435,7 +438,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
// Update min/max
Vec3 obj_min, obj_max;
MeshTools::minMax3D(obj.m_model, &obj_min, &obj_max);
MeshTools::minMax3D(obj.m_model, &obj_min, &obj_max);
obj_min += obj.m_position;
obj_max += obj.m_position;
kart_min.min(obj_min);

View File

@@ -166,6 +166,7 @@ private:
float m_kart_width; /**< Width of kart. */
float m_kart_length; /**< Length of kart. */
float m_kart_height; /**< Height of kart. */
float m_kart_highest_point; /**< Coordinate on up axis */
/** True if this is the master copy, managed by KartProperties. This
* is mainly used for debugging, e.g. the master copies might not have
* anything attached to it etc. */
@@ -263,6 +264,9 @@ public:
// ------------------------------------------------------------------------
/** Returns the height of the kart. */
float getHeight () const {return m_kart_height; }
// ------------------------------------------------------------------------
/** Coordoinate on up axis */
float getHighestPoint () const { return m_kart_highest_point; }
// ------------------------------------------------------------------------
/** Enables- or disables the end animation. */
void setAnimation(AnimationFrameType type);