Scripts / quaternion library

Author
Message
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 9th Dec 2016 21:30 Edited at: 12th Dec 2016 17:54
To use just add the following to your script:



Provides some useful quaternion functions.

Example of use:



If none of that means anything to you then you probably don't need this.

I may add LERPs and SLERPs at some point, if anyone has a use for them.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Dec 2016 09:56
Could you use this to make a function to tell if the player is looking at something in all 3 angles?
If you can give it a modifiable leeway that would be great too.
Currently i only have a function that works for the y angle.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 10th Dec 2016 10:24
You could but its a bit over the top for that probably.

In my pickuppable script I work out where the real centre of an entity is (as an offset from the entities origin point) and store it. Then I work out where the player is looking (which only works in First Person, haven't figured it out for 3rd person yet) and check if that vector passes close to any entities centre (only need check those entities within a certain distance and 'in front') then I pick the closest entity of those.

When I've updated my scripts to incorporate quaternion math for the rotation aspects I'll post them all up here.

In the meantime here is the part that figures out if the player is looking at an entity:



Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 12th Dec 2016 17:51
Library updated to remove a wee buglet.

For those who may be interested here is the code that displays the 'jets' from the nozzles in my little moonlander demo



Go on admit it, you thought it would be a lot longer than that didn't you?

Here is the code for the Rotate3D function:


Someone might find it useful, the angles are in radians btw, pass in the x, y, z values (for example the offsets from centre of an entity to the entities rotation point) and the Euler angles (i.e math.rad(Entity,anglex) etc) and it will return back the rotated offsets, simply subtract them from the Entities x, y, z values to find the centre of the entity.

Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-12-23 03:17:57
Your offset time is: 2024-12-23 03:17:57