Make red, green and blue of the nearest visible lamp changable
This commit is contained in:
@@ -358,13 +358,13 @@ void IrrDriver::initDevice()
|
||||
|
||||
core::dimension2d<u32> res = core::dimension2du(UserConfigParams::m_width,
|
||||
UserConfigParams::m_height);
|
||||
|
||||
|
||||
if (UserConfigParams::m_fullscreen)
|
||||
{
|
||||
if (modes->getVideoModeCount() > 0)
|
||||
{
|
||||
res = modes->getVideoModeResolution(res, res);
|
||||
|
||||
|
||||
UserConfigParams::m_width = res.Width;
|
||||
UserConfigParams::m_height = res.Height;
|
||||
}
|
||||
@@ -896,7 +896,7 @@ scene::IMesh *IrrDriver::getMesh(const std::string &filename)
|
||||
* joints data.
|
||||
* \param mesh Original mesh
|
||||
* \return Newly created skinned mesh. You should call drop() when you don't
|
||||
* need it anymore.
|
||||
* need it anymore.
|
||||
*/
|
||||
scene::IAnimatedMesh *IrrDriver::copyAnimatedMesh(scene::IAnimatedMesh *orig)
|
||||
{
|
||||
@@ -950,7 +950,7 @@ void IrrDriver::setAllMaterialFlags(scene::IMesh *mesh) const
|
||||
material_manager->setAllUntexturedMaterialFlags(mb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // for i<getMeshBufferCount()
|
||||
} // setAllMaterialFlags
|
||||
|
||||
|
||||
@@ -102,15 +102,15 @@ enum TypeFBO
|
||||
FBO_SCALAR_1024,
|
||||
FBO_BLOOM_512,
|
||||
FBO_TMP_512,
|
||||
FBO_LENS_512,
|
||||
FBO_LENS_512,
|
||||
|
||||
FBO_BLOOM_256,
|
||||
FBO_TMP_256,
|
||||
FBO_LENS_256,
|
||||
|
||||
FBO_TMP_256,
|
||||
FBO_LENS_256,
|
||||
|
||||
FBO_BLOOM_128,
|
||||
FBO_TMP_128,
|
||||
FBO_LENS_128,
|
||||
FBO_LENS_128,
|
||||
FBO_COUNT
|
||||
};
|
||||
|
||||
@@ -164,13 +164,13 @@ enum TypeRTT
|
||||
RTT_SCALAR_1024,
|
||||
RTT_BLOOM_512,
|
||||
RTT_TMP_512,
|
||||
RTT_LENS_512,
|
||||
RTT_LENS_512,
|
||||
RTT_BLOOM_256,
|
||||
RTT_TMP_256,
|
||||
RTT_LENS_256,
|
||||
RTT_LENS_256,
|
||||
RTT_BLOOM_128,
|
||||
RTT_TMP_128,
|
||||
RTT_LENS_128,
|
||||
RTT_LENS_128,
|
||||
|
||||
RTT_COUNT
|
||||
};
|
||||
@@ -626,6 +626,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
u32 getRenderPass() { return m_renderpass; }
|
||||
// ------------------------------------------------------------------------
|
||||
std::vector<LightNode *> getLights() { return m_lights; }
|
||||
// ------------------------------------------------------------------------
|
||||
void addGlowingNode(scene::ISceneNode *n, float r = 1.0f, float g = 1.0f, float b = 1.0f)
|
||||
{
|
||||
GlowData dat;
|
||||
|
||||
@@ -589,7 +589,7 @@ void Kart::createPhysics()
|
||||
const Vec3 &bevel = m_kart_properties->getBevelFactor();
|
||||
Vec3 wheel_pos[4];
|
||||
assert(bevel.getX() || bevel.getY() || bevel.getZ());
|
||||
|
||||
|
||||
Vec3 orig_factor(1, 1, 1 - bevel.getZ());
|
||||
Vec3 bevel_factor(1.0f - bevel.getX(), 1.0f - bevel.getY(), 1.0f);
|
||||
btConvexHullShape *hull = new btConvexHullShape();
|
||||
@@ -1346,7 +1346,7 @@ void Kart::update(float dt)
|
||||
|
||||
// A jump starts only the kart isn't already jumping, is on a new
|
||||
// (or no) texture.
|
||||
if (!m_is_jumping && last_m && last_m != m &&
|
||||
if (!m_is_jumping && last_m && last_m != m &&
|
||||
m_kart_model->getAnimation() == KartModel::AF_DEFAULT)
|
||||
{
|
||||
float v = getVelocity().getY();
|
||||
@@ -1477,7 +1477,7 @@ void Kart::handleMaterialSFX(const Material *material)
|
||||
// In multiplayer mode sounds are NOT positional, because we have
|
||||
// multiple listeners. This would make the sounds of all AIs be
|
||||
// audible at all times. So silence AI karts.
|
||||
if (s.size()!=0 && (race_manager->getNumPlayers()==1 ||
|
||||
if (s.size()!=0 && (race_manager->getNumPlayers()==1 ||
|
||||
m_controller->isPlayerController() ) )
|
||||
{
|
||||
m_terrain_sound = SFXManager::get()->createSoundSource(s);
|
||||
@@ -1899,10 +1899,10 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
|
||||
"to enter this challenge!\n"
|
||||
"Check the minimap for\n"
|
||||
"available challenges.");
|
||||
std::vector<core::stringw> parts =
|
||||
std::vector<core::stringw> parts =
|
||||
StringUtils::split(msg, '\n', false);
|
||||
|
||||
// For now, until we have scripting, special-case
|
||||
// For now, until we have scripting, special-case
|
||||
// the overworld... (TODO)
|
||||
if (dynamic_cast<OverWorld*>(World::getWorld()) != NULL)
|
||||
{
|
||||
@@ -2393,6 +2393,7 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
|
||||
m_nitro_light = irr_driver->addLight(core::vector3df(0.0f, 0.5f, m_kart_model->getLength()*-0.5f - 0.05f),
|
||||
0.6f /* force */, 5.0f /* radius */, 0.0f, 0.4f, 1.0f, false, m_node);
|
||||
m_nitro_light->setVisible(false);
|
||||
m_nitro_light->setName( ("nitro emitter (" + getIdent() + ")").c_str() );
|
||||
|
||||
#ifdef DEBUG
|
||||
m_node->setName( (getIdent()+"(lod-node)").c_str() );
|
||||
@@ -2611,7 +2612,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
float xx = fabsf(m_speed)* getKartProperties()->getDownwardImpulseFactor()*0.0006f;
|
||||
Vec3 center_shift = Vec3(0, m_skidding->getGraphicalJumpOffset()
|
||||
+ lean_height +m_graphical_y_offset+xx, 0);
|
||||
|
||||
|
||||
// Try to prevent the graphical chassis to be inside of the terrain:
|
||||
if(m_kart_properties->getPreventChassisInTerrain())
|
||||
{
|
||||
@@ -2626,14 +2627,14 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
} // for i<num_wheels
|
||||
|
||||
const btWheelInfo &w = getVehicle()->getWheelInfo(0);
|
||||
// Recompute the default average suspension length, see
|
||||
// Recompute the default average suspension length, see
|
||||
// kartIsInRestNow() how to get from y-offset to susp. len.
|
||||
float av_sus_len = -m_graphical_y_offset
|
||||
+ w.m_chassisConnectionPointCS.getY()
|
||||
- w.m_wheelsRadius;
|
||||
|
||||
float delta = av_sus_len - min_susp_len;
|
||||
// If the suspension length is so short, that it is less than the
|
||||
// If the suspension length is so short, that it is less than the
|
||||
// lowest point of the kart, it indicates that the graphical chassis
|
||||
// would be inside of the track:
|
||||
if (delta > m_kart_model->getLowestPoint())
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/light.hpp"
|
||||
#include "items/powerup_manager.hpp"
|
||||
#include "items/attachment.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
@@ -39,6 +40,8 @@
|
||||
#include <IGUIEnvironment.h>
|
||||
#include <IGUIContextMenu.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
using namespace irr;
|
||||
using namespace gui;
|
||||
|
||||
@@ -98,10 +101,11 @@ enum DebugMenuCommand
|
||||
DEBUG_THROTTLE_FPS,
|
||||
DEBUG_VISUAL_VALUES,
|
||||
DEBUG_PRINT_START_POS,
|
||||
DEBUG_LIGHT_SETTINGS,
|
||||
}; // DebugMenuCommand
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Add powerup selected from debug menu for all player karts
|
||||
/** Add powerup selected from debug menu for all player karts */
|
||||
void addPowerup(PowerupManager::PowerupType powerup)
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
@@ -144,8 +148,60 @@ void addAttachment(Attachment::AttachmentType type)
|
||||
|
||||
} // addAttachment
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Computes the distance between two points represented by one vector3df each */
|
||||
float distance(core::vector3df one, core::vector3df two)
|
||||
{
|
||||
return sqrt(pow(one.X - two.X, 2) + pow(one.Y - two.Y, 2) + pow(one.Z- two.Z, 2));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Debug menu handling
|
||||
/** returns the light node with the lowest distance to the player kart (excluding
|
||||
* nitro emitters)
|
||||
*/
|
||||
LightNode* findNearestLight()
|
||||
{
|
||||
World* world = World::getWorld();
|
||||
if (!world) return NULL;
|
||||
|
||||
AbstractKart* player_kart = NULL;
|
||||
for (unsigned int i = 0; i < world->getNumKarts(); i++)
|
||||
{
|
||||
AbstractKart *kart = world->getKart(i);
|
||||
if (kart->getController()->isPlayerController())
|
||||
player_kart = kart;
|
||||
}
|
||||
|
||||
if (!player_kart)
|
||||
{
|
||||
Log::error("Debug", "No player kart found.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
core::vector3df kart_pos = player_kart->getNode()->getAbsolutePosition();
|
||||
LightNode* nearest = 0;
|
||||
float nearest_dist = 1000000.0; // big enough
|
||||
for (unsigned int i = 0; i < irr_driver->getLights().size(); i++)
|
||||
{
|
||||
LightNode* light = irr_driver->getLights()[i];
|
||||
|
||||
// Avoid modifying the nitro emitter or another invisible light
|
||||
if (std::string(light->getName()).find("nitro emitter") == 0 || !light->isVisible())
|
||||
continue;
|
||||
|
||||
core::vector3df light_pos = light->getAbsolutePosition();
|
||||
if ( distance(kart_pos, light_pos) < nearest_dist)
|
||||
{
|
||||
nearest = irr_driver->getLights()[i];
|
||||
nearest_dist = distance(kart_pos, light_pos);
|
||||
}
|
||||
}
|
||||
|
||||
return nearest;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Debug menu handling */
|
||||
bool onEvent(const SEvent &event)
|
||||
{
|
||||
// Only activated in artist debug mode
|
||||
@@ -215,15 +271,16 @@ bool onEvent(const SEvent &event)
|
||||
|
||||
mnu->addItem(L"Adjust values", DEBUG_VISUAL_VALUES);
|
||||
|
||||
mnu->addItem(L"Profiler",DEBUG_PROFILER);
|
||||
mnu->addItem(L"Profiler", DEBUG_PROFILER);
|
||||
if (UserConfigParams::m_profiler_enabled)
|
||||
mnu->addItem(L"Toggle capture profiler report",
|
||||
DEBUG_PROFILER_GENERATE_REPORT);
|
||||
mnu->addItem(L"Do not limit FPS", DEBUG_THROTTLE_FPS);
|
||||
mnu->addItem(L"FPS",DEBUG_FPS);
|
||||
mnu->addItem(L"FPS", DEBUG_FPS);
|
||||
mnu->addItem(L"Save replay", DEBUG_SAVE_REPLAY);
|
||||
mnu->addItem(L"Save history", DEBUG_SAVE_HISTORY);
|
||||
mnu->addItem(L"Print position", DEBUG_PRINT_START_POS);
|
||||
mnu->addItem(L"Debug Light Setting", DEBUG_LIGHT_SETTINGS);
|
||||
|
||||
g_debug_menu_visible = true;
|
||||
irr_driver->showPointer();
|
||||
@@ -507,7 +564,7 @@ bool onEvent(const SEvent &event)
|
||||
{
|
||||
#if !defined(__APPLE__)
|
||||
DebugSliderDialog *dsd = new DebugSliderDialog();
|
||||
dsd->setSliderHook( "red_slider", 0, 255,
|
||||
dsd->setSliderHook("red_slider", 0, 255,
|
||||
[](){ return int(irr_driver->getAmbientLight().r * 255.f); },
|
||||
[](int v){
|
||||
video::SColorf ambient = irr_driver->getAmbientLight();
|
||||
@@ -542,6 +599,46 @@ bool onEvent(const SEvent &event)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
else if (cmdID == DEBUG_LIGHT_SETTINGS)
|
||||
{
|
||||
DebugSliderDialog *dsd = new DebugSliderDialog();
|
||||
dsd->setSliderHook("red_slider", 0, 255,
|
||||
[]()
|
||||
{
|
||||
return findNearestLight()->getColor().X;
|
||||
},
|
||||
[](int intensity)
|
||||
{
|
||||
LightNode* nearest = findNearestLight();
|
||||
core::vector3df color = nearest->getColor();
|
||||
nearest->setColor(intensity, color.Y, color.Z);
|
||||
}
|
||||
);
|
||||
dsd->setSliderHook("green_slider", 0, 255,
|
||||
[]()
|
||||
{
|
||||
return findNearestLight()->getColor().Y;
|
||||
},
|
||||
[](int intensity)
|
||||
{
|
||||
LightNode* nearest = findNearestLight();
|
||||
core::vector3df color = nearest->getColor();
|
||||
nearest->setColor(color.X, intensity, color.Z);
|
||||
}
|
||||
);
|
||||
dsd->setSliderHook("blue_slider", 0, 255,
|
||||
[]()
|
||||
{
|
||||
return findNearestLight()->getColor().Z;
|
||||
},
|
||||
[](int intensity)
|
||||
{
|
||||
LightNode* nearest = findNearestLight();
|
||||
core::vector3df color = nearest->getColor();
|
||||
nearest->setColor(color.X, color.Y, intensity);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return false; // event has been handled
|
||||
|
||||
Reference in New Issue
Block a user