semi automatic model cliping

General mapping discussions
User avatar
gsigms
Posts: 102
Joined: Thu Aug 18, 2011 11:24 am
Location: London, UK

semi automatic model cliping

Post by gsigms »

I am using a few model in the map I am working on: brazier, torch etc.

those models are not very complex but it seems to me autocliping is a bad idea: too complex geometries,

but, I am also lazy and because I use those models very repeatedly, manual clip would be very annoying.

so here is what I did:

this is a brazier model that I am using:
model
model


I created a new map containing only the playerclip brushes for that model (the brushes is placed similarly to the model relatively to the map origin as you would do for an ase model for example). Here the clip brush just account for the rough geometry of the brazier's base
model clip
model clip


I wrote a python script to automatically add the clip brushes into my map. It takes a few parameters, the filename of the map to "clip", the name of the model to clip, and the filename of the map containing the clip brush "model". The python script parses both the map and the clip model map, and inserts the clip brushes wherever there is an instance of the model to clip:

end result (map, model, clip) works fine:
ingame
ingame
nemNEMnem wrote:yeah, not like ur avatar, gsigms, i find ur ones is difficult to masturbate, too. :D :D :D :D

User avatar
nemNEMnem
Posts: 271
Joined: Sat Aug 20, 2011 11:11 am
Location: Germany
Contact:

Re: semi automatic model cliping

Post by nemNEMnem »

thats so cool and genius, i cant realy say it on english :D
how does it work? use it the .bsp or the .map file? creates it brushes like your second screenshot or add it more complex? Do you want to give that script to the public?
so many questions...
but then another thing: u know that with the playerclip the enemy can shoot TROUGH the model, thats stupid if the model is a stone or a car or sth like that, but its good and realistic for a tree or something
for a big tree, you need a small axe.
--Bob Marley--

User avatar
LynXIII
Posts: 54
Joined: Thu Aug 25, 2011 3:28 pm
Location: DE

Re: semi automatic model cliping

Post by LynXIII »

don't know what voodoo magic you did there, but it sounds useful :-)

User avatar
gsigms
Posts: 102
Joined: Thu Aug 18, 2011 11:24 am
Location: London, UK

Re: semi automatic model cliping

Post by gsigms »

ty :)

it works on the ".map", when you place a model in your map (md3, ase, whatever) you have an entity in the map file, from the example of the original post:

Code: Select all

{
"model" "models/mapobjects/7g/brazier.ase"
"origin" "384 192 0"
"classname" "misc_model"
}


the last property (classname) indicates that the entity is a model, the first one is the model, and the origin is where the model is placed in 3d. you have on such entity whenever you place a model somewhere in the map

the map file of the second screenshot is a usual worldspawn entity, but I am only interested in the brushes not the entity:

Code: Select all

