Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Hyperbolic (spherical) path finding?

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 10th Nov 2021 05:14 Edited at: 10th Nov 2021 05:14
I want to map a path from A to B following the curvature of the sphere (in 3D space), I know the dimension and location of the sphere but currently know diddily squat about the math I am going to need

I just bookmarked a bunch of pages that look like something that I might be able to use but thought I'd ask you guys fi anyone has done anything like this before I spend the entirety of tomorrow studying.

Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Nov 2021 05:19 Edited at: 10th Nov 2021 05:19
What you could do is use FixObjectToObject to attach a sphere to your sphere and then rotate the first sphere
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 10th Nov 2021 05:40 Edited at: 10th Nov 2021 05:51
I did consider that but there will be lots of moving objects so I'd have to give each one its own extra sphere adding too much unneeded geo data on the GPU, I might have better results using a plane and try some gnomonic mapping but again its going to take some research,

Distance from origin might be the best approach, I can get angle data from the collision normal from outside the sphere but mapping the points from the sphere centre wont work with RayCast, unless, maybe 1 extra sphere with inverted normals for the mapping routines ... yeah that could work, right?

Edit: Mental Note to Self

Map line from centre of sphere from A to B then cast a ray along the line to get spherical data on inward facing normal, move object to path point and get angle from outward facing normal, job done!

I wonder if an object with a solidify modifier registers contact with RayCast, or extrude and flip faces ...., looks like I got some experimenting to do, lol
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Nov 2021 03:16 Edited at: 11th Nov 2021 03:59
Do you know the points A and B on the sphere? If not and these are points in space around the sphere, I think it'll be easier to first project them onto the sphere, keeping track of the original point's distance from the surface.

This might help for starters, calculating the distance between the two points along the surface of the sphere:





Example in 2D:




Here's an idea I have. Red (A) is trying to get to green (B). If you draw a straight path between them but then plot those points to the surface of the sphere (the pink dots)








Working example (2D):



Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 11th Nov 2021 04:21
Quote: "Here's an idea I have."


That's pretty much what I have in mind.

Quote: "distance between the two points along the surface of the sphere"


that will come in handy for calculating valid targets in range, nice one, I was just going to hack that with a straight point to point distance but surface distance is so much better

it always helps to have a plan when opening an editor and I got a train day today so can sit and code while on the payroll

Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Nov 2021 02:36 Edited at: 12th Nov 2021 02:37
Humphf!!!

What sound easy in my head is turning out to be quite difficult!!



Edit: and this new lappy does nice screen cap.... might have to start uploading rants!! lmao!!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 12th Nov 2021 06:04
ok what I might do here is add points all around the circle by adding shapes and then getting each line to match each point.

You could even cast a distance to see how far you are from each point.

This is what I would do.

Might take a couple days to do but worth it in the end because you can reuse the same saved shape points.

I had to do this for my other game for collision on slopes.

Shapes do work good if you add them right.

Send me the picture so I can try to add shape points to it if this is what you would like to try.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Nov 2021 07:32
It does not need shapes it needs math, these are not fixed points they will be dynamic and always moving and the paths need to be calculated frame by frame, sure I can manually add a bunch of path nodes and call it a day but.... Na, this has to be procedural, I set myself the challenge and refuse to quit!

Mind you, if I just did that I could have got some sleep last night!!! lol

its not a picture its a generated sphere "CreateObjectSphere()"
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 12th Nov 2021 07:54
Quote: "its not a picture its a generated sphere "CreateObjectSphere()""


Is it a 3d model?

if so it has polys with point

I wonder if you can get the poly point positions?

What do you need this for anyhow?

Just so I know why you are trying to math out 3d spear sin positions, I'm just curious is all.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Nov 2021 08:27
Yeah its 3D, and no polys wont help as that would mean memblocks and they are slow, to slow for pathfinding

I need it for A.I. path mapping, imagine a RTS game on a flat plane, ok, now imagine that same game on a sphere ...

Dyson Sphere Program is the kind of gameplay mechanic I am aiming for, but obviously not as advanced or polished as that, but the spherical aspect to it

I found a pretty nice math lib for agk that will certainly help, just have to figure out how to use it.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 12th Nov 2021 08:40 Edited at: 12th Nov 2021 08:41
Quote: "A.I. path mapping"


I guess it depends on what you are trying to map a path for.

Different things means different ways.

For anyone approaching I would add a joint that rotates around the approaching elements so it rotates around the planet.

There easy to make and work good.

you can make a joint for just about anything and it would work.

I've been doing a lot of playing around with joints and been surprised.

But what you showed me is a big, no huge project for a one month competition.

That would scare me a lot lol.
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 12th Nov 2021 08:51
I found these functions if any of them help

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Nov 2021 09:54
Quote: "I guess it depends on what you are trying to map a path for.

Different things means different ways."


No, a path is a path, a start point, an end point and nodes inbetween, any AI or system just draws info from the path data and uses it to move, every path system in every game engine ever made works like this, you make the AI suit the path not the path suit the AI, anything else is just a hack!

Quote: "But what you showed me is a big, no huge project for a one month competition.

That would scare me a lot lol."


its huge for one month, its gargantuan for one month and one man!, if its ready its ready, if not, oh well, I'll come out on the other side knowing a whole bunch of stuff I didn't know before so it will be time well spent, no?

Quote: "I found these functions if any of them help"


not for my path mapping but I use similar code for my camera movement, I usually put stuff like that directly into my code, no need for functions



Quote: "you can make a joint for just about anything and it would work.

I've been doing a lot of playing around with joints and been surprised."


Hmmmmm, context really is everything, isn't it! lmao!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Nov 2021 10:13
Right, now I am getting closer, 3 days of searching and finally found this

Hyperbolic quaternion sounds like exactly what I need, might pull a sicky!! lol
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 12th Nov 2021 10:35
Quote: "Hmmmmm, context really is everything, isn't it! lmao!"


As a Girl I have heard them all. lol, but this is a new one.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 12th Nov 2021 10:51
This post has been marked by the post author as the answer.
I am sure you have, but as a builder I guarantee I have heard more! lol

Anyway... success!



I have to admit, that was a serious 14 hour brain ache!!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Nov 2021 16:23
Quote: "I found these functions if any of them help"

Those equations don't look correct to me. What PartTimeCoder posted for calculating his orbit values looks more like what I'd expect for finding x,y,z values. Problem with that however is the possibility of gimbal lock, so you use quaternions instead, which it looks like you found.

I can't tell in the video, but is spacing of the points along the surface equal distances? I noticed that was my problem in my 2d example, which made traveling at a constant speed not so constant.

Isn't it so satisfying to to solve a problem that's plagued you for days?
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 14th Nov 2021 16:57
Quote: "Isn't it so satisfying to to solve a problem that's plagued you for days?"


It is, the best feeling in the world.

But you are right, its not quite as perfect as I first thought, the spacing is off and the further apart the A and B nodes are the less accurate it becomes and I have to extend the ray out or reverse it, still playing with the formula to get that but its *acceptable*, it breaks when I push it far beyond the limits of what I am actually going to use it for.

I had considered the constant speed issue and figured if I can calculate an average and divide it by the node count and distance between each node when I generate the path I can fudge something that looks good enough, not quite sure how that calculation looks yet but once the path is generated I am dealing with fixed values so it will be a dam sight easier than generating the path in the first place, just loop the path nodes, get the distance to the next node, store them in an array and kiss goodbye to another 2 days trying to work it out! lol
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-11-21 13:12:50
Your offset time is: 2024-11-21 13:12:50