• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Library] Model Sizes Plus - Object Model Size Database
#1
Model Sizes Plus!



Basically said, this is just the better version of the old one.

____________________________________________________________________________________________________



Major Points:


  • Contains SA-MP objects.

  • Extreme precision (see picture below for comparison).

  • Exact offsets.

  • Easy to update with new versions of SA-MP (new objects).

  • Adds exact bounding boxes.

  • Adds exact dimensions.

  • Database version has major speed improvement!

____________________________________________________________________________________________________





Note:



Don't use this if you already have ColAndreas! Just simply implement the following:
Code:
stock Float:GetColSphereRadius(objectmodel)

{

new Float:tmp, rad;

if(0 <= objectmodel <= 19999)

{

CA_GetModelBoundingSphere(objectmodel, tmp, tmp, tmp, rad);

return rad;

}

return 0.0;

}



stock GetColSphereOffset(objectmodel, &Float:x, &Float:y, &Float:z)

{

new Float:tmp;

if(0 <= objectmodel <= 19999)

{

CA_GetModelBoundingSphere(objectmodel, x, y, z, tmp);

return 1;

}

return 0;

}



Precision difference - Object Model 3511:

[Image: VRB9NNb.png?1]



Many (most) other objects are affected also. Many even have differences over 100, A couple have differences over 200! Kalcor can't be blamed for these faults though, he extracted the data directly form the game files.

____________________________________________________________________________________________________





Functions:



Code:
GetColSphereRadius(objectmodel);[/pacoden]This gets the radius of the collision spheres for all the GTA objects used in SA (including the SA:MP objects); except skins, vehicles, and weapons. The collision sphere entirely encompases the object (for example to set the view distance accordingly). Returns 0.0 on invalid models.



[code]GetColSphereOffset(objectmodel, &Float:x, &Float:y, &Float:z);
This gets the offsets of the collision sphere for all objects. This information is kept in a separate array as it is generally less useful than the sphere radius. It indicates where the centre of the collision sphere is relative to the centre of the object, a position set to minimise the size of the sphere relative to the object. Note that you can't accurately calculate the exact center of the collision sphere without the quaternion rotation of the object, that is why this is a separate "stock" array - so it isn't included in the compiled code if not used.



Code:
GetModelBoundingBox(objectmodel, &Float:MinX, &Float:MinY, &Float:MinZ, &Float:MaxX, &Float:MaxY, &Float:MaxZ)
This gets the minimum and maximum points of all objects' collision boxes.



Code:
GetModelColDimensions(objectmodel, &Float:l, &Float:w, &Float:h)
This gets the dimensions of all objects.



Code:
GetColCount();
Gets the total number of models for which collision data is stored.



Usage is VERY simple. For model IDs up to 19999, simply use that number as an index in to the data, any other IDs don't exist (but return 0.0):
Code:
for (new i, c = GetColCount(); i != c; )

{

printf("%f", GetColSphereRadius(i));

new Float:x, Float:y, Float:z;

GetColSphereOffset(i, x, y, z);

printf("%f %f %f", x, y, z);

}

____________________________________________________________________________________________________





Credits:



Thanks to Y-Less and Kalcor for the original release. It got us by for years!

Thanks to Pottus, Chris, and Slice for ColAndreas. Bullet phyiscs' getBoundingSphere function makes this new version possible.

____________________________________________________________________________________________________





Downloads and Links:



For database mode go here! (RECOMMENDED FOR SPEED)

For regular, advanced version go here!



Table of extreme range differences (only above 1).
[Image: uc?export=view&id=1C5dMc9kb09iAUuASWBEPCK21lsedAXmB]

  Reply


Forum Jump: