automation of 3d maze

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.
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

automation of 3d maze

Post by elapj »

hi

ive imported my own 3d maze into the .irr tutorial and it works fine i can navigate around my maze easiy using the keybord.

is there a way of writing a bit of code to automatically do this so i littrally load it up an it moves throught the maze without me pressing any buttons ??

If so where can this be written ??

Any help would be much appreaitated

peter
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yep, basically you need pathfinding...

I did this stuff at Uni to make NPCs navigate through mazes.

Presumably you want it to actually find the way out, not actually just wander around randomly?

You can check out my IrrAI project which could help you. I wouldn't particularly advise using the library yet as it's not particularly ready for people to use yet but you can nick the relevant stuff to do with pathfinding from it probably.

EDIT: I'll give you a little description of what my Maze exploration did in my Uni project:

Basically in each cell of the maze (assuming it's a grid based maze) you check how many choices there are for moving, i.e. which directions you can move in.

If there's just one direction you can move in (that you haven't been to before) then you go that way. If there's more than one then you pick one of them (at random or more sensibly if you can think of a criteria for choosing between them) and for the other directions you could have gone in you 'remember' them so that you can come back to them later in case the direction you chose leads to a dead end.

And that's all you need to do really, that will result in your guy finding his way out of the maze. You only actually need the pathfinding stuff in this case to find your way back to an alternative direction you could have taken previously.

My maze was randomly created with an algorithm and representation which provided a lot of useful information for making this process easier. If you've just modelled a maze in an application then there's probably some more tricky work for you to do.

You could use my IrrAI library and just put waypoints into your maze in a grid fashion and that would make it very easy to replicate what i did in my Uni project, i'd certainly be willing to help you out with this so let me know if you do need any help.
Last edited by JP on Thu May 22, 2008 11:11 am, edited 1 time in total.
Image Image Image
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

Post by elapj »

i just want to navigate it from the start position to the end.

just the same route each time
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I just edited my above post so that might have more info for you, but from what you've just said there's a simpler answer.

Check out the followSplineAnimator which you can attach to your character's node and it will follow the given path. So all you need to do is create the spline (path) to be followed by making a list of 3D points you want your character to walk through.
Image Image Image
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

Post by elapj »

cheers


i have no charactor, its just an eye view from the camera.

the maze was simply made out of object in irredit,

im just after a simple movement instruction to move the camera throught the maze
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah followSplineAnimator will be perfect then, you can check out the Demo tutorial in the examples folder of the SDK, that's got the camera following a spline on start up so you can see how to use it and what it looks like there.
Image Image Image
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

Post by elapj »

cheers

which tutorial sorry ??
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The demo app, it's not a numbered example, but a separate application.
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

Post by elapj »

thankyou

so i am after the code that pans around the maze at the start ??

this would be perfect for me jusy pan the camera around the maze until it gets to the end
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

Post by elapj »

