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
00028
00029
00030
00031
00032
00033
00034
#ifndef STQGLEXAMPLEOBECTS_H
00035
#define STQGLEXAMPLEOBECTS_H
00036
00037
00038
00040
#include "QSceneTreeNode.h"
00041
#include "QViewingModeDialog.h"
00042
00043
00044
00046 class STQGLExampleSphere :
public QSceneTreeDrawable
00047 {
00048
public:
00049
00051 STQGLExampleSphere(
const CP3D &cCenter,
float radius,
00052
int n1,
int n2,
00053
float red,
float green,
float blue,
00054
float lw=2.5)
00055 :
QSceneTreeDrawable(),
00056
m_radius(radius),
00057
m_lw(lw),
00058
m_red(red),
00059
m_green(green),
00060
m_blue(blue),
00061
m_n1(n1),
00062
m_n2(n2)
00063 {
setCenter(cCenter); };
00064
00066 virtual void setCenter(
const CP3D &cCenter) {
00067
resetTransformation();
00068 applyTransformation(CMat4D::PTranslate(cCenter.
getCV3D()));
00069 };
00070
00072 virtual const CP3D getCenter() {
00073
CV4D cCentrVec = (*
getTransformation())(3);
00074
00075
return CP3D(cCentrVec.
getX(), cCentrVec.
getY(), cCentrVec.
getZ());
00076 };
00077
00079 virtual CBoundingBox3D getBoundingBox()
const {
00080
return QSceneTreeDrawable::getBoundingBox() +
00081
CBoundingBox3D(
CP3D(-
m_radius,-
m_radius,-
m_radius),
00082
CP3D(
m_radius,
m_radius,
m_radius));
00083 };
00084
00087 virtual bool event(
const QEvent *pqEvent) {
00088
switch (pqEvent->type()) {
00089
case QEvent::MouseButtonDblClick: {
00090
const QMouseEvent *pqMouseEvent = (
const QMouseEvent *)pqEvent;
00091
00092 m_ViewingMode = normal;
00093
requestUpdate();
00094
00095 m_ViewingMode = QViewingModeDialog::getViewingMode(pqMouseEvent->globalX(),
00096 pqMouseEvent->globalY(),
00097 normal);
00098
00099
requestUpdate();
00100
break;
00101 }
00102
default:
00103
return false;
00104 }
00105
00106
return true;
00107 };
00108
00109
00110
protected:
00111 float m_radius,
m_lw;
00112 float m_red,
m_green,
m_blue;
00113 int m_n1,
m_n2;
00114 };
00115
00116
00117
00119 class STQGLExampleWiredSphere :
public STQGLExampleSphere
00120 {
00121
public:
00122
00124 STQGLExampleWiredSphere(
const CP3D &cCenter,
float radius,
00125
int n1,
int n2,
00126
float red,
float green,
float blue,
00127
float lw=2.5)
00128 :
STQGLExampleSphere(cCenter,radius,n1,n2,red,green,blue,lw)
00129 {};
00130
00133
void draw();
00134 };
00135
00136
00137
00139 class STQGLExampleSolidSphere :
public STQGLExampleSphere
00140 {
00141
public:
00143 STQGLExampleSolidSphere(
const CP3D &cCenter,
float radius,
00144
int n1,
int n2,
00145
float red,
float green,
float blue)
00146 :
STQGLExampleSphere(cCenter,radius,n1,n2,red,green,blue)
00147 {
00148
int i;
00149
for (i=0; i<16; i++) {
00150
m_anMask[8*i] =
m_anMask[8*i+1] =
00151 m_anMask[8*i+2] = m_anMask[8*i+3] = 0xAA;
00152 m_anMask[8*i+4] = m_anMask[8*i+5] =
00153 m_anMask[8*i+6] = m_anMask[8*i+7] = 0x55;
00154 }
00155 };
00156
00159
void draw();
00160
00161
00162
protected:
00163 GLubyte
m_anMask[128];
00164 };
00165
00166
00168 class STQGLExampleInitNode :
public QSceneTreeDrawable
00169 {
00170
public:
00172 STQGLExampleInitNode() :
QSceneTreeDrawable() {};
00173
00176
void draw();
00177 };
00178
00179
00183 class STQGLExampleLightNode :
public QSceneTreeDrawable
00184 {
00185
public:
00187 STQGLExampleLightNode() :
QSceneTreeDrawable() {};
00188
00191 void draw() {
00192 glEnable(GL_LIGHT0);
00193 glEnable(GL_LIGHTING);
00194 };
00195 };
00196
00197
00198
#endif // STQGLEXAMPLEOBECTS_H