What is BMOD?
BMOD allows amxx developers to use physics engine (Bullet) inside their plugin. There are few videos, so you can get the idea, what kind of things can be achieve with this:
http://www.youtube.com/watch?v=WxbXrLsKFGQ
http://www.youtube.com/watch?v=Nn26KkoIGNY
http://www.youtube.com/watch?v=pAocm7bZszs
http://www.youtube.com/watch?v=CUmNRsVro1U
http://www.youtube.com/watch?v=vUCIKGlyDBQ
http://www.youtube.com/watch?v=fAJlHJehlI8
How does it work?
There is an API which gives you the ability to create dynamic, static or kinematic objects inside the "bullet world". After creating an dynamic object, you connect it to some entity and this entity now copies the object's movement. Dynamic objects can be used as anything that moves freely, for example pink rubber balls boucing all across the map. In case of static object, no movement is copied, but you can still work with the object, set its properties, etc. These can be used for building the world, making walls or triggers. Kinematic objects are exact opposite of dynamic objects - they copy their entity's movement. That is useful for player collision box or for moving brush entities like doors, trains, etc.
Documentation?
For documentation just grab
latest inc file, everything should be written in there.
Hello world?
Here is a simple example where you can learn how to create static world, dynamic spheres, kinematic player collision box and modify behaviour of some objects (bounciness).
Code:
#include <amxmodx>
#include <amxmisc>
#include <bmod>
#include <engine>
new worldObj
public plugin_init() {
register_concmd("bmod_test","_bmod_test")
//create static bmod object from worldspawn
worldObj = bmod_obj_from_ent(0)
//set world friction and restitution
bmod_obj_call(worldObj, "setFriction", 1.0)
bmod_obj_call(worldObj, "setRestitution", 1.0)
}
public _bmod_test(id){
//create a new entity
new entity = create_entity("func_wall")
entity_set_model(entity,"models/fyzsph.mdl")
//set entity origin 128 units above player
new Float:origin[3]
entity_get_vector(id,EV_VEC_origin,origin)
origin[2]+=128
entity_set_origin(entity,origin)
//set some movetype and nextthink, so entity movement is smoother (because of velocity and avelocity)
entity_set_float(entity,EV_FL_nextthink,86400.0)
entity_set_int(entity,EV_INT_movetype,8)
//create new bmod object
new object = bmod_obj_new("BMOD/sphere/24", 1.0)
//hook entity with bmod object
bmod_obj_assign_ent(object, entity)
bmod_obj_update_pos(object)
//set object friction and restitution
bmod_obj_call(object, "setFriction", 2.0)
bmod_obj_call(object, "setRestitution", 0.88)
}
public client_connect(plr){
//create collision box for a player
new obj = bmod_obj_new("BMOD/box/16/16/36")
bmod_obj_assign_ent(obj, plr)
bmod_obj_set_kinematic(obj, true)
}
public client_disconnect(plr){
bmod_obj_delete(bmod_obj_by_ent(plr))
}
public plugin_precache(){
precache_model("models/fyzsph.mdl")
}
More?
Download bmod_test.zip form the attached files. It contains more complicated example and also that
fyzsph.mdl you might be looking for.
You can also check out
CrateNade plugin.
Latest binaries/source
Download latest binaries from
GitHub (
windows,
linux).
Download latest amxx include file from
Github.
View latest source at
GitHub.
Additional info
Your feedback, wishes and english mistakes corrections are appreciated!
Current linux release requires
Bullet shared libraries to be put into hlds root directory. If there is anyone who can recompile this module for linux without the need for bullet shared libs, your help is very welcome.
Attached zip file might be several years old and contain some serious bugs.
If you're looking for old-api bmod, see
legacy branch. It's full of bugs and has been discontinued.
Thanks joropito for helping me with GitHub and other support.