Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Jul 07, 2012 3:56 pm 
Offline

Joined: Sat Jul 07, 2012 3:40 pm
Posts: 4
*Edit: I'm not sure if this is the correct board, should I move this to the serialization board?

I am attempting to load the model I have built using Blender 2.63.0 r46461 from which I have successfully exported a 22KB .bullet file. I have adapted the serialize demo supplied with bullet 2.80-rev2531 with the following code.

Code:
void   SerializeKuka::initPhysics()
{
   char* fileName = "kuka.bullet";
   setTexturing(true);
   setShadows(true);

   setCameraDistance(btScalar(SCALING*30.));

   setupEmptyDynamicsWorld();
   m_fileLoader = new btBulletWorldImporter(m_dynamicsWorld);
   
   bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(fileName);
   //bulletFile2->parse(true);
   bulletFile2->parseData();

   m_fileLoader->setVerboseMode(true);

   if(!m_fileLoader->loadFileFromMemory(bulletFile2))
   {
      std::cout << "Failed to load file: " << fileName << std::endl;
      return;
   }
   /*
   if (!m_fileLoader->loadFile(fileName))
   {
      std::cout << "Failed to load file: " << fileName << std::endl;
      return;
   }
   */
   std::cout << "Looking for bodies:\n Found "<< m_dynamicsWorld->getNumCollisionObjects() << " objects." <<  std::endl;
   for(int numBodies = 0; numBodies < m_dynamicsWorld->getNumCollisionObjects(); numBodies++)
   {
      btCollisionObject* Body = m_dynamicsWorld->getCollisionObjectArray()[numBodies];
      const char* name = Body->getCollisionShape()->getName() ;
      std::cout << "found body " << name << std::endl;
   }

   //clientResetScene();

}


Running this gives me a segmentation fault and gdb gives:
Code:
Program received signal SIGSEGV, Segmentation fault.
0x00000000004f6042 in bParse::bFile::getNextBlock(bParse::bChunkInd*, char const*, int) ()

The backtrace is:
Code:
(gdb) bt
#0  0x000000389e5380f0 in __memcpy_ssse3 () from /lib64/libc.so.6
#1  0x000000000052e59b in bParse::bFile::getNextBlock (this=0x8e42b0,
    dataChunk=0x7fffffffd5d0, dataPtr=0xc <Address 0xc out of bounds>, flags=0)
    at /media/B0FC-7F98/bullet-2.80-rev2531/Extras/Serialize/BulletFileLoader/bFile.cpp:1265
#2  0x00000000005302ab in bParse::btBulletFile::parseData (this=0x8e42b0)
    at /media/B0FC-7F98/bullet-2.80-rev2531/Extras/Serialize/BulletFileLoader/btBulletFile.cpp:135
#3  0x00000000004754f4 in SerializeKuka::initPhysics (this=0x7fffffffd720)
    at /media/B0FC-7F98/bullet-2.80-rev2531/Demos/SerializeKuka/SerializeKuka.cpp:162
#4  0x000000000046c2e9 in main (argc=1, argv=0x7fffffffd948)
    at /media/B0FC-7F98/bullet-2.80-rev2531/Demos/SerializeKuka/main.cpp:32

Using the commented loadFile method returns false. I have attached the mentioned .bullet file, renamed to allow upload.


Attachments:
kuka.bullet.renameme.txt [22.02 KiB]
Downloaded 32 times
Top
 Profile  
 
PostPosted: Wed Jul 11, 2012 11:18 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3744
Location: California, USA
The file loads fine here, using the unmodified Bullet/Demos/SerializeDemo (just rename the file to testFile.bullet and put it in the right place so your demo can find the file.
Of course you need to check if the file exists and if the parser is OK, that is what the original Bullet code does:

Code:
bool   btBulletWorldImporter::loadFileFromMemory(  bParse::btBulletFile* bulletFile2)
{
   bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0;
   
   if (ok)
      bulletFile2->parse(m_verboseDumpAllTypes);
   else
      return false;
   
   if (m_verboseDumpAllTypes)
   {
      bulletFile2->dumpChunks(bulletFile2->getFileDNA());
   }

   return convertAllObjects(bulletFile2);

}


Why didn't you use the btBulletWorldImporter?


Top
 Profile  
 
PostPosted: Thu Jul 12, 2012 11:00 am 
Offline

Joined: Sat Jul 07, 2012 3:40 pm
Posts: 4
The code does actually work, turns out I was just running from the wrong directory and the program was looking for the serialized file in the directory my shell was in rather than the directory the executable was in.

Boy is my face red.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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:  
Powered by phpBB® Forum Software © phpBB Group