Thursday 3 March 2011

Team Challenge - Big Bang/Little Bang Theory

Half a day into our team challenge we have a field of exploding craters. No pyro effects just yet but Dave built 3 crater sizes for various sizes of explosion and the following model LUA script that generates lighting flashes, plays a 3D audio effect and some rising impact dust. Additional random debris will be added later.

Simply spawn the blast crater model where you want it and this script does the rest.



Effect_explosion_small.lua script

require("scripts/class")
local class=CreateClass(...)

class.bang_loud = LoadSound("abstract::bang_soft.ogg")

--------------------- CREATE AND PLACE MODELS ---------------------

function class:CreateObject(model)

 local object=self.super:CreateObject(model)
 object.rand = math.random(15,25)/1000
 object.timeout = 250
 object.launchtime = AppTime()

 object.crater1 = LoadMesh("abstract::crater_large.gmf")
 object.crater1:SetPosition(object.model:GetPosition(1),1)
 object.crater1:SetScale(Vec3(object.rand,object.rand,object.rand))
--------------------- CORONAS ---------------------

 local flash1=CreateCorona()
 flash1:Paint(LoadMaterial("abstract::flare1.mat"),1)
 SetCoronaRadius(flash1,10,1)
 flash1:SetPosition(object.model:GetPosition(1),1)
 flash1:Movef(0,2,0)
 flash1:SetColor(Vec4(0.8,0.58,0.5,1))

 object.explosion_source = object.model:EmitSound(class.bang_loud,250,1,0)

--------------------- LIGHTS ---------------------

 local light1 = CreatePointLight(20)
 light1:SetPosition(object.model:GetPosition(1),1)
 light1:SetColor(Vec4(1.0,1.0,1.0,1))
 light1:Movef(0,2,0)



--------------------- EMITTERS ---------------------

 smoke=LoadMaterial("abstract::smoke.mat")

 SetWorld(fw.transparency.world)

 local smoke1 = CreateEmitter(10,2000,Vec3(0,2,0),1)
 smoke1:SetPosition(object.model:GetPosition(1),1)
 smoke1:Paint(smoke)
 smoke1:SetColor(Vec4(1,0.85,0.6,1))
 smoke1:SetRadius(1,10*(object.rand*10))
 smoke1:SetWaver(2)
 smoke1:SetArea(Vec3(5,2,5))
 smoke1:SetRotationSpeed(0.1)


 local smoke2 = CreateEmitter(10,1500,Vec3(0,3,0),1)
 smoke2:SetPosition(object.model:GetPosition(1),1)
 smoke2:Paint(smoke)
 smoke2:SetColor(Vec4(0.9,0.7,0.5,1))
 smoke2:SetRadius(1,5*(object.rand*10))
 smoke2:SetWaver(2)
 smoke2:SetArea(Vec3(5,2,5))
 smoke2:SetRotationSpeed(0.01)

 SetWorld(fw.main.world)

--------------------- UPDATE ---------------------

 function object:Update()

  if (AppTime() > object.launchtime + object.timeout) then

   FreeEntity(flash1)
   FreeEntity(light1)
  end

  if (AppTime() > object.launchtime + (object.timeout * 10)) then

   FreeEntity(smoke1)
   FreeEntity(smoke2)
  end

 end

--------------------- FREE ---------------------

 function object.Free()
  FreeEntity(flash1)
  FreeEntity(light1)
  FreeEntity(smoke1)
  FreeEntity(smoke2)
  FreeEntity(object.crater1)
 end

end



I wouldn't recommend saving out a scene with craters then reloading. You can guess what happens. The script would need a flag to say it's 'live' to deal with that.


Muzzle Flash

A universal object that can be attached to any vehicle with a "barrel" child object. Flash duration set to 5ms, but I need to review health and safety guidelines concerning epilepsy and shape it the best I can.



Dave is working on tracers and debris objects now. Ballistics in a network environment can be tricky to handle in multiplayer environments. To make the physics deterministic (ensure that results of  calculations are the same across clients) we're sending source/destination vector, time of launch plus time in flight. The synced game clock should have enough information to create the round across clients in the same position.

Some objects have special cases, such as those having having dual barrels (e.g. ZSUs).

Ballistics will follow a curved path of course using data obtained from the A model Apache Dash 10 Operators Manual. A deterministic scatter pattern will need to be generated across clients for which I think I have a solution. But I'll leave this for a blog entry later in the week.


Visual style and it's origins (no pun intended)

If anyone is interested in origin of the visual style here is the video that sparked it off. It was created by Chris "BeachAV8R" Frishmuth and posted July 2009. Janes F15 III, the last of the great fun combat simulations of that era (IMHO of course).

4 comments:

  1. Blinding Flash when launching missile and during the explosion, that I most missed in all the old simulator :)
    And in general, dynamic lighting.
    It's great looks in the DCS, and gives incredible pleasure to play.

    Btw from what month you count those 18 months? ;)

    ReplyDelete
  2. Project was green-lit September 2009. Which is about 18 months ago. The duration and finances assumed a level of funding to support it and the only reason I agreed to take on a project of this scale (and it IS massive).

    Since you mention it.

    If we had everything we needed from the outset we'd be flying around by now, at least in a beta. Hey ho. To quote GlaDOS, "We do what we must, because we can."

    Our immediate financial problems have just been sorted (just heard about that). Overall, not a bad day so far.

    ReplyDelete
  3. Good to hear :)
    Are these all the scripts will not be encrypted, and everyone will be able to change the parameters of explosions or other things?

    ReplyDelete
  4. Normally you won't be able to access them unless they live in unencrypted packages.

    ReplyDelete