Jump to content
Sign in to follow this  
granQ

House, partial destruction

Recommended Posts

So we got a nice island (many thanks to Old Bear), and its filled with custom made houses.. but no fun in blasting them if we can't destroy one wall at a time.

Any tutorial how this is made.. or example .p3d?

Share this post


Link to post
Share on other sites

I'd imagine you'd do it the same way we get destroyable wheels and windows on vehicles: model.cfg animation to hide parts of the wall using the 'class hitpoints' based animation source. Possibly unhiding a proxy of the rubble at the bottom of the building.

Along the lines of this:

http://forums.bistudio.com/showthread.php?t=95087

Share this post


Link to post
Share on other sites

afaik they use different p3ds for the different damage states

Share this post


Link to post
Share on other sites

yeah, i digged up the config for a house which gave me understanding of most of it.

Still would be sweet with a bis house just to see the "standard level", instead of guessing all the time.

Share this post


Link to post
Share on other sites

i got it working yesterday. I' m goin to do a example building at the weekend, when i have some time to do this.

110411_02.jpg

110411_03.jpg

110411_04.jpg

The damage model isn't fully done yet, but at least it works.

Share this post


Link to post
Share on other sites

As T_D said, it´s done with hide-animations and hitpoints.

I´m goin to release a example at weekend, when i have time for this.

Share this post


Link to post
Share on other sites

Did el76 ever release the example?

I've been ticking over some ideas for buildings lately, but am keen to get them to an A2 standard of destruction.

Share this post


Link to post
Share on other sites
Did el76 ever release the example?

I've been ticking over some ideas for buildings lately, but am keen to get them to an A2 standard of destruction.

Sorry, forgot about this, will do it the next days. :o

Share this post


Link to post
Share on other sites

still waiting for some pointers.. also you got the "ruins" to work? Does it work when you place in visitor as well?

Share this post


Link to post
Share on other sites

Sorry for the long delay.

But it was part of a bigger building and i had to remove and rewirte a lot so it doesn´t confuses too much. (and i have to admit: i forgot it again...:o)

Part damage works nice, but i have probs with jip players, which don´t get updated.

The example contains a simple wall with two destroyable parts. The damage model is just a simple one, but at least it´s just to show what i got so far.

Object can be found in editor below objects: Part damage wall

File contains pbo-file and source files: Link

Before and after:

partdamage.jpg

Edited by el76

Share this post


Link to post
Share on other sites

Hey el76 thanks heaps.

But at a glance it appears I have a problem. Placing the wall in the editor and firing 2 smaw rounds at one of the bottom quaters results in the whole wall being destroyed and sinking into the ground.

Share this post


Link to post
Share on other sites

Here's a quick run-through how BIS' "dynamic destruction" of buildings works (not for beginners, sorry)

First you need your normal building + Hitpoints that define where a hit will cause a part of a house disappear. No extra selections, sections or anything other mysteriously magic thingies.

This object can be placed in a map (Visitor 3) or on a map (Normal and RT-Editor).

So far no destruction.

Next you need a model that has selections that are sections of their own. (Meaning not linked to the rest. Imagine creating two boxes with F7. These two boxes will be two independent sections.)

Name these sections, which are also selections, according to a pattern that suits you (In the config below referenced as "dam1", "dam2", etc...). Now create "ruined" parts for each broken section. These ruined parts will later replace the sections you just created when they are "hit". This is actually the dynamic/partial damage part of it. After you have created one, cut it, and save it as a different .p3d with a name pattern that lets you identify where this belongs. Remember to create all the necessary LODs.

Now add your freshly created destructed segments back in place as proxies. Select one proxy, and then create another NamedSelection for it called "unhide1","unhide2", etc.

Save this model as YourModelName_dam.p3d.

Also don't forget to define proper model.cfgs (cfgModels & cfgSkeletons) with correct hide-animations for each section/selection of "yourHouse_dam.p3d". Because they don't hide without actually having an animation for it. The anim will be triggered then through the hitpoints.

Now to actually give you an understanding of how this works:

Something hits a hitpoint. -> The hitpoint recieves damages. -> The recieved damage is exceeding the specified threshold of that specific hit point. -> The hit point triggers it's linked animation. -> The linked animation hides the linked building section that is intact and un-hides the corresponding "damaged" section of a building. -> Done.

Having this second model prevents all unharmed buildings from having more sections than needed, because the more sections you have means worse performance. Since this model will only be used when the house is actually damaged, we save performance with all the unharmed buildings having less sections.

So, to tell the engine to do that, you add this to the house's config:

replaceDamaged = "YourModelName_dam";

