Running whitespaces.py; no more trailing whitespaces & tabs -> 4 spaces
This commit is contained in:
parent
233f9947ff
commit
65e2dcf2f0
@ -35,7 +35,7 @@ class XMLNode;
|
|||||||
* storage for state information by a generic key-value mapping. The values
|
* storage for state information by a generic key-value mapping. The values
|
||||||
* are stored as strings, but can be used to store numerical values. E.g.
|
* are stored as strings, but can be used to store numerical values. E.g.
|
||||||
* you can call increase("key", 10) for an achievement, which will convert
|
* you can call increase("key", 10) for an achievement, which will convert
|
||||||
* the string to int, add 10, then convert the result back to string for
|
* the string to int, add 10, then convert the result back to string for
|
||||||
* storage.
|
* storage.
|
||||||
* \ingroup achievements
|
* \ingroup achievements
|
||||||
*/
|
*/
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
|
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
virtual irr::core::stringw getProgressAsString() const;
|
virtual irr::core::stringw getProgressAsString() const;
|
||||||
void onRaceEnd();
|
void onRaceEnd();
|
||||||
void onLapEnd();
|
void onLapEnd();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the id of this achievement. */
|
/** Returns the id of this achievement. */
|
||||||
@ -89,4 +89,4 @@ public:
|
|||||||
return m_progress_map;
|
return m_progress_map;
|
||||||
} // getProgress
|
} // getProgress
|
||||||
}; // class Achievement
|
}; // class Achievement
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,7 +41,7 @@ AchievementInfo::AchievementInfo(const XMLNode * input)
|
|||||||
input->get("description", &m_description );
|
input->get("description", &m_description );
|
||||||
if (!all)
|
if (!all)
|
||||||
{
|
{
|
||||||
Log::error("AchievementInfo",
|
Log::error("AchievementInfo",
|
||||||
"Not all necessary values for achievement defined.");
|
"Not all necessary values for achievement defined.");
|
||||||
Log::error("AchievementInfo",
|
Log::error("AchievementInfo",
|
||||||
"ID %d title '%s' description '%s'", m_id, m_title.c_str(),
|
"ID %d title '%s' description '%s'", m_id, m_title.c_str(),
|
||||||
@ -80,7 +80,7 @@ AchievementInfo::AchievementInfo(const XMLNode * input)
|
|||||||
m_goal_values[key] = goal;
|
m_goal_values[key] = goal;
|
||||||
}
|
}
|
||||||
if (m_goal_values.size() != input->getNumNodes())
|
if (m_goal_values.size() != input->getNumNodes())
|
||||||
Log::fatal("AchievementInfo",
|
Log::fatal("AchievementInfo",
|
||||||
"Duplicate keys for the entries of a MapAchievement found.");
|
"Duplicate keys for the entries of a MapAchievement found.");
|
||||||
|
|
||||||
if (m_check_type == AC_ONE_AT_LEAST)
|
if (m_check_type == AC_ONE_AT_LEAST)
|
||||||
@ -156,7 +156,7 @@ bool AchievementInfo::checkCompletion(Achievement * achievement) const
|
|||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
int AchievementInfo::getGoalValue(const std::string &key) const
|
int AchievementInfo::getGoalValue(const std::string &key) const
|
||||||
{
|
{
|
||||||
std::map<std::string, int>::const_iterator it;
|
std::map<std::string, int>::const_iterator it;
|
||||||
it = m_goal_values.find(key);
|
it = m_goal_values.find(key);
|
||||||
if (it != m_goal_values.end())
|
if (it != m_goal_values.end())
|
||||||
|
@ -74,14 +74,14 @@ AchievementsManager::~AchievementsManager()
|
|||||||
* information for a single player.
|
* information for a single player.
|
||||||
* \param node The XML of saved data, or NULL if no saved data exists.
|
* \param node The XML of saved data, or NULL if no saved data exists.
|
||||||
*/
|
*/
|
||||||
AchievementsStatus*
|
AchievementsStatus*
|
||||||
AchievementsManager::createAchievementsStatus(const XMLNode *node)
|
AchievementsManager::createAchievementsStatus(const XMLNode *node)
|
||||||
{
|
{
|
||||||
AchievementsStatus *status = new AchievementsStatus();
|
AchievementsStatus *status = new AchievementsStatus();
|
||||||
|
|
||||||
// First add all achievements, before restoring the saved data.
|
// First add all achievements, before restoring the saved data.
|
||||||
std::map<uint32_t, AchievementInfo *>::const_iterator it;
|
std::map<uint32_t, AchievementInfo *>::const_iterator it;
|
||||||
for (it = m_achievements_info.begin();
|
for (it = m_achievements_info.begin();
|
||||||
it != m_achievements_info.end(); ++it)
|
it != m_achievements_info.end(); ++it)
|
||||||
{
|
{
|
||||||
Achievement * achievement;
|
Achievement * achievement;
|
||||||
@ -98,7 +98,7 @@ AchievementsStatus*
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
AchievementInfo * AchievementsManager::getAchievementInfo(uint32_t id) const
|
AchievementInfo * AchievementsManager::getAchievementInfo(uint32_t id) const
|
||||||
{
|
{
|
||||||
std::map<uint32_t, AchievementInfo*>::const_iterator info =
|
std::map<uint32_t, AchievementInfo*>::const_iterator info =
|
||||||
m_achievements_info.find(id);
|
m_achievements_info.find(id);
|
||||||
if (info != m_achievements_info.end())
|
if (info != m_achievements_info.end())
|
||||||
return info->second;
|
return info->second;
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const std::map<uint32_t, AchievementInfo *> & getAllInfo()
|
const std::map<uint32_t, AchievementInfo *> & getAllInfo()
|
||||||
{
|
{
|
||||||
return m_achievements_info;
|
return m_achievements_info;
|
||||||
} // getAllInfo
|
} // getAllInfo
|
||||||
|
|
||||||
}; // class AchievementsManager
|
}; // class AchievementsManager
|
||||||
|
@ -140,4 +140,4 @@ void AchievementsStatus::onLapEnd()
|
|||||||
for (iter = m_achievements.begin(); iter != m_achievements.end(); ++iter) {
|
for (iter = m_achievements.begin(); iter != m_achievements.end(); ++iter) {
|
||||||
iter->second->onLapEnd();
|
iter->second->onLapEnd();
|
||||||
}
|
}
|
||||||
} // onLapEnd
|
} // onLapEnd
|
||||||
|
@ -62,7 +62,7 @@ public :
|
|||||||
void onRaceEnd();
|
void onRaceEnd();
|
||||||
void onLapEnd();
|
void onLapEnd();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const std::map<uint32_t, Achievement *>& getAllAchievements()
|
const std::map<uint32_t, Achievement *>& getAllAchievements()
|
||||||
{
|
{
|
||||||
return m_achievements;
|
return m_achievements;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ bool Addon::testIncluded(const std::string &min_ver, const std::string &max_ver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* \brief Filter the add-on with a list of words.
|
* \brief Filter the add-on with a list of words.
|
||||||
* \param words A list of words separated by ' '.
|
* \param words A list of words separated by ' '.
|
||||||
* \return true if the add-on contains one of the words, otherwise false.
|
* \return true if the add-on contains one of the words, otherwise false.
|
||||||
@ -194,25 +194,25 @@ bool Addon::filterByWords(const core::stringw words) const
|
|||||||
for (unsigned int i = 0; i < list.size(); i++)
|
for (unsigned int i = 0; i < list.size(); i++)
|
||||||
{
|
{
|
||||||
list[i].make_lower();
|
list[i].make_lower();
|
||||||
|
|
||||||
core::stringw name = core::stringw(m_name).make_lower();
|
core::stringw name = core::stringw(m_name).make_lower();
|
||||||
if (name.find(list[i].c_str()) != -1)
|
if (name.find(list[i].c_str()) != -1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
core::stringw designer = core::stringw(m_designer).make_lower();
|
core::stringw designer = core::stringw(m_designer).make_lower();
|
||||||
if (designer.find(list[i].c_str()) != -1)
|
if (designer.find(list[i].c_str()) != -1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
core::stringw description = core::stringw(m_description).make_lower();
|
core::stringw description = core::stringw(m_description).make_lower();
|
||||||
if (description.find(list[i].c_str()) != -1)
|
if (description.find(list[i].c_str()) != -1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // filterByWords
|
} // filterByWords
|
||||||
|
@ -271,7 +271,7 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool filterByWords(const core::stringw words) const;
|
bool filterByWords(const core::stringw words) const;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Compares two addons according to the sort order currently defined.
|
/** Compares two addons according to the sort order currently defined.
|
||||||
* \param a The addon to compare this addon to.
|
* \param a The addon to compare this addon to.
|
||||||
*/
|
*/
|
||||||
|
@ -106,17 +106,17 @@ void AddonsManager::init(const XMLNode *xml,
|
|||||||
include->get("mtime", &tmp);
|
include->get("mtime", &tmp);
|
||||||
mtime = tmp;
|
mtime = tmp;
|
||||||
|
|
||||||
bool download =
|
bool download =
|
||||||
( mtime > UserConfigParams::m_addons_last_updated +frequency ||
|
( mtime > UserConfigParams::m_addons_last_updated +frequency ||
|
||||||
force_refresh ||
|
force_refresh ||
|
||||||
!file_manager->fileExists(filename) )
|
!file_manager->fileExists(filename) )
|
||||||
&& UserConfigParams::m_internet_status == RequestManager::IPERM_ALLOWED;
|
&& UserConfigParams::m_internet_status == RequestManager::IPERM_ALLOWED;
|
||||||
|
|
||||||
if (download)
|
if (download)
|
||||||
{
|
{
|
||||||
Log::info("NetworkHttp", "Downloading updated addons.xml");
|
Log::info("NetworkHttp", "Downloading updated addons.xml");
|
||||||
Online::HTTPRequest *download_request = new Online::HTTPRequest("addons.xml");
|
Online::HTTPRequest *download_request = new Online::HTTPRequest("addons.xml");
|
||||||
download_request->setURL(addon_list_url);
|
download_request->setURL(addon_list_url);
|
||||||
download_request->executeNow();
|
download_request->executeNow();
|
||||||
if(download_request->hadDownloadError())
|
if(download_request->hadDownloadError())
|
||||||
{
|
{
|
||||||
@ -130,7 +130,7 @@ void AddonsManager::init(const XMLNode *xml,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log::info("NetworkHttp", "Using cached addons.xml");
|
Log::info("NetworkHttp", "Using cached addons.xml");
|
||||||
|
|
||||||
const XMLNode *xml_addons = new XMLNode(filename);
|
const XMLNode *xml_addons = new XMLNode(filename);
|
||||||
addons_manager->initAddons(xml_addons); // will free xml_addons
|
addons_manager->initAddons(xml_addons); // will free xml_addons
|
||||||
if(UserConfigParams::logAddons())
|
if(UserConfigParams::logAddons())
|
||||||
@ -375,7 +375,7 @@ void AddonsManager::downloadIcons()
|
|||||||
m_addon->setIconReady();
|
m_addon->setIconReady();
|
||||||
} // callback
|
} // callback
|
||||||
public:
|
public:
|
||||||
IconRequest(const std::string &filename,
|
IconRequest(const std::string &filename,
|
||||||
const std::string &url,
|
const std::string &url,
|
||||||
Addon *addon ) : HTTPRequest(filename, true, 1)
|
Addon *addon ) : HTTPRequest(filename, true, 1)
|
||||||
{
|
{
|
||||||
@ -558,8 +558,8 @@ bool AddonsManager::uninstall(const Addon &addon)
|
|||||||
// some files were successfully removed. Since we can not
|
// some files were successfully removed. Since we can not
|
||||||
// know if the addon is still functional, better remove it.
|
// know if the addon is still functional, better remove it.
|
||||||
// On the other hand, in case of a problem the user will have
|
// On the other hand, in case of a problem the user will have
|
||||||
// the option in the GUI to try again. In this case
|
// the option in the GUI to try again. In this case
|
||||||
// removeTrack/Kart would not find the addon and assert. So
|
// removeTrack/Kart would not find the addon and assert. So
|
||||||
// check first if the track is still known.
|
// check first if the track is still known.
|
||||||
if(addon.getType()=="kart")
|
if(addon.getType()=="kart")
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ NewsManager::~NewsManager()
|
|||||||
* separate thread to execute downloadNews() - which (if necessary) the
|
* separate thread to execute downloadNews() - which (if necessary) the
|
||||||
* news.xml file and updating the list of news messages. It also initialises
|
* news.xml file and updating the list of news messages. It also initialises
|
||||||
* the addons manager (which can trigger another download of news.xml).
|
* the addons manager (which can trigger another download of news.xml).
|
||||||
* \param force_refresh Re-download news.xml, even if
|
* \param force_refresh Re-download news.xml, even if
|
||||||
*/
|
*/
|
||||||
void NewsManager::init(bool force_refresh)
|
void NewsManager::init(bool force_refresh)
|
||||||
{
|
{
|
||||||
@ -102,7 +102,7 @@ void* NewsManager::downloadNews(void *obj)
|
|||||||
bool download = ( UserConfigParams::m_news_last_updated==0 ||
|
bool download = ( UserConfigParams::m_news_last_updated==0 ||
|
||||||
UserConfigParams::m_news_last_updated
|
UserConfigParams::m_news_last_updated
|
||||||
+UserConfigParams::m_news_frequency
|
+UserConfigParams::m_news_frequency
|
||||||
< StkTime::getTimeSinceEpoch() ||
|
< StkTime::getTimeSinceEpoch() ||
|
||||||
me->m_force_refresh ||
|
me->m_force_refresh ||
|
||||||
!news_exists )
|
!news_exists )
|
||||||
&& UserConfigParams::m_internet_status==RequestManager::IPERM_ALLOWED;
|
&& UserConfigParams::m_internet_status==RequestManager::IPERM_ALLOWED;
|
||||||
@ -183,7 +183,7 @@ void* NewsManager::downloadNews(void *obj)
|
|||||||
|
|
||||||
if(xml) delete xml;
|
if(xml) delete xml;
|
||||||
xml = NULL;
|
xml = NULL;
|
||||||
|
|
||||||
// Process new.xml now.
|
// Process new.xml now.
|
||||||
if(file_manager->fileExists(xml_file))
|
if(file_manager->fileExists(xml_file))
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ private:
|
|||||||
/** True if a collision with this object should trigger
|
/** True if a collision with this object should trigger
|
||||||
* "exploding" a kart. */
|
* "exploding" a kart. */
|
||||||
bool m_explode_kart;
|
bool m_explode_kart;
|
||||||
|
|
||||||
bool m_flatten_kart;
|
bool m_flatten_kart;
|
||||||
|
|
||||||
/** We have to store the rotation value as computed in blender, since
|
/** We have to store the rotation value as computed in blender, since
|
||||||
|
@ -78,7 +78,7 @@ SFXBuffer::SFXBuffer(const std::string& file,
|
|||||||
bool SFXBuffer::load()
|
bool SFXBuffer::load()
|
||||||
{
|
{
|
||||||
if (UserConfigParams::m_sfx == false) return false;
|
if (UserConfigParams::m_sfx == false) return false;
|
||||||
|
|
||||||
#if HAVE_OGGVORBIS
|
#if HAVE_OGGVORBIS
|
||||||
if (m_loaded) return false;
|
if (m_loaded) return false;
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ SFXBuffer* SFXManager::loadSingleSfx(const XMLNode* node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string sfx_name = StringUtils::removeExtension(filename);
|
std::string sfx_name = StringUtils::removeExtension(filename);
|
||||||
|
|
||||||
if(m_all_sfx_types.find(sfx_name)!=m_all_sfx_types.end())
|
if(m_all_sfx_types.find(sfx_name)!=m_all_sfx_types.end())
|
||||||
{
|
{
|
||||||
Log::error("SFXManager",
|
Log::error("SFXManager",
|
||||||
@ -262,7 +262,7 @@ SFXBuffer* SFXManager::loadSingleSfx(const XMLNode* node,
|
|||||||
|
|
||||||
// Only use the filename if no full path is specified. This is used
|
// Only use the filename if no full path is specified. This is used
|
||||||
// to load terrain specific sfx.
|
// to load terrain specific sfx.
|
||||||
const std::string full_path = (path == "")
|
const std::string full_path = (path == "")
|
||||||
? file_manager->getAsset(FileManager::SFX,filename)
|
? file_manager->getAsset(FileManager::SFX,filename)
|
||||||
: path;
|
: path;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ void SFXOpenAL::volume(float gain)
|
|||||||
void SFXOpenAL::masterVolume(float gain)
|
void SFXOpenAL::masterVolume(float gain)
|
||||||
{
|
{
|
||||||
m_master_gain = gain;
|
m_master_gain = gain;
|
||||||
|
|
||||||
if(!m_ok) return;
|
if(!m_ok) return;
|
||||||
|
|
||||||
alSourcef(m_soundSource, AL_GAIN, (m_gain < 0.0f ? m_defaultGain : m_gain) * m_master_gain);
|
alSourcef(m_soundSource, AL_GAIN, (m_gain < 0.0f ? m_defaultGain : m_gain) * m_master_gain);
|
||||||
|
@ -55,7 +55,7 @@ private:
|
|||||||
the sound source won't be created and we'll be left with no clue when enabling
|
the sound source won't be created and we'll be left with no clue when enabling
|
||||||
sounds later. */
|
sounds later. */
|
||||||
float m_gain;
|
float m_gain;
|
||||||
|
|
||||||
/** The master gain set in user preferences */
|
/** The master gain set in user preferences */
|
||||||
float m_master_gain;
|
float m_master_gain;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class XMLNode;
|
|||||||
* challenge is not possible yet (inactive), active (i.e. user can try to
|
* challenge is not possible yet (inactive), active (i.e. user can try to
|
||||||
* solve it), or solved. This status is stored for each difficulty level.
|
* solve it), or solved. This status is stored for each difficulty level.
|
||||||
* This data is saved to and loaded from the players.xml file.
|
* This data is saved to and loaded from the players.xml file.
|
||||||
* A StoryModeStatus instance will store an array of ChallengeStatuses,
|
* A StoryModeStatus instance will store an array of ChallengeStatuses,
|
||||||
* one for each Challenge in STK.
|
* one for each Challenge in STK.
|
||||||
*
|
*
|
||||||
* \ingroup challenges
|
* \ingroup challenges
|
||||||
|
@ -111,9 +111,9 @@ public:
|
|||||||
/** Returns if this is the first time the intro is shown. */
|
/** Returns if this is the first time the intro is shown. */
|
||||||
bool isFirstTime() const { return m_first_time; }
|
bool isFirstTime() const { return m_first_time; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const ChallengeStatus *getCurrentChallengeStatus() const
|
const ChallengeStatus *getCurrentChallengeStatus() const
|
||||||
{
|
{
|
||||||
return m_current_challenge;
|
return m_current_challenge;
|
||||||
} // getCurrentChallengeStatus
|
} // getCurrentChallengeStatus
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns a challenge given the challenge id.
|
/** Returns a challenge given the challenge id.
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
PlayerManager *PlayerManager::m_player_manager = NULL;
|
PlayerManager *PlayerManager::m_player_manager = NULL;
|
||||||
|
|
||||||
|
|
||||||
/** Create the instance of the player manager.
|
/** Create the instance of the player manager.
|
||||||
* Also make sure that at least one player is defined (and if not,
|
* Also make sure that at least one player is defined (and if not,
|
||||||
* create a default player and a guest player).
|
* create a default player and a guest player).
|
||||||
*/
|
*/
|
||||||
@ -137,7 +137,7 @@ void PlayerManager::addNewPlayer(const core::stringw& name)
|
|||||||
} // addNewPlayer
|
} // addNewPlayer
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Deletes a player profile from the list of all profiles.
|
/** Deletes a player profile from the list of all profiles.
|
||||||
*/
|
*/
|
||||||
void PlayerManager::deletePlayer(PlayerProfile *player)
|
void PlayerManager::deletePlayer(PlayerProfile *player)
|
||||||
{
|
{
|
||||||
@ -146,7 +146,7 @@ void PlayerManager::deletePlayer(PlayerProfile *player)
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** This function makes sure that a current player is defined. This is called
|
/** This function makes sure that a current player is defined. This is called
|
||||||
* when a screen skipping command line option is given (-N, -R, ...), in
|
* when a screen skipping command line option is given (-N, -R, ...), in
|
||||||
* which case there might not be a current player (if no default player is
|
* which case there might not be a current player (if no default player is
|
||||||
* set in players.xml, i.e. the 'remember be' option was not picked ). Since
|
* set in players.xml, i.e. the 'remember be' option was not picked ). Since
|
||||||
* a lot of code depends on having a local player, just set the most
|
* a lot of code depends on having a local player, just set the most
|
||||||
|
@ -70,7 +70,7 @@ public:
|
|||||||
m_player_manager = NULL;
|
m_player_manager = NULL;
|
||||||
} // destroy
|
} // destroy
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
unsigned int getUniqueId() const;
|
unsigned int getUniqueId() const;
|
||||||
void addDefaultPlayer();
|
void addDefaultPlayer();
|
||||||
|
@ -45,7 +45,7 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
|
|||||||
m_unique_id = PlayerManager::get()->getUniqueId();
|
m_unique_id = PlayerManager::get()->getUniqueId();
|
||||||
m_story_mode_status = unlock_manager->createStoryModeStatus();
|
m_story_mode_status = unlock_manager->createStoryModeStatus();
|
||||||
m_is_default = false;
|
m_is_default = false;
|
||||||
m_achievements_status =
|
m_achievements_status =
|
||||||
AchievementsManager::get()->createAchievementsStatus();
|
AchievementsManager::get()->createAchievementsStatus();
|
||||||
} // PlayerProfile
|
} // PlayerProfile
|
||||||
|
|
||||||
@ -77,8 +77,8 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
|
|||||||
*/
|
*/
|
||||||
void PlayerProfile::save(UTFWriter &out)
|
void PlayerProfile::save(UTFWriter &out)
|
||||||
{
|
{
|
||||||
out << L" <player name=\"" << m_name
|
out << L" <player name=\"" << m_name
|
||||||
<< L"\" guest=\"" << m_is_guest_account
|
<< L"\" guest=\"" << m_is_guest_account
|
||||||
<< L"\" use-frequency=\"" << m_use_frequency
|
<< L"\" use-frequency=\"" << m_use_frequency
|
||||||
<< L"\" is-default=\"" << m_is_default
|
<< L"\" is-default=\"" << m_is_default
|
||||||
<< L"\" unique-id=\"" << m_unique_id << L"\">\n";
|
<< L"\" unique-id=\"" << m_unique_id << L"\">\n";
|
||||||
@ -111,7 +111,7 @@ void PlayerProfile::raceFinished()
|
|||||||
} // raceFinished
|
} // raceFinished
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** Comparison used to sort players.
|
/** Comparison used to sort players.
|
||||||
*/
|
*/
|
||||||
bool PlayerProfile::operator<(const PlayerProfile &other)
|
bool PlayerProfile::operator<(const PlayerProfile &other)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ using namespace irr;
|
|||||||
class UTFWriter;
|
class UTFWriter;
|
||||||
class AchievementsStatus;
|
class AchievementsStatus;
|
||||||
|
|
||||||
/** Class for managing player profiles (name, usage frequency,
|
/** Class for managing player profiles (name, usage frequency,
|
||||||
* etc.). All PlayerProfiles are managed by the PlayerManager.
|
* etc.). All PlayerProfiles are managed by the PlayerManager.
|
||||||
* A PlayerProfile keeps track of the story mode progress using an instance
|
* A PlayerProfile keeps track of the story mode progress using an instance
|
||||||
* of StoryModeStatus, and achievements with AchievementsStatus. All data
|
* of StoryModeStatus, and achievements with AchievementsStatus. All data
|
||||||
@ -42,7 +42,7 @@ class PlayerProfile : public NoCopy
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** The name of the player (wide string, so it can be in native
|
/** The name of the player (wide string, so it can be in native
|
||||||
* language). */
|
* language). */
|
||||||
core::stringw m_name;
|
core::stringw m_name;
|
||||||
|
|
||||||
@ -130,14 +130,14 @@ public:
|
|||||||
/** Returnes if the feature (kart, track) is locked. */
|
/** Returnes if the feature (kart, track) is locked. */
|
||||||
bool isLocked(const std::string &feature) const
|
bool isLocked(const std::string &feature) const
|
||||||
{
|
{
|
||||||
return m_story_mode_status->isLocked(feature);
|
return m_story_mode_status->isLocked(feature);
|
||||||
} // isLocked
|
} // isLocked
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns all active challenges. */
|
/** Returns all active challenges. */
|
||||||
void computeActive() { m_story_mode_status->computeActive(); }
|
void computeActive() { m_story_mode_status->computeActive(); }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the list of recently completed challenges. */
|
/** Returns the list of recently completed challenges. */
|
||||||
std::vector<const ChallengeData*> getRecentlyCompletedChallenges()
|
std::vector<const ChallengeData*> getRecentlyCompletedChallenges()
|
||||||
{
|
{
|
||||||
return m_story_mode_status->getRecentlyCompletedChallenges();
|
return m_story_mode_status->getRecentlyCompletedChallenges();
|
||||||
} // getRecently Completed Challenges
|
} // getRecently Completed Challenges
|
||||||
@ -173,7 +173,7 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
unsigned int getNumEasyTrophies() const
|
unsigned int getNumEasyTrophies() const
|
||||||
{
|
{
|
||||||
return m_story_mode_status->getNumEasyTrophies();
|
return m_story_mode_status->getNumEasyTrophies();
|
||||||
} // getNumEasyTrophies
|
} // getNumEasyTrophies
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
unsigned int getNumMediumTrophies() const
|
unsigned int getNumMediumTrophies() const
|
||||||
@ -183,10 +183,10 @@ public:
|
|||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
unsigned int getNumHardTrophies() const
|
unsigned int getNumHardTrophies() const
|
||||||
{
|
{
|
||||||
return m_story_mode_status->getNumHardTrophies();
|
return m_story_mode_status->getNumHardTrophies();
|
||||||
} // getNumHardTropies
|
} // getNumHardTropies
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
AchievementsStatus* getAchievementsStatus()
|
AchievementsStatus* getAchievementsStatus()
|
||||||
{
|
{
|
||||||
return m_achievements_status;
|
return m_achievements_status;
|
||||||
} // getAchievementsStatus
|
} // getAchievementsStatus
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
float m_parachute_ubound_fraction; /**<Upper bound fraction of speed when
|
float m_parachute_ubound_fraction; /**<Upper bound fraction of speed when
|
||||||
lost will detach parachute. */
|
lost will detach parachute. */
|
||||||
float m_parachute_lbound_fraction; /**<Lower bound fraction of speed when
|
float m_parachute_lbound_fraction; /**<Lower bound fraction of speed when
|
||||||
lost will detach parachute. */
|
lost will detach parachute. */
|
||||||
float m_parachute_max_speed; /**<Max speed to rate current speed */
|
float m_parachute_max_speed; /**<Max speed to rate current speed */
|
||||||
float m_parachute_time; /**<Time a parachute is active. */
|
float m_parachute_time; /**<Time a parachute is active. */
|
||||||
float m_parachute_time_other; /**<Time a parachute attached to other
|
float m_parachute_time_other; /**<Time a parachute attached to other
|
||||||
|
@ -285,7 +285,7 @@ void ListUserConfigParam<T, U>::findYourDataInAChildOf(const XMLNode* node)
|
|||||||
std::string str;
|
std::string str;
|
||||||
child->get( StringUtils::toString(n), &str);
|
child->get( StringUtils::toString(n), &str);
|
||||||
StringUtils::fromString<T>(str, elt);
|
StringUtils::fromString<T>(str, elt);
|
||||||
|
|
||||||
// check if the element is already there :
|
// check if the element is already there :
|
||||||
bool there = false;
|
bool there = false;
|
||||||
for (unsigned int i = 0; i < m_elements.size(); i++)
|
for (unsigned int i = 0; i < m_elements.size(); i++)
|
||||||
@ -692,7 +692,7 @@ bool UserConfig::loadConfig()
|
|||||||
"Could not read user config file '%s'.", filename.c_str());
|
"Could not read user config file '%s'.", filename.c_str());
|
||||||
if(root) delete root;
|
if(root) delete root;
|
||||||
// Create a default config file - just in case that stk crashes later
|
// Create a default config file - just in case that stk crashes later
|
||||||
// there is a config file that can be modified (to e.g. disable
|
// there is a config file that can be modified (to e.g. disable
|
||||||
// shaders)
|
// shaders)
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return false;
|
return false;
|
||||||
@ -703,7 +703,7 @@ bool UserConfig::loadConfig()
|
|||||||
if(root->get("version", &config_file_version) < 1)
|
if(root->get("version", &config_file_version) < 1)
|
||||||
{
|
{
|
||||||
GUIEngine::showMessage( _("Your config file was malformed, so it was deleted and a new one will be created."), 10.0f);
|
GUIEngine::showMessage( _("Your config file was malformed, so it was deleted and a new one will be created."), 10.0f);
|
||||||
Log::error("UserConfig",
|
Log::error("UserConfig",
|
||||||
"Warning, malformed user config file! Contains no version");
|
"Warning, malformed user config file! Contains no version");
|
||||||
}
|
}
|
||||||
if (config_file_version < m_current_config_version)
|
if (config_file_version < m_current_config_version)
|
||||||
|
@ -14,232 +14,232 @@ CBatchingMesh::CBatchingMesh()
|
|||||||
|
|
||||||
CBatchingMesh::~CBatchingMesh()
|
CBatchingMesh::~CBatchingMesh()
|
||||||
{
|
{
|
||||||
u32 i;
|
u32 i;
|
||||||
for (i=0; i < DestBuffers.size(); ++i)
|
for (i=0; i < DestBuffers.size(); ++i)
|
||||||
DestBuffers[i].Buffer->drop();
|
DestBuffers[i].Buffer->drop();
|
||||||
|
|
||||||
for (i=0; i < SourceBuffers.size(); ++i)
|
for (i=0; i < SourceBuffers.size(); ++i)
|
||||||
SourceBuffers[i]->drop();
|
SourceBuffers[i]->drop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBatchingMesh::isDirty(s32 id)
|
bool CBatchingMesh::isDirty(s32 id)
|
||||||
{
|
{
|
||||||
if ((u32)id > DestBuffers.size())
|
if ((u32)id > DestBuffers.size())
|
||||||
return IsDirty;
|
return IsDirty;
|
||||||
else
|
else
|
||||||
return DestBuffers[id].IsDirty;
|
return DestBuffers[id].IsDirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! refreshes the internal buffers from source
|
//! refreshes the internal buffers from source
|
||||||
void CBatchingMesh::update()
|
void CBatchingMesh::update()
|
||||||
{
|
{
|
||||||
// allocate the index and vertex arrays
|
// allocate the index and vertex arrays
|
||||||
u32 i;
|
u32 i;
|
||||||
for (i=0; i<DestBuffers.size(); ++i)
|
for (i=0; i<DestBuffers.size(); ++i)
|
||||||
{
|
{
|
||||||
if (DestBuffers[i].IndexCount != DestBuffers[i].Buffer->getIndexCount() ||
|
if (DestBuffers[i].IndexCount != DestBuffers[i].Buffer->getIndexCount() ||
|
||||||
DestBuffers[i].VertexCount != DestBuffers[i].Buffer->getVertexCount())
|
DestBuffers[i].VertexCount != DestBuffers[i].Buffer->getVertexCount())
|
||||||
{
|
{
|
||||||
DestBuffers[i].IsDirty = true;
|
DestBuffers[i].IsDirty = true;
|
||||||
|
|
||||||
switch (DestBuffers[i].VertexType)
|
switch (DestBuffers[i].VertexType)
|
||||||
{
|
{
|
||||||
case video::EVT_STANDARD:
|
case video::EVT_STANDARD:
|
||||||
{
|
{
|
||||||
SMeshBuffer* mb = (SMeshBuffer*)DestBuffers[i].Buffer;
|
SMeshBuffer* mb = (SMeshBuffer*)DestBuffers[i].Buffer;
|
||||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case video::EVT_2TCOORDS:
|
case video::EVT_2TCOORDS:
|
||||||
{
|
{
|
||||||
SMeshBufferLightMap* mb = (SMeshBufferLightMap*)DestBuffers[i].Buffer;
|
SMeshBufferLightMap* mb = (SMeshBufferLightMap*)DestBuffers[i].Buffer;
|
||||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case video::EVT_TANGENTS:
|
case video::EVT_TANGENTS:
|
||||||
{
|
{
|
||||||
SMeshBufferTangents* mb = (SMeshBufferTangents*)DestBuffers[i].Buffer;
|
SMeshBufferTangents* mb = (SMeshBufferTangents*)DestBuffers[i].Buffer;
|
||||||
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
mb->Vertices.set_used(DestBuffers[i].VertexCount);
|
||||||
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
mb->Indices.set_used(DestBuffers[i].IndexCount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: // shouldn't ever happen
|
default: // shouldn't ever happen
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh dirty buffers from source
|
// refresh dirty buffers from source
|
||||||
for (i=0; i<BufferReferences.size(); ++i)
|
for (i=0; i<BufferReferences.size(); ++i)
|
||||||
{
|
{
|
||||||
if (DestBuffers[BufferReferences[i].DestReference].IsDirty)
|
if (DestBuffers[BufferReferences[i].DestReference].IsDirty)
|
||||||
{
|
{
|
||||||
updateDestFromSourceBuffer(i);
|
updateDestFromSourceBuffer(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate bounding boxes
|
// calculate bounding boxes
|
||||||
for (i=0; i< DestBuffers.size(); ++i)
|
for (i=0; i< DestBuffers.size(); ++i)
|
||||||
{
|
{
|
||||||
if (DestBuffers[i].IsDirty)
|
if (DestBuffers[i].IsDirty)
|
||||||
{
|
{
|
||||||
recalculateDestBufferBoundingBox(i);
|
recalculateDestBufferBoundingBox(i);
|
||||||
// reset dirty state too
|
// reset dirty state too
|
||||||
DestBuffers[i].IsDirty = false;
|
DestBuffers[i].IsDirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IsDirty = false;
|
IsDirty = false;
|
||||||
recalculateBoundingBox();
|
recalculateBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! adds a mesh to the buffers with the given offset
|
//! adds a mesh to the buffers with the given offset
|
||||||
/** \Returns Returns an array of ID numbers */
|
/** \Returns Returns an array of ID numbers */
|
||||||
core::array<s32> CBatchingMesh::addMesh(IMesh* mesh, core::vector3df pos, core::vector3df rot, core::vector3df scale)
|
core::array<s32> CBatchingMesh::addMesh(IMesh* mesh, core::vector3df pos, core::vector3df rot, core::vector3df scale)
|
||||||
{
|
{
|
||||||
core::matrix4 m;
|
core::matrix4 m;
|
||||||
m.setRotationDegrees(rot);
|
m.setRotationDegrees(rot);
|
||||||
m.setTranslation(pos);
|
m.setTranslation(pos);
|
||||||
|
|
||||||
core::matrix4 scalem;
|
core::matrix4 scalem;
|
||||||
scalem.setScale(scale);
|
scalem.setScale(scale);
|
||||||
m *= scalem;
|
m *= scalem;
|
||||||
|
|
||||||
return addMesh(mesh, m);
|
return addMesh(mesh, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! adds a mesh with the given transformation
|
//! adds a mesh with the given transformation
|
||||||
core::array<s32> CBatchingMesh::addMesh(IMesh* mesh, const core::matrix4 &transform)
|
core::array<s32> CBatchingMesh::addMesh(IMesh* mesh, const core::matrix4 &transform)
|
||||||
{
|
{
|
||||||
core::array<s32> bufferNos;
|
core::array<s32> bufferNos;
|
||||||
|
|
||||||
if (!mesh)
|
if (!mesh)
|
||||||
return bufferNos;
|
return bufferNos;
|
||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
for (i=0; i<mesh->getMeshBufferCount(); ++i)
|
for (i=0; i<mesh->getMeshBufferCount(); ++i)
|
||||||
bufferNos.push_back(addMeshBuffer(mesh->getMeshBuffer(i), transform));
|
bufferNos.push_back(addMeshBuffer(mesh->getMeshBuffer(i), transform));
|
||||||
|
|
||||||
return bufferNos;
|
return bufferNos;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! adds a mesh buffer with the given transformation
|
//! adds a mesh buffer with the given transformation
|
||||||
/** \Return Returns the ID of this mesh buffer */
|
/** \Return Returns the ID of this mesh buffer */
|
||||||
s32 CBatchingMesh::addMeshBuffer(IMeshBuffer* buffer, core::vector3df pos, core::vector3df rot, core::vector3df scale)
|
s32 CBatchingMesh::addMeshBuffer(IMeshBuffer* buffer, core::vector3df pos, core::vector3df rot, core::vector3df scale)
|
||||||
{
|
{
|
||||||
core::matrix4 m;
|
core::matrix4 m;
|
||||||
m.setRotationDegrees(rot);
|
m.setRotationDegrees(rot);
|
||||||
m.setTranslation(pos);
|
m.setTranslation(pos);
|
||||||
|
|
||||||
core::matrix4 scalem;
|
core::matrix4 scalem;
|
||||||
scalem.setScale(scale);
|
scalem.setScale(scale);
|
||||||
m *= scalem;
|
m *= scalem;
|
||||||
|
|
||||||
return addMeshBuffer(buffer, m);
|
return addMeshBuffer(buffer, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! adds a mesh with the given transformation
|
//! adds a mesh with the given transformation
|
||||||
/** \Return Returns the ID of this mesh buffer */
|
/** \Return Returns the ID of this mesh buffer */
|
||||||
s32 CBatchingMesh::addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform)
|
s32 CBatchingMesh::addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform)
|
||||||
{
|
{
|
||||||
if (!buffer || IsFinal)
|
if (!buffer || IsFinal)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
video::SMaterial m = buffer->getMaterial();
|
video::SMaterial m = buffer->getMaterial();
|
||||||
|
|
||||||
// find material
|
// find material
|
||||||
bool found=false;
|
bool found=false;
|
||||||
video::E_VERTEX_TYPE vt = buffer->getVertexType();
|
video::E_VERTEX_TYPE vt = buffer->getVertexType();
|
||||||
for (i=0; i<MaterialReferences.size(); ++i)
|
for (i=0; i<MaterialReferences.size(); ++i)
|
||||||
{
|
{
|
||||||
if (MaterialReferences[i].VertexType == vt &&
|
if (MaterialReferences[i].VertexType == vt &&
|
||||||
MaterialReferences[i].Material == m)
|
MaterialReferences[i].Material == m)
|
||||||
{
|
{
|
||||||
// will there be too many vertices in the buffer?
|
// will there be too many vertices in the buffer?
|
||||||
u32 newTotalI = buffer->getIndexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount;
|
u32 newTotalI = buffer->getIndexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount;
|
||||||
u32 newTotalV = buffer->getVertexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount;
|
u32 newTotalV = buffer->getVertexCount() + DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount;
|
||||||
|
|
||||||
if ( newTotalI < 65536*3 && newTotalV < 65536)
|
if ( newTotalI < 65536*3 && newTotalV < 65536)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount = newTotalI;
|
DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount = newTotalI;
|
||||||
DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount = newTotalV;
|
DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount = newTotalV;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
// we need a new destination buffer and material reference
|
// we need a new destination buffer and material reference
|
||||||
IMeshBuffer *mb=0;
|
IMeshBuffer *mb=0;
|
||||||
|
|
||||||
SMaterialReference r;
|
SMaterialReference r;
|
||||||
r.Material = m;
|
r.Material = m;
|
||||||
r.VertexType = vt;
|
r.VertexType = vt;
|
||||||
r.BufferIndex = DestBuffers.size();
|
r.BufferIndex = DestBuffers.size();
|
||||||
switch (vt)
|
switch (vt)
|
||||||
{
|
{
|
||||||
case video::EVT_STANDARD:
|
case video::EVT_STANDARD:
|
||||||
mb = (IMeshBuffer*)new SMeshBuffer();
|
mb = (IMeshBuffer*)new SMeshBuffer();
|
||||||
mb->getMaterial() = m;
|
mb->getMaterial() = m;
|
||||||
break;
|
break;
|
||||||
case video::EVT_2TCOORDS:
|
case video::EVT_2TCOORDS:
|
||||||
mb = (IMeshBuffer*)new SMeshBufferLightMap();
|
mb = (IMeshBuffer*)new SMeshBufferLightMap();
|
||||||
mb->getMaterial() = m;
|
mb->getMaterial() = m;
|
||||||
break;
|
break;
|
||||||
case video::EVT_TANGENTS:
|
case video::EVT_TANGENTS:
|
||||||
mb = (IMeshBuffer*)new SMeshBufferTangents();
|
mb = (IMeshBuffer*)new SMeshBufferTangents();
|
||||||
mb->getMaterial() = m;
|
mb->getMaterial() = m;
|
||||||
break;
|
break;
|
||||||
default: // unknown vertex type
|
default: // unknown vertex type
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
i = MaterialReferences.size();
|
i = MaterialReferences.size();
|
||||||
MaterialReferences.push_back(r);
|
MaterialReferences.push_back(r);
|
||||||
|
|
||||||
SDestBufferReference db;
|
SDestBufferReference db;
|
||||||
db.Buffer = mb;
|
db.Buffer = mb;
|
||||||
db.IndexCount = buffer->getIndexCount();
|
db.IndexCount = buffer->getIndexCount();
|
||||||
db.VertexCount = buffer->getVertexCount();
|
db.VertexCount = buffer->getVertexCount();
|
||||||
db.IsDirty = true;
|
db.IsDirty = true;
|
||||||
db.VertexType = vt;
|
db.VertexType = vt;
|
||||||
|
|
||||||
DestBuffers.push_back(db);
|
DestBuffers.push_back(db);
|
||||||
}
|
}
|
||||||
// now we add the mesh reference
|
// now we add the mesh reference
|
||||||
SBufferReference r;
|
SBufferReference r;
|
||||||
r.DestReference = i;
|
r.DestReference = i;
|
||||||
r.SourceBuffer = buffer;
|
r.SourceBuffer = buffer;
|
||||||
r.Transform = transform;
|
r.Transform = transform;
|
||||||
r.IndexCount = buffer->getIndexCount();
|
r.IndexCount = buffer->getIndexCount();
|
||||||
r.VertexCount = buffer->getVertexCount();
|
r.VertexCount = buffer->getVertexCount();
|
||||||
r.FirstIndex = DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount - r.IndexCount;
|
r.FirstIndex = DestBuffers[ MaterialReferences[i].BufferIndex ].IndexCount - r.IndexCount;
|
||||||
r.FirstVertex = DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount - r.VertexCount;
|
r.FirstVertex = DestBuffers[ MaterialReferences[i].BufferIndex ].VertexCount - r.VertexCount;
|
||||||
r.Initialized = false;
|
r.Initialized = false;
|
||||||
BufferReferences.push_back(r);
|
BufferReferences.push_back(r);
|
||||||
addSourceBuffer(buffer);
|
addSourceBuffer(buffer);
|
||||||
|
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
return BufferReferences.size()-1;
|
return BufferReferences.size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! updates bouding box from internal buffers
|
//! updates bouding box from internal buffers
|
||||||
void CBatchingMesh::recalculateBoundingBox()
|
void CBatchingMesh::recalculateBoundingBox()
|
||||||
{
|
{
|
||||||
if (DestBuffers.size() == 0)
|
if (DestBuffers.size() == 0)
|
||||||
Box.reset(0,0,0);
|
Box.reset(0,0,0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Box.reset(DestBuffers[0].Buffer->getBoundingBox().MinEdge);
|
Box.reset(DestBuffers[0].Buffer->getBoundingBox().MinEdge);
|
||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
for (i=0; i < DestBuffers.size(); ++i)
|
for (i=0; i < DestBuffers.size(); ++i)
|
||||||
Box.addInternalBox(DestBuffers[i].Buffer->getBoundingBox());
|
Box.addInternalBox(DestBuffers[i].Buffer->getBoundingBox());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ void CBatchingMesh::recalculateBoundingBox()
|
|||||||
/** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */
|
/** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */
|
||||||
u32 CBatchingMesh::getMeshBufferCount() const
|
u32 CBatchingMesh::getMeshBufferCount() const
|
||||||
{
|
{
|
||||||
return DestBuffers.size();
|
return DestBuffers.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns pointer to a mesh buffer.
|
//! Returns pointer to a mesh buffer.
|
||||||
@ -259,29 +259,29 @@ getMeshBufferCount() - 1;
|
|||||||
NULL if there is no such mesh buffer. */
|
NULL if there is no such mesh buffer. */
|
||||||
IMeshBuffer* CBatchingMesh::getMeshBuffer(u32 nr) const
|
IMeshBuffer* CBatchingMesh::getMeshBuffer(u32 nr) const
|
||||||
{
|
{
|
||||||
if (nr < DestBuffers.size())
|
if (nr < DestBuffers.size())
|
||||||
return DestBuffers[nr].Buffer;
|
return DestBuffers[nr].Buffer;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns pointer to a mesh buffer which fits a material
|
//! Returns pointer to a mesh buffer which fits a material
|
||||||
IMeshBuffer* CBatchingMesh::getMeshBuffer( const video::SMaterial &material) const
|
IMeshBuffer* CBatchingMesh::getMeshBuffer( const video::SMaterial &material) const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns an axis aligned bounding box of the mesh.
|
//! Returns an axis aligned bounding box of the mesh.
|
||||||
/** \return A bounding box of this mesh is returned. */
|
/** \return A bounding box of this mesh is returned. */
|
||||||
const core::aabbox3d<f32>& CBatchingMesh::getBoundingBox() const
|
const core::aabbox3d<f32>& CBatchingMesh::getBoundingBox() const
|
||||||
{
|
{
|
||||||
return Box;
|
return Box;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! set user axis aligned bounding box
|
//! set user axis aligned bounding box
|
||||||
void CBatchingMesh::setBoundingBox( const core::aabbox3df& box)
|
void CBatchingMesh::setBoundingBox( const core::aabbox3df& box)
|
||||||
{
|
{
|
||||||
Box = box;
|
Box = box;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Sets a flag of all contained materials to a new value.
|
//! Sets a flag of all contained materials to a new value.
|
||||||
@ -289,218 +289,218 @@ void CBatchingMesh::setBoundingBox( const core::aabbox3df& box)
|
|||||||
\param newvalue: New value to set in all materials. */
|
\param newvalue: New value to set in all materials. */
|
||||||
void CBatchingMesh::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
|
void CBatchingMesh::setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
|
||||||
{
|
{
|
||||||
for (u32 i=0; i<DestBuffers.size(); ++i)
|
for (u32 i=0; i<DestBuffers.size(); ++i)
|
||||||
DestBuffers[i].Buffer->getMaterial().setFlag(flag, newvalue);
|
DestBuffers[i].Buffer->getMaterial().setFlag(flag, newvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! drops all buffers and clears internal states
|
//! drops all buffers and clears internal states
|
||||||
void CBatchingMesh::clear()
|
void CBatchingMesh::clear()
|
||||||
{
|
{
|
||||||
u32 i;
|
u32 i;
|
||||||
for (i=0; i < DestBuffers.size(); ++i)
|
for (i=0; i < DestBuffers.size(); ++i)
|
||||||
DestBuffers[i].Buffer->drop();
|
DestBuffers[i].Buffer->drop();
|
||||||
|
|
||||||
for (i=0; i < SourceBuffers.size(); ++i)
|
for (i=0; i < SourceBuffers.size(); ++i)
|
||||||
SourceBuffers[i]->drop();
|
SourceBuffers[i]->drop();
|
||||||
|
|
||||||
BufferReferences.clear();
|
BufferReferences.clear();
|
||||||
MaterialReferences.clear();
|
MaterialReferences.clear();
|
||||||
DestBuffers.clear();
|
DestBuffers.clear();
|
||||||
SourceBuffers.clear();
|
SourceBuffers.clear();
|
||||||
|
|
||||||
IsDirty = false;
|
IsDirty = false;
|
||||||
IsFinal = false;
|
IsFinal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! first updates the mesh, then drops all source buffers.
|
//! first updates the mesh, then drops all source buffers.
|
||||||
/** once this mesh has been finalized, it cannot be changed again! */
|
/** once this mesh has been finalized, it cannot be changed again! */
|
||||||
void CBatchingMesh::finalize()
|
void CBatchingMesh::finalize()
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
|
||||||
for (u32 i=0; i < SourceBuffers.size(); ++i)
|
for (u32 i=0; i < SourceBuffers.size(); ++i)
|
||||||
SourceBuffers[i]->drop();
|
SourceBuffers[i]->drop();
|
||||||
|
|
||||||
SourceBuffers.clear();
|
SourceBuffers.clear();
|
||||||
|
|
||||||
IsFinal = true;
|
IsFinal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Moves a mesh
|
//! Moves a mesh
|
||||||
core::array<bool> CBatchingMesh::moveMesh(const core::array<s32>& bufferIDs, const core::matrix4 &newMatrix)
|
core::array<bool> CBatchingMesh::moveMesh(const core::array<s32>& bufferIDs, const core::matrix4 &newMatrix)
|
||||||
{
|
{
|
||||||
core::array<bool> result;
|
core::array<bool> result;
|
||||||
result.reallocate(bufferIDs.size());
|
result.reallocate(bufferIDs.size());
|
||||||
for (u32 i=0; i<bufferIDs.size(); ++i)
|
for (u32 i=0; i<bufferIDs.size(); ++i)
|
||||||
result.push_back(moveMeshBuffer(bufferIDs[i], newMatrix));
|
result.push_back(moveMeshBuffer(bufferIDs[i], newMatrix));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Moves a mesh buffer
|
//! Moves a mesh buffer
|
||||||
bool CBatchingMesh::moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix)
|
bool CBatchingMesh::moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix)
|
||||||
{
|
{
|
||||||
if ((u32)id > BufferReferences.size() || IsFinal )
|
if ((u32)id > BufferReferences.size() || IsFinal )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BufferReferences[id].Transform = newMatrix;
|
BufferReferences[id].Transform = newMatrix;
|
||||||
|
|
||||||
// is the source buffer dirty?
|
// is the source buffer dirty?
|
||||||
if (!DestBuffers[BufferReferences[id].DestReference].IsDirty)
|
if (!DestBuffers[BufferReferences[id].DestReference].IsDirty)
|
||||||
{
|
{
|
||||||
// transform each vertex and normal
|
// transform each vertex and normal
|
||||||
updateDestFromSourceBuffer(id);
|
updateDestFromSourceBuffer(id);
|
||||||
recalculateDestBufferBoundingBox(BufferReferences[id].DestReference);
|
recalculateDestBufferBoundingBox(BufferReferences[id].DestReference);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! returns the source buffer, if available
|
//! returns the source buffer, if available
|
||||||
IMeshBuffer* CBatchingMesh::getSourceBuffer(s32 id)
|
IMeshBuffer* CBatchingMesh::getSourceBuffer(s32 id)
|
||||||
{
|
{
|
||||||
if ((u32)id > BufferReferences.size() || IsFinal)
|
if ((u32)id > BufferReferences.size() || IsFinal)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return BufferReferences[id].SourceBuffer;
|
return BufferReferences[id].SourceBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! returns the matrix of the source buffer
|
//! returns the matrix of the source buffer
|
||||||
core::matrix4 CBatchingMesh::getSourceBufferMatrix(s32 id)
|
core::matrix4 CBatchingMesh::getSourceBufferMatrix(s32 id)
|
||||||
{
|
{
|
||||||
core::matrix4 ret;
|
core::matrix4 ret;
|
||||||
if ((u32)id > BufferReferences.size() || IsFinal)
|
if ((u32)id > BufferReferences.size() || IsFinal)
|
||||||
ret.makeIdentity();
|
ret.makeIdentity();
|
||||||
else
|
else
|
||||||
ret = BufferReferences[id].Transform;
|
ret = BufferReferences[id].Transform;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! returns the number of source buffers
|
//! returns the number of source buffers
|
||||||
u32 CBatchingMesh::getSourceBufferCount() const
|
u32 CBatchingMesh::getSourceBufferCount() const
|
||||||
{
|
{
|
||||||
return BufferReferences.size();
|
return BufferReferences.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// private functions
|
// private functions
|
||||||
|
|
||||||
void CBatchingMesh::recalculateDestBufferBoundingBox(u32 i)
|
void CBatchingMesh::recalculateDestBufferBoundingBox(u32 i)
|
||||||
{
|
{
|
||||||
switch (DestBuffers[i].VertexType)
|
switch (DestBuffers[i].VertexType)
|
||||||
{
|
{
|
||||||
case video::EVT_STANDARD:
|
case video::EVT_STANDARD:
|
||||||
((SMeshBuffer*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
((SMeshBuffer*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||||
break;
|
break;
|
||||||
case video::EVT_2TCOORDS:
|
case video::EVT_2TCOORDS:
|
||||||
((SMeshBufferLightMap*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
((SMeshBufferLightMap*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||||
break;
|
break;
|
||||||
case video::EVT_TANGENTS:
|
case video::EVT_TANGENTS:
|
||||||
((SMeshBufferTangents*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
((SMeshBufferTangents*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBatchingMesh::updateDestFromSourceBuffer(u32 i)
|
void CBatchingMesh::updateDestFromSourceBuffer(u32 i)
|
||||||
{
|
{
|
||||||
u16* ind = BufferReferences[i].SourceBuffer->getIndices();
|
u16* ind = BufferReferences[i].SourceBuffer->getIndices();
|
||||||
void*ver = BufferReferences[i].SourceBuffer->getVertices();
|
void*ver = BufferReferences[i].SourceBuffer->getVertices();
|
||||||
core::matrix4 m = BufferReferences[i].Transform;
|
core::matrix4 m = BufferReferences[i].Transform;
|
||||||
u32 fi = BufferReferences[i].FirstIndex;
|
u32 fi = BufferReferences[i].FirstIndex;
|
||||||
u32 fv = BufferReferences[i].FirstVertex;
|
u32 fv = BufferReferences[i].FirstVertex;
|
||||||
u32 ic = BufferReferences[i].IndexCount;
|
u32 ic = BufferReferences[i].IndexCount;
|
||||||
u32 vc = BufferReferences[i].VertexCount;
|
u32 vc = BufferReferences[i].VertexCount;
|
||||||
u32 x;
|
u32 x;
|
||||||
video::E_VERTEX_TYPE vt = DestBuffers[BufferReferences[i].DestReference].VertexType;
|
video::E_VERTEX_TYPE vt = DestBuffers[BufferReferences[i].DestReference].VertexType;
|
||||||
switch (vt)
|
switch (vt)
|
||||||
{
|
{
|
||||||
case video::EVT_STANDARD:
|
case video::EVT_STANDARD:
|
||||||
{
|
{
|
||||||
SMeshBuffer* dest = (SMeshBuffer*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
SMeshBuffer* dest = (SMeshBuffer*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||||
|
|
||||||
for (x=fi; x < fi+ic; ++x)
|
for (x=fi; x < fi+ic; ++x)
|
||||||
dest->Indices[x] = ind[x-fi]+fv;
|
dest->Indices[x] = ind[x-fi]+fv;
|
||||||
|
|
||||||
video::S3DVertex* vertices= (video::S3DVertex*) ver;
|
video::S3DVertex* vertices= (video::S3DVertex*) ver;
|
||||||
|
|
||||||
for (x=fv; x < fv+vc; ++x)
|
for (x=fv; x < fv+vc; ++x)
|
||||||
{
|
{
|
||||||
dest->Vertices[x] = vertices[x-fv];
|
dest->Vertices[x] = vertices[x-fv];
|
||||||
m.transformVect(dest->Vertices[x].Pos);
|
m.transformVect(dest->Vertices[x].Pos);
|
||||||
m.rotateVect(dest->Vertices[x].Normal);
|
m.rotateVect(dest->Vertices[x].Normal);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case video::EVT_2TCOORDS:
|
case video::EVT_2TCOORDS:
|
||||||
{
|
{
|
||||||
SMeshBufferLightMap* dest = (SMeshBufferLightMap*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
SMeshBufferLightMap* dest = (SMeshBufferLightMap*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||||
|
|
||||||
for (x=fi; x < fi+ic; ++x)
|
for (x=fi; x < fi+ic; ++x)
|
||||||
dest->Indices[x] = ind[x-fi]+fv;
|
dest->Indices[x] = ind[x-fi]+fv;
|
||||||
|
|
||||||
video::S3DVertex2TCoords* vertices= (video::S3DVertex2TCoords*) ver;
|
video::S3DVertex2TCoords* vertices= (video::S3DVertex2TCoords*) ver;
|
||||||
|
|
||||||
for (x=fv; x < fv+vc; ++x)
|
for (x=fv; x < fv+vc; ++x)
|
||||||
{
|
{
|
||||||
dest->Vertices[x] = vertices[x-fv];
|
dest->Vertices[x] = vertices[x-fv];
|
||||||
m.transformVect(dest->Vertices[x].Pos);
|
m.transformVect(dest->Vertices[x].Pos);
|
||||||
m.rotateVect(dest->Vertices[x].Normal);
|
m.rotateVect(dest->Vertices[x].Normal);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case video::EVT_TANGENTS:
|
case video::EVT_TANGENTS:
|
||||||
{
|
{
|
||||||
SMeshBufferTangents* dest = (SMeshBufferTangents*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
SMeshBufferTangents* dest = (SMeshBufferTangents*) DestBuffers[BufferReferences[i].DestReference].Buffer;
|
||||||
|
|
||||||
for (x=fi; x < fi+ic; ++x)
|
for (x=fi; x < fi+ic; ++x)
|
||||||
dest->Indices[x] = ind[x-fi]+fv;
|
dest->Indices[x] = ind[x-fi]+fv;
|
||||||
|
|
||||||
video::S3DVertexTangents* vertices= (video::S3DVertexTangents*) ver;
|
video::S3DVertexTangents* vertices= (video::S3DVertexTangents*) ver;
|
||||||
|
|
||||||
for (x=fv; x < fv+vc; ++x)
|
for (x=fv; x < fv+vc; ++x)
|
||||||
{
|
{
|
||||||
dest->Vertices[x] = vertices[x-fv];
|
dest->Vertices[x] = vertices[x-fv];
|
||||||
m.transformVect(dest->Vertices[x].Pos);
|
m.transformVect(dest->Vertices[x].Pos);
|
||||||
m.rotateVect(dest->Vertices[x].Normal); // are tangents/binormals in face space?
|
m.rotateVect(dest->Vertices[x].Normal); // are tangents/binormals in face space?
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBatchingMesh::addSourceBuffer(IMeshBuffer *source)
|
void CBatchingMesh::addSourceBuffer(IMeshBuffer *source)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (u32 i=0; i<SourceBuffers.size(); ++i)
|
for (u32 i=0; i<SourceBuffers.size(); ++i)
|
||||||
{
|
{
|
||||||
if (SourceBuffers[i] == source)
|
if (SourceBuffers[i] == source)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
source->grab();
|
source->grab();
|
||||||
SourceBuffers.push_back(source);
|
SourceBuffers.push_back(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBatchingMesh::setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type)
|
void CBatchingMesh::setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type)
|
||||||
{
|
{
|
||||||
for (u32 i=0; i < DestBuffers.size(); ++i)
|
for (u32 i=0; i < DestBuffers.size(); ++i)
|
||||||
DestBuffers[i].Buffer->setHardwareMappingHint(mapping, type);
|
DestBuffers[i].Buffer->setHardwareMappingHint(mapping, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CBatchingMesh::setDirty(E_BUFFER_TYPE type)
|
void CBatchingMesh::setDirty(E_BUFFER_TYPE type)
|
||||||
{
|
{
|
||||||
for (u32 i=0; i < DestBuffers.size(); ++i)
|
for (u32 i=0; i < DestBuffers.size(); ++i)
|
||||||
DestBuffers[i].Buffer->setDirty(type);
|
DestBuffers[i].Buffer->setDirty(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace scene
|
} // namespace scene
|
||||||
|
@ -15,157 +15,157 @@ namespace scene
|
|||||||
class CBatchingMesh : public IMesh
|
class CBatchingMesh : public IMesh
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CBatchingMesh();
|
CBatchingMesh();
|
||||||
|
|
||||||
virtual ~CBatchingMesh();
|
virtual ~CBatchingMesh();
|
||||||
|
|
||||||
//! returns true if new buffers have been added without updating the internal buffers
|
//! returns true if new buffers have been added without updating the internal buffers
|
||||||
bool isDirty(s32 id=-1);
|
bool isDirty(s32 id=-1);
|
||||||
|
|
||||||
//! refreshes the internal buffers from source
|
//! refreshes the internal buffers from source
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
//! drops all buffers and clears internal states
|
//! drops all buffers and clears internal states
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
//! first updates the mesh, then drops all source buffers.
|
//! first updates the mesh, then drops all source buffers.
|
||||||
/** once this mesh has been finalized, it cannot be changed again! */
|
/** once this mesh has been finalized, it cannot be changed again! */
|
||||||
void finalize();
|
void finalize();
|
||||||
|
|
||||||
//! adds a mesh to the buffers with the given offset
|
//! adds a mesh to the buffers with the given offset
|
||||||
/** \Return: Returns an array of ID numbers */
|
/** \Return: Returns an array of ID numbers */
|
||||||
core::array<s32> addMesh(IMesh* mesh,
|
core::array<s32> addMesh(IMesh* mesh,
|
||||||
core::vector3df pos = core::vector3df(0,0,0),
|
core::vector3df pos = core::vector3df(0,0,0),
|
||||||
core::vector3df rot = core::vector3df(0,0,0),
|
core::vector3df rot = core::vector3df(0,0,0),
|
||||||
core::vector3df scale = core::vector3df(1,1,1));
|
core::vector3df scale = core::vector3df(1,1,1));
|
||||||
|
|
||||||
//! adds a mesh with the given transformation
|
//! adds a mesh with the given transformation
|
||||||
/** \Return: Returns an array of ID numbers */
|
/** \Return: Returns an array of ID numbers */
|
||||||
core::array<s32> addMesh(IMesh* mesh, const core::matrix4 &transform);
|
core::array<s32> addMesh(IMesh* mesh, const core::matrix4 &transform);
|
||||||
|
|
||||||
//! adds a mesh buffer with the given transformation
|
//! adds a mesh buffer with the given transformation
|
||||||
/** \Return: Returns the ID of this mesh buffer */
|
/** \Return: Returns the ID of this mesh buffer */
|
||||||
s32 addMeshBuffer(IMeshBuffer* buffer,
|
s32 addMeshBuffer(IMeshBuffer* buffer,
|
||||||
core::vector3df pos = core::vector3df(0,0,0),
|
core::vector3df pos = core::vector3df(0,0,0),
|
||||||
core::vector3df rot = core::vector3df(0,0,0),
|
core::vector3df rot = core::vector3df(0,0,0),
|
||||||
core::vector3df scale = core::vector3df(1,1,1));
|
core::vector3df scale = core::vector3df(1,1,1));
|
||||||
|
|
||||||
//! adds a mesh with the given transformation
|
//! adds a mesh with the given transformation
|
||||||
/** \Return Returns the ID of this mesh buffer */
|
/** \Return Returns the ID of this mesh buffer */
|
||||||
s32 addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform);
|
s32 addMeshBuffer(IMeshBuffer* buffer, const core::matrix4 &transform);
|
||||||
|
|
||||||
//! updates bouding box from internal buffers
|
//! updates bouding box from internal buffers
|
||||||
void recalculateBoundingBox();
|
void recalculateBoundingBox();
|
||||||
|
|
||||||
//! Moves a mesh,
|
//! Moves a mesh,
|
||||||
/** mesh buffers in clean destination buffers will be moved immediately,
|
/** mesh buffers in clean destination buffers will be moved immediately,
|
||||||
ones in dirty buffers will be left until the next update */
|
ones in dirty buffers will be left until the next update */
|
||||||
core::array<bool> moveMesh(const core::array<s32>& bufferIDs, const core::matrix4 &newMatrix);
|
core::array<bool> moveMesh(const core::array<s32>& bufferIDs, const core::matrix4 &newMatrix);
|
||||||
|
|
||||||
//! Moves a mesh buffer
|
//! Moves a mesh buffer
|
||||||
/** if the destination buffer is clean it will be moved immediately,
|
/** if the destination buffer is clean it will be moved immediately,
|
||||||
if a member of a dirty buffer, it will be left until the next update */
|
if a member of a dirty buffer, it will be left until the next update */
|
||||||
bool moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix);
|
bool moveMeshBuffer(const s32 id, const core::matrix4 &newMatrix);
|
||||||
|
|
||||||
//! returns the source buffer, if available
|
//! returns the source buffer, if available
|
||||||
IMeshBuffer* getSourceBuffer(s32 id);
|
IMeshBuffer* getSourceBuffer(s32 id);
|
||||||
|
|
||||||
//! returns the matrix of the source buffer
|
//! returns the matrix of the source buffer
|
||||||
core::matrix4 getSourceBufferMatrix(s32 id);
|
core::matrix4 getSourceBufferMatrix(s32 id);
|
||||||
|
|
||||||
//! returns the number of source buffers
|
//! returns the number of source buffers
|
||||||
u32 getSourceBufferCount() const;
|
u32 getSourceBufferCount() const;
|
||||||
|
|
||||||
/* Standard IMesh functions */
|
/* Standard IMesh functions */
|
||||||
|
|
||||||
//! Returns the amount of mesh buffers.
|
//! Returns the amount of mesh buffers.
|
||||||
/** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */
|
/** \return Returns the amount of mesh buffers (IMeshBuffer) in this mesh. */
|
||||||
virtual u32 getMeshBufferCount() const;
|
virtual u32 getMeshBufferCount() const;
|
||||||
|
|
||||||
//! Returns pointer to a mesh buffer.
|
//! Returns pointer to a mesh buffer.
|
||||||
/** \param nr: Zero based index of the mesh buffer. The maximum value is
|
/** \param nr: Zero based index of the mesh buffer. The maximum value is
|
||||||
getMeshBufferCount() - 1;
|
getMeshBufferCount() - 1;
|
||||||
\return Returns the pointer to the mesh buffer or
|
\return Returns the pointer to the mesh buffer or
|
||||||
NULL if there is no such mesh buffer. */
|
NULL if there is no such mesh buffer. */
|
||||||
virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
|
virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
|
||||||
|
|
||||||
//! Returns pointer to a mesh buffer which fits a material
|
//! Returns pointer to a mesh buffer which fits a material
|
||||||
/** \param material: material to search for
|
/** \param material: material to search for
|
||||||
\return Returns the pointer to the mesh buffer or
|
\return Returns the pointer to the mesh buffer or
|
||||||
NULL if there is no such mesh buffer. */
|
NULL if there is no such mesh buffer. */
|
||||||
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const;
|
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const;
|
||||||
|
|
||||||
//! Returns an axis aligned bounding box of the mesh.
|
//! Returns an axis aligned bounding box of the mesh.
|
||||||
/** \return A bounding box of this mesh is returned. */
|
/** \return A bounding box of this mesh is returned. */
|
||||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||||
|
|
||||||
//! set user axis aligned bounding box
|
//! set user axis aligned bounding box
|
||||||
virtual void setBoundingBox( const core::aabbox3df& box);
|
virtual void setBoundingBox( const core::aabbox3df& box);
|
||||||
|
|
||||||
//! Sets a flag of all contained materials to a new value.
|
//! Sets a flag of all contained materials to a new value.
|
||||||
/** \param flag: Flag to set in all materials.
|
/** \param flag: Flag to set in all materials.
|
||||||
\param newvalue: New value to set in all materials. */
|
\param newvalue: New value to set in all materials. */
|
||||||
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
|
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
|
||||||
|
|
||||||
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type);
|
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING mapping, E_BUFFER_TYPE type);
|
||||||
|
|
||||||
virtual void setDirty(E_BUFFER_TYPE type);
|
virtual void setDirty(E_BUFFER_TYPE type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// add a buffer to the source buffers array if it doesn't already exist
|
// add a buffer to the source buffers array if it doesn't already exist
|
||||||
void addSourceBuffer(IMeshBuffer* source);
|
void addSourceBuffer(IMeshBuffer* source);
|
||||||
|
|
||||||
// updates the vertices in dest buffer from the source one
|
// updates the vertices in dest buffer from the source one
|
||||||
void updateDestFromSourceBuffer(u32 id);
|
void updateDestFromSourceBuffer(u32 id);
|
||||||
|
|
||||||
// recalculates the bounding box for the given dest buffer
|
// recalculates the bounding box for the given dest buffer
|
||||||
void recalculateDestBufferBoundingBox(u32 i);
|
void recalculateDestBufferBoundingBox(u32 i);
|
||||||
|
|
||||||
struct SBufferReference
|
struct SBufferReference
|
||||||
{
|
{
|
||||||
SBufferReference()
|
SBufferReference()
|
||||||
: SourceBuffer(0), DestReference(0), FirstVertex(0), VertexCount(0),
|
: SourceBuffer(0), DestReference(0), FirstVertex(0), VertexCount(0),
|
||||||
FirstIndex(0), IndexCount(0), Initialized(false) { }
|
FirstIndex(0), IndexCount(0), Initialized(false) { }
|
||||||
|
|
||||||
IMeshBuffer* SourceBuffer;
|
IMeshBuffer* SourceBuffer;
|
||||||
u32 DestReference;
|
u32 DestReference;
|
||||||
u32 FirstVertex, VertexCount, FirstIndex, IndexCount;
|
u32 FirstVertex, VertexCount, FirstIndex, IndexCount;
|
||||||
core::matrix4 Transform;
|
core::matrix4 Transform;
|
||||||
bool Initialized;
|
bool Initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMaterialReference
|
struct SMaterialReference
|
||||||
{
|
{
|
||||||
video::SMaterial Material;
|
video::SMaterial Material;
|
||||||
video::E_VERTEX_TYPE VertexType;
|
video::E_VERTEX_TYPE VertexType;
|
||||||
u32 BufferIndex;
|
u32 BufferIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SDestBufferReference
|
struct SDestBufferReference
|
||||||
{
|
{
|
||||||
IMeshBuffer* Buffer;
|
IMeshBuffer* Buffer;
|
||||||
video::E_VERTEX_TYPE VertexType;
|
video::E_VERTEX_TYPE VertexType;
|
||||||
u32 VertexCount;
|
u32 VertexCount;
|
||||||
u32 IndexCount;
|
u32 IndexCount;
|
||||||
bool IsDirty;
|
bool IsDirty;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Source mesh buffers, these are locked
|
//! Source mesh buffers, these are locked
|
||||||
core::array<IMeshBuffer*> SourceBuffers;
|
core::array<IMeshBuffer*> SourceBuffers;
|
||||||
|
|
||||||
core::array<SBufferReference> BufferReferences;
|
core::array<SBufferReference> BufferReferences;
|
||||||
core::array<SMaterialReference> MaterialReferences;
|
core::array<SMaterialReference> MaterialReferences;
|
||||||
core::array<SDestBufferReference> DestBuffers;
|
core::array<SDestBufferReference> DestBuffers;
|
||||||
|
|
||||||
//! bounding containing all destination buffers
|
//! bounding containing all destination buffers
|
||||||
core::aabbox3d<f32> Box;
|
core::aabbox3d<f32> Box;
|
||||||
|
|
||||||
//! does it require an update?
|
//! does it require an update?
|
||||||
bool IsDirty;
|
bool IsDirty;
|
||||||
|
|
||||||
//! can it be changed?
|
//! can it be changed?
|
||||||
bool IsFinal;
|
bool IsFinal;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace scene
|
} // namespace scene
|
||||||
|
@ -130,7 +130,7 @@ void SkyboxProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
|||||||
|
|
||||||
vector3df sun_pos = m_sunpos;
|
vector3df sun_pos = m_sunpos;
|
||||||
srv->setVertexShaderConstant("sun_pos", &sun_pos.X, 3);
|
srv->setVertexShaderConstant("sun_pos", &sun_pos.X, 3);
|
||||||
|
|
||||||
core::matrix4 ModelViewProjectionMatrix = srv->getVideoDriver()->getTransform(ETS_PROJECTION);
|
core::matrix4 ModelViewProjectionMatrix = srv->getVideoDriver()->getTransform(ETS_PROJECTION);
|
||||||
ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_VIEW);
|
ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_VIEW);
|
||||||
ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_WORLD);
|
ModelViewProjectionMatrix *= srv->getVideoDriver()->getTransform(ETS_WORLD);
|
||||||
@ -558,21 +558,21 @@ void DisplaceProvider::OnSetConstants(IMaterialRendererServices *srv, int)
|
|||||||
|
|
||||||
void DisplaceProvider::update()
|
void DisplaceProvider::update()
|
||||||
{
|
{
|
||||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||||
const float speed = World::getWorld()->getTrack()->getDisplacementSpeed();
|
const float speed = World::getWorld()->getTrack()->getDisplacementSpeed();
|
||||||
|
|
||||||
float strength = time;
|
float strength = time;
|
||||||
strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.002f;
|
strength = fabsf(noise2d(strength / 10.0f)) * 0.006f + 0.002f;
|
||||||
|
|
||||||
vector3df wind = irr_driver->getWind() * strength * speed;
|
vector3df wind = irr_driver->getWind() * strength * speed;
|
||||||
m_dir[0] += wind.X;
|
m_dir[0] += wind.X;
|
||||||
m_dir[1] += wind.Z;
|
m_dir[1] += wind.Z;
|
||||||
|
|
||||||
strength = time * 0.56f + sinf(time);
|
strength = time * 0.56f + sinf(time);
|
||||||
strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.0025f;
|
strength = fabsf(noise2d(0.0, strength / 6.0f)) * 0.0095f + 0.0025f;
|
||||||
|
|
||||||
wind = irr_driver->getWind() * strength * speed;
|
wind = irr_driver->getWind() * strength * speed;
|
||||||
wind.rotateXZBy(cosf(time));
|
wind.rotateXZBy(cosf(time));
|
||||||
m_dir2[0] += wind.X;
|
m_dir2[0] += wind.X;
|
||||||
m_dir2[1] += wind.Z;
|
m_dir2[1] += wind.Z;
|
||||||
}
|
}
|
||||||
|
@ -121,15 +121,15 @@ public:
|
|||||||
m_amplitude = amp;
|
m_amplitude = amp;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getSpeed() const
|
float getSpeed() const
|
||||||
{
|
{
|
||||||
return m_speed;
|
return m_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getAmplitude() const
|
float getAmplitude() const
|
||||||
{
|
{
|
||||||
return m_amplitude;
|
return m_amplitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_amplitude, m_speed;
|
float m_amplitude, m_speed;
|
||||||
@ -141,7 +141,7 @@ class SkyboxProvider: public CallBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
|
virtual void OnSetConstants(video::IMaterialRendererServices *srv, int);
|
||||||
|
|
||||||
void setSunPosition(const core::vector3df &in)
|
void setSunPosition(const core::vector3df &in)
|
||||||
{
|
{
|
||||||
m_sunpos = in;
|
m_sunpos = in;
|
||||||
@ -327,20 +327,20 @@ public:
|
|||||||
m_color[2] = b;
|
m_color[2] = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getRed() const
|
float getRed() const
|
||||||
{
|
{
|
||||||
return m_color[0];
|
return m_color[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
float getGreen() const
|
float getGreen() const
|
||||||
{
|
{
|
||||||
return m_color[1];
|
return m_color[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
float getBlue() const
|
float getBlue() const
|
||||||
{
|
{
|
||||||
return m_color[2];
|
return m_color[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_color[3];
|
float m_color[3];
|
||||||
@ -375,7 +375,7 @@ public:
|
|||||||
m_color[1] = g;
|
m_color[1] = g;
|
||||||
m_color[2] = b;
|
m_color[2] = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getRed() const
|
float getRed() const
|
||||||
{
|
{
|
||||||
return m_color[0];
|
return m_color[0];
|
||||||
@ -385,7 +385,7 @@ public:
|
|||||||
{
|
{
|
||||||
return m_color[1];
|
return m_color[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
float getBlue() const
|
float getBlue() const
|
||||||
{
|
{
|
||||||
return m_color[2];
|
return m_color[2];
|
||||||
@ -405,7 +405,7 @@ public:
|
|||||||
m_pos[1] = pos.Y;
|
m_pos[1] = pos.Y;
|
||||||
m_pos[2] = pos.Z;
|
m_pos[2] = pos.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
core::vector3df getPosition() const
|
core::vector3df getPosition() const
|
||||||
{
|
{
|
||||||
return core::vector3df(m_pos[0], m_pos[1], m_pos[2]);
|
return core::vector3df(m_pos[0], m_pos[1], m_pos[2]);
|
||||||
@ -555,27 +555,27 @@ public:
|
|||||||
m_dir[0] = m_dir[1] = m_dir2[0] = m_dir2[1] = 0;
|
m_dir[0] = m_dir[1] = m_dir2[0] = m_dir2[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
float getDirX() const
|
float getDirX() const
|
||||||
{
|
{
|
||||||
return m_dir[0];
|
return m_dir[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
float getDirY() const
|
float getDirY() const
|
||||||
{
|
{
|
||||||
return m_dir[1];
|
return m_dir[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
float getDir2X() const
|
float getDir2X() const
|
||||||
{
|
{
|
||||||
return m_dir2[0];
|
return m_dir2[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
float getDir2Y() const
|
float getDir2Y() const
|
||||||
{
|
{
|
||||||
return m_dir2[1];
|
return m_dir2[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_screen[2];
|
float m_screen[2];
|
||||||
|
@ -39,7 +39,7 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char
|
|||||||
{
|
{
|
||||||
// short emision time, explosion, not constant flame
|
// short emision time, explosion, not constant flame
|
||||||
m_remaining_time = burst_time;
|
m_remaining_time = burst_time;
|
||||||
|
|
||||||
ParticleKindManager* pkm = ParticleKindManager::get();
|
ParticleKindManager* pkm = ParticleKindManager::get();
|
||||||
ParticleKind* particles = pkm->getParticles(particle_file);
|
ParticleKind* particles = pkm->getParticles(particle_file);
|
||||||
m_emitter = new ParticleEmitter(particles, coord, NULL);
|
m_emitter = new ParticleEmitter(particles, coord, NULL);
|
||||||
@ -72,7 +72,7 @@ bool Explosion::updateAndDelete(float dt)
|
|||||||
if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time)
|
if (m_remaining_time < 0.0f && m_remaining_time >= -explosion_time)
|
||||||
{
|
{
|
||||||
scene::ISceneNode* node = m_emitter->getNode();
|
scene::ISceneNode* node = m_emitter->getNode();
|
||||||
|
|
||||||
const int intensity = (int)(255-(m_remaining_time/-explosion_time)*255);
|
const int intensity = (int)(255-(m_remaining_time/-explosion_time)*255);
|
||||||
node->getMaterial(0).AmbientColor.setGreen(intensity);
|
node->getMaterial(0).AmbientColor.setGreen(intensity);
|
||||||
node->getMaterial(0).DiffuseColor.setGreen(intensity);
|
node->getMaterial(0).DiffuseColor.setGreen(intensity);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,164 +1,164 @@
|
|||||||
#ifndef GLWRAP_HEADER_H
|
#ifndef GLWRAP_HEADER_H
|
||||||
#define GLWRAP_HEADER_H
|
#define GLWRAP_HEADER_H
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
# include <OpenGL/gl.h>
|
# include <OpenGL/gl.h>
|
||||||
# include <OpenGL/gl3.h>
|
# include <OpenGL/gl3.h>
|
||||||
# define OGL32CTX
|
# define OGL32CTX
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
# include <GLES/gl.h>
|
# include <GLES/gl.h>
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
# define _WINSOCKAPI_
|
# define _WINSOCKAPI_
|
||||||
// has to be included before gl.h because of WINGDIAPI and APIENTRY definitions
|
// has to be included before gl.h because of WINGDIAPI and APIENTRY definitions
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <GL/gl.h>
|
# include <GL/gl.h>
|
||||||
#else
|
#else
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#define DEBUG_OUTPUT_DECLARED
|
#define DEBUG_OUTPUT_DECLARED
|
||||||
# include <GL/gl.h>
|
# include <GL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "utils/log.hpp"
|
#include "utils/log.hpp"
|
||||||
|
|
||||||
// already includes glext.h, which defines useful GL constants.
|
// already includes glext.h, which defines useful GL constants.
|
||||||
// COpenGLDriver has already loaded the extension GL functions we use (e.g glBeginQuery)
|
// COpenGLDriver has already loaded the extension GL functions we use (e.g glBeginQuery)
|
||||||
#include "../../lib/irrlicht/source/Irrlicht/COpenGLDriver.h"
|
#include "../../lib/irrlicht/source/Irrlicht/COpenGLDriver.h"
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
extern PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks;
|
extern PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks;
|
||||||
extern PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback;
|
extern PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback;
|
||||||
extern PFNGLDRAWTRANSFORMFEEDBACKPROC glDrawTransformFeedback;
|
extern PFNGLDRAWTRANSFORMFEEDBACKPROC glDrawTransformFeedback;
|
||||||
extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback;
|
extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback;
|
||||||
extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback;
|
extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback;
|
||||||
extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings;
|
extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings;
|
||||||
extern PFNGLBINDBUFFERBASEPROC glBindBufferBase;
|
extern PFNGLBINDBUFFERBASEPROC glBindBufferBase;
|
||||||
extern PFNGLGENBUFFERSPROC glGenBuffers;
|
extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||||
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||||
extern PFNGLBUFFERDATAPROC glBufferData;
|
extern PFNGLBUFFERDATAPROC glBufferData;
|
||||||
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||||
extern PFNGLCREATESHADERPROC glCreateShader;
|
extern PFNGLCREATESHADERPROC glCreateShader;
|
||||||
extern PFNGLCOMPILESHADERPROC glCompileShader;
|
extern PFNGLCOMPILESHADERPROC glCompileShader;
|
||||||
extern PFNGLSHADERSOURCEPROC glShaderSource;
|
extern PFNGLSHADERSOURCEPROC glShaderSource;
|
||||||
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||||
extern PFNGLATTACHSHADERPROC glAttachShader;
|
extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||||
extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||||
extern PFNGLUSEPROGRAMPROC glUseProgram;
|
extern PFNGLUSEPROGRAMPROC glUseProgram;
|
||||||
extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||||
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||||
extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||||
extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||||
extern PFNGLUNIFORM1FPROC glUniform1f;
|
extern PFNGLUNIFORM1FPROC glUniform1f;
|
||||||
extern PFNGLUNIFORM3FPROC glUniform3f;
|
extern PFNGLUNIFORM3FPROC glUniform3f;
|
||||||
extern PFNGLUNIFORM1FVPROC glUniform1fv;
|
extern PFNGLUNIFORM1FVPROC glUniform1fv;
|
||||||
extern PFNGLUNIFORM4FVPROC glUniform4fv;
|
extern PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||||
extern PFNGLDELETESHADERPROC glDeleteShader;
|
extern PFNGLDELETESHADERPROC glDeleteShader;
|
||||||
extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||||
extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||||
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||||
extern PFNGLUNIFORM2FPROC glUniform2f;
|
extern PFNGLUNIFORM2FPROC glUniform2f;
|
||||||
extern PFNGLUNIFORM1IPROC glUniform1i;
|
extern PFNGLUNIFORM1IPROC glUniform1i;
|
||||||
extern PFNGLUNIFORM3IPROC glUniform3i;
|
extern PFNGLUNIFORM3IPROC glUniform3i;
|
||||||
extern PFNGLUNIFORM4IPROC glUniform4i;
|
extern PFNGLUNIFORM4IPROC glUniform4i;
|
||||||
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||||
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||||
extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
|
extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
|
||||||
extern PFNGLBLENDEQUATIONPROC glBlendEquation;
|
extern PFNGLBLENDEQUATIONPROC glBlendEquation;
|
||||||
extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
|
extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
|
||||||
extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
|
extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
|
||||||
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||||
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||||
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||||
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||||
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
||||||
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||||
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
||||||
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||||
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||||
extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
||||||
extern PFNGLTEXIMAGE3DPROC glTexImage3D;
|
extern PFNGLTEXIMAGE3DPROC glTexImage3D;
|
||||||
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
|
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void initGL();
|
void initGL();
|
||||||
GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount);
|
GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount);
|
||||||
void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF = false);
|
void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF = false);
|
||||||
GLuint LoadShader(const char * file, unsigned type);
|
GLuint LoadShader(const char * file, unsigned type);
|
||||||
|
|
||||||
template<typename ... Types>
|
template<typename ... Types>
|
||||||
void loadAndAttach(GLint ProgramID)
|
void loadAndAttach(GLint ProgramID)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ... Types>
|
template<typename ... Types>
|
||||||
void loadAndAttach(GLint ProgramID, GLint ShaderType, const char *filepath, Types ... args)
|
void loadAndAttach(GLint ProgramID, GLint ShaderType, const char *filepath, Types ... args)
|
||||||
{
|
{
|
||||||
GLint ShaderID = LoadShader(filepath, ShaderType);
|
GLint ShaderID = LoadShader(filepath, ShaderType);
|
||||||
glAttachShader(ProgramID, ShaderID);
|
glAttachShader(ProgramID, ShaderID);
|
||||||
glDeleteShader(ShaderID);
|
glDeleteShader(ShaderID);
|
||||||
loadAndAttach(ProgramID, args...);
|
loadAndAttach(ProgramID, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...Types>
|
template<typename ...Types>
|
||||||
void printFileList()
|
void printFileList()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...Types>
|
template<typename ...Types>
|
||||||
void printFileList(GLint ShaderType, const char *filepath, Types ... args)
|
void printFileList(GLint ShaderType, const char *filepath, Types ... args)
|
||||||
{
|
{
|
||||||
Log::error("GLWrapp", filepath);
|
Log::error("GLWrapp", filepath);
|
||||||
printFileList(args...);
|
printFileList(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ... Types>
|
template<typename ... Types>
|
||||||
GLint LoadProgram(Types ... args)
|
GLint LoadProgram(Types ... args)
|
||||||
{
|
{
|
||||||
GLint ProgramID = glCreateProgram();
|
GLint ProgramID = glCreateProgram();
|
||||||
loadAndAttach(ProgramID, args...);
|
loadAndAttach(ProgramID, args...);
|
||||||
glLinkProgram(ProgramID);
|
glLinkProgram(ProgramID);
|
||||||
|
|
||||||
GLint Result = GL_FALSE;
|
GLint Result = GL_FALSE;
|
||||||
int InfoLogLength;
|
int InfoLogLength;
|
||||||
glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
|
glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
|
||||||
if (Result == GL_FALSE) {
|
if (Result == GL_FALSE) {
|
||||||
Log::error("GLWrapp", "Error when linking these shaders :");
|
Log::error("GLWrapp", "Error when linking these shaders :");
|
||||||
printFileList(args...);
|
printFileList(args...);
|
||||||
glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength);
|
glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength);
|
||||||
char *ErrorMessage = new char[InfoLogLength];
|
char *ErrorMessage = new char[InfoLogLength];
|
||||||
glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, ErrorMessage);
|
glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, ErrorMessage);
|
||||||
Log::error("GLWrapp", ErrorMessage);
|
Log::error("GLWrapp", ErrorMessage);
|
||||||
delete[] ErrorMessage;
|
delete[] ErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum glErr = glGetError();
|
GLenum glErr = glGetError();
|
||||||
if (glErr != GL_NO_ERROR)
|
if (glErr != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
|
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ProgramID;
|
return ProgramID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// core::rect<s32> needs these includes
|
// core::rect<s32> needs these includes
|
||||||
#include <rect.h>
|
#include <rect.h>
|
||||||
#include "utils/vec3.hpp"
|
#include "utils/vec3.hpp"
|
||||||
|
|
||||||
GLuint getTextureGLuint(irr::video::ITexture *tex);
|
GLuint getTextureGLuint(irr::video::ITexture *tex);
|
||||||
GLuint getDepthTexture(irr::video::ITexture *tex);
|
GLuint getDepthTexture(irr::video::ITexture *tex);
|
||||||
|
|
||||||
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,
|
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,
|
||||||
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,
|
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,
|
||||||
const irr::video::SColor &color, bool useAlphaChannelOfTexture);
|
const irr::video::SColor &color, bool useAlphaChannelOfTexture);
|
||||||
|
|
||||||
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,
|
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,
|
||||||
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,
|
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,
|
||||||
const irr::video::SColor* const colors, bool useAlphaChannelOfTexture);
|
const irr::video::SColor* const colors, bool useAlphaChannelOfTexture);
|
||||||
|
|
||||||
void GL32_draw2DRectangle(irr::video::SColor color, const irr::core::rect<s32>& position,
|
void GL32_draw2DRectangle(irr::video::SColor color, const irr::core::rect<s32>& position,
|
||||||
const irr::core::rect<s32>* clip = 0);
|
const irr::core::rect<s32>* clip = 0);
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,70 +1,70 @@
|
|||||||
#ifndef GPUPARTICLES_H
|
#ifndef GPUPARTICLES_H
|
||||||
#define GPUPARTICLES_H
|
#define GPUPARTICLES_H
|
||||||
|
|
||||||
#include "graphics/glwrap.hpp"
|
#include "graphics/glwrap.hpp"
|
||||||
|
|
||||||
#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h"
|
#include "../lib/irrlicht/source/Irrlicht/CParticleSystemSceneNode.h"
|
||||||
#include <ISceneManager.h>
|
#include <ISceneManager.h>
|
||||||
#include <IParticleSystemSceneNode.h>
|
#include <IParticleSystemSceneNode.h>
|
||||||
|
|
||||||
namespace irr { namespace video{ class ITexture; } }
|
namespace irr { namespace video{ class ITexture; } }
|
||||||
|
|
||||||
class ParticleSystemProxy : public scene::CParticleSystemSceneNode
|
class ParticleSystemProxy : public scene::CParticleSystemSceneNode
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
GLuint tfb_buffers[2], initial_values_buffer, heighmapbuffer, heightmaptexture, quaternionsbuffer;
|
GLuint tfb_buffers[2], initial_values_buffer, heighmapbuffer, heightmaptexture, quaternionsbuffer;
|
||||||
GLuint current_simulation_vao, non_current_simulation_vao;
|
GLuint current_simulation_vao, non_current_simulation_vao;
|
||||||
GLuint current_rendering_vao, non_current_rendering_vao;
|
GLuint current_rendering_vao, non_current_rendering_vao;
|
||||||
bool m_alpha_additive, has_height_map, flip;
|
bool m_alpha_additive, has_height_map, flip;
|
||||||
float size_increase_factor, track_x, track_z, track_x_len, track_z_len;
|
float size_increase_factor, track_x, track_z, track_x_len, track_z_len;
|
||||||
float m_color_from[3];
|
float m_color_from[3];
|
||||||
float m_color_to[3];
|
float m_color_to[3];
|
||||||
|
|
||||||
static GLuint quad_vertex_buffer;
|
static GLuint quad_vertex_buffer;
|
||||||
|
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
unsigned count;
|
unsigned count;
|
||||||
static void SimpleParticleVAOBind(GLuint PositionBuffer);
|
static void SimpleParticleVAOBind(GLuint PositionBuffer);
|
||||||
static void FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer);
|
static void FlipParticleVAOBind(GLuint PositionBuffer, GLuint QuaternionBuffer);
|
||||||
static void SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
|
static void SimpleSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
|
||||||
static void HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
|
static void HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer);
|
||||||
|
|
||||||
void generateVAOs();
|
void generateVAOs();
|
||||||
|
|
||||||
void simulateHeightmap();
|
void simulateHeightmap();
|
||||||
void simulateNoHeightmap();
|
void simulateNoHeightmap();
|
||||||
void drawFlip();
|
void drawFlip();
|
||||||
void drawNotFlip();
|
void drawNotFlip();
|
||||||
virtual void simulate();
|
virtual void simulate();
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
void generateParticlesFromPointEmitter(scene::IParticlePointEmitter *);
|
void generateParticlesFromPointEmitter(scene::IParticlePointEmitter *);
|
||||||
void generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *);
|
void generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *);
|
||||||
void generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *);
|
void generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *);
|
||||||
public:
|
public:
|
||||||
static IParticleSystemSceneNode *addParticleNode(
|
static IParticleSystemSceneNode *addParticleNode(
|
||||||
bool withDefaultEmitter = true, ISceneNode* parent = 0, s32 id = -1,
|
bool withDefaultEmitter = true, ISceneNode* parent = 0, s32 id = -1,
|
||||||
const core::vector3df& position = core::vector3df(0, 0, 0),
|
const core::vector3df& position = core::vector3df(0, 0, 0),
|
||||||
const core::vector3df& rotation = core::vector3df(0, 0, 0),
|
const core::vector3df& rotation = core::vector3df(0, 0, 0),
|
||||||
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
|
const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f));
|
||||||
|
|
||||||
ParticleSystemProxy(bool createDefaultEmitter,
|
ParticleSystemProxy(bool createDefaultEmitter,
|
||||||
ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
|
ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
|
||||||
const core::vector3df& position,
|
const core::vector3df& position,
|
||||||
const core::vector3df& rotation,
|
const core::vector3df& rotation,
|
||||||
const core::vector3df& scale);
|
const core::vector3df& scale);
|
||||||
~ParticleSystemProxy();
|
~ParticleSystemProxy();
|
||||||
|
|
||||||
virtual void setEmitter(scene::IParticleEmitter* emitter);
|
virtual void setEmitter(scene::IParticleEmitter* emitter);
|
||||||
virtual void render();
|
virtual void render();
|
||||||
virtual void OnRegisterSceneNode();
|
virtual void OnRegisterSceneNode();
|
||||||
void setAlphaAdditive(bool val) { m_alpha_additive = val; }
|
void setAlphaAdditive(bool val) { m_alpha_additive = val; }
|
||||||
void setIncreaseFactor(float val) { size_increase_factor = val; }
|
void setIncreaseFactor(float val) { size_increase_factor = val; }
|
||||||
void setColorFrom(float r, float g, float b) { m_color_from[0] = r; m_color_from[1] = g; m_color_from[2] = b; }
|
void setColorFrom(float r, float g, float b) { m_color_from[0] = r; m_color_from[1] = g; m_color_from[2] = b; }
|
||||||
void setColorTo(float r, float g, float b) { m_color_to[0] = r; m_color_to[1] = g; m_color_to[2] = b; }
|
void setColorTo(float r, float g, float b) { m_color_to[0] = r; m_color_to[1] = g; m_color_to[2] = b; }
|
||||||
const float* getColorFrom() const { return m_color_from; }
|
const float* getColorFrom() const { return m_color_from; }
|
||||||
const float* getColorTo() const { return m_color_to; }
|
const float* getColorTo() const { return m_color_to; }
|
||||||
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);
|
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);
|
||||||
void setFlip();
|
void setFlip();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GPUPARTICLES_H
|
#endif // GPUPARTICLES_H
|
||||||
|
@ -155,7 +155,7 @@ STKRenderingPass IrrDriver::getPhase() const
|
|||||||
|
|
||||||
void IrrDriver::IncreaseObjectCount()
|
void IrrDriver::IncreaseObjectCount()
|
||||||
{
|
{
|
||||||
object_count[m_phase]++;
|
object_count[m_phase]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
core::array<video::IRenderTarget> &IrrDriver::getMainSetup()
|
core::array<video::IRenderTarget> &IrrDriver::getMainSetup()
|
||||||
@ -424,10 +424,10 @@ void IrrDriver::initDevice()
|
|||||||
|
|
||||||
GLMajorVersion = 2;
|
GLMajorVersion = 2;
|
||||||
GLMinorVersion = 1;
|
GLMinorVersion = 1;
|
||||||
glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVersion);
|
glGetIntegerv(GL_MAJOR_VERSION, &GLMajorVersion);
|
||||||
glGetIntegerv(GL_MINOR_VERSION, &GLMinorVersion);
|
glGetIntegerv(GL_MINOR_VERSION, &GLMinorVersion);
|
||||||
Log::info("IrrDriver", "OPENGL VERSION IS %d.%d", GLMajorVersion, GLMinorVersion);
|
Log::info("IrrDriver", "OPENGL VERSION IS %d.%d", GLMajorVersion, GLMinorVersion);
|
||||||
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1)) && UserConfigParams::m_pixel_shaders;
|
m_glsl = (GLMajorVersion > 3 || (GLMajorVersion == 3 && GLMinorVersion >= 1)) && UserConfigParams::m_pixel_shaders;
|
||||||
|
|
||||||
// This remaps the window, so it has to be done before the clear to avoid flicker
|
// This remaps the window, so it has to be done before the clear to avoid flicker
|
||||||
m_device->setResizable(false);
|
m_device->setResizable(false);
|
||||||
@ -458,7 +458,7 @@ void IrrDriver::initDevice()
|
|||||||
m_mrt.push_back(m_rtts->getRTT(RTT_COLOR));
|
m_mrt.push_back(m_rtts->getRTT(RTT_COLOR));
|
||||||
m_mrt.push_back(m_rtts->getRTT(RTT_NORMAL_AND_DEPTH));
|
m_mrt.push_back(m_rtts->getRTT(RTT_NORMAL_AND_DEPTH));
|
||||||
|
|
||||||
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
||||||
gl_driver->extGlGenQueries(1, &m_lensflare_query);
|
gl_driver->extGlGenQueries(1, &m_lensflare_query);
|
||||||
m_query_issued = false;
|
m_query_issued = false;
|
||||||
|
|
||||||
@ -595,7 +595,7 @@ core::position2di IrrDriver::getMouseLocation()
|
|||||||
bool IrrDriver::moveWindow(const int x, const int y)
|
bool IrrDriver::moveWindow(const int x, const int y)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
const video::SExposedVideoData& videoData =
|
const video::SExposedVideoData& videoData =
|
||||||
m_video_driver->getExposedVideoData();
|
m_video_driver->getExposedVideoData();
|
||||||
// this should work even if using DirectX in theory,
|
// this should work even if using DirectX in theory,
|
||||||
// because the HWnd is always third pointer in the struct,
|
// because the HWnd is always third pointer in the struct,
|
||||||
@ -964,17 +964,17 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size,
|
|||||||
video::ITexture *texture,
|
video::ITexture *texture,
|
||||||
scene::ISceneNode* parent, bool alphaTesting)
|
scene::ISceneNode* parent, bool alphaTesting)
|
||||||
{
|
{
|
||||||
scene::IBillboardSceneNode* node;
|
scene::IBillboardSceneNode* node;
|
||||||
if (isGLSL())
|
if (isGLSL())
|
||||||
{
|
{
|
||||||
if (!parent)
|
if (!parent)
|
||||||
parent = m_scene_manager->getRootSceneNode();
|
parent = m_scene_manager->getRootSceneNode();
|
||||||
|
|
||||||
node = new STKBillboard(parent, m_scene_manager, -1, vector3df(0., 0., 0.), size);
|
node = new STKBillboard(parent, m_scene_manager, -1, vector3df(0., 0., 0.), size);
|
||||||
node->drop();
|
node->drop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
node = m_scene_manager->addBillboardSceneNode(parent, size);
|
node = m_scene_manager->addBillboardSceneNode(parent, size);
|
||||||
assert(node->getMaterialCount() > 0);
|
assert(node->getMaterialCount() > 0);
|
||||||
node->setMaterialTexture(0, texture);
|
node->setMaterialTexture(0, texture);
|
||||||
if(alphaTesting)
|
if(alphaTesting)
|
||||||
@ -1150,7 +1150,7 @@ scene::ISceneNode *IrrDriver::addSkyDome(video::ITexture *texture,
|
|||||||
float texture_percent,
|
float texture_percent,
|
||||||
float sphere_percent)
|
float sphere_percent)
|
||||||
{
|
{
|
||||||
Log::error("skybox", "Using deprecated SkyDome");
|
Log::error("skybox", "Using deprecated SkyDome");
|
||||||
return m_scene_manager->addSkyDomeSceneNode(texture, hori_res, vert_res,
|
return m_scene_manager->addSkyDomeSceneNode(texture, hori_res, vert_res,
|
||||||
texture_percent,
|
texture_percent,
|
||||||
sphere_percent);
|
sphere_percent);
|
||||||
@ -1171,7 +1171,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*>
|
|||||||
&texture)
|
&texture)
|
||||||
{
|
{
|
||||||
assert(texture.size() == 6);
|
assert(texture.size() == 6);
|
||||||
SkyboxTextures = texture;
|
SkyboxTextures = texture;
|
||||||
SkyboxCubeMap = 0;
|
SkyboxCubeMap = 0;
|
||||||
ConvolutedSkyboxCubeMap = 0;
|
ConvolutedSkyboxCubeMap = 0;
|
||||||
return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1],
|
return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1],
|
||||||
@ -1181,7 +1181,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector<video::ITexture*>
|
|||||||
|
|
||||||
void IrrDriver::suppressSkyBox()
|
void IrrDriver::suppressSkyBox()
|
||||||
{
|
{
|
||||||
SkyboxTextures.clear();
|
SkyboxTextures.clear();
|
||||||
glDeleteTextures(1, &SkyboxCubeMap);
|
glDeleteTextures(1, &SkyboxCubeMap);
|
||||||
glDeleteTextures(1, &ConvolutedSkyboxCubeMap);
|
glDeleteTextures(1, &ConvolutedSkyboxCubeMap);
|
||||||
SkyboxCubeMap = 0;
|
SkyboxCubeMap = 0;
|
||||||
@ -1518,9 +1518,9 @@ void IrrDriver::displayFPS()
|
|||||||
{
|
{
|
||||||
sprintf(buffer, "FPS: %i/%i/%i - Objects (P1:%d P2:%d T:%d) KTris - LightDst : ~%d",
|
sprintf(buffer, "FPS: %i/%i/%i - Objects (P1:%d P2:%d T:%d) KTris - LightDst : ~%d",
|
||||||
min, fps, max, object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[TRANSPARENT_PASS], m_last_light_bucket_distance);
|
min, fps, max, object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[SOLID_NORMAL_AND_DEPTH_PASS], object_count[TRANSPARENT_PASS], m_last_light_bucket_distance);
|
||||||
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
|
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
|
||||||
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
|
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
|
||||||
object_count[TRANSPARENT_PASS] = 0;
|
object_count[TRANSPARENT_PASS] = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1531,7 +1531,7 @@ void IrrDriver::displayFPS()
|
|||||||
core::stringw fpsString = buffer;
|
core::stringw fpsString = buffer;
|
||||||
|
|
||||||
static video::SColor fpsColor = video::SColor(255, 0, 0, 0);
|
static video::SColor fpsColor = video::SColor(255, 0, 0, 0);
|
||||||
|
|
||||||
font->draw( fpsString.c_str(), core::rect< s32 >(100,0,400,50), fpsColor, false );
|
font->draw( fpsString.c_str(), core::rect< s32 >(100,0,400,50), fpsColor, false );
|
||||||
} // updateFPS
|
} // updateFPS
|
||||||
|
|
||||||
@ -2017,7 +2017,7 @@ void IrrDriver::RTTProvider::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
|
|||||||
m_rtt_main_node->getMaterial(n).SpecularColor.set(255,50,50,50);
|
m_rtt_main_node->getMaterial(n).SpecularColor.set(255,50,50,50);
|
||||||
m_rtt_main_node->getMaterial(n).DiffuseColor.set(255,150,150,150);
|
m_rtt_main_node->getMaterial(n).DiffuseColor.set(255,150,150,150);
|
||||||
|
|
||||||
m_rtt_main_node->getMaterial(n).setFlag(video::EMF_GOURAUD_SHADING ,
|
m_rtt_main_node->getMaterial(n).setFlag(video::EMF_GOURAUD_SHADING ,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2136,7 +2136,7 @@ void IrrDriver::applyObjectPassShader(scene::ISceneNode * const node, bool rimli
|
|||||||
// viamb = (dynamic_cast<scene::IMeshSceneNode*>(node))->isReadOnlyMaterials();
|
// viamb = (dynamic_cast<scene::IMeshSceneNode*>(node))->isReadOnlyMaterials();
|
||||||
// mesh = (dynamic_cast<scene::IMeshSceneNode*>(node))->getMesh();
|
// mesh = (dynamic_cast<scene::IMeshSceneNode*>(node))->getMesh();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
for (i = 0; i < mcount; i++)
|
for (i = 0; i < mcount; i++)
|
||||||
{
|
{
|
||||||
video::SMaterial &nodemat = node->getMaterial(i);
|
video::SMaterial &nodemat = node->getMaterial(i);
|
||||||
@ -2216,7 +2216,7 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos, float energy,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_scene_manager->addLightSceneNode(m_scene_manager->getRootSceneNode(),
|
return m_scene_manager->addLightSceneNode(m_scene_manager->getRootSceneNode(),
|
||||||
pos, video::SColorf(1.0f, r, g, b));
|
pos, video::SColorf(1.0f, r, g, b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,13 +65,13 @@ class ShadowImportance;
|
|||||||
|
|
||||||
enum STKRenderingPass
|
enum STKRenderingPass
|
||||||
{
|
{
|
||||||
SOLID_NORMAL_AND_DEPTH_PASS,
|
SOLID_NORMAL_AND_DEPTH_PASS,
|
||||||
SOLID_LIT_PASS,
|
SOLID_LIT_PASS,
|
||||||
TRANSPARENT_PASS,
|
TRANSPARENT_PASS,
|
||||||
GLOW_PASS,
|
GLOW_PASS,
|
||||||
DISPLACEMENT_PASS,
|
DISPLACEMENT_PASS,
|
||||||
SHADOW_PASS,
|
SHADOW_PASS,
|
||||||
PASS_COUNT,
|
PASS_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,7 +115,7 @@ private:
|
|||||||
/** Matrixes used in several places stored here to avoid recomputation. */
|
/** Matrixes used in several places stored here to avoid recomputation. */
|
||||||
core::matrix4 m_ViewMatrix, m_InvViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix;
|
core::matrix4 m_ViewMatrix, m_InvViewMatrix, m_ProjMatrix, m_InvProjMatrix, m_ProjViewMatrix, m_InvProjViewMatrix;
|
||||||
|
|
||||||
std::vector<video::ITexture *> SkyboxTextures;
|
std::vector<video::ITexture *> SkyboxTextures;
|
||||||
|
|
||||||
float blueSHCoeff[9];
|
float blueSHCoeff[9];
|
||||||
float greenSHCoeff[9];
|
float greenSHCoeff[9];
|
||||||
@ -183,9 +183,9 @@ private:
|
|||||||
bool m_shadowviz;
|
bool m_shadowviz;
|
||||||
bool m_lightviz;
|
bool m_lightviz;
|
||||||
bool m_distortviz;
|
bool m_distortviz;
|
||||||
/** Performance stats */
|
/** Performance stats */
|
||||||
unsigned m_last_light_bucket_distance;
|
unsigned m_last_light_bucket_distance;
|
||||||
unsigned object_count[PASS_COUNT];
|
unsigned object_count[PASS_COUNT];
|
||||||
u32 m_renderpass;
|
u32 m_renderpass;
|
||||||
u32 m_lensflare_query;
|
u32 m_lensflare_query;
|
||||||
bool m_query_issued;
|
bool m_query_issued;
|
||||||
@ -208,7 +208,7 @@ private:
|
|||||||
|
|
||||||
std::vector<scene::ISceneNode *> m_background;
|
std::vector<scene::ISceneNode *> m_background;
|
||||||
|
|
||||||
STKRenderingPass m_phase;
|
STKRenderingPass m_phase;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/** Used to visualise skeletons. */
|
/** Used to visualise skeletons. */
|
||||||
@ -244,13 +244,13 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
void generateSkyboxCubemap();
|
void generateSkyboxCubemap();
|
||||||
void renderSkybox();
|
void renderSkybox();
|
||||||
void setPhase(STKRenderingPass);
|
void setPhase(STKRenderingPass);
|
||||||
STKRenderingPass getPhase() const;
|
STKRenderingPass getPhase() const;
|
||||||
const std::vector<core::matrix4> &getShadowViewProj() const
|
const std::vector<core::matrix4> &getShadowViewProj() const
|
||||||
{
|
{
|
||||||
return sun_ortho_matrix;
|
return sun_ortho_matrix;
|
||||||
}
|
}
|
||||||
void IncreaseObjectCount();
|
void IncreaseObjectCount();
|
||||||
core::array<video::IRenderTarget> &getMainSetup();
|
core::array<video::IRenderTarget> &getMainSetup();
|
||||||
void updateConfigIfRelevant();
|
void updateConfigIfRelevant();
|
||||||
void setAllMaterialFlags(scene::IMesh *mesh) const;
|
void setAllMaterialFlags(scene::IMesh *mesh) const;
|
||||||
@ -261,7 +261,7 @@ public:
|
|||||||
void displayFPS();
|
void displayFPS();
|
||||||
bool OnEvent(const irr::SEvent &event);
|
bool OnEvent(const irr::SEvent &event);
|
||||||
void setAmbientLight(const video::SColor &light);
|
void setAmbientLight(const video::SColor &light);
|
||||||
video::ITexture *getTexture(FileManager::AssetType type,
|
video::ITexture *getTexture(FileManager::AssetType type,
|
||||||
const std::string &filename,
|
const std::string &filename,
|
||||||
bool is_premul=false,
|
bool is_premul=false,
|
||||||
bool is_prediv=false,
|
bool is_prediv=false,
|
||||||
@ -297,7 +297,7 @@ public:
|
|||||||
int vert_res, float texture_percent,
|
int vert_res, float texture_percent,
|
||||||
float sphere_percent);
|
float sphere_percent);
|
||||||
scene::ISceneNode *addSkyBox(const std::vector<video::ITexture*> &texture_names);
|
scene::ISceneNode *addSkyBox(const std::vector<video::ITexture*> &texture_names);
|
||||||
void suppressSkyBox();
|
void suppressSkyBox();
|
||||||
void removeNode(scene::ISceneNode *node);
|
void removeNode(scene::ISceneNode *node);
|
||||||
void removeMeshFromCache(scene::IMesh *mesh);
|
void removeMeshFromCache(scene::IMesh *mesh);
|
||||||
void removeTexture(video::ITexture *t);
|
void removeTexture(video::ITexture *t);
|
||||||
@ -369,7 +369,7 @@ public:
|
|||||||
char *detail=NULL)
|
char *detail=NULL)
|
||||||
{
|
{
|
||||||
if(!detail)
|
if(!detail)
|
||||||
return getTexture(filename, std::string(error_message),
|
return getTexture(filename, std::string(error_message),
|
||||||
std::string(""));
|
std::string(""));
|
||||||
|
|
||||||
return getTexture(filename, std::string(error_message),
|
return getTexture(filename, std::string(error_message),
|
||||||
@ -384,7 +384,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
const std::string &getTextureErrorMessage()
|
const std::string &getTextureErrorMessage()
|
||||||
{
|
{
|
||||||
return m_texture_error_message;
|
return m_texture_error_message;
|
||||||
} // getTextureErrorMessage
|
} // getTextureErrorMessage
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -420,7 +420,7 @@ public:
|
|||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
inline void updateShaders() {m_shaders->loadShaders();}
|
inline void updateShaders() {m_shaders->loadShaders();}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
inline video::IShaderConstantSetCallBack* getCallback(const ShaderType num)
|
inline video::IShaderConstantSetCallBack* getCallback(const ShaderType num)
|
||||||
{
|
{
|
||||||
return (m_shaders == NULL ? NULL : m_shaders->m_callbacks[num]);
|
return (m_shaders == NULL ? NULL : m_shaders->m_callbacks[num]);
|
||||||
}
|
}
|
||||||
|
@ -13,43 +13,43 @@ namespace irr
|
|||||||
{
|
{
|
||||||
namespace scene
|
namespace scene
|
||||||
{
|
{
|
||||||
//! A SMeshBuffer with 32-bit indices
|
//! A SMeshBuffer with 32-bit indices
|
||||||
class LargeMeshBuffer : public SMeshBuffer
|
class LargeMeshBuffer : public SMeshBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Get type of index data which is stored in this meshbuffer.
|
//! Get type of index data which is stored in this meshbuffer.
|
||||||
/** \return Index type of this buffer. */
|
/** \return Index type of this buffer. */
|
||||||
virtual video::E_INDEX_TYPE getIndexType() const
|
virtual video::E_INDEX_TYPE getIndexType() const
|
||||||
{
|
{
|
||||||
return video::EIT_32BIT;
|
return video::EIT_32BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get pointer to indices
|
//! Get pointer to indices
|
||||||
/** \return Pointer to indices. */
|
/** \return Pointer to indices. */
|
||||||
virtual const u16* getIndices() const
|
virtual const u16* getIndices() const
|
||||||
{
|
{
|
||||||
return (u16 *) Indices.const_pointer();
|
return (u16 *) Indices.const_pointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Get pointer to indices
|
//! Get pointer to indices
|
||||||
/** \return Pointer to indices. */
|
/** \return Pointer to indices. */
|
||||||
virtual u16* getIndices()
|
virtual u16* getIndices()
|
||||||
{
|
{
|
||||||
return (u16 *) Indices.pointer();
|
return (u16 *) Indices.pointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Get number of indices
|
//! Get number of indices
|
||||||
/** \return Number of indices. */
|
/** \return Number of indices. */
|
||||||
virtual u32 getIndexCount() const
|
virtual u32 getIndexCount() const
|
||||||
{
|
{
|
||||||
return Indices.size();
|
return Indices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Indices into the vertices of this buffer.
|
//! Indices into the vertices of this buffer.
|
||||||
core::array<u32> Indices;
|
core::array<u32> Indices;
|
||||||
};
|
};
|
||||||
} // end namespace scene
|
} // end namespace scene
|
||||||
} // end namespace irr
|
} // end namespace irr
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
|
|||||||
else if (s=="" || s=="none")
|
else if (s=="" || s=="none")
|
||||||
m_adjust_image = ADJ_NONE;
|
m_adjust_image = ADJ_NONE;
|
||||||
else
|
else
|
||||||
Log::warn("material",
|
Log::warn("material",
|
||||||
"Incorrect adjust-image specification: '%s' - ignored.",
|
"Incorrect adjust-image specification: '%s' - ignored.",
|
||||||
s.c_str());
|
s.c_str());
|
||||||
node->get("alpha", &m_alpha_blending );
|
node->get("alpha", &m_alpha_blending );
|
||||||
@ -121,7 +121,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
|
|||||||
}
|
}
|
||||||
else if (creaction.size() > 0)
|
else if (creaction.size() > 0)
|
||||||
{
|
{
|
||||||
Log::warn("Material","Unknown collision reaction '%s'",
|
Log::warn("Material","Unknown collision reaction '%s'",
|
||||||
creaction.c_str());
|
creaction.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
|
|||||||
}
|
}
|
||||||
else if (s != "")
|
else if (s != "")
|
||||||
{
|
{
|
||||||
Log::warn("material",
|
Log::warn("material",
|
||||||
"Invalid graphical effect specification: '%s' - ignored.",
|
"Invalid graphical effect specification: '%s' - ignored.",
|
||||||
s.c_str());
|
s.c_str());
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ Material::Material(const XMLNode *node, int index, bool deprecated)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::warn("material",
|
Log::warn("material",
|
||||||
"Could not find normal map image in materials.xml");
|
"Could not find normal map image in materials.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,7 +554,7 @@ void Material::initParticlesEffect(const XMLNode *node)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
particles = pkm->getParticles(base.c_str());
|
particles = pkm->getParticles(base.c_str());
|
||||||
|
|
||||||
if (particles == NULL)
|
if (particles == NULL)
|
||||||
{
|
{
|
||||||
Log::warn("Material::initParticlesEffect",
|
Log::warn("Material::initParticlesEffect",
|
||||||
@ -650,22 +650,22 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
|||||||
// materials.xml, if you want to set flags for all surfaces, see
|
// materials.xml, if you want to set flags for all surfaces, see
|
||||||
// 'MaterialManager::setAllMaterialFlags'
|
// 'MaterialManager::setAllMaterialFlags'
|
||||||
|
|
||||||
if (m_deprecated ||
|
if (m_deprecated ||
|
||||||
(m->getTexture(0) != NULL &&
|
(m->getTexture(0) != NULL &&
|
||||||
((core::stringc)m->getTexture(0)->getName()).find("deprecated") != -1))
|
((core::stringc)m->getTexture(0)->getName()).find("deprecated") != -1))
|
||||||
{
|
{
|
||||||
Log::warn("material", "Track uses deprecated texture '%s'",
|
Log::warn("material", "Track uses deprecated texture '%s'",
|
||||||
m_texname.c_str());
|
m_texname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int modes = 0;
|
int modes = 0;
|
||||||
|
|
||||||
if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add)
|
if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add)
|
||||||
{
|
{
|
||||||
m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT);
|
m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT);
|
||||||
modes++;
|
modes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_alpha_testing)
|
if (m_alpha_testing)
|
||||||
{
|
{
|
||||||
@ -765,8 +765,8 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
|||||||
if (irr_driver->isGLSL())
|
if (irr_driver->isGLSL())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (mb->getVertexType() != video::EVT_TANGENTS)
|
if (mb->getVertexType() != video::EVT_TANGENTS)
|
||||||
Log::error("material", "Requiring normal map without tangent enabled mesh");
|
Log::error("material", "Requiring normal map without tangent enabled mesh");
|
||||||
ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
|
ITexture* tex = irr_driver->getTexture(m_normal_map_tex);
|
||||||
if (m_is_heightmap)
|
if (m_is_heightmap)
|
||||||
{
|
{
|
||||||
@ -810,13 +810,13 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
|
|||||||
m->SpecularColor.set(0,0,0,0);
|
m->SpecularColor.set(0,0,0,0);
|
||||||
modes++;
|
modes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_graphical_effect == GE_SKYBOX && irr_driver->isGLSL())
|
if(m_graphical_effect == GE_SKYBOX && irr_driver->isGLSL())
|
||||||
{
|
{
|
||||||
ITexture* tex = irr_driver->getTexture("cloud_mask.png");
|
ITexture* tex = irr_driver->getTexture("cloud_mask.png");
|
||||||
m->setTexture(1, tex);
|
m->setTexture(1, tex);
|
||||||
|
|
||||||
|
|
||||||
m->MaterialType = irr_driver->getShader(ES_SKYBOX);
|
m->MaterialType = irr_driver->getShader(ES_SKYBOX);
|
||||||
}
|
}
|
||||||
if (m_graphical_effect == GE_SPLATTING)
|
if (m_graphical_effect == GE_SPLATTING)
|
||||||
|
@ -107,7 +107,7 @@ private:
|
|||||||
/** If a kart is rescued when driving on this surface. */
|
/** If a kart is rescued when driving on this surface. */
|
||||||
bool m_drive_reset;
|
bool m_drive_reset;
|
||||||
|
|
||||||
/** True if this is a texture that will start the jump animatoin when
|
/** True if this is a texture that will start the jump animatoin when
|
||||||
* leaving it and being in the air. */
|
* leaving it and being in the air. */
|
||||||
bool m_is_jump_texture;
|
bool m_is_jump_texture;
|
||||||
|
|
||||||
@ -179,8 +179,8 @@ private:
|
|||||||
float m_slowdown_time;
|
float m_slowdown_time;
|
||||||
/** Maximum speed at which no more slow down occurs. */
|
/** Maximum speed at which no more slow down occurs. */
|
||||||
float m_max_speed_fraction;
|
float m_max_speed_fraction;
|
||||||
/** Minimum speed on this terrain. This is used for zippers on a ramp to
|
/** Minimum speed on this terrain. This is used for zippers on a ramp to
|
||||||
* guarantee the right jump distance. A negative value indicates no
|
* guarantee the right jump distance. A negative value indicates no
|
||||||
* minimum speed. */
|
* minimum speed. */
|
||||||
float m_zipper_min_speed;
|
float m_zipper_min_speed;
|
||||||
/** The minimum speed at which a special sfx is started to be played. */
|
/** The minimum speed at which a special sfx is started to be played. */
|
||||||
@ -346,9 +346,9 @@ public:
|
|||||||
void onMadeVisible(scene::IMeshBuffer* who);
|
void onMadeVisible(scene::IMeshBuffer* who);
|
||||||
void onHidden(scene::IMeshBuffer* who);
|
void onHidden(scene::IMeshBuffer* who);
|
||||||
void isInitiallyHidden(scene::IMeshBuffer* who);
|
void isInitiallyHidden(scene::IMeshBuffer* who);
|
||||||
/** For particle system : specify if the particle should be additively blended
|
/** For particle system : specify if the particle should be additively blended
|
||||||
*/
|
*/
|
||||||
bool isAlphaAdditive() const { return !m_alpha_blending; }
|
bool isAlphaAdditive() const { return !m_alpha_blending; }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ void MaterialManager::loadMaterial()
|
|||||||
// Use temp material for reading, but then set the shared
|
// Use temp material for reading, but then set the shared
|
||||||
// material index later, so that these materials are not popped
|
// material index later, so that these materials are not popped
|
||||||
//
|
//
|
||||||
addSharedMaterial(file_manager->getAssetChecked(FileManager::TEXTURE,
|
addSharedMaterial(file_manager->getAssetChecked(FileManager::TEXTURE,
|
||||||
"materials.xml", true));
|
"materials.xml", true));
|
||||||
std::string deprecated = file_manager->getAssetChecked(FileManager::TEXTURE,
|
std::string deprecated = file_manager->getAssetChecked(FileManager::TEXTURE,
|
||||||
"deprecated/materials.xml");
|
"deprecated/materials.xml");
|
||||||
@ -298,12 +298,12 @@ Material *MaterialManager::getMaterial(const std::string& fname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string basename;
|
std::string basename;
|
||||||
|
|
||||||
if (strip_path)
|
if (strip_path)
|
||||||
basename = StringUtils::getBasename(fname);
|
basename = StringUtils::getBasename(fname);
|
||||||
else
|
else
|
||||||
basename = fname;
|
basename = fname;
|
||||||
|
|
||||||
// Search backward so that temporary (track) textures are found first
|
// Search backward so that temporary (track) textures are found first
|
||||||
for(int i = (int)m_materials.size()-1; i>=0; i-- )
|
for(int i = (int)m_materials.size()-1; i>=0; i-- )
|
||||||
{
|
{
|
||||||
|
@ -390,21 +390,21 @@ void ParticleEmitter::setCreationRateAbsolute(float f)
|
|||||||
|
|
||||||
if (f <= 0.0f && m_node->getEmitter())
|
if (f <= 0.0f && m_node->getEmitter())
|
||||||
{
|
{
|
||||||
m_node->clearParticles();
|
m_node->clearParticles();
|
||||||
}
|
}
|
||||||
else if (m_node->getEmitter() == NULL)
|
else if (m_node->getEmitter() == NULL)
|
||||||
{
|
{
|
||||||
m_node->setEmitter(m_emitter);
|
m_node->setEmitter(m_emitter);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* if (f <= 0.0f)
|
/* if (f <= 0.0f)
|
||||||
{
|
{
|
||||||
m_node->setVisible(false);
|
m_node->setVisible(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_node->setVisible(true);
|
m_node->setVisible(true);
|
||||||
}*/
|
}*/
|
||||||
} // setCreationRateAbsolute
|
} // setCreationRateAbsolute
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -451,7 +451,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
|||||||
m_node = ParticleSystemProxy::addParticleNode(m_is_glsl);
|
m_node = ParticleSystemProxy::addParticleNode(m_is_glsl);
|
||||||
else
|
else
|
||||||
m_node = irr_driver->addParticleNode();
|
m_node = irr_driver->addParticleNode();
|
||||||
|
|
||||||
if (m_is_glsl)
|
if (m_is_glsl)
|
||||||
static_cast<ParticleSystemProxy *>(m_node)->setAlphaAdditive(type->getMaterial()->isAlphaAdditive());
|
static_cast<ParticleSystemProxy *>(m_node)->setAlphaAdditive(type->getMaterial()->isAlphaAdditive());
|
||||||
}
|
}
|
||||||
@ -520,7 +520,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
|||||||
case EMITTER_POINT:
|
case EMITTER_POINT:
|
||||||
{
|
{
|
||||||
m_emitter = m_node->createPointEmitter(velocity,
|
m_emitter = m_node->createPointEmitter(velocity,
|
||||||
type->getMinRate(), type->getMaxRate(),
|
type->getMinRate(), type->getMaxRate(),
|
||||||
type->getMinColor(), type->getMinColor(),
|
type->getMinColor(), type->getMinColor(),
|
||||||
lifeTimeMin, lifeTimeMax,
|
lifeTimeMin, lifeTimeMax,
|
||||||
m_particle_type->getAngleSpread() /* angle */
|
m_particle_type->getAngleSpread() /* angle */
|
||||||
@ -680,7 +680,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
|||||||
if (flips)
|
if (flips)
|
||||||
{
|
{
|
||||||
if (m_is_glsl)
|
if (m_is_glsl)
|
||||||
static_cast<ParticleSystemProxy *>(m_node)->setFlip();
|
static_cast<ParticleSystemProxy *>(m_node)->setFlip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // setParticleType
|
} // setParticleType
|
||||||
@ -689,7 +689,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
|
|||||||
|
|
||||||
void ParticleEmitter::addHeightMapAffector(Track* t)
|
void ParticleEmitter::addHeightMapAffector(Track* t)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_is_glsl)
|
if (m_is_glsl)
|
||||||
{
|
{
|
||||||
const Vec3* aabb_min;
|
const Vec3* aabb_min;
|
||||||
|
@ -95,7 +95,7 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
|
|||||||
else if (emitterShape == "sphere")
|
else if (emitterShape == "sphere")
|
||||||
{
|
{
|
||||||
m_shape = EMITTER_SPHERE;
|
m_shape = EMITTER_SPHERE;
|
||||||
|
|
||||||
xml->get("radius", &m_sphere_radius);
|
xml->get("radius", &m_sphere_radius);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -169,7 +169,7 @@ ParticleKind::ParticleKind(const std::string file) : m_min_start_color(255,255,2
|
|||||||
bool has_y = size->get("y-increase-factor", &m_scale_affector_factor_y) == 1;
|
bool has_y = size->get("y-increase-factor", &m_scale_affector_factor_y) == 1;
|
||||||
m_has_scale_affector = (has_x || has_y);
|
m_has_scale_affector = (has_x || has_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_has_scale_affector = false;
|
m_has_scale_affector = false;
|
||||||
|
@ -58,11 +58,11 @@ PostProcessing::PostProcessing(IVideoDriver* video_driver)
|
|||||||
io::IReadFile *areamap = irr_driver->getDevice()->getFileSystem()->
|
io::IReadFile *areamap = irr_driver->getDevice()->getFileSystem()->
|
||||||
createMemoryReadFile((void *) AreaMap33, sizeof(AreaMap33),
|
createMemoryReadFile((void *) AreaMap33, sizeof(AreaMap33),
|
||||||
"AreaMap33", false);
|
"AreaMap33", false);
|
||||||
if (!areamap)
|
if (!areamap)
|
||||||
{
|
{
|
||||||
Log::fatal("postprocessing", "Failed to load the areamap");
|
Log::fatal("postprocessing", "Failed to load the areamap");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_areamap = irr_driver->getVideoDriver()->getTexture(areamap);
|
m_areamap = irr_driver->getVideoDriver()->getTexture(areamap);
|
||||||
areamap->drop();
|
areamap->drop();
|
||||||
|
|
||||||
@ -207,77 +207,77 @@ void PostProcessing::update(float dt)
|
|||||||
static
|
static
|
||||||
void renderBloom(ITexture *in)
|
void renderBloom(ITexture *in)
|
||||||
{
|
{
|
||||||
const float threshold = World::getWorld()->getTrack()->getBloomThreshold();
|
const float threshold = World::getWorld()->getTrack()->getBloomThreshold();
|
||||||
glUseProgram(FullScreenShader::BloomShader::Program);
|
glUseProgram(FullScreenShader::BloomShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::BloomShader::vao);
|
glBindVertexArray(FullScreenShader::BloomShader::vao);
|
||||||
glUniform1f(FullScreenShader::BloomShader::uniform_low, threshold);
|
glUniform1f(FullScreenShader::BloomShader::uniform_low, threshold);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glUniform1i(FullScreenShader::BloomShader::uniform_texture, 0);
|
glUniform1i(FullScreenShader::BloomShader::uniform_texture, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void renderBloomBlend(ITexture *in)
|
void renderBloomBlend(ITexture *in)
|
||||||
{
|
{
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFunc(GL_ONE, GL_ONE);
|
glBlendFunc(GL_ONE, GL_ONE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glUseProgram(FullScreenShader::BloomBlendShader::Program);
|
glUseProgram(FullScreenShader::BloomBlendShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::BloomBlendShader::vao);
|
glBindVertexArray(FullScreenShader::BloomBlendShader::vao);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glUniform1i(FullScreenShader::BloomBlendShader::uniform_texture, 0);
|
glUniform1i(FullScreenShader::BloomBlendShader::uniform_texture, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void renderColorLevel(ITexture *in)
|
void renderColorLevel(ITexture *in)
|
||||||
{
|
{
|
||||||
core::vector3df m_inlevel = World::getWorld()->getTrack()->getColorLevelIn();
|
core::vector3df m_inlevel = World::getWorld()->getTrack()->getColorLevelIn();
|
||||||
core::vector2df m_outlevel = World::getWorld()->getTrack()->getColorLevelOut();
|
core::vector2df m_outlevel = World::getWorld()->getTrack()->getColorLevelOut();
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glUseProgram(FullScreenShader::ColorLevelShader::Program);
|
glUseProgram(FullScreenShader::ColorLevelShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::ColorLevelShader::vao);
|
glBindVertexArray(FullScreenShader::ColorLevelShader::vao);
|
||||||
glUniform3f(FullScreenShader::ColorLevelShader::uniform_inlevel, m_inlevel.X, m_inlevel.Y, m_inlevel.Z);
|
glUniform3f(FullScreenShader::ColorLevelShader::uniform_inlevel, m_inlevel.X, m_inlevel.Y, m_inlevel.Z);
|
||||||
glUniform2f(FullScreenShader::ColorLevelShader::uniform_outlevel, m_outlevel.X, m_outlevel.Y);
|
glUniform2f(FullScreenShader::ColorLevelShader::uniform_outlevel, m_outlevel.X, m_outlevel.Y);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)));
|
glBindTexture(GL_TEXTURE_2D, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glUniform1i(FullScreenShader::ColorLevelShader::uniform_tex, 0);
|
glUniform1i(FullScreenShader::ColorLevelShader::uniform_tex, 0);
|
||||||
glUniform1i(FullScreenShader::ColorLevelShader::uniform_dtex, 1);
|
glUniform1i(FullScreenShader::ColorLevelShader::uniform_dtex, 1);
|
||||||
glUniformMatrix4fv(FullScreenShader::ColorLevelShader::uniform_invprojm, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
|
glUniformMatrix4fv(FullScreenShader::ColorLevelShader::uniform_invprojm, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer());
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff)
|
void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff)
|
||||||
@ -349,103 +349,103 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
|||||||
|
|
||||||
void PostProcessing::renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height)
|
void PostProcessing::renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height)
|
||||||
{
|
{
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
{
|
{
|
||||||
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
||||||
glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program);
|
glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao);
|
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao);
|
||||||
|
|
||||||
glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height);
|
glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0);
|
glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
||||||
glUseProgram(FullScreenShader::Gaussian3HBlurShader::Program);
|
glUseProgram(FullScreenShader::Gaussian3HBlurShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::vao);
|
glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::vao);
|
||||||
|
|
||||||
glUniform2f(FullScreenShader::Gaussian3HBlurShader::uniform_pixel, inv_width, inv_height);
|
glUniform2f(FullScreenShader::Gaussian3HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(temprtt));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(temprtt));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glUniform1i(FullScreenShader::Gaussian3HBlurShader::uniform_tex, 0);
|
glUniform1i(FullScreenShader::Gaussian3HBlurShader::uniform_tex, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessing::renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height)
|
void PostProcessing::renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height)
|
||||||
{
|
{
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
{
|
{
|
||||||
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
||||||
glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program);
|
glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao);
|
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao);
|
||||||
|
|
||||||
glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height);
|
glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0);
|
glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
||||||
glUseProgram(FullScreenShader::Gaussian6HBlurShader::Program);
|
glUseProgram(FullScreenShader::Gaussian6HBlurShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::vao);
|
glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::vao);
|
||||||
|
|
||||||
glUniform2f(FullScreenShader::Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height);
|
glUniform2f(FullScreenShader::Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(temprtt));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(temprtt));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glUniform1i(FullScreenShader::Gaussian6HBlurShader::uniform_tex, 0);
|
glUniform1i(FullScreenShader::Gaussian6HBlurShader::uniform_tex, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessing::renderPassThrough(ITexture *tex)
|
void PostProcessing::renderPassThrough(ITexture *tex)
|
||||||
{
|
{
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glUseProgram(FullScreenShader::PassThroughShader::Program);
|
glUseProgram(FullScreenShader::PassThroughShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::PassThroughShader::vao);
|
glBindVertexArray(FullScreenShader::PassThroughShader::vao);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glUniform1i(FullScreenShader::PassThroughShader::uniform_texture, 0);
|
glUniform1i(FullScreenShader::PassThroughShader::uniform_texture, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessing::renderPassThrough(GLuint tex)
|
void PostProcessing::renderPassThrough(GLuint tex)
|
||||||
@ -471,85 +471,85 @@ void PostProcessing::renderPassThrough(GLuint tex)
|
|||||||
|
|
||||||
void PostProcessing::renderGlow(ITexture *tex)
|
void PostProcessing::renderGlow(ITexture *tex)
|
||||||
{
|
{
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glUseProgram(FullScreenShader::GlowShader::Program);
|
glUseProgram(FullScreenShader::GlowShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::GlowShader::vao);
|
glBindVertexArray(FullScreenShader::GlowShader::vao);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex));
|
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(tex));
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glUniform1i(FullScreenShader::GlowShader::uniform_tex, 0);
|
glUniform1i(FullScreenShader::GlowShader::uniform_tex, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
ITexture *noise_tex = 0;
|
ITexture *noise_tex = 0;
|
||||||
|
|
||||||
void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm)
|
void PostProcessing::renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm)
|
||||||
{
|
{
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
if (!noise_tex)
|
if (!noise_tex)
|
||||||
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str());
|
noise_tex = irr_driver->getTexture(file_manager->getAsset("textures/noise.png").c_str());
|
||||||
|
|
||||||
glUseProgram(FullScreenShader::SSAOShader::Program);
|
glUseProgram(FullScreenShader::SSAOShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::SSAOShader::vao);
|
glBindVertexArray(FullScreenShader::SSAOShader::vao);
|
||||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
||||||
setTexture(1, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_LINEAR, GL_LINEAR);
|
setTexture(1, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_LINEAR, GL_LINEAR);
|
||||||
setTexture(2, getTextureGLuint(noise_tex), GL_NEAREST, GL_NEAREST);
|
setTexture(2, getTextureGLuint(noise_tex), GL_NEAREST, GL_NEAREST);
|
||||||
|
|
||||||
FullScreenShader::SSAOShader::setUniforms(projm, invprojm, 0, 1, 2);
|
FullScreenShader::SSAOShader::setUniforms(projm, invprojm, 0, 1, 2);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessing::renderFog(const core::matrix4 &ipvmat)
|
void PostProcessing::renderFog(const core::matrix4 &ipvmat)
|
||||||
{
|
{
|
||||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_COLOR), false, false);
|
||||||
const Track * const track = World::getWorld()->getTrack();
|
const Track * const track = World::getWorld()->getTrack();
|
||||||
|
|
||||||
// This function is only called once per frame - thus no need for setters.
|
// This function is only called once per frame - thus no need for setters.
|
||||||
const float fogmax = track->getFogMax();
|
const float fogmax = track->getFogMax();
|
||||||
const float startH = track->getFogStartHeight();
|
const float startH = track->getFogStartHeight();
|
||||||
const float endH = track->getFogEndHeight();
|
const float endH = track->getFogEndHeight();
|
||||||
const float start = track->getFogStart();
|
const float start = track->getFogStart();
|
||||||
const float end = track->getFogEnd();
|
const float end = track->getFogEnd();
|
||||||
const SColor tmpcol = track->getFogColor();
|
const SColor tmpcol = track->getFogColor();
|
||||||
|
|
||||||
core::vector3df col( tmpcol.getRed() / 255.0f,
|
core::vector3df col( tmpcol.getRed() / 255.0f,
|
||||||
tmpcol.getGreen() / 255.0f,
|
tmpcol.getGreen() / 255.0f,
|
||||||
tmpcol.getBlue() / 255.0f );
|
tmpcol.getBlue() / 255.0f );
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
glUseProgram(FullScreenShader::FogShader::Program);
|
glUseProgram(FullScreenShader::FogShader::Program);
|
||||||
glBindVertexArray(FullScreenShader::FogShader::vao);
|
glBindVertexArray(FullScreenShader::FogShader::vao);
|
||||||
|
|
||||||
setTexture(0, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
setTexture(0, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
|
||||||
FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, 0);
|
FullScreenShader::FogShader::setUniforms(ipvmat, fogmax, startH, endH, start, end, col, 0);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessing::renderMotionBlur(unsigned cam, ITexture *in, ITexture *out)
|
void PostProcessing::renderMotionBlur(unsigned cam, ITexture *in, ITexture *out)
|
||||||
@ -647,24 +647,24 @@ void PostProcessing::render()
|
|||||||
mocb->setCurrentCamera(cam);
|
mocb->setCurrentCamera(cam);
|
||||||
ITexture *in = irr_driver->getRTT(RTT_COLOR);
|
ITexture *in = irr_driver->getRTT(RTT_COLOR);
|
||||||
ITexture *out = irr_driver->getRTT(RTT_TMP1);
|
ITexture *out = irr_driver->getRTT(RTT_TMP1);
|
||||||
// Each effect uses these as named, and sets them up for the next effect.
|
// Each effect uses these as named, and sets them up for the next effect.
|
||||||
// This allows chaining effects where some may be disabled.
|
// This allows chaining effects where some may be disabled.
|
||||||
|
|
||||||
// As the original color shouldn't be touched, the first effect can't be disabled.
|
// As the original color shouldn't be touched, the first effect can't be disabled.
|
||||||
|
|
||||||
PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00);
|
PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00);
|
||||||
if (1) // bloom
|
if (1) // bloom
|
||||||
{
|
{
|
||||||
// Blit the base to tmp1
|
// Blit the base to tmp1
|
||||||
drv->setRenderTarget(out, true, false);
|
drv->setRenderTarget(out, true, false);
|
||||||
renderPassThrough(in);
|
renderPassThrough(in);
|
||||||
|
|
||||||
const bool globalbloom = World::getWorld()->getTrack()->getBloom();
|
const bool globalbloom = World::getWorld()->getTrack()->getBloom();
|
||||||
|
|
||||||
if (globalbloom)
|
if (globalbloom)
|
||||||
{
|
{
|
||||||
drv->setRenderTarget(irr_driver->getRTT(RTT_TMP3), true, false);
|
drv->setRenderTarget(irr_driver->getRTT(RTT_TMP3), true, false);
|
||||||
renderBloom(in);
|
renderBloom(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -681,23 +681,23 @@ void PostProcessing::render()
|
|||||||
|
|
||||||
// To half
|
// To half
|
||||||
drv->setRenderTarget(irr_driver->getRTT(RTT_HALF1), true, false);
|
drv->setRenderTarget(irr_driver->getRTT(RTT_HALF1), true, false);
|
||||||
renderPassThrough(irr_driver->getRTT(RTT_TMP3));
|
renderPassThrough(irr_driver->getRTT(RTT_TMP3));
|
||||||
|
|
||||||
|
|
||||||
// To quarter
|
// To quarter
|
||||||
drv->setRenderTarget(irr_driver->getRTT(RTT_QUARTER1), true, false);
|
drv->setRenderTarget(irr_driver->getRTT(RTT_QUARTER1), true, false);
|
||||||
renderPassThrough(irr_driver->getRTT(RTT_HALF1));
|
renderPassThrough(irr_driver->getRTT(RTT_HALF1));
|
||||||
|
|
||||||
// To eighth
|
// To eighth
|
||||||
drv->setRenderTarget(irr_driver->getRTT(RTT_EIGHTH1), true, false);
|
drv->setRenderTarget(irr_driver->getRTT(RTT_EIGHTH1), true, false);
|
||||||
renderPassThrough(irr_driver->getRTT(RTT_QUARTER1));
|
renderPassThrough(irr_driver->getRTT(RTT_QUARTER1));
|
||||||
|
|
||||||
// Blur it for distribution.
|
// Blur it for distribution.
|
||||||
renderGaussian6Blur(irr_driver->getRTT(RTT_EIGHTH1), irr_driver->getRTT(RTT_EIGHTH2), 8.f / UserConfigParams::m_width, 8.f / UserConfigParams::m_height);
|
renderGaussian6Blur(irr_driver->getRTT(RTT_EIGHTH1), irr_driver->getRTT(RTT_EIGHTH2), 8.f / UserConfigParams::m_width, 8.f / UserConfigParams::m_height);
|
||||||
|
|
||||||
// Additively blend on top of tmp1
|
// Additively blend on top of tmp1
|
||||||
drv->setRenderTarget(out, false, false);
|
drv->setRenderTarget(out, false, false);
|
||||||
renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1));
|
renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1));
|
||||||
} // end if bloom
|
} // end if bloom
|
||||||
|
|
||||||
in = irr_driver->getRTT(RTT_TMP1);
|
in = irr_driver->getRTT(RTT_TMP1);
|
||||||
@ -735,7 +735,7 @@ void PostProcessing::render()
|
|||||||
|
|
||||||
|
|
||||||
// Blur
|
// Blur
|
||||||
renderGaussian3Blur(irr_driver->getRTT(RTT_QUARTER1),
|
renderGaussian3Blur(irr_driver->getRTT(RTT_QUARTER1),
|
||||||
irr_driver->getRTT(RTT_QUARTER2),
|
irr_driver->getRTT(RTT_QUARTER2),
|
||||||
4.f / UserConfigParams::m_width,
|
4.f / UserConfigParams::m_width,
|
||||||
4.f / UserConfigParams::m_height);
|
4.f / UserConfigParams::m_height);
|
||||||
@ -853,14 +853,14 @@ void PostProcessing::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Final blit
|
// Final blit
|
||||||
// TODO : Use glBlitFramebuffer
|
// TODO : Use glBlitFramebuffer
|
||||||
drv->setRenderTarget(ERT_FRAME_BUFFER, false, false);
|
drv->setRenderTarget(ERT_FRAME_BUFFER, false, false);
|
||||||
if (irr_driver->getNormals())
|
if (irr_driver->getNormals())
|
||||||
renderPassThrough(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
|
renderPassThrough(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
|
||||||
else if (irr_driver->getSSAOViz())
|
else if (irr_driver->getSSAOViz())
|
||||||
renderPassThrough(irr_driver->getRTT(RTT_SSAO));
|
renderPassThrough(irr_driver->getRTT(RTT_SSAO));
|
||||||
else
|
else
|
||||||
renderColorLevel(in);
|
renderColorLevel(in);
|
||||||
}
|
}
|
||||||
} // render
|
} // render
|
||||||
|
|
||||||
|
@ -72,24 +72,24 @@ public:
|
|||||||
void begin();
|
void begin();
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
|
|
||||||
/** Generate diffuse and specular map */
|
/** Generate diffuse and specular map */
|
||||||
void renderSunlight();
|
void renderSunlight();
|
||||||
void renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, unsigned depthtex);
|
void renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, unsigned depthtex);
|
||||||
|
|
||||||
void renderFog(const core::matrix4 &ipvmat);
|
void renderFog(const core::matrix4 &ipvmat);
|
||||||
void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm);
|
void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm);
|
||||||
void renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff);
|
void renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff);
|
||||||
|
|
||||||
/** Blur the in texture */
|
/** Blur the in texture */
|
||||||
void renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
void renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
||||||
void renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
void renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
||||||
|
|
||||||
/** Render tex. Used for blit/texture resize */
|
/** Render tex. Used for blit/texture resize */
|
||||||
void renderPassThrough(video::ITexture *tex);
|
void renderPassThrough(video::ITexture *tex);
|
||||||
void renderPassThrough(unsigned tex);
|
void renderPassThrough(unsigned tex);
|
||||||
|
|
||||||
void renderMotionBlur(unsigned cam, video::ITexture *in, video::ITexture *out);
|
void renderMotionBlur(unsigned cam, video::ITexture *in, video::ITexture *out);
|
||||||
void renderGlow(video::ITexture *tex);
|
void renderGlow(video::ITexture *tex);
|
||||||
|
|
||||||
/** Render the post-processed scene */
|
/** Render the post-processed scene */
|
||||||
void render();
|
void render();
|
||||||
|
@ -189,14 +189,14 @@ void IrrDriver::renderGLSL(float dt)
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Fire up the MRT
|
// Fire up the MRT
|
||||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH), false, false);
|
||||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
|
PROFILER_PUSH_CPU_MARKER("- Solid Pass 1", 0xFF, 0x00, 0x00);
|
||||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
|
irr_driver->setPhase(SOLID_NORMAL_AND_DEPTH_PASS);
|
||||||
m_scene_manager->drawAll(m_renderpass);
|
m_scene_manager->drawAll(m_renderpass);
|
||||||
@ -204,7 +204,7 @@ void IrrDriver::renderGLSL(float dt)
|
|||||||
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
|
irr_driver->setViewMatrix(irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW));
|
||||||
irr_driver->genProjViewMatrix();
|
irr_driver->genProjViewMatrix();
|
||||||
|
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
|
|
||||||
// Todo : reenable glow and shadows
|
// Todo : reenable glow and shadows
|
||||||
//ShadowImportanceProvider * const sicb = (ShadowImportanceProvider *)
|
//ShadowImportanceProvider * const sicb = (ShadowImportanceProvider *)
|
||||||
@ -227,14 +227,14 @@ void IrrDriver::renderGLSL(float dt)
|
|||||||
|
|
||||||
// Lights
|
// Lights
|
||||||
renderLights(cambox, camnode, overridemat, cam, dt);
|
renderLights(cambox, camnode, overridemat, cam, dt);
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
|
|
||||||
PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF);
|
PROFILER_PUSH_CPU_MARKER("- Solid Pass 2", 0x00, 0x00, 0xFF);
|
||||||
irr_driver->setPhase(SOLID_LIT_PASS);
|
irr_driver->setPhase(SOLID_LIT_PASS);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_SOLID;
|
||||||
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_TMP1)), GL_NEAREST, GL_NEAREST);
|
||||||
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
setTexture(1, getTextureGLuint(irr_driver->getRTT(RTT_TMP2)), GL_NEAREST, GL_NEAREST);
|
||||||
@ -248,27 +248,27 @@ void IrrDriver::renderGLSL(float dt)
|
|||||||
|
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
|
|
||||||
if (World::getWorld()->getTrack()->isFogEnabled())
|
if (World::getWorld()->getTrack()->isFogEnabled())
|
||||||
{
|
{
|
||||||
PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00);
|
PROFILER_PUSH_CPU_MARKER("- Fog", 0xFF, 0x00, 0x00);
|
||||||
m_post_processing->renderFog(irr_driver->getInvProjMatrix());
|
m_post_processing->renderFog(irr_driver->getInvProjMatrix());
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILER_PUSH_CPU_MARKER("- Glow", 0xFF, 0xFF, 0x00);
|
PROFILER_PUSH_CPU_MARKER("- Glow", 0xFF, 0xFF, 0x00);
|
||||||
|
|
||||||
// Render anything glowing.
|
// Render anything glowing.
|
||||||
if (!m_mipviz && !m_wireframe)
|
if (!m_mipviz && !m_wireframe)
|
||||||
{
|
{
|
||||||
irr_driver->setPhase(GLOW_PASS);
|
irr_driver->setPhase(GLOW_PASS);
|
||||||
renderGlow(overridemat, glows, cambox, cam);
|
renderGlow(overridemat, glows, cambox, cam);
|
||||||
} // end glow
|
} // end glow
|
||||||
|
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
|
|
||||||
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
|
PROFILER_PUSH_CPU_MARKER("- Skybox", 0xFF, 0x00, 0xFF);
|
||||||
renderSkybox();
|
renderSkybox();
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
|
|
||||||
PROFILER_PUSH_CPU_MARKER("- Lensflare/godray", 0x00, 0xFF, 0xFF);
|
PROFILER_PUSH_CPU_MARKER("- Lensflare/godray", 0x00, 0xFF, 0xFF);
|
||||||
// Is the lens flare enabled & visible? Check last frame's query.
|
// Is the lens flare enabled & visible? Check last frame's query.
|
||||||
@ -276,7 +276,7 @@ void IrrDriver::renderGLSL(float dt)
|
|||||||
const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays();
|
const bool hasgodrays = World::getWorld()->getTrack()->hasGodRays();
|
||||||
if (true)//hasflare || hasgodrays)
|
if (true)//hasflare || hasgodrays)
|
||||||
{
|
{
|
||||||
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
irr::video::COpenGLDriver* gl_driver = (irr::video::COpenGLDriver*)m_device->getVideoDriver();
|
||||||
|
|
||||||
GLuint res = 0;
|
GLuint res = 0;
|
||||||
if (m_query_issued)
|
if (m_query_issued)
|
||||||
@ -305,26 +305,26 @@ void IrrDriver::renderGLSL(float dt)
|
|||||||
|
|
||||||
// We need to re-render camera due to the per-cam-node hack.
|
// We need to re-render camera due to the per-cam-node hack.
|
||||||
PROFILER_PUSH_CPU_MARKER("- Transparent Pass", 0xFF, 0x00, 0x00);
|
PROFILER_PUSH_CPU_MARKER("- Transparent Pass", 0xFF, 0x00, 0x00);
|
||||||
irr_driver->setPhase(TRANSPARENT_PASS);
|
irr_driver->setPhase(TRANSPARENT_PASS);
|
||||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT;
|
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT;
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
m_scene_manager->drawAll(m_renderpass);
|
m_scene_manager->drawAll(m_renderpass);
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
|
|
||||||
PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00);
|
PROFILER_PUSH_CPU_MARKER("- Particles", 0xFF, 0xFF, 0x00);
|
||||||
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
|
m_renderpass = scene::ESNRP_CAMERA | scene::ESNRP_TRANSPARENT_EFFECT;
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
m_scene_manager->drawAll(m_renderpass);
|
m_scene_manager->drawAll(m_renderpass);
|
||||||
PROFILER_POP_CPU_MARKER();
|
PROFILER_POP_CPU_MARKER();
|
||||||
|
|
||||||
PROFILER_PUSH_CPU_MARKER("- Displacement", 0x00, 0x00, 0xFF);
|
PROFILER_PUSH_CPU_MARKER("- Displacement", 0x00, 0x00, 0xFF);
|
||||||
// Handle displacing nodes, if any
|
// Handle displacing nodes, if any
|
||||||
@ -689,10 +689,10 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat,
|
|||||||
glStencilFunc(GL_ALWAYS, 1, ~0);
|
glStencilFunc(GL_ALWAYS, 1, ~0);
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
for (u32 i = 0; i < glowcount; i++)
|
for (u32 i = 0; i < glowcount; i++)
|
||||||
{
|
{
|
||||||
@ -723,22 +723,22 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat,
|
|||||||
|
|
||||||
// To half
|
// To half
|
||||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_HALF1), false, false);
|
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_HALF1), false, false);
|
||||||
m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_TMP1));
|
m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_TMP1));
|
||||||
|
|
||||||
// To quarter
|
// To quarter
|
||||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_QUARTER1), false, false);
|
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_QUARTER1), false, false);
|
||||||
m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_HALF1));
|
m_post_processing->renderPassThrough(m_rtts->getRTT(RTT_HALF1));
|
||||||
|
|
||||||
// Blur it
|
// Blur it
|
||||||
m_post_processing->renderGaussian6Blur(m_rtts->getRTT(RTT_QUARTER1), m_rtts->getRTT(RTT_QUARTER2), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
m_post_processing->renderGaussian6Blur(m_rtts->getRTT(RTT_QUARTER1), m_rtts->getRTT(RTT_QUARTER2), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glStencilFunc(GL_EQUAL, 0, ~0);
|
glStencilFunc(GL_EQUAL, 0, ~0);
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
|
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
|
||||||
m_post_processing->renderGlow(m_rtts->getRTT(RTT_QUARTER1));
|
m_post_processing->renderGlow(m_rtts->getRTT(RTT_QUARTER1));
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,9 +863,9 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
|||||||
|
|
||||||
// Blur it to reduce noise.
|
// Blur it to reduce noise.
|
||||||
if(UserConfigParams::m_ssao == 1)
|
if(UserConfigParams::m_ssao == 1)
|
||||||
m_post_processing->renderGaussian3Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_QUARTER4), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
m_post_processing->renderGaussian3Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_QUARTER4), 4.f / UserConfigParams::m_width, 4.f / UserConfigParams::m_height);
|
||||||
else if (UserConfigParams::m_ssao == 2)
|
else if (UserConfigParams::m_ssao == 2)
|
||||||
m_post_processing->renderGaussian6Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_TMP4), 1.f / UserConfigParams::m_width, 1.f / UserConfigParams::m_height);
|
m_post_processing->renderGaussian6Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_TMP4), 1.f / UserConfigParams::m_width, 1.f / UserConfigParams::m_height);
|
||||||
|
|
||||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
|
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
|
||||||
}
|
}
|
||||||
@ -1265,17 +1265,17 @@ void IrrDriver::renderSkybox()
|
|||||||
if (!SkyboxCubeMap)
|
if (!SkyboxCubeMap)
|
||||||
generateSkyboxCubemap();
|
generateSkyboxCubemap();
|
||||||
glBindVertexArray(MeshShader::SkyboxShader::cubevao);
|
glBindVertexArray(MeshShader::SkyboxShader::cubevao);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
assert(SkyboxTextures.size() == 6);
|
assert(SkyboxTextures.size() == 6);
|
||||||
core::matrix4 transform = irr_driver->getProjViewMatrix();
|
core::matrix4 transform = irr_driver->getProjViewMatrix();
|
||||||
core::matrix4 translate;
|
core::matrix4 translate;
|
||||||
translate.setTranslation(camera->getAbsolutePosition());
|
translate.setTranslation(camera->getAbsolutePosition());
|
||||||
|
|
||||||
// Draw the sky box between the near and far clip plane
|
// Draw the sky box between the near and far clip plane
|
||||||
const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
|
const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
|
||||||
core::matrix4 scale;
|
core::matrix4 scale;
|
||||||
scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
|
scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
|
||||||
transform *= translate * scale;
|
transform *= translate * scale;
|
||||||
core::matrix4 invtransform;
|
core::matrix4 invtransform;
|
||||||
transform.getInverse(invtransform);
|
transform.getInverse(invtransform);
|
||||||
|
|
||||||
@ -1297,15 +1297,15 @@ void IrrDriver::renderDisplacement(video::SOverrideMaterial &overridemat,
|
|||||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_TMP4), true, false);
|
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_TMP4), true, false);
|
||||||
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_DISPLACE), true, false);
|
irr_driver->getVideoDriver()->setRenderTarget(irr_driver->getRTT(RTT_DISPLACE), true, false);
|
||||||
|
|
||||||
DisplaceProvider * const cb = (DisplaceProvider *)irr_driver->getCallback(ES_DISPLACE);
|
DisplaceProvider * const cb = (DisplaceProvider *)irr_driver->getCallback(ES_DISPLACE);
|
||||||
cb->update();
|
cb->update();
|
||||||
|
|
||||||
const int displacingcount = m_displacing.size();
|
const int displacingcount = m_displacing.size();
|
||||||
irr_driver->setPhase(DISPLACEMENT_PASS);
|
irr_driver->setPhase(DISPLACEMENT_PASS);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
|
@ -70,7 +70,7 @@ RTT::RTT()
|
|||||||
rtts[RTT_TMP2] = drv->addRenderTargetTexture(res, "rtt.tmp2", ECF_A8R8G8B8, stencil);
|
rtts[RTT_TMP2] = drv->addRenderTargetTexture(res, "rtt.tmp2", ECF_A8R8G8B8, stencil);
|
||||||
rtts[RTT_TMP3] = drv->addRenderTargetTexture(res, "rtt.tmp3", ECF_A8R8G8B8, stencil);
|
rtts[RTT_TMP3] = drv->addRenderTargetTexture(res, "rtt.tmp3", ECF_A8R8G8B8, stencil);
|
||||||
rtts[RTT_TMP4] = drv->addRenderTargetTexture(res, "rtt.tmp4", ECF_R8, stencil);
|
rtts[RTT_TMP4] = drv->addRenderTargetTexture(res, "rtt.tmp4", ECF_R8, stencil);
|
||||||
rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_G16R16F, stencil);
|
rtts[RTT_NORMAL_AND_DEPTH] = drv->addRenderTargetTexture(res, "rtt.normal_and_depth", ECF_G16R16F, stencil);
|
||||||
rtts[RTT_COLOR] = drv->addRenderTargetTexture(res, "rtt.color", ECF_A16B16G16R16F, stencil);
|
rtts[RTT_COLOR] = drv->addRenderTargetTexture(res, "rtt.color", ECF_A16B16G16R16F, stencil);
|
||||||
|
|
||||||
rtts[RTT_HALF1] = drv->addRenderTargetTexture(half, "rtt.half1", ECF_A8R8G8B8, stencil);
|
rtts[RTT_HALF1] = drv->addRenderTargetTexture(half, "rtt.half1", ECF_A8R8G8B8, stencil);
|
||||||
|
@ -23,8 +23,8 @@ const u16 ScreenQuad::indices[4] = {0, 1, 2, 3};
|
|||||||
static const SColor white(255, 255, 255, 255);
|
static const SColor white(255, 255, 255, 255);
|
||||||
|
|
||||||
const S3DVertex ScreenQuad::vertices[4] = {
|
const S3DVertex ScreenQuad::vertices[4] = {
|
||||||
S3DVertex(-1, 1, 0, 0, 1, 0, white, 0, 1),
|
S3DVertex(-1, 1, 0, 0, 1, 0, white, 0, 1),
|
||||||
S3DVertex(1, 1, 0, 0, 1, 0, white, 1, 1),
|
S3DVertex(1, 1, 0, 0, 1, 0, white, 1, 1),
|
||||||
S3DVertex(-1, -1, 0, 0, 1, 0, white, 0, 0),
|
S3DVertex(-1, -1, 0, 0, 1, 0, white, 0, 0),
|
||||||
S3DVertex(1, -1, 0, 0, 1, 0, white, 1, 0),
|
S3DVertex(1, -1, 0, 0, 1, 0, white, 1, 0),
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
|||||||
#include <IMeshSceneNode.h>
|
#include <IMeshSceneNode.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
typedef unsigned int GLuint;
|
typedef unsigned int GLuint;
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
class ParticleSystemProxy;
|
class ParticleSystemProxy;
|
||||||
|
|
||||||
@ -36,22 +36,22 @@ namespace MeshShader
|
|||||||
class ObjectPass1Shader
|
class ObjectPass1Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_normal;
|
static GLuint attrib_position, attrib_normal;
|
||||||
static GLuint uniform_MVP, uniform_TIMV;
|
static GLuint uniform_MVP, uniform_TIMV;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectRefPass1Shader
|
class ObjectRefPass1Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_TM, uniform_TIMV, uniform_tex;
|
static GLuint uniform_MVP, uniform_TM, uniform_TIMV, uniform_tex;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_texture);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_texture);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,108 +80,108 @@ public:
|
|||||||
class ObjectPass2Shader
|
class ObjectPass2Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||||
static GLuint TU_Albedo;
|
static GLuint TU_Albedo;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DetailledObjectPass2Shader
|
class DetailledObjectPass2Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||||
static GLuint TU_Albedo, TU_detail;
|
static GLuint TU_Albedo, TU_detail;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectRimLimitShader
|
class ObjectRimLimitShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_screen, uniform_ambient;
|
||||||
static GLuint TU_Albedo;
|
static GLuint TU_Albedo;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class UntexturedObjectShader
|
class UntexturedObjectShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_color;
|
static GLuint attrib_position, attrib_color;
|
||||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectUnlitShader
|
class ObjectUnlitShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_MVP;
|
static GLuint uniform_MVP;
|
||||||
static GLuint TU_tex;
|
static GLuint TU_tex;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ObjectRefPass2Shader
|
class ObjectRefPass2Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_TM, uniform_screen, uniform_ambient;
|
||||||
static GLuint TU_Albedo;
|
static GLuint TU_Albedo;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GrassPass2Shader
|
class GrassPass2Shader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir;
|
static GLuint uniform_MVP, uniform_screen, uniform_ambient, uniform_windDir;
|
||||||
static GLuint TU_Albedo;
|
static GLuint TU_Albedo;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SphereMapShader
|
class SphereMapShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_normal;
|
static GLuint attrib_position, attrib_normal;
|
||||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TVM, uniform_invproj, uniform_screen;
|
static GLuint uniform_MVP, uniform_TIMV, uniform_TVM, uniform_invproj, uniform_screen;
|
||||||
static GLuint TU_tex;
|
static GLuint TU_tex;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeViewMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeViewMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &InvProj, const core::vector2df& screen);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SplattingShader
|
class SplattingShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
static GLuint uniform_MVP, uniform_screen, uniform_ambient;
|
||||||
static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
|
static GLuint TU_tex_layout, TU_tex_detail0, TU_tex_detail1, TU_tex_detail2, TU_tex_detail3;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CausticsShader
|
class CausticsShader
|
||||||
@ -199,22 +199,22 @@ public:
|
|||||||
class BubbleShader
|
class BubbleShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_tex, uniform_time, uniform_transparency;
|
static GLuint uniform_MVP, uniform_tex, uniform_time, uniform_transparency;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex, float time, float transparency);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, unsigned TU_tex, float time, float transparency);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TransparentShader
|
class TransparentShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||||
static GLuint uniform_MVP, uniform_TM, uniform_tex;
|
static GLuint uniform_MVP, uniform_TM, uniform_tex;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -232,24 +232,24 @@ public:
|
|||||||
class BillboardShader
|
class BillboardShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_corner, attrib_texcoord;
|
static GLuint attrib_corner, attrib_texcoord;
|
||||||
static GLuint uniform_MV, uniform_P, uniform_tex, uniform_Position, uniform_Size;
|
static GLuint uniform_MV, uniform_P, uniform_tex, uniform_Position, uniform_Size;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex);
|
static void setUniforms(const core::matrix4 &ModelViewMatrix, const core::matrix4 &ProjectionMatrix, const core::vector3df &Position, const core::dimension2d<float> &size, unsigned TU_tex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ColorizeShader
|
class ColorizeShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position;
|
static GLuint attrib_position;
|
||||||
static GLuint uniform_MVP, uniform_col;
|
static GLuint uniform_MVP, uniform_col;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, float r, float g, float b);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShadowShader
|
class ShadowShader
|
||||||
@ -299,11 +299,11 @@ public:
|
|||||||
class DisplaceShader
|
class DisplaceShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
static GLuint attrib_position, attrib_texcoord, attrib_second_texcoord;
|
||||||
static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_screen, uniform_dir, uniform_dir2;
|
static GLuint uniform_MVP, uniform_MV, uniform_displacement_tex, uniform_mask_tex, uniform_color_tex, uniform_screen, uniform_dir, uniform_dir2;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
|
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &ModelViewMatrix, const core::vector2df &dir, const core::vector2df &dir2, const core::vector2df &screen, unsigned TU_displacement_tex, unsigned TU_mask_tex, unsigned TU_color_tex);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -359,11 +359,11 @@ namespace ParticleShader
|
|||||||
class SimpleSimulationShader
|
class SimpleSimulationShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||||
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -371,23 +371,23 @@ public:
|
|||||||
class HeightmapSimulationShader
|
class HeightmapSimulationShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
static GLuint attrib_position, attrib_velocity, attrib_lifetime, attrib_initial_position, attrib_initial_velocity, attrib_initial_lifetime, attrib_size, attrib_initial_size;
|
||||||
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
static GLuint uniform_sourcematrix, uniform_dt, uniform_level, uniform_size_increase_factor;
|
||||||
static GLuint uniform_track_x, uniform_track_z, uniform_track_x_len, uniform_track_z_len, uniform_heightmap;
|
static GLuint uniform_track_x, uniform_track_z, uniform_track_x_len, uniform_track_z_len, uniform_heightmap;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimpleParticleRender
|
class SimpleParticleRender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
|
||||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to;
|
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
|
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
|
||||||
const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex,
|
const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex,
|
||||||
unsigned TU_normal_and_depth, const ParticleSystemProxy* particle_system);
|
unsigned TU_normal_and_depth, const ParticleSystemProxy* particle_system);
|
||||||
};
|
};
|
||||||
@ -395,12 +395,12 @@ public:
|
|||||||
class FlipParticleRender
|
class FlipParticleRender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
|
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz, attrib_rotationvec, attrib_anglespeed;
|
||||||
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
|
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
|
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,42 +410,42 @@ namespace FullScreenShader
|
|||||||
class BloomShader
|
class BloomShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_texture, uniform_low;
|
static GLuint uniform_texture, uniform_low;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class BloomBlendShader
|
class BloomBlendShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_texture, uniform_low;
|
static GLuint uniform_texture, uniform_low;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ColorLevelShader
|
class ColorLevelShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_tex, uniform_invprojm, uniform_dtex, uniform_inlevel, uniform_outlevel;
|
static GLuint uniform_tex, uniform_invprojm, uniform_dtex, uniform_inlevel, uniform_outlevel;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SunLightShader
|
class SunLightShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col, uniform_invproj;
|
static GLuint uniform_ntex, uniform_dtex, uniform_direction, uniform_col, uniform_invproj;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex);
|
static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiffuseEnvMapShader
|
class DiffuseEnvMapShader
|
||||||
@ -473,41 +473,41 @@ public:
|
|||||||
class Gaussian6HBlurShader
|
class Gaussian6HBlurShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_tex, uniform_pixel;
|
static GLuint uniform_tex, uniform_pixel;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Gaussian3HBlurShader
|
class Gaussian3HBlurShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_tex, uniform_pixel;
|
static GLuint uniform_tex, uniform_pixel;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Gaussian6VBlurShader
|
class Gaussian6VBlurShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_tex, uniform_pixel;
|
static GLuint uniform_tex, uniform_pixel;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Gaussian3VBlurShader
|
class Gaussian3VBlurShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_tex, uniform_pixel;
|
static GLuint uniform_tex, uniform_pixel;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PenumbraHShader
|
class PenumbraHShader
|
||||||
@ -546,44 +546,44 @@ public:
|
|||||||
class PassThroughShader
|
class PassThroughShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_texture;
|
static GLuint uniform_texture;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlowShader
|
class GlowShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_tex;
|
static GLuint uniform_tex;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SSAOShader
|
class SSAOShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints;
|
static GLuint uniform_ntex, uniform_dtex, uniform_noise_texture, uniform_invprojm, uniform_projm, uniform_samplePoints;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
static float SSAOSamples[64];
|
static float SSAOSamples[64];
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise);
|
static void setUniforms(const core::matrix4& projm, const core::matrix4 &invprojm, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_noise);
|
||||||
};
|
};
|
||||||
|
|
||||||
class FogShader
|
class FogShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_ipvmat;
|
static GLuint uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col, uniform_ipvmat;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex);
|
static void setUniforms(const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MotionBlurShader
|
class MotionBlurShader
|
||||||
@ -626,13 +626,13 @@ namespace UIShader
|
|||||||
class TextureRectShader
|
class TextureRectShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord;
|
static GLuint attrib_position, attrib_texcoord;
|
||||||
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
||||||
};
|
};
|
||||||
|
|
||||||
class UniformColoredTextureRectShader
|
class UniformColoredTextureRectShader
|
||||||
@ -650,26 +650,26 @@ public:
|
|||||||
class ColoredTextureRectShader
|
class ColoredTextureRectShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
static GLuint attrib_position, attrib_texcoord, attrib_color;
|
||||||
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
static GLuint uniform_tex, uniform_center, uniform_size, uniform_texcenter, uniform_texsize;
|
||||||
static GLuint colorvbo;
|
static GLuint colorvbo;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, float tex_center_pos_x, float tex_center_pos_y, float tex_width, float tex_height, unsigned TU_tex);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ColoredRectShader
|
class ColoredRectShader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GLuint Program;
|
static GLuint Program;
|
||||||
static GLuint attrib_position;
|
static GLuint attrib_position;
|
||||||
static GLuint uniform_center, uniform_size, uniform_color;
|
static GLuint uniform_center, uniform_size, uniform_color;
|
||||||
static GLuint vao;
|
static GLuint vao;
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color);
|
static void setUniforms(float center_pos_x, float center_pos_y, float width, float height, const video::SColor &color);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,7 +690,7 @@ public:
|
|||||||
ACT(ES_GAUSSIAN3V) \
|
ACT(ES_GAUSSIAN3V) \
|
||||||
ACT(ES_MIPVIZ) \
|
ACT(ES_MIPVIZ) \
|
||||||
ACT(ES_COLORIZE) \
|
ACT(ES_COLORIZE) \
|
||||||
ACT(ES_OBJECT_UNLIT) \
|
ACT(ES_OBJECT_UNLIT) \
|
||||||
ACT(ES_OBJECTPASS) \
|
ACT(ES_OBJECTPASS) \
|
||||||
ACT(ES_OBJECTPASS_REF) \
|
ACT(ES_OBJECTPASS_REF) \
|
||||||
ACT(ES_SUNLIGHT) \
|
ACT(ES_SUNLIGHT) \
|
||||||
@ -740,7 +740,7 @@ public:
|
|||||||
void loadShaders();
|
void loadShaders();
|
||||||
private:
|
private:
|
||||||
void check(const int num) const;
|
void check(const int num) const;
|
||||||
|
|
||||||
int m_shaders[ES_COUNT];
|
int m_shaders[ES_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ const core::vector3df& rotation,
|
|||||||
const core::vector3df& scale) :
|
const core::vector3df& scale) :
|
||||||
CAnimatedMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale)
|
CAnimatedMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale)
|
||||||
{
|
{
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKAnimatedMesh::cleanGLMeshes()
|
void STKAnimatedMesh::cleanGLMeshes()
|
||||||
@ -45,13 +45,13 @@ void STKAnimatedMesh::cleanGLMeshes()
|
|||||||
|
|
||||||
void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
|
void STKAnimatedMesh::setMesh(scene::IAnimatedMesh* mesh)
|
||||||
{
|
{
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
GLmeshes.clear();
|
GLmeshes.clear();
|
||||||
for (unsigned i = 0; i < FPSM_COUNT; i++)
|
for (unsigned i = 0; i < FPSM_COUNT; i++)
|
||||||
GeometricMesh[i].clear();
|
GeometricMesh[i].clear();
|
||||||
for (unsigned i = 0; i < SM_COUNT; i++)
|
for (unsigned i = 0; i < SM_COUNT; i++)
|
||||||
ShadedMesh[i].clear();
|
ShadedMesh[i].clear();
|
||||||
CAnimatedMeshSceneNode::setMesh(mesh);
|
CAnimatedMeshSceneNode::setMesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKAnimatedMesh::drawSolidPass1(const GLMesh &mesh, GeometricMaterial type)
|
void STKAnimatedMesh::drawSolidPass1(const GLMesh &mesh, GeometricMaterial type)
|
||||||
@ -97,26 +97,26 @@ void STKAnimatedMesh::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type)
|
|||||||
|
|
||||||
void STKAnimatedMesh::render()
|
void STKAnimatedMesh::render()
|
||||||
{
|
{
|
||||||
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
video::IVideoDriver* driver = SceneManager->getVideoDriver();
|
||||||
|
|
||||||
bool isTransparentPass =
|
bool isTransparentPass =
|
||||||
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
|
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
|
||||||
|
|
||||||
++PassCount;
|
++PassCount;
|
||||||
|
|
||||||
scene::IMesh* m = getMeshForCurrentFrame();
|
scene::IMesh* m = getMeshForCurrentFrame();
|
||||||
|
|
||||||
if (m)
|
if (m)
|
||||||
{
|
{
|
||||||
Box = m->getBoundingBox();
|
Box = m->getBoundingBox();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::error("animated mesh", "Animated Mesh returned no mesh to render.");
|
Log::error("animated mesh", "Animated Mesh returned no mesh to render.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
|
||||||
|
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
{
|
{
|
||||||
@ -157,7 +157,7 @@ void STKAnimatedMesh::render()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
|
|
||||||
for (u32 i = 0; i<m->getMeshBufferCount(); ++i)
|
for (u32 i = 0; i<m->getMeshBufferCount(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode
|
class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
bool firstTime;
|
bool firstTime;
|
||||||
std::vector<GLMesh *> GeometricMesh[FPSM_COUNT];
|
std::vector<GLMesh *> GeometricMesh[FPSM_COUNT];
|
||||||
std::vector<GLMesh *> ShadedMesh[SM_COUNT];
|
std::vector<GLMesh *> ShadedMesh[SM_COUNT];
|
||||||
std::vector<GLMesh *> TransparentMesh[TM_COUNT];
|
std::vector<GLMesh *> TransparentMesh[TM_COUNT];
|
||||||
std::vector<GLMesh> GLmeshes;
|
std::vector<GLMesh> GLmeshes;
|
||||||
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView;
|
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView;
|
||||||
void drawSolidPass1(const GLMesh &mesh, GeometricMaterial type);
|
void drawSolidPass1(const GLMesh &mesh, GeometricMaterial type);
|
||||||
void drawSolidPass2(const GLMesh &mesh, ShadedMaterial type);
|
void drawSolidPass2(const GLMesh &mesh, ShadedMaterial type);
|
||||||
|
@ -9,36 +9,36 @@ static GLuint billboardvao = 0;
|
|||||||
|
|
||||||
static void createbillboardvao()
|
static void createbillboardvao()
|
||||||
{
|
{
|
||||||
glGenVertexArrays(1, &billboardvao);
|
glGenVertexArrays(1, &billboardvao);
|
||||||
glBindVertexArray(billboardvao);
|
glBindVertexArray(billboardvao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
|
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
|
||||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner);
|
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_corner);
|
||||||
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord);
|
glEnableVertexAttribArray(MeshShader::BillboardShader::attrib_texcoord);
|
||||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
glVertexAttribPointer(MeshShader::BillboardShader::attrib_corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||||
glVertexAttribPointer(MeshShader::BillboardShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float)));
|
glVertexAttribPointer(MeshShader::BillboardShader::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*) (2 * sizeof(float)));
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
STKBillboard::STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
STKBillboard::STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||||
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
|
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
|
||||||
irr::video::SColor colorTop, irr::video::SColor colorBottom) :
|
irr::video::SColor colorTop, irr::video::SColor colorBottom) :
|
||||||
CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom), IBillboardSceneNode(parent, mgr, id, position)
|
CBillboardSceneNode(parent, mgr, id, position, size, colorTop, colorBottom), IBillboardSceneNode(parent, mgr, id, position)
|
||||||
{
|
{
|
||||||
if (!billboardvao)
|
if (!billboardvao)
|
||||||
createbillboardvao();
|
createbillboardvao();
|
||||||
}
|
}
|
||||||
|
|
||||||
void STKBillboard::render()
|
void STKBillboard::render()
|
||||||
{
|
{
|
||||||
if (irr_driver->getPhase() != TRANSPARENT_PASS)
|
if (irr_driver->getPhase() != TRANSPARENT_PASS)
|
||||||
return;
|
return;
|
||||||
core::vector3df pos = getAbsolutePosition();
|
core::vector3df pos = getAbsolutePosition();
|
||||||
glBindVertexArray(billboardvao);
|
glBindVertexArray(billboardvao);
|
||||||
GLuint texid = getTextureGLuint(Material.getTexture(0));
|
GLuint texid = getTextureGLuint(Material.getTexture(0));
|
||||||
setTexture(0, texid, GL_LINEAR, GL_LINEAR);
|
setTexture(0, texid, GL_LINEAR, GL_LINEAR);
|
||||||
glUseProgram(MeshShader::BillboardShader::Program);
|
glUseProgram(MeshShader::BillboardShader::Program);
|
||||||
MeshShader::BillboardShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size, 0);
|
MeshShader::BillboardShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), pos, Size, 0);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
class STKBillboard : public irr::scene::CBillboardSceneNode
|
class STKBillboard : public irr::scene::CBillboardSceneNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
STKBillboard(irr::scene::ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||||
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
|
const irr::core::vector3df& position, const irr::core::dimension2d<irr::f32>& size,
|
||||||
irr::video::SColor colorTop = irr::video::SColor(0xFFFFFFFF),
|
irr::video::SColor colorTop = irr::video::SColor(0xFFFFFFFF),
|
||||||
irr::video::SColor colorBottom = irr::video::SColor(0xFFFFFFFF));
|
irr::video::SColor colorBottom = irr::video::SColor(0xFFFFFFFF));
|
||||||
|
|
||||||
virtual void render();
|
virtual void render();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -57,153 +57,153 @@ GLuint createVAO(GLuint vbo, GLuint idx, GLuint attrib_position, GLuint attrib_t
|
|||||||
{
|
{
|
||||||
if (attrib_position == -1)
|
if (attrib_position == -1)
|
||||||
return 0;
|
return 0;
|
||||||
GLuint vao;
|
GLuint vao;
|
||||||
glGenVertexArrays(1, &vao);
|
glGenVertexArrays(1, &vao);
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||||
glEnableVertexAttribArray(attrib_position);
|
glEnableVertexAttribArray(attrib_position);
|
||||||
if ((GLint)attrib_texcoord != -1)
|
if ((GLint)attrib_texcoord != -1)
|
||||||
glEnableVertexAttribArray(attrib_texcoord);
|
glEnableVertexAttribArray(attrib_texcoord);
|
||||||
if ((GLint)attrib_second_texcoord != -1)
|
if ((GLint)attrib_second_texcoord != -1)
|
||||||
glEnableVertexAttribArray(attrib_second_texcoord);
|
glEnableVertexAttribArray(attrib_second_texcoord);
|
||||||
if ((GLint)attrib_normal != -1)
|
if ((GLint)attrib_normal != -1)
|
||||||
glEnableVertexAttribArray(attrib_normal);
|
glEnableVertexAttribArray(attrib_normal);
|
||||||
if ((GLint)attrib_tangent != -1)
|
if ((GLint)attrib_tangent != -1)
|
||||||
glEnableVertexAttribArray(attrib_tangent);
|
glEnableVertexAttribArray(attrib_tangent);
|
||||||
if ((GLint)attrib_bitangent != -1)
|
if ((GLint)attrib_bitangent != -1)
|
||||||
glEnableVertexAttribArray(attrib_bitangent);
|
glEnableVertexAttribArray(attrib_bitangent);
|
||||||
if ((GLint)attrib_color != -1)
|
if ((GLint)attrib_color != -1)
|
||||||
glEnableVertexAttribArray(attrib_color);
|
glEnableVertexAttribArray(attrib_color);
|
||||||
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, 0);
|
glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, stride, 0);
|
||||||
if ((GLint)attrib_texcoord != -1)
|
if ((GLint)attrib_texcoord != -1)
|
||||||
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 28);
|
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 28);
|
||||||
if ((GLint)attrib_second_texcoord != -1)
|
if ((GLint)attrib_second_texcoord != -1)
|
||||||
{
|
{
|
||||||
if (stride < 44)
|
if (stride < 44)
|
||||||
Log::error("material", "Second texcoords not present in VBO");
|
Log::error("material", "Second texcoords not present in VBO");
|
||||||
glVertexAttribPointer(attrib_second_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 36);
|
glVertexAttribPointer(attrib_second_texcoord, 2, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 36);
|
||||||
}
|
}
|
||||||
if ((GLint)attrib_normal != -1)
|
if ((GLint)attrib_normal != -1)
|
||||||
glVertexAttribPointer(attrib_normal, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 12);
|
glVertexAttribPointer(attrib_normal, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*) 12);
|
||||||
if ((GLint)attrib_tangent != -1)
|
if ((GLint)attrib_tangent != -1)
|
||||||
{
|
{
|
||||||
if (stride < 48)
|
if (stride < 48)
|
||||||
Log::error("material", "Tangents not present in VBO");
|
Log::error("material", "Tangents not present in VBO");
|
||||||
glVertexAttribPointer(attrib_tangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)36);
|
glVertexAttribPointer(attrib_tangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)36);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((GLint)attrib_bitangent != -1)
|
if ((GLint)attrib_bitangent != -1)
|
||||||
{
|
{
|
||||||
if (stride < 60)
|
if (stride < 60)
|
||||||
Log::error("material", "Bitangents not present in VBO");
|
Log::error("material", "Bitangents not present in VBO");
|
||||||
glVertexAttribPointer(attrib_bitangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)48);
|
glVertexAttribPointer(attrib_bitangent, 3, GL_FLOAT, GL_FALSE, stride, (GLvoid*)48);
|
||||||
}
|
}
|
||||||
if ((GLint)attrib_color != -1)
|
if ((GLint)attrib_color != -1)
|
||||||
glVertexAttribPointer(attrib_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (GLvoid*)24);
|
glVertexAttribPointer(attrib_color, 4, GL_UNSIGNED_BYTE, GL_TRUE, stride, (GLvoid*)24);
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idx);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
return vao;
|
return vao;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
|
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
|
||||||
{
|
{
|
||||||
GLMesh result = {};
|
GLMesh result = {};
|
||||||
if (!mb)
|
if (!mb)
|
||||||
return result;
|
return result;
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glGenBuffers(1, &(result.vertex_buffer));
|
glGenBuffers(1, &(result.vertex_buffer));
|
||||||
glGenBuffers(1, &(result.index_buffer));
|
glGenBuffers(1, &(result.index_buffer));
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, result.vertex_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, result.vertex_buffer);
|
||||||
const void* vertices = mb->getVertices();
|
const void* vertices = mb->getVertices();
|
||||||
const u32 vertexCount = mb->getVertexCount();
|
const u32 vertexCount = mb->getVertexCount();
|
||||||
const irr::video::E_VERTEX_TYPE vType = mb->getVertexType();
|
const irr::video::E_VERTEX_TYPE vType = mb->getVertexType();
|
||||||
result.Stride = getVertexPitchFromType(vType);
|
result.Stride = getVertexPitchFromType(vType);
|
||||||
const c8* vbuf = static_cast<const c8*>(vertices);
|
const c8* vbuf = static_cast<const c8*>(vertices);
|
||||||
glBufferData(GL_ARRAY_BUFFER, vertexCount * result.Stride, vbuf, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, vertexCount * result.Stride, vbuf, GL_STATIC_DRAW);
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.index_buffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, result.index_buffer);
|
||||||
const void* indices = mb->getIndices();
|
const void* indices = mb->getIndices();
|
||||||
u32 indexCount = mb->getIndexCount();
|
u32 indexCount = mb->getIndexCount();
|
||||||
GLenum indexSize;
|
GLenum indexSize;
|
||||||
switch (mb->getIndexType())
|
switch (mb->getIndexType())
|
||||||
{
|
{
|
||||||
case irr::video::EIT_16BIT:
|
case irr::video::EIT_16BIT:
|
||||||
{
|
{
|
||||||
indexSize = sizeof(u16);
|
indexSize = sizeof(u16);
|
||||||
result.IndexType = GL_UNSIGNED_SHORT;
|
result.IndexType = GL_UNSIGNED_SHORT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case irr::video::EIT_32BIT:
|
case irr::video::EIT_32BIT:
|
||||||
{
|
{
|
||||||
indexSize = sizeof(u32);
|
indexSize = sizeof(u32);
|
||||||
result.IndexType = GL_UNSIGNED_INT;
|
result.IndexType = GL_UNSIGNED_INT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
assert(0 && "Wrong index size");
|
assert(0 && "Wrong index size");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexCount * indexSize, indices, GL_STATIC_DRAW);
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
result.IndexCount = mb->getIndexCount();
|
result.IndexCount = mb->getIndexCount();
|
||||||
switch (mb->getPrimitiveType())
|
switch (mb->getPrimitiveType())
|
||||||
{
|
{
|
||||||
case scene::EPT_POINTS:
|
case scene::EPT_POINTS:
|
||||||
result.PrimitiveType = GL_POINTS;
|
result.PrimitiveType = GL_POINTS;
|
||||||
break;
|
|
||||||
case scene::EPT_TRIANGLE_STRIP:
|
|
||||||
result.PrimitiveType = GL_TRIANGLE_STRIP;
|
|
||||||
break;
|
|
||||||
case scene::EPT_TRIANGLE_FAN:
|
|
||||||
result.PrimitiveType = GL_TRIANGLE_FAN;
|
|
||||||
break;
|
|
||||||
case scene::EPT_LINES:
|
|
||||||
result.PrimitiveType = GL_LINES;
|
|
||||||
break;
|
break;
|
||||||
case scene::EPT_TRIANGLES:
|
case scene::EPT_TRIANGLE_STRIP:
|
||||||
result.PrimitiveType = GL_TRIANGLES;
|
result.PrimitiveType = GL_TRIANGLE_STRIP;
|
||||||
break;
|
break;
|
||||||
case scene::EPT_POINT_SPRITES:
|
case scene::EPT_TRIANGLE_FAN:
|
||||||
case scene::EPT_LINE_LOOP:
|
result.PrimitiveType = GL_TRIANGLE_FAN;
|
||||||
case scene::EPT_POLYGON:
|
break;
|
||||||
case scene::EPT_LINE_STRIP:
|
case scene::EPT_LINES:
|
||||||
case scene::EPT_QUAD_STRIP:
|
result.PrimitiveType = GL_LINES;
|
||||||
case scene::EPT_QUADS:
|
break;
|
||||||
assert(0 && "Unsupported primitive type");
|
case scene::EPT_TRIANGLES:
|
||||||
}
|
result.PrimitiveType = GL_TRIANGLES;
|
||||||
ITexture *tex;
|
break;
|
||||||
for (unsigned i = 0; i < 6; i++)
|
case scene::EPT_POINT_SPRITES:
|
||||||
{
|
case scene::EPT_LINE_LOOP:
|
||||||
tex = mb->getMaterial().getTexture(i);
|
case scene::EPT_POLYGON:
|
||||||
if (tex)
|
case scene::EPT_LINE_STRIP:
|
||||||
result.textures[i] = getTextureGLuint(tex);
|
case scene::EPT_QUAD_STRIP:
|
||||||
else
|
case scene::EPT_QUADS:
|
||||||
result.textures[i] = 0;
|
assert(0 && "Unsupported primitive type");
|
||||||
}
|
}
|
||||||
|
ITexture *tex;
|
||||||
|
for (unsigned i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
tex = mb->getMaterial().getTexture(i);
|
||||||
|
if (tex)
|
||||||
|
result.textures[i] = getTextureGLuint(tex);
|
||||||
|
else
|
||||||
|
result.textures[i] = 0;
|
||||||
|
}
|
||||||
result.TextureMatrix = 0;
|
result.TextureMatrix = 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void computeMVP(core::matrix4 &ModelViewProjectionMatrix)
|
void computeMVP(core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
ModelViewProjectionMatrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION);
|
||||||
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||||
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
ModelViewProjectionMatrix *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeTIMV(core::matrix4 &TransposeInverseModelView)
|
void computeTIMV(core::matrix4 &TransposeInverseModelView)
|
||||||
{
|
{
|
||||||
TransposeInverseModelView = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
TransposeInverseModelView = irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||||
TransposeInverseModelView *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
TransposeInverseModelView *= irr_driver->getVideoDriver()->getTransform(video::ETS_WORLD);
|
||||||
TransposeInverseModelView.makeInverse();
|
TransposeInverseModelView.makeInverse();
|
||||||
TransposeInverseModelView = TransposeInverseModelView.getTransposed();
|
TransposeInverseModelView = TransposeInverseModelView.getTransposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||||
@ -240,34 +240,34 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje
|
|||||||
void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, core::vector3df windDir)
|
void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, core::vector3df windDir)
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
|
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
|
||||||
|
|
||||||
assert(mesh.vao_first_pass);
|
assert(mesh.vao_first_pass);
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
assert(mesh.textures[1]);
|
assert(mesh.textures[1]);
|
||||||
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[1], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
|
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
|
||||||
|
|
||||||
assert(mesh.vao_first_pass);
|
assert(mesh.vao_first_pass);
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||||
@ -437,27 +437,27 @@ void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionM
|
|||||||
void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir)
|
void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir)
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(MeshShader::GrassPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::GrassPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ALPHA};
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
GLint swizzleMask[] = {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA};
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir);
|
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir);
|
||||||
|
|
||||||
assert(mesh.vao_second_pass);
|
assert(mesh.vao_second_pass);
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
@ -477,53 +477,53 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProj
|
|||||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(MeshShader::ObjectRimLimitShader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::ObjectRimLimitShader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
||||||
|
|
||||||
assert(mesh.vao_second_pass);
|
assert(mesh.vao_second_pass);
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(MeshShader::ObjectUnlitShader::TU_tex, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::ObjectUnlitShader::TU_tex, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix);
|
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix);
|
||||||
|
|
||||||
assert(mesh.vao_second_pass);
|
assert(mesh.vao_second_pass);
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
@ -557,43 +557,43 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
|
|||||||
void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(MeshShader::ObjectPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(MeshShader::ObjectPass2Shader::TU_Albedo, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
if (irr_driver->getLightViz())
|
if (irr_driver->getLightViz())
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
|
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
|
||||||
|
|
||||||
assert(mesh.vao_second_pass);
|
assert(mesh.vao_second_pass);
|
||||||
glBindVertexArray(mesh.vao_second_pass);
|
glBindVertexArray(mesh.vao_second_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
irr_driver->IncreaseObjectCount();
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
|
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
|
||||||
|
|
||||||
assert(mesh.vao_first_pass);
|
assert(mesh.vao_first_pass);
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix)
|
||||||
@ -630,20 +630,20 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView
|
|||||||
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix)
|
||||||
{
|
{
|
||||||
irr_driver->IncreaseObjectCount();
|
irr_driver->IncreaseObjectCount();
|
||||||
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f;
|
||||||
float transparency = 1.;
|
float transparency = 1.;
|
||||||
|
|
||||||
GLenum ptype = mesh.PrimitiveType;
|
GLenum ptype = mesh.PrimitiveType;
|
||||||
GLenum itype = mesh.IndexType;
|
GLenum itype = mesh.IndexType;
|
||||||
size_t count = mesh.IndexCount;
|
size_t count = mesh.IndexCount;
|
||||||
|
|
||||||
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||||
|
|
||||||
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
|
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
|
||||||
|
|
||||||
assert(mesh.vao_first_pass);
|
assert(mesh.vao_first_pass);
|
||||||
glBindVertexArray(mesh.vao_first_pass);
|
glBindVertexArray(mesh.vao_first_pass);
|
||||||
glDrawElements(ptype, count, itype, 0);
|
glDrawElements(ptype, count, itype, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawShadowRef(const GLMesh &mesh)
|
void drawShadowRef(const GLMesh &mesh)
|
||||||
@ -692,41 +692,41 @@ void drawShadow(const GLMesh &mesh)
|
|||||||
|
|
||||||
bool isObject(video::E_MATERIAL_TYPE type)
|
bool isObject(video::E_MATERIAL_TYPE type)
|
||||||
{
|
{
|
||||||
if (type == irr_driver->getShader(ES_OBJECTPASS))
|
if (type == irr_driver->getShader(ES_OBJECTPASS))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_NORMAL_MAP))
|
if (type == irr_driver->getShader(ES_NORMAL_MAP))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
if (type == irr_driver->getShader(ES_SPHERE_MAP))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_SPLATTING))
|
if (type == irr_driver->getShader(ES_SPLATTING))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_GRASS))
|
if (type == irr_driver->getShader(ES_GRASS))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_GRASS_REF))
|
if (type == irr_driver->getShader(ES_GRASS_REF))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_BUBBLES))
|
if (type == irr_driver->getShader(ES_BUBBLES))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
||||||
return true;
|
return true;
|
||||||
if (type == irr_driver->getShader(ES_CAUSTICS))
|
if (type == irr_driver->getShader(ES_CAUSTICS))
|
||||||
return true;
|
return true;
|
||||||
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL)
|
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL)
|
||||||
return true;
|
return true;
|
||||||
if (type == video::EMT_ONETEXTURE_BLEND)
|
if (type == video::EMT_ONETEXTURE_BLEND)
|
||||||
return true;
|
return true;
|
||||||
if (type == video::EMT_TRANSPARENT_ADD_COLOR)
|
if (type == video::EMT_TRANSPARENT_ADD_COLOR)
|
||||||
return true;
|
return true;
|
||||||
if (type == video::EMT_SOLID)
|
if (type == video::EMT_SOLID)
|
||||||
return true;
|
return true;
|
||||||
if (type == video::EMT_LIGHTMAP_LIGHTING)
|
if (type == video::EMT_LIGHTMAP_LIGHTING)
|
||||||
return true;
|
return true;
|
||||||
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
|
if (type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat)
|
void initvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat)
|
||||||
|
@ -40,19 +40,19 @@ enum TransparentMaterial
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct GLMesh {
|
struct GLMesh {
|
||||||
GLuint vao_first_pass;
|
GLuint vao_first_pass;
|
||||||
GLuint vao_second_pass;
|
GLuint vao_second_pass;
|
||||||
GLuint vao_glow_pass;
|
GLuint vao_glow_pass;
|
||||||
GLuint vao_displace_pass;
|
GLuint vao_displace_pass;
|
||||||
GLuint vao_displace_mask_pass;
|
GLuint vao_displace_mask_pass;
|
||||||
GLuint vao_shadow_pass;
|
GLuint vao_shadow_pass;
|
||||||
GLuint vertex_buffer;
|
GLuint vertex_buffer;
|
||||||
GLuint index_buffer;
|
GLuint index_buffer;
|
||||||
GLuint textures[6];
|
GLuint textures[6];
|
||||||
GLenum PrimitiveType;
|
GLenum PrimitiveType;
|
||||||
GLenum IndexType;
|
GLenum IndexType;
|
||||||
size_t IndexCount;
|
size_t IndexCount;
|
||||||
size_t Stride;
|
size_t Stride;
|
||||||
core::matrix4 TextureMatrix;
|
core::matrix4 TextureMatrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,14 +24,14 @@ using core::vector3df;
|
|||||||
class Wind
|
class Wind
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Wind();
|
Wind();
|
||||||
|
|
||||||
vector3df getWind() const;
|
vector3df getWind() const;
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector3df m_wind;
|
vector3df m_wind;
|
||||||
float m_seed;
|
float m_seed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -794,14 +794,14 @@ namespace GUIEngine
|
|||||||
{
|
{
|
||||||
return Private::small_font_height;
|
return Private::small_font_height;
|
||||||
} // getSmallFontHeight
|
} // getSmallFontHeight
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
int getLargeFontHeight()
|
int getLargeFontHeight()
|
||||||
{
|
{
|
||||||
|
|
||||||
return Private::large_font_height;
|
return Private::large_font_height;
|
||||||
} // getSmallFontHeight
|
} // getSmallFontHeight
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
@ -170,7 +170,7 @@ namespace GUIEngine
|
|||||||
inline Skin* getSkin() { return Private::g_skin; }
|
inline Skin* getSkin() { return Private::g_skin; }
|
||||||
|
|
||||||
Screen* getScreenNamed(const char* name);
|
Screen* getScreenNamed(const char* name);
|
||||||
|
|
||||||
/** \return the height of the title font in pixels */
|
/** \return the height of the title font in pixels */
|
||||||
int getTitleFontHeight();
|
int getTitleFontHeight();
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ bool EventHandler::OnEvent (const SEvent &event)
|
|||||||
|
|
||||||
if(!Debug::onEvent(event))
|
if(!Debug::onEvent(event))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TO DEBUG HATS (when you don't actually have a hat)
|
// TO DEBUG HATS (when you don't actually have a hat)
|
||||||
/*
|
/*
|
||||||
if (event.EventType == EET_KEY_INPUT_EVENT)
|
if (event.EventType == EET_KEY_INPUT_EVENT)
|
||||||
@ -630,7 +630,7 @@ EventPropagation EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int
|
|||||||
if (w->m_deactivated) return EVENT_BLOCK;
|
if (w->m_deactivated) return EVENT_BLOCK;
|
||||||
|
|
||||||
Widget* parent = w->m_event_handler;
|
Widget* parent = w->m_event_handler;
|
||||||
|
|
||||||
if (ModalDialog::isADialogActive() && (parent == NULL || parent->m_type != GUIEngine::WTYPE_RIBBON))
|
if (ModalDialog::isADialogActive() && (parent == NULL || parent->m_type != GUIEngine::WTYPE_RIBBON))
|
||||||
{
|
{
|
||||||
if (ModalDialog::getCurrent()->processEvent(w->m_properties[PROP_ID]) == EVENT_BLOCK)
|
if (ModalDialog::getCurrent()->processEvent(w->m_properties[PROP_ID]) == EVENT_BLOCK)
|
||||||
|
@ -59,7 +59,7 @@ namespace GUIEngine
|
|||||||
a player cannot trigger an action by clicking on the window during loading screen
|
a player cannot trigger an action by clicking on the window during loading screen
|
||||||
for example */
|
for example */
|
||||||
bool m_accept_events;
|
bool m_accept_events;
|
||||||
|
|
||||||
EventPropagation onGUIEvent(const irr::SEvent& event);
|
EventPropagation onGUIEvent(const irr::SEvent& event);
|
||||||
EventPropagation onWidgetActivated(Widget* w, const int playerID);
|
EventPropagation onWidgetActivated(Widget* w, const int playerID);
|
||||||
void navigateUp(const int playerID, Input::InputType type, const bool pressedDown);
|
void navigateUp(const int playerID, Input::InputType type, const bool pressedDown);
|
||||||
@ -102,7 +102,7 @@ namespace GUIEngine
|
|||||||
/** singleton access */
|
/** singleton access */
|
||||||
static EventHandler* get();
|
static EventHandler* get();
|
||||||
static void deallocate();
|
static void deallocate();
|
||||||
|
|
||||||
void startAcceptingEvents() { m_accept_events = true; }
|
void startAcceptingEvents() { m_accept_events = true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -302,19 +302,19 @@ void LayoutManager::applyCoords(Widget* self, AbstractTopLevelContainer* topLeve
|
|||||||
parent_x = parent->m_x;
|
parent_x = parent->m_x;
|
||||||
parent_y = parent->m_y;
|
parent_y = parent->m_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent != NULL && parent->getType() == WTYPE_DIV && parent->m_show_bounding_box)
|
if (parent != NULL && parent->getType() == WTYPE_DIV && parent->m_show_bounding_box)
|
||||||
{
|
{
|
||||||
int padding = 15;
|
int padding = 15;
|
||||||
if (parent->m_properties[PROP_DIV_PADDING].length() > 0)
|
if (parent->m_properties[PROP_DIV_PADDING].length() > 0)
|
||||||
padding = atoi(parent->m_properties[PROP_DIV_PADDING].c_str());
|
padding = atoi(parent->m_properties[PROP_DIV_PADDING].c_str());
|
||||||
|
|
||||||
parent_x += padding;
|
parent_x += padding;
|
||||||
parent_y += padding;
|
parent_y += padding;
|
||||||
parent_w -= padding*2;
|
parent_w -= padding*2;
|
||||||
parent_h -= padding*2;
|
parent_h -= padding*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->m_absolute_x > -1) self->m_x = parent_x + self->m_absolute_x;
|
if (self->m_absolute_x > -1) self->m_x = parent_x + self->m_absolute_x;
|
||||||
else if (self->m_absolute_reverse_x > -1) self->m_x = parent_x + (parent_w - self->m_absolute_reverse_x);
|
else if (self->m_absolute_reverse_x > -1) self->m_x = parent_x + (parent_w - self->m_absolute_reverse_x);
|
||||||
else if (self->m_relative_x > -1) self->m_x = (int)(parent_x + parent_w*self->m_relative_x/100);
|
else if (self->m_relative_x > -1) self->m_x = (int)(parent_x + parent_w*self->m_relative_x/100);
|
||||||
@ -434,13 +434,13 @@ void LayoutManager::doCalculateLayout(PtrVector<Widget>& widgets, AbstractTopLev
|
|||||||
int padding = 15;
|
int padding = 15;
|
||||||
if (parent->m_properties[PROP_DIV_PADDING].length() > 0)
|
if (parent->m_properties[PROP_DIV_PADDING].length() > 0)
|
||||||
padding = atoi(parent->m_properties[PROP_DIV_PADDING].c_str());
|
padding = atoi(parent->m_properties[PROP_DIV_PADDING].c_str());
|
||||||
|
|
||||||
x += padding;
|
x += padding;
|
||||||
y += padding;
|
y += padding;
|
||||||
w -= padding*2;
|
w -= padding*2;
|
||||||
h -= padding*2;
|
h -= padding*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find space left after placing all absolutely-sized widgets in a row
|
// find space left after placing all absolutely-sized widgets in a row
|
||||||
// (the space left will be divided between remaining widgets later)
|
// (the space left will be divided between remaining widgets later)
|
||||||
int left_space = (horizontal ? w : h);
|
int left_space = (horizontal ? w : h);
|
||||||
|
@ -89,7 +89,7 @@ void ModalDialog::doInit()
|
|||||||
pointer_was_shown = irr_driver->isPointerShown();
|
pointer_was_shown = irr_driver->isPointerShown();
|
||||||
irr_driver->showPointer();
|
irr_driver->showPointer();
|
||||||
|
|
||||||
const core::dimension2d<u32>& frame_size =
|
const core::dimension2d<u32>& frame_size =
|
||||||
GUIEngine::getDriver()->getCurrentRenderTargetSize();
|
GUIEngine::getDriver()->getCurrentRenderTargetSize();
|
||||||
|
|
||||||
const int w = (int)(frame_size.Width* m_percent_width);
|
const int w = (int)(frame_size.Width* m_percent_width);
|
||||||
@ -131,7 +131,7 @@ void ModalDialog::doInit()
|
|||||||
}
|
}
|
||||||
modalWindow = this;
|
modalWindow = this;
|
||||||
|
|
||||||
m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow(m_area,
|
m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow(m_area,
|
||||||
true /* modal */);
|
true /* modal */);
|
||||||
|
|
||||||
GUIEngine::getSkin()->m_dialog = true;
|
GUIEngine::getSkin()->m_dialog = true;
|
||||||
|
@ -818,7 +818,7 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect,
|
|||||||
const int texture_w = texture->getSize().Width / 4;
|
const int texture_w = texture->getSize().Width / 4;
|
||||||
const int texture_h = texture->getSize().Height;
|
const int texture_h = texture->getSize().Height;
|
||||||
const float aspect_ratio = 1.0f;
|
const float aspect_ratio = 1.0f;
|
||||||
|
|
||||||
const int star_number = ratingBar->getStarNumber();
|
const int star_number = ratingBar->getStarNumber();
|
||||||
|
|
||||||
int star_h = rect.getHeight();
|
int star_h = rect.getHeight();
|
||||||
@ -830,7 +830,7 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect,
|
|||||||
star_w = (int)(star_w * scale_factor);
|
star_w = (int)(star_w * scale_factor);
|
||||||
star_h = (int)(star_h * scale_factor);
|
star_h = (int)(star_h * scale_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// center horizontally and vertically
|
// center horizontally and vertically
|
||||||
const int x_from = rect.UpperLeftCorner.X;
|
const int x_from = rect.UpperLeftCorner.X;
|
||||||
const int y_from = rect.UpperLeftCorner.Y;
|
const int y_from = rect.UpperLeftCorner.Y;
|
||||||
@ -853,10 +853,10 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect,
|
|||||||
star_rect.UpperLeftCorner.Y = y_from;
|
star_rect.UpperLeftCorner.Y = y_from;
|
||||||
star_rect.LowerRightCorner.X = x_from + (i + 1) * star_w;
|
star_rect.LowerRightCorner.X = x_from + (i + 1) * star_w;
|
||||||
star_rect.LowerRightCorner.Y = y_from + star_h;
|
star_rect.LowerRightCorner.Y = y_from + star_h;
|
||||||
|
|
||||||
int step = ratingBar->getStepsOfStar(i);
|
int step = ratingBar->getStepsOfStar(i);
|
||||||
|
|
||||||
const core::recti source_area(texture_w * step, 0,
|
const core::recti source_area(texture_w * step, 0,
|
||||||
texture_w * (step + 1), texture_h);
|
texture_w * (step + 1), texture_h);
|
||||||
|
|
||||||
draw2DImage(texture,
|
draw2DImage(texture,
|
||||||
@ -1253,7 +1253,7 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget,
|
|||||||
rect2.LowerRightCorner.Y += 5;
|
rect2.LowerRightCorner.Y += 5;
|
||||||
drawBoxFromStretchableTexture(widget, rect2,
|
drawBoxFromStretchableTexture(widget, rect2,
|
||||||
SkinConfig::m_render_params["squareFocusHalo::neutral"]);
|
SkinConfig::m_render_params["squareFocusHalo::neutral"]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (widget->isFocusedForPlayer(1))
|
else if (widget->isFocusedForPlayer(1))
|
||||||
@ -1314,7 +1314,7 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget,
|
|||||||
|
|
||||||
// ---- If this spinner is of "gauge" type, draw filling
|
// ---- If this spinner is of "gauge" type, draw filling
|
||||||
const SpinnerWidget* w = dynamic_cast<const SpinnerWidget*>(widget);
|
const SpinnerWidget* w = dynamic_cast<const SpinnerWidget*>(widget);
|
||||||
|
|
||||||
if (w->isGauge() && !w->m_deactivated)
|
if (w->isGauge() && !w->m_deactivated)
|
||||||
{
|
{
|
||||||
const int handle_size = (int)( widget->m_h*params->m_left_border
|
const int handle_size = (int)( widget->m_h*params->m_left_border
|
||||||
@ -1651,7 +1651,7 @@ void Skin::renderSections(PtrVector<Widget>* within_vector)
|
|||||||
drawBoxFromStretchableTexture(&widget, rect,
|
drawBoxFromStretchableTexture(&widget, rect,
|
||||||
SkinConfig::m_render_params["section::neutral"]);
|
SkinConfig::m_render_params["section::neutral"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSections( &widget.m_children );
|
renderSections( &widget.m_children );
|
||||||
}
|
}
|
||||||
else if (widget.isBottomBar())
|
else if (widget.isBottomBar())
|
||||||
@ -2097,7 +2097,7 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor,
|
|||||||
core::recti innerArea = borderArea;
|
core::recti innerArea = borderArea;
|
||||||
innerArea.UpperLeftCorner += position2d< s32 >( 3, 3 );
|
innerArea.UpperLeftCorner += position2d< s32 >( 3, 3 );
|
||||||
innerArea.LowerRightCorner -= position2d< s32 >( 3, 3 );
|
innerArea.LowerRightCorner -= position2d< s32 >( 3, 3 );
|
||||||
GL32_draw2DRectangle(focused ? bg_color_focused : bg_color, innerArea);
|
GL32_draw2DRectangle(focused ? bg_color_focused : bg_color, innerArea);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (type == WTYPE_LIST)
|
else if (type == WTYPE_LIST)
|
||||||
@ -2161,7 +2161,7 @@ void Skin::drawBGFadeColor()
|
|||||||
SColor color = SkinConfig::m_colors["dialog_background::neutral"];
|
SColor color = SkinConfig::m_colors["dialog_background::neutral"];
|
||||||
if (m_dialog_size < 1.0f)
|
if (m_dialog_size < 1.0f)
|
||||||
color.setAlpha( (unsigned int)(color.getAlpha()*m_dialog_size ));
|
color.setAlpha( (unsigned int)(color.getAlpha()*m_dialog_size ));
|
||||||
GL32_draw2DRectangle(color,
|
GL32_draw2DRectangle(color,
|
||||||
core::recti(position2d< s32 >(0,0),
|
core::recti(position2d< s32 >(0,0),
|
||||||
GUIEngine::getDriver()->getCurrentRenderTargetSize()) );
|
GUIEngine::getDriver()->getCurrentRenderTargetSize()) );
|
||||||
} // drawBGFadeColor
|
} // drawBGFadeColor
|
||||||
@ -2211,7 +2211,7 @@ void Skin::draw3DMenuPane (IGUIElement *element, const core::recti &rect,
|
|||||||
const core::recti *clip)
|
const core::recti *clip)
|
||||||
{
|
{
|
||||||
SColor color = SColor(150, 96, 74, 196);
|
SColor color = SColor(150, 96, 74, 196);
|
||||||
GL32_draw2DRectangle(color, rect);
|
GL32_draw2DRectangle(color, rect);
|
||||||
} // draw3DMenuPane
|
} // draw3DMenuPane
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -16,155 +16,155 @@
|
|||||||
using namespace irr;
|
using namespace irr;
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
class CGUIEditBox : public IGUIEditBox
|
class CGUIEditBox : public IGUIEditBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment,
|
CGUIEditBox(const wchar_t* text, bool border, IGUIEnvironment* environment,
|
||||||
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle, bool is_rtl);
|
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle, bool is_rtl);
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
virtual ~CGUIEditBox();
|
virtual ~CGUIEditBox();
|
||||||
|
|
||||||
//! Sets another skin independent font.
|
//! Sets another skin independent font.
|
||||||
virtual void setOverrideFont(IGUIFont* font=0);
|
virtual void setOverrideFont(IGUIFont* font=0);
|
||||||
|
|
||||||
//! Sets another color for the text.
|
//! Sets another color for the text.
|
||||||
virtual void setOverrideColor(video::SColor color);
|
virtual void setOverrideColor(video::SColor color);
|
||||||
|
|
||||||
//! Gets the override color
|
//! Gets the override color
|
||||||
virtual video::SColor getOverrideColor() const;
|
virtual video::SColor getOverrideColor() const;
|
||||||
|
|
||||||
//! Sets if the text should use the overide color or the
|
//! Sets if the text should use the overide color or the
|
||||||
//! color in the gui skin.
|
//! color in the gui skin.
|
||||||
virtual void enableOverrideColor(bool enable);
|
virtual void enableOverrideColor(bool enable);
|
||||||
|
|
||||||
//! Checks if an override color is enabled
|
//! Checks if an override color is enabled
|
||||||
/** \return true if the override color is enabled, false otherwise */
|
/** \return true if the override color is enabled, false otherwise */
|
||||||
virtual bool isOverrideColorEnabled(void) const;
|
virtual bool isOverrideColorEnabled(void) const;
|
||||||
|
|
||||||
//! Turns the border on or off
|
//! Turns the border on or off
|
||||||
virtual void setDrawBorder(bool border);
|
virtual void setDrawBorder(bool border);
|
||||||
|
|
||||||
//! Enables or disables word wrap for using the edit box as multiline text editor.
|
//! Enables or disables word wrap for using the edit box as multiline text editor.
|
||||||
virtual void setWordWrap(bool enable);
|
virtual void setWordWrap(bool enable);
|
||||||
|
|
||||||
//! Checks if word wrap is enabled
|
//! Checks if word wrap is enabled
|
||||||
//! \return true if word wrap is enabled, false otherwise
|
//! \return true if word wrap is enabled, false otherwise
|
||||||
virtual bool isWordWrapEnabled() const;
|
virtual bool isWordWrapEnabled() const;
|
||||||
|
|
||||||
//! Enables or disables newlines.
|
//! Enables or disables newlines.
|
||||||
/** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired,
|
/** \param enable: If set to true, the EGET_EDITBOX_ENTER event will not be fired,
|
||||||
instead a newline character will be inserted. */
|
instead a newline character will be inserted. */
|
||||||
virtual void setMultiLine(bool enable);
|
virtual void setMultiLine(bool enable);
|
||||||
|
|
||||||
//! Checks if multi line editing is enabled
|
//! Checks if multi line editing is enabled
|
||||||
//! \return true if mult-line is enabled, false otherwise
|
//! \return true if mult-line is enabled, false otherwise
|
||||||
virtual bool isMultiLineEnabled() const;
|
virtual bool isMultiLineEnabled() const;
|
||||||
|
|
||||||
//! Enables or disables automatic scrolling with cursor position
|
//! Enables or disables automatic scrolling with cursor position
|
||||||
//! \param enable: If set to true, the text will move around with the cursor position
|
//! \param enable: If set to true, the text will move around with the cursor position
|
||||||
virtual void setAutoScroll(bool enable);
|
virtual void setAutoScroll(bool enable);
|
||||||
|
|
||||||
//! Checks to see if automatic scrolling is enabled
|
//! Checks to see if automatic scrolling is enabled
|
||||||
//! \return true if automatic scrolling is enabled, false if not
|
//! \return true if automatic scrolling is enabled, false if not
|
||||||
virtual bool isAutoScrollEnabled() const;
|
virtual bool isAutoScrollEnabled() const;
|
||||||
|
|
||||||
//! Gets the size area of the text in the edit box
|
//! Gets the size area of the text in the edit box
|
||||||
//! \return Returns the size in pixels of the text
|
//! \return Returns the size in pixels of the text
|
||||||
virtual core::dimension2du getTextDimension();
|
virtual core::dimension2du getTextDimension();
|
||||||
|
|
||||||
//! Sets text justification
|
//! Sets text justification
|
||||||
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
|
virtual void setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical);
|
||||||
|
|
||||||
//! called if an event happened.
|
//! called if an event happened.
|
||||||
virtual bool OnEvent(const SEvent& event);
|
virtual bool OnEvent(const SEvent& event);
|
||||||
|
|
||||||
//! draws the element and its children
|
//! draws the element and its children
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
|
|
||||||
//! Sets the new caption of this element.
|
//! Sets the new caption of this element.
|
||||||
virtual void setText(const wchar_t* text);
|
virtual void setText(const wchar_t* text);
|
||||||
|
|
||||||
//! Sets the maximum amount of characters which may be entered in the box.
|
//! Sets the maximum amount of characters which may be entered in the box.
|
||||||
//! \param max: Maximum amount of characters. If 0, the character amount is
|
//! \param max: Maximum amount of characters. If 0, the character amount is
|
||||||
//! infinity.
|
//! infinity.
|
||||||
virtual void setMax(u32 max);
|
virtual void setMax(u32 max);
|
||||||
|
|
||||||
//! Returns maximum amount of characters, previously set by setMax();
|
//! Returns maximum amount of characters, previously set by setMax();
|
||||||
virtual u32 getMax() const;
|
virtual u32 getMax() const;
|
||||||
|
|
||||||
//! Sets whether the edit box is a password box. Setting this to true will
|
//! Sets whether the edit box is a password box. Setting this to true will
|
||||||
/** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x
|
/** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x
|
||||||
\param passwordBox: true to enable password, false to disable
|
\param passwordBox: true to enable password, false to disable
|
||||||
\param passwordChar: the character that is displayed instead of letters */
|
\param passwordChar: the character that is displayed instead of letters */
|
||||||
virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*');
|
virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*');
|
||||||
|
|
||||||
//! Returns true if the edit box is currently a password box.
|
//! Returns true if the edit box is currently a password box.
|
||||||
virtual bool isPasswordBox() const;
|
virtual bool isPasswordBox() const;
|
||||||
|
|
||||||
//! Updates the absolute position, splits text if required
|
//! Updates the absolute position, splits text if required
|
||||||
virtual void updateAbsolutePosition();
|
virtual void updateAbsolutePosition();
|
||||||
|
|
||||||
//! Writes attributes of the element.
|
//! Writes attributes of the element.
|
||||||
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
||||||
|
|
||||||
//! Reads attributes of the element
|
//! Reads attributes of the element
|
||||||
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
||||||
|
|
||||||
virtual irr::gui::IGUIFont* getOverrideFont() const { return NULL; }
|
virtual irr::gui::IGUIFont* getOverrideFont() const { return NULL; }
|
||||||
virtual irr::gui::IGUIFont* getActiveFont() const { return NULL; }
|
virtual irr::gui::IGUIFont* getActiveFont() const { return NULL; }
|
||||||
virtual void setDrawBackground(bool) { }
|
virtual void setDrawBackground(bool) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Breaks the single text line.
|
//! Breaks the single text line.
|
||||||
void breakText();
|
void breakText();
|
||||||
//! sets the area of the given line
|
//! sets the area of the given line
|
||||||
void setTextRect(s32 line);
|
void setTextRect(s32 line);
|
||||||
//! returns the line number that the cursor is on
|
//! returns the line number that the cursor is on
|
||||||
s32 getLineFromPos(s32 pos);
|
s32 getLineFromPos(s32 pos);
|
||||||
//! adds a letter to the edit box
|
//! adds a letter to the edit box
|
||||||
void inputChar(wchar_t c);
|
void inputChar(wchar_t c);
|
||||||
//! calculates the current scroll position
|
//! calculates the current scroll position
|
||||||
void calculateScrollPos();
|
void calculateScrollPos();
|
||||||
//! send some gui event to parent
|
//! send some gui event to parent
|
||||||
void sendGuiEvent(EGUI_EVENT_TYPE type);
|
void sendGuiEvent(EGUI_EVENT_TYPE type);
|
||||||
//! set text markers
|
//! set text markers
|
||||||
void setTextMarkers(s32 begin, s32 end);
|
void setTextMarkers(s32 begin, s32 end);
|
||||||
|
|
||||||
bool processKey(const SEvent& event);
|
bool processKey(const SEvent& event);
|
||||||
bool processMouse(const SEvent& event);
|
bool processMouse(const SEvent& event);
|
||||||
s32 getCursorPos(s32 x, s32 y);
|
s32 getCursorPos(s32 x, s32 y);
|
||||||
|
|
||||||
bool MouseMarking;
|
bool MouseMarking;
|
||||||
bool Border;
|
bool Border;
|
||||||
bool OverrideColorEnabled;
|
bool OverrideColorEnabled;
|
||||||
s32 MarkBegin;
|
s32 MarkBegin;
|
||||||
s32 MarkEnd;
|
s32 MarkEnd;
|
||||||
|
|
||||||
video::SColor OverrideColor;
|
video::SColor OverrideColor;
|
||||||
gui::IGUIFont *OverrideFont, *LastBreakFont;
|
gui::IGUIFont *OverrideFont, *LastBreakFont;
|
||||||
IOSOperator* Operator;
|
IOSOperator* Operator;
|
||||||
|
|
||||||
StkTime::TimeType BlinkStartTime;
|
StkTime::TimeType BlinkStartTime;
|
||||||
s32 CursorPos;
|
s32 CursorPos;
|
||||||
s32 HScrollPos, VScrollPos; // scroll position in characters
|
s32 HScrollPos, VScrollPos; // scroll position in characters
|
||||||
u32 Max;
|
u32 Max;
|
||||||
|
|
||||||
bool m_rtl;
|
bool m_rtl;
|
||||||
|
|
||||||
bool WordWrap, MultiLine, AutoScroll, PasswordBox;
|
bool WordWrap, MultiLine, AutoScroll, PasswordBox;
|
||||||
wchar_t PasswordChar;
|
wchar_t PasswordChar;
|
||||||
EGUI_ALIGNMENT HAlign, VAlign;
|
EGUI_ALIGNMENT HAlign, VAlign;
|
||||||
|
|
||||||
core::array< core::stringw > BrokenText;
|
core::array< core::stringw > BrokenText;
|
||||||
core::array< s32 > BrokenTextPositions;
|
core::array< s32 > BrokenTextPositions;
|
||||||
|
|
||||||
core::rect<s32> CurrentTextRect, FrameRect; // temporary values
|
core::rect<s32> CurrentTextRect, FrameRect; // temporary values
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,59 +21,59 @@ namespace gui
|
|||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
CGUISTKListBox::CGUISTKListBox(IGUIEnvironment* environment, IGUIElement* parent,
|
CGUISTKListBox::CGUISTKListBox(IGUIEnvironment* environment, IGUIElement* parent,
|
||||||
s32 id, core::rect<s32> rectangle, bool clip,
|
s32 id, core::rect<s32> rectangle, bool clip,
|
||||||
bool drawBack, bool moveOverSelect)
|
bool drawBack, bool moveOverSelect)
|
||||||
: IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle), Selected(-1),
|
: IGUIElement(EGUIET_LIST_BOX, environment, parent, id, rectangle), Selected(-1),
|
||||||
ItemHeight(0),ItemHeightOverride(0),
|
ItemHeight(0),ItemHeightOverride(0),
|
||||||
TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0),
|
TotalItemHeight(0), ItemsIconWidth(0), Font(0), IconBank(0),
|
||||||
ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack),
|
ScrollBar(0), selectTime(0), LastKeyTime(0), Selecting(false), DrawBack(drawBack),
|
||||||
MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true)
|
MoveOverSelect(moveOverSelect), AutoScroll(true), HighlightWhenNotFocused(true)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
setDebugName("CGUISTKListBox");
|
setDebugName("CGUISTKListBox");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IGUISkin* skin = Environment->getSkin();
|
IGUISkin* skin = Environment->getSkin();
|
||||||
const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE);
|
const s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE);
|
||||||
|
|
||||||
ScrollBar = Environment->addScrollBar(false,
|
ScrollBar = Environment->addScrollBar(false,
|
||||||
core::rect<s32>(RelativeRect.getWidth() - s, 0,
|
core::rect<s32>(RelativeRect.getWidth() - s, 0,
|
||||||
RelativeRect.getWidth(), RelativeRect.getHeight()), this, -1);
|
RelativeRect.getWidth(), RelativeRect.getHeight()), this, -1);
|
||||||
ScrollBar->grab();
|
ScrollBar->grab();
|
||||||
ScrollBar->setSubElement(true);
|
ScrollBar->setSubElement(true);
|
||||||
ScrollBar->setTabStop(false);
|
ScrollBar->setTabStop(false);
|
||||||
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
|
ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
|
||||||
ScrollBar->setVisible(false);
|
ScrollBar->setVisible(false);
|
||||||
ScrollBar->setPos(0);
|
ScrollBar->setPos(0);
|
||||||
|
|
||||||
setNotClipped(!clip);
|
setNotClipped(!clip);
|
||||||
|
|
||||||
// this element can be tabbed to
|
// this element can be tabbed to
|
||||||
setTabStop(true);
|
setTabStop(true);
|
||||||
setTabOrder(-1);
|
setTabOrder(-1);
|
||||||
|
|
||||||
updateAbsolutePosition();
|
updateAbsolutePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
CGUISTKListBox::~CGUISTKListBox()
|
CGUISTKListBox::~CGUISTKListBox()
|
||||||
{
|
{
|
||||||
if (ScrollBar)
|
if (ScrollBar)
|
||||||
ScrollBar->drop();
|
ScrollBar->drop();
|
||||||
|
|
||||||
if (Font)
|
if (Font)
|
||||||
Font->drop();
|
Font->drop();
|
||||||
|
|
||||||
if (IconBank)
|
if (IconBank)
|
||||||
IconBank->drop();
|
IconBank->drop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! returns amount of list items
|
//! returns amount of list items
|
||||||
u32 CGUISTKListBox::getItemCount() const
|
u32 CGUISTKListBox::getItemCount() const
|
||||||
{
|
{
|
||||||
return Items.size();
|
return Items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ const wchar_t* CGUISTKListBox::getCellText(u32 row_num, u32 col_num) const
|
|||||||
return 0;
|
return 0;
|
||||||
if ( col_num >= Items[row_num].m_contents.size() )
|
if ( col_num >= Items[row_num].m_contents.size() )
|
||||||
return 0;
|
return 0;
|
||||||
return Items[row_num].m_contents[col_num].m_text.c_str();
|
return Items[row_num].m_contents[col_num].m_text.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
CGUISTKListBox::ListItem CGUISTKListBox::getItem(u32 id) const
|
CGUISTKListBox::ListItem CGUISTKListBox::getItem(u32 id) const
|
||||||
@ -105,109 +105,109 @@ s32 CGUISTKListBox::getIcon(u32 row_num, u32 col_num) const
|
|||||||
|
|
||||||
void CGUISTKListBox::removeItem(u32 id)
|
void CGUISTKListBox::removeItem(u32 id)
|
||||||
{
|
{
|
||||||
if (id >= Items.size())
|
if (id >= Items.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((u32)Selected==id)
|
if ((u32)Selected==id)
|
||||||
{
|
{
|
||||||
Selected = -1;
|
Selected = -1;
|
||||||
}
|
}
|
||||||
else if ((u32)Selected > id)
|
else if ((u32)Selected > id)
|
||||||
{
|
{
|
||||||
Selected -= 1;
|
Selected -= 1;
|
||||||
selectTime = (u32)StkTime::getTimeSinceEpoch();
|
selectTime = (u32)StkTime::getTimeSinceEpoch();
|
||||||
}
|
}
|
||||||
|
|
||||||
Items.erase(id);
|
Items.erase(id);
|
||||||
|
|
||||||
recalculateItemHeight();
|
recalculateItemHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
s32 CGUISTKListBox::getItemAt(s32 xpos, s32 ypos) const
|
s32 CGUISTKListBox::getItemAt(s32 xpos, s32 ypos) const
|
||||||
{
|
{
|
||||||
if ( xpos < AbsoluteRect.UpperLeftCorner.X || xpos >= AbsoluteRect.LowerRightCorner.X
|
if ( xpos < AbsoluteRect.UpperLeftCorner.X || xpos >= AbsoluteRect.LowerRightCorner.X
|
||||||
|| ypos < AbsoluteRect.UpperLeftCorner.Y || ypos >= AbsoluteRect.LowerRightCorner.Y
|
|| ypos < AbsoluteRect.UpperLeftCorner.Y || ypos >= AbsoluteRect.LowerRightCorner.Y
|
||||||
)
|
)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ( ItemHeight == 0 )
|
if ( ItemHeight == 0 )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
s32 item = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight;
|
s32 item = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight;
|
||||||
if ( item < 0 || item >= (s32)Items.size())
|
if ( item < 0 || item >= (s32)Items.size())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! clears the list
|
//! clears the list
|
||||||
void CGUISTKListBox::clear()
|
void CGUISTKListBox::clear()
|
||||||
{
|
{
|
||||||
Items.clear();
|
Items.clear();
|
||||||
ItemsIconWidth = 0;
|
ItemsIconWidth = 0;
|
||||||
Selected = -1;
|
Selected = -1;
|
||||||
|
|
||||||
if (ScrollBar)
|
if (ScrollBar)
|
||||||
ScrollBar->setPos(0);
|
ScrollBar->setPos(0);
|
||||||
|
|
||||||
recalculateItemHeight();
|
recalculateItemHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::recalculateItemHeight()
|
void CGUISTKListBox::recalculateItemHeight()
|
||||||
{
|
{
|
||||||
IGUISkin* skin = Environment->getSkin();
|
IGUISkin* skin = Environment->getSkin();
|
||||||
|
|
||||||
if (Font != skin->getFont())
|
if (Font != skin->getFont())
|
||||||
{
|
{
|
||||||
if (Font)
|
if (Font)
|
||||||
Font->drop();
|
Font->drop();
|
||||||
|
|
||||||
Font = skin->getFont();
|
Font = skin->getFont();
|
||||||
if ( 0 == ItemHeightOverride )
|
if ( 0 == ItemHeightOverride )
|
||||||
ItemHeight = 0;
|
ItemHeight = 0;
|
||||||
|
|
||||||
if (Font)
|
if (Font)
|
||||||
{
|
{
|
||||||
if ( 0 == ItemHeightOverride )
|
if ( 0 == ItemHeightOverride )
|
||||||
ItemHeight = Font->getDimension(L"A").Height + 4;
|
ItemHeight = Font->getDimension(L"A").Height + 4;
|
||||||
|
|
||||||
Font->grab();
|
Font->grab();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TotalItemHeight = ItemHeight * Items.size();
|
TotalItemHeight = ItemHeight * Items.size();
|
||||||
ScrollBar->setMax( core::max_(0, TotalItemHeight - AbsoluteRect.getHeight()) );
|
ScrollBar->setMax( core::max_(0, TotalItemHeight - AbsoluteRect.getHeight()) );
|
||||||
s32 minItemHeight = ItemHeight > 0 ? ItemHeight : 1;
|
s32 minItemHeight = ItemHeight > 0 ? ItemHeight : 1;
|
||||||
ScrollBar->setSmallStep ( minItemHeight );
|
ScrollBar->setSmallStep ( minItemHeight );
|
||||||
ScrollBar->setLargeStep ( 2*minItemHeight );
|
ScrollBar->setLargeStep ( 2*minItemHeight );
|
||||||
|
|
||||||
if ( TotalItemHeight <= AbsoluteRect.getHeight() )
|
if ( TotalItemHeight <= AbsoluteRect.getHeight() )
|
||||||
ScrollBar->setVisible(false);
|
ScrollBar->setVisible(false);
|
||||||
else
|
else
|
||||||
ScrollBar->setVisible(true);
|
ScrollBar->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! returns id of selected item. returns -1 if no item is selected.
|
//! returns id of selected item. returns -1 if no item is selected.
|
||||||
s32 CGUISTKListBox::getSelected() const
|
s32 CGUISTKListBox::getSelected() const
|
||||||
{
|
{
|
||||||
return Selected;
|
return Selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! sets the selected item. Set this to -1 if no item should be selected
|
//! sets the selected item. Set this to -1 if no item should be selected
|
||||||
void CGUISTKListBox::setSelected(s32 id)
|
void CGUISTKListBox::setSelected(s32 id)
|
||||||
{
|
{
|
||||||
if ((u32)id>=Items.size())
|
if ((u32)id>=Items.size())
|
||||||
Selected = -1;
|
Selected = -1;
|
||||||
else
|
else
|
||||||
Selected = id;
|
Selected = id;
|
||||||
|
|
||||||
selectTime = (u32)StkTime::getTimeSinceEpoch();
|
selectTime = (u32)StkTime::getTimeSinceEpoch();
|
||||||
|
|
||||||
recalculateScrollPos();
|
recalculateScrollPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 CGUISTKListBox::getRowByCellText(const wchar_t * text)
|
s32 CGUISTKListBox::getRowByCellText(const wchar_t * text)
|
||||||
@ -249,184 +249,184 @@ s32 CGUISTKListBox::getRowByInternalName(const std::string & text) const
|
|||||||
//! called if an event happened.
|
//! called if an event happened.
|
||||||
bool CGUISTKListBox::OnEvent(const SEvent& event)
|
bool CGUISTKListBox::OnEvent(const SEvent& event)
|
||||||
{
|
{
|
||||||
if (isEnabled())
|
if (isEnabled())
|
||||||
{
|
{
|
||||||
switch(event.EventType)
|
switch(event.EventType)
|
||||||
{
|
{
|
||||||
case EET_KEY_INPUT_EVENT:
|
case EET_KEY_INPUT_EVENT:
|
||||||
if (event.KeyInput.PressedDown &&
|
if (event.KeyInput.PressedDown &&
|
||||||
(event.KeyInput.Key == KEY_DOWN ||
|
(event.KeyInput.Key == KEY_DOWN ||
|
||||||
event.KeyInput.Key == KEY_UP ||
|
event.KeyInput.Key == KEY_UP ||
|
||||||
event.KeyInput.Key == KEY_HOME ||
|
event.KeyInput.Key == KEY_HOME ||
|
||||||
event.KeyInput.Key == KEY_END ||
|
event.KeyInput.Key == KEY_END ||
|
||||||
event.KeyInput.Key == KEY_NEXT ||
|
event.KeyInput.Key == KEY_NEXT ||
|
||||||
event.KeyInput.Key == KEY_PRIOR ) )
|
event.KeyInput.Key == KEY_PRIOR ) )
|
||||||
{
|
{
|
||||||
s32 oldSelected = Selected;
|
s32 oldSelected = Selected;
|
||||||
switch (event.KeyInput.Key)
|
switch (event.KeyInput.Key)
|
||||||
{
|
{
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
Selected += 1;
|
Selected += 1;
|
||||||
break;
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
Selected -= 1;
|
Selected -= 1;
|
||||||
break;
|
break;
|
||||||
case KEY_HOME:
|
case KEY_HOME:
|
||||||
Selected = 0;
|
Selected = 0;
|
||||||
break;
|
break;
|
||||||
case KEY_END:
|
case KEY_END:
|
||||||
Selected = (s32)Items.size()-1;
|
Selected = (s32)Items.size()-1;
|
||||||
break;
|
break;
|
||||||
case KEY_NEXT:
|
case KEY_NEXT:
|
||||||
Selected += AbsoluteRect.getHeight() / ItemHeight;
|
Selected += AbsoluteRect.getHeight() / ItemHeight;
|
||||||
break;
|
break;
|
||||||
case KEY_PRIOR:
|
case KEY_PRIOR:
|
||||||
Selected -= AbsoluteRect.getHeight() / ItemHeight;
|
Selected -= AbsoluteRect.getHeight() / ItemHeight;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Selected >= (s32)Items.size())
|
if (Selected >= (s32)Items.size())
|
||||||
Selected = Items.size() - 1;
|
Selected = Items.size() - 1;
|
||||||
else
|
else
|
||||||
if (Selected<0)
|
if (Selected<0)
|
||||||
Selected = 0;
|
Selected = 0;
|
||||||
|
|
||||||
recalculateScrollPos();
|
recalculateScrollPos();
|
||||||
|
|
||||||
// post the news
|
// post the news
|
||||||
|
|
||||||
if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect)
|
if (oldSelected != Selected && Parent && !Selecting && !MoveOverSelect)
|
||||||
{
|
{
|
||||||
SEvent e;
|
SEvent e;
|
||||||
e.EventType = EET_GUI_EVENT;
|
e.EventType = EET_GUI_EVENT;
|
||||||
e.GUIEvent.Caller = this;
|
e.GUIEvent.Caller = this;
|
||||||
e.GUIEvent.Element = 0;
|
e.GUIEvent.Element = 0;
|
||||||
e.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
|
e.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
|
||||||
Parent->OnEvent(e);
|
Parent->OnEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE ) )
|
if (!event.KeyInput.PressedDown && ( event.KeyInput.Key == KEY_RETURN || event.KeyInput.Key == KEY_SPACE ) )
|
||||||
{
|
{
|
||||||
if (Parent)
|
if (Parent)
|
||||||
{
|
{
|
||||||
SEvent e;
|
SEvent e;
|
||||||
e.EventType = EET_GUI_EVENT;
|
e.EventType = EET_GUI_EVENT;
|
||||||
e.GUIEvent.Caller = this;
|
e.GUIEvent.Caller = this;
|
||||||
e.GUIEvent.Element = 0;
|
e.GUIEvent.Element = 0;
|
||||||
e.GUIEvent.EventType = EGET_LISTBOX_SELECTED_AGAIN;
|
e.GUIEvent.EventType = EGET_LISTBOX_SELECTED_AGAIN;
|
||||||
Parent->OnEvent(e);
|
Parent->OnEvent(e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EET_GUI_EVENT:
|
case EET_GUI_EVENT:
|
||||||
switch(event.GUIEvent.EventType)
|
switch(event.GUIEvent.EventType)
|
||||||
{
|
{
|
||||||
case gui::EGET_SCROLL_BAR_CHANGED:
|
case gui::EGET_SCROLL_BAR_CHANGED:
|
||||||
if (event.GUIEvent.Caller == ScrollBar)
|
if (event.GUIEvent.Caller == ScrollBar)
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case gui::EGET_ELEMENT_FOCUS_LOST:
|
case gui::EGET_ELEMENT_FOCUS_LOST:
|
||||||
{
|
{
|
||||||
if (event.GUIEvent.Caller == this)
|
if (event.GUIEvent.Caller == this)
|
||||||
Selecting = false;
|
Selecting = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EET_MOUSE_INPUT_EVENT:
|
case EET_MOUSE_INPUT_EVENT:
|
||||||
{
|
{
|
||||||
core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
|
core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
|
||||||
|
|
||||||
switch(event.MouseInput.Event)
|
switch(event.MouseInput.Event)
|
||||||
{
|
{
|
||||||
case EMIE_MOUSE_WHEEL:
|
case EMIE_MOUSE_WHEEL:
|
||||||
ScrollBar->setPos(ScrollBar->getPos() + (event.MouseInput.Wheel < 0 ? -1 : 1)*-ItemHeight/2);
|
ScrollBar->setPos(ScrollBar->getPos() + (event.MouseInput.Wheel < 0 ? -1 : 1)*-ItemHeight/2);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||||
{
|
{
|
||||||
Selecting = true;
|
Selecting = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EMIE_LMOUSE_LEFT_UP:
|
case EMIE_LMOUSE_LEFT_UP:
|
||||||
{
|
{
|
||||||
Selecting = false;
|
Selecting = false;
|
||||||
|
|
||||||
if (isPointInside(p))
|
if (isPointInside(p))
|
||||||
selectNew(event.MouseInput.Y);
|
selectNew(event.MouseInput.Y);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EMIE_MOUSE_MOVED:
|
case EMIE_MOUSE_MOVED:
|
||||||
if (Selecting || MoveOverSelect)
|
if (Selecting || MoveOverSelect)
|
||||||
{
|
{
|
||||||
if (isPointInside(p))
|
if (isPointInside(p))
|
||||||
{
|
{
|
||||||
selectNew(event.MouseInput.Y, true);
|
selectNew(event.MouseInput.Y, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EET_LOG_TEXT_EVENT:
|
case EET_LOG_TEXT_EVENT:
|
||||||
case EET_USER_EVENT:
|
case EET_USER_EVENT:
|
||||||
case EET_JOYSTICK_INPUT_EVENT:
|
case EET_JOYSTICK_INPUT_EVENT:
|
||||||
case EGUIET_FORCE_32_BIT:
|
case EGUIET_FORCE_32_BIT:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return IGUIElement::OnEvent(event);
|
return IGUIElement::OnEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::selectNew(s32 ypos, bool onlyHover)
|
void CGUISTKListBox::selectNew(s32 ypos, bool onlyHover)
|
||||||
{
|
{
|
||||||
u32 now = (u32)StkTime::getTimeSinceEpoch();
|
u32 now = (u32)StkTime::getTimeSinceEpoch();
|
||||||
s32 oldSelected = Selected;
|
s32 oldSelected = Selected;
|
||||||
|
|
||||||
Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos);
|
Selected = getItemAt(AbsoluteRect.UpperLeftCorner.X, ypos);
|
||||||
if (Selected<0 && !Items.empty())
|
if (Selected<0 && !Items.empty())
|
||||||
Selected = 0;
|
Selected = 0;
|
||||||
|
|
||||||
recalculateScrollPos();
|
recalculateScrollPos();
|
||||||
|
|
||||||
gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED;
|
gui::EGUI_EVENT_TYPE eventType = (Selected == oldSelected && now < selectTime + 500) ? EGET_LISTBOX_SELECTED_AGAIN : EGET_LISTBOX_CHANGED;
|
||||||
selectTime = now;
|
selectTime = now;
|
||||||
// post the news
|
// post the news
|
||||||
if (Parent && !onlyHover)
|
if (Parent && !onlyHover)
|
||||||
{
|
{
|
||||||
SEvent event;
|
SEvent event;
|
||||||
event.EventType = EET_GUI_EVENT;
|
event.EventType = EET_GUI_EVENT;
|
||||||
event.GUIEvent.Caller = this;
|
event.GUIEvent.Caller = this;
|
||||||
event.GUIEvent.Element = 0;
|
event.GUIEvent.Element = 0;
|
||||||
event.GUIEvent.EventType = eventType;
|
event.GUIEvent.EventType = eventType;
|
||||||
Parent->OnEvent(event);
|
Parent->OnEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Update the position and size of the listbox, and update the scrollbar
|
//! Update the position and size of the listbox, and update the scrollbar
|
||||||
void CGUISTKListBox::updateAbsolutePosition()
|
void CGUISTKListBox::updateAbsolutePosition()
|
||||||
{
|
{
|
||||||
IGUIElement::updateAbsolutePosition();
|
IGUIElement::updateAbsolutePosition();
|
||||||
|
|
||||||
recalculateItemHeight();
|
recalculateItemHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -563,10 +563,10 @@ void CGUISTKListBox::draw()
|
|||||||
//! adds an list item with an icon
|
//! adds an list item with an icon
|
||||||
u32 CGUISTKListBox::addItem(const ListItem & item)
|
u32 CGUISTKListBox::addItem(const ListItem & item)
|
||||||
{
|
{
|
||||||
Items.push_back(item);
|
Items.push_back(item);
|
||||||
recalculateItemHeight();
|
recalculateItemHeight();
|
||||||
recalculateIconWidth();
|
recalculateIconWidth();
|
||||||
return Items.size() - 1;
|
return Items.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -574,44 +574,44 @@ void CGUISTKListBox::setSpriteBank(IGUISpriteBank* bank)
|
|||||||
{
|
{
|
||||||
if ( bank == IconBank )
|
if ( bank == IconBank )
|
||||||
return;
|
return;
|
||||||
if (IconBank)
|
if (IconBank)
|
||||||
IconBank->drop();
|
IconBank->drop();
|
||||||
|
|
||||||
IconBank = bank;
|
IconBank = bank;
|
||||||
if (IconBank)
|
if (IconBank)
|
||||||
IconBank->grab();
|
IconBank->grab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::recalculateScrollPos()
|
void CGUISTKListBox::recalculateScrollPos()
|
||||||
{
|
{
|
||||||
if (!AutoScroll)
|
if (!AutoScroll)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const s32 selPos = (Selected == -1 ? TotalItemHeight : Selected * ItemHeight) - ScrollBar->getPos();
|
const s32 selPos = (Selected == -1 ? TotalItemHeight : Selected * ItemHeight) - ScrollBar->getPos();
|
||||||
|
|
||||||
if (selPos < 0)
|
if (selPos < 0)
|
||||||
{
|
{
|
||||||
ScrollBar->setPos(ScrollBar->getPos() + selPos);
|
ScrollBar->setPos(ScrollBar->getPos() + selPos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (selPos > AbsoluteRect.getHeight() - ItemHeight)
|
if (selPos > AbsoluteRect.getHeight() - ItemHeight)
|
||||||
{
|
{
|
||||||
ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight);
|
ScrollBar->setPos(ScrollBar->getPos() + selPos - AbsoluteRect.getHeight() + ItemHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::setAutoScrollEnabled(bool scroll)
|
void CGUISTKListBox::setAutoScrollEnabled(bool scroll)
|
||||||
{
|
{
|
||||||
AutoScroll = scroll;
|
AutoScroll = scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CGUISTKListBox::isAutoScrollEnabled() const
|
bool CGUISTKListBox::isAutoScrollEnabled() const
|
||||||
{
|
{
|
||||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
||||||
return AutoScroll;
|
return AutoScroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGUISTKListBox::recalculateIconWidth()
|
void CGUISTKListBox::recalculateIconWidth()
|
||||||
@ -619,128 +619,128 @@ void CGUISTKListBox::recalculateIconWidth()
|
|||||||
for(int x = 0; x < (int)Items.getLast().m_contents.size(); ++x)
|
for(int x = 0; x < (int)Items.getLast().m_contents.size(); ++x)
|
||||||
{
|
{
|
||||||
s32 icon = Items.getLast().m_contents[x].m_icon;
|
s32 icon = Items.getLast().m_contents[x].m_icon;
|
||||||
if (IconBank && icon > -1 &&
|
if (IconBank && icon > -1 &&
|
||||||
IconBank->getSprites().size() > (u32)icon &&
|
IconBank->getSprites().size() > (u32)icon &&
|
||||||
IconBank->getSprites()[(u32)icon].Frames.size())
|
IconBank->getSprites()[(u32)icon].Frames.size())
|
||||||
{
|
{
|
||||||
u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber;
|
u32 rno = IconBank->getSprites()[(u32)icon].Frames[0].rectNumber;
|
||||||
if (IconBank->getPositions().size() > rno)
|
if (IconBank->getPositions().size() > rno)
|
||||||
{
|
{
|
||||||
const s32 w = IconBank->getPositions()[rno].getWidth();
|
const s32 w = IconBank->getPositions()[rno].getWidth();
|
||||||
if (w > ItemsIconWidth)
|
if (w > ItemsIconWidth)
|
||||||
ItemsIconWidth = w;
|
ItemsIconWidth = w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::setCell(u32 row_num, u32 col_num, const wchar_t* text, s32 icon)
|
void CGUISTKListBox::setCell(u32 row_num, u32 col_num, const wchar_t* text, s32 icon)
|
||||||
{
|
{
|
||||||
if ( row_num >= Items.size() )
|
if ( row_num >= Items.size() )
|
||||||
return;
|
return;
|
||||||
if ( col_num >= Items[row_num].m_contents.size() )
|
if ( col_num >= Items[row_num].m_contents.size() )
|
||||||
return;
|
return;
|
||||||
Items[row_num].m_contents[col_num].m_text = text;
|
Items[row_num].m_contents[col_num].m_text = text;
|
||||||
Items[row_num].m_contents[col_num].m_icon = icon;
|
Items[row_num].m_contents[col_num].m_icon = icon;
|
||||||
|
|
||||||
recalculateItemHeight();
|
recalculateItemHeight();
|
||||||
recalculateIconWidth();
|
recalculateIconWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGUISTKListBox::swapItems(u32 index1, u32 index2)
|
void CGUISTKListBox::swapItems(u32 index1, u32 index2)
|
||||||
{
|
{
|
||||||
if ( index1 >= Items.size() || index2 >= Items.size() )
|
if ( index1 >= Items.size() || index2 >= Items.size() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ListItem dummmy = Items[index1];
|
ListItem dummmy = Items[index1];
|
||||||
Items[index1] = Items[index2];
|
Items[index1] = Items[index2];
|
||||||
Items[index2] = dummmy;
|
Items[index2] = dummmy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::setItemOverrideColor(u32 index, video::SColor color)
|
void CGUISTKListBox::setItemOverrideColor(u32 index, video::SColor color)
|
||||||
{
|
{
|
||||||
for ( u32 c=0; c < EGUI_LBC_COUNT; ++c )
|
for ( u32 c=0; c < EGUI_LBC_COUNT; ++c )
|
||||||
{
|
{
|
||||||
Items[index].OverrideColors[c].Use = true;
|
Items[index].OverrideColors[c].Use = true;
|
||||||
Items[index].OverrideColors[c].Color = color;
|
Items[index].OverrideColors[c].Color = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color)
|
void CGUISTKListBox::setItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType, video::SColor color)
|
||||||
{
|
{
|
||||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Items[index].OverrideColors[colorType].Use = true;
|
Items[index].OverrideColors[colorType].Use = true;
|
||||||
Items[index].OverrideColors[colorType].Color = color;
|
Items[index].OverrideColors[colorType].Color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::clearItemOverrideColor(u32 index)
|
void CGUISTKListBox::clearItemOverrideColor(u32 index)
|
||||||
{
|
{
|
||||||
for (u32 c=0; c < (u32)EGUI_LBC_COUNT; ++c )
|
for (u32 c=0; c < (u32)EGUI_LBC_COUNT; ++c )
|
||||||
{
|
{
|
||||||
Items[index].OverrideColors[c].Use = false;
|
Items[index].OverrideColors[c].Use = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CGUISTKListBox::clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType)
|
void CGUISTKListBox::clearItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType)
|
||||||
{
|
{
|
||||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Items[index].OverrideColors[colorType].Use = false;
|
Items[index].OverrideColors[colorType].Use = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CGUISTKListBox::hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const
|
bool CGUISTKListBox::hasItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const
|
||||||
{
|
{
|
||||||
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
if ( index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Items[index].OverrideColors[colorType].Use;
|
return Items[index].OverrideColors[colorType].Use;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
video::SColor CGUISTKListBox::getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const
|
video::SColor CGUISTKListBox::getItemOverrideColor(u32 index, EGUI_LISTBOX_COLOR colorType) const
|
||||||
{
|
{
|
||||||
if ( (u32)index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
if ( (u32)index >= Items.size() || colorType < 0 || colorType >= EGUI_LBC_COUNT )
|
||||||
return video::SColor();
|
return video::SColor();
|
||||||
|
|
||||||
return Items[index].OverrideColors[colorType].Color;
|
return Items[index].OverrideColors[colorType].Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
video::SColor CGUISTKListBox::getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const
|
video::SColor CGUISTKListBox::getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const
|
||||||
{
|
{
|
||||||
IGUISkin* skin = Environment->getSkin();
|
IGUISkin* skin = Environment->getSkin();
|
||||||
if ( !skin )
|
if ( !skin )
|
||||||
return video::SColor();
|
return video::SColor();
|
||||||
|
|
||||||
switch ( colorType )
|
switch ( colorType )
|
||||||
{
|
{
|
||||||
case EGUI_LBC_TEXT:
|
case EGUI_LBC_TEXT:
|
||||||
return skin->getColor(EGDC_BUTTON_TEXT);
|
return skin->getColor(EGDC_BUTTON_TEXT);
|
||||||
case EGUI_LBC_TEXT_HIGHLIGHT:
|
case EGUI_LBC_TEXT_HIGHLIGHT:
|
||||||
return skin->getColor(EGDC_HIGH_LIGHT_TEXT);
|
return skin->getColor(EGDC_HIGH_LIGHT_TEXT);
|
||||||
case EGUI_LBC_ICON:
|
case EGUI_LBC_ICON:
|
||||||
return skin->getColor(EGDC_ICON);
|
return skin->getColor(EGDC_ICON);
|
||||||
case EGUI_LBC_ICON_HIGHLIGHT:
|
case EGUI_LBC_ICON_HIGHLIGHT:
|
||||||
return skin->getColor(EGDC_ICON_HIGH_LIGHT);
|
return skin->getColor(EGDC_ICON_HIGH_LIGHT);
|
||||||
default:
|
default:
|
||||||
return video::SColor();
|
return video::SColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! set global itemHeight
|
//! set global itemHeight
|
||||||
void CGUISTKListBox::setItemHeight( s32 height )
|
void CGUISTKListBox::setItemHeight( s32 height )
|
||||||
{
|
{
|
||||||
ItemHeight = height;
|
ItemHeight = height;
|
||||||
ItemHeightOverride = 1;
|
ItemHeightOverride = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,12 +17,12 @@ namespace irr
|
|||||||
{
|
{
|
||||||
namespace gui
|
namespace gui
|
||||||
{
|
{
|
||||||
class IGUIFont;
|
class IGUIFont;
|
||||||
class IGUIScrollBar;
|
class IGUIScrollBar;
|
||||||
|
|
||||||
class CGUISTKListBox : public IGUIElement
|
class CGUISTKListBox : public IGUIElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct ListItem
|
struct ListItem
|
||||||
{
|
{
|
||||||
@ -163,7 +163,7 @@ namespace irr
|
|||||||
//! Sets whether to draw the background
|
//! Sets whether to draw the background
|
||||||
virtual void setDrawBackground(bool draw);
|
virtual void setDrawBackground(bool draw);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void recalculateItemHeight();
|
void recalculateItemHeight();
|
||||||
void selectNew(s32 ypos, bool onlyHover=false);
|
void selectNew(s32 ypos, bool onlyHover=false);
|
||||||
@ -189,7 +189,7 @@ namespace irr
|
|||||||
bool MoveOverSelect;
|
bool MoveOverSelect;
|
||||||
bool AutoScroll;
|
bool AutoScroll;
|
||||||
bool HighlightWhenNotFocused;
|
bool HighlightWhenNotFocused;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // end namespace gui
|
} // end namespace gui
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
const int BUBBLE_MARGIN_ON_RIGHT = 15;
|
const int BUBBLE_MARGIN_ON_RIGHT = 15;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A text widget that can expand when focused
|
* A text widget that can expand when focused
|
||||||
* \ingroup widgetsgroup
|
* \ingroup widgetsgroup
|
||||||
@ -35,36 +35,36 @@ namespace GUIEngine
|
|||||||
class BubbleWidget : public Widget
|
class BubbleWidget : public Widget
|
||||||
{
|
{
|
||||||
friend class Skin;
|
friend class Skin;
|
||||||
|
|
||||||
/** shrinked size of this widget (size allowed in layout; internal text may be bigger than that).
|
/** shrinked size of this widget (size allowed in layout; internal text may be bigger than that).
|
||||||
* If the text all fits in the allowed layout space, m_shrinked_size == m_expanded_size.
|
* If the text all fits in the allowed layout space, m_shrinked_size == m_expanded_size.
|
||||||
*/
|
*/
|
||||||
irr::core::rect<irr::s32> m_shrinked_size;
|
irr::core::rect<irr::s32> m_shrinked_size;
|
||||||
|
|
||||||
/** Expanded size of this widget (size to see all text inside the bubble).
|
/** Expanded size of this widget (size to see all text inside the bubble).
|
||||||
* If the text all fits in the allowed layout space, m_shrinked_size == m_expanded_size.
|
* If the text all fits in the allowed layout space, m_shrinked_size == m_expanded_size.
|
||||||
*/
|
*/
|
||||||
irr::core::rect<irr::s32> m_expanded_size;
|
irr::core::rect<irr::s32> m_expanded_size;
|
||||||
|
|
||||||
/** Text shrinked to fit into the allowed layout space (will be same as m_text if all text fits) */
|
/** Text shrinked to fit into the allowed layout space (will be same as m_text if all text fits) */
|
||||||
irr::core::stringw m_shrinked_text;
|
irr::core::stringw m_shrinked_text;
|
||||||
|
|
||||||
/** For the skin to create the zooming effect */
|
/** For the skin to create the zooming effect */
|
||||||
float m_zoom;
|
float m_zoom;
|
||||||
|
|
||||||
/** Will add/replace text in the bubble. If it doesn't fit, the text will get shrinked. **/
|
/** Will add/replace text in the bubble. If it doesn't fit, the text will get shrinked. **/
|
||||||
void replaceText();
|
void replaceText();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
BubbleWidget();
|
BubbleWidget();
|
||||||
|
|
||||||
virtual void add();
|
virtual void add();
|
||||||
|
|
||||||
virtual EventPropagation focused(const int playerID);
|
virtual EventPropagation focused(const int playerID);
|
||||||
|
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
void setText(const irr::core::stringw &s);
|
void setText(const irr::core::stringw &s);
|
||||||
|
@ -33,37 +33,37 @@
|
|||||||
|
|
||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* \brief A text button widget.
|
* \brief A text button widget.
|
||||||
* \ingroup widgetsgroup
|
* \ingroup widgetsgroup
|
||||||
*/
|
*/
|
||||||
class ButtonWidget : public Widget
|
class ButtonWidget : public Widget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
ButtonWidget();
|
ButtonWidget();
|
||||||
virtual ~ButtonWidget() {}
|
virtual ~ButtonWidget() {}
|
||||||
|
|
||||||
/** \brief Implement callback from base class Widget */
|
/** \brief Implement callback from base class Widget */
|
||||||
void add();
|
void add();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Change the label on the button
|
* \brief Change the label on the button
|
||||||
* \pre This should only be called after a widget has been add()ed (changing the label
|
* \pre This should only be called after a widget has been add()ed (changing the label
|
||||||
* before the widget is added can be done by editing the 'text' property of Widget).
|
* before the widget is added can be done by editing the 'text' property of Widget).
|
||||||
*/
|
*/
|
||||||
void setLabel(const irr::core::stringw &label);
|
void setLabel(const irr::core::stringw &label);
|
||||||
|
|
||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getWidthNeededAroundLabel() const { return 35; }
|
virtual int getWidthNeededAroundLabel() const { return 35; }
|
||||||
|
|
||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getHeightNeededAroundLabel() const { return 4; }
|
virtual int getHeightNeededAroundLabel() const { return 4; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,31 +33,31 @@ namespace GUIEngine
|
|||||||
class CheckBoxWidget : public Widget
|
class CheckBoxWidget : public Widget
|
||||||
{
|
{
|
||||||
bool m_state;
|
bool m_state;
|
||||||
EventPropagation transmitEvent(Widget* w,
|
EventPropagation transmitEvent(Widget* w,
|
||||||
const std::string& originator,
|
const std::string& originator,
|
||||||
const int playerID);
|
const int playerID);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
CheckBoxWidget();
|
CheckBoxWidget();
|
||||||
virtual ~CheckBoxWidget() {}
|
virtual ~CheckBoxWidget() {}
|
||||||
|
|
||||||
/** \brief Implement callback from parent class Widget */
|
/** \brief Implement callback from parent class Widget */
|
||||||
void add();
|
void add();
|
||||||
|
|
||||||
/** Get whether the checkbox is checked */
|
/** Get whether the checkbox is checked */
|
||||||
bool getState() const { return m_state; }
|
bool getState() const { return m_state; }
|
||||||
|
|
||||||
/** Set whether the checkbox is checked */
|
/** Set whether the checkbox is checked */
|
||||||
void setState(const bool checked) { m_state = checked; }
|
void setState(const bool checked) { m_state = checked; }
|
||||||
|
|
||||||
|
|
||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getHeightNeededAroundLabel() const { return 10; }
|
virtual int getHeightNeededAroundLabel() const { return 10; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
class IconButtonWidget;
|
class IconButtonWidget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Even if you have a ribbon that only acts on click/enter, you may wish to know which
|
* Even if you have a ribbon that only acts on click/enter, you may wish to know which
|
||||||
* item is currently highlighted. In this case, create a listener and pass it to the ribbon.
|
* item is currently highlighted. In this case, create a listener and pass it to the ribbon.
|
||||||
@ -39,12 +39,12 @@ namespace GUIEngine
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~DynamicRibbonHoverListener() {}
|
virtual ~DynamicRibbonHoverListener() {}
|
||||||
virtual void onSelectionChanged(DynamicRibbonWidget* theWidget,
|
virtual void onSelectionChanged(DynamicRibbonWidget* theWidget,
|
||||||
const std::string& selectionID,
|
const std::string& selectionID,
|
||||||
const irr::core::stringw& selectionText,
|
const irr::core::stringw& selectionText,
|
||||||
const int playerID) = 0;
|
const int playerID) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The description of an item added to a DynamicRibbonWidget */
|
/** The description of an item added to a DynamicRibbonWidget */
|
||||||
struct ItemDescription
|
struct ItemDescription
|
||||||
{
|
{
|
||||||
@ -52,17 +52,17 @@ namespace GUIEngine
|
|||||||
std::string m_code_name;
|
std::string m_code_name;
|
||||||
std::string m_sshot_file;
|
std::string m_sshot_file;
|
||||||
IconButtonWidget::IconPathType m_image_path_type;
|
IconButtonWidget::IconPathType m_image_path_type;
|
||||||
|
|
||||||
bool m_animated;
|
bool m_animated;
|
||||||
/** used instead of 'm_sshot_file' if m_animated is true */
|
/** used instead of 'm_sshot_file' if m_animated is true */
|
||||||
std::vector<std::string> m_all_images;
|
std::vector<std::string> m_all_images;
|
||||||
float m_curr_time;
|
float m_curr_time;
|
||||||
float m_time_per_frame;
|
float m_time_per_frame;
|
||||||
|
|
||||||
unsigned int m_badges;
|
unsigned int m_badges;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An extended version of RibbonWidget, with more capabilities.
|
* \brief An extended version of RibbonWidget, with more capabilities.
|
||||||
* A dynamic ribbon builds upon RibbonWidget, adding dynamic contents creation and sizing,
|
* A dynamic ribbon builds upon RibbonWidget, adding dynamic contents creation and sizing,
|
||||||
* scrolling, multiple-row layouts.
|
* scrolling, multiple-row layouts.
|
||||||
@ -73,55 +73,55 @@ namespace GUIEngine
|
|||||||
class DynamicRibbonWidget : public Widget, public RibbonWidget::IRibbonListener
|
class DynamicRibbonWidget : public Widget, public RibbonWidget::IRibbonListener
|
||||||
{
|
{
|
||||||
friend class RibbonWidget;
|
friend class RibbonWidget;
|
||||||
|
|
||||||
/** A list of all listeners that registered to be notified on hover/selection */
|
/** A list of all listeners that registered to be notified on hover/selection */
|
||||||
PtrVector<DynamicRibbonHoverListener> m_hover_listeners;
|
PtrVector<DynamicRibbonHoverListener> m_hover_listeners;
|
||||||
|
|
||||||
virtual ~DynamicRibbonWidget();
|
virtual ~DynamicRibbonWidget();
|
||||||
|
|
||||||
/** Used for ribbon grids that have a label at the bottom */
|
/** Used for ribbon grids that have a label at the bottom */
|
||||||
bool m_has_label;
|
bool m_has_label;
|
||||||
irr::gui::IGUIStaticText* m_label;
|
irr::gui::IGUIStaticText* m_label;
|
||||||
|
|
||||||
/** Height of ONE label text line (if label is multiline only one line is measured here).
|
/** Height of ONE label text line (if label is multiline only one line is measured here).
|
||||||
* If there is no label, will be 0.
|
* If there is no label, will be 0.
|
||||||
*/
|
*/
|
||||||
int m_label_height;
|
int m_label_height;
|
||||||
|
|
||||||
/** Whether this ribbon contains at least one animated item */
|
/** Whether this ribbon contains at least one animated item */
|
||||||
bool m_animated_contents;
|
bool m_animated_contents;
|
||||||
|
|
||||||
/** Whether there are more items than can fit in a single screen; arrows will then appear
|
/** Whether there are more items than can fit in a single screen; arrows will then appear
|
||||||
* on each side of the ribbon to scroll the contents
|
* on each side of the ribbon to scroll the contents
|
||||||
*/
|
*/
|
||||||
bool m_scrolling_enabled;
|
bool m_scrolling_enabled;
|
||||||
|
|
||||||
/** Used to keep track of item count changes */
|
/** Used to keep track of item count changes */
|
||||||
int m_previous_item_count;
|
int m_previous_item_count;
|
||||||
|
|
||||||
/** List of items in the ribbon */
|
/** List of items in the ribbon */
|
||||||
std::vector<ItemDescription> m_items;
|
std::vector<ItemDescription> m_items;
|
||||||
|
|
||||||
/** Width of the scrolling arrows on each side */
|
/** Width of the scrolling arrows on each side */
|
||||||
int m_arrows_w;
|
int m_arrows_w;
|
||||||
|
|
||||||
/** Current scroll offset within items */
|
/** Current scroll offset within items */
|
||||||
int m_scroll_offset;
|
int m_scroll_offset;
|
||||||
|
|
||||||
/** Width and height of children as declared in the GUI file */
|
/** Width and height of children as declared in the GUI file */
|
||||||
int m_child_width, m_child_height;
|
int m_child_width, m_child_height;
|
||||||
|
|
||||||
/** Number of rows and columns. Number of columns can dynamically change, number of row is
|
/** Number of rows and columns. Number of columns can dynamically change, number of row is
|
||||||
determined at creation */
|
determined at creation */
|
||||||
int m_row_amount;
|
int m_row_amount;
|
||||||
int m_col_amount;
|
int m_col_amount;
|
||||||
|
|
||||||
/** The total number of columns given item count and row count (even counting not visible with current scrolling) */
|
/** The total number of columns given item count and row count (even counting not visible with current scrolling) */
|
||||||
int m_needed_cols;
|
int m_needed_cols;
|
||||||
|
|
||||||
/** Whether this ribbon can have multiple rows (i.e. ribbon grid) or is a single line */
|
/** Whether this ribbon can have multiple rows (i.e. ribbon grid) or is a single line */
|
||||||
bool m_multi_row;
|
bool m_multi_row;
|
||||||
|
|
||||||
/** irrlicht relies on consecutive IDs to perform keyboard navigation between widgets. However, since this
|
/** irrlicht relies on consecutive IDs to perform keyboard navigation between widgets. However, since this
|
||||||
widget is dynamic, irrlicht widgets are not created as early as all others, so by the time we're ready
|
widget is dynamic, irrlicht widgets are not created as early as all others, so by the time we're ready
|
||||||
to create the full contents of this widget, the ID generator is already incremented, thus messing up
|
to create the full contents of this widget, the ID generator is already incremented, thus messing up
|
||||||
@ -129,65 +129,65 @@ namespace GUIEngine
|
|||||||
number of IDs (the number of rows) and store them here. Then, when we're finally ready to create the
|
number of IDs (the number of rows) and store them here. Then, when we're finally ready to create the
|
||||||
contents dynamically, we can re-use these IDs and get correct navigation order. */
|
contents dynamically, we can re-use these IDs and get correct navigation order. */
|
||||||
std::vector<int> m_ids;
|
std::vector<int> m_ids;
|
||||||
|
|
||||||
/** Whether this is a "combo" style ribbon grid widget */
|
/** Whether this is a "combo" style ribbon grid widget */
|
||||||
bool m_combo;
|
bool m_combo;
|
||||||
|
|
||||||
/* reference pointers only, the actual instances are owned by m_children */
|
/* reference pointers only, the actual instances are owned by m_children */
|
||||||
IconButtonWidget* m_left_widget;
|
IconButtonWidget* m_left_widget;
|
||||||
IconButtonWidget* m_right_widget;
|
IconButtonWidget* m_right_widget;
|
||||||
|
|
||||||
/** Returns the currently selected row */
|
/** Returns the currently selected row */
|
||||||
RibbonWidget* getSelectedRibbon(const int playerID);
|
RibbonWidget* getSelectedRibbon(const int playerID);
|
||||||
|
|
||||||
/** Returns the row */
|
/** Returns the row */
|
||||||
RibbonWidget* getRowContaining(Widget* w);
|
RibbonWidget* getRowContaining(Widget* w);
|
||||||
|
|
||||||
/** Updates the visible label to match the currently selected item */
|
/** Updates the visible label to match the currently selected item */
|
||||||
void updateLabel(RibbonWidget* from_this_ribbon=NULL);
|
void updateLabel(RibbonWidget* from_this_ribbon=NULL);
|
||||||
|
|
||||||
/** Even though the ribbon grid widget looks like a grid, it is really a vertical stack of
|
/** Even though the ribbon grid widget looks like a grid, it is really a vertical stack of
|
||||||
independant ribbons. When moving selection horizontally, this method is used to notify
|
independant ribbons. When moving selection horizontally, this method is used to notify
|
||||||
other rows above and below of which column is selected, so that moving vertically to
|
other rows above and below of which column is selected, so that moving vertically to
|
||||||
another row keeps the same selected column. */
|
another row keeps the same selected column. */
|
||||||
void propagateSelection();
|
void propagateSelection();
|
||||||
|
|
||||||
/** Callback called widget is focused */
|
/** Callback called widget is focused */
|
||||||
EventPropagation focused(const int playerID);
|
EventPropagation focused(const int playerID);
|
||||||
|
|
||||||
/** Removes all previously added contents icons, and re-adds them (calculating the new amount) */
|
/** Removes all previously added contents icons, and re-adds them (calculating the new amount) */
|
||||||
void buildInternalStructure();
|
void buildInternalStructure();
|
||||||
|
|
||||||
/** Call this to scroll within a scrollable ribbon */
|
/** Call this to scroll within a scrollable ribbon */
|
||||||
void scroll(const int x_delta);
|
void scroll(const int x_delta);
|
||||||
|
|
||||||
/** Used for combo ribbons, to contain the ID of the currently selected item for each player */
|
/** Used for combo ribbons, to contain the ID of the currently selected item for each player */
|
||||||
int m_selected_item[MAX_PLAYER_COUNT];
|
int m_selected_item[MAX_PLAYER_COUNT];
|
||||||
|
|
||||||
/** Callbacks */
|
/** Callbacks */
|
||||||
virtual void add();
|
virtual void add();
|
||||||
virtual EventPropagation mouseHovered(Widget* child, const int playerID);
|
virtual EventPropagation mouseHovered(Widget* child, const int playerID);
|
||||||
virtual EventPropagation transmitEvent(Widget* w, const std::string& originator, const int playerID);
|
virtual EventPropagation transmitEvent(Widget* w, const std::string& originator, const int playerID);
|
||||||
|
|
||||||
bool findItemInRows(const char* name, int* p_row, int* p_id);
|
bool findItemInRows(const char* name, int* p_row, int* p_id);
|
||||||
|
|
||||||
int m_item_count_hint;
|
int m_item_count_hint;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \param combo Whether this is a "combo" ribbon, i.e. whether there is always one selected item.
|
* \param combo Whether this is a "combo" ribbon, i.e. whether there is always one selected item.
|
||||||
* If set to false, will behave more like a toolbar.
|
* If set to false, will behave more like a toolbar.
|
||||||
* \param multi_row Whether this ribbon can have more than one row
|
* \param multi_row Whether this ribbon can have more than one row
|
||||||
*/
|
*/
|
||||||
DynamicRibbonWidget(const bool combo, const bool multi_row);
|
DynamicRibbonWidget(const bool combo, const bool multi_row);
|
||||||
|
|
||||||
/** Reference pointers only, the actual instances are owned by m_children. Used to create mtultiple-row
|
/** Reference pointers only, the actual instances are owned by m_children. Used to create mtultiple-row
|
||||||
ribbons (what appears to be a grid of icons is actually a vector of stacked basic ribbons) */
|
ribbons (what appears to be a grid of icons is actually a vector of stacked basic ribbons) */
|
||||||
PtrVector<RibbonWidget, REF> m_rows;
|
PtrVector<RibbonWidget, REF> m_rows;
|
||||||
|
|
||||||
/** Dynamically add an item to the ribbon's list of items (will not be visible until you
|
/** Dynamically add an item to the ribbon's list of items (will not be visible until you
|
||||||
* call 'updateItemDisplay' or 'add').
|
* call 'updateItemDisplay' or 'add').
|
||||||
*
|
*
|
||||||
@ -200,7 +200,7 @@ namespace GUIEngine
|
|||||||
void addItem( const irr::core::stringw& user_name, const std::string& code_name,
|
void addItem( const irr::core::stringw& user_name, const std::string& code_name,
|
||||||
const std::string& image_file, const unsigned int badge=0,
|
const std::string& image_file, const unsigned int badge=0,
|
||||||
IconButtonWidget::IconPathType image_path_type=IconButtonWidget::ICON_PATH_TYPE_RELATIVE);
|
IconButtonWidget::IconPathType image_path_type=IconButtonWidget::ICON_PATH_TYPE_RELATIVE);
|
||||||
|
|
||||||
/** Dynamically add an animated item to the ribbon's list of items (will not be visible until you
|
/** Dynamically add an animated item to the ribbon's list of items (will not be visible until you
|
||||||
* call 'updateItemDisplay' or 'add'). Animated means it has many images that will be shown in
|
* call 'updateItemDisplay' or 'add'). Animated means it has many images that will be shown in
|
||||||
* a slideshown fashion.
|
* a slideshown fashion.
|
||||||
@ -220,70 +220,70 @@ namespace GUIEngine
|
|||||||
/** Clears all items added through 'addItem'. You can then add new items with 'addItem' and call
|
/** Clears all items added through 'addItem'. You can then add new items with 'addItem' and call
|
||||||
'updateItemDisplay' to update the display. */
|
'updateItemDisplay' to update the display. */
|
||||||
void clearItems();
|
void clearItems();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Register a listener to be notified of selection changes within the ribbon.
|
* \brief Register a listener to be notified of selection changes within the ribbon.
|
||||||
* \note The ribbon takes ownership of this listener and will delete it.
|
* \note The ribbon takes ownership of this listener and will delete it.
|
||||||
* \note The listener will be deleted upon leaving the screen, so you will likely
|
* \note The listener will be deleted upon leaving the screen, so you will likely
|
||||||
* want to add a listener in the "init" callback of your screen.
|
* want to add a listener in the "init" callback of your screen.
|
||||||
*/
|
*/
|
||||||
void registerHoverListener(DynamicRibbonHoverListener* listener);
|
void registerHoverListener(DynamicRibbonHoverListener* listener);
|
||||||
|
|
||||||
/** Called when right key is pressed */
|
/** Called when right key is pressed */
|
||||||
EventPropagation rightPressed(const int playerID);
|
EventPropagation rightPressed(const int playerID);
|
||||||
|
|
||||||
/** Called when left key is pressed */
|
/** Called when left key is pressed */
|
||||||
EventPropagation leftPressed(const int playerID);
|
EventPropagation leftPressed(const int playerID);
|
||||||
|
|
||||||
/** Updates icons/labels given current items and scrolling offset, taking care of resizing
|
/** Updates icons/labels given current items and scrolling offset, taking care of resizing
|
||||||
the dynamic ribbon if the number of items changed */
|
the dynamic ribbon if the number of items changed */
|
||||||
void updateItemDisplay();
|
void updateItemDisplay();
|
||||||
|
|
||||||
/** Get the internal name (ID) of the selected item */
|
/** Get the internal name (ID) of the selected item */
|
||||||
const std::string& getSelectionIDString(const int playerID);
|
const std::string& getSelectionIDString(const int playerID);
|
||||||
|
|
||||||
/** Get the user-visible text of the selected item */
|
/** Get the user-visible text of the selected item */
|
||||||
irr::core::stringw getSelectionText(const int playerID);
|
irr::core::stringw getSelectionText(const int playerID);
|
||||||
|
|
||||||
/** Returns a read-only list of items added to this ribbon */
|
/** Returns a read-only list of items added to this ribbon */
|
||||||
const std::vector<ItemDescription>& getItems() const { return m_items; }
|
const std::vector<ItemDescription>& getItems() const { return m_items; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Select an item from its numerical ID. Only for [1-row] combo ribbons.
|
* \brief Select an item from its numerical ID. Only for [1-row] combo ribbons.
|
||||||
*
|
*
|
||||||
* \param item_id In range [0 .. number of items added through 'addItem' - 1]
|
* \param item_id In range [0 .. number of items added through 'addItem' - 1]
|
||||||
* \return Whether setting the selection was successful (whether the item exists)
|
* \return Whether setting the selection was successful (whether the item exists)
|
||||||
*/
|
*/
|
||||||
bool setSelection(int item_id, const int playerID, const bool focusIt, bool evenIfDeactivated=false);
|
bool setSelection(int item_id, const int playerID, const bool focusIt, bool evenIfDeactivated=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Select an item from its codename.
|
* \brief Select an item from its codename.
|
||||||
*
|
*
|
||||||
* \return Whether setting the selection was successful (whether the item exists)
|
* \return Whether setting the selection was successful (whether the item exists)
|
||||||
*/
|
*/
|
||||||
bool setSelection(const std::string &item_codename,
|
bool setSelection(const std::string &item_codename,
|
||||||
const int playerID, const bool focusIt,
|
const int playerID, const bool focusIt,
|
||||||
bool evenIfDeactivated=false);
|
bool evenIfDeactivated=false);
|
||||||
|
|
||||||
/** \brief Callback from parent class Widget. */
|
/** \brief Callback from parent class Widget. */
|
||||||
virtual void elementRemoved();
|
virtual void elementRemoved();
|
||||||
|
|
||||||
/** \brief callback from IRibbonListener */
|
/** \brief callback from IRibbonListener */
|
||||||
virtual void onRibbonWidgetScroll(const int delta_x);
|
virtual void onRibbonWidgetScroll(const int delta_x);
|
||||||
|
|
||||||
/** \brief callback from IRibbonListener */
|
/** \brief callback from IRibbonListener */
|
||||||
virtual void onRibbonWidgetFocus(RibbonWidget* emitter, const int playerID);
|
virtual void onRibbonWidgetFocus(RibbonWidget* emitter, const int playerID);
|
||||||
|
|
||||||
/** \brief callback from IRibbonListener */
|
/** \brief callback from IRibbonListener */
|
||||||
virtual void onSelectionChange(){}
|
virtual void onSelectionChange(){}
|
||||||
|
|
||||||
virtual void update(float delta);
|
virtual void update(float delta);
|
||||||
|
|
||||||
/** Set approximately how many items are expected to be in this ribbon; will help the layout
|
/** Set approximately how many items are expected to be in this ribbon; will help the layout
|
||||||
* algorithm next time add() is called */
|
* algorithm next time add() is called */
|
||||||
void setItemCountHint(int hint) { m_item_count_hint = hint; }
|
void setItemCountHint(int hint) { m_item_count_hint = hint; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,42 +54,42 @@ namespace GUIEngine
|
|||||||
* the path type as it currently is */
|
* the path type as it currently is */
|
||||||
ICON_PATH_TYPE_NO_CHANGE
|
ICON_PATH_TYPE_NO_CHANGE
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
IconPathType m_icon_path_type;
|
IconPathType m_icon_path_type;
|
||||||
|
|
||||||
friend class Skin;
|
friend class Skin;
|
||||||
|
|
||||||
irr::gui::IGUIStaticText* m_label;
|
irr::gui::IGUIStaticText* m_label;
|
||||||
irr::video::ITexture* m_texture;
|
irr::video::ITexture* m_texture;
|
||||||
irr::video::ITexture* m_highlight_texture;
|
irr::video::ITexture* m_highlight_texture;
|
||||||
|
|
||||||
int m_texture_w, m_texture_h;
|
int m_texture_w, m_texture_h;
|
||||||
|
|
||||||
ScaleMode m_scale_mode;
|
ScaleMode m_scale_mode;
|
||||||
float m_custom_aspect_ratio;
|
float m_custom_aspect_ratio;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
/** Whether to make the widget included in keyboard navigation order when adding */
|
/** Whether to make the widget included in keyboard navigation order when adding */
|
||||||
bool m_tab_stop;
|
bool m_tab_stop;
|
||||||
|
|
||||||
IconButtonWidget(ScaleMode scale_mode=SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, const bool tab_stop=true,
|
IconButtonWidget(ScaleMode scale_mode=SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, const bool tab_stop=true,
|
||||||
const bool focusable=true, IconPathType pathType=ICON_PATH_TYPE_RELATIVE);
|
const bool focusable=true, IconPathType pathType=ICON_PATH_TYPE_RELATIVE);
|
||||||
virtual ~IconButtonWidget() {}
|
virtual ~IconButtonWidget() {}
|
||||||
|
|
||||||
/** \brief Implement callback from base class Widget */
|
/** \brief Implement callback from base class Widget */
|
||||||
virtual void add();
|
virtual void add();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Call this if scale mode is SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO.
|
* \brief Call this if scale mode is SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO.
|
||||||
* \param custom_aspect_ratio The width/height aspect ratio
|
* \param custom_aspect_ratio The width/height aspect ratio
|
||||||
*/
|
*/
|
||||||
void setCustomAspectRatio(float custom_aspect_ratio) { m_custom_aspect_ratio = custom_aspect_ratio; }
|
void setCustomAspectRatio(float custom_aspect_ratio) { m_custom_aspect_ratio = custom_aspect_ratio; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Temporarily change the text label if there is a label (next time this screen is
|
* \brief Temporarily change the text label if there is a label (next time this screen is
|
||||||
* visited, the previous label will be back. For a permanent change, edit the 'text'
|
* visited, the previous label will be back. For a permanent change, edit the 'text'
|
||||||
@ -99,7 +99,7 @@ namespace GUIEngine
|
|||||||
* \note Calling this method on a button without label will have no effect
|
* \note Calling this method on a button without label will have no effect
|
||||||
*/
|
*/
|
||||||
void setLabel(irr::core::stringw new_label);
|
void setLabel(irr::core::stringw new_label);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the texture used for this icon.
|
* Change the texture used for this icon.
|
||||||
* \pre At the moment, the new texture must have the same aspct ratio
|
* \pre At the moment, the new texture must have the same aspct ratio
|
||||||
@ -107,11 +107,11 @@ namespace GUIEngine
|
|||||||
* be resized to fit a different aspect ratio.
|
* be resized to fit a different aspect ratio.
|
||||||
* \note May safely be called no matter if the widget is add()ed or not
|
* \note May safely be called no matter if the widget is add()ed or not
|
||||||
*/
|
*/
|
||||||
void setImage(const char* path_to_texture,
|
void setImage(const char* path_to_texture,
|
||||||
IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE);
|
IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE);
|
||||||
|
|
||||||
/** Convenience function taking std::string. */
|
/** Convenience function taking std::string. */
|
||||||
void setImage(const std::string &path_to_texture,
|
void setImage(const std::string &path_to_texture,
|
||||||
IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE)
|
IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE)
|
||||||
{
|
{
|
||||||
setImage(path_to_texture.c_str(), path_type);
|
setImage(path_to_texture.c_str(), path_type);
|
||||||
@ -125,15 +125,15 @@ namespace GUIEngine
|
|||||||
* \note May safely be called no matter if the widget is add()ed or not
|
* \note May safely be called no matter if the widget is add()ed or not
|
||||||
*/
|
*/
|
||||||
void setImage(irr::video::ITexture* texture);
|
void setImage(irr::video::ITexture* texture);
|
||||||
|
|
||||||
void setHighlightedImage(irr::video::ITexture* texture)
|
void setHighlightedImage(irr::video::ITexture* texture)
|
||||||
{
|
{
|
||||||
m_highlight_texture = texture;
|
m_highlight_texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief override from base class */
|
/** \brief override from base class */
|
||||||
virtual EventPropagation focused(const int playerID);
|
virtual EventPropagation focused(const int playerID);
|
||||||
|
|
||||||
/** \brief override from base class */
|
/** \brief override from base class */
|
||||||
virtual void unfocused(const int playerID, Widget* new_focus);
|
virtual void unfocused(const int playerID, Widget* new_focus);
|
||||||
};
|
};
|
||||||
|
@ -40,23 +40,23 @@ namespace GUIEngine
|
|||||||
|
|
||||||
/** Scroll speed in characters/seconds (0 if no scrolling). */
|
/** Scroll speed in characters/seconds (0 if no scrolling). */
|
||||||
float m_scroll_speed;
|
float m_scroll_speed;
|
||||||
|
|
||||||
/** Current scroll offset. */
|
/** Current scroll offset. */
|
||||||
float m_scroll_offset;
|
float m_scroll_offset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
/** Constructs the label widget. Parameter:
|
/** Constructs the label widget. Parameter:
|
||||||
* \param title True if the special title font should be used.
|
* \param title True if the special title font should be used.
|
||||||
* \param bright True if a bright color should be used
|
* \param bright True if a bright color should be used
|
||||||
* \note \c title and \c bright are mutually exclusive
|
* \note \c title and \c bright are mutually exclusive
|
||||||
*/
|
*/
|
||||||
LabelWidget(bool title=false, bool bright=false);
|
LabelWidget(bool title=false, bool bright=false);
|
||||||
|
|
||||||
virtual ~LabelWidget() {}
|
virtual ~LabelWidget() {}
|
||||||
|
|
||||||
/** \brief Callback from base class Widget */
|
/** \brief Callback from base class Widget */
|
||||||
virtual void add();
|
virtual void add();
|
||||||
|
|
||||||
@ -65,10 +65,10 @@ namespace GUIEngine
|
|||||||
void setColor(const irr::video::SColor& color);
|
void setColor(const irr::video::SColor& color);
|
||||||
void setErrorColor();
|
void setErrorColor();
|
||||||
void setDefaultColor();
|
void setDefaultColor();
|
||||||
|
|
||||||
/** \brief Callback from base class Widget */
|
/** \brief Callback from base class Widget */
|
||||||
virtual void update(float dt);
|
virtual void update(float dt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets the text in the label.
|
* \brief Sets the text in the label.
|
||||||
*
|
*
|
||||||
@ -84,21 +84,21 @@ namespace GUIEngine
|
|||||||
* only be passed after the widget has been add()ed.
|
* only be passed after the widget has been add()ed.
|
||||||
*/
|
*/
|
||||||
virtual void setText(const wchar_t *text, bool expandAsNeeded);
|
virtual void setText(const wchar_t *text, bool expandAsNeeded);
|
||||||
|
|
||||||
/** Overloaded function which takes a stringw. */
|
/** Overloaded function which takes a stringw. */
|
||||||
virtual void setText(const irr::core::stringw &s, bool expandAsNeeded)
|
virtual void setText(const irr::core::stringw &s, bool expandAsNeeded)
|
||||||
{
|
{
|
||||||
setText(s.c_str(), expandAsNeeded);
|
setText(s.c_str(), expandAsNeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/** Sets horizontal scroll speed. */
|
/** Sets horizontal scroll speed. */
|
||||||
void setScrollSpeed(float speed);
|
void setScrollSpeed(float speed);
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Check if the current has been fully scrolled
|
* \brief Check if the current has been fully scrolled
|
||||||
* \return true if the text has completely scrolled off
|
* \return true if the text has completely scrolled off
|
||||||
* \pre May only be called after this widget has been add()ed
|
* \pre May only be called after this widget has been add()ed
|
||||||
|
@ -38,10 +38,10 @@ namespace GUIEngine
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IListWidgetHeaderListener(){}
|
virtual ~IListWidgetHeaderListener(){}
|
||||||
|
|
||||||
virtual void onColumnClicked(int columnId) = 0;
|
virtual void onColumnClicked(int columnId) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief A vertical list widget with text entries
|
/** \brief A vertical list widget with text entries
|
||||||
* \ingroup widgetsgroup
|
* \ingroup widgetsgroup
|
||||||
* \note items you add to a list are not kept after the the list is in was removed
|
* \note items you add to a list are not kept after the the list is in was removed
|
||||||
@ -50,62 +50,62 @@ namespace GUIEngine
|
|||||||
class ListWidget : public Widget
|
class ListWidget : public Widget
|
||||||
{
|
{
|
||||||
friend class Skin;
|
friend class Skin;
|
||||||
|
|
||||||
/** \brief whether this list has icons */
|
/** \brief whether this list has icons */
|
||||||
bool m_use_icons;
|
bool m_use_icons;
|
||||||
|
|
||||||
/** \brief if m_use_icons is true, this will contain the icon bank */
|
/** \brief if m_use_icons is true, this will contain the icon bank */
|
||||||
irr::gui::STKModifiedSpriteBank* m_icons;
|
irr::gui::STKModifiedSpriteBank* m_icons;
|
||||||
|
|
||||||
PtrVector< ButtonWidget > m_header_elements;
|
PtrVector< ButtonWidget > m_header_elements;
|
||||||
|
|
||||||
ButtonWidget* m_selected_column;
|
ButtonWidget* m_selected_column;
|
||||||
|
|
||||||
/** \brief whether this list is sorted in descending order */
|
/** \brief whether this list is sorted in descending order */
|
||||||
bool m_sort_desc;
|
bool m_sort_desc;
|
||||||
|
|
||||||
/** true when deault sorting is enabled */
|
/** true when deault sorting is enabled */
|
||||||
bool m_sort_default;
|
bool m_sort_default;
|
||||||
|
|
||||||
/** index of column*/
|
/** index of column*/
|
||||||
int m_sort_col;
|
int m_sort_col;
|
||||||
|
|
||||||
struct Column
|
struct Column
|
||||||
{
|
{
|
||||||
irr::core::stringw m_text;
|
irr::core::stringw m_text;
|
||||||
int m_proportion;
|
int m_proportion;
|
||||||
|
|
||||||
Column(irr::core::stringw text, int proportion)
|
Column(irr::core::stringw text, int proportion)
|
||||||
{
|
{
|
||||||
m_text = text;
|
m_text = text;
|
||||||
m_proportion = proportion;
|
m_proportion = proportion;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Leave empty for no header */
|
/** Leave empty for no header */
|
||||||
std::vector< Column > m_header;
|
std::vector< Column > m_header;
|
||||||
|
|
||||||
IListWidgetHeaderListener* m_listener;
|
IListWidgetHeaderListener* m_listener;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef irr::gui::CGUISTKListBox::ListItem ListItem;
|
typedef irr::gui::CGUISTKListBox::ListItem ListItem;
|
||||||
typedef ListItem::ListCell ListCell;
|
typedef ListItem::ListCell ListCell;
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
ListWidget();
|
ListWidget();
|
||||||
|
|
||||||
SkinWidgetContainer m_selection_skin_info;
|
SkinWidgetContainer m_selection_skin_info;
|
||||||
|
|
||||||
/** \brief implement add method from base class GUIEngine::Widget */
|
/** \brief implement add method from base class GUIEngine::Widget */
|
||||||
virtual void add();
|
virtual void add();
|
||||||
|
|
||||||
/** \brief implement callback from base class GUIEngine::Widget */
|
/** \brief implement callback from base class GUIEngine::Widget */
|
||||||
virtual void unfocused(const int playerID, Widget* new_focus);
|
virtual void unfocused(const int playerID, Widget* new_focus);
|
||||||
|
|
||||||
/** \brief implement callback from base class GUIEngine::Widget */
|
/** \brief implement callback from base class GUIEngine::Widget */
|
||||||
virtual void elementRemoved();
|
virtual void elementRemoved();
|
||||||
|
|
||||||
/** \brief set the icon bank to use for list entries.
|
/** \brief set the icon bank to use for list entries.
|
||||||
*
|
*
|
||||||
* The height of list entries will be ajusted to the size of the highest icon.
|
* The height of list entries will be ajusted to the size of the highest icon.
|
||||||
@ -116,10 +116,10 @@ namespace GUIEngine
|
|||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
void setIcons(irr::gui::STKModifiedSpriteBank* icons, int size=-1);
|
void setIcons(irr::gui::STKModifiedSpriteBank* icons, int size=-1);
|
||||||
|
|
||||||
|
|
||||||
// ---- contents management
|
// ---- contents management
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief add an item to the list
|
* \brief add an item to the list
|
||||||
* \param name user-visible, potentially translated, name of the item
|
* \param name user-visible, potentially translated, name of the item
|
||||||
@ -133,53 +133,53 @@ namespace GUIEngine
|
|||||||
|
|
||||||
void addItem( const std::string& internal_name,
|
void addItem( const std::string& internal_name,
|
||||||
const std::vector<ListCell>& contents);
|
const std::vector<ListCell>& contents);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief erases all items in the list
|
* \brief erases all items in the list
|
||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \return the number of items in the list
|
* \return the number of items in the list
|
||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
int getItemCount() const;
|
int getItemCount() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \return the index of the selected element within the list, or -1 if none
|
* \return the index of the selected element within the list, or -1 if none
|
||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
int getSelectionID() const;
|
int getSelectionID() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \return the text of the selected item
|
* \return the text of the selected item
|
||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
std::string getSelectionInternalName();
|
std::string getSelectionInternalName();
|
||||||
|
|
||||||
irr::core::stringw getSelectionLabel(const int cell = 0) const;
|
irr::core::stringw getSelectionLabel(const int cell = 0) const;
|
||||||
|
|
||||||
void selectItemWithLabel(const irr::core::stringw& name);
|
void selectItemWithLabel(const irr::core::stringw& name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Finds the ID of the item that has a given internal name
|
* \brief Finds the ID of the item that has a given internal name
|
||||||
*/
|
*/
|
||||||
int getItemID(const std::string internalName) const;
|
int getItemID(const std::string internalName) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief change the selected item
|
* \brief change the selected item
|
||||||
* \param index the index of the element to select within the list, or -1 to select nothing
|
* \param index the index of the element to select within the list, or -1 to select nothing
|
||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
void setSelectionID(const int index);
|
void setSelectionID(const int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief rename an item and/or change its icon based on its ID
|
* \brief rename an item and/or change its icon based on its ID
|
||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
void renameCell(const int row_num, const int col_num, const irr::core::stringw newName, const int icon=-1);
|
void renameCell(const int row_num, const int col_num, const irr::core::stringw newName, const int icon=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* renames first cell only
|
* renames first cell only
|
||||||
*/
|
*/
|
||||||
@ -197,18 +197,18 @@ namespace GUIEngine
|
|||||||
assert(id != -1);
|
assert(id != -1);
|
||||||
renameCell( id, col_num, newName, icon );
|
renameCell( id, col_num, newName, icon );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Make an item red to mark an error, for instance
|
* \brief Make an item red to mark an error, for instance
|
||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
void markItemRed(const int id, bool red=true);
|
void markItemRed(const int id, bool red=true);
|
||||||
void markItemBlue(const int id, bool blue=true);
|
void markItemBlue(const int id, bool blue=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Make an item red to mark an error, for instance
|
* \brief Make an item red to mark an error, for instance
|
||||||
* \pre may only be called after the widget has been added to the screen with add()
|
* \pre may only be called after the widget has been added to the screen with add()
|
||||||
*/
|
*/
|
||||||
void markItemRed(const std::string internalName, bool red=true)
|
void markItemRed(const std::string internalName, bool red=true)
|
||||||
{
|
{
|
||||||
const int id = getItemID(internalName);
|
const int id = getItemID(internalName);
|
||||||
@ -224,21 +224,21 @@ namespace GUIEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Override callback from Widget */
|
/** Override callback from Widget */
|
||||||
virtual EventPropagation transmitEvent(Widget* w,
|
virtual EventPropagation transmitEvent(Widget* w,
|
||||||
const std::string& originator,
|
const std::string& originator,
|
||||||
const int playerID);
|
const int playerID);
|
||||||
|
|
||||||
void setColumnListener(IListWidgetHeaderListener* listener)
|
void setColumnListener(IListWidgetHeaderListener* listener)
|
||||||
{
|
{
|
||||||
if (m_listener) delete m_listener;
|
if (m_listener) delete m_listener;
|
||||||
m_listener = listener;
|
m_listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** To be called before Widget::add(); columns are persistent across multiple add/remove cycles
|
/** To be called before Widget::add(); columns are persistent across multiple add/remove cycles
|
||||||
* \param proportion A column with proportion 2 will be twice as large as a column with proportion 1
|
* \param proportion A column with proportion 2 will be twice as large as a column with proportion 1
|
||||||
*/
|
*/
|
||||||
void addColumn(irr::core::stringw col, int proportion=1) { m_header.push_back( Column(col, proportion) ); }
|
void addColumn(irr::core::stringw col, int proportion=1) { m_header.push_back( Column(col, proportion) ); }
|
||||||
|
|
||||||
void clearColumns() { m_header.clear(); }
|
void clearColumns() { m_header.clear(); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -44,53 +44,53 @@ namespace GUIEngine
|
|||||||
RotationMode m_rotation_mode;
|
RotationMode m_rotation_mode;
|
||||||
float m_rotation_speed;
|
float m_rotation_speed;
|
||||||
float m_rotation_target;
|
float m_rotation_target;
|
||||||
|
|
||||||
PtrVector<scene::IMesh, REF> m_models;
|
PtrVector<scene::IMesh, REF> m_models;
|
||||||
AlignedArray<Vec3> m_model_location;
|
AlignedArray<Vec3> m_model_location;
|
||||||
AlignedArray<Vec3> m_model_scale;
|
AlignedArray<Vec3> m_model_scale;
|
||||||
std::vector<int> m_model_frames;
|
std::vector<int> m_model_frames;
|
||||||
|
|
||||||
video::ITexture* m_texture;
|
video::ITexture* m_texture;
|
||||||
|
|
||||||
IrrDriver::RTTProvider* m_rtt_provider;
|
IrrDriver::RTTProvider* m_rtt_provider;
|
||||||
|
|
||||||
float angle;
|
float angle;
|
||||||
|
|
||||||
bool m_rtt_unsupported;
|
bool m_rtt_unsupported;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
ModelViewWidget();
|
ModelViewWidget();
|
||||||
virtual ~ModelViewWidget();
|
virtual ~ModelViewWidget();
|
||||||
|
|
||||||
void add();
|
void add();
|
||||||
void clearModels();
|
void clearModels();
|
||||||
void addModel(irr::scene::IMesh* mesh,
|
void addModel(irr::scene::IMesh* mesh,
|
||||||
const Vec3& location = Vec3(0,0,0),
|
const Vec3& location = Vec3(0,0,0),
|
||||||
const Vec3& scale = Vec3(1,1,1),
|
const Vec3& scale = Vec3(1,1,1),
|
||||||
const int frame=-1);
|
const int frame=-1);
|
||||||
|
|
||||||
void update(float delta);
|
void update(float delta);
|
||||||
|
|
||||||
virtual void elementRemoved();
|
virtual void elementRemoved();
|
||||||
|
|
||||||
/** Disables any model rotation */
|
/** Disables any model rotation */
|
||||||
void setRotateOff();
|
void setRotateOff();
|
||||||
|
|
||||||
/** Makes the model rotate at given speed (in degrees per second) */
|
/** Makes the model rotate at given speed (in degrees per second) */
|
||||||
void setRotateContinuously(float speed);
|
void setRotateContinuously(float speed);
|
||||||
|
|
||||||
/** Rotate to 'targetAngle' in degrees at given speed (in degrees per second) */
|
/** Rotate to 'targetAngle' in degrees at given speed (in degrees per second) */
|
||||||
void setRotateTo(float targetAngle, float speed);
|
void setRotateTo(float targetAngle, float speed);
|
||||||
|
|
||||||
/** Returns information if currently kart is rotating */
|
/** Returns information if currently kart is rotating */
|
||||||
bool isRotating();
|
bool isRotating();
|
||||||
|
|
||||||
void clearRttProvider();
|
void clearRttProvider();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* \brief A progress bar widget.
|
* \brief A progress bar widget.
|
||||||
* \ingroup widgetsgroup
|
* \ingroup widgetsgroup
|
||||||
*/
|
*/
|
||||||
@ -37,32 +37,32 @@ namespace GUIEngine
|
|||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getWidthNeededAroundLabel() const { return 35; }
|
virtual int getWidthNeededAroundLabel() const { return 35; }
|
||||||
|
|
||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getHeightNeededAroundLabel() const { return 4; }
|
virtual int getHeightNeededAroundLabel() const { return 4; }
|
||||||
|
|
||||||
/** Change the label on the widget */
|
/** Change the label on the widget */
|
||||||
void setLabel(const irr::core::stringw label);
|
void setLabel(const irr::core::stringw label);
|
||||||
int m_value;
|
int m_value;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
ProgressBarWidget();
|
ProgressBarWidget();
|
||||||
virtual ~ProgressBarWidget() {}
|
virtual ~ProgressBarWidget() {}
|
||||||
|
|
||||||
/** Change the value of the widget, it must be a percent. */
|
/** Change the value of the widget, it must be a percent. */
|
||||||
void setValue(int value);
|
void setValue(int value);
|
||||||
|
|
||||||
|
|
||||||
void add();
|
void add();
|
||||||
|
|
||||||
/** Get the current value of the widget. */
|
/** Get the current value of the widget. */
|
||||||
int getValue() {return m_value; };
|
int getValue() {return m_value; };
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,7 +56,7 @@ void RatingBarWidget::add()
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/** Get the current step of the star
|
/** Get the current step of the star
|
||||||
*
|
*
|
||||||
* \param index The index of the star.
|
* \param index The index of the star.
|
||||||
* \return The current step of the star.
|
* \return The current step of the star.
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* \brief A rating bar widget.
|
* \brief A rating bar widget.
|
||||||
* \ingroup widgetsgroup
|
* \ingroup widgetsgroup
|
||||||
*/
|
*/
|
||||||
@ -47,28 +47,28 @@ namespace GUIEngine
|
|||||||
void setStepValues(float rating);
|
void setStepValues(float rating);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
RatingBarWidget();
|
RatingBarWidget();
|
||||||
virtual ~RatingBarWidget() {}
|
virtual ~RatingBarWidget() {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void add();
|
void add();
|
||||||
|
|
||||||
/** Change the rating value of the widget. */
|
/** Change the rating value of the widget. */
|
||||||
void setRating(float rating);
|
void setRating(float rating);
|
||||||
|
|
||||||
/** Get the current value of the widget. */
|
/** Get the current value of the widget. */
|
||||||
float getRating() {return m_rating; };
|
float getRating() {return m_rating; };
|
||||||
|
|
||||||
/** Change the number of stars of the widget. */
|
/** Change the number of stars of the widget. */
|
||||||
void setStarNumber(int star_number) { m_stars = star_number; };
|
void setStarNumber(int star_number) { m_stars = star_number; };
|
||||||
|
|
||||||
/** Get the current number of stars of the widget. */
|
/** Get the current number of stars of the widget. */
|
||||||
int getStarNumber() {return m_stars; };
|
int getStarNumber() {return m_stars; };
|
||||||
|
|
||||||
int getStepsOfStar(int index);
|
int getStepsOfStar(int index);
|
||||||
|
|
||||||
void setStepValuesByMouse(const core::position2di & mouse_position, const core::recti & stars_rect);
|
void setStepValuesByMouse(const core::position2di & mouse_position, const core::recti & stars_rect);
|
||||||
@ -76,7 +76,7 @@ namespace GUIEngine
|
|||||||
virtual void onClick();
|
virtual void onClick();
|
||||||
|
|
||||||
void allowVoting() { m_allow_voting = true; }
|
void allowVoting() { m_allow_voting = true; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -305,7 +305,7 @@ void RibbonWidget::add()
|
|||||||
(float)m_active_children[i].m_w / (float)m_active_children[i].m_h;
|
(float)m_active_children[i].m_w / (float)m_active_children[i].m_h;
|
||||||
|
|
||||||
// calculate the size of the image
|
// calculate the size of the image
|
||||||
std::string filename =
|
std::string filename =
|
||||||
file_manager->getAsset(m_active_children[i].m_properties[PROP_ICON]);
|
file_manager->getAsset(m_active_children[i].m_properties[PROP_ICON]);
|
||||||
video::ITexture* image =
|
video::ITexture* image =
|
||||||
irr_driver->getTexture((filename).c_str());
|
irr_driver->getTexture((filename).c_str());
|
||||||
|
@ -42,8 +42,8 @@ namespace GUIEngine
|
|||||||
/** \brief A static text/icons/tabs bar widget.
|
/** \brief A static text/icons/tabs bar widget.
|
||||||
* The contents of this ribbon are static.
|
* The contents of this ribbon are static.
|
||||||
* \ingroup widgetsgroup
|
* \ingroup widgetsgroup
|
||||||
* \note items you add to a list are kept after the the ribbon was in
|
* \note items you add to a list are kept after the the ribbon was in
|
||||||
* is removed (i.e. you don't need to add items everytime the
|
* is removed (i.e. you don't need to add items everytime the
|
||||||
* screen is shown, only upon loading)
|
* screen is shown, only upon loading)
|
||||||
*/
|
*/
|
||||||
class RibbonWidget : public Widget
|
class RibbonWidget : public Widget
|
||||||
@ -54,79 +54,79 @@ namespace GUIEngine
|
|||||||
public:
|
public:
|
||||||
virtual ~IRibbonListener(){}
|
virtual ~IRibbonListener(){}
|
||||||
virtual void onRibbonWidgetScroll(const int delta_x) = 0;
|
virtual void onRibbonWidgetScroll(const int delta_x) = 0;
|
||||||
virtual void onRibbonWidgetFocus(RibbonWidget* emitter,
|
virtual void onRibbonWidgetFocus(RibbonWidget* emitter,
|
||||||
const int playerID) = 0;
|
const int playerID) = 0;
|
||||||
virtual void onSelectionChange() = 0;
|
virtual void onSelectionChange() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class DynamicRibbonWidget;
|
friend class DynamicRibbonWidget;
|
||||||
friend class EventHandler;
|
friend class EventHandler;
|
||||||
|
|
||||||
int m_selection[MAX_PLAYER_COUNT];
|
int m_selection[MAX_PLAYER_COUNT];
|
||||||
|
|
||||||
/** The type of this ribbon (toolbar, combo, tabs) */
|
/** The type of this ribbon (toolbar, combo, tabs) */
|
||||||
RibbonType m_ribbon_type;
|
RibbonType m_ribbon_type;
|
||||||
|
|
||||||
/** Each item within the ribbon holds a flag saying whether it is
|
/** Each item within the ribbon holds a flag saying whether it is
|
||||||
* selected or not. This method updates the flag in all of this
|
* selected or not. This method updates the flag in all of this
|
||||||
* ribbon's children. Called everytime selection changes.*/
|
* ribbon's children. Called everytime selection changes.*/
|
||||||
void updateSelection();
|
void updateSelection();
|
||||||
|
|
||||||
/** Callbacks */
|
/** Callbacks */
|
||||||
virtual EventPropagation rightPressed(const int playerID=0);
|
virtual EventPropagation rightPressed(const int playerID=0);
|
||||||
virtual EventPropagation leftPressed(const int playerID=0);
|
virtual EventPropagation leftPressed(const int playerID=0);
|
||||||
virtual EventPropagation mouseHovered(Widget* child,
|
virtual EventPropagation mouseHovered(Widget* child,
|
||||||
const int playerID);
|
const int playerID);
|
||||||
virtual EventPropagation transmitEvent(Widget* w,
|
virtual EventPropagation transmitEvent(Widget* w,
|
||||||
const std::string& originator,
|
const std::string& originator,
|
||||||
const int playerID=0);
|
const int playerID=0);
|
||||||
virtual EventPropagation focused(const int playerID);
|
virtual EventPropagation focused(const int playerID);
|
||||||
virtual void unfocused(const int playerID, Widget* new_focus);
|
virtual void unfocused(const int playerID, Widget* new_focus);
|
||||||
|
|
||||||
PtrVector<irr::gui::IGUIStaticText, REF> m_labels;
|
PtrVector<irr::gui::IGUIStaticText, REF> m_labels;
|
||||||
|
|
||||||
IRibbonListener* m_listener;
|
IRibbonListener* m_listener;
|
||||||
PtrVector<Widget> m_active_children;
|
PtrVector<Widget> m_active_children;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
/** Internal identifier of filler items that are added in a ribbon
|
/** Internal identifier of filler items that are added in a ribbon
|
||||||
* widget to filllines when the number of items cannot be divided
|
* widget to filllines when the number of items cannot be divided
|
||||||
* by the number of rows in the grid (mostly used by dynamic ribbon
|
* by the number of rows in the grid (mostly used by dynamic ribbon
|
||||||
* widgets, but the base ribbon needs to know about filler items)
|
* widgets, but the base ribbon needs to know about filler items)
|
||||||
*/
|
*/
|
||||||
static const char NO_ITEM_ID[];
|
static const char NO_ITEM_ID[];
|
||||||
|
|
||||||
/** Contains which element within the ribbon is currently focused by
|
/** Contains which element within the ribbon is currently focused by
|
||||||
* player 0 (used by the skin to show mouse hovers over items that
|
* player 0 (used by the skin to show mouse hovers over items that
|
||||||
* are not selected). Only used for COMBO and TAB ribbons. */
|
* are not selected). Only used for COMBO and TAB ribbons. */
|
||||||
Widget* m_mouse_focus;
|
Widget* m_mouse_focus;
|
||||||
|
|
||||||
RibbonWidget(const RibbonType type=RIBBON_COMBO);
|
RibbonWidget(const RibbonType type=RIBBON_COMBO);
|
||||||
virtual ~RibbonWidget();
|
virtual ~RibbonWidget();
|
||||||
|
|
||||||
void add();
|
void add();
|
||||||
|
|
||||||
/** Sets a listener that will be notified of changes on this ribbon.
|
/** Sets a listener that will be notified of changes on this ribbon.
|
||||||
* Does _not_ take ownership of the listener, i.e. will not delete it.
|
* Does _not_ take ownership of the listener, i.e. will not delete it.
|
||||||
* You may call this with the listener parameter set to NULL to
|
* You may call this with the listener parameter set to NULL to
|
||||||
* remove the listener. */
|
* remove the listener. */
|
||||||
void setListener(IRibbonListener* listener) { m_listener = listener; }
|
void setListener(IRibbonListener* listener) { m_listener = listener; }
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
/** Returns the type of this ribbon (see the GUI module overview page
|
/** Returns the type of this ribbon (see the GUI module overview page
|
||||||
* for detailed descriptions) */
|
* for detailed descriptions) */
|
||||||
RibbonType getRibbonType() const { return m_ribbon_type; }
|
RibbonType getRibbonType() const { return m_ribbon_type; }
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
/** Returns the numerical ID of the selected item within the ribbon */
|
/** Returns the numerical ID of the selected item within the ribbon */
|
||||||
int getSelection(const int playerID) const
|
int getSelection(const int playerID) const
|
||||||
{ return m_selection[playerID]; }
|
{ return m_selection[playerID]; }
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
/** Returns the string ID (internal name) of the selection */
|
/** Returns the string ID (internal name) of the selection */
|
||||||
const std::string& getSelectionIDString(const int playerID);
|
const std::string& getSelectionIDString(const int playerID);
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
/** Returns the user-visible text of the selection */
|
/** Returns the user-visible text of the selection */
|
||||||
irr::core::stringw getSelectionText(const int playerID)
|
irr::core::stringw getSelectionText(const int playerID)
|
||||||
{
|
{
|
||||||
@ -134,15 +134,15 @@ namespace GUIEngine
|
|||||||
if (selection < 0 || selection >= int(m_children.size())) return "";
|
if (selection < 0 || selection >= int(m_children.size())) return "";
|
||||||
return m_children[selection].m_text;
|
return m_children[selection].m_text;
|
||||||
}
|
}
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/** Sets the ID of the selected item within the ribbon */
|
/** Sets the ID of the selected item within the ribbon */
|
||||||
void setSelection(const int i, const int playerID)
|
void setSelection(const int i, const int playerID)
|
||||||
{ m_selection[playerID] = i; updateSelection(); }
|
{ m_selection[playerID] = i; updateSelection(); }
|
||||||
|
|
||||||
/** Select an item in the ribbon by its internal name */
|
/** Select an item in the ribbon by its internal name */
|
||||||
void select(std::string item, const int playerID);
|
void select(std::string item, const int playerID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief This method can be used to rename an item.
|
* \brief This method can be used to rename an item.
|
||||||
* Has no effect for ribbons without individual labels.
|
* Has no effect for ribbons without individual labels.
|
||||||
@ -151,22 +151,22 @@ namespace GUIEngine
|
|||||||
* \param id The index of the item to rename, in range [0 .. item count - 1]
|
* \param id The index of the item to rename, in range [0 .. item count - 1]
|
||||||
*/
|
*/
|
||||||
void setLabel(const unsigned int id, irr::core::stringw new_name);
|
void setLabel(const unsigned int id, irr::core::stringw new_name);
|
||||||
|
|
||||||
/** Returns the ID of the item, or -1 if not found */
|
/** Returns the ID of the item, or -1 if not found */
|
||||||
int findItemNamed(const char* internalName);
|
int findItemNamed(const char* internalName);
|
||||||
|
|
||||||
/** Returns the the widget, or NULL if not found */
|
/** Returns the the widget, or NULL if not found */
|
||||||
GUIEngine::Widget * findWidgetNamed(const char* interalName);
|
GUIEngine::Widget * findWidgetNamed(const char* interalName);
|
||||||
|
|
||||||
/** \brief Dynamically (at runtime) add a text item to this ribbon
|
/** \brief Dynamically (at runtime) add a text item to this ribbon
|
||||||
* \pre This must be called before RibbonWidget::add, while the
|
* \pre This must be called before RibbonWidget::add, while the
|
||||||
* widget is not yet displayed
|
* widget is not yet displayed
|
||||||
* \pre only valid for ribbons that take text-only contents
|
* \pre only valid for ribbons that take text-only contents
|
||||||
* (e.g. tab bars)
|
* (e.g. tab bars)
|
||||||
*/
|
*/
|
||||||
void addTextChild(const wchar_t* text, const std::string id);
|
void addTextChild(const wchar_t* text, const std::string id);
|
||||||
|
|
||||||
|
|
||||||
/** \brief Dynamically (at runtime) add an icon item to this ribbon.
|
/** \brief Dynamically (at runtime) add an icon item to this ribbon.
|
||||||
* \pre this must be called before RibbonWidget::add, while the widget
|
* \pre this must be called before RibbonWidget::add, while the widget
|
||||||
* is not yet displayed
|
* is not yet displayed
|
||||||
@ -176,19 +176,19 @@ namespace GUIEngine
|
|||||||
const int w, const int h, const std::string &icon,
|
const int w, const int h, const std::string &icon,
|
||||||
const IconButtonWidget::IconPathType iconPathType=
|
const IconButtonWidget::IconPathType iconPathType=
|
||||||
IconButtonWidget::ICON_PATH_TYPE_RELATIVE);
|
IconButtonWidget::ICON_PATH_TYPE_RELATIVE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief clear all children of this ribbon (likely because new ones will be added soon after)
|
* \brief clear all children of this ribbon (likely because new ones will be added soon after)
|
||||||
* \pre this must be called before RibbonWidget::add, while the widget is not yet displayed
|
* \pre this must be called before RibbonWidget::add, while the widget is not yet displayed
|
||||||
*/
|
*/
|
||||||
void clearAllChildren();
|
void clearAllChildren();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief clear one child from this ribbon
|
* \brief clear one child from this ribbon
|
||||||
* \pre this must be called before RibbonWidget::add, while the widget is not yet displayed
|
* \pre this must be called before RibbonWidget::add, while the widget is not yet displayed
|
||||||
*/
|
*/
|
||||||
void removeChildNamed(const char* name);
|
void removeChildNamed(const char* name);
|
||||||
|
|
||||||
PtrVector<Widget>& getRibbonChildren() { return m_children; }
|
PtrVector<Widget>& getRibbonChildren() { return m_children; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,17 +62,17 @@ void SpinnerWidget::add()
|
|||||||
|
|
||||||
if (min_s.size() > 0)
|
if (min_s.size() > 0)
|
||||||
{
|
{
|
||||||
if (!StringUtils::parseString<int>(min_s, &m_min))
|
if (!StringUtils::parseString<int>(min_s, &m_min))
|
||||||
{
|
{
|
||||||
Log::warn("invalid value for spinner widget minimum value : %s", min_s.c_str());
|
Log::warn("invalid value for spinner widget minimum value : %s", min_s.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_s.size() > 0)
|
if (max_s.size() > 0)
|
||||||
{
|
{
|
||||||
if (!StringUtils::parseString<int>(max_s, &m_max))
|
if (!StringUtils::parseString<int>(max_s, &m_max))
|
||||||
{
|
{
|
||||||
Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str());
|
Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ void SpinnerWidget::add()
|
|||||||
{
|
{
|
||||||
label->setText(m_labels[m_value].c_str() );
|
label->setText(m_labels[m_value].c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ void SpinnerWidget::add()
|
|||||||
m_children[2].m_id = m_children[2].m_element->getID();
|
m_children[2].m_id = m_children[2].m_element->getID();
|
||||||
|
|
||||||
// refresh display
|
// refresh display
|
||||||
|
|
||||||
|
|
||||||
setValue(m_value);
|
setValue(m_value);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace irr
|
|||||||
|
|
||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
|
|
||||||
/** \brief A spinner or gauge widget (to select numbers / percentages).
|
/** \brief A spinner or gauge widget (to select numbers / percentages).
|
||||||
* \ingroup widgetsgroup
|
* \ingroup widgetsgroup
|
||||||
*/
|
*/
|
||||||
@ -43,73 +43,73 @@ namespace GUIEngine
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ISpinnerConfirmListener() {}
|
virtual ~ISpinnerConfirmListener() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Invoked when the spinner is selected and "fire" is pressed
|
* \brief Invoked when the spinner is selected and "fire" is pressed
|
||||||
* \return whether to block the event from further processing
|
* \return whether to block the event from further processing
|
||||||
*/
|
*/
|
||||||
virtual EventPropagation onSpinnerConfirmed() = 0;
|
virtual EventPropagation onSpinnerConfirmed() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
ISpinnerConfirmListener* m_listener;
|
ISpinnerConfirmListener* m_listener;
|
||||||
|
|
||||||
int m_value, m_min, m_max;
|
int m_value, m_min, m_max;
|
||||||
|
|
||||||
int m_spinner_widget_player_id;
|
int m_spinner_widget_player_id;
|
||||||
bool m_use_background_color;
|
bool m_use_background_color;
|
||||||
|
|
||||||
/** If each value the spinner can take has an associated text, this vector will be non-empty */
|
/** If each value the spinner can take has an associated text, this vector will be non-empty */
|
||||||
std::vector<irr::core::stringw> m_labels;
|
std::vector<irr::core::stringw> m_labels;
|
||||||
|
|
||||||
/** Whether the value of this spinner is displayed using an icon rather than with a plain label */
|
/** Whether the value of this spinner is displayed using an icon rather than with a plain label */
|
||||||
bool m_graphical;
|
bool m_graphical;
|
||||||
|
|
||||||
/** \brief Whether this widget is a gauge
|
/** \brief Whether this widget is a gauge
|
||||||
* the behaviour is the same but the look is a bit different, instead of displaying a number,
|
* the behaviour is the same but the look is a bit different, instead of displaying a number,
|
||||||
* it displays how close the value is to the maximum by filling a line
|
* it displays how close the value is to the maximum by filling a line
|
||||||
*/
|
*/
|
||||||
bool m_gauge;
|
bool m_gauge;
|
||||||
|
|
||||||
|
|
||||||
/** \brief Whether to wrap back to the first value when going "beyond" the last value */
|
/** \brief Whether to wrap back to the first value when going "beyond" the last value */
|
||||||
bool m_wrap_around;
|
bool m_wrap_around;
|
||||||
|
|
||||||
/** \brief implementing method from base class Widget */
|
/** \brief implementing method from base class Widget */
|
||||||
virtual EventPropagation transmitEvent(Widget* w,
|
virtual EventPropagation transmitEvent(Widget* w,
|
||||||
const std::string& originator,
|
const std::string& originator,
|
||||||
const int playerID);
|
const int playerID);
|
||||||
|
|
||||||
/** \brief implementing method from base class Widget */
|
/** \brief implementing method from base class Widget */
|
||||||
virtual EventPropagation rightPressed(const int playerID);
|
virtual EventPropagation rightPressed(const int playerID);
|
||||||
|
|
||||||
/** \brief implementing method from base class Widget */
|
/** \brief implementing method from base class Widget */
|
||||||
virtual EventPropagation leftPressed(const int playerID);
|
virtual EventPropagation leftPressed(const int playerID);
|
||||||
|
|
||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getWidthNeededAroundLabel() const { return 25; }
|
virtual int getWidthNeededAroundLabel() const { return 25; }
|
||||||
|
|
||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getHeightNeededAroundLabel() const { return 8; }
|
virtual int getHeightNeededAroundLabel() const { return 8; }
|
||||||
|
|
||||||
/** Call only if this spinner is graphical. Returns the current texture to display */
|
/** Call only if this spinner is graphical. Returns the current texture to display */
|
||||||
irr::video::ITexture* getTexture();
|
irr::video::ITexture* getTexture();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
SpinnerWidget(const bool gauge=false);
|
SpinnerWidget(const bool gauge=false);
|
||||||
virtual ~SpinnerWidget() {}
|
virtual ~SpinnerWidget() {}
|
||||||
virtual void move(const int x, const int y, const int w, const int h);
|
virtual void move(const int x, const int y, const int w, const int h);
|
||||||
|
|
||||||
void addLabel(irr::core::stringw label);
|
void addLabel(irr::core::stringw label);
|
||||||
void clearLabels();
|
void clearLabels();
|
||||||
|
|
||||||
// next four functions are for background colour behind playername in multikart screen selection
|
// next four functions are for background colour behind playername in multikart screen selection
|
||||||
void setUseBackgroundColor() {m_use_background_color=true; }
|
void setUseBackgroundColor() {m_use_background_color=true; }
|
||||||
bool getUseBackgroundColor() {return m_use_background_color; }
|
bool getUseBackgroundColor() {return m_use_background_color; }
|
||||||
void setSpinnerWidgetPlayerID(int playerID) {m_spinner_widget_player_id=playerID;}
|
void setSpinnerWidgetPlayerID(int playerID) {m_spinner_widget_player_id=playerID;}
|
||||||
@ -128,26 +128,26 @@ namespace GUIEngine
|
|||||||
* \param new_value the new value that will be become the current value of this spinner.
|
* \param new_value the new value that will be become the current value of this spinner.
|
||||||
*/
|
*/
|
||||||
void setValue(const int new_value);
|
void setValue(const int new_value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief sets the current value of the spinner
|
* \brief sets the current value of the spinner
|
||||||
* \pre the 'new_value' string passed must be the name of an item
|
* \pre the 'new_value' string passed must be the name of an item
|
||||||
* (added through SpinnerWidget::addLabel)in the spinner
|
* (added through SpinnerWidget::addLabel)in the spinner
|
||||||
*/
|
*/
|
||||||
void setValue(irr::core::stringw new_value);
|
void setValue(irr::core::stringw new_value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \return whether this spinner is of "gauge" type
|
* \return whether this spinner is of "gauge" type
|
||||||
*/
|
*/
|
||||||
bool isGauge() const { return m_gauge; }
|
bool isGauge() const { return m_gauge; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief retrieve the current value of the spinner
|
* \brief retrieve the current value of the spinner
|
||||||
* \return the current value of the spinner, in a int form
|
* \return the current value of the spinner, in a int form
|
||||||
*/
|
*/
|
||||||
int getValue() const { return m_value; }
|
int getValue() const { return m_value; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief retrieve the current value of the spinner
|
* \brief retrieve the current value of the spinner
|
||||||
* \return the current value of the spinner, in a string form
|
* \return the current value of the spinner, in a string form
|
||||||
*/
|
*/
|
||||||
@ -165,15 +165,15 @@ namespace GUIEngine
|
|||||||
* \return the minimum value the spinner can take
|
* \return the minimum value the spinner can take
|
||||||
*/
|
*/
|
||||||
int getMin() const { return m_min; }
|
int getMin() const { return m_min; }
|
||||||
|
|
||||||
void setMin(int n) { m_min = n; }
|
void setMin(int n) { m_min = n; }
|
||||||
|
|
||||||
/** Override method from base class Widget */
|
/** Override method from base class Widget */
|
||||||
virtual void setActivated();
|
virtual void setActivated();
|
||||||
|
|
||||||
/** Override method from base class Widget */
|
/** Override method from base class Widget */
|
||||||
virtual void setDeactivated();
|
virtual void setDeactivated();
|
||||||
|
|
||||||
bool isActivated() { return !m_deactivated; }
|
bool isActivated() { return !m_deactivated; }
|
||||||
|
|
||||||
/** Display custom text in spinner */
|
/** Display custom text in spinner */
|
||||||
|
@ -154,7 +154,7 @@ void TextBoxWidget::unfocused(const int playerID, Widget* new_focus)
|
|||||||
assert(playerID == 0); // No support for multiple players in text areas!
|
assert(playerID == 0); // No support for multiple players in text areas!
|
||||||
|
|
||||||
setWithinATextBox(false);
|
setWithinATextBox(false);
|
||||||
|
|
||||||
GUIEngine::getGUIEnv()->removeFocus(m_element);
|
GUIEngine::getGUIEnv()->removeFocus(m_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ namespace GUIEngine
|
|||||||
virtual ~ITextBoxWidgetListener() {}
|
virtual ~ITextBoxWidgetListener() {}
|
||||||
virtual void onTextUpdated() = 0;
|
virtual void onTextUpdated() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief A text field widget.
|
/** \brief A text field widget.
|
||||||
* \ingroup widgetsgroup
|
* \ingroup widgetsgroup
|
||||||
*/
|
*/
|
||||||
class TextBoxWidget : public Widget
|
class TextBoxWidget : public Widget
|
||||||
@ -43,33 +43,33 @@ namespace GUIEngine
|
|||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getWidthNeededAroundLabel() const { return 10; }
|
virtual int getWidthNeededAroundLabel() const { return 10; }
|
||||||
|
|
||||||
/** When inferring widget size from its label length, this method will be called to
|
/** When inferring widget size from its label length, this method will be called to
|
||||||
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
* if/how much space must be added to the raw label's size for the widget to be large enough */
|
||||||
virtual int getHeightNeededAroundLabel() const { return 10; }
|
virtual int getHeightNeededAroundLabel() const { return 10; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
TextBoxWidget();
|
TextBoxWidget();
|
||||||
~TextBoxWidget()
|
~TextBoxWidget()
|
||||||
{
|
{
|
||||||
setWithinATextBox(false);
|
setWithinATextBox(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add();
|
void add();
|
||||||
void addItem(const char* item);
|
void addItem(const char* item);
|
||||||
|
|
||||||
virtual EventPropagation focused(const int playerID);
|
virtual EventPropagation focused(const int playerID);
|
||||||
virtual void unfocused(const int playerID, Widget* new_focus);
|
virtual void unfocused(const int playerID, Widget* new_focus);
|
||||||
|
|
||||||
void addListener(ITextBoxWidgetListener* listener);
|
void addListener(ITextBoxWidgetListener* listener);
|
||||||
void clearListeners();
|
void clearListeners();
|
||||||
|
|
||||||
irr::core::stringw getText() const;
|
irr::core::stringw getText() const;
|
||||||
void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*');
|
void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*');
|
||||||
|
|
||||||
virtual void elementRemoved();
|
virtual void elementRemoved();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ bool Binding::deserialize(irr::io::IrrXMLReader* xml)
|
|||||||
printf("WARNING: IT_STICKMOTION without direction, ignoring.\n");
|
printf("WARNING: IT_STICKMOTION without direction, ignoring.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the action is a stick motion & a range is defined
|
// If the action is a stick motion & a range is defined
|
||||||
if (range_string == NULL)
|
if (range_string == NULL)
|
||||||
{
|
{
|
||||||
@ -79,7 +79,7 @@ bool Binding::deserialize(irr::io::IrrXMLReader* xml)
|
|||||||
{
|
{
|
||||||
m_range = (Input::AxisRange)atoi(range_string);
|
m_range = (Input::AxisRange)atoi(range_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dir = (Input::AxisDirection)atoi(dir_string);
|
m_dir = (Input::AxisDirection)atoi(dir_string);
|
||||||
|
|
||||||
} // if m_type!=stickmotion
|
} // if m_type!=stickmotion
|
||||||
|
@ -168,12 +168,12 @@ void InputManager::handleStaticAction(int key, int value)
|
|||||||
if (UserConfigParams::m_artist_debug_mode && world)
|
if (UserConfigParams::m_artist_debug_mode && world)
|
||||||
{
|
{
|
||||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||||
|
|
||||||
if (control_is_pressed)
|
if (control_is_pressed)
|
||||||
kart->setPowerup(PowerupManager::POWERUP_SWATTER, 10000);
|
kart->setPowerup(PowerupManager::POWERUP_SWATTER, 10000);
|
||||||
else
|
else
|
||||||
kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL, 10000);
|
kart->setPowerup(PowerupManager::POWERUP_RUBBERBALL, 10000);
|
||||||
|
|
||||||
#ifdef FORCE_RESCUE_ON_FIRST_KART
|
#ifdef FORCE_RESCUE_ON_FIRST_KART
|
||||||
// Can be useful for debugging places where the AI gets into
|
// Can be useful for debugging places where the AI gets into
|
||||||
// a rescue loop: rescue, drive, crash, rescue to same place
|
// a rescue loop: rescue, drive, crash, rescue to same place
|
||||||
@ -185,7 +185,7 @@ void InputManager::handleStaticAction(int key, int value)
|
|||||||
if (UserConfigParams::m_artist_debug_mode && world)
|
if (UserConfigParams::m_artist_debug_mode && world)
|
||||||
{
|
{
|
||||||
AbstractKart* kart = world->getLocalPlayerKart(0);
|
AbstractKart* kart = world->getLocalPlayerKart(0);
|
||||||
|
|
||||||
kart->setPowerup(PowerupManager::POWERUP_PLUNGER, 10000);
|
kart->setPowerup(PowerupManager::POWERUP_PLUNGER, 10000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -481,13 +481,13 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
|
|||||||
m_mode == INPUT_SENSE_GAMEPAD)
|
m_mode == INPUT_SENSE_GAMEPAD)
|
||||||
{
|
{
|
||||||
// Do not pick disabled gamepads for input sensing
|
// Do not pick disabled gamepads for input sensing
|
||||||
if (type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION)
|
if (type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION)
|
||||||
{
|
{
|
||||||
GamePadDevice *gPad = m_device_manager->getGamePadFromIrrID(deviceID);
|
GamePadDevice *gPad = m_device_manager->getGamePadFromIrrID(deviceID);
|
||||||
DeviceConfig *conf = gPad->getConfiguration();
|
DeviceConfig *conf = gPad->getConfiguration();
|
||||||
if (!conf->isEnabled())
|
if (!conf->isEnabled())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inputSensing(type, deviceID, button, axisDirection, value);
|
inputSensing(type, deviceID, button, axisDirection, value);
|
||||||
return;
|
return;
|
||||||
|
@ -25,12 +25,12 @@ using namespace irr;
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
UTFWriter::UTFWriter(const char* dest)
|
UTFWriter::UTFWriter(const char* dest)
|
||||||
: m_base(dest, std::ios::out | std::ios::binary)
|
: m_base(dest, std::ios::out | std::ios::binary)
|
||||||
{
|
{
|
||||||
if (!m_base.is_open())
|
if (!m_base.is_open())
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Failed to open file for writing : " +
|
throw std::runtime_error("Failed to open file for writing : " +
|
||||||
std::string(dest));
|
std::string(dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ XMLNode::XMLNode(const std::string &filename)
|
|||||||
m_file_name = filename;
|
m_file_name = filename;
|
||||||
|
|
||||||
io::IXMLReader *xml = file_manager->createXMLReader(filename);
|
io::IXMLReader *xml = file_manager->createXMLReader(filename);
|
||||||
|
|
||||||
if (xml == NULL)
|
if (xml == NULL)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Cannot find file "+filename);
|
throw std::runtime_error("Cannot find file "+filename);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "karts/explosion_animation.hpp"
|
#include "karts/explosion_animation.hpp"
|
||||||
#include "karts/kart_properties.hpp"
|
#include "karts/kart_properties.hpp"
|
||||||
#include "modes/three_strikes_battle.hpp"
|
#include "modes/three_strikes_battle.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "physics/triangle_mesh.hpp"
|
#include "physics/triangle_mesh.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
#include "physics/triangle_mesh.hpp"
|
#include "physics/triangle_mesh.hpp"
|
||||||
@ -81,7 +81,7 @@ Attachment::~Attachment()
|
|||||||
sfx_manager->deleteSFX(m_bomb_sound);
|
sfx_manager->deleteSFX(m_bomb_sound);
|
||||||
m_bomb_sound = NULL;
|
m_bomb_sound = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_bubble_explode_sound)
|
if (m_bubble_explode_sound)
|
||||||
{
|
{
|
||||||
sfx_manager->deleteSFX(m_bubble_explode_sound);
|
sfx_manager->deleteSFX(m_bubble_explode_sound);
|
||||||
@ -123,7 +123,7 @@ void Attachment::set(AttachmentType type, float time,
|
|||||||
|
|
||||||
clear();
|
clear();
|
||||||
m_node_scale = 0.3f;
|
m_node_scale = 0.3f;
|
||||||
|
|
||||||
// If necessary create the appropriate plugin which encapsulates
|
// If necessary create the appropriate plugin which encapsulates
|
||||||
// the associated behavior
|
// the associated behavior
|
||||||
switch(type)
|
switch(type)
|
||||||
@ -323,7 +323,7 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
|||||||
void Attachment::handleCollisionWithKart(AbstractKart *other)
|
void Attachment::handleCollisionWithKart(AbstractKart *other)
|
||||||
{
|
{
|
||||||
Attachment *attachment_other=other->getAttachment();
|
Attachment *attachment_other=other->getAttachment();
|
||||||
|
|
||||||
if(getType()==Attachment::ATTACH_BOMB)
|
if(getType()==Attachment::ATTACH_BOMB)
|
||||||
{
|
{
|
||||||
// Don't attach a bomb when the kart is shielded
|
// Don't attach a bomb when the kart is shielded
|
||||||
@ -380,15 +380,15 @@ void Attachment::update(float dt)
|
|||||||
{
|
{
|
||||||
if(m_type==ATTACH_NOTHING) return;
|
if(m_type==ATTACH_NOTHING) return;
|
||||||
m_time_left -=dt;
|
m_time_left -=dt;
|
||||||
|
|
||||||
|
|
||||||
bool is_shield = (m_type == ATTACH_BUBBLEGUM_SHIELD|| m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD);
|
bool is_shield = (m_type == ATTACH_BUBBLEGUM_SHIELD|| m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD);
|
||||||
float m_wanted_node_scale = is_shield ? std::max(1.0f, m_kart->getHighestPoint()*1.1f) : 1.0f;
|
float m_wanted_node_scale = is_shield ? std::max(1.0f, m_kart->getHighestPoint()*1.1f) : 1.0f;
|
||||||
|
|
||||||
if (m_node_scale < m_wanted_node_scale)
|
if (m_node_scale < m_wanted_node_scale)
|
||||||
{
|
{
|
||||||
m_node_scale += dt*1.5f;
|
m_node_scale += dt*1.5f;
|
||||||
if (m_node_scale > m_wanted_node_scale) m_node_scale = m_wanted_node_scale;
|
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));
|
m_node->setScale(core::vector3df(m_node_scale,m_node_scale,m_node_scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ void Attachment::update(float dt)
|
|||||||
if (f > 1.0f) f = 1.0f; // cap fraction
|
if (f > 1.0f) f = 1.0f; // cap fraction
|
||||||
if (m_kart->getSpeed() <= m_initial_speed *
|
if (m_kart->getSpeed() <= m_initial_speed *
|
||||||
(stk_config->m_parachute_lbound_fraction +
|
(stk_config->m_parachute_lbound_fraction +
|
||||||
f * ( stk_config->m_parachute_ubound_fraction
|
f * ( stk_config->m_parachute_ubound_fraction
|
||||||
- stk_config->m_parachute_lbound_fraction)))
|
- stk_config->m_parachute_lbound_fraction)))
|
||||||
{
|
{
|
||||||
m_time_left = -1;
|
m_time_left = -1;
|
||||||
@ -471,7 +471,7 @@ void Attachment::update(float dt)
|
|||||||
m_bubble_explode_sound = sfx_manager->createSoundSource("bubblegum_explode");
|
m_bubble_explode_sound = sfx_manager->createSoundSource("bubblegum_explode");
|
||||||
m_bubble_explode_sound->position(m_kart->getXYZ());
|
m_bubble_explode_sound->position(m_kart->getXYZ());
|
||||||
m_bubble_explode_sound->play();
|
m_bubble_explode_sound->play();
|
||||||
|
|
||||||
// drop a small bubble gum
|
// drop a small bubble gum
|
||||||
Vec3 hit_point;
|
Vec3 hit_point;
|
||||||
Vec3 normal;
|
Vec3 normal;
|
||||||
@ -488,7 +488,7 @@ void Attachment::update(float dt)
|
|||||||
normal.normalize();
|
normal.normalize();
|
||||||
|
|
||||||
pos.setY(hit_point.getY()-0.05f);
|
pos.setY(hit_point.getY()-0.05f);
|
||||||
|
|
||||||
ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_kart);
|
ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_kart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ private:
|
|||||||
|
|
||||||
/** Soung for exploding bubble gum shield */
|
/** Soung for exploding bubble gum shield */
|
||||||
SFXBase *m_bubble_explode_sound;
|
SFXBase *m_bubble_explode_sound;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Attachment(AbstractKart* kart);
|
Attachment(AbstractKart* kart);
|
||||||
~Attachment();
|
~Attachment();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// Copyright (C) 2007-2013 Joerg Henrichs
|
// Copyright (C) 2007-2013 Joerg Henrichs
|
||||||
//
|
//
|
||||||
// Linear item-kart intersection function written by
|
// Linear item-kart intersection function written by
|
||||||
// Copyright (C) 2009-2013 David Mikos.
|
// Copyright (C) 2009-2013 David Mikos.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License
|
// modify it under the terms of the GNU General Public License
|
||||||
|
@ -67,7 +67,7 @@ void ItemManager::destroy()
|
|||||||
void ItemManager::loadDefaultItemMeshes()
|
void ItemManager::loadDefaultItemMeshes()
|
||||||
{
|
{
|
||||||
m_item_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL);
|
m_item_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL);
|
||||||
m_glow_color.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1,
|
m_glow_color.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1,
|
||||||
video::SColorf(255.0f, 255.0f, 255.0f) );
|
video::SColorf(255.0f, 255.0f, 255.0f) );
|
||||||
|
|
||||||
m_item_lowres_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL);
|
m_item_lowres_mesh.resize(Item::ITEM_LAST-Item::ITEM_FIRST+1, NULL);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// Copyright (C) 2007-2013 Joerg Henrichs
|
// Copyright (C) 2007-2013 Joerg Henrichs
|
||||||
//
|
//
|
||||||
// Physics improvements and linear intersection algorithm by
|
// Physics improvements and linear intersection algorithm by
|
||||||
// Copyright (C) 2009-2013 David Mikos.
|
// Copyright (C) 2009-2013 David Mikos.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License
|
// modify it under the terms of the GNU General Public License
|
||||||
@ -158,7 +158,7 @@ bool Plunger::updateAndDelete(float dt)
|
|||||||
bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
|
bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
|
||||||
{
|
{
|
||||||
if(isOwnerImmunity(kart)) return false;
|
if(isOwnerImmunity(kart)) return false;
|
||||||
|
|
||||||
// pulling back makes no sense in battle mode, since this mode is not a race.
|
// pulling back makes no sense in battle mode, since this mode is not a race.
|
||||||
// so in battle mode, always hide view
|
// so in battle mode, always hide view
|
||||||
if( m_reverse_mode || race_manager->isBattleMode() )
|
if( m_reverse_mode || race_manager->isBattleMode() )
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// Copyright (C) 2007-2013 Joerg Henrichs
|
// Copyright (C) 2007-2013 Joerg Henrichs
|
||||||
//
|
//
|
||||||
// Physics improvements and linear intersection algorithm by
|
// Physics improvements and linear intersection algorithm by
|
||||||
// Copyright (C) 2009-2013 David Mikos.
|
// Copyright (C) 2009-2013 David Mikos.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of the GNU General Public License
|
// modify it under the terms of the GNU General Public License
|
||||||
|
@ -109,7 +109,7 @@ void ProjectileManager::updateServer(float dt)
|
|||||||
else
|
else
|
||||||
p++;
|
p++;
|
||||||
} // while p!=m_active_projectiles.end()
|
} // while p!=m_active_projectiles.end()
|
||||||
|
|
||||||
} // updateServer
|
} // updateServer
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -473,7 +473,7 @@ void RubberBall::interpolate(Vec3 *next_xyz, float dt)
|
|||||||
+4*m_control_points[2] - m_control_points[3])*m_t*m_t
|
+4*m_control_points[2] - m_control_points[3])*m_t*m_t
|
||||||
+ (- m_control_points[0] + m_control_points[2])*m_t
|
+ (- m_control_points[0] + m_control_points[2])*m_t
|
||||||
+ 2*m_control_points[1] );
|
+ 2*m_control_points[1] );
|
||||||
|
|
||||||
assert(!isnan((*next_xyz)[0]));
|
assert(!isnan((*next_xyz)[0]));
|
||||||
assert(!isnan((*next_xyz)[1]));
|
assert(!isnan((*next_xyz)[1]));
|
||||||
assert(!isnan((*next_xyz)[2]));
|
assert(!isnan((*next_xyz)[2]));
|
||||||
|
@ -69,9 +69,9 @@ protected:
|
|||||||
/** Which of the successors of a node was selected by the AI. */
|
/** Which of the successors of a node was selected by the AI. */
|
||||||
std::vector<int> m_successor_index;
|
std::vector<int> m_successor_index;
|
||||||
/** For each node in the graph this list contains the chosen next node.
|
/** For each node in the graph this list contains the chosen next node.
|
||||||
* For normal lap track without branches we always have
|
* For normal lap track without branches we always have
|
||||||
* m_next_node_index[i] = (i+1) % size;
|
* m_next_node_index[i] = (i+1) % size;
|
||||||
* but if a branch is possible, the AI will select one option here.
|
* but if a branch is possible, the AI will select one option here.
|
||||||
* If the node is not used, m_next_node_index will be -1. */
|
* If the node is not used, m_next_node_index will be -1. */
|
||||||
std::vector<int> m_next_node_index;
|
std::vector<int> m_next_node_index;
|
||||||
/** For each graph node this list contains a list of the next X
|
/** For each graph node this list contains a list of the next X
|
||||||
|
@ -44,7 +44,7 @@ class EndController : public AIBaseController
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/** Stores the type of the previous controller. This is necessary so that
|
/** Stores the type of the previous controller. This is necessary so that
|
||||||
* after the end of race ths kart (and its results) can still be
|
* after the end of race ths kart (and its results) can still be
|
||||||
* identified to be from a player kart. */
|
* identified to be from a player kart. */
|
||||||
bool m_was_player_controller;
|
bool m_was_player_controller;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ private:
|
|||||||
float m_max_handicap_accel; //The allowed maximum speed, in percentage,
|
float m_max_handicap_accel; //The allowed maximum speed, in percentage,
|
||||||
//from 0.0 to 1.0. Used only when
|
//from 0.0 to 1.0. Used only when
|
||||||
//m_wait_for_players == true.
|
//m_wait_for_players == true.
|
||||||
|
|
||||||
/*General purpose variables*/
|
/*General purpose variables*/
|
||||||
//The crash percentage is how much of the time the AI has been crashing,
|
//The crash percentage is how much of the time the AI has been crashing,
|
||||||
//if the AI has been crashing for some time, use the rescue.
|
//if the AI has been crashing for some time, use the rescue.
|
||||||
@ -66,7 +66,7 @@ private:
|
|||||||
/** Stores a pointer to the original controller. */
|
/** Stores a pointer to the original controller. */
|
||||||
Controller *m_previous_controller;
|
Controller *m_previous_controller;
|
||||||
|
|
||||||
/** For debugging purpose: a sphere indicating where the AI
|
/** For debugging purpose: a sphere indicating where the AI
|
||||||
* is targeting at. */
|
* is targeting at. */
|
||||||
irr::scene::ISceneNode *m_debug_sphere;
|
irr::scene::ISceneNode *m_debug_sphere;
|
||||||
|
|
||||||
@ -81,13 +81,13 @@ private:
|
|||||||
void findNonCrashingPoint(Vec3 *result);
|
void findNonCrashingPoint(Vec3 *result);
|
||||||
int calcSteps();
|
int calcSteps();
|
||||||
public:
|
public:
|
||||||
EndController(AbstractKart *kart,
|
EndController(AbstractKart *kart,
|
||||||
StateManager::ActivePlayer* player,
|
StateManager::ActivePlayer* player,
|
||||||
Controller *prev_controller);
|
Controller *prev_controller);
|
||||||
~EndController();
|
~EndController();
|
||||||
virtual void update (float delta) ;
|
virtual void update (float delta) ;
|
||||||
virtual void reset ();
|
virtual void reset ();
|
||||||
/** Returns if the original controller of the kart was a player
|
/** Returns if the original controller of the kart was a player
|
||||||
* controller. This way e.g. highscores can still be assigned
|
* controller. This way e.g. highscores can still be assigned
|
||||||
* to the right player. */
|
* to the right player. */
|
||||||
virtual bool isPlayerController () const {return m_player!=NULL;}
|
virtual bool isPlayerController () const {return m_player!=NULL;}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define HEADER_KART_CONTROL_HPP
|
#define HEADER_KART_CONTROL_HPP
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup controller
|
* \ingroup controller
|
||||||
*/
|
*/
|
||||||
class KartControl
|
class KartControl
|
||||||
@ -37,13 +37,13 @@ public:
|
|||||||
/** The skidding control state: SC_NONE: not pressed;
|
/** The skidding control state: SC_NONE: not pressed;
|
||||||
SC_NO_DIRECTION: pressed, but no steering;
|
SC_NO_DIRECTION: pressed, but no steering;
|
||||||
SC_LEFT/RIGHT: pressed in the specified direction. */
|
SC_LEFT/RIGHT: pressed in the specified direction. */
|
||||||
enum SkidControl {SC_NONE, SC_NO_DIRECTION, SC_LEFT, SC_RIGHT}
|
enum SkidControl {SC_NONE, SC_NO_DIRECTION, SC_LEFT, SC_RIGHT}
|
||||||
m_skid;
|
m_skid;
|
||||||
/** True if rescue is selected. */
|
/** True if rescue is selected. */
|
||||||
bool m_rescue;
|
bool m_rescue;
|
||||||
/** True if fire is selected. */
|
/** True if fire is selected. */
|
||||||
bool m_fire;
|
bool m_fire;
|
||||||
/** True if the kart looks (and shoots) backwards. */
|
/** True if the kart looks (and shoots) backwards. */
|
||||||
bool m_look_back;
|
bool m_look_back;
|
||||||
|
|
||||||
KartControl()
|
KartControl()
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Resets all controls. */
|
/** Resets all controls. */
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
m_steer = 0.0f;
|
m_steer = 0.0f;
|
||||||
m_accel = 0.0f;
|
m_accel = 0.0f;
|
||||||
@ -66,7 +66,7 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void uncompress(char *c)
|
void uncompress(char *c)
|
||||||
{
|
{
|
||||||
m_steer = ((float*)c)[0];
|
m_steer = ((float*)c)[0];
|
||||||
m_accel = ((float*)c)[1];
|
m_accel = ((float*)c)[1];
|
||||||
setButtonsCompressed(c[8]);
|
setButtonsCompressed(c[8]);
|
||||||
} // uncompress
|
} // uncompress
|
||||||
|
@ -55,7 +55,7 @@ private:
|
|||||||
|
|
||||||
void steer(float, int);
|
void steer(float, int);
|
||||||
public:
|
public:
|
||||||
PlayerController (AbstractKart *kart,
|
PlayerController (AbstractKart *kart,
|
||||||
StateManager::ActivePlayer *_player,
|
StateManager::ActivePlayer *_player,
|
||||||
unsigned int player_index);
|
unsigned int player_index);
|
||||||
~PlayerController ();
|
~PlayerController ();
|
||||||
|
@ -1223,12 +1223,12 @@ void SkiddingAI::handleItems(const float dt)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this kart is in its last lap, drop bubble gums at every
|
// If this kart is in its last lap, drop bubble gums at every
|
||||||
// opportunity, since this kart won't envounter them anymore.
|
// opportunity, since this kart won't envounter them anymore.
|
||||||
LinearWorld *lin_world = dynamic_cast<LinearWorld*>(World::getWorld());
|
LinearWorld *lin_world = dynamic_cast<LinearWorld*>(World::getWorld());
|
||||||
if(m_time_since_last_shot > 3.0f &&
|
if(m_time_since_last_shot > 3.0f &&
|
||||||
lin_world &&
|
lin_world &&
|
||||||
lin_world->getKartLaps(m_kart->getWorldKartId())
|
lin_world->getKartLaps(m_kart->getWorldKartId())
|
||||||
== race_manager->getNumLaps()-1)
|
== race_manager->getNumLaps()-1)
|
||||||
{
|
{
|
||||||
m_controls->m_fire = true;
|
m_controls->m_fire = true;
|
||||||
|
@ -40,7 +40,7 @@ namespace irr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief This is the actual racing AI.
|
\brief This is the actual racing AI.
|
||||||
|
|
||||||
The main entry point, called once per frame for each AI, is update().
|
The main entry point, called once per frame for each AI, is update().
|
||||||
@ -49,7 +49,7 @@ the AI does the following steps:
|
|||||||
- compute nearest karts (one ahead and one behind)
|
- compute nearest karts (one ahead and one behind)
|
||||||
- check if the kart is about to crash with another kart or the
|
- check if the kart is about to crash with another kart or the
|
||||||
track. This is done by simply testing a certain number of timesteps
|
track. This is done by simply testing a certain number of timesteps
|
||||||
ahead and estimating the future position of any kart by using
|
ahead and estimating the future position of any kart by using
|
||||||
current_position + velocity * time
|
current_position + velocity * time
|
||||||
(so turns are not taken into account). It also checks if the kart
|
(so turns are not taken into account). It also checks if the kart
|
||||||
would be outside the quad graph, which indicates a 'collision with
|
would be outside the quad graph, which indicates a 'collision with
|
||||||
@ -104,7 +104,7 @@ private:
|
|||||||
void clear() {m_road = false; m_kart = -1;}
|
void clear() {m_road = false; m_kart = -1;}
|
||||||
} m_crashes;
|
} m_crashes;
|
||||||
|
|
||||||
RaceManager::AISuperPower m_superpower;
|
RaceManager::AISuperPower m_superpower;
|
||||||
|
|
||||||
/*General purpose variables*/
|
/*General purpose variables*/
|
||||||
|
|
||||||
@ -123,15 +123,15 @@ private:
|
|||||||
float m_distance_behind;
|
float m_distance_behind;
|
||||||
|
|
||||||
/** The actual start delay used. */
|
/** The actual start delay used. */
|
||||||
float m_start_delay;
|
float m_start_delay;
|
||||||
|
|
||||||
/** Time an item has been collected and not used. */
|
/** Time an item has been collected and not used. */
|
||||||
float m_time_since_last_shot;
|
float m_time_since_last_shot;
|
||||||
|
|
||||||
float m_time_since_stuck;
|
float m_time_since_stuck;
|
||||||
|
|
||||||
/** Direction of crash: -1 = left, 1 = right, 0 = no crash. */
|
/** Direction of crash: -1 = left, 1 = right, 0 = no crash. */
|
||||||
int m_start_kart_crash_direction;
|
int m_start_kart_crash_direction;
|
||||||
|
|
||||||
/** The direction of the track where the kart is on atm. */
|
/** The direction of the track where the kart is on atm. */
|
||||||
GraphNode::DirectionType m_current_track_direction;
|
GraphNode::DirectionType m_current_track_direction;
|
||||||
@ -140,7 +140,7 @@ private:
|
|||||||
* when being on a straigt section. */
|
* when being on a straigt section. */
|
||||||
float m_current_curve_radius;
|
float m_current_curve_radius;
|
||||||
|
|
||||||
/** Stores the center of the curve (if the kart is in a curve,
|
/** Stores the center of the curve (if the kart is in a curve,
|
||||||
* otherwise undefined). */
|
* otherwise undefined). */
|
||||||
Vec3 m_curve_center;
|
Vec3 m_curve_center;
|
||||||
|
|
||||||
@ -185,12 +185,12 @@ private:
|
|||||||
|
|
||||||
/** \brief Determines the algorithm to use to select the point-to-aim-for
|
/** \brief Determines the algorithm to use to select the point-to-aim-for
|
||||||
* There are three different Point Selection Algorithms:
|
* There are three different Point Selection Algorithms:
|
||||||
* 1. findNonCrashingPoint() is the default (which is actually slightly
|
* 1. findNonCrashingPoint() is the default (which is actually slightly
|
||||||
* buggy, but so far best one after handling of 90 degree turns was
|
* buggy, but so far best one after handling of 90 degree turns was
|
||||||
* added).
|
* added).
|
||||||
* 2. findNonCrashingPointFixed() which fixes the bugs of the default
|
* 2. findNonCrashingPointFixed() which fixes the bugs of the default
|
||||||
* algorithm.
|
* algorithm.
|
||||||
* 3. findNonCrashingPointNew() A newly designed algorithm, which is
|
* 3. findNonCrashingPointNew() A newly designed algorithm, which is
|
||||||
* faster than the standard one, but does not give as good results
|
* faster than the standard one, but does not give as good results
|
||||||
* as the 'buggy' one.
|
* as the 'buggy' one.
|
||||||
*
|
*
|
||||||
@ -203,11 +203,11 @@ private:
|
|||||||
/** For skidding debugging: shows the estimated turn shape. */
|
/** For skidding debugging: shows the estimated turn shape. */
|
||||||
ShowCurve **m_curve;
|
ShowCurve **m_curve;
|
||||||
|
|
||||||
/** For debugging purpose: a sphere indicating where the AI
|
/** For debugging purpose: a sphere indicating where the AI
|
||||||
* is targeting at. */
|
* is targeting at. */
|
||||||
irr::scene::ISceneNode *m_debug_sphere[4];
|
irr::scene::ISceneNode *m_debug_sphere[4];
|
||||||
|
|
||||||
/** For item debugging: set to the item that is selected to
|
/** For item debugging: set to the item that is selected to
|
||||||
* be collected. */
|
* be collected. */
|
||||||
irr::scene::ISceneNode *m_item_sphere;
|
irr::scene::ISceneNode *m_item_sphere;
|
||||||
#endif
|
#endif
|
||||||
@ -226,15 +226,15 @@ private:
|
|||||||
void handleBraking();
|
void handleBraking();
|
||||||
void handleNitroAndZipper();
|
void handleNitroAndZipper();
|
||||||
void computeNearestKarts();
|
void computeNearestKarts();
|
||||||
void handleItemCollectionAndAvoidance(Vec3 *aim_point,
|
void handleItemCollectionAndAvoidance(Vec3 *aim_point,
|
||||||
int last_node);
|
int last_node);
|
||||||
bool handleSelectedItem(float kart_aim_angle, Vec3 *aim_point);
|
bool handleSelectedItem(float kart_aim_angle, Vec3 *aim_point);
|
||||||
bool steerToAvoid(const std::vector<const Item *> &items_to_avoid,
|
bool steerToAvoid(const std::vector<const Item *> &items_to_avoid,
|
||||||
const core::line2df &line_to_target,
|
const core::line2df &line_to_target,
|
||||||
Vec3 *aim_point);
|
Vec3 *aim_point);
|
||||||
bool hitBadItemWhenAimAt(const Item *item,
|
bool hitBadItemWhenAimAt(const Item *item,
|
||||||
const std::vector<const Item *> &items_to_avoid);
|
const std::vector<const Item *> &items_to_avoid);
|
||||||
void evaluateItems(const Item *item, float kart_aim_angle,
|
void evaluateItems(const Item *item, float kart_aim_angle,
|
||||||
std::vector<const Item *> *items_to_avoid,
|
std::vector<const Item *> *items_to_avoid,
|
||||||
std::vector<const Item *> *items_to_collect);
|
std::vector<const Item *> *items_to_collect);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ ExplosionAnimation *ExplosionAnimation::create(AbstractKart *kart,
|
|||||||
bool direct_hit)
|
bool direct_hit)
|
||||||
{
|
{
|
||||||
if(kart->isInvulnerable()) return NULL;
|
if(kart->isInvulnerable()) return NULL;
|
||||||
|
|
||||||
float r = kart->getKartProperties()->getExplosionRadius();
|
float r = kart->getKartProperties()->getExplosionRadius();
|
||||||
|
|
||||||
// Ignore explosion that are too far away.
|
// Ignore explosion that are too far away.
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user