False error when loading height map

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
0lenny0
Posts: 2
Joined: Wed Feb 22, 2012 1:45 pm

False error when loading height map

Post by 0lenny0 »

Hi
Whenever i try to debug my code i get the error that my height map can't be loaded.
Could not load terrain, because file could not be opened.: heightmap.bmp
However when not debugging the program and running it outside my IDE i see that it runs just fine.
It looks like i'm getting a false error. I have tried some different code which always results into the same.
Anybody know why this is happening (i don't get further then the line which loads the height map when debugging).

Code: Select all

        scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
                "heightmap.bmp",
                0,                                      // parent node
                -1,                                     // node id
                core::vector3df(0.f, 0.f, 0.f),         // position
                core::vector3df(0.f, 0.f, 0.f),         // rotation
                core::vector3df(40.f, 4.4f, 40.f),      // scale
                video::SColor ( 255, 255, 255, 255 ),   // vertexColor
                5,                                      // maxLOD
                scene::ETPS_17,                         // patchSize
                4                                       // smoothFactor
                );
 
        terrain->setMaterialFlag(video::EMF_LIGHTING, false);
 
        terrain->setMaterialTexture(0,
                        driver->getTexture("terrain-texture.jpg"));
        //terrain->setMaterialTexture(1,
        //                driver->getTexture("../../media/detailmap3.jpg"));
 
        terrain->setMaterialType(video::EMT_DETAIL_MAP);
 
        terrain->scaleTexture(1.0f, 20.0f);
Voxel
Posts: 8
Joined: Wed Feb 23, 2011 9:04 am

Re: False error when loading height map

Post by Voxel »

Hi 0lenny0,

maybe the actual working directory within your IDE is different?

Try this to get information about the actual working directory:

Code: Select all

 
void ShowInfoAboutActualWorkingDirectory()
{
    TCHAR szCurDir[1024];
    szCurDir[0] = '\0';
    GetCurrentDirectory (1024, szCurDir);
    
    CString csCurrentDirectory(szCurDir);
 
    AfxMessageBox((LPCTSTR)(csCurrentDirectory));
}
 
Regards,
Voxel
0lenny0
Posts: 2
Joined: Wed Feb 22, 2012 1:45 pm

Re: False error when loading height map

Post by 0lenny0 »

I saw that the working directory in fact was wrong.
Once changed to the location where i output my files and put my resources everything ran just fine.
Thanks for the help.
Post Reply