Thread: NPC Model - Rescale, Size and Hull Tutorial

Results 1 to 6 of 6
  1. #1
    Still learning wolf-3d's Avatar  
    Tester
    Join Date
    Jan 2011
    Location
    Somewhere Warm.
    Posts
    1,474

    NPC Model - Rescale, Size and Hull Tutorial

    NPC Model
    mins
    maxs
    size
    HeadCrab
    -12 -12 0
    12 12 24
    24 24 24
    Chumtoad
    -8 -8 0
    8 8 12
    16 16 12
    Houndeye
    -16 -16 0
    16 16 36
    32 32 36
    BullSquid
    -32 -32 0
    32 32 64
    64 64 64
    Slave
    -16 -16 0
    16 16 72
    32 32 72
    Agrunt
    -24 -24 0
    24 24 64
    48 48 64
    Barney
    Scientist
    Human Grunt
    M/F Assassins
    Otis
    Medic
    Torch
    Robo Grunt
    -16 -16 0
    16 16 72
    32 32 72
    MiniGun Grunt/HWG
    -16 -16 0
    16 16 72
    32 32 72
    Ichthyosaur
    -32 -32 -32
    32 32 32
    64 64 64
    Gonome
    -16 -16 0
    16 16 72
    32 32 72
    Pitdrone
    -16 -16 0
    16 16 48
    32 32 48
    Baby Voltigore
    -16 -16 0
    16 16 72
    32 32 72
    Voltigore
    -48 -48 0
    48 48 90
    96 96 90
    Baby Garg
    -32 -32 0
    32 32 96
    64 64 96
    Garg
    -32 -32 0
    32 32 214
    64 64 214
    Tor
    -24 -24 0
    24 24 64
    48 48 64
    Kingpin
    -24 -24 0
    24 24 112
    48 48 112
    Stukabat
    -12 -12 0
    12 12 24
    24 24 24
    Nihilanth
    -32 -32 0
    32 32 64
    64 64 64

    Note: Many of these Models have various mathematical irregularities in their design, (Tor, Agrunt, HWG, Gargantua, to name a few) but just ignore them for the moment and respect that the Original Game was released in 1997, Valve was probably under pressure to release the game, "mistakes do happen", people are lazy and like to reuse code etc. etc.
    You should just consider them "features" now. (They don't bother or effect me, so they should not bother you or your maps.)
    Also changing these values may introduce problems to "Old Maps" and would be a complete waste of developer time and cause unnecessary testing.
    NB: The "Ichthyosaur" hull values may scream irregularity but if you think really carefully, you can quite easily accept that was done on purpose by valve. (Hint: It allows what seems to be a "LOL" bug, but given the early concept and art work was probably intentional.)


    Alright, so what is the above table all about ?

    "mins" = the bottom left co-ordinates of the "blocking hull"
    "maxs" = the top right co-ordinates of the "blocking hull"
    "size" = These "mins" and "maxs" co-ordinates define the model's "size" hull.

    Summary:
    mins and maxs are co-ordinates.
    size is a Hull ( used to determine if NPC/Model is touching something. )

    So taking Kingpin for example:
    mins -24 -24 0
    maxs +24 +24 +112 (less or subtract to = )
    size -48 -48 -112 (But it is an absolute value)

    so it becomes:
    size +48 +48 +112

    Note: Because I understand that some "Forum Members" may not understand, the [link:] maths involved you can use the values in the above Table.

    So what is "scale"
    Scale is the growth or shrink factor applied to a models "Mesh" (The bit that you texture or apply a skin too. This is NOT the same as size. )

    How do I use any of this information ?

    Well suppose (for example) you want a "Half Size" model for your map when it loads.
    In Hammer Click your model (look up the mins, and maxs in the table above), divide by 2 to get a half and enter them here:
    ( Pic 1 )
    Note: If you press the "SmartEdit" Button, you will actually see the Attributes as "minhullsize" (mins) and "maxhullsize" (maxs).

    Then in "smartedit mode" add an Attribute called "scale" "0.5"
    ( Pic 2 )

    That is it ! Done, you will see no change in hammer but after compile and loading the ".bsp file" you should see it is half size model and if you jump on it you should not be floating above it. (i.e there is no invisible "blocking hull" at full size.)

    But what if you want to change a "model" in game via a "trigger" (like: Button, trigger_multiple etc.) I hear you say, how would you do that ?
    Answer:
    Extract/Unzip the the attached file called "t101_scModel_resizing"
    Put the ".rmf" file in your hammer source directory. (where you build maps)
    Put the .bsp file in Drive Letter:\ program files \ Steam \SteamApps\ common [or UserName] \ svencoop \ maps \

    For Example: Mine is "C:\Program Files\Steam\SteamApps\common\Half-Life\svencoop\maps"

    Then play the .bsp , look around, find button, press it, see what happens to Models.

    If you are a mapper examine the .rmf source file.

    Summary.:

    mins = bottom corner of "size" hull co-ordinates relative to model.
    maxs = top corner of "size" hull co-ordinates relative to model.
    size = The hull defined by mins and maxs

    scale = What most people call "the size of something", here it relates to the mesh of the model.

    Process: look in the .rmf file, the entity's will be above the models that they change.

    NOTE: This tutorial is about NPC / Monster models.
    A "NPC" has its origin at the bottom of the model.
    Where as a "Player" has its origin at the centre of the model. (Hint: Do not apply this tutorial to Player models.)


    Extended tutorial (for those interested in "targeting"):

    absmin = World relative min co-ordinates. (Used for trace targeting )
    absmax = World relative max co-ordinates (Used for trace targeting ).
    (These co-ordinates define a trace "hull" used by the HUD, "line of sight" and targeting parts of the HL code in order to speed up the determination of "did a bullet hit the model ?" or "can something see something else" etc.)

    What is this Model relative and World relative stuff ?
    As said NPC models have there origin (Yes essentially "origin" is another set of co-ordinates which you can calculate, but we have no need to do that in this tutorial) which live at the base or floor of the NPC Model.
    The co-ordinates of mins and maxs, are calculated from this origin (the base or floor) in every case so as to expand out the "collision hull/bounding box" of the model. BUT because "models can move and the "size" hull is FIXED to the model it also moves.
    In other words the "size hull" is always relative to the model it belongs to.

    But we like to shoot things in Sven Coop from time to time, so what now ?, how do we know if a bullet has hit or missed this model as it runs about our map ? (In other words where is the Model relative to the BSP World)

    The engine does this via absmin and absmax. (Note: I said the engine because these PEVs (absmin and absmax) should be treaded as if they are read-only because they are recalculated every sever frame.
    Hence changing them is basically a waste of time. (Write the values now ?, Well your are too slow, the server has recalculated and overwritten your values atleast 0 .01 seconds ago, assuming there was server lag, otherwise it was 0.0001 seconds ago on a modern PC/Server.)

    Then how could I use this for "tracking movement", "Line of sight" etc. ?
    Think PEVs::"origin" and "fov" (Hint: "Origin" is the centre of BOTH a model's "size hull" and the centre of "absmin" and "absmax" (Not mathematically but for your purposes assume so.), whereas "fov" tells you where a model is looking.)
    Since the engine keeps track these values for you, maybe you could compare Player.fov against Enemy.origin with a trigger_condition.

    Some warnings:
    Doing this constantly for every Player against every Enemy, is not something to be done without a lot of testing because of potential lag.
    I would also break your map up into zones and make the zones trigger "Player tracking" to "on state" from within these known vantage points or look out posts only. (Limit the activity of trigger_condition.)

    Note: Zip file (Enjoy)
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	t101.jpg 
Views:	98 
Size:	63.3 KB 
ID:	15837   Click image for larger version. 

Name:	t101a.jpg 
Views:	100 
Size:	73.9 KB 
ID:	15838  
    Attached Files Attached Files
    Last edited by wolf-3d; 26-10-2015 at 02:06 PM. Reason: Add Stukabat, Nih, PitDrone
    Regards
    Wolf-3D

  2. #2
    warrior spy-warrior's Avatar  
    Contributor
    Join Date
    Nov 2006
    Location
    Europe, France, Paris
    Posts
    2,965

    Re: NPC Model - Rescale, Size and Hull Tutorial

    I find there are many too errors that are known and are not corrected. this is a shame.
    Je trouve qu'il y a beaucoup trop d'erreurs qui sont connus et ne sont pas corrigées. c'est une honte.
    Patience is a virtue greatly needed by those who attempt great things.
    La patience est une vertu fort nécessaire à ceux qui tentent de réaliser de grandes choses.

    Server SvenCoop
    I love the mods svencoop
    World time zone & Look clocks

  3. #3
    ~ Unholy Madness ~ 19941994ra's Avatar
    Join Date
    Jan 2010
    Location
    Argentina
    Posts
    244

    Re: NPC Model - Rescale, Size and Hull Tutorial

    Pretty good actually. I have seen too many big mobs that i could just almost noclip them through.
    Sven Co-op - Player, enthusiast, alien-reaper, Shotgun-lover
    Sven Co-op Forums - Addict, spam-hater, playing 5.0 a lot
    In-game name - Delacroix

  4. #4
    Still learning wolf-3d's Avatar  
    Tester
    Join Date
    Jan 2011
    Location
    Somewhere Warm.
    Posts
    1,474

    Re: NPC Model - Rescale, Size and Hull Tutorial

    First Post Updated with Zip File.

    Notes: This example, uses the "trigger_changevalue" entity to change scale, mins, maxs and size (in that order.)

    (I will try and update again soon with the other 2 methods. - Yes there are slightly different ways of doing the same thing)

    The example also just dynamically shrinks models from 100% after button to 10%, I will try and add more dynamic changes with additional buttons.

    (Lastly I haven't fully tested this, there might be errors in the entities or setup. EDIT: Tell me here if you find any.)
    Regards
    Wolf-3D

  5. #5
    Still learning wolf-3d's Avatar  
    Tester
    Join Date
    Jan 2011
    Location
    Somewhere Warm.
    Posts
    1,474

    Re: NPC Model - Rescale, Size and Hull Tutorial

    Quote Originally Posted by spy-warrior View Post
    I find there are many too errors that are known and are not corrected. this is a shame.
    Je trouve qu'il y a beaucoup trop d'erreurs qui sont connus et ne sont pas corrigées. c'est une honte.
    Don't worry about the "irregularities" (They are not real Errors to be concerned about).
    Also remember you have the ability to change mins, maxs and size now.

    So if you scale up a model (Scaling down will help hide any irregularities) and then can see into the mesh or perhaps the "size" box/hull is square (and the model shape is rectangular), you can adjust until you get a "better fit", between the model, hull and mesh.

    Everything has been acceptable in game so far with "standard sized" models (because it is very difficult to see any problems with your eyes, you need maths.)

    And lastly 15 years ago, Valve never designed HL with the thought that we would still be developing their engine or that we would add changes to features (that where originally intended to be fixed/static) like "scale", "mins", "maxs". "size" or any of the other enhancements put into SC.
    Last edited by wolf-3d; 05-05-2014 at 07:39 PM.
    Regards
    Wolf-3D

  6. #6
    warrior spy-warrior's Avatar  
    Contributor
    Join Date
    Nov 2006
    Location
    Europe, France, Paris
    Posts
    2,965

    Re: NPC Model - Rescale, Size and Hull Tutorial

    Quote Originally Posted by wolf-3d View Post
    ...
    And lastly 15 years ago, Valve never designed HL with the thought that we would still be developing their engine or that we would add changes to features (that where originally intended to be fixed/static) like "scale", "mins", "maxs". "size" or any of the other enhancements put into SC.
    I say "valve" did not correct their mistakes from the beginning in all their games.
    a game that remains for sale is a game with a follow-up by the publisher.

    je dis que "valve" n'a pas corriger leurs erreurs depuis le début dans tout leur jeux.
    un jeu qui reste à la vente est un jeu avec un suivi par l'éditeur.
    Patience is a virtue greatly needed by those who attempt great things.
    La patience est une vertu fort nécessaire à ceux qui tentent de réaliser de grandes choses.

    Server SvenCoop
    I love the mods svencoop
    World time zone & Look clocks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •