Author Topic: 3d explosions explanation  (Read 11035 times)

Offline Zharik1999

  • Colonel
  • ****
  • Posts: 133
    • View Profile
3d explosions explanation
« on: May 14, 2012, 05:45:29 pm »
Can anyone give me a good explanation about how 3d explosions work? (spread of damage, calculations, that kind of stuff) They seems to be rather unpredictable for me now.

Offline kkmic

  • Commander
  • *****
  • Posts: 582
  • Undefined
    • View Profile
Re: 3d explosions explanation
« Reply #1 on: May 15, 2012, 09:15:42 am »
Now that's something I would like to know too.

IIRC, Daiky implemented 3D explosions.

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: 3d explosions explanation
« Reply #2 on: May 15, 2012, 11:37:08 am »
real explosions aren't always predictable either :p

ok, for 3D explosions, I did not look at how original xcom does explosions, I just made something that I could easely code and understand.

I use raycasting from the center of the explosion outwards, like a point light. Each ray has a starting power, the power reduces by distance and it can be dramatically reduced or even blocked by objects (depending on their HE block value)
When a ray crosses a tile, the objects (and unit) on that tile are affected by the power the ray has at that time. It keeps track of which tiles already have been affected, so they can be skipped if another ray crosses the same tile.
The method is similar for smoke and incendiary explosions.

There are probably things that still can be optimised, but it works and we didn't have any complaints about explosions being slow or unrealistic.

Offline Zharik1999

  • Colonel
  • ****
  • Posts: 133
    • View Profile
Re: 3d explosions explanation
« Reply #3 on: May 15, 2012, 01:39:18 pm »
Thank you that looks rather logic.

Offline Space Voyager

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: 3d explosions explanation
« Reply #4 on: May 31, 2012, 11:25:51 am »
Wow, this looks really cool! So the damage is not limited to a single hight level as in X-COM?

Offline Zharik1999

  • Colonel
  • ****
  • Posts: 133
    • View Profile
Re: 3d explosions explanation
« Reply #5 on: May 31, 2012, 01:41:54 pm »
Yes, and it plays good too :D

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: 3d explosions explanation
« Reply #6 on: May 31, 2012, 10:55:51 pm »
while it looks and plays rather well, I have noticed one thing: if the explosion happens on the outside of a wall (that is, by firing explosive ammo at a wall) above ground level, the explosion only radiates outward-and-down, but not straight down. the squares directly below the center point are completely untouched, as if the explosion actually happened "within" the wall and couldn't go straight down.

is that consistent with your mechanics? is the center point for the raycasting within the wall (that is, between the tiles)? if so, it would probably be best to move it slightly outward, to avoid strange effects like the one described above.

Offline Space Voyager

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: 3d explosions explanation
« Reply #7 on: June 01, 2012, 01:09:50 pm »
Hello Moriarty!

I have to ask, are you the same Moriarty as the one at the SotS forums?  :)

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: 3d explosions explanation
« Reply #8 on: June 01, 2012, 03:03:43 pm »
SotS? no, I don't think so.

I'm guessing you mean this: www.swordofthestars.com/

an not this: www.sots.ac.uk/

but anyway, the answer would be no in both cases :P

Offline Space Voyager

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: 3d explosions explanation
« Reply #9 on: June 01, 2012, 03:10:00 pm »
I meant Sword of the Stars forum, yes. There is also a member with the same nick.

Ah well, sorry for bothering.

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: 3d explosions explanation
« Reply #10 on: June 01, 2012, 03:17:20 pm »
no problem. that looks like an interesting game, though, thank you for pointing me to it... :)