Phlex
09-04-2009, 08:16 PM
Hey, I've been using the ray trace tutorial here - http://www.codermind.com/articles/Raytracer-in-C++-Depth-of-field-Fresnel-blobs.html - and when I tried to use the source, I encountered a problem.
The sample source code is set up to read information from a txt file, it seems to work fine, although, when I pass in the names of images for a skybox, it does not work, they are defined like this in the txt file
Cubemap.Up = alpup.tga;
Cubemap.Down = alpdown.tga;
Cubemap.Right = alpright.tga;
Cubemap.Left = alpleft.tga;
Cubemap.Forward = alpforward.tga;
Cubemap.Backward = alpback.tga;
These are then read as such in the application:
myScene.cm.name[cubemap::up] = sceneFile.GetByNameAsString("Cubemap.Up", emptyString);
myScene.cm.name[cubemap::down] = sceneFile.GetByNameAsString("Cubemap.Down", emptyString);
myScene.cm.name[cubemap::right] = sceneFile.GetByNameAsString("Cubemap.Right", emptyString);
myScene.cm.name[cubemap::left] = sceneFile.GetByNameAsString("Cubemap.Left", emptyString);
myScene.cm.name[cubemap::forward] = sceneFile.GetByNameAsString("Cubemap.Forward", emptyString);
myScene.cm.name[cubemap::backward] = sceneFile.GetByNameAsString("Cubemap.Backward", emptyString);
The function works fine, however, when it gets to this part of the code:
currentfile.open(name[up].c_str(), ios_base::binary);
if ((!currentfile)||(!dummyTGAHeader(currentfile, sizeX, sizeY)))
return false;
it returns false, and I don't know why, the files are in the same directory as the executable, but still, currentfile is not opening the file as it returns false. Any ideas? Thanks.
The sample source code is set up to read information from a txt file, it seems to work fine, although, when I pass in the names of images for a skybox, it does not work, they are defined like this in the txt file
Cubemap.Up = alpup.tga;
Cubemap.Down = alpdown.tga;
Cubemap.Right = alpright.tga;
Cubemap.Left = alpleft.tga;
Cubemap.Forward = alpforward.tga;
Cubemap.Backward = alpback.tga;
These are then read as such in the application:
myScene.cm.name[cubemap::up] = sceneFile.GetByNameAsString("Cubemap.Up", emptyString);
myScene.cm.name[cubemap::down] = sceneFile.GetByNameAsString("Cubemap.Down", emptyString);
myScene.cm.name[cubemap::right] = sceneFile.GetByNameAsString("Cubemap.Right", emptyString);
myScene.cm.name[cubemap::left] = sceneFile.GetByNameAsString("Cubemap.Left", emptyString);
myScene.cm.name[cubemap::forward] = sceneFile.GetByNameAsString("Cubemap.Forward", emptyString);
myScene.cm.name[cubemap::backward] = sceneFile.GetByNameAsString("Cubemap.Backward", emptyString);
The function works fine, however, when it gets to this part of the code:
currentfile.open(name[up].c_str(), ios_base::binary);
if ((!currentfile)||(!dummyTGAHeader(currentfile, sizeX, sizeY)))
return false;
it returns false, and I don't know why, the files are in the same directory as the executable, but still, currentfile is not opening the file as it returns false. Any ideas? Thanks.