Menu

#32 LWS importer

closed-fixed
nobody
None
5
2012-02-05
2012-01-14
No

Hi,

I've got some problems with several LWS files on windows. So I've extended

std::string LWSImporter::FindLWOFile(const std::string& in)

with the following:

// try to look if the LWO file is in the same folder than the LWS
size_t pos = in.rfind("/");
if (-1 == pos)
pos = in.rfind("\\");
if (-1 != pos)
{
test = ".";
test += io->getOsSeparator();
test += in.substr(pos+1, in.length()-pos);
if (io->Exists(test))
return test;
}

before
// return original path, maybe the IOsystem knows better
return tmp;

Best regards,

Patrik

Discussion

  • Alexander Gessler

    Hi,

    I'm quite sure FileSystemFile should try this already ..

    what's the error messages you get? How are the LWO files referenced in the LWS script?

    Bye, Alex

     
  • Patrik Mueller

    Patrik Mueller - 2012-01-14

    Hi Alex,

    this is the definition inside the lws file:

    LoadObjectLayer 1 C:NEWTEK/Gerdolans Models/DS9/Docking-ring-outer.lwo

    I've added the values inside comments - very strange results!!

    // insert missing directory seperator if necessary
    std::string tmp;
    if (in.length() > 3 && in[1] == ':'&& in[2] != '\\' && in[2] != '/')
    {
    tmp = in[0] + ":\\" + in.substr(2);
    }
    else tmp = in;

    /*
    tmp "LWS file NEWTEK/Gerdolans Models/DS9/Docking-ring-outer.lwo"
    */

    if (io->Exists(tmp))
    return in;

    // file is not accessible for us ... maybe it's packed by
    // LightWave's 'Package Scene' command?

    // Relevant for us are the following two directories:
    // <folder>\Objects\&lt;hh>\&lt;*>.lwo
    // <folder>\Scenes\&lt;hh>\&lt;*>.lws
    // where <hh> is optional.

    std::string test = ".." + io->getOsSeparator() + tmp;

    /*
    test "Wave scene, magic tag LWSC not foundLWS file NEWTEK/Gerdolans Models/DS9/Docking-ring-outer.lwo"
    */

    if (io->Exists(test))
    return test;

    test = ".." + io->getOsSeparator() + test;

    /*
    test "c tag LWSC not foundWave scene, magic tag LWSC not foundLWS file NEWTEK/Gerdolans Models/DS9/Docking-ring-outer.lwo"
    */

    if (io->Exists(test))
    return test;

    Greets,

    Patrik

     
  • Alexander Gessler

    I see -

    I applied your patch (r1113), but moved the code to FileSystemFilter.h, which wraps IOSystem within Assimp in order to intelligently locate external files.

    This *should* fix the issue even though the LWS loader is not touched at all. Please check this. Waiting for your confirmation to close this issue :-)

    Thanks!

    Bye, Alex

     
  • Alexander Gessler

    • status: open --> pending
     
  • Patrik Mueller

    Patrik Mueller - 2012-01-15

    Hi Alex,

    sorry - this isn't enough!

    The result from FindLWOFile doesn't make sense:

    std::string path = FindLWOFile( c );
    d.path = path;
    d.id = batch.AddLoadRequest(path,0,&props);

    In this case, path would be:
    "LWS file NEWTEK/Gerdolans Models/DS9/Docking-ring-outer.lwo"

    But as an additional idea for the FileSystemFilter (I'm using Assimp since yesterday - so sorry if I tell nonsens ;-)):

    Imagine you have an result like "NEWTEK/Gerdolans Models/DS9/Docking-ring-outer.lwo".
    How about to trying to iterate over all directories inside the string to find it from the start folder?

    Greets,

    Patrik

     
  • Alexander Gessler

    >> The result from FindLWOFile doesn't make sense:

    FindLWOFile is not supposed to return the path to the target file. It's just supposed to check for LWS-specific locations.

    With my recent change, a batch request for NEWTEK/Gerdolans Models/DS9/Docking-ring-outer.lwo should succeed if Docking-ring-outer.lwo is located in the LWS' files folder - apart from this, I have troubles understanding what you mean by 'doesn't make sense'. What is the exact result with my last change applied?

    The proposed idea for FileSystemFilter is nice, will add this asap.

    Bye, Alex

     
  • Patrik Mueller

    Patrik Mueller - 2012-01-16

    Hi Alex,

    >>FindLWOFile is not supposed to return the path to the target file. It's
    >>just supposed to check for LWS-specific locations.

    if I understand the workflow inside LWS correctly, the result from FindLWOFile will be used later in the batch:

    std::string path = FindLWOFile( c );
    d.path = path;
    d.id = batch.AddLoadRequest(path,0,&props);

    So the result should be just a file path (doesn't matter if its relative or absolute).
    If this is correct, the "LWS file " inside the path value is incorrect, as no path containing "LWS file " will exists. Is this true?

    Best regards,

    Patrik

     
  • Alexander Gessler

    Oehm .. you mean, the path starts with "LWS File" - I have no idea where it should come from if not from the original file.

    Can you upload the LWS file or send it by mail? (my mail address can be found on our website).

    Bye, Alex

     
  • Patrik Mueller

    Patrik Mueller - 2012-01-17

    Hi,

    I've sent you a PM.

    Greets,

    Patrik

     
  • Patrik Mueller

    Patrik Mueller - 2012-01-17
    • status: pending --> open
     
  • Alexander Gessler

    • status: open --> closed-fixed
     
  • Alexander Gessler

    Should be fixed in r1160. FSF now scans all possible paths relative to the model base folder.

    Thanks!
    Bye, Alex