Author Topic: How would I go about making a glass object break/shatter?  (Read 326 times)

MarcellusW

  • Posts: 105
How would I go about making a glass object break/shatter like the ingame car windows?

What I have found so far is,
car windows have #car_window in their material.
In data\property\effects\car\window_break\ are 6 files
glass1.fxbp
glass2.fxbp
sound.fxac
sound_crack.fxac
window_break.fxcn
window_crack.fxcn
The example car windows point to a non-excisting .dntp
Some of the ingame cars windows point to a non_excisting default_default_p_e_g.dntp, others to the above.
The example cars windows are models in the body.vhcl
The ingame cars rear_window is a model in the body.vhcl, but the front_window is a part (window_front_0.vhcl)
I haven't found any other refference about car windows.

Is there a relationship between #car_window and the effects?
What CustomData would an object like this have?

I have been thinking about this for over a year now, but every time something else came up.
Been breaking my head over this the last couple of days, but I'm stuck now.
I remember reading in a topic someone mentioning about breaking glass in his mod, but I cant find to topic. (tried searching to no avail )
I really hope there is a solution for this, I would like this to work on some custom props I'm making for Purple44 and for the mod I have been working on.

Any help and insight would be highly appreciated.

KillerAJD

  • Posts: 50
Keep in mind, I've only ever tried to get a wood wall to break, so this info may not be of any use to you/may be incorrect. If this is for parts of a vehicle, I have no idea if any of this applies.

The walls I have in my Petaluma track that break are pretty much recreated from the objects The Very End has in his track pack for breakable signs. I don't know the exact details of the object properties and if you can change them at all, but here's how the breaking wood sign/wall worked at least.


1st image shows the breakable wood sign and all the other pieces in the scene.


2nd image shows that the object, breakSign02, is one large piece. From what I can tell, until you touch/break the object in game, this is the piece you would see. Also, this images shows that there are already pre-broken pieces of the wall, and each piece is named breakSign02$partxx (where xx is the number of the object, starting at 00). I had issues with lighting if the piece objects weren't solid (I forget the correct term for this, but if the object isn't closed, it'll give you issues). I tried using this exact object from TVE's pack, but had issues converting it due to 3ds Max unit differences, but it was easy enough to re-create it.

Essentially, when you hit the object in game, the main piece disappears, and then all of the smaller parts are what show up and get physics applied to them. I think? So for your object, you would have one modeled object for the solid, non-broken object, and then lots of little pieces for when it becomes broken.


3rd image shows you the user defined properties of the main breakSign02 piece. This is where you might need to explore the objects folder in BagEdit to see if there are different object properties you could use for glass (I'm assuming these properties determine the weight/particles/sound from the objects, but I've not looked into it).


4th image shows you the user defined properties of the various breakSign02$partxx pieces. Same info applies as far as the object properties.

This might not have any relation to what you're asking about, but if it does, you could try with the above info and go from there? I really recommend downloading The Very Ends' track pack and taking a look through the objects folder. There were tons of little things like this that I wouldn't have figured out if I didn't take a look through the folder and play around with stuff.
« Last Edit: August 16, 2018, 03:57:55 AM by KillerAJD »

MarcellusW

  • Posts: 105
Thank you for your response.

This procedure was the first thing that came to mind when I started making the objects for Purple44.

What I've made is, 2 beer bottles with a 50% transparent material , which actually looks like glass bottles ingame
and I thought it would be really cool to have them break/shatter on impact in pretty much the same way the front window of the ingame cars shatter, if at all possible.
The mod I've been working on ( Flatout2's City1 map ) has 1 route that leads through a Mall and you have to go through the glass entrance and -exit.

My actual question should be: Can the effects for breaking the ingame cars windows be applied to a dynamic object?

Thanks again for your effort.

The Very End

  • *
  • *
  • Posts: 2416
Probably. Crate a dntp file, link it to the glass shattering effects (look in fxfr, trigger files and whatnot), and make it the effect that occurs when object is replaced / decomposed. Not done it myself but with other effects.

MarcellusW

  • Posts: 105
Thanks TVE, that put me in the right direction.

Partially succes, I now have a dynamic object that emits glass particles and sound when hit, but the bottle remains intact. ( will have to make a #lod object aswel )

Will do further testing tomorrow.

Cheers

Purple44

  • *
  • Posts: 8350
Good luck in figuring this out MarcellusW.   :)
Flatout Joint, where the mods were.

i5 2500 i7 8700, 16GB, Nvidia 660 960 1060 6GB, Win 10 64bit, DFGT Wheel

MarcellusW

  • Posts: 105
quote
I turns out that this works in pretty much the same way as any other dynamic objects that break on impact.

I got the bottle breaking in pieces, but only 1 part of the bottle is visible at start, the rest of the bottle becomes visible after it gets hit.
(I now know that the compleet object needs to be the main part and all pieces need to have $partxx behind the name)
The bottle consists of 49 objects, the bottom part being the "main" part, the rest have "$pxx behind the name. ( bugbear uses both $pxx and $partxx )
I have parented the $pxx objects (children)  to the main object ( parent ) to link them. ( is this the correct way? )

The above had to go here, but was placed in different thread.


Cheers

The Very End

  • *
  • *
  • Posts: 2416
