Jump to content


Photo
- - - - -

Binary file format


  • Please log in to reply
2 replies to this topic

#1 adam82

adam82

    Newbie

  • Customers
  • Pip
  • 6 posts

Posted 30 June 2012 - 10:03 AM

Hello,

I have problems with the new binary file format (CWB).

In Ogre3D sometimes they are loading perfectly sometimes not.

If not

myShroudObject->Load(buffer,length);

returns with false.

My loader code is the same as in the documentation.
CWF files are loading perfectly.

Studio / Runtime versions are both 2.1.2

What could be the problem ?

Regards,
Adam Horvath
  • Halfundinedia and Belisa like this

#2 Joe_vdH

Joe_vdH

    Administrator

  • Administrators
  • 193 posts
  • LocationSeattle, WA
  • Company:CloakWorks

Posted 01 July 2012 - 06:54 AM

Have you hooked in an IWarningListener? If the load fails, it should send you a message with the reason why.

If the same file works sometime and not others, then I'm guessing its an issue of alignment: the buffer holding the binary data needs to be 16 byte aligned. In windows using _mm_malloc() and _mm_free() are an easy way to allocate an aligned buffer.

Shroud - Real-Time Cloth Physics - www.cloak-works.com


#3 adam82

adam82

    Newbie

  • Customers
  • Pip
  • 6 posts

Posted 01 July 2012 - 12:22 PM

Thanks Joe, _aligned_malloc() did the job!

Here is the working code:

void* buffer = NULL;

// Using _aligned_malloc
buffer = _aligned_malloc(length+1, 16);
ds->read(buffer,length);
ds->close();

// Load the data into the shroud object

bool loadResult = myShroudObject->Load((const char*)buffer,length);

// Once the data is read it can be deleted
_aligned_free(buffer);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users