From 80a13f1ac759b495ab77e77276bd613308c4aee4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 30 Mar 2017 12:20:45 +0100 Subject: [PATCH] Added --address and --port command line parameters to osgoscdevice example --- examples/osgoscdevice/osgoscdevice.cpp | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/examples/osgoscdevice/osgoscdevice.cpp b/examples/osgoscdevice/osgoscdevice.cpp index 88e96adad..558a8c072 100644 --- a/examples/osgoscdevice/osgoscdevice.cpp +++ b/examples/osgoscdevice/osgoscdevice.cpp @@ -201,7 +201,7 @@ private: bool UserEventHandler::handle(osgGA::Event* event, osg::Object* /*object*/, osg::NodeVisitor* nv) { - OSG_ALWAYS << "handle user-event: " << event->getName() << std::endl; + OSG_INFO << "handle user-event: " << event->getName() << std::endl; if (event->getName() == "/pick-result") { @@ -398,7 +398,7 @@ int main( int argc, char **argv ) arguments.getApplicationUsage()->addCommandLineOption("--zeroconf","uses zeroconf to advertise the osc-plugin and to discover it"); arguments.getApplicationUsage()->addCommandLineOption("--sender","create a view which sends its events via osc"); - arguments.getApplicationUsage()->addCommandLineOption("--recevier","create a view which receive its events via osc"); + arguments.getApplicationUsage()->addCommandLineOption("--receiver","create a view which receive its events via osc"); @@ -414,12 +414,19 @@ int main( int argc, char **argv ) scene = geode; } + std::string address; + std::string port; + bool use_zeroconf(false); bool use_sender(false); bool use_receiver(false); if(arguments.find("--zeroconf") > 0) { use_zeroconf = true; } if(arguments.find("--sender") > 0) { use_sender = true; } if(arguments.find("--receiver") > 0) { use_receiver = true; } + + while (arguments.read("--address", address)) {} + while (arguments.read("--port", port)) {} + // construct the viewer. osgViewer::CompositeViewer viewer(arguments); @@ -463,7 +470,13 @@ int main( int argc, char **argv ) view->addEventHandler( new osgViewer::StatsHandler ); view->addEventHandler( new UserEventHandler(text) ); - osg::ref_ptr device = osgDB::readRefFile("0.0.0.0:9000.receiver.osc"); + if (address.empty()) address="0.0.0.0"; + if (port.empty()) port="9000"; + + std::string address_port = address+":"+port+".receiver.osc"; + OSG_NOTICE<<"osc plugin address:port string : "< device = osgDB::readRefFile(address_port); if (device.valid() && (device->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)) { view->addDevice(device); @@ -536,7 +549,13 @@ int main( int argc, char **argv ) } else { - osg::ref_ptr device = osgDB::readRefFile("localhost:9000.sender.osc"); + if (address.empty()) address="localhost"; + if (port.empty()) port="9000"; + + std::string address_port = address+":"+port+".sender.osc"; + OSG_NOTICE<<"osc plugin address:port string : "< device = osgDB::readRefFile(address_port); if (device.valid() && (device->getCapabilities() & osgGA::Device::SEND_EVENTS)) { // add as first event handler, so it gets ALL events ...