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

This commit is contained in:
2015-12-09 15:44:03 +00:00
parent 64f21dc682
commit 458a516317
31 changed files with 1486 additions and 870 deletions

View File

@@ -24,13 +24,17 @@
#include "glmaterial.h"
class Camera;
class QGLView;
class GLObjectBase
{
friend class QGLView;
friend class GLRendererBase;
friend QDataStream & operator <<(QDataStream & s, const GLObjectBase * p);
friend QDataStream & operator >>(QDataStream & s, GLObjectBase *& p);
friend GLObjectBase * loadFromQGLFile(const QString & filepath);
public:
enum Type {Mesh, Light, ParticlesSystem};
enum Type {glMesh, glLight, glCamera, glParticlesSystem};
enum Pass {Solid, Transparent, Reflection, User};
enum GeomPrimitives {Triangles = GL_TRIANGLES, Quads = GL_QUADS};
enum RenderMode {View = 0, Point = GL_POINT, Line = GL_LINE, Fill = GL_FILL};
@@ -60,6 +64,7 @@ public:
void setParent(GLObjectBase * o) {parent_ = o;}
bool hasParent() const {return parent_ != 0;}
bool hasChildren() const {return children_.size() != 0;}
void setView(QGLView * v);
void addChild(GLObjectBase * o) {if (o == this) return; if (o->parent_ != 0) o->parent_->children_.removeAll(o); children_ << o; o->parent_ = this; o->buildTransform(); if (view_ != 0) view_->collectLights();}
void removeChild(GLObjectBase * o) {if (o == this) return; children_.removeAll(o); o->parent_ = 0; o->buildTransform(); if (view_ != 0) view_->collectLights();}
@@ -68,6 +73,8 @@ public:
int childCount() const {return children_.size();}
GLObjectBase * child(int index) {if (index < 0 || index >= children_.size()) return 0; return children_[index];}
GLObjectBase * child(const QString & name) {foreach (GLObjectBase * i, children_) if (i->name_ == name) return i; return 0;}
const GLObjectBase * child(int index) const {if (index < 0 || index >= children_.size()) return 0; return children_[index];}
const GLObjectBase * child(const QString & name) const {foreach (GLObjectBase * i, children_) if (i->name_ == name) return i; return 0;}
QList<GLObjectBase * > children(bool all_ = false);
bool isVisible() const {return visible_;}
@@ -145,7 +152,7 @@ public:
bool isSelected() const {return selected_;}
void setSelected(bool yes) {selected_ = yes;}
void select() {selected_ = true;}
void select();
void deselect() {selected_ = false;}
bool isSelectable() const {return select_;}
@@ -246,4 +253,8 @@ inline T globject_cast(GLObjectBase * object) {return reinterpret_cast<T>(object
template <class T>
inline T globject_cast(const GLObjectBase * object) {return reinterpret_cast<T>(object);}
QDataStream & operator <<(QDataStream & s, const GLObjectBase * p);
QDataStream & operator >>(QDataStream & s, GLObjectBase *& p);
#endif // GLOBJECT_H