Raised This Month: $ Target: $400
 0% 

Get proper model size for creating accurate bounding box


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 03-29-2014 , 10:30   Get proper model size for creating accurate bounding box
Reply With Quote #1

Hello everybody,

I want to place a model at the map and want it to take damage and execute a function when it's health under a fixed amount.
My problem is, players can go through the model and the model / entity does not take damage.
So my question is, how do I get the proper size of the model to make a accurate box?

My current code :

PHP Code:
new Floatmins[3] = {-12.0, -12.00.0 // Not accurate
new Floatmaxs[3] = { 12.012.075.0 }  // Not accurate

entity_set_model(iEntCORE_MODEL)
entity_set_origin(iEntg_flTCoreOrigin); 
                
entity_set_float(iEntEV_FL_takedamage1.0); 
entity_set_float(iEntEV_FL_health2000.0); 
        
entity_set_size(iEntminsmaxs); // Not accurate
entity_set_int(iEntEV_INT_solidSOLID_BBOX); // does not do anything? 
__________________

Last edited by Kia; 03-29-2014 at 10:30.
Kia is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 03-29-2014 , 10:48   Re: Get proper model size for creating accurate bounding box
Reply With Quote #2

Maybe you can fix it by looking at the blockmakers codes.
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 03-29-2014 , 11:00   Re: Get proper model size for creating accurate bounding box
Reply With Quote #3

Quote:
Originally Posted by ironskillz1 View Post
Maybe you can fix it by looking at the blockmakers codes.
afaik, it has fixed boxes since it is a cube-shaped model. My model isn't.
__________________
Kia is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 03-29-2014 , 11:57   Re: Get proper model size for creating accurate bounding box
Reply With Quote #4

you can only make cube shaped solids
jimaway is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 03-29-2014 , 12:23   Re: Get proper model size for creating accurate bounding box
Reply With Quote #5

Well okay, but how do I get the size of my model?
__________________
Kia is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-29-2014 , 12:23   Re: Get proper model size for creating accurate bounding box
Reply With Quote #6

Try GetModelBoundingBox or GetModelCollisionBox. (1.8.3, .inc : https://hg.alliedmods.net/amxmodx-ce...emeta.inc#l548)
__________________
Arkshine is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 03-29-2014 , 12:57   Re: Get proper model size for creating accurate bounding box
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
Try GetModelBoundingBox or GetModelCollisionBox. (1.8.3, .inc : https://hg.alliedmods.net/amxmodx-ce...emeta.inc#l548)
Thanks, I will try that.

EDIT : Does not work, I can still run through it. Maybe it is a issue with the model?

PHP Code:
while((iEnt find_ent_by_class(iEntENTITY_TERROR_CORE))) 
            {
                
g_iTCoreEnt iEnt
                
                entity_set_model
(g_iTCoreEntCORE_MODEL)
                
entity_set_origin(g_iTCoreEntg_flTCoreOrigin); 
                
                
entity_set_float(g_iTCoreEntEV_FL_takedamage1.0); 
                
entity_set_float(g_iTCoreEntEV_FL_health2000.0); 
                
                
GetModelCollisionBox(g_iTCoreEntminsmaxs// GetModelBoundingBox did not work too.
                
entity_set_size(g_iTCoreEntminsmaxs); 
                
entity_set_int(g_iTCoreEntEV_INT_solidSOLID_BBOX); 
                
                
drop_to_floor(g_iTCoreEnt)
                
ClCMD_sm(id)
            } 
PHP Code:
if(GetModelBoundingBox(g_iTCoreEntminsmaxsModel_DefaultSize))
                    
client_print(idprint_console"%i %i %i - %i %i %i"mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2]) 
Returns : 0 0 0 - 0 0 0
__________________

Last edited by Kia; 03-30-2014 at 08:13.
Kia is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 04-27-2014 , 12:58   Re: Get proper model size for creating accurate bounding box
Reply With Quote #8

Bump.
__________________
Kia is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 04-27-2014 , 13:18   Re: Get proper model size for creating accurate bounding box
Reply With Quote #9

PHP Code:
"%i %i %i - %i %i %i" 
Aren't mins and maxs supposed to be floats?
Or maybe try
PHP Code:
native SetModelCollisionBox(entity); 
Code:
/**
* Sets entity size to the models collision box.
*
* @param entity        The entity index to set the value on.
* 
* @return              1 on success, 0 on faillure.
* 
* @error               Invalid entity.
*                      Invalid model pointer.
*/
I believe that is also in 1.8.3.
And for moderators: it should be "failure", not "faillure" in @return line.

Last edited by klippy; 04-27-2014 at 13:22.
klippy is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-27-2014 , 14:18   Re: Get proper model size for creating accurate bounding box
Reply With Quote #10

native GetModelBoundingBox(entity, Float:mins[3], Float:maxs[3], sequence = Model_DefaultSize);

I see well Float:.

@KliPPy, thanks for the typo.
__________________
Arkshine is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:03.


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