main.C

Go to the documentation of this file.
00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00026 #include <iostream>
00027 
00028 #include <archon/math/vector.H>
00029 #include <archon/util/time.H>
00030 #include <archon/util/mutex.H>
00031 #include <archon/util/ref.H>
00032 #include <archon/util/options.H>
00033 
00034 #include <archon/x3d/proxy/exception.H>
00035 #include <archon/x3d/proxy/proxy.H>
00036 
00037 namespace Archon
00038 {
00039   namespace SaiTestApps
00040   {
00041     namespace Simple
00042     {
00043       using namespace std;
00044       using namespace Math;
00045       using namespace Utilities;
00046       using namespace X3D::Proxy;
00047 
00048       void isOver(bool v)
00049       {
00050         cerr << v << "\n";
00051       }
00052 
00053       int main(int argc, const char *argv[])
00054       {
00055         bool   opt_help              = false;
00056         int    opt_corbaEndpointPort = -1; // Auto assign
00057         string opt_serverName        = "archon";
00058 
00059         Options o;
00060 
00061         o.addSwitch("h", "help", opt_help, true,
00062                     "Describe the parameters");
00063         o.addConfig("p", "corba-endpoint-port", opt_corbaEndpointPort, opt_corbaEndpointPort,
00064                     "The TCP/IP port on which the CORBA Orb listens (-1 for auto assign)",
00065                     Options::wantArg_always);
00066         o.addConfig("n", "server-name", opt_serverName, opt_serverName,
00067                     "The name of the server to connect to",
00068                     Options::wantArg_always);
00069 
00070         if(o.processCommandLine(argc, argv))
00071         {
00072           cerr << "Try --help\n";
00073           return 1;
00074         }
00075 
00076         if(opt_help)
00077         {
00078           cout <<
00079             "Test Application for 3D-Console by Brian Kristiansen & Kristian Spangsege\n"
00080             "\n"
00081             "Synopsis: " << argv[0] << "\n"
00082             "\n"
00083             "Available options:\n";
00084           cout << o.list();
00085           return 0;
00086         }
00087 
00088         if(argc > 1)
00089         {
00090           cerr << "Too many aguments\n";
00091           cerr << "Try --help\n";
00092           return 1;
00093         }
00094 
00095         Ref<Session> session =
00096           Session::create(opt_serverName, opt_corbaEndpointPort);
00097 
00098         Ref<Application> application =
00099           Application::create(session, Uri());
00100 
00101         Ref<Sphere> sphere = Sphere::create(application);
00102         sphere->radius = 8;
00103 
00104         Ref<Material> material = Material::create(application);
00105         material->diffuseColor = Vector3(0.8, 0.3, 0.3);
00106 
00107         Ref<Appearance> apperance = Appearance::create(application);
00108         apperance->material = material;
00109 
00110         Ref<Shape> shape = Shape::create(application);
00111         shape->geometry = sphere;
00112         shape->appearance = apperance;
00113 
00114         Ref<Group> rootGroup = Group::create(application);
00115         rootGroup->children.add(shape);
00116 
00117         Ref<PointLight> light = PointLight::create(application);
00118 
00119         light->location = Vector3(0, 20, 0);
00120 
00121         rootGroup->children.add(light);
00122 
00123         Ref<TouchSensor> touch = TouchSensor::create(application);
00124 
00125         rootGroup->children.add(touch);
00126 
00127         touch->isOver.registerInterest<SFBool>(new FuncCaller<SFBool>(isOver));
00128         //application->createRoute(touch->isOver, light->on);
00129 
00130         application->setRootGroup(rootGroup);
00131         application->launch();
00132 
00133         Archon::Utilities::Time delay(0, 100000000l);
00134 
00135         while(true)
00136         {
00137           Archon::Utilities::Thread::sleep(delay);
00138         }
00139 
00140         return 0;
00141       }
00142     }
00143   }
00144 }
00145 
00146 int main(int argc, const char *argv[]) throw()
00147 {
00148   using namespace std;
00149   using namespace Archon::Utilities;
00150   using namespace Archon::X3D;
00151 
00152   set_unexpected(Exception::terminal<Proxy::exceptionCatchInfo>);
00153   set_terminate (Exception::terminal<Proxy::exceptionCatchInfo>);
00154 
00155   return Archon::SaiTestApps::Simple::main(argc, argv);
00156 }

Generated on Sun Jul 30 22:55:41 2006 for Archon by  doxygen 1.4.4