This is not a path to a .p3d, it is a reference to another class that this current building will be replaced once damaged. The replacement building can be any building you like, but for the sake dynamic destruction, it will be a building that is prepared with "breakaway" sections. See above.

Next, the game needs to know what each hitpoint is causing. To do so, we need this class Hitpoints. This needs to be in both configs for "class yourHouse" and "class yourHouse_dam".

class HitPoints
 {
  class Hit1
  {
   armor = 0.2;
   material = -1;
   name = "dam1";
   visual = "damT1";
   passThrough = 0.2;
   convexComponent = "dam1";
   class DestructionEffects
   {
    class Dust
    {
     simulation = "particles";
     type = "HousePartDust";
     position = "";
     intensity = 1;
     interval = 1;
     lifeTime = 0.01;
    };
    class Dust2: Dust
    {
     type = "HousePartDustLong";
    };
    class Walls: Dust
    {
     type = "HousePartWall";
    };
   };
  };
  class Hit2
  {
   armor = 0.2;
   material = -1;
   name = "dam2";
   visual = "damT2";
   passThrough = 0.2;
   convexComponent = "dam2";
   class DestructionEffects
   {
    class Dust
    {
     simulation = "particles";
     type = "HousePartDust";
     position = "";
     intensity = 1;
     interval = 1;
     lifeTime = 0.01;
    };
    class Dust2: Dust
    {
     type = "HousePartDustLong";
    };
    class Walls: Dust
    {
     type = "HousePartWall";
    };
   };
  };
  class Hit3
  {
   armor = 0.2;
   material = -1;
   name = "dam3";
   visual = "damT3";
   passThrough = 0.2;
   convexComponent = "dam3";
   class DestructionEffects
   {
    class Dust
    {
     simulation = "particles";
     type = "HousePartDust";
     position = "";
     intensity = 1;
     interval = 1;
     lifeTime = 0.01;
    };
    class Dust2: Dust
    {
     type = "HousePartDustLong";
    };
    class Walls: Dust
    {
     type = "HousePartWall";
    };
   };
  };
  class Hit4
  {
   armor = 0.2;
   material = -1;
   name = "dam4";
   visual = "damT4";
   passThrough = 0.2;
   convexComponent = "dam4";
   class DestructionEffects
   {
    class Dust
    {
     simulation = "particles";
     type = "HousePartDust";
     position = "";
     intensity = 1;
     interval = 1;
     lifeTime = 0.01;
    };
    class Dust2: Dust
    {
     type = "HousePartDustLong";
    };
    class Walls: Dust
    {
     type = "HousePartWall";
    };
   };
  };
 };

- - - - AND This only needs to be in "class yourHouse_dam"- - -

  class AnimationSources
 {
  class Hit1
  {
   source = "Hit";
   hitpoint = "Hit1";
   raw = 1;
  };
  class Hit2: Hit1
  {
   hitpoint = "Hit2";
  };
  class Hit3: Hit1
  {
   hitpoint = "Hit3";
  };
  class Hit4: Hit1
  {
   hitpoint = "Hit4";
  };
};

Now BOTH models (yourHouse.p3d and yourHouse_dam.p3d) need proper configs!

Corresponding model.cfg animation for hiding a section looks like this (only needed for "yourHouse_dam.p3d").

   class Hit1
  {
   type="hide";
   source="Hit1";
   selection="dam1";
   minValue = 0.0;//rad 0.0
   maxValue = 1.0;//rad 57.29578
   minPhase = 0.0;//rad 0.0
   maxPhase = 1.0;//rad 57.29578
   hideValue = 0.999;
  };
  class Unhide1
  {
   type="hide";
   source="Hit1";
   selection="unhide1";
   minValue = -1.0;//rad -57.29578
   maxValue = 0.0;//rad 0.0
   minPhase = -1.0;//rad -57.29578
   maxPhase = 0.0;//rad 0.0
   hideValue = 0.001;
  };

Now you have damage detection that will replace parts of your building with proxies that look like damaged parts of a building.

I'll try to write a proper tutorial on this once I get a short quip with one of BIS' Devs who actually conceived this.

In the meantime el76's magnificent example along with this rough guide should help you master this.

Edited by Mondkalb

Share this post


Link to post
Share on other sites

Cheers Mondkalb, It may be a little while before I put into practice and prove I've learnt anything but now, with all this stuff, I'm definately going to give it a crack.

Share this post


Link to post
Share on other sites

Amazing ! :eek: since i need to apply that's stuff to my building that's useful ! thx if you guys make a tutorial or thx anyways for posting some help here : P

Share this post


Link to post
Share on other sites

A big thanks to both Mondkalb for the code and el76 for the example

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×