Load obj fails if its not the teapot that comes from the demo


#1

Hi 

I add the teapot.obj from the introjucer to create my binarydata.cpp and binarydata.h.

 

Binarydata.h looks like this:


namespace BinaryData
{
    extern const char*   lamp_obj;
    const int            lamp_objSize = 227066;
    extern const char*   teapot_obj;
    const int            teapot_objSize = 95000;
    extern const char*   Main_cpp;
    const int            Main_cppSize = 43859;
    // Points to the start of a list of resource names.
    extern const char* namedResourceList[];
    // Number of elements in the namedResourceList array.
    extern const int namedResourceListSize;
    // If you provide the name of one of the binary resource variables above, this function will
    // return the corresponding data and its size (or a null pointer if the name isn't found).
    const char* getNamedResource (const char* resourceNameUTF8, int& dataSizeInBytes) throw();
}
 

as you can see I added a lamp.obj which was parsed with the introjucer as well.

the  binarydata.cpp looks like this:


namespace BinaryData
{
//================== lamp.obj ==================
static const unsigned char temp_binary_data_0[] =
{ 35, ... , }

const char* lamp_obj = (const char*) temp_binary_data_0;

 

//================== teapot.obj ==================

static const unsigned char temp_binary_data_1[] =

{ 35,32, ... }

const char* teapot_obj = (const char*) temp_binary_data_1;

 

//================== Main.cpp ==================
static const unsigned char temp_binary_data_2[] =
{ 13, 10, ... }

const char* Main_cpp = (const char*) temp_binary_data_2;


const char* getNamedResource (const char*, int&) throw();
const char* getNamedResource (const char* resourceNameUTF8, int& numBytes) throw()
{
    unsigned int hash = 0;
    if (resourceNameUTF8 != 0)
        while (*resourceNameUTF8 != 0)
            hash = 31 * hash + (unsigned int) *resourceNameUTF8++;
    switch (hash)
    {
        case 0x9e92c210:  numBytes = 227066; return lamp_obj;
        case 0x754c69fd:  numBytes = 95000; return teapot_obj;
        case 0x035e963d:  numBytes = 43859; return Main_cpp;
        default: break;
    }
    numBytes = 0;
    return 0;
}
const int namedResourceListSize = 3;
const char* namedResourceList[] =
{
    "lamp_obj",
    "teapot_obj",
    "Main_cpp"
};
}

 I add the WavefrontObjParser.h to my headers and use the following code to get if the data was loaded correctly:

if (shapeFile.load (BinaryData::teapot_obj).wasOk())            

which works perfectly with the teapot, however when I call 

if (shapeFile.load (BinaryData::lamp_obj).wasOk())            

 triggers the following breakpoint at the WaveFrontObjParser.h line 316:


Result parseMaterial (Array<Material>& materials, const String& filename)
    {
        jassert (sourceFile.exists());

The File obviously exists as I shown in the binaryData header and cpp so I do not know what is the problem. I try with obj's created with blender, 3ds and from here: http://people.sc.fsu.edu/~jburkardt/data/obj/ and it is always the same mistake.

Please a little help on why this is happening?

Thank you 


#2

Well, no, the sourceFile variable doesn't exist, because you told it to load from memory, and didn't give it a sourceFile!

Why are you trying to make it load your files from the binary data?? If you just use the other load() method to load directly from the .obj file, then that sourceFile variable will be correct and it'll be able to find any .mat files in the same folder.


#3

Fixed like this:

if (shapeFile.load( File::getCurrentWorkingDirectory().getChildFile ("../../Resources/lamp.obj")).wasOk())

Now the same nvidia dll problem but now with a different stack. Hope you can help me by adressing the issue.


     nvoglv32.dll!5469f610()    Unknown
     [Frames below may be incorrect and/or missing, no symbols loaded for nvoglv32.dll]    
     nvoglv32.dll!5473a9b2()    Unknown
     nvoglv32.dll!5473add2()    Unknown
     nvoglv32.dll!54731ca3()    Unknown
     nvoglv32.dll!53e6d4ed()    Unknown
>    JuceOpenGL.exe!OpenGLClasses::Shape::draw(juce::OpenGLContext & openGLContext, OpenGLClasses::Attributes & attributes) Line 172    C++
     JuceOpenGL.exe!OpenGLClasses::OpenGL::renderOpenGL() Line 688    C++
     JuceOpenGL.exe!juce::OpenGLContext::CachedImage::renderFrame() Line 169    C++
     JuceOpenGL.exe!juce::OpenGLContext::CachedImage::run() Line 326    C++
     JuceOpenGL.exe!juce::Thread::threadEntryPoint() Line 106    C++
     JuceOpenGL.exe!juce::juce_threadEntryPoint(void * userData) Line 114    C++
     JuceOpenGL.exe!juce::threadEntryProc(void * userData) Line 103    C++
     JuceOpenGL.exe!_callthreadstartex() Line 354    C
     JuceOpenGL.exe!_threadstartex(void * ptd) Line 337    C
     kernel32.dll!76c0850d()    Unknown
     ntdll.dll!772cbf39()    Unknown
     ntdll.dll!772cbf0c()    Unknown

thank you 


#4

The last function on the stack is your code, not mine.