Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find assets #98

Closed
mandyedi opened this issue Jan 31, 2021 · 7 comments
Closed

Can't find assets #98

mandyedi opened this issue Jan 31, 2021 · 7 comments

Comments

@mandyedi
Copy link

mandyedi commented Jan 31, 2021

Hi vkoskiv,
I built a release following your instructions and when I run

bin\Release\c-ray.exe input\scene.json

it gives the following errors:

': Invalid argument3:52:41]: Can't access 'input\//tonni.mtl
': Invalid argument3:52:41]: Can't access 'input\//newScene.mtl
': Invalid argument3:52:41]: Can't access 'input\//torus.mtl
': Invalid argument3:52:41]: Can't access 'input\//teapot.mtl
': Invalid argument3:52:41]: Can't access 'input\//teapot_green.mtl

If I run it from Visual Studio and set command line arguments to c:\github\c-ray\input\scene.json, it gives the following errors:

[WARN][2021-01-31 23:54:53]: Can't access '/tonni.obj': No such file or directory
[WARN][2021-01-31 23:54:53]: Can't access '/newScene.obj': No such file or directory
[WARN][2021-01-31 23:54:53]: Can't access '/torus.obj': No such file or directory
[WARN][2021-01-31 23:54:53]: Can't access '/teapot.obj': No such file or directory
[WARN][2021-01-31 23:54:53]: Can't access '/teapot_green.obj': No such file or directory
[INFO][2021-01-31 23:54:53]: Loading mesh 6/6
[WARN][2021-01-31 23:54:53]: Can't access '/teapot_blue.obj': No such file or directory

I started to debug it. Do you have any workaround or is it a known issue?

@vkoskiv
Copy link
Owner

vkoskiv commented Feb 1, 2021

Hi! Thanks for reporting this.

Interesting! Looks like a regression, likely my fault for not checking the newer file loading code thoroughly on Windows.

I don't have a Windows box on hand to start debugging right now, but it looks like the issue is likely in getFilePath(), where it blindly appends a forward slash, assuming it'll be a UNIX filepath.

Specifically we get two forward slashes, since we reconstruct the full path to the mtl file in parseWavefront(), and then again grab the asset path from that full string in parseMTLFile().

Could you try substituting that getFilePath() function with this one below, and see if it works? I can test it myself later this week as well if you're busy.

char *getFilePath(const char *input) {
	char *dir = NULL;
#ifdef WINDOWS
	dir = calloc(256, sizeof(*dir));
	_splitpath_s(input, NULL, 0, dir, sizeof(dir), NULL, 0, NULL, 0);
	return dir;
#else
	char *inputCopy = stringCopy(input);
	dir = stringCopy(dirname(inputCopy));
	free(inputCopy);
	char *final = stringConcat(dir, "/");
	free(dir);
	return final;
#endif
}

@mandyedi
Copy link
Author

mandyedi commented Feb 2, 2021

Thank you for your reply. I tested with the given modification but still have the issue.
I also built and ran on Linux and got this:

': No such file or directory Can't access './input/tonni.mtl
': No such file or directory Can't access './input/newScene.mtl
': No such file or directory Can't access './input/torus.mtl
': No such file or directory Can't access './input/teapot.mtl
': No such file or directory Can't access './input/teapot_green.mtl

@vkoskiv
Copy link
Owner

vkoskiv commented Feb 2, 2021

@mandyedi Is that under Visual Studio? If so, c-ray assumes you're using relative paths from the current working directory. Try setting the CWD to the project root directory.

The earlier invocation you showed:

bin\Release\c-ray.exe input\scene.json

from the command prompt looks to be doing this correctly already, so that should work.

@Nolram12345
Copy link

+1 I have this same issue currently on Windows. It can't find the assets and crashes.

@vkoskiv
Copy link
Owner

vkoskiv commented Apr 8, 2021

I fired up a Win10 VM and took a look. I think I resolved the file loading + crashing issue. Turns out, they were two unrelated problems.
Let me know if it works for you now.

Resolved by #101

@mandyedi
Copy link
Author

I tested it and works fine.
Thank you!

@vkoskiv
Copy link
Owner

vkoskiv commented Apr 19, 2021

Great to hear! Closing this as resolved, then.

@vkoskiv vkoskiv closed this as completed Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants