summaryrefslogtreecommitdiffstats
path: root/debian/fireflies/fireflies-2.08/src/arrow.cc
blob: 12d03d5aaf5c543d1e8f497c2536f440d6afb94b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "arrow.h"
#include "scene.h"

// Draw a wireframe axis-aligned box whose opposite corners are given by the
// points 'min' and 'max'.
void draw_box(const Vec3f& min, const Vec3f& max)
{
    glBegin(GL_LINE_LOOP);
    glVertex3d(min[0],min[1],min[2]); glVertex3d(min[0],max[1],min[2]);
    glVertex3d(max[0],max[1],min[2]); glVertex3d(max[0],min[1],min[2]);
    glEnd();
    
    glBegin(GL_LINE_LOOP);
    glVertex3d(min[0],min[1],max[2]); glVertex3d(min[0],max[1],max[2]);
    glVertex3d(max[0],max[1],max[2]); glVertex3d(max[0],min[1],max[2]);
    glEnd();
    
    glBegin(GL_LINES);
    glVertex3d(min[0],min[1],min[2]); glVertex3d(min[0],min[1],max[2]);
    glVertex3d(min[0],max[1],min[2]); glVertex3d(min[0],max[1],max[2]);
    glVertex3d(max[0],max[1],min[2]); glVertex3d(max[0],max[1],max[2]);
    glVertex3d(max[0],min[1],min[2]); glVertex3d(max[0],min[1],max[2]);
    glEnd();
}

void Arrow::draw()
{
    glColor4fv(color);
    apply_transform();

    glBegin(GL_TRIANGLE_FAN); // the front pyramid
    glVertex3d(0., 0., scene.fsize*3); // height
    glVertex3d(scene.fsize, 0., 0.);
    glVertex3d(0., -scene.fsize, 0.);
    glVertex3d(-scene.fsize, 0., 0.);
    glVertex3d(0., scene.fsize, 0.);
    glEnd();

    glBegin(GL_TRIANGLE_FAN); // the butt pyramid
    glVertex3d(0., 0., -scene.fsize*2); // height
    glVertex3d(scene.fsize, 0., 0.);
    glVertex3d(0., -scene.fsize, 0.);
    glVertex3d(-scene.fsize, 0., 0.);
    glVertex3d(0., scene.fsize, 0.);
    glEnd();
}

void Arrow::point(Vec3f dir)
{
    double angle = acos(Vec3f(0, 0, 1)*unit_vec(dir));
    rot_axis = unit_vec(cross(Vec3f(0, 0, 1), dir));
    rot_angle = RAD_TO_DEG(angle);
}