#include "model.h"

void init_model(Model *model) {
  model->vertex_data.vertices.resize(36);

  /* front */
  model->vertex_data.vertices[0].position = Vector3(-0.5f, -0.5f,  0.5f);
  model->vertex_data.vertices[1].position = Vector3( 0.5f,  0.5f,  0.5f);
  model->vertex_data.vertices[2].position = Vector3(-0.5f,  0.5f,  0.5f);
  model->vertex_data.vertices[3].position = Vector3(-0.5f, -0.5f,  0.5f);
  model->vertex_data.vertices[4].position = Vector3( 0.5f, -0.5f,  0.5f);
  model->vertex_data.vertices[5].position = Vector3( 0.5f,  0.5f,  0.5f);

  model->vertex_data.vertices[0].color = Vector3(1.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[1].color = Vector3(1.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[2].color = Vector3(1.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[3].color = Vector3(1.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[4].color = Vector3(1.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[5].color = Vector3(1.0f, 0.5f, 0.5f);

  model->vertex_data.vertices[0].uv = Vector2(0.0, 0.0);
  model->vertex_data.vertices[1].uv = Vector2(1.0, 1.0);
  model->vertex_data.vertices[2].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[3].uv = Vector2(0.0, 0.0);
  model->vertex_data.vertices[4].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[5].uv = Vector2(1.0, 1.0);

  /* back */
  model->vertex_data.vertices[6].position = Vector3(-0.5f, -0.5f,  -0.5f);
  model->vertex_data.vertices[7].position = Vector3(-0.5f,  0.5f,  -0.5f);
  model->vertex_data.vertices[8].position = Vector3( 0.5f,  0.5f,  -0.5f);
  model->vertex_data.vertices[9].position = Vector3(-0.5f, -0.5f,  -0.5f);
  model->vertex_data.vertices[10].position = Vector3( 0.5f,  0.5f,  -0.5f);
  model->vertex_data.vertices[11].position = Vector3( 0.5f, -0.5f,  -0.5f);

  model->vertex_data.vertices[6].color = Vector3(0.5f, 1.0f, 0.5f);
  model->vertex_data.vertices[7].color = Vector3(0.5f, 1.0f, 0.5f);
  model->vertex_data.vertices[8].color = Vector3(0.5f, 1.0f, 0.5f);
  model->vertex_data.vertices[9].color = Vector3(0.5f, 1.0f, 0.5f);
  model->vertex_data.vertices[10].color = Vector3(0.5f, 1.0f, 0.5f);
  model->vertex_data.vertices[11].color = Vector3(0.5f, 1.0f, 0.5f);

  model->vertex_data.vertices[6].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[7].uv = Vector2(1.0, 1.0);
  model->vertex_data.vertices[8].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[9].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[10].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[11].uv = Vector2(0.0, 0.0);

  /* left */
  model->vertex_data.vertices[12].position = Vector3(-0.5f, -0.5f,  0.5f);
  model->vertex_data.vertices[13].position = Vector3(-0.5f,  0.5f,  0.5f);
  model->vertex_data.vertices[14].position = Vector3(-0.5f,  0.5f,  -0.5f);
  model->vertex_data.vertices[15].position = Vector3(-0.5f, -0.5f,  0.5f);
  model->vertex_data.vertices[16].position = Vector3(-0.5f,  0.5f, -0.5f);
  model->vertex_data.vertices[17].position = Vector3(-0.5f, -0.5f, -0.5f);

  model->vertex_data.vertices[12].color = Vector3(0.5f, 0.5f, 1.0f);
  model->vertex_data.vertices[13].color = Vector3(0.5f, 0.5f, 1.0f);
  model->vertex_data.vertices[14].color = Vector3(0.5f, 0.5f, 1.0f);
  model->vertex_data.vertices[15].color = Vector3(0.5f, 0.5f, 1.0f);
  model->vertex_data.vertices[16].color = Vector3(0.5f, 0.5f, 1.0f);
  model->vertex_data.vertices[17].color = Vector3(0.5f, 0.5f, 1.0f);

  model->vertex_data.vertices[12].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[13].uv = Vector2(1.0, 1.0);
  model->vertex_data.vertices[14].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[15].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[16].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[17].uv = Vector2(0.0, 0.0);

  /* right */
  model->vertex_data.vertices[18].position = Vector3(0.5f, -0.5f,  0.5f);
  model->vertex_data.vertices[19].position = Vector3(0.5f,  0.5f,  -0.5f);
  model->vertex_data.vertices[20].position = Vector3(0.5f,  0.5f,  0.5f);
  model->vertex_data.vertices[21].position = Vector3(0.5f, -0.5f,  0.5f);
  model->vertex_data.vertices[22].position = Vector3(0.5f, -0.5f, -0.5f);
  model->vertex_data.vertices[23].position = Vector3(0.5f,  0.5f, -0.5f);

  model->vertex_data.vertices[18].color = Vector3(0.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[19].color = Vector3(0.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[20].color = Vector3(0.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[21].color = Vector3(0.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[22].color = Vector3(0.0f, 0.5f, 0.5f);
  model->vertex_data.vertices[23].color = Vector3(0.0f, 0.5f, 0.5f);

  model->vertex_data.vertices[18].uv = Vector2(0.0, 0.0);
  model->vertex_data.vertices[19].uv = Vector2(1.0, 1.0);
  model->vertex_data.vertices[20].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[21].uv = Vector2(0.0, 0.0);
  model->vertex_data.vertices[22].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[23].uv = Vector2(1.0, 1.0);

  /* top */
  model->vertex_data.vertices[24].position = Vector3( 0.5f,  0.5f,  0.5f);
  model->vertex_data.vertices[25].position = Vector3(-0.5f,  0.5f,  -0.5f);
  model->vertex_data.vertices[26].position = Vector3(-0.5f,  0.5f,  0.5f);
  model->vertex_data.vertices[27].position = Vector3( 0.5f,  0.5f,  0.5f);
  model->vertex_data.vertices[28].position = Vector3( 0.5f,  0.5f,  -0.5f);
  model->vertex_data.vertices[29].position = Vector3(-0.5f,  0.5f,  -0.5f);

  model->vertex_data.vertices[24].color = Vector3(0.5f, 0.0f, 0.5f);
  model->vertex_data.vertices[25].color = Vector3(0.5f, 0.0f, 0.5f);
  model->vertex_data.vertices[26].color = Vector3(0.5f, 0.0f, 0.5f);
  model->vertex_data.vertices[27].color = Vector3(0.5f, 0.0f, 0.5f);
  model->vertex_data.vertices[28].color = Vector3(0.5f, 0.0f, 0.5f);
  model->vertex_data.vertices[29].color = Vector3(0.5f, 0.0f, 0.5f);

  model->vertex_data.vertices[24].uv = Vector2(0.0, 0.0);
  model->vertex_data.vertices[25].uv = Vector2(1.0, 1.0);
  model->vertex_data.vertices[26].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[27].uv = Vector2(0.0, 0.0);
  model->vertex_data.vertices[28].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[29].uv = Vector2(1.0, 1.0);

  /* bottom */
  model->vertex_data.vertices[30].position = Vector3( 0.5f,  -0.5f,  0.5f);
  model->vertex_data.vertices[31].position = Vector3(-0.5f,  -0.5f,  0.5f);
  model->vertex_data.vertices[32].position = Vector3(-0.5f,  -0.5f,  -0.5f);
  model->vertex_data.vertices[33].position = Vector3( 0.5f,  -0.5f,  0.5f);
  model->vertex_data.vertices[34].position = Vector3(-0.5f,  -0.5f,  -0.5f);
  model->vertex_data.vertices[35].position = Vector3( 0.5f,  -0.5f,  -0.5f);

  model->vertex_data.vertices[30].color = Vector3(0.5f, 0.5f, 0.0f);
  model->vertex_data.vertices[31].color = Vector3(0.5f, 0.5f, 0.0f);
  model->vertex_data.vertices[32].color = Vector3(0.5f, 0.5f, 0.0f);
  model->vertex_data.vertices[33].color = Vector3(0.5f, 0.5f, 0.0f);
  model->vertex_data.vertices[34].color = Vector3(0.5f, 0.5f, 0.0f);
  model->vertex_data.vertices[35].color = Vector3(0.5f, 0.5f, 0.0f);

  model->vertex_data.vertices[30].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[31].uv = Vector2(0.0, 0.0);
  model->vertex_data.vertices[32].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[33].uv = Vector2(0.0, 1.0);
  model->vertex_data.vertices[34].uv = Vector2(1.0, 0.0);
  model->vertex_data.vertices[35].uv = Vector2(1.0, 1.0);
}
