git-svn-id: svn://db.shs.com.ru/libs@75 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -296,30 +296,40 @@ void Light::draw(QGLShaderProgram * prog, bool simplest) {
|
||||
|
||||
QDataStream & operator <<(QDataStream & s, const GLObjectBase * p) {
|
||||
ChunkStream cs;
|
||||
//qDebug() << "place" << p->name() << "...";
|
||||
cs << cs.chunk(1, int(p->type_)) << cs.chunk(2, p->accept_light) << cs.chunk(3, p->accept_fog) << cs.chunk(4, p->visible_)
|
||||
<< cs.chunk(5, p->cast_shadow) << cs.chunk(6, p->rec_shadow) << cs.chunk(7, p->raw_matrix) << cs.chunk(8, p->line_width)
|
||||
<< cs.chunk(9, int(p->render_mode)) << cs.chunk(10, p->material_) << cs.chunk(11, p->pos_) << cs.chunk(12, p->angles_)
|
||||
<< cs.chunk(13, p->scale_) << cs.chunk(14, p->mat_) << cs.chunk(15, p->vbo) << cs.chunk(16, p->children_)
|
||||
<< cs.chunk(13, p->scale_) << cs.chunk(14, p->mat_) << cs.chunk(15, p->vbo) << cs.chunk(16, p->children_.size())
|
||||
<< cs.chunk(17, p->name_);
|
||||
//qDebug() << "place self done";
|
||||
if (p->type_ == GLObjectBase::glLight) {
|
||||
//qDebug() << "place light ...";
|
||||
Light * l = (Light*)p;
|
||||
cs << cs.chunk(100, l->direction) << cs.chunk(101, l->angle_start) << cs.chunk(102, l->angle_end) << cs.chunk(103, l->intensity)
|
||||
<< cs.chunk(104, l->decay_const) << cs.chunk(105, l->decay_linear) << cs.chunk(106, l->decay_quadratic)
|
||||
<< cs.chunk(107, l->decay_start) << cs.chunk(108, l->decay_end) << cs.chunk(109, int(l->light_type));
|
||||
}
|
||||
if (p->type_ == GLObjectBase::glCamera) {
|
||||
//qDebug() << "place camera ...";
|
||||
Camera * c = (Camera*)p;
|
||||
cs << cs.chunk(200, c->aim_) << cs.chunk(201, c->fov_) << cs.chunk(202, c->depth_start) << cs.chunk(203, c->depth_end)
|
||||
<< cs.chunk(204, c->angle_limit_lower_xy) << cs.chunk(205, c->angle_limit_upper_xy)
|
||||
<< cs.chunk(206, c->mirror_x) << cs.chunk(207, c->mirror_y);
|
||||
}
|
||||
s << cs.data(); return s;
|
||||
//qDebug() << "place" << p->name() << cs.data().size() << s.device()->size();
|
||||
s << cs.data();
|
||||
foreach (const GLObjectBase * c, p->children_)
|
||||
s << c;
|
||||
return s;
|
||||
}
|
||||
QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
|
||||
ChunkStream cs(s);
|
||||
p = 0;
|
||||
int ccnt = 0;
|
||||
Light * l = 0;
|
||||
Camera * c = 0;
|
||||
//qDebug() << "read obj ...";
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
case 1:
|
||||
@@ -348,12 +358,7 @@ QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
|
||||
case 13: if (p) p->scale_ = cs.getData<QVector3D>(); break;
|
||||
case 14: if (p) p->mat_ = cs.getData<QMatrix4x4>(); break;
|
||||
case 15: if (p) p->vbo = cs.getData<GLVBO>(); break;
|
||||
case 16: if (p) {
|
||||
p->children_ = cs.getData<QList<GLObjectBase * > >();
|
||||
foreach (GLObjectBase * c_, p->children_)
|
||||
c_->parent_ = p;
|
||||
}
|
||||
break;
|
||||
case 16: if (p) ccnt = cs.getData<int>(); break;
|
||||
case 17: if (p) p->name_ = cs.getData<QString>(); break;
|
||||
case 100: if (l) l->direction = cs.getData<QVector3D>(); break;
|
||||
case 101: if (l) l->angle_start = cs.getData<GLdouble>(); break;
|
||||
@@ -375,5 +380,13 @@ QDataStream & operator >>(QDataStream & s, GLObjectBase *& p) {
|
||||
case 207: if (c) c->mirror_y = cs.getData<bool>(); break;
|
||||
}
|
||||
}
|
||||
//qDebug() << p->name() << ccnt;
|
||||
for (int i = 0; i < ccnt; ++i) {
|
||||
GLObjectBase * c = 0;
|
||||
s >> c;
|
||||
if (!c) continue;
|
||||
c->parent_ = p;
|
||||
p->children_ << c;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user