29.08.2011, 14:32
[Plugin] [REL] Math Plugin
29.08.2011, 14:51
(
Последний раз редактировалось Kar; 29.08.2011 в 19:14.
)
Quote:
Some questions:
1) Could you please make a MPDistance2D? 2) Is MPDistance faster than PointToPoint3D in the PointToPoint plugin? 3) How is MPFDistance less accurate? :S Can you please give me examples of what MPDistance and MPFDistance will return using the same coordinates? 4) Does MPGetTrailerTowingVehicle loop through all vehicles to find the towing vehicle or do you keep track of trailers using OnPlayerUpdate and OnUnoccupiedVehicleUpdate? Thanks |
3.
pawn Код:
printf("%0.2f", MPClamp360(361.0));
new Float:distance[4];
distance[3] = MPFDistance(0.0, 0.0, 0.0, 100.0, 100.0, 100.0);
distance[0] = MPFDistance(0.0, 0.0, 0.0, 1000.0, 1000.0, 1000.0);
distance[1] = MPFDistance(0.0, 0.0, 0.0, 2000.0, 2000.0, 3000.0);
distance[2] = MPFDistance(0.0, 0.0, 0.0, 3000.0, 3000.0, 3000.0);
printf("MPFDistance: 0.0 - 100.0: %f - 0.0 - 1000.0: %f - 0.0 - 2000.0: %f - 0.0 - 3000.0: %f", distance[3], distance[0], distance[1], distance[2]);
distance[3] = MPDistance(0.0, 0.0, 0.0, 100.0, 100.0, 100.0);
distance[0] = MPDistance(0.0, 0.0, 0.0, 1000.0, 1000.0, 1000.0);
distance[1] = MPDistance(0.0, 0.0, 0.0, 2000.0, 2000.0, 3000.0);
distance[2] = MPDistance(0.0, 0.0, 0.0, 3000.0, 3000.0, 3000.0);
printf("MPDistance: 0.0 - 100.0: %f - 0.0 - 1000.0: %f - 0.0 - 2000.0: %f - 0.0 - 3000.0: %f", distance[3], distance[0], distance[1], distance[2]);
pawn Код:
[10:50:22] 1.00
[15:13:13] MPFDistance: 0.0 - 100.0: 173.204788 - 0.0 - 1000.0: 1732.046386 - 0.0 - 2000.0: 4123.093261 - 0.0 - 3000.0: 5196.132324
[15:13:13] MPDistance: 0.0 - 100.0: 173.205078 - 0.0 - 1000.0: 1732.050781 - 0.0 - 2000.0: 4123.105468 - 0.0 - 3000.0: 5196.152343
4. Look at the source code for it
29.08.2011, 18:27
when you use F variants of function (fast) you sacrifice some precision for speed.
15.11.2011, 14:17
Can you make a similar functions to detect vehicles too? native MPGetAimTarget(PlayerID, Float:SeekRadius = 50.0);
15.11.2011, 15:25
superb , gonna try some codes
thank you for it 3))
thank you for it 3))
17.11.2011, 08:45
I've problem in FMPVecLength when I update this plugin, and recompiled my gamemode.
Here's crashdetect log:
MathPlugin.inc:
Sorry if it is reported or has a solution already.
Edit:
I've checked the source code and I found that there's a typo in your MathPlugin.inc:
Here's crashdetect log:
Код:
[17:46:46] Script[gamemodes\scfri.amx]: During execution of OnGameModeInit(): [17:46:46] Script[gamemodes\scfri.amx]: Run time error 19: "File or function is not found" [17:46:46] Additional information: [17:46:46] The following natives were not registered: [17:46:46] FMPVecLength [17:46:46] Script[gamemodes\scfri.amx]: During execution of main(): [17:46:46] Script[gamemodes\scfri.amx]: Run time error 19: "File or function is not found" [17:46:46] Additional information: [17:46:46] The following natives were not registered: [17:46:46] FMPVecLength
pawn Код:
// game helpers
native Float:MPDistanceCameraToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ); // calculates how distant target aim is from camera data pointed towards a certain point
native Float:MPGetVehicleUpsideDown(vehicleid); // returns values such as 1.0 as pointing up, -1.0 is totally upside down. returns -5.0 if car id is not 1..2000.
native MPGetAimTarget(PlayerID, Float:SeekRadius = 50.0); // returns player that this player is aiming at or invalid player id if no player in target area.
native MPGetTrailerTowingVehicle(vehicleid); // finds the vehicle that this trailer is attached to, returns invalid_vehicle_id if invalid or not attached to any towing vehicle.
native MPGetVehicleDriver(vehicleid); // gets vehicle driver id or invalid player id - does a quick reverse vehicle to player id lookup.
native MPGetVehicleDriverCount(vehicleid); // returns number of drivers a car has (important to solve 2 drivers 1 car issue - if you wrote any decent anticheat you know what i mean)
native MPGetVehicleOccupantCnt(vehicleid); // returns number of player a vehicle is carrying
native MPGetVehicleSurfersCnt(vehicleid); // returns number of players surfing a vehicle
native MPProjectPointOnVehicle(vehicleid, Float:v1x, Float:v1y, Float:v1z, &Float:resx, &Float:resy, &Float:resz, worldspace = 0); // projects a point on vehicle's rotation on all 3 axes.
native MPProjectPointOnPlayer(playerid, Float:v1x, Float:v1y, Float:v1z, &Float:resx, &Float:resy, &Float:resz); // projects a point on player's facing angle (x - sideways, y front/back, z = up/down).
// pure math
native Float:FMPVecLength(Float:v1x, Float:v1y, Float:v1z); // calculates length of a simple XYZ 3d vector (FAST,less precision)
native Float:MPClamp360(Float:value);
native Float:MPDistance(Float:v1x, Float:v1y, Float:v1z, Float:v2x, Float:v2y, Float:v2z); // distance between 2 points
native Float:MPDistancePointLine(Float:PointX, Float:PointY, Float:PointZ, Float:LineSx, Float:LineSy, Float:LineSz, Float:LineEx, Float:LineEy, Float:LineEz); // http://paulbourke.net/geometry/pointline/ returns super huge number 10000000 if outside of range of specified the lie segment.
native Float:MPDotProduct(Float:v1x, Float:v1y, Float:v1z, Float:v2x, Float:v2y, Float:v2z);
native Float:MPFDistance(Float:v1x, Float:v1y, Float:v1z, Float:v2x, Float:v2y, Float:v2z); // distance between 2 points (faster but less precise)
native Float:MPFSQRT(Float:value); // Faster sqrt (****** the 0x5f3759df method)
native Float:MPVecLength(Float:v1x, Float:v1y, Float:v1z); // calculates length of a simple XYZ 3d vector
native MPCrossProduct(Float:v1x, Float:v1y, Float:v1z, Float:v2x, Float:v2y, Float:v2z, &Float:resx, &Float:resy, &Float:resz);
native MPFNormalize(&Float:vx, &Float:vy, &Float:vz); // fast float normalization of a vector to unit-length (makes whatever vector 1.0 long, purely to preserve direction and be able to scale it controllably)
native MPInterpolatePoint(Float:v1x, Float:v1y, Float:v1z, Float:v2x, Float:v2y, Float:v2z, &Float:resx, &Float:resy, &Float:resz, Float:distance);
Edit:
I've checked the source code and I found that there's a typo in your MathPlugin.inc:
Код:
native Float:MPFVecLength(Float:v1x, Float:v1y, Float:v1z);
22.12.2011, 21:56
Is this plugin still in beta/WIP state? and does it support 0.3d?
23.12.2011, 04:07
23.12.2011, 22:54
Are there any known bugs with it?
24.12.2011, 16:54
Probably no. However, it uses an old version of sampgdk if I am right.
03.01.2012, 23:30
I don't really understand this native
can you do an example in a callback?
pawn Код:
native Float:MPDistanceCameraToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ); // calculates how distant target aim is from camera data pointed towards a certain point
04.01.2012, 00:35
Put camera position in Cam_, the position of the object (or point) in Obj_ and the camera front vector in Fr_.
04.01.2012, 00:44
Thanks, is creative ^^
04.01.2012, 01:05
09.06.2012, 12:11
Please, help me. I don't understand, why does it happens . Please, fix it
pawn Код:
stock function( playerid, vehicleid )
{
new
Float:offsetPos[ 3 ],
Float:result[ 3 ]
;
GetVehicleModelInfo( GetVehicleModel( vehicleid ), VEHICLE_MODEL_INFO_WHEELSFRONT, offsetPos[ 0 ], offsetPos[ 1 ], offsetPos[ 2 ] );
MPProjectPointOnVehicle( vehicleid, offsetPos[ 0 ], offsetPos[ 1 ], offsetPos[ 2 ], result[ 0 ], result[ 1 ], result[ 2 ], 1 );
printf( "%f %f %f", result[ 0 ], result[ 1 ], result[ 2 ] );
CreateObject( 324, result[ 0 ], result[ 1 ], result[ 2 ], 0.0, 0.0, 0.0 );
return false;
}
04.10.2012, 19:55
Any chance we can get the source with the sampgdk folders included? I wanted to add this to MPGetAimTarget Nero3d's GetPlayerCameraWeaponVector so that way the aim target will be accurate with weapons but I can not get the project to compile with MSVC. (Has to do with paths not being correct)
01.02.2013, 18:14
erm erm... where's the source code? :/
02.02.2013, 10:25
25.03.2015, 12:14
(
Последний раз редактировалось JernejL; 25.03.2015 в 19:45.
)
Since ****** code is shutting down i've ported the project over to github.
I added a few natives that can deal with NaN and Inf floats.
I added a few natives that can deal with NaN and Inf floats.
« Next Oldest | Next Newest »
Users browsing this thread: 2 Guest(s)