-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plane.cpp
56 lines (51 loc) · 1014 Bytes
/
Plane.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
//
// Plane class
//
#include "Plane.h"
//
// Constructor
//
Plane::Plane(const QString tex, float _rad)
{
rad = _rad;
sx = sy = sz = 1;
if (tex.length()>0) setTexture(tex);
}
//
// Set scaling
//
void Plane::setScale(float dx,float dy,float dz)
{
sx = dx;
sy = dy;
sz = dz;
}
//
// Display the Plane
//
void Plane::display()
{
if (!show) return;
// Save transformation
glPushMatrix();
// Offset, scale and rotate
useTransform(sx,sy,sz);
// Texture on
EnableTex();
// Front
useColor();
float step = rad / 128.0;
for(float z = -rad; z <= rad; z += step) {
glBegin(GL_QUAD_STRIP);
for(float x = -rad; x < rad; x += step) {
glNormal3f(0, 1, 0);
glTexCoord2f((x+rad)/(2.0*rad),(z +rad)/(2*rad)); glVertex3f(x,0.0, z);
glTexCoord2f((x+rad)/(2.0*rad),(z+step+rad)/(2*rad)); glVertex3f(x,0.0, z+step);
}
glEnd();
}
// Texture off
DisableTex();
// Undo transofrmations
glPopMatrix();
}