00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef STQGLEXAMPLEOBECTS_H
00028 #define STQGLEXAMPLEOBECTS_H
00029
00030
00031
00033
00034 #include "QViewingModeDialog.h"
00035
00036
00037
00039 class STQGLExampleSphere : public QSceneTreeDrawable
00040 {
00041 public:
00042
00044 STQGLExampleSphere(const CP3D &cCenter, float radius,
00045 int n1,int n2,
00046 float red, float green, float blue,
00047 float lw=2.5)
00048 : QSceneTreeDrawable(),
00049 m_radius(radius),
00050 m_lw(lw),
00051 m_red(red),
00052 m_green(green),
00053 m_blue(blue),
00054 m_n1(n1),
00055 m_n2(n2)
00056 { setCenter(cCenter); };
00057
00059 virtual void setCenter(const CP3D &cCenter) {
00060 resetTransformation();
00061 applyTransformation(CMat4D::PTranslate(cCenter.getCV3D()));
00062 };
00063
00065 virtual const CP3D getCenter() {
00066 CV4D cCentrVec = (*getTransformation())(3);
00067
00068 return CP3D(cCentrVec.getX(), cCentrVec.getY(), cCentrVec.getZ());
00069 };
00070
00072 virtual CBoundingBox3D getBoundingBox() const {
00073 return QSceneTreeDrawable::getBoundingBox() +
00074 CBoundingBox3D(CP3D(-m_radius,-m_radius,-m_radius),
00075 CP3D(m_radius,m_radius,m_radius));
00076 };
00077
00080 virtual bool event(const QEvent *pqEvent) {
00081 switch (pqEvent->type()) {
00082 case QEvent::MouseButtonDblClick: {
00083 const QMouseEvent *pqMouseEvent = (const QMouseEvent *)pqEvent;
00084
00085 m_ViewingMode = normal;
00086 requestUpdate();
00087
00088 m_ViewingMode = QViewingModeDialog::getViewingMode(pqMouseEvent->globalX(),
00089 pqMouseEvent->globalY(),
00090 normal);
00091
00092 requestUpdate();
00093 break;
00094 }
00095 default:
00096 return false;
00097 }
00098
00099 return true;
00100 };
00101
00102
00103 protected:
00104 float m_radius, m_lw;
00105 float m_red, m_green, m_blue;
00106 int m_n1, m_n2;
00107 };
00108
00109
00110
00112 class STQGLExampleWiredSphere : public STQGLExampleSphere
00113 {
00114 public:
00115
00117 STQGLExampleWiredSphere(const CP3D &cCenter, float radius,
00118 int n1,int n2,
00119 float red, float green, float blue,
00120 float lw=2.5)
00121 : STQGLExampleSphere(cCenter,radius,n1,n2,red,green,blue,lw)
00122 {};
00123
00126 void draw();
00127 };
00128
00129
00130
00132 class STQGLExampleSolidSphere : public STQGLExampleSphere
00133 {
00134 public:
00136 STQGLExampleSolidSphere(const CP3D &cCenter, float radius,
00137 int n1,int n2,
00138 float red, float green, float blue)
00139 : STQGLExampleSphere(cCenter,radius,n1,n2,red,green,blue)
00140 {
00141 int i;
00142 for (i=0; i<16; i++) {
00143 m_anMask[8*i] = m_anMask[8*i+1] =
00144 m_anMask[8*i+2] = m_anMask[8*i+3] = 0xAA;
00145 m_anMask[8*i+4] = m_anMask[8*i+5] =
00146 m_anMask[8*i+6] = m_anMask[8*i+7] = 0x55;
00147 }
00148 };
00149
00152 void draw();
00153
00154
00155 protected:
00156 GLubyte m_anMask[128];
00157 };
00158
00159
00161 class STQGLExampleInitNode : public QSceneTreeDrawable
00162 {
00163 public:
00165 STQGLExampleInitNode() : QSceneTreeDrawable() {};
00166
00169 void draw();
00170 };
00171
00172
00176 class STQGLExampleLightNode : public QSceneTreeDrawable
00177 {
00178 public:
00180 STQGLExampleLightNode() : QSceneTreeDrawable() {};
00181
00184 void draw() {
00185 glEnable(GL_LIGHT0);
00186 glEnable(GL_LIGHTING);
00187 };
00188 };
00189
00190
00191 #endif // STQGLEXAMPLEOBECTS_H