Moved the glowing data from stk_config.xml to items.xml.

Unfortunately I can't test (since the shaders don't work for me).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14683 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2013-12-09 12:24:26 +00:00
parent 375b1a1f06
commit 09dc33d07e
8 changed files with 43 additions and 96 deletions

View File

@ -1,13 +1,13 @@
<?xml version="1.0"?>
<items>
<bonus-box model="gift-box.b3d" lowmodel="gift-box-low.b3d" />
<banana model="banana.b3d" lowmodel="banana-low.b3d" />
<nitro-big model="nitrotank-big.b3d" lowmodel="nitrotank-big-low.b3d" />
<nitro-small model="nitrotank-small.b3d" lowmodel="nitrotank-small-low.b3d" />
<bonus-box model="gift-box.b3d" lowmodel="gift-box-low.b3d" glow="0.12 0.79 0.99"/>
<banana model="banana.b3d" lowmodel="banana-low.b3d" glow="0.77 0.60 0.15"/>
<nitro-big model="nitrotank-big.b3d" lowmodel="nitrotank-big-low.b3d" glow="0.00 0.27 0.62"/>
<nitro-small model="nitrotank-small.b3d" lowmodel="nitrotank-small-low.b3d" glow="0.00 0.27 0.62"/>
<!-- While a bubble gum technically
isn't an item, it is internally
handled as one, so list it here -->
<bubblegum model="bubblegum.b3d" lowmodel="bubblegum-low.b3d" />
<bubblegum model="bubblegum.b3d" lowmodel="bubblegum-low.b3d" glow="0.96 0.59 0.82"/>
<bubblegum-nolok model="bubblegum-nolok.b3d" lowmodel="bubblegum-nolok-low.b3d"/>
<!-- <easter-egg model="easter_egg.b3d" /> -->
<easter-egg model="easter_egg.b3d" />

View File

@ -135,9 +135,6 @@
<steer disable-while-unskid="false"
camera-follow-skid="true" />
<!-- Glow colors for the items -->
<glow-colors nitro="0 70 158" box="31 202 253" banana="197 152 37" bubblegum="246 150 209"/>
<!-- Default values for all karts
============================ -->
<general-kart-defaults>

View File

@ -181,19 +181,6 @@ void STKConfig::init_defaults()
m_disable_steer_while_unskid = false;
m_camera_follow_skid = false;
m_nitro_glow_color[0] = 1.0f;
m_nitro_glow_color[1] = 1.0f;
m_nitro_glow_color[2] = 1.0f;
m_box_glow_color[0] = 1.0f;
m_box_glow_color[1] = 1.0f;
m_box_glow_color[2] = 1.0f;
m_banana_glow_color[0] = 1.0f;
m_banana_glow_color[1] = 1.0f;
m_banana_glow_color[2] = 1.0f;
m_bubblegum_glow_color[0] = 1.0f;
m_bubblegum_glow_color[1] = 1.0f;
m_bubblegum_glow_color[2] = 1.0f;
m_score_increase.clear();
m_leader_intervals.clear();
m_switch_items.clear();
@ -376,38 +363,6 @@ void STKConfig::getAllData(const XMLNode * root)
replay_node->get("delta-t", &m_replay_dt );
}
if(const XMLNode *colors = root->getNode("glow-colors"))
{
video::SColor tmpcol;
if (colors->get("nitro", &tmpcol))
{
m_nitro_glow_color[0] = tmpcol.getRed() / 255.0f;
m_nitro_glow_color[1] = tmpcol.getGreen() / 255.0f;
m_nitro_glow_color[2] = tmpcol.getBlue() / 255.0f;
}
if (colors->get("box", &tmpcol))
{
m_box_glow_color[0] = tmpcol.getRed() / 255.0f;
m_box_glow_color[1] = tmpcol.getGreen() / 255.0f;
m_box_glow_color[2] = tmpcol.getBlue() / 255.0f;
}
if (colors->get("banana", &tmpcol))
{
m_banana_glow_color[0] = tmpcol.getRed() / 255.0f;
m_banana_glow_color[1] = tmpcol.getGreen() / 255.0f;
m_banana_glow_color[2] = tmpcol.getBlue() / 255.0f;
}
if (colors->get("bubblegum", &tmpcol))
{
m_bubblegum_glow_color[0] = tmpcol.getRed() / 255.0f;
m_bubblegum_glow_color[1] = tmpcol.getGreen() / 255.0f;
m_bubblegum_glow_color[2] = tmpcol.getBlue() / 255.0f;
}
}
// Get the default KartProperties
// ------------------------------
const XMLNode *node = root -> getNode("general-kart-defaults");

View File

