AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Module: BMOD - Extended Physics Module (https://forums.alliedmods.net/showthread.php?t=178066)

Backup 02-10-2012 16:11

Module: BMOD - Extended Physics Module
 
2 Attachment(s)
https://github.com/jonatan1024/bgmod..._logo/bmod.png

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.

mabaclu 02-10-2012 16:33

Re: Module: BMOD - Extended Physics Module
 
Finally released! Good job!

.Dare Devil. 02-10-2012 17:07

Re: Module: BMOD - Extended Physics Module
 
I just cant belive it,

this is better than hl2 Physics omg.
Good job!

hleV 02-10-2012 17:14

Re: Module: BMOD - Extended Physics Module
 
Sweet!

zeus 02-10-2012 17:42

Re: Module: BMOD - Extended Physics Module
 
Awsome work dude !!
We apreciate
http://assets.diylol.com/hfs/f07/478...ome-99ecc3.jpg

xPaw 02-11-2012 04:50

Re: Module: BMOD - Extended Physics Module
 
Quote:

Originally Posted by .Dare Devil. (Post 1648059)
this is better than hl2 Physics omg.

Let's get real, it is not better than HL2 physics.

.Dare Devil. 02-11-2012 08:39

Re: Module: BMOD - Extended Physics Module
 
Quote:

Originally Posted by xPaw (Post 1648248)
Let's get real, it is not better than HL2 physics.

I tested it and tested hl2 physics.
And i take back my words :):):):):):)

But this module here, is so fucking awsome.
That bounce balls and spike physics is so nice.

I think it is impossible on hl2 physics :)
that way i said that is better than hl2 physics.

HL2 physics are too real :)
but better player touch...

Steelec 02-11-2012 09:25

Re: Module: BMOD - Extended Physics Module
 
Awesome! Wery NICE! GJ ;)

Kiske 02-12-2012 07:05

Re: Module: BMOD - Extended Physics Module
 
EXCELENT!

You upload the plugin that samples in the video: http://www.youtube.com/watch?v=Nn26KkoIGNY ?
You upload the models/fyzsph.mdl ?

Backup 02-12-2012 08:37

Re: Module: BMOD - Extended Physics Module
 
1 Attachment(s)
Quote:

Originally Posted by Kiske (Post 1648872)
EXCELENT!

You upload the plugin that samples in the video: http://www.youtube.com/watch?v=Nn26KkoIGNY ?
You upload the models/fyzsph.mdl ?

Code:

#include <amxmodx>
#include <engine>
#include <bmod>

public plugin_init() {
    register_plugin("bmod_test","0","asdf")
    register_concmd("bmod_test","_bmod_test")
}

new i=0

public _bmod_test(id){
    new entity = create_entity("func_wall")
    switch(i%5){
        case 0:{
            entity_set_model(entity,"models/fyzsph.mdl")
        }
        case 1:{
            entity_set_model(entity,"models/fyzbox.mdl")
        }
        case 2:{
            entity_set_model(entity,"models/fyzcyl.mdl")
        }
        case 3:{
            entity_set_model(entity,"models/fyzcap.mdl")
        }
        case 4:{
            entity_set_model(entity,"models/fyzcon.mdl")
        }
    }
    new Float:origin[3]
    entity_get_vector(id,EV_VEC_origin,origin)
    origin[2]+=128
    entity_set_origin(entity,origin)
    entity_set_float(entity,EV_FL_nextthink,86400.0)
    entity_set_int(entity,EV_INT_movetype,8)
    bmod_object_add(entity,i%5,1.0,24.0,24.0,24.0)
    i++
}

public plugin_precache(){
    precache_model("models/fyzsph.mdl")
    precache_model("models/fyzbox.mdl")
    precache_model("models/fyzcyl.mdl")
    precache_model("models/fyzcap.mdl")
    precache_model("models/fyzcon.mdl")
}



All times are GMT -4. The time now is 13:37.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.