00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00027 #include <iostream>
00028
00029 #include <archon/math/vector.H>
00030 #include <archon/util/time.H>
00031 #include <archon/util/mutex.H>
00032 #include <archon/util/ref.H>
00033 #include <archon/util/options.H>
00034
00035 #include <archon/x3d/proxy/exception.H>
00036 #include <archon/x3d/proxy/proxy.H>
00037
00038 namespace Archon
00039 {
00040 namespace SaiTestApps
00041 {
00042 namespace Cylinders
00043 {
00044 using namespace std;
00045 using namespace Math;
00046 using namespace Utilities;
00047 using namespace X3D::Proxy;
00048
00049 void handleCyl(Time, int i) { cout << "cyl" << i << "\n"; }
00050
00051 int main(int argc, const char *argv[])
00052 {
00053 bool opt_help = false;
00054 int opt_corbaEndpointPort = -1;
00055 string opt_serverName = "archon";
00056
00057 Options o;
00058
00059 o.addSwitch("h", "help", opt_help, true,
00060 "Describe the parameters");
00061 o.addConfig("p", "corba-endpoint-port", opt_corbaEndpointPort, opt_corbaEndpointPort,
00062 "The TCP/IP port on which the CORBA Orb listens (-1 for auto assign)",
00063 Options::wantArg_always);
00064 o.addConfig("n", "server-name", opt_serverName, opt_serverName,
00065 "The name of the server to connect to",
00066 Options::wantArg_always);
00067
00068 if(o.processCommandLine(argc, argv))
00069 {
00070 cerr << "Try --help\n";
00071 return 1;
00072 }
00073
00074 if(opt_help)
00075 {
00076 cout <<
00077 "Test Application for 3D-Console by Brian Kristiansen & Kristian Spangsege\n"
00078 "\n"
00079 "Synopsis: " << argv[0] << "\n"
00080 "\n"
00081 "Available options:\n";
00082 cout << o.list();
00083 return 0;
00084 }
00085
00086 if(argc > 1)
00087 {
00088 cerr << "Too many aguments\n";
00089 cerr << "Try --help\n";
00090 return 1;
00091 }
00092
00093 Ref<Session> session =
00094 Session::create(opt_serverName, opt_corbaEndpointPort);
00095
00096 Ref<Application> application =
00097 Application::create(session, Uri());
00098
00099 Ref<Transform> rootTransform = Transform::create(application);
00100 rootTransform->rotation = Rotation3(Vector3(1, 0, 0), M_PI/2);
00101 rootTransform->scale = Vector3(2, 2, 2);
00102
00103 Ref<Group> rootGroup = Group::create(application);
00104 rootGroup->children.add(rootTransform);
00105
00106 application->setRootGroup(rootGroup);
00107 application->launch();
00108
00109
00110 {
00111 Thread::sleep(Time(0.1));
00112
00113 Ref<Appearance> apperance = Appearance::create(application);
00114 apperance->material = Material::create(application);
00115
00116 Ref<Cylinder> cyl = Cylinder::create(application);
00117 cyl->side = false;
00118 cyl->top = false;
00119 cyl->bottom = false;
00120
00121 Ref<Shape> shape = Shape::create(application);
00122 shape->appearance = apperance;
00123 shape->geometry = cyl;
00124
00125 Ref<TouchSensor> touch = TouchSensor::create(application);
00126 touch->touchTime.registerInterest<SFTime>
00127 (new CookieFuncCaller<SFTime, int>(&handleCyl, 1));
00128
00129 Ref<Transform> transform = Transform::create(application);
00130 transform->translation = Vector3(-5, 0, -1.5);
00131 transform->children.add(shape);
00132 transform->children.add(touch);
00133
00134 rootTransform->children.add(transform);
00135 }
00136
00137
00138 {
00139 Thread::sleep(Time(0.1));
00140
00141 Ref<Appearance> apperance = Appearance::create(application);
00142 apperance->material = Material::create(application);
00143
00144 Ref<Cylinder> cyl = Cylinder::create(application);
00145 cyl->side = false;
00146 cyl->top = false;
00147
00148 Ref<Shape> shape = Shape::create(application);
00149 shape->appearance = apperance;
00150 shape->geometry = cyl;
00151
00152 Ref<TouchSensor> touch = TouchSensor::create(application);
00153 touch->touchTime.registerInterest<SFTime>
00154 (new CookieFuncCaller<SFTime, int>(&handleCyl, 2));
00155
00156 Ref<Transform> transform = Transform::create(application);
00157 transform->translation = Vector3(-2, 0, -1.5);
00158 transform->children.add(shape);
00159 transform->children.add(touch);
00160
00161 rootTransform->children.add(transform);
00162 }
00163
00164
00165 {
00166 Thread::sleep(Time(0.1));
00167
00168 Ref<Appearance> apperance = Appearance::create(application);
00169 apperance->material = Material::create(application);
00170
00171 Ref<Cylinder> cyl = Cylinder::create(application);
00172 cyl->side = false;
00173 cyl->bottom = false;
00174
00175 Ref<Shape> shape = Shape::create(application);
00176 shape->appearance = apperance;
00177 shape->geometry = cyl;
00178
00179 Ref<TouchSensor> touch = TouchSensor::create(application);
00180 touch->touchTime.registerInterest<SFTime>
00181 (new CookieFuncCaller<SFTime, int>(&handleCyl, 3));
00182
00183 Ref<Transform> transform = Transform::create(application);
00184 transform->translation = Vector3(-5, 0, 1.5);
00185 transform->children.add(shape);
00186 transform->children.add(touch);
00187
00188 rootTransform->children.add(transform);
00189 }
00190
00191
00192 {
00193 Thread::sleep(Time(0.1));
00194
00195 Ref<Appearance> apperance = Appearance::create(application);
00196 apperance->material = Material::create(application);
00197
00198 Ref<Cylinder> cyl = Cylinder::create(application);
00199 cyl->side = false;
00200
00201 Ref<Shape> shape = Shape::create(application);
00202 shape->appearance = apperance;
00203 shape->geometry = cyl;
00204
00205 Ref<TouchSensor> touch = TouchSensor::create(application);
00206 touch->touchTime.registerInterest<SFTime>
00207 (new CookieFuncCaller<SFTime, int>(&handleCyl, 4));
00208
00209 Ref<Transform> transform = Transform::create(application);
00210 transform->translation = Vector3(-2, 0, 1.5);
00211 transform->children.add(shape);
00212 transform->children.add(touch);
00213
00214 rootTransform->children.add(transform);
00215 }
00216
00217
00218 {
00219 Thread::sleep(Time(0.1));
00220
00221 Ref<Appearance> apperance = Appearance::create(application);
00222 apperance->material = Material::create(application);
00223
00224 Ref<Cylinder> cyl = Cylinder::create(application);
00225 cyl->top = false;
00226 cyl->bottom = false;
00227
00228 Ref<Shape> shape = Shape::create(application);
00229 shape->appearance = apperance;
00230 shape->geometry = cyl;
00231
00232 Ref<TouchSensor> touch = TouchSensor::create(application);
00233 touch->touchTime.registerInterest<SFTime>
00234 (new CookieFuncCaller<SFTime, int>(&handleCyl, 5));
00235
00236 Ref<Transform> transform = Transform::create(application);
00237 transform->translation = Vector3(2, 0, -1.5);
00238 transform->children.add(shape);
00239 transform->children.add(touch);
00240
00241 rootTransform->children.add(transform);
00242 }
00243
00244
00245 {
00246 Thread::sleep(Time(0.1));
00247
00248 Ref<Appearance> apperance = Appearance::create(application);
00249 apperance->material = Material::create(application);
00250
00251 Ref<Cylinder> cyl = Cylinder::create(application);
00252 cyl->top = false;
00253
00254 Ref<Shape> shape = Shape::create(application);
00255 shape->appearance = apperance;
00256 shape->geometry = cyl;
00257
00258 Ref<TouchSensor> touch = TouchSensor::create(application);
00259 touch->touchTime.registerInterest<SFTime>
00260 (new CookieFuncCaller<SFTime, int>(&handleCyl, 6));
00261
00262 Ref<Transform> transform = Transform::create(application);
00263 transform->translation = Vector3(5, 0, -1.5);
00264 transform->children.add(shape);
00265 transform->children.add(touch);
00266
00267 rootTransform->children.add(transform);
00268 }
00269
00270
00271 {
00272 Thread::sleep(Time(0.1));
00273
00274 Ref<Appearance> apperance = Appearance::create(application);
00275 apperance->material = Material::create(application);
00276
00277 Ref<Cylinder> cyl = Cylinder::create(application);
00278 cyl->bottom = false;
00279
00280 Ref<Shape> shape = Shape::create(application);
00281 shape->appearance = apperance;
00282 shape->geometry = cyl;
00283
00284 Ref<TouchSensor> touch = TouchSensor::create(application);
00285 touch->touchTime.registerInterest<SFTime>
00286 (new CookieFuncCaller<SFTime, int>(&handleCyl, 7));
00287
00288 Ref<Transform> transform = Transform::create(application);
00289 transform->translation = Vector3(2, 0, 1.5);
00290 transform->children.add(shape);
00291 transform->children.add(touch);
00292
00293 rootTransform->children.add(transform);
00294 }
00295
00296
00297 {
00298 Thread::sleep(Time(0.1));
00299
00300 Ref<Appearance> apperance = Appearance::create(application);
00301 apperance->material = Material::create(application);
00302
00303 Ref<Cylinder> cyl = Cylinder::create(application);
00304
00305 Ref<Shape> shape = Shape::create(application);
00306 shape->appearance = apperance;
00307 shape->geometry = cyl;
00308
00309 Ref<TouchSensor> touch = TouchSensor::create(application);
00310 touch->touchTime.registerInterest<SFTime>
00311 (new CookieFuncCaller<SFTime, int>(&handleCyl, 8));
00312
00313 Ref<Transform> transform = Transform::create(application);
00314 transform->translation = Vector3(5, 0, 1.5);
00315 transform->children.add(shape);
00316 transform->children.add(touch);
00317
00318 rootTransform->children.add(transform);
00319 }
00320
00321 Archon::Utilities::Time delay(0, 100000000l);
00322
00323 while(true)
00324 {
00325 Archon::Utilities::Thread::sleep(delay);
00326 }
00327
00328 return 0;
00329 }
00330 }
00331 }
00332 }
00333
00334 int main(int argc, const char *argv[]) throw()
00335 {
00336 using namespace std;
00337 using namespace Archon::Utilities;
00338 using namespace Archon::X3D;
00339
00340 set_unexpected(Exception::terminal<Proxy::exceptionCatchInfo>);
00341 set_terminate (Exception::terminal<Proxy::exceptionCatchInfo>);
00342
00343 return Archon::SaiTestApps::Cylinders::main(argc, argv);
00344 }