SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Need help with spatial geometry (https://forum.sa-mp.com/showthread.php?t=663539)

 Lunoxx 04/02/2019 01:28 AM

Need help with spatial geometry

Hello, I`m trying to make a crane system, it`s complete, but, I need help to get REAL position of crane magnet, this magnet is an attached object to another object and I don`t know how I can get real position, not attached offsets.
Is any method?

Thank you! :)

 Kaliber 04/02/2019 08:25 AM

Re: Need help with spatial geometry

When i am not complete wrong, its just the x,y,z of the crane +offsetX, +offsetY, +offsetZ of the magnet :)

 Lunoxx 04/02/2019 08:51 PM

Re: Need help with spatial geometry

Quote:
 Originally Posted by Kaliber (Post 4080763) When i am not complete wrong, its just the x,y,z of the crane +offsetX, +offsetY, +offsetZ of the magnet :)
Good idea, I tried right now, but, don`t work.. :(

Quote:
 Originally Posted by ****** (Post 4080764) Assuming the crane rotates, you need trigonometry. Look up how to find a point on a circle.
Can you give me a small example, please?

Re: Need help with spatial geometry

This is what I use create an explosion infront of the player. Not sure how good it is but it works, i think if you mess around with the code and the formula enough you can make your thing work.

PHP Code:

``` new Float:x; new Float:y; new Float:z; new Float:PlayerFacingAngle; new const Float:DISTANCE = 3.0; GetPlayerFacingAngle(playerid, PlayerFacingAngle); PlayerFacingAngle = PlayerFacingAngle-180.0; new Float:F_FLOATSIN = floatsin(-PlayerFacingAngle, degrees); new Float:F_FLOATCOS = floatcos(-PlayerFacingAngle, degrees); F_FLOATSIN = -F_FLOATSIN; F_FLOATCOS = -F_FLOATCOS; GetPlayerPos(playerid, x, y ,z); CreateExplosion(x + DISTANCE * F_FLOATSIN, y + DISTANCE * F_FLOATCOS, z, 6, 0);  ```

 IstuntmanI 04/02/2019 09:37 PM

Re: Need help with spatial geometry

Maybe you need this exact same thing: https://forum.sa-mp.com/showthread.php?t=586841.

 Lunoxx 04/02/2019 10:05 PM

Re: Need help with spatial geometry

Quote:
 Originally Posted by IstuntmanI (Post 4080874) Maybe you need this exact same thing: https://forum.sa-mp.com/showthread.php?t=586841.
Thank you verry much!
Now, I need to know real rotations of attached object.

 Pottus 05/02/2019 01:48 AM

Re: Need help with spatial geometry

Quote:
 Originally Posted by Lunoxx (Post 4080878) Thank you verry much! Now, I need to know real rotations of attached object.
Using that function isn't going to help you then! You need something else.

https://github.com/Pottus/Texture-St...dio/tsmain.pwn
Line 1610

Code:

`AttachPoint(Float:offx, Float:offy, Float:offz, Float:offrx, Float:offry, Float:offrz, Float:px, Float:py, Float:pz, Float:prx, Float:pry, Float:prz, &Float:RetX, &Float:RetY, &Float:RetZ, &Float:RetRX, &Float:RetRY, &Float:RetRZ, sync_rotation = 1)`
The first six parameters is your attached object's XYZ/RXRYRZ offsets the next 6 parameters is the XYZ/RXRYRZ in which the the attached object is attached to.

Returns the actual position xyz/rxryrz of the attached object.

 Lunoxx 05/02/2019 02:00 PM

Re: Need help with spatial geometry

I did something like: https://i.imgur.com/KQYZLSn.png, for test.. but, don`t work. Returns is only attached offsets of magnet. What`s wrong in my code?
Thank you for your response! :)

@Pottus

 Pottus 05/02/2019 02:57 PM

Re: Need help with spatial geometry

Quote:
 Originally Posted by Lunoxx (Post 4080940) I did something like: https://i.imgur.com/KQYZLSn.png, for test.. but, don`t work. Returns is only attached offsets of magnet. What`s wrong in my code? Thank you for your response! :) @Pottus
Because you are using two sets of offsets that is not that this function does! You need to calculate from a static XYZ/RXRYRZ point for this to work.

 Lunoxx 05/02/2019 04:08 PM

Re: Need help with spatial geometry

Quote:
 Originally Posted by Pottus (Post 4080954) Because you are using two sets of offsets that is not that this function does! You need to calculate from a static XYZ/RXRYRZ point for this to work.
I tried to calculate position for Crane Cabine, from crane base which is an real object, single "real object" from this crane, but, returns is invalid position, I will try again, probably I used wrong parameters.

All times are GMT. The time now is 05:33 PM.