Additional smoke textures looking like explosion
This commit is contained in:
parent
ebd8f292e0
commit
063efdde63
@ -3,7 +3,7 @@
|
||||
All paks for development vesion
|
||||
-------------------------------
|
||||
|
||||
http://yvt.jp/files/programs/osppaks/DevPaks26.zip
|
||||
http://yvt.jp/files/programs/osppaks/DevPaks27.zip
|
||||
|
||||
These paks are not included in the source tree because they contains some
|
||||
non-opensource materials and they seem too large to include in the git tree.
|
||||
|
@ -250,8 +250,7 @@ namespace spades {
|
||||
/** Initiate an initialization which likely to take some time */
|
||||
void Client::DoInit() {
|
||||
renderer->Init();
|
||||
// preload
|
||||
SmokeSpriteEntity(this, Vector4(), 20.f);
|
||||
SmokeSpriteEntity::Preload(renderer);
|
||||
|
||||
renderer->RegisterImage("Textures/Fluid.png");
|
||||
renderer->RegisterImage("Textures/WaterExpl.png");
|
||||
|
@ -162,7 +162,8 @@ namespace spades {
|
||||
color = MakeVector4(.7f, .35f, .37f, .6f);
|
||||
for(int i = 0; i < 2; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 100.f);
|
||||
new SmokeSpriteEntity(this, color, 100.f,
|
||||
SmokeSpriteEntity::Type::Explosion);
|
||||
ent->SetTrajectory(v,
|
||||
MakeVector3(GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom(),
|
||||
@ -175,6 +176,26 @@ namespace spades {
|
||||
ent->SetLifeTime(.20f + GetRandom() * .2f, 0.06f, .20f);
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
|
||||
if(cg_reduceSmoke)
|
||||
return;
|
||||
color.w *= .3f;
|
||||
for(int i = 0; i < 1; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 40.f,
|
||||
SmokeSpriteEntity::Type::Steady);
|
||||
ent->SetTrajectory(v,
|
||||
MakeVector3(GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom()) * .7f,
|
||||
.8f, 0.f);
|
||||
ent->SetRotation(GetRandom() * (float)M_PI * 2.f);
|
||||
ent->SetRadius(.7f + GetRandom()*GetRandom()*0.2f,
|
||||
1.f, 0.5f);
|
||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||
ent->SetLifeTime(.80f + GetRandom() * 0.4f, 0.06f, 1.0f);
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::EmitBlockFragments(Vector3 origin,
|
||||
@ -292,15 +313,16 @@ namespace spades {
|
||||
// rapid smoke
|
||||
for(int i = 0; i < 2; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 120.f);
|
||||
new SmokeSpriteEntity(this, color, 120.f,
|
||||
SmokeSpriteEntity::Type::Explosion);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom())+velBias*.5f) * 0.3f,
|
||||
1.f, 0.f);
|
||||
ent->SetRotation(GetRandom() * (float)M_PI * 2.f);
|
||||
ent->SetRadius(.2f,
|
||||
7.f, 0.0000005f);
|
||||
ent->SetRadius(.4f,
|
||||
3.f, 0.0000005f);
|
||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||
ent->SetLifeTime(0.2f + GetRandom()*0.1f, 0.f, .30f);
|
||||
localEntities.emplace_back(ent);
|
||||
@ -346,26 +368,27 @@ namespace spades {
|
||||
}
|
||||
|
||||
Vector4 color;
|
||||
color = MakeVector4( .8f, .8f, .8f, .6f);
|
||||
color = MakeVector4( .6f, .6f, .6f, 1.f);
|
||||
// rapid smoke
|
||||
for(int i = 0; i < 4; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 60.f);
|
||||
new SmokeSpriteEntity(this, color, 60.f,
|
||||
SmokeSpriteEntity::Type::Explosion);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom())+velBias*.5f) * 4.f,
|
||||
GetRandom()-GetRandom())+velBias*.5f) * 2.f,
|
||||
1.f, 0.f);
|
||||
ent->SetRotation(GetRandom() * (float)M_PI * 2.f);
|
||||
ent->SetRadius(1.f + GetRandom()*GetRandom()*0.4f,
|
||||
10.f);
|
||||
ent->SetRadius(.6f + GetRandom()*GetRandom()*0.4f,
|
||||
2.f, .2f);
|
||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||
ent->SetLifeTime(.1f + GetRandom()*0.02f, 0.f, .10f);
|
||||
ent->SetLifeTime(1.8f + GetRandom()*0.1f, 0.f, .20f);
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
|
||||
// slow smoke
|
||||
color.w = .15f;
|
||||
color.w = .25f;
|
||||
for(int i = 0; i < 8; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 20.f);
|
||||
@ -375,13 +398,13 @@ namespace spades {
|
||||
(GetRandom()-GetRandom()) * .2f)) * 2.f,
|
||||
1.f, 0.f);
|
||||
ent->SetRotation(GetRandom() * (float)M_PI * 2.f);
|
||||
ent->SetRadius(1.4f + GetRandom()*GetRandom()*0.8f,
|
||||
ent->SetRadius(1.5f + GetRandom()*GetRandom()*0.8f,
|
||||
0.2f);
|
||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||
if(cg_reduceSmoke)
|
||||
ent->SetLifeTime(1.f + GetRandom() * 2.f, 0.1f, 8.f);
|
||||
else
|
||||
ent->SetLifeTime(4.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||
ent->SetLifeTime(2.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
|
||||
@ -407,21 +430,22 @@ namespace spades {
|
||||
}
|
||||
|
||||
// fire smoke
|
||||
color= MakeVector4(1.f, .6f, .2f, 1.f);
|
||||
color= MakeVector4(1.f, .7f, .4f, .2f) * 5.f;
|
||||
for(int i = 0; i < 4; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 60.f);
|
||||
new SmokeSpriteEntity(this, color, 120.f,
|
||||
SmokeSpriteEntity::Type::Explosion);
|
||||
ent->SetTrajectory(origin,
|
||||
(MakeVector3(GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom(),
|
||||
GetRandom()-GetRandom())+velBias) * 12.f,
|
||||
GetRandom()-GetRandom())+velBias) * 6.f,
|
||||
1.f, 0.f);
|
||||
ent->SetRotation(GetRandom() * (float)M_PI * 2.f);
|
||||
ent->SetRadius(1.f + GetRandom()*GetRandom()*0.4f,
|
||||
6.f);
|
||||
ent->SetRadius(.3f + GetRandom()*GetRandom()*0.4f,
|
||||
3.f, .1f);
|
||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||
ent->SetLifeTime(.08f + GetRandom()*0.03f, 0.f, .10f);
|
||||
ent->SetAdditive(true);
|
||||
ent->SetLifeTime(.18f + GetRandom()*0.03f, 0.f, .10f);
|
||||
//ent->SetAdditive(true);
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ namespace spades{
|
||||
namespace client{
|
||||
static IRenderer *lastRenderer = NULL;
|
||||
static IImage *lastSeq[180];
|
||||
static IImage *lastSeq2[48];
|
||||
|
||||
// FIXME: add "image manager"?
|
||||
static void Load(IRenderer *r) {
|
||||
@ -36,32 +37,56 @@ namespace spades{
|
||||
|
||||
for(int i = 0; i < 180; i++){
|
||||
char buf[256];
|
||||
sprintf(buf, "Textures/Smoke/%03d.tga", i);
|
||||
sprintf(buf, "Textures/Smoke1/%03d.png", i);
|
||||
lastSeq[i] = r->RegisterImage(buf);
|
||||
}
|
||||
for(int i = 0; i < 48; i++){
|
||||
char buf[256];
|
||||
sprintf(buf, "Textures/Smoke2/%03d.png", i);
|
||||
lastSeq2[i] = r->RegisterImage(buf);
|
||||
}
|
||||
|
||||
lastRenderer = r;
|
||||
}
|
||||
|
||||
static IImage *GetSequence(int i, IRenderer *r){
|
||||
IImage *SmokeSpriteEntity::GetSequence(int i, IRenderer *r,
|
||||
Type type){
|
||||
Load(r);
|
||||
return lastSeq[i];
|
||||
if(type == Type::Steady) {
|
||||
SPAssert(fId >= 0 && fId < 180);
|
||||
return lastSeq[i];
|
||||
} else {
|
||||
SPAssert(fId >= 0 && fId < 48);
|
||||
return lastSeq2[i];
|
||||
}
|
||||
}
|
||||
|
||||
SmokeSpriteEntity::SmokeSpriteEntity(Client *c,
|
||||
Vector4 color,
|
||||
float fps):
|
||||
ParticleSpriteEntity(c, GetSequence(0, c->GetRenderer()), color), fps(fps){
|
||||
float fps,
|
||||
Type type):
|
||||
ParticleSpriteEntity(c, GetSequence(0, c->GetRenderer(), type), color), fps(fps),
|
||||
type(type){
|
||||
frame = 0.f;
|
||||
}
|
||||
|
||||
void SmokeSpriteEntity::Preload(IRenderer *r) {
|
||||
Load(r);
|
||||
}
|
||||
|
||||
bool SmokeSpriteEntity::Update(float dt) {
|
||||
frame += dt * fps;
|
||||
frame = fmodf(frame, 180.f);
|
||||
if(type == Type::Steady) {
|
||||
frame = fmodf(frame, 180.f);
|
||||
} else {
|
||||
if(frame > 47.f) {
|
||||
frame = 47.f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int fId = (int)floorf(frame);
|
||||
SPAssert(fId >= 0 && fId < 180);
|
||||
SetImage(GetSequence(fId, GetRenderer()));
|
||||
SetImage(GetSequence(fId, GetRenderer(), type));
|
||||
|
||||
return ParticleSpriteEntity::Update(dt);
|
||||
}
|
||||
|
@ -24,12 +24,26 @@
|
||||
|
||||
namespace spades{
|
||||
namespace client{
|
||||
class IImage;
|
||||
class IRenderer;
|
||||
class SmokeSpriteEntity: public ParticleSpriteEntity{
|
||||
public:
|
||||
enum class Type {
|
||||
Steady,
|
||||
Explosion
|
||||
};
|
||||
private:
|
||||
float frame;
|
||||
float fps;
|
||||
Type type;
|
||||
static IImage *GetSequence(int i, IRenderer *r, Type);
|
||||
public:
|
||||
|
||||
SmokeSpriteEntity(Client *cli, Vector4 color,
|
||||
float fps);
|
||||
float fps, Type type = Type::Steady);
|
||||
|
||||
static void Preload(IRenderer *);
|
||||
|
||||
virtual bool Update(float dt);
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user