This commit is contained in:
Benau
2016-11-18 00:31:48 +08:00
parent b6c1a45918
commit ac74304dd7
6 changed files with 64 additions and 31 deletions

View File

@@ -158,6 +158,7 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
track_x_len = 0;
track_z_len = 0;
texture = 0;
m_reverse = false;
}
ParticleSystemProxy::~ParticleSystemProxy()
@@ -633,3 +634,21 @@ void ParticleSystemProxy::render() {
draw();
}
}
void ParticleSystemProxy::updateAbsolutePosition()
{
if (Parent && m_reverse)
{
core::vector3df old_rot = RelativeRotation;
core::vector3df old_tran = RelativeTranslation;
RelativeRotation.Y += 180.0f;
RelativeTranslation.Z = -RelativeTranslation.Z;
scene::CParticleSystemSceneNode::updateAbsolutePosition();
RelativeRotation = old_rot;
RelativeTranslation = old_tran;
}
else
{
scene::CParticleSystemSceneNode::updateAbsolutePosition();
}
}

View File

@@ -40,9 +40,10 @@ protected:
float m_color_to[3];
bool m_first_execution;
bool m_randomize_initial_y;
bool m_reverse;
GLuint texture;
/** Previous frame particles emitter source matrix */
core::matrix4 m_previous_frame_matrix;
@@ -106,6 +107,8 @@ public:
const float* getColorTo() const { return m_color_to; }
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);
void setFlip();
void setReverse(bool reverse) { m_reverse = reverse; }
virtual void updateAbsolutePosition();
};
#endif // GPUPARTICLES_H

View File

@@ -25,6 +25,9 @@
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/gpu_particles.hpp"
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind.hpp"
#include "input/input_manager.hpp"
#include "items/attachment.hpp"
#include "items/item.hpp"
@@ -39,6 +42,7 @@
#include "network/race_event_manager.hpp"
#include "race/history.hpp"
#include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"
@@ -52,7 +56,8 @@
*/
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player)
: PlayerController(kart)
: PlayerController(kart), m_sky_particles_emitter(NULL),
m_particle_system_proxy(NULL)
{
m_player = player;
if(player)
@@ -67,6 +72,27 @@ LocalPlayerController::LocalPlayerController(AbstractKart *kart,
m_ugh_sound = SFXManager::get()->createSoundSource("ugh");
m_grab_sound = SFXManager::get()->createSoundSource("grab_collectable");
m_full_sound = SFXManager::get()->createSoundSource("energy_bar_full");
// Attach Particle System
Track *track = World::getWorld()->getTrack();
if (UserConfigParams::m_weather_effects &&
track->getSkyParticles() != NULL)
{
track->getSkyParticles()->setBoxSizeXZ(150.0f, 150.0f);
m_sky_particles_emitter =
new ParticleEmitter(track->getSkyParticles(),
core::vector3df(0.0f, 30.0f, 100.0f),
m_kart->getNode(),
true);
// FIXME: in multiplayer mode, this will result in several instances
// of the heightmap being calculated and kept in memory
m_sky_particles_emitter->addHeightMapAffector(track);
m_particle_system_proxy = dynamic_cast<ParticleSystemProxy*>
(m_sky_particles_emitter->getNode());
}
} // LocalPlayerController
//-----------------------------------------------------------------------------
@@ -79,6 +105,8 @@ LocalPlayerController::~LocalPlayerController()
m_ugh_sound ->deleteSFX();
m_grab_sound->deleteSFX();
m_full_sound->deleteSFX();
if (m_sky_particles_emitter)
delete m_sky_particles_emitter;
} // ~LocalPlayerController
//-----------------------------------------------------------------------------
@@ -174,11 +202,17 @@ void LocalPlayerController::update(float dt)
m_kart->getSpeed() < -UserConfigParams::m_reverse_look_threshold))
{
camera->setMode(Camera::CM_REVERSE);
if (m_particle_system_proxy)
m_particle_system_proxy->setReverse(true);
}
else
{
if (camera->getMode() == Camera::CM_REVERSE)
{
camera->setMode(Camera::CM_NORMAL);
if (m_particle_system_proxy)
m_particle_system_proxy->setReverse(false);
}
}
}

View File

@@ -24,7 +24,8 @@
#include "karts/controller/player_controller.hpp"
class AbstractKart;
class Player;
class ParticleEmitter;
class ParticleSystemProxy;
class SFXBase;
/** PlayerKart manages control events from the player and moves
@@ -41,6 +42,9 @@ private:
bool m_sound_schedule;
ParticleEmitter* m_sky_particles_emitter;
ParticleSystemProxy* m_particle_system_proxy;
/** The index of the camera attached to the kart for this controller. The
* camera object is managed in the Camera class, so no need to free it. */

View File

@@ -33,7 +33,6 @@
#include "graphics/irr_driver.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/render_info.hpp"
#include "graphics/shadow.hpp"
@@ -137,7 +136,6 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_controller = NULL;
m_saved_controller = NULL;
m_flying = false;
m_sky_particles_emitter= NULL;
m_stars_effect = NULL;
m_is_jumping = false;
m_min_nitro_time = 0.0f;
@@ -261,7 +259,6 @@ Kart::~Kart()
if(m_previous_terrain_sound) m_previous_terrain_sound->deleteSFX();
if(m_collision_particles) delete m_collision_particles;
if(m_slipstream) delete m_slipstream;
if(m_sky_particles_emitter) delete m_sky_particles_emitter;
if(m_attachment) delete m_attachment;
if(m_stars_effect) delete m_stars_effect;
@@ -2536,28 +2533,6 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
m_attachment = new Attachment(this);
createPhysics();
// Attach Particle System
Track *track = World::getWorld()->getTrack();
if (type == RaceManager::KT_PLAYER &&
UserConfigParams::m_weather_effects &&
track->getSkyParticles() != NULL)
{
track->getSkyParticles()->setBoxSizeXZ(150.0f, 150.0f);
m_sky_particles_emitter =
new ParticleEmitter(track->getSkyParticles(),
core::vector3df(0.0f, 30.0f, 100.0f),
getNode(),
true);
// FIXME: in multiplayer mode, this will result in several instances
// of the heightmap being calculated and kept in memory
m_sky_particles_emitter->addHeightMapAffector(track);
}
Vec3 position(0, getKartHeight()*0.35f, -getKartLength()*0.35f);
m_slipstream = new SlipStream(this);
if (m_kart_properties->getSkidEnabled())

View File

@@ -178,8 +178,6 @@ protected:
/** The shadow of a kart. */
Shadow *m_shadow;
ParticleEmitter *m_sky_particles_emitter;
/** All particle effects. */
KartGFX *m_kart_gfx;