Update overworld : challenge orbs now contain the screenshot of the actual challenge they lead to

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10502 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-12-27 21:59:11 +00:00
parent c45e9be77d
commit 3b0a88ae30
3 changed files with 57 additions and 4 deletions

View File

@ -114,7 +114,7 @@ public:
void addDependency(const std::string id) {m_prerequisites.push_back(id);}
const std::vector<std::string>&
getPrerequisites() const {return m_prerequisites; }
getPrerequisites() const { return m_prerequisites; }
/** Returns the id of the challenge. */
const std::string &getId() const { return m_id; }
@ -129,6 +129,9 @@ public:
/** Sets the id of this challenge. */
void setId(const std::string& s) { m_id = s; }
const std::string& getTrackName() const { return m_track_name; }
void addUnlockTrackReward(const std::string &track_name);
void addUnlockModeReward(const std::string &internal_mode_name,
const irr::core::stringw &user_mode_name);

View File

@ -886,7 +886,7 @@ void Material::setMaterialProperties(video::SMaterial *m)
else if (UserConfigParams::m_trilinear)
{
m->setFlag(video::EMF_TRILINEAR_FILTER, true);
}
}
// UV clamping
if ( (m_clamp_tex & UCLAMP) != 0)

View File

@ -26,6 +26,8 @@
using namespace irr;
#include "audio/music_manager.hpp"
#include "challenges/challenge.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/stk_config.hpp"
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
@ -50,6 +52,7 @@ using namespace irr;
#include "tracks/bezier_curve.hpp"
#include "tracks/check_manager.hpp"
#include "tracks/lod_node_loader.hpp"
#include "tracks/track_manager.hpp"
#include "tracks/quad_graph.hpp"
#include "tracks/quad_set.hpp"
#include "tracks/track_object_manager.hpp"
@ -727,6 +730,10 @@ bool Track::loadMainTrack(const XMLNode &root)
core::vector3df scale(1.0f, 1.0f, 1.0f);
n->get("scale", &scale);
// a special challenge orb object for overworld
std::string challenge;
n->get("challenge", &challenge);
lodLoader.check(n);
if (tangent)
@ -769,7 +776,8 @@ bool Track::loadMainTrack(const XMLNode &root)
}
else
{
scene::IAnimatedMesh *a_mesh = irr_driver->getAnimatedMesh(full_path);
// TODO: check if mesh is animated or not
scene::IMesh *a_mesh = irr_driver->getMesh(full_path);
if(!a_mesh)
{
fprintf(stderr, "Warning: object model '%s' not found, ignored.\n",
@ -788,7 +796,7 @@ bool Track::loadMainTrack(const XMLNode &root)
m_all_cached_meshes.push_back(a_mesh);
irr_driver->grabAllTextures(a_mesh);
a_mesh->grab();
scene_node = irr_driver->addAnimatedMesh(a_mesh);
scene_node = irr_driver->addMesh(a_mesh);
scene_node->setPosition(xyz);
scene_node->setRotation(hpr);
scene_node->setScale(scale);
@ -800,6 +808,48 @@ bool Track::loadMainTrack(const XMLNode &root)
handleAnimatedTextures(scene_node, *n);
m_all_nodes.push_back( scene_node );
// for challenge orbs, a bit more work to do
if (challenge.size() > 0)
{
const ChallengeData* c = unlock_manager->getChallenge(challenge);
if (c == NULL)
{
fprintf(stderr, "[WARNING] Cannot find challenge named <%s>\n", challenge.c_str());
continue;
}
Track* t = track_manager->getTrack(c->getTrackName());
if (t == NULL)
{
fprintf(stderr, "[WARNING] Cannot find track named <%s>\n", c->getTrackName().c_str());
continue;
}
std::string sshot = t->getScreenshotFile();
video::ITexture* screenshot = irr_driver->getTexture(sshot);
if (screenshot == NULL)
{
fprintf(stderr, "[WARNING] Cannot find track screenshot <%s>\n", sshot.c_str());
continue;
}
scene_node->getMaterial(0).setTexture(0, screenshot);
// make transparent
for (unsigned int m=0; m<a_mesh->getMeshBufferCount(); m++)
{
scene::IMeshBuffer* mb = a_mesh->getMeshBuffer(m);
if (mb->getVertexType() == video::EVT_STANDARD)
{
video::S3DVertex* v = (video::S3DVertex*)mb->getVertices();
for (unsigned int n=0; n<mb->getVertexCount(); n++)
{
v[n].Color.setAlpha(125);
}
}
}
}
}
} // for i