Make animated textures work with LOD

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11186 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2012-05-06 01:13:03 +00:00
parent fa861267a0
commit 95a8ba37e0
5 changed files with 23 additions and 11 deletions

View File

@@ -72,6 +72,7 @@ public:
XMLNode(const std::string &filename);
~XMLNode();
const std::string &getName() const {return m_name; }
const XMLNode *getNode(const std::string &name) const;
const void getNodes(const std::string &s, std::vector<XMLNode*>& out) const;

View File

@@ -22,6 +22,7 @@ using namespace irr;
#include "graphics/irr_driver.hpp"
#include "graphics/lod_node.hpp"
#include "io/xml_node.hpp"
#include "tracks/track.hpp"
#include <IMeshSceneNode.h>
#include <ISceneManager.h>
@@ -67,7 +68,7 @@ bool LodNodeLoader::check(const XMLNode* xml)
std::string model_name;
xml->get("model", &model_name);
lod_groups[lodgroup][(int)lod_distance] = LodModel(model_name, tangent);
lod_groups[lodgroup][(int)lod_distance] = LodModel(xml, model_name, tangent);
}
return true;
}
@@ -84,7 +85,8 @@ bool LodNodeLoader::check(const XMLNode* xml)
* @param cache the individual meshes will be added there
* @param[out] out the nodes are added here
*/
void LodNodeLoader::done(std::string directory,
void LodNodeLoader::done(Track* track,
std::string directory,
std::vector<scene::IMesh*>& cache,
std::vector<LODNode*>& out)
{
@@ -174,6 +176,8 @@ void LodNodeLoader::done(std::string directory,
scene_node->setRotation(hpr);
scene_node->setScale(scale);
track->handleAnimatedTextures( scene_node, *group[m].second.m_xml );
lod_node->add( group[m].first, scene_node, true );
}
@@ -181,7 +185,6 @@ void LodNodeLoader::done(std::string directory,
std::string debug_name = groupname+" (LOD track-object)";
lod_node->setName(debug_name.c_str());
#endif
out.push_back(lod_node);
}
else

View File

@@ -19,13 +19,13 @@
#ifndef HEADER_LOD_NODE_LOADER_HPP
#define HEADER_LOD_NODE_LOADER_HPP
class XMLNode;
class LODNode;
class Track;
#include <map>
#include <vector>
#include <string>
#include "io/xml_node.hpp"
namespace irr
{
@@ -39,17 +39,24 @@ struct LodModel
{
std::string m_model_file;
bool m_tangent;
const XMLNode* m_xml;
/** Constructor to allow storing this in STL containers */
LodModel()
{
m_tangent = false;
m_xml = NULL;
}
LodModel(std::string& model, bool tangent)
LodModel(const XMLNode* xml, std::string& model, bool tangent)
{
m_model_file = model;
m_tangent = tangent;
m_xml = xml;
}
~LodModel()
{
}
};
@@ -66,7 +73,8 @@ public:
LodNodeLoader();
bool check(const XMLNode* xml);
void done(std::string directory,
void done(Track* track,
std::string directory,
std::vector<irr::scene::IMesh*>& cache,
std::vector<LODNode*>& out);

View File

@@ -979,7 +979,7 @@ bool Track::loadMainTrack(const XMLNode &root)
// Create LOD nodes
std::vector<LODNode*> lod_nodes;
lodLoader.done(m_root, m_all_cached_meshes, lod_nodes);
lodLoader.done(this, m_root, m_all_cached_meshes, lod_nodes);
for (unsigned int n=0; n<lod_nodes.size(); n++)
{
// FIXME: support for animated textures on LOD objects
@@ -1428,7 +1428,7 @@ void Track::loadTrackModel(World* parent, bool reverse_track,
std::vector<LODNode*> lod_nodes;
std::vector<scene::IMesh*> devnull;
lod_loader.done(m_root, devnull, lod_nodes);
lod_loader.done(this, m_root, devnull, lod_nodes);
m_track_object_manager->assingLodNodes(lod_nodes);
// ---------------------------------------------

View File

@@ -320,13 +320,13 @@ private:
void getMusicInformation(std::vector<std::string>& filenames,
std::vector<MusicInformation*>& m_music );
void loadCurves(const XMLNode &node);
void handleAnimatedTextures(scene::ISceneNode *node, const XMLNode &xml);
void handleSky(const XMLNode &root, const std::string &filename);
public:
bool reverseAvailable() { return m_reverse_available; }
void handleAnimatedTextures(scene::ISceneNode *node, const XMLNode &xml);
static const float NOHIT;
Track (const std::string &filename);