SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 18/08/2015, 09:12 PM   #1
Crayder
High-roller
 
Crayder's Avatar
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,860
Reputation: 602
Default Model Sizes Plus

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.
__________________________________________________ __________________________________________________

Note:

Don't use this if you already have ColAndreas! Just simply implement the following:
pawn 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:


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:

pawn Code:
GetColSphereRadius(objectmodel);
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.

pawn 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.

pawn 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.

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

pawn 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):
pawn Code:
for (new i, c = GetColCount(); i != c; ++i)
{
    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.
__________________________________________________ __________________________________________________

For regular, advanced version go here!
For database mode go here!
Table of extreme range differences (only above 1).
__________________
Those who deserve reputation, do not need to beg for it.
Also, don't expect the help you need when offering reputation, you'll just be attracting Rep Hunters.
Join SA-MP Discord!

Last edited by Crayder; 13/10/2015 at 02:08 AM.
Crayder is offline   Reply With Quote
Old 23/08/2015, 09:37 PM   #2
Crayder
High-roller
 
Crayder's Avatar
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,860
Reputation: 602
Default Re: New Model Sizes

Update, adds GetModelBoundingBox and GetModelColDimensions.
Each face returned by GetModelBoundingBox touches a point on the object models, so yes they are exact. Just like the new collision spheres, which touch the least amount of outermost points that a sphere can, they are exact (as said before).
__________________
Those who deserve reputation, do not need to beg for it.
Also, don't expect the help you need when offering reputation, you'll just be attracting Rep Hunters.
Join SA-MP Discord!
Crayder is offline   Reply With Quote
Old 23/08/2015, 09:42 PM   #3
Variable™
Gangsta
 
Variable™'s Avatar
 
Join Date: Jul 2015
Location: Somewhere...
Posts: 682
Reputation: 128
Default Re: New Model Sizes

Nice
Variable™ is online now   Reply With Quote
Old 23/08/2015, 09:52 PM   #4
JeaSon
Gangsta
 
JeaSon's Avatar
 
Join Date: Aug 2013
Location: Future
Posts: 564
Reputation: 79
Default Re: New Model Sizes

Great man
__________________
Server:23.94.215.9:7777
Social Media:
Other:
My Works
JeaSon is offline   Reply With Quote
Old 24/08/2015, 06:40 AM   #5
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Portugal
Posts: 7,197
Reputation: 775
Default Re: New Model Sizes

Sweet, thanks for this

Nice work all of you.



TS is already using it?
PT is offline   Reply With Quote
Old 24/08/2015, 07:27 AM   #6
ExTaZZ69
Big Clucker
 
ExTaZZ69's Avatar
 
Join Date: Mar 2015
Location: Romania
Posts: 150
Reputation: 23
Default Re: New Model Sizes

Very nice
ExTaZZ69 is offline   Reply With Quote
Old 24/08/2015, 10:53 AM   #7
Crayder
High-roller
 
Crayder's Avatar
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,860
Reputation: 602
Default Re: New Model Sizes

Quote:
Originally Posted by PT View Post
TS is already using it?
It will I just haven't uploaded it.

@Everyone else, thanks. Do any of you have any suggestions on what model info would be useful?
__________________
Those who deserve reputation, do not need to beg for it.
Also, don't expect the help you need when offering reputation, you'll just be attracting Rep Hunters.
Join SA-MP Discord!
Crayder is offline   Reply With Quote
Old 24/08/2015, 12:50 PM   #8
kurta999
High-roller
 
kurta999's Avatar
 
Join Date: Apr 2009
Location: Slovakia (HU)
Posts: 1,420
Reputation: 626
Default Re: New Model Sizes

This is very good! Far better than original

Will be implemented into R15 YSF. I use this script to optimize objects draw distance, the result is amazing.

Code:
forward OptimizeObjectsDrawDistance();
public OptimizeObjectsDrawDistance()
{
	new
	    modelid, Float:distance, Float:distance2;

	for(new i = 0, j = Streamer_GetUpperBound(STREAMER_TYPE_OBJECT); i != j; i++)
	{
		if(!IsValidDynamicObject(i)) continue;

        Streamer_GetFloatData(STREAMER_TYPE_OBJECT, i, E_STREAMER_STREAM_DISTANCE, distance);
        Streamer_GetFloatData(STREAMER_TYPE_OBJECT, i, E_STREAMER_DRAW_DISTANCE, distance2);
		if(distance < 0.0 || distance2 > 300.0)
		{
			//printf("skip object: %d", i);
			continue;
		}


		modelid = Streamer_GetIntData(STREAMER_TYPE_OBJECT, i, E_STREAMER_MODEL_ID);

		distance = (GetColSphereRadius(modelid) * 25.0);

		if(distance < 100.0)
		    distance = 100.0;

                // NEVER NEVER NEVER USE DRAW DISTANCE BIGGER THAN 300 IF YOU HAVE LOT OF OBJECTS - crash.
	 	else if(distance > 299.0) // 500
			distance = 299.0;

		Streamer_SetFloatData(STREAMER_TYPE_OBJECT, i, E_STREAMER_STREAM_DISTANCE, distance);
		Streamer_SetFloatData(STREAMER_TYPE_OBJECT, i, E_STREAMER_DRAW_DISTANCE, distance);
	}
	printf("<< MFR >> All objects draw distance has beeen optimized");
}
__________________
I don't play and have ANY interest in SA:MP anymore! Please do not ask for help, because I'm not going to reply.
kurta999 is offline   Reply With Quote
Old 14/09/2015, 11:19 PM   #9
Crspy
Little Clucker
 
Join Date: Aug 2015
Posts: 4
Reputation: 0
Default Re: New Model Sizes

Great , just great.
Crspy is offline   Reply With Quote
Old 14/09/2015, 11:59 PM   #10
IDarkness
Huge Clucker
 
IDarkness's Avatar
 
Join Date: Jul 2014
Posts: 198
Reputation: 71
Default Re: New Model Sizes

thanks for upgrading it +REP
__________________
Its all about me.
IDarkness is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Model Sizes Emmet_ Includes 9 16/08/2015 11:28 PM
[Include] Model Sizes Abagail Includes 20 05/06/2015 06:19 AM
Finding best corresponding object using Y_Less' object model sizes? knackworst Scripting Help 0 18/11/2014 01:46 PM
Array sizes. Scarred Scripting Help 2 01/01/2012 05:04 AM


All times are GMT. The time now is 06:23 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.