@ -148,12 +148,6 @@ public:
* be generated. */
float m_replay_delta_angle;
/** Colors for glows */
float m_nitro_glow_color[3];
float m_box_glow_color[3];
float m_banana_glow_color[3];
float m_bubblegum_glow_color[3];
private:
/** True if stk_config has been loaded. This is necessary if the
* --stk-config command line parameter has been specified to avoid

View File

@ -115,34 +115,10 @@ void IrrDriver::renderGLSL(float dt)
dat.g = 1.0f;
dat.b = 1.0f;
// Item colors
switch (type)
{
case Item::ITEM_NITRO_BIG:
case Item::ITEM_NITRO_SMALL:
dat.r = stk_config->m_nitro_glow_color[0];
dat.g = stk_config->m_nitro_glow_color[1];
dat.b = stk_config->m_nitro_glow_color[2];
break;
case Item::ITEM_BONUS_BOX:
dat.r = stk_config->m_box_glow_color[0];
dat.g = stk_config->m_box_glow_color[1];
dat.b = stk_config->m_box_glow_color[2];
break;
case Item::ITEM_BANANA:
dat.r = stk_config->m_banana_glow_color[0];
dat.g = stk_config->m_banana_glow_color[1];
dat.b = stk_config->m_banana_glow_color[2];
break;
case Item::ITEM_BUBBLEGUM:
dat.r = stk_config->m_bubblegum_glow_color[0];
dat.g = stk_config->m_bubblegum_glow_color[1];
dat.b = stk_config->m_bubblegum_glow_color[2];
break;
default:
Log::fatal("render", "Unknown item type got through");
break;
}
const video::SColorf &c = ItemManager::getGlowColor(type);
dat.r = c.getRed();
dat.g = c.getGreen();
dat.b = c.getBlue();
glows.push_back(dat);

View File

@ -279,11 +279,22 @@ int XMLNode::get(const std::string &attribute, video::SColorf *color) const
if(!get(attribute, &s)) return 0;
std::vector<std::string> v = StringUtils::split(s,' ');
if(v.size()!=4) return 0;
if(v.size()==3)
{
color->set((float)atof(v[0].c_str()),
(float)atof(v[1].c_str()),
(float)atof(v[2].c_str()));
}
else if(v.size()==4)
{
color->set((float)atof(v[3].c_str()), // set takes ARGB, but we use RGBA
(float)atof(v[0].c_str()),
(float)atof(v[1].c_str()),
(float)atof(v[2].c_str()));
}
else
return 0;
return 1;
} // get(SColor)
// ----------------------------------------------------------------------------

View File

@ -40,8 +40,10 @@
std::vector<scene::IMesh *> ItemManager::m_item_mesh;
std::vector<scene::IMesh *> ItemManager::m_item_lowres_mesh;
std::vector<video::SColorf> ItemManager::m_glow_color;
ItemManager * ItemManager::m_item_manager = NULL;
//-----------------------------------------------------------------------------
/** Creates one instance of the item manager. */
void ItemManager::create()
@ -65,6 +67,9 @@ void ItemManager::destroy()
void ItemManager::loadDefaultItemMeshes()
{
m_item_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL);
m_glow_color.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1,
video::SColorf(255.0f, 255.0f, 255.0f) );
m_item_lowres_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL);
// A temporary mapping of items to names used in the XML file:
@ -98,6 +103,7 @@ void ItemManager::loadDefaultItemMeshes()
}
mesh->grab();
m_item_mesh[i] = mesh;
node->get("glow", &(m_glow_color[i]));
std::string lowres_model_filename;
node->get("lowmodel", &lowres_model_filename);

View File

@ -19,15 +19,16 @@
#ifndef HEADER_ITEMMANAGER_HPP
#define HEADER_ITEMMANAGER_HPP
#include "items/item.hpp"
#include "utils/no_copy.hpp"
#include <SColor.h>
#include <assert.h>
#include <map>
#include <string>
#include <vector>
#include "items/item.hpp"
#include "utils/no_copy.hpp"
class Kart;
/**
@ -40,6 +41,9 @@ private:
/** Stores all item models. */
static std::vector<scene::IMesh *> m_item_mesh;
/** Stores the glow color for all items. */
static std::vector<video::SColorf> m_glow_color;
/** Stores all low-resolution item models. */
static std::vector<scene::IMesh *> m_item_lowres_mesh;
@ -56,6 +60,10 @@ public:
static scene::IMesh* getItemModel(Item::ItemType type)
{ return m_item_mesh[type]; }
// ------------------------------------------------------------------------
/** Returns the glow color for an item. */
static video::SColorf& getGlowColor(Item::ItemType type)
{ return m_glow_color[type]; }
// ------------------------------------------------------------------------
/** Return an instance of the item manager (it does not automatically
* create one, call create for that). */
static ItemManager *get() {