20                          float vx, 
float vy, 
float vz,
 
   23    double rhos  = sqrt (vx*vx+vy*vy+vz*vz);
 
   24    float phi   = acos(vz/rhos);
 
   25    float theta = atan2 (vy, vx);
 
   28    mtx = glm::translate(mtx, glm::vec3(x, y, z));
 
   29    mtx = glm::rotate(mtx, theta, glm::vec3(0.f, 0.f, 1.f));
 
   30    mtx = glm::rotate(mtx, phi, glm::vec3(0.f, 1.f, 0.f));
 
   31    mtx = glm::scale(mtx, glm::vec3(cone_scale/4.));
 
   32    mtx = glm::translate(mtx, glm::vec3(0, 0, 4));
 
   34    norm = glm::inverseTranspose(norm);
 
   36    glm::vec3 start_vtx = glm::vec3(mtx * glm::vec4(0.f, 0.f, 0.f, 1.f));
 
   37    glm::vec3 start_norm = glm::vec3(norm * glm::vec3(0.f, 0.f, 1.f));
 
   39    glm::vec3 base_pts[] =
 
   41       glm::vec3(mtx * glm::vec4(1, 0, -4, 1)),
 
   42       glm::vec3(mtx * glm::vec4(cos(2*M_PI/4), sin(2*M_PI/4), -4, 1)),
 
   43       glm::vec3(mtx * glm::vec4(cos(4*M_PI/4), sin(4*M_PI/4), -4, 1)),
 
   44       glm::vec3(mtx * glm::vec4(cos(6*M_PI/4), sin(6*M_PI/4), -4, 1)),
 
   48    glm::vec3 base_norms[] =
 
   50       glm::vec3(norm * glm::vec3(1, 0, nz)),
 
   51       glm::vec3(norm * glm::vec3(cos(2*M_PI/4), sin(2*M_PI/4), nz)),
 
   52       glm::vec3(norm * glm::vec3(cos(4*M_PI/4), sin(4*M_PI/4), nz)),
 
   53       glm::vec3(norm * glm::vec3(cos(6*M_PI/4), sin(6*M_PI/4), nz)),
 
   56    float* orig = glm::value_ptr(start_vtx);
 
   57    float* orig_n = glm::value_ptr(start_norm);
 
   60       glm::value_ptr(base_pts[0]),
 
   61       glm::value_ptr(base_pts[1]),
 
   62       glm::value_ptr(base_pts[2]),
 
   63       glm::value_ptr(base_pts[3])
 
   67       glm::value_ptr(base_norms[0]),
 
   68       glm::value_ptr(base_norms[1]),
 
   69       glm::value_ptr(base_norms[2]),
 
   70       glm::value_ptr(base_norms[3])
 
   73    std::vector<float> cone_pts;
 
   74    for (
int i = 0; i < 4; i++)
 
   79          {orig[0],   orig[1],   orig[2]},
 
   80          {orig_n[0], orig_n[1], orig_n[2]}
 
   84          {base[i][0],   base[i][1],   base[i][2]},
 
   85          {base_n[i][0], base_n[i][1], base_n[i][2]}
 
   89          {base[(i+1)%4][0],   base[(i+1)%4][1],   base[(i+1)%4][2]},
 
   90          {base_n[(i+1)%4][0], base_n[(i+1)%4][1], base_n[(i+1)%4][2]}
 
   96 void GlBuilder::saveVertex(
const GlBuilder::FFState& v)
 
   98    GLenum dst_buf = is_line ? GL_LINES : GL_TRIANGLES;
 
   99    if (is_line || !use_norm)
 
  108          parent_buf->getBuffer<
VertexTex>(dst_buf)
 
  109          ->addVertex(
VertexTex{v.coords, v.texcoord});
 
  113          parent_buf->getBuffer<
Vertex>(dst_buf)
 
  114          ->addVertex(
Vertex{v.coords});
 
std::array< uint8_t, 4 > color
void addCone(float x, float y, float z, float vx, float vy, float vz, float cone_scale=0.075)
void addTriangle(const Vert &v1, const Vert &v2, const Vert &v3)
std::array< float, 3 > norm
std::array< float, 3 > norm
std::array< float, 3 > norm