It is currently Sat Aug 22, 2020 1:54 pm


All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: AStarPathfinder
PostPosted: Sun Feb 12, 2012 9:59 am 

Joined: Sun Feb 12, 2012 9:28 am
Posts: 8
Hello everybody.

I'm new to this forum but I have been watching PolyVox for some time and I am very interested in it's capabilities. At the moment I am working on a little project to get myself familiarised with the library but I have a little problem with using the AStar implementation. I don't understand how to implement it into my code.

I am using Ogre3D to take care of the rendering and I have created a 64x64x64 cube in the scene using PolyVox. My problem is how do I use the AStarPathfinder to calculate a path from one corner of the cube to another. I have the standard Ogre3D scene set-up, the cube rendered, but when I try to run the application, it crashed when it tries to render. My guess is it gets an error when it gets to write the positions in the result list. Here's a part of my code.

Code:
   std::list<Vector3DInt32> listResult;
   Vector3DInt32 v3dStart(0,0,0);
   Vector3DInt32 v3dEnd(63,63,63);
   
   AStarPathfinderParams<SimpleVolume, MaterialDensityPair44> *params;
   params->volume = &volData;
   params->start = v3dStart;
   params->end = v3dEnd;
   params->result = &listResult;

   AStarPathfinder<SimpleVolume, MaterialDensityPair44> *Astar;
   Astar->execute();


Can anyone please help me with this? I am trying to get a path from one point of the cube to another. As a side note, can the pathfinder calculate paths through the cube or just on the surface? Also, can it avoid some materials and calculate around them while going through others?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 11:27 am 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
Quite simple... you are using uninitialized objects.

Code:
AStarPathfinderParams<SimpleVolume, MaterialDensityPair44> *params;

and
Code:
AStarPathfinder<SimpleVolume, MaterialDensityPair44> *Astar;


are never initialized. i'm not sure why you create pointers here...
just create regular objects and use "." instead of "->".

edit:
AStarPathfinderParams and AStarPathfinder both need their constructors to be executed.
I'm not sure why it's members are public...
Here's what I believe your code needs to be changed to
Code:
AStarPathfinderParams<SimpleVolume, MaterialDensityPair44> params(&volData, v3dStart, v3dEnd, &listResult);

Code:
AStarPathfinder<SimpleVolume, MaterialDensityPair44> Astar(params);


Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 12:25 pm 

Joined: Sun Feb 12, 2012 9:28 am
Posts: 8
Thank you for the reply.

I did the changes you recommended but unfortunately, the app still crashes when at the following line.

Code:
Astar.execute();


If it is commented out, the app works normally. Still can't figure out what the problem is ... If anybody has a basic example with a working implementation of the AStarPathfinder, that would be very helpful.

Disclaimer: I am a beginner in coding and am self-taught.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 2:45 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Hi, welcome to PolyVox :-)

Firstly, be sure to build and run your application in Debug mode, so that when it crashes you can see exactly which line it has crashed on, see the call stack, etc.

Secondly, there is an example of using the AStarPathfinder in the 'tests' folder. You can also see it here: https://gitorious.org/polyvox/polyvox/b ... finder.cpp

There are some slight diffrences in the generated path between Windows and Linux... I have to investigate this but it shouldn't matter to you. Also, I've only really tested the path finder with 'cubic' (minecraft-style) worlds so I don't know how well it works if you want smooth terrain.

Also, post your new code if you are still having a crash.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 4:52 pm 

Joined: Sun Feb 12, 2012 9:28 am
Posts: 8
Well, this is embarrassing ... Apparently, the problem lies with ntdll.dll.

