How to dynamic draw road(trace) with real time data?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
wps20052002
Posts: 10
Joined: Thu Jul 17, 2014 6:40 am

How to dynamic draw road(trace) with real time data?

Post by wps20052002 »

I am developing a GIS software and I want to draw the trace(road) received from GPS
(just like the picture below, green path show the path witch vehicle has passed)

Image

Given the vehicle's width and position(x,y) (convert from GPS data in real time), i want to draw the trace in irrlicht's XY plane with green color road

Here is the major problems confuse me..

My poor plan is to create a little increment mesh(or add vertex into meshbuffer) to draw the trace(road) since every single movement (everytime receive GPS data)

but the GPS receive data rate is 10Hz , as time goes on there may be too many mesh objects to kill FPS.

Is there any better idea? maybe some technology to reduce the mesh (or vertex) ? LOD for increment updata ?

Thank you all for concerning my problem.
Last edited by wps20052002 on Tue Jul 22, 2014 7:06 am, edited 1 time in total.
wps20052002
Posts: 10
Joined: Thu Jul 17, 2014 6:40 am

Re: How to dynamic draw road(trace) with read time data?

Post by wps20052002 »

Is any one here ?
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: How to dynamic draw road(trace) with read time data?

Post by Seven »

at first thought I would just keep track of a single line that represents the path that I am traveling
then, each frame, I would calculate the visible portion of the line and create the 'road' based on that.
since the 'road' is a set width, it would be simple to create the mesh based on the path line.
in addition, it would limit the amount of 'mesh memory' to an almost constant since I can always see the same amount of road
I just change my position on it.

Since the only data that you are actually storing is points on the line, it should be minimal memory being retained.

my second thought :
maybe research 'spline' and see how to create the path, then just extrude the 'road' from that center point. should be fairly easy and fast.
Last edited by Seven on Fri Jul 18, 2014 12:54 am, edited 1 time in total.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: How to dynamic draw road(trace) with read time data?

Post by Seven »

another way of saying the same thing, is to NOT keep storing the entire mesh that is only partially rendered,
just store the line (or path or spline or whatever you want to call it) that represents where the car has traveled and then
only create the mesh that is visible on the screen. With such minimal graphics, you should be able to create / destroy / create the mesh each frame
with no issues.

should make zooming pretty easy too, you just calculate how much of the line is visible and then extrude that portion to create the mesh.

oh, and you can limit the size of the line to 10,000 points. then as new points are added, the last points are removed.
since the rendering is disassociated from the collection of the points, it wont care if there are 10 points or 10000 points. all the rendering pipe will need
to know is how many of the line points are you wanting to extrude and render.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: How to dynamic draw road(trace) with read time data?

Post by mongoose7 »

Just keep a mesh of, say, 1000 points. Then every time the car moves, say, 10m, reuse the oldest vertices to define the new section of road, a cyclic buffer as it were.
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: How to dynamic draw road(trace) with read time data?

Post by greenya »

If you have say 10-20 lines, you can store them in any form you like and draw them separately using driver->draw2DLine() call.
If you have much more and want them to be drawn as fast as possible, you need to deal with VertexBuffer, IndexBuffer and draw2DVertexPrimitiveList().

Here is an example which has some relation to "drawing lines fast":
the screenshot: http://irrlichtlime.sourceforge.net/ima ... era-01.jpg
the source: http://sourceforge.net/p/irrlichtlime/c ... ereCamera/
(it is C# but you can easily get the idea)
(actual work with needed buffers in SpherePath.cs)
wps20052002
Posts: 10
Joined: Thu Jul 17, 2014 6:40 am

Re: How to dynamic draw road(trace) with read time data?

Post by wps20052002 »

Seven wrote:at first thought I would just keep track of a single line that represents the path that I am traveling
then, each frame, I would calculate the visible portion of the line and create the 'road' based on that.
since the 'road' is a set width, it would be simple to create the mesh based on the path line.
in addition, it would limit the amount of 'mesh memory' to an almost constant since I can always see the same amount of road
I just change my position on it.

Since the only data that you are actually storing is points on the line, it should be minimal memory being retained.

my second thought :
maybe research 'spline' and see how to create the path, then just extrude the 'road' from that center point. should be fairly easy and fast.
I am happy to see you reply so quickly, and first of all, thank you.

Your first thought mentions that just creating the portion can be seen, and I think it is a good way to solve the problem.But here comes up another problem,
as you known my data is growing and the way points in the visible area may be more and more dense(high density), just simply draw them may cost too much
as time goes by. And maybe I need an algorithm the choose the major way points which holds the road's shape(contour), but I don't exactly know how to do.

Your second thought mentions using 'spline' to create road, i guess you means fitt spline with way points and get mathematical formula to represent a road,
am I right ? If so, still the same problem , as time goes by, the visible area may contains may way points , and contains many many splines (if cover , no need to draw all ), how to choose the useful spline to draw ?

I have an idea, use quadtree and LOD(Level of detail) . I mean store the way points in quadtree(set a minimum size, cluster points within a radius) and draw the road with different details base on sight distance. But I lack of reference source, any support will be appreciated.

Thank you and you are welcome to share any ideas.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to dynamic draw road(trace) with read time data?

Post by CuteAlien »

I would use a custom scenenode which just keeps as many points as it has to (not talking about drawing yet, just the gps points themself). And then it creates a new meshbuffer each frame - for such a small piece of road that's not too expensive. How to select them depends a little bit on the data. Putting the data in a grid might make sense (and is relatively easy to code).

And be sure to calculate as first step an approximation of how much data you will really have. Maybe it's not even a problem?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
wps20052002
Posts: 10
Joined: Thu Jul 17, 2014 6:40 am

Re: How to dynamic draw road(trace) with read time data?

Post by wps20052002 »

greenya wrote:If you have say 10-20 lines, you can store them in any form you like and draw them separately using driver->draw2DLine() call.
If you have much more and want them to be drawn as fast as possible, you need to deal with VertexBuffer, IndexBuffer and draw2DVertexPrimitiveList().

Here is an example which has some relation to "drawing lines fast":
the screenshot: http://irrlichtlime.sourceforge.net/ima ... era-01.jpg
the source: http://sourceforge.net/p/irrlichtlime/c ... ereCamera/
(it is C# but you can easily get the idea)
(actual work with needed buffers in SpherePath.cs)

Sorry for replying so late (busy recently) .i will read the source code soon and reply you again.
Thank you very much.
Post Reply