00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "gzGizmo3DLibrary.h"
00024
00025 class MyNodeClass : public gzNode
00026 {
00027 public:
00028
00029 GZ_DECLARE_TYPE_INTERFACE;
00030
00031 MyNodeClass(const gzString & name="MyNodeClass"):gzNode(name)
00032 {
00033
00034 }
00035
00036 virtual ~MyNodeClass()
00037 {
00038 }
00039
00040
00041
00042 virtual gzReference* clone() const
00043 {
00044 return new MyNodeClass(*this);
00045 }
00046
00047
00048
00049 virtual gzVoid preTraverseAction( gzTraverseAction *actionclass , gzContext *context)
00050 {
00051 if(actionclass->isExactType(gzRenderAction::getClassType()))
00052 {
00053 gzBegin(GZ_QUADS);
00054 gzColor4d(1,1,1,1);
00055 gzVertex3d(0,0,0);
00056 gzColor4d(1,0,1,1);
00057 gzVertex3d(0,1,0);
00058 gzColor4d(1,1,0,1);
00059 gzVertex3d(1,1,0);
00060 gzColor4d(0,1,1,1);
00061 gzVertex3d(1,0,0);
00062 gzEnd();
00063 }
00064 }
00065
00066 virtual gzVoid postTraverseAction( gzTraverseAction *actionclass , gzContext *context)
00067 {
00068
00069 }
00070
00071 virtual gzActionStage useActionStage( gzTraverseAction *actionclass , gzContext *context)
00072 {
00073 return GZ_ACTION_STAGE_SORTED_TEXTURE;
00074 }
00075
00076
00077 virtual gzVoid updateNode()
00078 {
00079 gzVec3 center(0.5,0.5,0);
00080
00081 gzReal radius=2;
00082
00083 resetBoundary();
00084 includeBoundary(center,radius);
00085
00086 adjustBoundary();
00087 }
00088 };
00089
00090
00091 GZ_DECLARE_TYPE_CHILD(gzNode,MyNodeClass,"MyNodeClassName");
00092
00093
00094 class MyWindow : public gzWindow
00095 {
00096 public:
00097 MyWindow():gzWindow("MyWindow")
00098 {
00099
00100 gzScene *scene=new gzScene;
00101
00102 scene->addNode(new MyNodeClass("A test quad"));
00103
00104
00105 scene->debug(GZ_DEBUG_RECURSIVE);
00106
00107 gzCamera *cam=getCamera();
00108
00109 cam->setScene(scene);
00110
00111 cam->setPosition(0.5,0.5,10);
00112 cam->lookAt(0.5,0.5,0);
00113 }
00114
00115
00116 };
00117
00118
00119
00120 class WindowApp : public gzApplication
00121 {
00122 public:
00123
00124 WindowApp():m_win(NULL)
00125 {
00126 };
00127
00128 ~WindowApp()
00129 {
00130 if(m_win)
00131 delete m_win;
00132 }
00133
00134 void Create()
00135 {
00136 m_win = new MyWindow();
00137 m_win->setBackground(0,0.8f,0.5f,0);
00138 m_win->refreshWindow();
00139 }
00140
00141
00142 private:
00143
00144 MyWindow *m_win;
00145 };
00146
00147
00148
00149 int main(int argc, char *argv[])
00150 {
00151 gzStartUpGizmo();
00152
00153 gzMessage::setMessageLevel(GZ_MESSAGE_DEBUG);
00154
00155 gzGraphicsEngine::useEngine(GZ_ENGINE_OPENGL);
00156
00157
00158 WindowApp app;
00159 try
00160 {
00161
00162 app.Create();
00163
00164
00165 app.run();
00166
00167 }
00168 catch(gzBaseError &error)
00169 {
00170 error.reportError();
00171 }
00172
00173 gzShutDownGizmo();
00174
00175 return 0;
00176 }
00177