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.

Dark GDK / Splines Demo

Author
Message
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 19th Feb 2008 03:07
I am in the planning discovery stage of creating a Traffic Simulator.

My initial road block pun intended is to decide the most flexible way to design the roads. They need to have multiple lanes, on ramps off ramps as well as roundabouts and ideally the ability to change altitude etc.

The suggestion was made that splines would be the way to go. As this was an unfamiliar programming area I checked the code base and the forums. I cam across a snippet by Jukuma. It looked interesting so I converted from DBP to GDK. I think the spline concept maybe a dead end and I am looking for a different approach. All suggestions will be considered.

Rather than add this to my many dead ends (it's the journey thats the joy) I am posting here for others to review comment learn from etc.



All the best

Coder

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 19th Feb 2008 05:20
Interesting Problem.

I'm thinkning computers are dumb - and that you need something akin to DarkAI - designed with a combination of "defined" Areas -and rules for each area - as well as mini waypoints - so a car can cross an intersection OR take a left turn and stay in and continue in the correct lane during such a turn. I say ways points for intersections - because this is an area where the rules change from following a specific "lane" on a road.

I don't have a solution yet - but interesting to think about for sure! (Note: Bugs during your trial and error phase may convince you never to get a car with autopilot!) hahah

Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 19th Feb 2008 06:20
Jason
I drive on the southern California freeway every day. Even a computer program with serious bugs would be an improvement over the Cell phone using, make up applying, newspaper reading, shaving incompetents I see every day. Not to mention the idiots who leave 300 yards between them and the car in front. fortunately I live in a nice enough neighborhood to skip the drive bye's.

Seriously I have most of the rules worked out for traffic decisions what I lack is a good road.

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 19th Feb 2008 06:42
In that case - I'm surpised the spline thing was a dead end. I (like you) got the impression they were new way to think about "flat objects" kinda.

Is your problem the display of roads - or making something "match" visually and "AI" wise - so you can write code to make cars stay on them as one would expect?

Also - what kind of terrain area do you need to cover - as that seems to dictate the kind of plausible solutions one might try.

From an AI perspective - I can't help but think of the robot sysems that are in experimental stages that have the magnetic "stripes" on the side of the road - at certain intervals - so the car can navigate from one to the next.

This idea makes me think of a series of "points" (literally tiny Way points) with a plotted position as well as a "normal" or a "direction" to "go from there" to the next. Basically: X,Y,Z,Angle To Drive Towards next. This would allow each waypoint to have all the info required to send the car to the next one - effectively sterring it. Though You would need to elaborate for more complicated scenarios like intersections etc obviously... but....

Yeah - tell me if its a visual challenge for you mostly or not. I get the impression that's your issue - but I see how the AI and visual definately need to JIVE so the final result looks right... ahh... A mind Puzzle for sure.

Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 19th Feb 2008 07:14
after a nap I have been rethinking splines they maybe the way to go as they do allow a 2d or 3d representation of a ribbon that would describe the path of a lane.
I would like a quality representation of a road but I am more concerned with how to align vehicles to the spline and or the spline to vehicles. One concept would be to use the splines to lay out planes if the planes were textured with lines of a specific color the color could define the position from the anchor points of the spline.

Vehicles position could be stored on an array that would allow a quick review of the a,y positions of the array to review any nearby vehicles.

I am thinking of starting with a couple of ovals think figure of 8 3 deep (to represent a 3 lanes ) textured as previously described

lots to think about

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 19th Feb 2008 20:06
I think you should create a road segment class, with virtual methods such as create, delete, move car and a function to get a list of available directions. When you have that, you can use whatever you want, just inherit from that base class, and you can use splines for curved segments, linear interpolation for straight ones, etc.

Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 20th Feb 2008 03:12
Diggsey
I am unfamiliar with how to create a class using virtual methods. Would you have a simple example that would demonstrate?

Thanks in advance

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 20th Feb 2008 06:26
Basically you use the key word virtual - and its a function with nothing in it - a place holder if I understand correctly.

Then you inherit the class with the virtual functions - and you can (I think you need keyword override for this) basically "Fill in the Code" for the virtual function.

I think thats how they work. I don't use them much obviously - but I do something kinda similiar - someone will likely argue - "Its not similiar" but I make my base class with all my functions - and I put code in them that may be useful for descendant clAsses, and if I want to ADD to what they do - I just make a function on the child class with the same name - this makes em both work - one then the other... a cascade... but when I want to REPLACE my base function (psuedo virtual) I override the base function by making a new one, the override keyword - function has same name and parameter list effectively becoming the replacement.

Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 25th Feb 2008 00:57 Edited at: 25th Feb 2008 05:06
Well I have finally figured out how the CatmullRom Vector is used to create splines. (I will post some code shortly for others).
Now I have these points along the curve Does anyone know how to make a terrain / Matrix / Mesh through them? To form a road or ribbon.

for instance is we make a triangle using points (x,y) :
-10,0 0,10 10,0 how would you create a surface 1 unit wide that looks like /?



Thanks in advance

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 25th Feb 2008 03:58 Edited at: 25th Feb 2008 05:04
Here is the Spline demo code as promised





Anyone know how to make surface along the splines so it would be suitable for a road?

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem

Login to post a reply

Server time is: 2024-11-20 03:45:53
Your offset time is: 2024-11-20 03:45:53