You are correct I think :)

From my testing naming is important. Lets say we have an item that breaks into two pieces which again breaks into two pieces.

This is the object we use as a base, which we will see. Should be assigned to a dntp which features a decompose / replace effect, see concrete barriers dntp file
object01

Same as above, we want to make sure the first object has broken into two pieces, but we want each of these pieces break again into more pieces. A use area of this could be to have a fence that has two damage stages. Either way;
object01$part01
object01$part02


These are dynamic object which does not break
object01$part01$part01 
object01$part01$part02
object01$part02$part01
object01$part02$part02


You can stack these as many times as you want, as long as the object breaks / replaces before moving on to the next "layer", indicated by a new "$". You don't need to call them "part", could call them something easier such as "part01$p01"
Edit: complete scene liste for this object:

object01
object01$part01
object01$part02
object01$part01$part01 
object01$part01$part02
object01$part02$part01
object01$part02$part02


If you just want ONE stage, let's say something that breaks just one time, then just keep it to one level, e.g. :
object01
object01$p01
object01$p02
object01$p03
object01$p04

etc.
« Last Edit: August 22, 2018, 03:45:49 PM by The Very End »

MarcellusW

  • Posts: 105
You are correct I think :)

If you just want ONE stage, let's say something that breaks just one time, then just keep it to one level, e.g. :
object01
object01$p01
object01$p02
object01$p03
object01$p04

etc.

Thanks mate you're tha Bomb.

Yeah, I was following the one stage option, but ad first it did not occur to me to have the full object as primary part ( parent ) and "all" the broken parts as secundary parts ( children ).
I asumed that the sum of the parts would make the full object visible, rather than the above, but it makes more sence to have a primary object be replaced by the sum of the secundary parts.

I do have an other question:
The primary object have it's pivot point (origin ) centre min. ( e.g. bottom centre ) , as do the secundary parts, though that kinda gives a weird effect to the parts after collision.
Do I change the pivot point ( origin ) of the secundary parts to their individual centres of mass or should I have set the pivot point ( origin ) of the primary object to centre of mass and than make the secundary parts? ( the first kinda makes more sence to me )

This is the first time that I have dug in deeper than just the surface of this matter, I must admit, I should have done this some time ago.
The ability to decompose an object in several stages brings some nice ideas to mind.

Thanks again TVE

Cheers

The Very End

  • *
  • *
  • Posts: 2416
Just happy to help :D
From what I understand it's better if every piece has it's own pivot to center, but some might be better rotating or moving. For example, for a cylinder I had to rotate to pivot so that Y axis was up, or it would act strange. I'm not entierly sure about what is best, but for testing let pivot be to center of the invidual objects.

Then it is a matter how to decompose. You can select different effects here. For example, the inherit one makes it so that when the object is replaced, the replacement objects inherid the velocity of the "mother" object. If you do replace, it simply replaces the object without taking that into consideration. I have not tested them all out myself, but I suspect that chosing a other decompose effect might yield you better results.

Edit: Also, somtimes the feel of the objects might be a bit messed up too, as they follow their boundry box when being a dynamic object. It is specially noticeable if you have a object which is bent. You could cheat it a little by adding colission boxes to it, but that might be a bit too much work if many sub objects. Either way; Say you have a fence that has a damage model, but this is a bent version, and you want to make sure the colision follows the actual bend. Then you will have to add up to collision 8 boxes (simple boxes, no more advances shapes are allowed). The naming would be following (please note that its now with "#" signs):


Object01
Object01$p01
Object01$p01#col0
Object01$p01#col1
Object01$p01#col2
Object01$p01#col3
Object01$p01#col4
Object01$p01#col5
Object01$p01#col6
Object01$p01#col7
« Last Edit: August 22, 2018, 06:53:25 PM by The Very End »

MarcellusW

  • Posts: 105
Just happy to help :D
From what I understand it's better if every piece has it's own pivot to center, but some might be better rotating. For example, for a cylinder I had to rotate to pivot so that Y axis was up, or it would act strange. I'm not entierly sure about what is best, but for testing let pivot be to center of the invidual objects.

Then it is a matter how to decompose. You can select different effects here. For example, the inherit one makes it so that when the object is replaced, the replacement objects inherid the velocity of the "mother" object. If you do replace, it simply replaces the object without taking that into consideration. I have not tested them all out myself, but I suspect that chosing a other decompose effect might yield you better results.

Got that very same problem, I guess the game needs to think it's a horizontal object rather than a vertical, which makes sence for object behaviour.

Will do further testing tonight.

cheers

MarcellusW

  • Posts: 105
Got it working now.
I used the "cluster_bomb" decompose type, this gives the best effect imo, the 2 directional types makes the debri go mostly in the direction the car is moving,
with only little lateral movement, while the cluster_bomb type has more lateral movement giving the effect a more natural look. ( excellent for glass objects )

Allthough I made the bottle for Purple to be non-transparent, it still has a glass look to it, reason for this is, I haven't figured out yet how to get a full colored glass bottle texture.
My appempts so far only have resulted in a transparent bottle ( like a normal drinking glass or window ) , but with faint color in it at certain angles.
My guess is, the alpha channel is still set to too much transparency.

50 bottle test




Thanks everyone for your great help making this possible.