Jump to content

Explosions for my little Game


ParaToxic
 Share

Recommended Posts

Hl2 smg? Haha anyway great work it would be great to see a peek at some of the code... wink.png From my experience with the source engine I'd personally like to see effects work on an per entity basis. So you can layer effects onto anything.

 

EDIT: I am currently looking to make an explosion effect to work with. Can you provide some code basis of how you started?

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

Here is the source of explosion class.It's very basic and I think everybody can edit it to optimize it for your application.

 

(included materials and textures smile.png

Explode.rar

 

Test:

Explode explosion0;
explosion0.CreateExplosions(Vec3(10,10,10),1);
and in the loop
explosion0.Update();

 

Hl2 smg?

 

Why?

  • Upvote 1
Link to comment
Share on other sites

I get an:

 

Unhandled exception at 0x1017eace in Explosion.exe: 0xC0000005: Access violation reading location 0x00000058.

 

Dont know why.

 

 

EDIT: Needed an explosion sound wink.png

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

yes I know this error.Have you created some explosions in the same time?

 

You have to wait for the active variable,because when you create a new explosion in the same time as the other isn't ready (not all emitters are created) you overwrite the old emitters,so the old emitter wouldn't stop.

 

When you create only 1 class ,you have to wait for the "active" variable,than it would work biggrin.png

 

Something like :

 

Explode ex;

loop:
ex.Update();
if(KeyHit(KEY_A) && ex.active == false)
   ex.CreateExplosions(Vec3(2,3,4),1);

Link to comment
Share on other sites

In the Explosion.cpp file (overwrite the other):

else if(Trailtime < 0.1)
{
 for(int i = 0;i < 6;i++)
 PauseEmitter(smoke[i]);
 if(EmitterPaused(smoke[5]))
  active = false;  //The emitter are ready for a new explosions
}

 

 

Now when you check the active state first it works ;D

Link to comment
Share on other sites

As I make a new explosion class with a crysis like explosion right now.

 

Yeah it'd be great to just see that little bit more detail in it.

  • Upvote 1

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

As an aside, when building an FX system for CombatHelo we used SendMessage(....) which can take a delay in microseconds as a parameter. The FX system uses a dummy entity in the scene that works as a mediator (if you know your design patterns).

 

It creates and removes FX objects which might include emitters, sounds, lights, even structure collapse.

 

This example code is part of the structure collapse update method, it's fired when the building object has reached the end of collapsing motion. The message id EFFECT_REMOVE_ENTITY is sent to to the mediator to remove itself after 20000 ms which is enough time for the audio and dust effects to dissipate. Typically the building is replaced with a destroyed version (or pile of rubble) but we don't want the original model too.

 

  game.scene.SendFXMessage(TEntity(fxEntity), EFFECT_REMOVE_ENTITY, fxEntity.position, 0, 0, TEntity(fxEntity), 20000) ;

 

A mediator approach lets you create compound effects made from your own pool of effect code to make many variations. My code ended up being large due to having lots of extended classes to deal with specific kinds of objects. Not just for explosions but also ambient audio effects, triggers and a bunch of other things I need in my game.

 

What it can't do is jump around, once it's been sent to the message queue you can't get at it till it plays.

  • Upvote 1

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

  • 1 month later...

Here is the source of explosion class.It's very basic and I think everybody can edit it to optimize it for your application.

 

(included materials and textures smile.png

Explode.rar

 

Test:

Explode explosion0;
explosion0.CreateExplosions(Vec3(10,10,10),1);
and in the loop
explosion0.Update();

 

 

 

Why?

 

Hello,

 

I'd like to change the dimention of the explosion (smaller) without changing the position z ;-)

 

I tried to put a scale parameter of the radius, but it change the diameter of a particle :-( but not of the explosion.

 

anyone has a solution for me?

 

Thank you in advance

Link to comment
Share on other sites

When you want to make the explosion bigger or smaller in the diameter you have to change the SetEmitterVelocity(Vec3(0,0,0),Vec3(1,1,1)) and (optional) the waver value

 

For Example:

Big Explosion:
SetEmitterWaver(emitter,50.0);
SetEmitterVelocity(Vec3(0,1,0),Vec3(5,0,5)) //When the particles moves very fast you need more particles otherwise the distance between the particles are too big and it looks bad
Small Explosion:
SetEmitterWaver(emitter,5.0);
SetEmitterVelocity(emitter,Vec3(0,1,0),Vec3(1,0,1));

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...