git-svn-id: svn://db.shs.com.ru/libs@638 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "glframebuffer.h"
|
||||
#include "glmaterial.h"
|
||||
#include "gltypes.h"
|
||||
#include "gltransform.h"
|
||||
|
||||
|
||||
class ObjectBase
|
||||
@@ -89,61 +90,64 @@ public:
|
||||
void setReceiveShadows(bool on) {rec_shadow = on;}
|
||||
void setCastShadows(bool on) {cast_shadow = on;}
|
||||
|
||||
void move(const QVector3D & dv) {pos_ += dv; buildTransform();}
|
||||
void moveTo(const QVector3D & dv) {pos_ = dv; buildTransform();}
|
||||
void move(const QVector3D & dv) {trans.setTranslation(pos() + dv); buildTransform();}
|
||||
void moveTo(const QVector3D & dv) {trans.setTranslation(dv); 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();}
|
||||
void moveX(GLfloat o) {trans.setTranslationX(posX() + o); buildTransform();}
|
||||
void moveY(GLfloat o) {trans.setTranslationY(posY() + o); buildTransform();}
|
||||
void moveZ(GLfloat o) {trans.setTranslationZ(posZ() + o); buildTransform();}
|
||||
void setPosX(GLfloat o) {trans.setTranslationX(o); buildTransform();}
|
||||
void setPosY(GLfloat o) {trans.setTranslationY(o); buildTransform();}
|
||||
void setPosZ(GLfloat o) {trans.setTranslationZ(o); buildTransform();}
|
||||
void setPos(GLfloat x, GLfloat y, GLfloat z) {trans.setTranslation(QVector3D(x, y, z)); buildTransform();}
|
||||
void setPos(const QVector3D & p) {trans.setTranslation(p); buildTransform();}
|
||||
void resetPos() {trans.setTranslation(QVector3D()); buildTransform();}
|
||||
|
||||
QVector3D pos() const {return pos_;}
|
||||
float posX() const {return pos_.x();}
|
||||
float posY() const {return pos_.y();}
|
||||
float posZ() const {return pos_.z();}
|
||||
QVector3D pos() const {return trans.translation();}
|
||||
float posX() const {return trans.translation().x();}
|
||||
float posY() const {return trans.translation().y();}
|
||||
float posZ() const {return trans.translation().z();}
|
||||
QVector3D worldPos() const {return (itransform_ * QVector4D(0, 0, 0, 1.)).toVector3D();}
|
||||
QMatrix4x4 worldTransform() const {return itransform_;}
|
||||
|
||||
QVector3D rotation() const {return angles_;}
|
||||
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);
|
||||
QVector3D rotation() const {return trans.rotation();}
|
||||
float rotationX() const {return rotation().x();}
|
||||
float rotationY() const {return rotation().y();}
|
||||
float rotationZ() const {return rotation().z();}
|
||||
void rotateX(GLfloat a) {raw_matrix = false; trans.setRotationX(trans.rotationX() + a); buildTransform();}
|
||||
void rotateY(GLfloat a) {raw_matrix = false; trans.setRotationY(trans.rotationY() + a); buildTransform();}
|
||||
void rotateZ(GLfloat a);
|
||||
void setRotationX(GLfloat a);
|
||||
void setRotationY(GLfloat a);
|
||||
void setRotationX(GLfloat a) {raw_matrix = false; trans.setRotationX(a); buildTransform();}
|
||||
void setRotationY(GLfloat a) {raw_matrix = false; trans.setRotationY(a); buildTransform();}
|
||||
void setRotationZ(GLfloat a);
|
||||
void setRotation(const QVector3D & a);
|
||||
void resetRotation();
|
||||
void setRotation(const QVector3D & a) {raw_matrix = false; trans.setRotation(a); buildTransform();}
|
||||
void resetRotation() {raw_matrix = false; trans.setRotation(QVector3D()); buildTransform();}
|
||||
|
||||
QVector3D scale() {return scale_;}
|
||||
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();}
|
||||
QVector3D scale() {return trans.scale3D();}
|
||||
float scaleX() {return trans.scale3D().x();}
|
||||
float scaleY() {return trans.scale3D().y();}
|
||||
float scaleZ() {return trans.scale3D().z();}
|
||||
void scale(const QVector3D & sv) {raw_matrix = false; trans.setScale(trans.scale3D() * sv); 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(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();}
|
||||
void scaleX(GLfloat a) {raw_matrix = false; trans.setScaleX(trans.scale3D().x() + a); buildTransform();}
|
||||
void scaleY(GLfloat a) {raw_matrix = false; trans.setScaleY(trans.scale3D().y() + a); buildTransform();}
|
||||
void scaleZ(GLfloat a) {raw_matrix = false; trans.setScaleZ(trans.scale3D().z() + a); buildTransform();}
|
||||
void setScale(const QVector3D & a) {raw_matrix = false; trans.setScale(a); buildTransform();}
|
||||
void setScale(GLfloat a) {raw_matrix = false; trans.setScale(a); buildTransform();}
|
||||
void setScaleX(GLfloat a) {raw_matrix = false; trans.setScaleX(a); buildTransform();}
|
||||
void setScaleY(GLfloat a) {raw_matrix = false; trans.setScaleY(a); buildTransform();}
|
||||
void setScaleZ(GLfloat a) {raw_matrix = false; trans.setScaleZ(a); buildTransform();}
|
||||
void resetScale() {raw_matrix = false; trans.setScale(1.f); buildTransform();}
|
||||
|
||||
QMatrix4x4 transform() {return mat_;}
|
||||
void setTransform(const QMatrix4x4 & t);
|
||||
Transform transform() {return trans;}
|
||||
void setTransform(const Transform & t);
|
||||
void setMatrix(const QMatrix4x4 & t);
|
||||
QMatrix4x4 matrix() const;
|
||||
bool isRawMatrix() {return raw_matrix;}
|
||||
QVector3D inParentSpace(const QVector3D & v) const;
|
||||
|
||||
bool isAcceptLight() const {return accept_light;}
|
||||
void setAcceptLight(bool yes) {accept_light = yes;}
|
||||
@@ -190,6 +194,7 @@ public:
|
||||
//QVector<GLfloat> d_vertices, d_normals, d_uvs;
|
||||
|
||||
protected:
|
||||
virtual void transformChanged() {}
|
||||
void addChildren(QList<ObjectBase * > & list, ObjectBase * where);
|
||||
void loadTextures(bool with_children = false);
|
||||
//void deleteTextures() {foreach (GLuint i, textures) currentQGLView->deleteTexture(i); textures.clear();}
|
||||
@@ -210,7 +215,7 @@ protected:
|
||||
Type type_;
|
||||
RenderMode render_mode;
|
||||
Box3D bound;
|
||||
QVector3D pos_, angles_, scale_;
|
||||
Transform trans;
|
||||
QList<ObjectBase * > children_;
|
||||
QMatrix4x4 itransform_, mat_;
|
||||
QString name_;
|
||||
@@ -234,14 +239,20 @@ class AimedObject: public ObjectBase {
|
||||
public:
|
||||
AimedObject();
|
||||
~AimedObject() {}
|
||||
QVector3D aim() const {return aim_;}
|
||||
QVector3D worldAim() const {return (itransform_ * QVector4D(aim_, 1.)).toVector3D();}
|
||||
QVector3D aim() const {return pos() + (direction() * aim_dist);}
|
||||
QVector3D worldAim() const;
|
||||
void setAim(const QVector3D & p);
|
||||
QVector3D direction() const;
|
||||
QVector3D worldDirection() const {return (itransform_ * QVector4D(direction(), 0.)).toVector3D().normalized();}
|
||||
void setDirection(const QVector3D & d);
|
||||
void setDirection(double x, double y, double z) {setDirection(QVector3D(x, y, z));}
|
||||
double distance() const {return aim_dist;}
|
||||
void flyCloser(double s);
|
||||
void flyFarer(double s);
|
||||
void flyToDistance(double d);
|
||||
protected:
|
||||
QVector3D aim_;
|
||||
void transformChanged() override;
|
||||
double aim_dist;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user