I was wondering if a developer could help add a feature to the opensource darkplaces engine. Model cutting and model deforms.
I would like to add an axe to a mod I'm working on. I've allready added 4 other ancient weapons including caltrops and a torch that burns, gives light, and extinguishes in water, also other bludgeon weapons and ancient ranged weapons.
I cannot add an axe or a sword however because it would not be any different than the bludgeon weapons without some darkplaces engine modifications: the axe needs to cut and cleave that which it is brought against, for this there need to be routines in the darkplaces engine that cut things via a plane and then either loop-fill the hole or just mirror the new model on the inside with a blood texture (easier) (depending on species).
The subroutine would need to accept a few parameters: coords of the cut plane (ofcourse), texture to use for blood, weather to loop-and-fill with new polygons the hole or to just copy-reverse the new model(s) and make an interior hull (easier).
This could all be placed in a modeldeforms.c for darkplaces.
Other deforms that would be nice could be: shatter (model is reduced to collections of it's triangles), shrink/expand, collapse (think disolve in acid, model is collapsed/shrunk towards the bones), cave-in (radius is given and point, any part of the model that is in this radius is collapsed away, thus looking like a cave-in).
Here's a zip of just the engine: http://ompldr.org/vZ2R0dA/darkplacesforxonotic.zip
But here is how to download the whole game with all the source (the darkplaces directory has the engine):
This is what other developers for darkplaces suggested:
\ By model cutting, what are you referring to?
\ laser scalpels
\ Seemingly that shouldn't be terribly difficult to implement
\ human or animal models? there is an important ethical difference
\ For the physics system being used, you'd create a new actor or entity to handle the newly created pile of guts or whatever.
\ no sane person wants to experiment on human models
\ but a cute dog model...
\ Let's say you chopped off a leg.
\ You'd need to load up the model's verticies, create a clipping plane for the slice, and designate which polygons were affected
\ Two new models would need to be created,
\ The "hole" in the leg would need to be filled with an appropriate "blood and guts" textured mesh
\ You'd probably designate a particle system for the center of the newly created hole, at which point blood gushes out.
* LordHavoc has quit ("Client exiting")
\ The physics system would take care of the collision of either mesh.
* LordHavoc (\~email@example.com) has joined #darkplaces
* Caleb gives channel operator status to LordHavoc
\ Something to that effect.
\ Obviously there'd be more to it, but overall, I'd probably code it in those steps.
\ As for the actual slicing and filling of the model, I'm sure there are papers around for that.
\ no, none.
\ I just want.... model cutting and deforms
\ and I.. don't know how to do this
\ oh, is that all?
\ suppsidly it's easy
\ that's all
\ aye, it is really easy...
\ doing it in realtime in a persistant manner on the other hand...
\ especially if you want the severed limb to fall on the ground instead of instantly vanishing in an immersion breaking way
\ be given an entity and fall on ground like a gib
\ (doesn't need to be properly min/maxed or anything)
\ if you have a mesh and a plane to cut along, you can test the distance from the point, and figure out the fraction and midpoint
\ problem is that in an animating mesh, that mid point moves.
\ and the plane bends too.
\ and the animations kinda expect there to still be an arm or whatever to counter balance the animation's momentum, etc
\ could still keep the bone there?
\ (but no verts )
\ I made a thread here http://forums.xonotic.org/showthread.php?tid=3666 about that
\ but whatever's simple is fine too, something is better than nothing
\ easiest way is to likely build the mesh, figure out the interpolant values, and then generate a completely new mesh from the original mesh. then import animations from the origional model into your new mesh.
\ if animation can't be done this could just be a death effect which wouldn't be called unless the blow's dmg reduced theirs to less than 0
\ Spoike1, in the engine?
\ using vertex weights to figure out the new midpoint of the lines on the cuts
\ may I post these things to that thread (so others can read the ideas?)
\ do whatever you want, so long as I don't have to stop being lazy.
\ are there any turtorials on darkplaces I can read to learn how do work with it and maybe do this
The game and engine are GPL licensed, so virtually anything can be done with it.
Here's a crosspost to where discussion has taken place: