git-svn-id: svn://db.shs.com.ru/libs@44 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2015-11-20 21:19:36 +00:00
parent cabaead1c6
commit 104a7f99ad
48 changed files with 1973 additions and 1273 deletions

View File

@@ -77,8 +77,8 @@ GLObjectBase * GLObjectBase::clone(bool withChildren) {
return o;
}
void GLObjectBase::draw(bool simplest) {
vbo.draw(geom_prim, simplest);
void GLObjectBase::draw(QGLShaderProgram * prog, bool simplest) {
vbo.draw(geom_prim, prog, simplest);
/*if (!d_vertices.isEmpty()) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glVertexPointer(3, GL_FLOAT, 0, d_vertices.constData());
@@ -147,7 +147,7 @@ void GLObjectBase::buildTransform() {
itransform_.setToIdentity();
GLObjectBase * p = parent_;
if (p != 0)
itransform_ *= p->itransform_;
itransform_ = p->itransform_;
if (raw_matrix) {
itransform_.translate(pos_);
itransform_ *= mat_;
@@ -159,6 +159,7 @@ void GLObjectBase::buildTransform() {
itransform_.rotate(angles_.x(), 1., 0., 0.);
itransform_.scale(scale_);
}
//qDebug() << name_ << itransform_;
foreach (GLObjectBase * i, children_)
i->buildTransform();
}
@@ -170,29 +171,36 @@ void GLObjectBase::checkPass() {
}
QMatrix4x4 GLObjectBase::worldMatrix(QMatrix4x4 parent) const {
QMatrix4x4 mat;
mat.translate(pos_);
if (raw_matrix) {
mat *= mat_;
} else {
if (angles_.z() != 0.) mat.rotate(angles_.z(), 0., 0., 1.);
if (angles_.y() != 0.) mat.rotate(angles_.y(), 0., 1., 0.);
if (angles_.x() != 0.) mat.rotate(angles_.x(), 1., 0., 0.);
mat.scale(scale_);
}
return parent * mat;
}
void GLObjectBase::render(int * id, QMap<int, GLObjectBase * > * ids, int sh_id_loc) {
if (!visible_) return;
glPushMatrix();
if (pos_.x() != 0. || pos_.y() != 0. || pos_.z() != 0.) glTranslated(pos_.x(), pos_.y(), pos_.z());
if (raw_matrix) {
qglMultMatrix(mat_);
} else {
if (angles_.z() != 0.) glRotated(angles_.z(), 0., 0., 1.);
if (angles_.y() != 0.) glRotated(angles_.y(), 0., 1., 0.);
if (angles_.x() != 0.) glRotated(angles_.x(), 1., 0., 0.);
if (scale_.x() != 1. || scale_.y() != 1. || scale_.z() != 1.) glScaled(scale_.x(), scale_.y(), scale_.z());
}
material_.apply();
//glPushMatrix();
///qglMultMatrix TODO
material_.apply(0);
if (id != 0) {
++(*id);
ids->insert(*id, this);
//glVertexAttrib1f(sh_id_loc, (*id) / 255.f);
//qDebug() << "assign to" << sh_id_loc << (*id) / 255.f;
}
draw();
draw(0);
foreach (GLObjectBase * i, children_)
i->render(id, ids, sh_id_loc);
glPopMatrix();
//glPopMatrix();
}
@@ -217,7 +225,7 @@ GLObjectBase * Light::clone(bool withChildren) {
}
void Light::draw(bool simplest) {
void Light::draw(QGLShaderProgram * prog, bool simplest) {
bool l = glIsEnabled(GL_LIGHTING);
glDisable(GL_LIGHTING);
glPointSize(8.);