Skip to content

Commit

Permalink
Single file rigid body simulator and BVH-based closet point queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
xelatihy committed May 8, 2016
1 parent da84b81 commit bc64ec9
Show file tree
Hide file tree
Showing 13 changed files with 2,648 additions and 95 deletions.
1 change: 1 addition & 0 deletions apps/build.linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ $cc $cflags apps/yview.c $linkflags -o bin/yview
$cc $cflags apps/ytrace.c $linkflags -o bin/ytrace
$cc -DYA_NOGL $cflags apps/ytrace.c $linkflags -o bin/ytrace-cli
$cc $cflags apps/yshade.c $linkflags -o bin/yshade
$cc $cflags apps/ysym.c $linkflags -o bin/ysym
$cc $cflags apps/ytestgen.c $linkflags -o bin/ytestgen
1 change: 1 addition & 0 deletions apps/build.osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ $cc $cflags $linkflags apps/yview.c -o bin/yview &
$cc $cflags $linkflags apps/ytrace.c -o bin/ytrace &
$cc -DYA_NOGL $cflags $linkflags apps/ytrace.c -o bin/ytrace-cli &
$cc $cflags $linkflags apps/yshade.c -o bin/yshade &
$cc $cflags $linkflags apps/ysym.c -o bin/ysym &
$cc $cflags $linkflags apps/ytestgen.c -o bin/ytestgen &
wait
25 changes: 21 additions & 4 deletions apps/yshade.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ ui_loop(const char* filename, const char* imfilename, yo_scene* scene, int w,

// glfw
if (!glfwInit()) exit(EXIT_FAILURE);
GLFWwindow* window = glfwCreateWindow(view->w, view->h, "mview", 0, 0);
GLFWwindow* window = glfwCreateWindow(view->w, view->h, "yshade", 0, 0);
glfwMakeContextCurrent(window);
glfwSetWindowUserPointer(window, view);

Expand All @@ -402,8 +402,8 @@ ui_loop(const char* filename, const char* imfilename, yo_scene* scene, int w,
glfwSetMouseButtonCallback(window, mouse_button_callback);
glfwSetCursorPosCallback(window, mouse_pos_callback);
glfwSetWindowRefreshCallback(window, window_refresh_callback);
// init gl extensions

// init gl extensions
#ifdef YG_USING_GLEW
if (glewInit() != GLEW_OK) exit(EXIT_FAILURE);
#endif
Expand Down Expand Up @@ -446,11 +446,28 @@ load_scene(const char* filename, bool triangulate) {
yo_scene* scene = (strcmp(ext, ".objbin"))
? yo_load_obj(filename, triangulate, true)
: yo_load_objbin(filename, true);
if (!scene) return 0;
if (!scene) {
printf("unable to load scene %s\n", filename);
return 0;
}

// load textures
yo_load_textures(scene, filename, 0);

// check texture and return error if not found
for (int t = 0; t < scene->ntextures; t++) {
yo_texture* txt = &scene->textures[t];
if (!txt->pixels) {
printf("unable to load texture %s\n", txt->path);
txt->width = 1;
txt->height = 1;
txt->ncomp = 4;
ym_vec4f white = { 1, 1, 1, 1 };
txt->pixels = (float*)calloc(4, sizeof(float));
*(ym_vec4f*)txt->pixels = white;
}
}

// ensure normals
for (int s = 0; s < scene->nshapes; s++) {
yo_shape* shape = &scene->shapes[s];
Expand Down
Loading

0 comments on commit bc64ec9

Please sign in to comment.