Esempio n. 1
0
static void DrawBone(S32 jointIndex, Animation_Joint *jointList, M4 *globalTransforms, M4 modelMatrix) {
  static const V4 LINE_COLOR = COLOR_YELLOW;
  Animation_Joint *joint = &jointList[jointIndex];
  if (joint->child_index != -1) {
    V4 start = globalTransforms[jointIndex] * V4(0.0f, 0.0f, 0.0f, 1.0f);
    V4 end = globalTransforms[joint->child_index] * V4(0.0f, 0.0f, 0.0f, 1.0f);
    start = modelMatrix * start;
    end = modelMatrix * end;
    draw_debug_line(V3(start), V3(end), LINE_COLOR);
  } else {
    V4 start = globalTransforms[jointIndex] * V4(0.0f, 0.0f, 0.0f, 1.0f);
    V4 end = globalTransforms[jointIndex] * V4(0.0f, 1.0f, 0.0f, 1.0f);
    start = modelMatrix * start;
    end = modelMatrix * end;
    draw_debug_line(V3(start), V3(end), LINE_COLOR);
  }
}
Esempio n. 2
0
void draw(int deltaTimeMs)
{
    float deltaTimeS = (float) deltaTimeMs / 1000;
    float fps = (float) 1.0 / deltaTimeS;

    debug_line_num = 0;

    renderToBuffer(renderer, map_tex, NULL, &map_rect);

    for (int i = 0; i < MAX_ENTITIES; i++) {
        if (entities[i] != NULL)
            renderEntity(renderer, entities[i], (int[3])WORLD_COLOR_HARD);
    }

    char str[10];
    sprintf(str, "%3.2f fps", fps);
    draw_debug_line(str, 50);

    sprintf(str, "x: %d y: %d", mouse_x, mouse_y);
    draw_debug_line(str, 80);

    sprintf(str, "px: %2.0f py: %2.0f", character->x, character->y);
    draw_debug_line(str, 80);

    sprintf(str, "angle: %3.4f", character->torso_angle);
    draw_debug_line(str, 100);

    sprintf(str, "cx: %d cy: %d", camera.x, camera.y);
    draw_debug_line(str, 80);

    sprintf(str, "mx: %d my: %d", map_rect.x, map_rect.y);
    draw_debug_line(str, 80);

    sprintf(str, "dx: %3.1f dy: %3.1f", deltaX, deltaY);
    draw_debug_line(str, 100);

    double x = character->x + 32;
    double y = character->y + 32;
    SDL_RenderDrawLine(renderer, x, y, mouse_x, mouse_y);
    SDL_RenderDrawLine(renderer, x, y, mouse_x, y);
    SDL_RenderDrawLine(renderer, mouse_x, y, mouse_x, mouse_y);
    SDL_RenderDrawLine(renderer, x, y, x, mouse_y);
    SDL_RenderDrawLine(renderer, x, mouse_y, mouse_x, mouse_y);
}