case 1: // panorama camera
{
currentScene += 1;
//camera = sm->addCameraSceneNode(0, core::vector3df(0,0,0), core::vector3df(-586,708,52));
//camera->setTarget(core::vector3df(0,400,0));

core::array<core::vector3df> points;

points.push_back(core::vector3df(-931.473755f, 138.300003f, 987.279114f)); // -49873
points.push_back(core::vector3df(-847.902222f, 136.757553f, 915.792725f)); // -50559
points.push_back(core::vector3df(-748.680420f, 152.254501f, 826.418945f)); // -51964
points.push_back(core::vector3df(-708.428406f, 213.569580f, 784.466675f)); // -53251
points.push_back(core::vector3df(-686.217651f, 288.141174f, 762.965576f)); // -54015
points.push_back(core::vector3df(-679.685059f, 365.095612f, 756.551453f)); // -54733
points.push_back(core::vector3df(-671.317871f, 447.360107f, 749.394592f)); // -55588
points.push_back(core::vector3df(-669.468445f, 583.335632f, 747.711853f)); // -56178
points.push_back(core::vector3df(-667.611267f, 727.313232f, 746.018250f)); // -56757
points.push_back(core::vector3df(-665.853210f, 862.791931f, 744.436096f)); // -57859
points.push_back(core::vector3df(-642.649597f, 1026.047607f, 724.259827f)); // -59705
points.push_back(core::vector3df(-517.793884f, 838.396790f, 490.326050f)); // -60983
points.push_back(core::vector3df(-474.387299f, 715.691467f, 344.639984f)); // -61629
points.push_back(core::vector3df(-444.600250f, 601.155701f, 180.938095f)); // -62319
points.push_back(core::vector3df(-414.808899f, 479.691406f, 4.866660f)); // -63048
points.push_back(core::vector3df(-410.418945f, 429.642242f, -134.332687f)); // -63757
points.push_back(core::vector3df(-399.837585f, 411.498383f, -349.350983f)); // -64418
points.push_back(core::vector3df(-390.756653f, 403.970093f, -524.454407f)); // -65005
points.push_back(core::vector3df(-334.864227f, 350.065491f, -732.397400f)); // -65701
points.push_back(core::vector3df(-195.253387f, 349.577209f, -812.475891f)); // -66335
points.push_back(core::vector3df(16.255573f, 363.743134f, -833.800415f)); // -67170
points.push_back(core::vector3df(234.940964f, 352.957825f, -820.150696f)); // -67939
points.push_back(core::vector3df(436.797668f, 349.236450f, -816.914185f)); // -68596
points.push_back(core::vector3df(575.236206f, 356.244812f, -719.788513f)); // -69166
points.push_back(core::vector3df(594.131042f, 387.173828f, -609.675598f)); // -69744
points.push_back(core::vector3df(617.615234f, 412.002899f, -326.174072f)); // -70640
points.push_back(core::vector3df(606.456848f, 403.221954f, -104.179291f)); // -71390
points.push_back(core::vector3df(610.958252f, 407.037750f, 117.209778f)); // -72085
points.push_back(core::vector3df(597.956909f, 395.167877f, 345.942200f)); // -72817
points.push_back(core::vector3df(587.383118f, 391.444519f, 566.098633f)); // -73477
points.push_back(core::vector3df(559.572449f, 371.991333f, 777.689453f)); // -74124
points.push_back(core::vector3df(423.753204f, 329.990051f, 925.859741f)); // -74941
points.push_back(core::vector3df(247.520050f, 252.818954f, 935.311829f)); // -75651
points.push_back(core::vector3df(114.756012f, 199.799759f, 805.014160f));
points.push_back(core::vector3df(96.783348f, 181.639481f, 648.188110f));
points.push_back(core::vector3df(97.865623f, 138.905975f, 484.812561f));
points.push_back(core::vector3df(99.612457f, 102.463669f, 347.603210f));
points.push_back(core::vector3df(99.612457f, 102.463669f, 347.603210f));
points.push_back(core::vector3df(99.612457f, 102.463669f, 347.603210f));

timeForThisScene = (points.size()-3)* 1000;

camera = sm->addCameraSceneNode(0, points[0], core::vector3df(0 ,400,0));
//camera->setTarget(core::vector3df(0,400,0));

sa = sm->createFollowSplineAnimator(device->getTimer()->getTime(),
points);
camera->addAnimator(sa);
sa->drop();

model1->setVisible(false);
model2->setVisible(false);
campFire->setVisible(false);
inOutFader->fadeIn(7000);
}








im guessing this is the area of code i need to introduce
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

Post by elapj »

any ideas how it works or where it needs to go
??
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

:? Where what needs to go? You've just posted all the code that you'll need in your app. Where you put it in your app code is really up to you.

One thing to look out for (pun intended) is that attaching a spline animator to the camera will only move it; it won't change the direction it's looking in.

To do that, you can have it look towards the next target position. You'll want to repeatedly call setTarget() with a position that's ahead of it in its path. One way to do that would be to attach the same animator to an empty scene node, delay attaching the animator to your camera for a short while, then set the camera's target position to be the empty scene node's position. This should keep it looking in its direction of travel, and if you get the delay right, it should even be a fairly smooth rotation at junctions.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

Post by elapj »

right ok

at the moment ive added the code before it draws everthing , it compiles and the camera pans around my maze just like in the demo , but now i need to make the camera move through the demo

ive tried changing the co ordinated but its impossible to get a starting point
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

What do you mean impossible to get a starting point?

Are you finding it hard to get the correct positions for the points on the spline?

I guess that's probably just a case of trial and error... You know the starting point because you know where your camera is initially placed at the start of the maze.

I suppose irrEdit would be useful for figuring out the points on the spline, just by putting your maze into irrEdit and then adding some node (empty or cube maybe) and then drag it to the necessary position and read off its position that it shows in the info window.
Image Image Image
elapj
Posts: 34
Joined: Tue Nov 06, 2007 1:34 pm

Post by elapj »

by changing the co ordinates i cant get a view of the starting point,

your theory of using iredit in that way should work but it doesnt dont know y

do they use the same co ordinates ???
Post Reply