This is probably a bit of a long shot, but as I'm not a moddler, I might have missed something you guys understand.
I am trying to understand how gmod assigns drag (air resistance) to props.
I already know drag is equal to area * air_density * speed^2 * a_constant
What I don't quite understand is how that area value is extracted from the prop's unique physical properties/size.
I do know each prop has an [I]area vector[/I], which for many props (like phx cubes) is equal to the area of the respective xyz faces of their bounding box. (ergo in e2 speak; area vector = shiftL(E:boxSize()) * ShiftR(E:boxSize()) )
This [I]area vector[/I] is then projected in the direction of velocity (simply using the dot product of the [I]area vector[/I] with the localised direction of the prop) to get the area value. ([URL="http://www.codersnotes.com/notes/projected-area-of-an-aabb"]like this[/URL])(again, in e2 speak; Area = abs(E:toLocalAxis(Velocity:normalized()):dot(Area_vector)) )
I have already found a simple way to [URL="http://www.wiremod.com/forum/wiremod-general-chat/17874-comprehensive-gmod-physics-guide-2.html#post210047"]experimentally calculate[/URL] the area vector, but id like to be able to do it properly, as the numbers will obviously be somewhere in the physics engine so I shouldn't need to find it by experiment.
So yeah, anyone know what makes many props have "area vectors" that are different from their bounding box dimensions?
I think you're overthinking it. I'm pretty sure source only takes into account size and weight. It's easy to notice this if you take something big and change the weight to something really low, like 1-5, it falls extremely slowly.
I'm sure about everything I stated I already know :). I do realise that it will mean nothing to most people though.
If you really want to learn more about gmod's physics, I suggest you read [URL="http://www.wiremod.com/forum/wiremod-general-chat/17874-comprehensive-gmod-physics-guide.html"]my thread here[/URL]. You likely need to be competent with high-school (A level) physics and maths to understand that too though...
Drag can be scaled with the $drag qc command, so I assume if there were a place to directly extract numbers related to that stuff, it's in the phy file.
Ok thanks, where would I find this 'phy file'?
All models consist of 6 model files (nobody should be making xbox files anymore).
Looking at the phy files, the first half of them seems to be encrypted/none readable in notepad. Any ideas how I convert that to text?
They're binary files, not text. You probably won't be able to figure out which value is which. If you really want to, and can read code, I think the SDK has the source code to StudioMDL.exe, so you can figure out what it's doing.
[QUOTE=gman003-main;24902807]I think the SDK has the source code to StudioMDL.exe, so you can figure out what it's doing.[/QUOTE]
Any ideas where the code may be in the SDK files? because I can't find it :(
Seems I was mistaken. The code for the exporter is there, not the compiler.
It's in \src\utils\smdlexp\, if that ends up being useful, but a quick glance didn't see anything.
[QUOTE=gman003-main;24904308]Seems I was mistaken. The code for the exporter is there, not the compiler.
It's in \src\utils\smdlexp\, if that ends up being useful, but a quick glance didn't see anything.[/QUOTE]
Humm, this may be quite useful as I am trying to write an SMD importer ^^
Edit: That code seems to be for a 3Dmax export script.
Hmm, I couldn't see anything in the exporter code that looked like what I'm after either. If you think it is the studiomdl compiler I need to have a look at, are there any other possible places I might be able to take a look at it?
I found $drag referenced [URL="http://developer.valvesoftware.com/wiki/$collisionmodel"]here[/URL], don't suppose you have any suggestions for what to look for next either?
I am completely new at navigating the source sdk and the documentation so its hard to know where to go next. I have somewhat of an understanding of the code (from use of matlab and e2 code :p) though.
You could always decompile the model and check the qc for the $drag command.
Can someone point me to a tutorial on how to do that?
Download mdldecompiler from here: [url]http://www.chaosincarnate.net/cannonfodder/cftools.htm[/url]
Then find the model you want to work with, create a separate working folder for it, and copy all the model files (should be 6 of them including the .phy) to that folder. Put your mdldecompiler into your EP1 SDK bin folder. Run it, browse to your model, decompile.
Once it's decompiled, you can take a look at the QC files (via notepad) and check out the physics (always at the bottom).
To recompile, simply drag your QC onto studiomdl.exe in your bin folder.
EDIT: It probably goes without saying, but to decompile default models stored in the GCF, you need to extract them first.
Ok thanks, I did that. It seems $damping is used for a few props, which I probably wrongly included in my drag force test results.
I'm guessing force = $damping * speed if anyone knows? (easy for me to test if not)
However one of the most obvious test cases I tried, a phx triangle, has a very specific [I]area vector[/I], the area vector is equal to the bounding box face area, except in the y direction it is exactly twice the size.
This is not apparent from the .qc file though, as the $hbox is a cube, and that model doesn't have any $damping either.
Nowhere in any of the files is $drag referenced either, so I'm at a bit of a loss.
The collision model is used for physics not the hitboxes.
Other than that I don't have much idea how it works other than the stuff the ValveWiki says in the QC entry.
Ok, well I'm still sure that drag comes down to a area vector of some sort, so the geometry it is dependant on is going to have to be a box rather than the collision model. Is $hbox not the same as the bounding box?
I tested the $damping value and found it disappears when air_density is set to zero, so splitting it apart from drag may be a bit more of a challenge. To get accurate numbers I figure the simplest way is to test a prop with damping set to 1, and 0, and then measure the difference. Therefore, I am going to need to learn to compile models...I'll search the site for that no need to type it out for me.
Cheers for all the help.
Sorry, you need to Log In to post a reply to this thread.