Add more helper function to render info class
This commit is contained in:
parent
bfd66ebbac
commit
f23ec7e7b8
@ -1,5 +1,5 @@
|
||||
# Modify this file to change the last-modified date when you add/remove a file.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
||||
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
||||
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "graphics/2dutils.hpp"
|
||||
#include "graphics/graphics_restrictions.hpp"
|
||||
#include "graphics/light.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/particle_kind_manager.hpp"
|
||||
#include "graphics/per_camera_node.hpp"
|
||||
#include "graphics/post_processing.hpp"
|
||||
|
45
src/graphics/render_info.cpp
Normal file
45
src/graphics/render_info.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2016 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "graphics/render_info.hpp"
|
||||
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
|
||||
#include <ISceneManager.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
RenderInfo::RenderInfo(float hue, float min_saturation, bool transparent)
|
||||
{
|
||||
m_hue = hue;
|
||||
m_min_saturation = min_saturation;
|
||||
m_transparent = transparent;
|
||||
} // RenderInfo
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void RenderInfo::setColorizableParts(irr::scene::IMesh* m)
|
||||
{
|
||||
for (int i = 0; i < int(m->getMeshBufferCount()); i++)
|
||||
{
|
||||
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
||||
Material* material = material_manager->getMaterialFor(mb
|
||||
->getMaterial().getTexture(0), mb);
|
||||
if (material->isColorizable())
|
||||
m_colorizable_parts.push_back(i);
|
||||
}
|
||||
} // setColorizableParts
|
@ -19,13 +19,14 @@
|
||||
#ifndef HEADER_RENDER_INFO_HPP
|
||||
#define HEADER_RENDER_INFO_HPP
|
||||
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
|
||||
#include <ISceneManager.h>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene { class IMesh; }
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup graphics
|
||||
*/
|
||||
@ -51,24 +52,11 @@ private:
|
||||
|
||||
public:
|
||||
RenderInfo(float hue = 0.0f, float min_saturation = 0.0f,
|
||||
bool transparent = false)
|
||||
{
|
||||
m_hue = hue;
|
||||
m_min_saturation = min_saturation;
|
||||
m_transparent = transparent;
|
||||
}
|
||||
bool transparent = false);
|
||||
// ------------------------------------------------------------------------
|
||||
void setColorizableParts(irr::scene::IMesh* m)
|
||||
{
|
||||
for (int i = 0; i < int(m->getMeshBufferCount()); i++)
|
||||
{
|
||||
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
||||
Material* material = material_manager->getMaterialFor(mb
|
||||
->getMaterial().getTexture(0), mb);
|
||||
if (material->isColorizable())
|
||||
m_colorizable_parts.push_back(i);
|
||||
}
|
||||
}
|
||||
~RenderInfo() {}
|
||||
// ------------------------------------------------------------------------
|
||||
void setColorizableParts(irr::scene::IMesh* m);
|
||||
// ------------------------------------------------------------------------
|
||||
void setHue(float hue) { m_hue = hue; }
|
||||
// ------------------------------------------------------------------------
|
||||
@ -100,6 +88,8 @@ public:
|
||||
|
||||
setTransparent(krt == RenderInfo::KRT_TRANSPARENT ? true : false);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void setRenderInfo(const RenderInfo* other) { *this = *other; }
|
||||
|
||||
}; // RenderInfo
|
||||
|
||||
|
@ -105,9 +105,9 @@ namespace GUIEngine
|
||||
|
||||
void setupRTTScene();
|
||||
|
||||
FrameBuffer* getFrameBuffer() { return m_frame_buffer; }
|
||||
video::ITexture* getTexture() { return m_texture; }
|
||||
RenderInfo& getRenderInfo() { return m_render_info; }
|
||||
FrameBuffer* getFrameBuffer() { return m_frame_buffer; }
|
||||
video::ITexture* getTexture() { return m_texture; }
|
||||
RenderInfo& getModelViewRenderInfo() { return m_render_info; }
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -336,6 +336,8 @@ public:
|
||||
core::vector3df getHatOffset() { return m_hat_offset; }
|
||||
// ------------------------------------------------------------------------
|
||||
RenderInfo* getRenderInfo() { return &m_render_info; }
|
||||
// ------------------------------------------------------------------------
|
||||
const RenderInfo* getRenderInfo() const { return &m_render_info; }
|
||||
|
||||
}; // KartModel
|
||||
#endif
|
||||
|
@ -146,9 +146,12 @@ void SoccerSetupScreen::beforeAddingWidget()
|
||||
(i&1 ? SOCCER_TEAM_BLUE : SOCCER_TEAM_RED));
|
||||
|
||||
// addModel requires loading the RenderInfo first
|
||||
kart_view->getRenderInfo().setKartModelRenderInfo(info.team == SOCCER_TEAM_BLUE ?
|
||||
kart_view->getModelViewRenderInfo().setRenderInfo
|
||||
(kart_model.getRenderInfo());
|
||||
|
||||
kart_view->getModelViewRenderInfo().setKartModelRenderInfo
|
||||
(info.team == SOCCER_TEAM_BLUE ?
|
||||
RenderInfo::KRT_BLUE : RenderInfo::KRT_RED);
|
||||
kart_view->getRenderInfo().setColorizableParts(kart_model.getModel());
|
||||
|
||||
// Add the kart model (including wheels and speed weight objects)
|
||||
kart_view->addModel( kart_model.getModel(), Vec3(0,0,0),
|
||||
@ -288,7 +291,7 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
||||
team_switch = SOCCER_TEAM_RED;
|
||||
|
||||
// Change the kart color
|
||||
m_kart_view_info[playerId].view->getRenderInfo()
|
||||
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
||||
.setKartModelRenderInfo(RenderInfo::KRT_RED);
|
||||
|
||||
for(int i=0 ; i < nb_players ; i++)
|
||||
@ -305,7 +308,7 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
||||
team_switch = SOCCER_TEAM_BLUE;
|
||||
|
||||
// Change the kart color
|
||||
m_kart_view_info[playerId].view->getRenderInfo()
|
||||
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
||||
.setKartModelRenderInfo(RenderInfo::KRT_BLUE);
|
||||
|
||||
for(int i=0 ; i < nb_players ; i++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user