git-svn-id: svn://db.shs.com.ru/libs@540 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -39,7 +39,7 @@ public:
|
||||
enum GeomPrimitives {Triangles = GL_TRIANGLES, Quads = GL_QUADS};
|
||||
enum RenderMode {View = 0, Point = GL_POINT, Line = GL_LINE, Fill = GL_FILL};
|
||||
|
||||
GLObjectBase();
|
||||
explicit GLObjectBase();
|
||||
virtual ~GLObjectBase();
|
||||
|
||||
virtual GLObjectBase * clone(bool withChildren = true);
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
QString name() const {return name_;}
|
||||
void setName(const QString & name) {name_ = name;}
|
||||
//virtual GLuint hList() {return list;}
|
||||
virtual void init() {calculateBoundingBox(); vbo.init(); vbo.rebuffer(); /*material_.reflection.create();*/ /*qDebug() << "init" << vbo.buffer_;*/ is_init = true;}
|
||||
virtual void init();
|
||||
virtual void draw(QOpenGLShaderProgram * prog, bool simplest = false);
|
||||
virtual void update() {}
|
||||
bool isInit() const {return is_init;}
|
||||
@@ -57,24 +57,24 @@ public:
|
||||
RenderMode renderMode() const {return render_mode;}
|
||||
void setRenderMode(RenderMode mode) {render_mode = mode;}
|
||||
|
||||
double lineWidth() const {return line_width;}
|
||||
void setLineWidth(const double & width) {line_width = width;}
|
||||
float lineWidth() const {return line_width;}
|
||||
void setLineWidth(const float & width) {line_width = width;}
|
||||
|
||||
GLObjectBase * parent() {return parent_;}
|
||||
void setParent(GLObjectBase * o) {parent_ = o;}
|
||||
bool hasParent() const {return parent_ != 0;}
|
||||
bool hasParent() const {return parent_ != nullptr;}
|
||||
bool hasChildren() const {return children_.size() != 0;}
|
||||
void setView(QGLView * v);
|
||||
|
||||
void addChild(GLObjectBase * o);
|
||||
void removeChild(GLObjectBase * o) {if (o == this) return; children_.removeAll(o); o->parent_ = 0; o->buildTransform(); if (view_ != 0) view_->collectLights();}
|
||||
void removeChild(int index) {children_[index]->parent_ = 0; children_[index]->buildTransform(); children_.removeAt(index); if (view_ != 0) view_->collectLights();}
|
||||
void removeChild(GLObjectBase * o);
|
||||
void removeChild(int index);
|
||||
void clearChildren(bool deleteAll = false);
|
||||
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;}
|
||||
GLObjectBase * child(int index);
|
||||
GLObjectBase * child(const QString & name);
|
||||
const GLObjectBase * child(int index) const;
|
||||
const GLObjectBase * child(const QString & name) const;
|
||||
QList<GLObjectBase * > children(bool all_ = false);
|
||||
|
||||
bool isVisible() const {return visible_;}
|
||||
@@ -91,54 +91,54 @@ public:
|
||||
|
||||
void move(const QVector3D & dv) {pos_ += dv; buildTransform();}
|
||||
void moveTo(const QVector3D & dv) {pos_ = dv; buildTransform();}
|
||||
void move(GLdouble dx, GLdouble dy, GLdouble dz = 0.) {move(QVector3D(dx, dy, dz)); buildTransform();}
|
||||
void moveTo(GLdouble dx, GLdouble dy, GLdouble dz = 0.) {moveTo(QVector3D(dx, dy, dz)); buildTransform();}
|
||||
void moveX(GLdouble o) {pos_.setX(pos_.x() + o); buildTransform();}
|
||||
void moveY(GLdouble o) {pos_.setY(pos_.y() + o); buildTransform();}
|
||||
void moveZ(GLdouble o) {pos_.setZ(pos_.z() + o); buildTransform();}
|
||||
void setPosX(GLdouble o) {pos_.setX(o); buildTransform();}
|
||||
void setPosY(GLdouble o) {pos_.setY(o); buildTransform();}
|
||||
void setPosZ(GLdouble o) {pos_.setZ(o); buildTransform();}
|
||||
void setPos(GLdouble x, GLdouble y, GLdouble z) {pos_ = QVector3D(x, y, z); buildTransform();}
|
||||
void move(GLfloat dx, GLfloat dy, GLfloat dz = 0.) {move(QVector3D(dx, dy, dz)); buildTransform();}
|
||||
void moveTo(GLfloat dx, GLfloat dy, GLfloat dz = 0.) {moveTo(QVector3D(dx, dy, dz)); buildTransform();}
|
||||
void moveX(GLfloat o) {pos_.setX(pos_.x() + o); buildTransform();}
|
||||
void moveY(GLfloat o) {pos_.setY(pos_.y() + o); buildTransform();}
|
||||
void moveZ(GLfloat o) {pos_.setZ(pos_.z() + o); buildTransform();}
|
||||
void setPosX(GLfloat o) {pos_.setX(o); buildTransform();}
|
||||
void setPosY(GLfloat o) {pos_.setY(o); buildTransform();}
|
||||
void setPosZ(GLfloat o) {pos_.setZ(o); buildTransform();}
|
||||
void setPos(GLfloat x, GLfloat y, GLfloat z) {pos_ = QVector3D(x, y, z); buildTransform();}
|
||||
void setPos(const QVector3D & p) {pos_ = p; buildTransform();}
|
||||
void resetPos() {pos_ = QVector3D(0., 0., 0.); buildTransform();}
|
||||
|
||||
QVector3D pos() const {return pos_;}
|
||||
double posX() const {return pos_.x();}
|
||||
double posY() const {return pos_.y();}
|
||||
double posZ() const {return pos_.z();}
|
||||
float posX() const {return pos_.x();}
|
||||
float posY() const {return pos_.y();}
|
||||
float posZ() const {return pos_.z();}
|
||||
QVector3D worldPos() const {return (itransform_ * QVector4D(0, 0, 0, 1.)).toVector3D();}
|
||||
QMatrix4x4 worldTransform() const {return itransform_;}
|
||||
|
||||
QVector3D rotation() const {return angles_;}
|
||||
double rotationX() const {return angles_.x();}
|
||||
double rotationY() const {return angles_.y();}
|
||||
double rotationZ() const {return angles_.z();}
|
||||
void rotateX(GLdouble a) {raw_matrix = false; angles_.setX(angles_.x() + a); buildTransform();}
|
||||
void rotateY(GLdouble a) {raw_matrix = false; angles_.setY(angles_.y() + a); buildTransform();}
|
||||
void rotateZ(GLdouble a) {raw_matrix = false; angles_.setZ(angles_.z() + a); while (angles_.z() < -360.) angles_.setZ(angles_.z() + 360.); while (angles_.z() > 360.) angles_.setZ(angles_.z() - 360.); buildTransform();}
|
||||
void setRotationX(GLdouble a) {raw_matrix = false; angles_.setX(a); buildTransform();}
|
||||
void setRotationY(GLdouble a) {raw_matrix = false; angles_.setY(a); buildTransform();}
|
||||
void setRotationZ(GLdouble a) {raw_matrix = false; angles_.setZ(a); while (angles_.z() < -360.) angles_.setZ(angles_.z() + 360.); while (angles_.z() > 360.) angles_.setZ(angles_.z() - 360.); buildTransform();}
|
||||
void setRotation(const QVector3D & a) {raw_matrix = false; angles_= a; buildTransform();}
|
||||
void resetRotation() {raw_matrix = false; angles_ = QVector3D(0., 0., 0.); buildTransform();}
|
||||
float rotationX() const {return angles_.x();}
|
||||
float rotationY() const {return angles_.y();}
|
||||
float rotationZ() const {return angles_.z();}
|
||||
void rotateX(GLfloat a);
|
||||
void rotateY(GLfloat a);
|
||||
void rotateZ(GLfloat a);
|
||||
void setRotationX(GLfloat a);
|
||||
void setRotationY(GLfloat a);
|
||||
void setRotationZ(GLfloat a);
|
||||
void setRotation(const QVector3D & a);
|
||||
void resetRotation();
|
||||
|
||||
QVector3D scale() {return scale_;}
|
||||
double scaleX() {return scale_.x();}
|
||||
double scaleY() {return scale_.y();}
|
||||
double scaleZ() {return scale_.z();}
|
||||
float scaleX() {return scale_.x();}
|
||||
float scaleY() {return scale_.y();}
|
||||
float scaleZ() {return scale_.z();}
|
||||
void scale(const QVector3D & sv) {raw_matrix = false; scale_ *= sv; buildTransform();}
|
||||
void scale(GLdouble sx, GLdouble sy, GLdouble sz) {raw_matrix = false; scale(QVector3D(sx, sy, sz)); buildTransform();}
|
||||
void scale(GLdouble sx, GLdouble sy) {raw_matrix = false; scale(QVector3D(sx, sy, sy)); buildTransform();}
|
||||
void scale(GLdouble sx) {raw_matrix = false; scale(QVector3D(sx, sx, sx)); buildTransform();}
|
||||
void scaleX(GLdouble a) {raw_matrix = false; scale_.setX(scale_.x() + a); buildTransform();}
|
||||
void scaleY(GLdouble a) {raw_matrix = false; scale_.setY(scale_.y() + a); buildTransform();}
|
||||
void scaleZ(GLdouble a) {raw_matrix = false; scale_.setZ(scale_.z() + a); buildTransform();}
|
||||
void scale(GLfloat sx, GLfloat sy, GLfloat sz) {raw_matrix = false; scale(QVector3D(sx, sy, sz)); buildTransform();}
|
||||
void scale(GLfloat sx, GLfloat sy) {raw_matrix = false; scale(QVector3D(sx, sy, sy)); buildTransform();}
|
||||
void scale(GLfloat sx) {raw_matrix = false; scale(QVector3D(sx, sx, sx)); buildTransform();}
|
||||
void scaleX(GLfloat a) {raw_matrix = false; scale_.setX(scale_.x() + a); buildTransform();}
|
||||
void scaleY(GLfloat a) {raw_matrix = false; scale_.setY(scale_.y() + a); buildTransform();}
|
||||
void scaleZ(GLfloat a) {raw_matrix = false; scale_.setZ(scale_.z() + a); buildTransform();}
|
||||
void setScale(const QVector3D & a) {raw_matrix = false; scale_ = a; buildTransform();}
|
||||
void setScale(GLdouble a) {raw_matrix = false; scale_ = QVector3D(a, a, a); buildTransform();}
|
||||
void setScaleX(GLdouble a) {raw_matrix = false; scale_.setX(a); buildTransform();}
|
||||
void setScaleY(GLdouble a) {raw_matrix = false; scale_.setY(a); buildTransform();}
|
||||
void setScaleZ(GLdouble a) {raw_matrix = false; scale_.setZ(a); buildTransform();}
|
||||
void setScale(GLfloat a) {raw_matrix = false; scale_ = QVector3D(a, a, a); buildTransform();}
|
||||
void setScaleX(GLfloat a) {raw_matrix = false; scale_.setX(a); buildTransform();}
|
||||
void setScaleY(GLfloat a) {raw_matrix = false; scale_.setY(a); buildTransform();}
|
||||
void setScaleZ(GLfloat a) {raw_matrix = false; scale_.setZ(a); buildTransform();}
|
||||
void resetScale() {raw_matrix = false; scale_ = QVector3D(1., 1., 1.); buildTransform();}
|
||||
|
||||
QMatrix4x4 transform() {return mat_;}
|
||||
@@ -170,8 +170,8 @@ public:
|
||||
void setSrcAlpha(GLenum mode) {blend_src = mode;}
|
||||
void setDestAlpha(GLenum mode) {blend_dest = mode;}
|
||||
|
||||
void setMaterial(const Material & m, bool with_children = false) {material_ = m; if (with_children) foreach (GLObjectBase * i, children_) i->setMaterial(m, true); checkPass(); is_tex_loaded = false;}
|
||||
Material & material() {/*is_tex_loaded = false;*/ return material_;}
|
||||
void setMaterial(const Material & m, bool with_children = false);
|
||||
Material & material() {return material_;}
|
||||
|
||||
const Box3D & boundingBox(bool withChildren = true) const {return bound;}
|
||||
GLVBO & VBO() {return vbo;}
|
||||
@@ -192,11 +192,11 @@ public:
|
||||
|
||||
protected:
|
||||
void addChildren(QList<GLObjectBase * > & list, GLObjectBase * where);
|
||||
void loadTextures(bool with_children = false) {material_.loadTextures(view_->textureManager()); if (with_children) foreach (GLObjectBase * i, children_) i->loadTextures(); is_tex_loaded = true; checkPass();}
|
||||
void loadTextures(bool with_children = false);
|
||||
//void deleteTextures() {foreach (GLuint i, textures) currentQGLView->deleteTexture(i); textures.clear();}
|
||||
void buildTransform();
|
||||
void initInternal() {init(); loadTextures(); foreach (GLObjectBase * i, children_) i->initInternal();}
|
||||
void render(int * id = 0, QMap<int, GLObjectBase * > * ids = 0, int sh_id_loc = 0);
|
||||
void initInternal();
|
||||
void render(int * id = nullptr, QMap<int, GLObjectBase * > * ids = nullptr, int sh_id_loc = 0);
|
||||
void checkPass();
|
||||
virtual void localTransform(QMatrix4x4 & m);
|
||||
QMatrix4x4 worldMatrix(QMatrix4x4 parent) const;
|
||||
@@ -204,7 +204,7 @@ protected:
|
||||
int pass_; // Pass
|
||||
bool is_init, is_tex_loaded, accept_light, accept_fog, /*write_depth_,*/ visible_, cast_shadow, rec_shadow, select_, selected_, raw_matrix;
|
||||
bool is_root;
|
||||
double line_width;
|
||||
float line_width;
|
||||
Type type_;
|
||||
GeomPrimitives geom_prim;
|
||||
RenderMode render_mode;
|
||||
@@ -233,20 +233,20 @@ public:
|
||||
enum Type {Omni, Directional, Cone};
|
||||
|
||||
Light();
|
||||
Light(const QVector3D & p, const QColor & c = Qt::white, GLdouble i = 1.);
|
||||
Light(const QVector3D & p, const QColor & c = Qt::white, float i = 1.);
|
||||
virtual GLObjectBase * clone(bool withChildren = true);
|
||||
virtual void init() {shadow_map.resize(512, 512); is_init = true;}
|
||||
virtual void draw(QOpenGLShaderProgram * prog, bool simplest = false);
|
||||
|
||||
QVector3D direction, dir0, dir1;
|
||||
GLdouble angle_start;
|
||||
GLdouble angle_end;
|
||||
GLdouble intensity;
|
||||
GLdouble decay_const;
|
||||
GLdouble decay_linear;
|
||||
GLdouble decay_quadratic;
|
||||
GLdouble decay_start;
|
||||
GLdouble decay_end;
|
||||
float angle_start;
|
||||
float angle_end;
|
||||
float intensity;
|
||||
float decay_const;
|
||||
float decay_linear;
|
||||
float decay_quadratic;
|
||||
float decay_start;
|
||||
float decay_end;
|
||||
Type light_type;
|
||||
GLFramebuffer shadow_map;
|
||||
QMatrix4x4 shadow_matrix;
|
||||
|
||||
Reference in New Issue
Block a user