How to create a flat ground? & collision on rails (train)

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
twitchyliquid64
Posts: 11
Joined: Sun Jul 08, 2012 11:49 am

How to create a flat ground? & collision on rails (train)

Post by twitchyliquid64 »

Hi all,

I can spilt my problem into three main things, the first being the simplest.

1: How can I create a very very large flat ground? preferably texturable, but not required. I was thinking maybe there is a CreatePlaneNode function or something, but I dont think thats the correct way to do terrain.

So the next big project I want to work on is a simple train simulator.
This has two problems:

2: how to line up the movement of the train with the track

3: how to deal with curved and straight track creation (im guessing I just need to create a line node for the straight parts, and a curved-line for the curved track?)



Thankyou for any help you can give me,
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to create a flat ground? & collision on rails (train

Post by CuteAlien »

For curves search the web for bezier curves, they are most likely the best solution for this (you can can probably find working code-classes on the web somewhere). And with rails you probably don't need a collision at all - just follow the bezier-curve once you have one.

There is ISceneManager::addTerrainSceneNode in Irrlicht, don't know if it is sufficient for what you want to do. But it allows using a heightmap + textures. Or create your tracks and landscape in a modeling tool and export it in some common format like .obj.
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
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: How to create a flat ground? & collision on rails (train

Post by hendu »

The geometry creator has the hillplane node, which can give you a flat texturable quad.
twitchyliquid64
Posts: 11
Joined: Sun Jul 08, 2012 11:49 am

Re: How to create a flat ground? & collision on rails (train

Post by twitchyliquid64 »

Thanks guys.

Now, How to make the tracks? Im guessing Ill need a custom scene node that draws the lines?

Does anyone know the name of the Irrlicht function that draws a line? I had a quick look but didnt find anything.

EDIT: Found irr::core::line3d But I dont see how I create the colour of the line ...
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to create a flat ground? & collision on rails (train

Post by CuteAlien »

irr::core::line3d is a geometry class for working with lines, it's not for drawing.
IVideoDriver has some drawLine functions: http://irrlicht.sourceforge.net/docu/cl ... river.html
If you use them be aware that you have to set a material and the world transformation matrix first (otherwise it just uses whichever is set at that moment). But not sure if those functions will really do in your case. I use them sometimes for debug-output, but for real game-graphics you usually try to find other solutions. A better solution for paths is usually a custom scenenode where you create the corresponding vertices and indices yourself. So for a simple line you use 2 triangles (= 4 vertices + 6 indices). For more complicated paths... well, draw it on paper how you would approximate those with triangles. Then consider how to do the same in code using vertices and indices.
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
Post Reply