// entity 0
{
"classname" "worldspawn"
// brush 0
{
( 24 24 0 ) ( -24 24 0 ) ( -24 -24 0 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( -24 -24 32 ) ( 24 -24 32 ) ( 24 -24 0 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( 24 -24 32 ) ( 24 24 32 ) ( 24 24 0 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( 24 24 32 ) ( -24 24 32 ) ( -24 24 0 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( -24 24 32 ) ( -24 -24 32 ) ( -24 -24 0 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( -24 24 8 ) ( -16 24 8 ) ( -24 -24 8 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
}
// brush 1
{
( -16 24 8 ) ( -24 24 8 ) ( -24 -24 8 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( -16 24 27 ) ( -2 24 27 ) ( -16 -24 27 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( -22 24 8 ) ( -14 24 27 ) ( -22 -24 8 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( 14 24 27 ) ( 22 24 8 ) ( 14 -24 27 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( -22 -22 8 ) ( -22 -14 27 ) ( 22 -22 8 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
( -22 14 27 ) ( -22 22 8 ) ( 22 14 27 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
}
}


what the script does is adding those brushes into the worldspawn of the map for each model entity, after having translated the clip brushes wrt to the "origin" of the model to clip

Code: Select all

    {
        ( 408.000000 216.000000 0.000000 ) ( 360.000000 216.000000 0.000000 ) ( 360.000000 168.000000 0.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 360.000000 168.000000 32.000000 ) ( 408.000000 168.000000 32.000000 ) ( 408.000000 168.000000 0.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 408.000000 168.000000 32.000000 ) ( 408.000000 216.000000 32.000000 ) ( 408.000000 216.000000 0.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 408.000000 216.000000 32.000000 ) ( 360.000000 216.000000 32.000000 ) ( 360.000000 216.000000 0.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 360.000000 216.000000 32.000000 ) ( 360.000000 168.000000 32.000000 ) ( 360.000000 168.000000 0.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 360.000000 216.000000 8.000000 ) ( 368.000000 216.000000 8.000000 ) ( 360.000000 168.000000 8.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
    }
    {
        ( 368.000000 216.000000 8.000000 ) ( 360.000000 216.000000 8.000000 ) ( 360.000000 168.000000 8.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 368.000000 216.000000 27.000000 ) ( 382.000000 216.000000 27.000000 ) ( 368.000000 168.000000 27.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 362.000000 216.000000 8.000000 ) ( 370.000000 216.000000 27.000000 ) ( 362.000000 168.000000 8.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 398.000000 216.000000 27.000000 ) ( 406.000000 216.000000 8.000000 ) ( 398.000000 168.000000 27.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 362.000000 170.000000 8.000000 ) ( 362.000000 178.000000 27.000000 ) ( 406.000000 170.000000 8.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
        ( 362.000000 206.000000 27.000000 ) ( 362.000000 214.000000 8.000000 ) ( 406.000000 206.000000 27.000000 ) common/full_clip 0 0 0 0.500000 0.500000 0 5 0
    }


so in effect, it is exactly as if in radiant, for each model, you had imported the "clip map" into you map and moved the imported brushes on top of your model by hand.

for those knowing a little of programming, the python script is hand-writen lexer/parser for map files that generates an AST, a bit of 3D maths, modfying the AST, and some pretty-printing.

as to "making it public", very likely that I will post the code for whoever is interested, very unlikely that I will do any packaging (front end or whatever). But first, I need to add some extra code to handle independent axis scaling and rotation of models, and I also want to do some cleanup of the code.
nemNEMnem wrote:yeah, not like ur avatar, gsigms, i find ur ones is difficult to masturbate, too. :D :D :D :D

User avatar
ValkoVer
Posts: 176
Joined: Mon Aug 22, 2011 11:01 am
Location: Poland

Re: semi automatic model cliping

Post by ValkoVer »

Nice, You geek :>

User avatar
theRipper
Posts: 223
Joined: Tue Aug 30, 2011 1:57 pm
Contact:

Re: semi automatic model cliping

Post by theRipper »

this should be a plugin for radiant :>
Image

User avatar
Rayne
Site Admin
Posts: 624
Joined: Wed Aug 17, 2011 5:22 pm

Re: semi automatic model cliping

Post by Rayne »

Very nice G. Keep those ideas rolling.
Who says laziness is a bad thing :P
If a man wasn't too lazy to walk he wouldn't invent the wheel.

User avatar
gsigms
Posts: 102
Joined: Thu Aug 18, 2011 11:24 am
Location: London, UK

Re: semi automatic model cliping

Post by gsigms »

nemNEMnem wrote:but then another thing: u know that with the playerclip the enemy can shoot TROUGH the model, thats stupid if the model is a stone or a car or sth like that, but its good and realistic for a tree or something


forgot to mention, the script does not differentiate on that, you can use player/item/full/any clip, or any shader for that matter, the script import the geometry (brushes and patches) of the worldspawn of the clip model map into your map, and ignores the rest (models, func_*) (actually it could even import that but I don't see any use for it)

theRipper wrote:this should be a plugin for radiant :>


most of the script is about parsing the map file and some 3D maths and all that already exits in radiant so that should not be very difficult to do.
nemNEMnem wrote:yeah, not like ur avatar, gsigms, i find ur ones is difficult to masturbate, too. :D :D :D :D

MajkiFajki

Re: semi automatic model cliping

Post by MajkiFajki »

My friend, open source developer, PhD in programming and stuff stuff once:
Good programmer is lazy. If he has to make 100 similar operations, he writes a script for that.

User avatar
DagF
Posts: 277
Joined: Thu Aug 18, 2011 8:40 am
Location: Norway
Contact:

Re: semi automatic model cliping

Post by DagF »

I am trying to figure this out :P

I have had this in mind, well creating blocks with notepad in mind all since i got back to school.
We are playing around with 3d vectors in maths.

I am trying to move a block from one location to where a model just to see if i can manage.
I would very much like to have a look at your code if you dont mind. I dont know python, but i think i know kodeing well enough to see what you are doing :)

This is a really fun project! Thanks for sharing :D
Image

Post Reply