code format
This commit is contained in:
@@ -28,7 +28,6 @@ void GLPrimitivePoint::draw(QOpenGLShaderProgram * prog, bool simplest) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLPrimitiveLine::draw(QOpenGLShaderProgram * prog, bool simplest) {
|
||||
glColor3f(material_.color_diffuse.redF(), material_.color_diffuse.greenF(), material_.color_diffuse.blueF());
|
||||
glBegin(GL_LINES);
|
||||
@@ -38,24 +37,24 @@ void GLPrimitiveLine::draw(QOpenGLShaderProgram * prog, bool simplest) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLPrimitiveCube::GLPrimitiveCube(float width, float length, float height, QVector3D pos): GLObjectBase() {
|
||||
geom_prim = Quads;
|
||||
w = width;
|
||||
l = length;
|
||||
h = height;
|
||||
w = width;
|
||||
l = length;
|
||||
h = height;
|
||||
moveTo(pos);
|
||||
//init();
|
||||
// init();
|
||||
}
|
||||
|
||||
|
||||
void GLPrimitiveCube::init() {
|
||||
float hw = w / 2.f, hl = l / 2.f, hh = h / 2.f;
|
||||
//list = glGenLists(1);
|
||||
//glNewList(list, GL_COMPILE);
|
||||
//glColor4d(material_.color_diffuse.redF(), material_.color_diffuse.greenF(), material_.color_diffuse.blueF(), material_.color_diffuse.alphaF());
|
||||
// list = glGenLists(1);
|
||||
// glNewList(list, GL_COMPILE);
|
||||
// glColor4d(material_.color_diffuse.redF(), material_.color_diffuse.greenF(), material_.color_diffuse.blueF(),
|
||||
// material_.color_diffuse.alphaF());
|
||||
vbo.init();
|
||||
QVector<GLfloat> & d_vertices(vbo.vertices()), & d_normals(vbo.normals()), & d_uvs(vbo.texcoords());
|
||||
QVector<GLfloat> &d_vertices(vbo.vertices()), &d_normals(vbo.normals()), &d_uvs(vbo.texcoords());
|
||||
d_vertices.clear();
|
||||
d_normals.clear();
|
||||
d_uvs.clear();
|
||||
@@ -108,13 +107,13 @@ void GLPrimitiveCube::init() {
|
||||
|
||||
GLPrimitiveEllipsoid::GLPrimitiveEllipsoid(float width, float length, float height, int seg_wl, int seg_h, QVector3D pos) {
|
||||
geom_prim = GLObjectBase::Triangles;
|
||||
w = width;
|
||||
l = length;
|
||||
h = height;
|
||||
swl = seg_wl;
|
||||
sh = seg_h;
|
||||
w = width;
|
||||
l = length;
|
||||
h = height;
|
||||
swl = seg_wl;
|
||||
sh = seg_h;
|
||||
moveTo(pos);
|
||||
//init();
|
||||
// init();
|
||||
}
|
||||
|
||||
|
||||
@@ -125,9 +124,12 @@ void GLPrimitiveEllipsoid::putTriangle(const QVector3D & v0, const QVector3D & v
|
||||
vbo.normals() << n.x() << n.y() << n.z();
|
||||
return;
|
||||
QVector3D s(w, l, h);
|
||||
n = (v0 * s).normalized(); vbo.normals() << n.x() << n.y() << n.z();
|
||||
n = (v1 * s).normalized(); vbo.normals() << n.x() << n.y() << n.z();
|
||||
n = (v2 * s).normalized(); vbo.normals() << n.x() << n.y() << n.z();
|
||||
n = (v0 * s).normalized();
|
||||
vbo.normals() << n.x() << n.y() << n.z();
|
||||
n = (v1 * s).normalized();
|
||||
vbo.normals() << n.x() << n.y() << n.z();
|
||||
n = (v2 * s).normalized();
|
||||
vbo.normals() << n.x() << n.y() << n.z();
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +137,7 @@ void GLPrimitiveEllipsoid::init() {
|
||||
QVector<QVector3D> points;
|
||||
vbo.clear();
|
||||
vbo.init();
|
||||
int ret = 0;
|
||||
int ret = 0;
|
||||
int hseg = sh + 1, wlseg = swl + 1;
|
||||
float crw, crl, a, ch, twl;
|
||||
QVector3D cp(0., 0., -h / 2.f);
|
||||
@@ -161,7 +163,8 @@ void GLPrimitiveEllipsoid::init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i == 1) putTriangle(points[0], points[ret - wlseg * 2 + 1], points[ret]);
|
||||
if (i == 1)
|
||||
putTriangle(points[0], points[ret - wlseg * 2 + 1], points[ret]);
|
||||
else {
|
||||
putTriangle(points[ret - wlseg * 2 + 1], points[ret], points[ret - wlseg * 2]);
|
||||
putTriangle(points[ret - wlseg * 2 + 1], points[ret - wlseg * 2], points[ret - wlseg * 4 + 1]);
|
||||
@@ -178,43 +181,43 @@ void GLPrimitiveEllipsoid::init() {
|
||||
|
||||
|
||||
void GLPrimitiveAxis::draw(QOpenGLShaderProgram * prog, bool simplest) {
|
||||
float bs = 1.f;
|
||||
float as = 0.1f;
|
||||
float aw = 0.07f;
|
||||
float bs = 1.f;
|
||||
float as = 0.1f;
|
||||
float aw = 0.07f;
|
||||
float cr_x = 0.8f, cg_y = 0.75f, cb_z = 0.8f;
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(cr_x, 0, 0);
|
||||
glVertex3f(-bs, 0, 0);
|
||||
glVertex3f(bs, 0, 0);
|
||||
glVertex3f(bs, 0, 0);
|
||||
glVertex3f(bs-as, aw, 0);
|
||||
glVertex3f(bs - as, aw, 0);
|
||||
glVertex3f(bs, 0, 0);
|
||||
glVertex3f(bs-as, -aw, 0);
|
||||
glVertex3f(bs - as, -aw, 0);
|
||||
glVertex3f(bs, 0, 0);
|
||||
glVertex3f(bs-as, 0, aw);
|
||||
glVertex3f(bs - as, 0, aw);
|
||||
glVertex3f(bs, 0, 0);
|
||||
glVertex3f(bs-as, 0, -aw);
|
||||
glVertex3f(bs - as, 0, -aw);
|
||||
glColor3f(0, cg_y, 0);
|
||||
glVertex3f(0, -bs, 0);
|
||||
glVertex3f(0, bs, 0);
|
||||
glVertex3f(0, bs, 0);
|
||||
glVertex3f(0, bs-as, aw);
|
||||
glVertex3f(0, bs - as, aw);
|
||||
glVertex3f(0, bs, 0);
|
||||
glVertex3f(0, bs-as, -aw);
|
||||
glVertex3f(0, bs - as, -aw);
|
||||
glVertex3f(0, bs, 0);
|
||||
glVertex3f(aw, bs-as, 0);
|
||||
glVertex3f(aw, bs - as, 0);
|
||||
glVertex3f(0, bs, 0);
|
||||
glVertex3f(-aw, bs-as, 0);
|
||||
glVertex3f(-aw, bs - as, 0);
|
||||
glColor3f(0, 0, cb_z);
|
||||
glVertex3f(0, 0, -bs);
|
||||
glVertex3f(0, 0, bs);
|
||||
glVertex3f(0, 0, bs);
|
||||
glVertex3f(aw, 0, bs-as);
|
||||
glVertex3f(aw, 0, bs - as);
|
||||
glVertex3f(0, 0, bs);
|
||||
glVertex3f(-aw, 0, bs-as);
|
||||
glVertex3f(-aw, 0, bs - as);
|
||||
glVertex3f(0, 0, bs);
|
||||
glVertex3f(0, aw, bs-as);
|
||||
glVertex3f(0, aw, bs - as);
|
||||
glVertex3f(0, 0, bs);
|
||||
glVertex3f(0, -aw, bs-as);
|
||||
glVertex3f(0, -aw, bs - as);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user