My code is this:
Code:
void OgreApp1::createScene(void)
{
   SimpleVolume<MaterialDensityPair44> volData(PolyVox::Region(Vector3DInt32(0,0,0),Vector3DInt32(63,63,63)));
   createSphereInVolume(volData, 20);
   //createCubeInVolume(volData,30);

   SurfaceMesh<PositionMaterialNormal> mesh;
   CubicSurfaceExtractorWithNormals<SimpleVolume, MaterialDensityPair44> surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
   surfaceExtractor.execute();

   Ogre::ManualObject* test;
   test = mSceneMgr->createManualObject("Surface");

   test->setDynamic(true);
   test->begin("BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST);
   {
      const std::vector<uint32_t>& vecIndices = mesh.getIndices();
      const std::vector<PolyVox::PositionMaterialNormal>& vecVertices = mesh.getVertices();
      for (std::vector<PolyVox::PositionMaterialNormal>::const_iterator itVertex = vecVertices.begin(); itVertex != vecVertices.end(); ++itVertex)
      {
         const PolyVox::PositionMaterialNormal& vertex = *itVertex;
         const PolyVox::Vector3DFloat& vertPos = vertex.getPosition();         

         test->position(vertPos.getX(), vertPos.getY(), vertPos.getZ());
         test->normal(vertex.getNormal().getX(), vertex.getNormal().getY(), vertex.getNormal().getZ());
      }
      for (std::vector<uint32_t>::const_iterator itIdx = vecIndices.begin(); itIdx != vecIndices.end(); ++itIdx)
      {
         test->index(*itIdx);
      }
   }
   test->end();

   Ogre::SceneNode* testNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
   testNode->attachObject(test);

   std::list<Vector3DInt32> listResult;
   AStarPathfinderParams<SimpleVolume, MaterialDensityPair44> params(&volData, Vector3DInt32(0,0,0), Vector3DInt32(63,63,63), &listResult);
   AStarPathfinder<SimpleVolume, MaterialDensityPair44> Astar(params);
   Astar.execute();
}


The app compiles with no problem, but it crashes on runtime without any errors (not responding). When in debug mode, the dll above keeps popping up:

ntdll.dll!77b215de()

Does that mean anything?
When viewing the disassembly, VS2010 points to this line:
77B215DE add esp,4

Also, I am using the 11.dec.2011 snapshot of PolyVox. Could it be that that version had some kind of bug or instability issue when using the AStarPathfinder?
Then again ... maybe my OS has gone haywire. I'm using Windows 7 (64bit).
If I can provide any other info that could prove helpful, please let me know. Also, has anyone had any experience with other AI libraries that worked with PolyVox and Ogre3D?

Thank you for all your help.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 6:46 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
You need to have a look at the call stack to see where it is crashing (Visual Studio -> Debug -> Windows -> Call Stack). I.e. 'execute()' called some funtion, that funtion called another, and so on until something called into the .dll you mention. What is the last PolyVox function that is called? Probably something is calling assert() (which means it's crashing on purpose because something is wrong)?

Just show a screenshot of the Call Stack if you don't understand it.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 6:59 pm 

Joined: Sun Feb 12, 2012 9:28 am
Posts: 8
Ok. I have attached a screenshot of the call stack.

EDIT: I reuploaded the screenshot with a bit more details. Hope this is of help.


Attachments:
call stack.png
call stack.png [ 116.31 KiB | Viewed 4683 times ]
Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 7:20 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I don't think it attached properly? Maybe you can upload it somewhere if you can't get it to attach?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 7:29 pm 

Joined: Sun Feb 12, 2012 9:28 am
Posts: 8
Attachment:
call stack.png
call stack.png [ 116.31 KiB | Viewed 4680 times ]

Attachment:
callstack2.png
callstack2.png [ 27.58 KiB | Viewed 4680 times ]


That's strange ... it looks fine to me.

Tell me if it's still not showing, and I'll try a different way of uploading the image.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: AStarPathfinder
PostPosted: Sun Feb 12, 2012 7:40 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I see it now... maybe you were just halfway though re-uploading it. Unfortunatly I can't say what is wrong, so I'll have to try running that code myself to see. I'll try to do this tomorrow and get back to you...


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net