[Include] GetObjectOffset!
#1

This is a rewritten version of my old GetObjectOffset include. This should be more: optimized, user friendly, accurate. Unlike the old version, the two main functions are merged between regular & dynamic objects. For now, streamer must be accessible as an include. It will attempt to include and if the CreateDynamicObject function can not be found, give a compiler error. If dynamic functions aren't used, streamer won't need to run as a plugin. Simple, right?

Pull requests are welcome if you have something to contribute. At this time, rotation offsets aren't supported.

Functions:

Internal:
  • static stock GetPosOffset(Float: p_p_x, Float: p_p_y, Float: p_p_z, Float: p_c_x, Float: p_c_y, Float: p_c_z, &Float:p_n_x, &Float:p_n_y, &Float: p_n_z)
External:
  • stock IsObjectInRangeOfPlayer(playerid, bool: isdynamic, objectid, Float: radius)
  • stock GetObjectOffsetFromPoint(objectid, bool: isdynamic, Float: cur_x, Float: cur_y, Float: cur_z, &Float: ret_x, &Float: ret_y, &Float: ret_z)
  • stock GetObjectOffset(objectid, bool: isdynamic, extratype, extraid, &Float: obj_off_ret_x, &Float: obj_off_ret_y, &Float: obj_off_ret_z)
Definitions:
  • #define OBJECT_EXTRA_TYPE_NONE (0)
  • #define OBJECT_EXTRA_TYPE_PLAYER (1)
  • #define OBJECT_EXTRA_TYPE_VEHICLE (2)
  • #define OBJECT_EXTRA_TYPE_OBJECT (3)
  • #define OBJECT_EXTRA_TYPE_DYNAMIC_OBJECT (4)
Download: GitHub
Reply
#2

IsObjectInRangeOfPlayer < is actually pretty cool saves me time from checking a certain object pos to use isplayerinrangeofpoint, good job i think there was someone earlier asking about a link for this too.
Reply
#3

How can this be used? Can you provide few examples? That would be much appreciated.
Reply
#4

What's the point of a non-directional offset?

If I was trying to make a row of objects based on 2 "base objects", I'd calculate the offset between them and continuously add this offset to the base coords, which would result in the next object's position. But this Include will not allow that since the offsets aren't directional (the values are always positive even if object 2 is west of object 1).

So as a result the offset values can only be used to calculate its length, but not the direction, so my question is:

Why not make the whole include about distances instead of offsets? This offset is useless for any other scenario where I'd want to know the direction of the offset.

Make them directional (so the offset points from Object A to Object B), OR call the functions GetDistanceBetweenObjects and return the distance instead of 3 values that represent the exact same thing.

It's also more efficient to calculate a directional offset than first checking its direction and discarding it either way.
Reply
#5

Quote:
Originally Posted by NaS
Посмотреть сообщение
What's the point of a non-directional offset?

If I was trying to make a row of objects based on 2 "base objects", I'd calculate the offset between them and continuously add this offset to the base coords, which would result in the next object's position. But this Include will not allow that since the offsets aren't directional (the values are always positive even if object 2 is west of object 1).

So as a result the offset values can only be used to calculate its length, but not the direction, so my question is:

Why not make the whole include about distances instead of offsets? This offset is useless for any other scenario where I'd want to know the direction of the offset.

Make them directional (so the offset points from Object A to Object B), OR call the functions GetDistanceBetweenObjects and return the distance instead of 3 values that represent the exact same thing.

It's also more efficient to calculate a directional offset than first checking its direction and discarding it either way.
Thank you, I will update this sometime soon to support both methods.
Reply
#6

This codebase is not currently being maintained as I'm not currently active on SA-MP to make necessary changes. The repository is still available on GitHub if anyone wants to contribute through a pull request.
Reply
#7

What about calculating real world positions of objects attached to objects? Including relative rotations.
Reply
#8

Quote:
Originally Posted by Pottus
Посмотреть сообщение
What about calculating real world positions of objects attached to objects? Including relative rotations.
That can be done with i_quat already
Reply
#9

Quote:
Originally Posted by IllidanS4
Посмотреть сообщение
That can be done with i_quat already
Which pretty much makes this include well inferior
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)