////////////////////////////////////////////////////// //! rcsid="$Id: ex3DCanvas.cc,v 1.11 2000/12/13 15:45:51 ees1cg Exp $" #include "amma/GUI/Window.hh" #include "amma/GUI/Button.hh" #include "amma/GUI/Canvas.hh" #include "amma/GUI/Manager.hh" #include "amma/GUI/Slider.hh" #include "amma/GUI/LBox.hh" #include "amma/GUI/3D/3DCanvas.hh" #include "amma/GUI/3D/ViewPoint.hh" #include "amma/GUI/3D/Cube.hh" #include "amma/GUI/3D/Lines.hh" #include "amma/GUI/3D/Util.hh" #include "amma/GUI/3D/Polops.hh" #include "amma/GUI/3D/Light.hh" #include "amma/Option.hh" #include "amma/GUI/Bitmap.hh" #include #include void DrawFunc() { Vector3dC diag(1,1,1); Vector3dC d1 = diag/2; Vector3dC d2 = -diag/2; glBegin(GL_QUAD_STRIP); { glNormal3d(1,0,0); glVertex3d(d1.X(),d1.Y(),d1.Y()); glVertex3d(d1.X(),d2.Y(),d1.Y()); glVertex3d(d1.X(),d1.Y(),d2.Y()); glVertex3d(d1.X(),d2.Y(),d2.Y()); } glEnd(); glBegin(GL_QUAD_STRIP); { glNormal3d(-1,0,0); glVertex3d(d2.X(),d1.Y(),d1.Y()); glVertex3d(d2.X(),d2.Y(),d1.Y()); glVertex3d(d2.X(),d1.Y(),d2.Y()); glVertex3d(d2.X(),d2.Y(),d2.Y()); } glEnd(); } void SetupGL() { //glCullFace( } void pressFunc(GUIMouseEventC &me) { cerr << "Press " << me.X() << " " << me.Y() << "\n"; } void releaseFunc(GUIMouseEventC &me) { cerr << "Release " << me.X() << " " << me.Y() << "\n"; } void moveFunc(GUIMouseEventC &me) { cerr << "Move " << me.X() << " " << me.Y() << "\n"; } int main(int nargs,char *args[]) { GUIManager.Init(nargs,args); OptionC opts(nargs,args); // Make sure help option is detected. BooleanT doMotion = opts.Boolean("m",false,"Detect motion events."); opts.Check(); GUIWindowC win(100,100,"Hello"); using namespace StdGUI; Canvas3DC area(400,400); StdDP::Connect(area.Signal("button_press_event"),&pressFunc); StdDP::Connect(area.Signal("button_release_event"),&releaseFunc); if(doMotion) StdDP::Connect(area.Signal("motion_notify_event"),&moveFunc); win.Add(VBox(area+ GUIButtonC("Hello1")+ GUIButtonC("Hello2") ) ); win.Show(); cerr << "Starting gui. \n"; #if 1 GUIBitmapC otherbm(400,400); otherbm.Clear(); GdkGC *agc = gdk_gc_new(&otherbm.Bitmap()); GdkColor col; col.pixel = 0; col.red = 0xffff; col.green = 0xffff; col.blue = 0xffff; gdk_gc_set_foreground(agc,&col); gdk_draw_rectangle(&otherbm.Bitmap(),agc,1,10,10,300,300); win.ShapeCombineMask(otherbm.Bitmap()); #endif GUIManager.Execute(); area.Render(SetupGL); #if 1 area.Light(RGBPointC(0.8,0.8,0.8),Point3dC(3,3,10)); //area.SwapBuffers(); area.ViewPoint(90,Point3dC(0,0,3)); // Setup view point. DCube3DC acube(Vector3dC(1,1,1),RGBPointC(0,1,0)); DObject3DC object ; #if 0 area.Transform(-90, // Angle. Vector3dC(0,1,0), // Axis of rotation acube); // Object to draw. area.SwapBuffers(); object = acube; #else PolopsC pol("/vol/vssp/data/polymesh/humanheads/ukvrsighead.tri"); DPolops3DC polgl(pol,FALSE); object = polgl; #endif object.EnableDisplayList(); #if 1 for(RealT i = 0;i < 1000;i++) { // Draw rotated cube area.Transform(i * 5, // Angle. Vector3dC(0,1,0), // Axis of rotation object); // Object to draw. // area.Render(DrawFunc); // area.Put(DLine3DC(Point3dC(0,0,0),Point3dC(0,1,0))); // Draw line. area.SwapBuffers(); } #else area.SwapBuffers(); // Draw rotated cube area.Transform(0, // Angle. Vector3dC(0,1,0), // Axis of rotation object); // Object to draw. // area.Render(DrawFunc); // area.Put(DLine3DC(Point3dC(0,0,0),Point3dC(0,1,0))); // Draw line. area.SwapBuffers(); #endif #endif cerr << "Execute done, waiting... \n"; //GUIManager.Start(); GUIManager.Wait(); }