-
Notifications
You must be signed in to change notification settings - Fork 0
/
Internode.cpp
61 lines (46 loc) · 1.22 KB
/
Internode.cpp
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
54
55
56
57
58
59
60
61
#include "Internode.h"
#include <math.h>
#include "GL/glut.h"
#include "Config.h"
#include "Common.h"
int nInternodeCount = 0;
float Internode::_specular[] = {128.f/255, 64.f/255, 0, 1};
void Internode::Render()
{
glPushMatrix();
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, _specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, _specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, _specular);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
GLUquadricObj *pInternode = gluNewQuadric(); // TODO: it is slow
glPushMatrix();
glTranslatef(pos.x(), pos.y(), pos.z());
Vect3d axis = Vect3d(0, 1, 0).Cross(vec);
axis.Normalize();
float a = acos(Vect3d(0, 1, 0).Dot(vec) / vec.Length()) * 180 / PI;
glRotatef(a, axis.x(), axis.y(), axis.z());
glRotatef(-90, 1, 0, 0);
width = pow(sqrt(1.6),(int)(GrownStep - nGrowthStep)) * 0.04;
gluCylinder(pInternode, width, width, vec.Length(), 15, 15);
gluDeleteQuadric(pInternode);
glPopMatrix();
// Render Buds
if(iRenderBud != 0)
{
if(pTerminalBud != NULL)
{
pTerminalBud->Render();
}
if(pAnxillaryBud != NULL)
{
pAnxillaryBud->Render();
}
}
//// Render Leaf
//if(pLeaf != NULL)
//{
// pLeaf->Render();
//}
//
glPopMatrix();
}