Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

STQGLExampleObjects.h

Go to the documentation of this file.
00001 /* 00002 * STQGLExampleObjects.h 00003 * $Id: 00004 * 00005 * Copyright (C) 2001 Markus Janich 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * As a special exception to the GPL, the QGLViewer authors (Markus 00022 * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas 00023 * Woerner) give permission to link this program with Qt (non-)commercial 00024 * edition, and distribute the resulting executable, without including 00025 * the source code for the Qt (non-)commercial edition in the source 00026 * distribution. 00027 * 00028 */ 00029 00030 // Description : Definition of example nodes 00031 00032 00033 00034 #ifndef STQGLEXAMPLEOBECTS_H 00035 #define STQGLEXAMPLEOBECTS_H 00036 00037 00038 // Own 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

Generated on Sun May 16 12:02:02 2004 for QGLViewer by doxygen 1.3.7