From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
// Created by Thomas Hogarth 2009
|
2017-03-18 14:53:32 +08:00
|
|
|
// Cleaned up by Stephan Huber 2013
|
|
|
|
// Added gles3 support 2017 TH
|
2010-11-27 02:19:28 +08:00
|
|
|
//
|
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
// this example will create a fullscreen window showing a box. You can interact with it via
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
// multi-touch gestures.
|
|
|
|
|
2010-11-27 02:19:28 +08:00
|
|
|
#import "iphoneViewerAppDelegate.h"
|
2017-05-04 07:24:46 +08:00
|
|
|
|
2010-11-27 02:19:28 +08:00
|
|
|
#include <osg/ShapeDrawable>
|
2017-05-04 07:24:46 +08:00
|
|
|
#include <osgDB/FileUtils>
|
2017-03-18 14:53:32 +08:00
|
|
|
#include <osgUtil/Optimizer>
|
2017-05-04 07:24:46 +08:00
|
|
|
#include <osgGA/MultiTouchTrackballManipulator>
|
2010-11-27 02:19:28 +08:00
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
//include the iphone specific windowing stuff
|
|
|
|
#include <osgViewer/api/IOS/GraphicsWindowIOS>
|
2010-11-27 02:19:28 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
#include "shaders.h"
|
|
|
|
|
|
|
|
// global programs
|
|
|
|
osg::ref_ptr<osg::Program> _vertColorProgram;
|
2017-05-04 07:24:46 +08:00
|
|
|
osg::ref_ptr<osg::Program> _textureProgram;
|
2017-03-18 14:53:32 +08:00
|
|
|
|
2010-11-27 02:19:28 +08:00
|
|
|
|
2014-01-23 23:37:48 +08:00
|
|
|
@interface MyViewController : UIViewController
|
|
|
|
|
|
|
|
- (BOOL)shouldAutorotate;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MyViewController
|
|
|
|
|
|
|
|
- (BOOL)shouldAutorotate
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
2010-11-27 02:19:28 +08:00
|
|
|
@implementation iphoneViewerAppDelegate
|
|
|
|
|
|
|
|
@synthesize _window;
|
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
//
|
|
|
|
// Shape drawables sometimes use gl_quads so use this function to convert
|
|
|
|
//
|
|
|
|
void optimizeNode(osg::Node* node) {
|
|
|
|
osgUtil::Optimizer optimizer;
|
|
|
|
optimizer.optimize(node, osgUtil::Optimizer::TRISTRIP_GEOMETRY);
|
|
|
|
}
|
2010-11-27 02:19:28 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
//
|
|
|
|
// create a camera to set up the projection and model view matrices, and the subgraph to draw in the HUD
|
|
|
|
//
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
osg::Camera* createHUD(unsigned int w, unsigned int h)
|
|
|
|
{
|
|
|
|
osg::Camera* camera = new osg::Camera;
|
|
|
|
|
|
|
|
// set the projection matrix
|
|
|
|
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,w,0,h));
|
|
|
|
|
|
|
|
// set the view matrix
|
|
|
|
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
|
|
|
|
camera->setViewMatrix(osg::Matrix::identity());
|
|
|
|
|
|
|
|
// only clear the depth buffer
|
|
|
|
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
// draw subgraph after main camera view.
|
|
|
|
camera->setRenderOrder(osg::Camera::POST_RENDER);
|
|
|
|
|
|
|
|
// we don't want the camera to grab event focus from the viewers main camera(s).
|
|
|
|
camera->setAllowEventFocus(false);
|
|
|
|
|
|
|
|
// add to this camera a subgraph to render
|
|
|
|
{
|
|
|
|
osg::Geode* geode = new osg::Geode();
|
|
|
|
|
|
|
|
osg::Vec3 position(50.0f,h-50,0.0f);
|
|
|
|
|
|
|
|
{
|
2017-03-18 14:53:32 +08:00
|
|
|
osgText::Text* text = new osgText::Text();
|
|
|
|
text->setUseVertexBufferObjects(true);
|
|
|
|
text->setFont(0);//"fonts/arial.ttf");
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
text->setPosition(position);
|
|
|
|
text->setText("A simple multi-touch-example\n1 touch = rotate, \n2 touches = drag + scale, \n3 touches = home");
|
2017-03-19 01:35:00 +08:00
|
|
|
text->setColor(osg::Vec4(0.9,0.1,0.1,1.0));
|
2017-03-21 03:35:01 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
geode->addDrawable( text );
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
camera->addChild(geode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return camera;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class TestMultiTouchEventHandler : public osgGA::GUIEventHandler {
|
|
|
|
public:
|
|
|
|
TestMultiTouchEventHandler(osg::Group* parent_group)
|
|
|
|
: osgGA::GUIEventHandler(),
|
|
|
|
_cleanupOnNextFrame(false)
|
|
|
|
{
|
|
|
|
createTouchRepresentations(parent_group, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void createTouchRepresentations(osg::Group* parent_group, unsigned int num_objects)
|
|
|
|
{
|
|
|
|
// create some geometry which is shown for every touch-point
|
|
|
|
for(unsigned int i = 0; i != num_objects; ++i)
|
|
|
|
{
|
|
|
|
std::ostringstream ss;
|
|
|
|
|
|
|
|
osg::Geode* geode = new osg::Geode();
|
|
|
|
|
|
|
|
osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0,0,0), 100));
|
2017-03-18 14:53:32 +08:00
|
|
|
drawable->setUseVertexBufferObjects(true);
|
|
|
|
drawable->setDataVariance(osg::Object::DYNAMIC);
|
|
|
|
#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
|
|
|
|
drawable->getOrCreateStateSet()->setAttributeAndModes(_vertColorProgram, osg::StateAttribute::ON);
|
|
|
|
optimizeNode(drawable);
|
|
|
|
#endif
|
2017-03-19 01:35:00 +08:00
|
|
|
drawable->setColor(osg::Vec4(0.5, 0.5, 0.5,1));
|
2017-03-18 14:53:32 +08:00
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
geode->addDrawable(drawable);
|
|
|
|
|
|
|
|
ss << "Touch " << i;
|
|
|
|
|
|
|
|
osgText::Text* text = new osgText::Text;
|
2017-03-18 14:53:32 +08:00
|
|
|
text->setUseVertexBufferObjects(true);
|
|
|
|
text->setFont(0); //"fonts/arial.ttf");
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
text->setPosition(osg::Vec3(110,0,0));
|
|
|
|
text->setDataVariance(osg::Object::DYNAMIC);
|
2017-03-18 14:53:32 +08:00
|
|
|
text->setText(ss.str());
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
geode->addDrawable( text );
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
_drawables.push_back(drawable);
|
|
|
|
_texts.push_back(text);
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
|
|
|
|
osg::MatrixTransform* mat = new osg::MatrixTransform();
|
|
|
|
mat->addChild(geode);
|
|
|
|
mat->setNodeMask(0x0);
|
|
|
|
|
|
|
|
_mats.push_back(mat);
|
|
|
|
|
|
|
|
parent_group->addChild(mat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
|
|
|
|
{
|
|
|
|
switch(ea.getEventType())
|
|
|
|
{
|
|
|
|
case osgGA::GUIEventAdapter::FRAME:
|
|
|
|
if (_cleanupOnNextFrame) {
|
|
|
|
cleanup(0);
|
|
|
|
_cleanupOnNextFrame = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case osgGA::GUIEventAdapter::PUSH:
|
|
|
|
case osgGA::GUIEventAdapter::DRAG:
|
|
|
|
case osgGA::GUIEventAdapter::RELEASE:
|
|
|
|
{
|
|
|
|
// is this a multi-touch event?
|
|
|
|
if (!ea.isMultiTouchEvent())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
unsigned int j(0);
|
|
|
|
|
|
|
|
// iterate over all touch-points and update the geometry
|
|
|
|
unsigned num_touch_ended(0);
|
|
|
|
|
|
|
|
for(osgGA::GUIEventAdapter::TouchData::iterator i = ea.getTouchData()->begin(); i != ea.getTouchData()->end(); ++i, ++j)
|
|
|
|
{
|
|
|
|
const osgGA::GUIEventAdapter::TouchData::TouchPoint& tp = (*i);
|
2014-01-23 23:37:48 +08:00
|
|
|
if (ea.getMouseYOrientation() == osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS)
|
|
|
|
_mats[j]->setMatrix(osg::Matrix::translate(tp.x, ea.getWindowHeight() - tp.y, 0));
|
|
|
|
else
|
|
|
|
_mats[j]->setMatrix(osg::Matrix::translate(tp.x, tp.y, 0));
|
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
_mats[j]->setNodeMask(0xffff);
|
|
|
|
|
|
|
|
std::ostringstream ss;
|
|
|
|
ss << "Touch " << tp.id;
|
|
|
|
_texts[j]->setText(ss.str());
|
|
|
|
|
|
|
|
switch (tp.phase)
|
|
|
|
{
|
|
|
|
case osgGA::GUIEventAdapter::TOUCH_BEGAN:
|
2017-03-19 01:35:00 +08:00
|
|
|
_drawables[j]->setColor(osg::Vec4(0,1,0,1));
|
2017-03-18 14:53:32 +08:00
|
|
|
OSG_INFO << "touch began: " << ss.str() << std::endl;
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case osgGA::GUIEventAdapter::TOUCH_MOVED:
|
2017-03-18 14:53:32 +08:00
|
|
|
//OSG_INFO << "touch moved: " << ss.str() << std::endl;
|
2017-03-19 01:35:00 +08:00
|
|
|
_drawables[j]->setColor(osg::Vec4(1,1,1,1));
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case osgGA::GUIEventAdapter::TOUCH_ENDED:
|
2017-03-19 01:35:00 +08:00
|
|
|
_drawables[j]->setColor(osg::Vec4(1,0,0,1));
|
2017-03-18 14:53:32 +08:00
|
|
|
OSG_INFO << "touch ended: " << ss.str() << std::endl;
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
++num_touch_ended;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case osgGA::GUIEventAdapter::TOUCH_STATIONERY:
|
2017-03-19 01:35:00 +08:00
|
|
|
_drawables[j]->setColor(osg::Vec4(0.5,0.5,0.5,1));
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2017-03-18 14:53:32 +08:00
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// hide unused geometry
|
|
|
|
cleanup(j);
|
|
|
|
|
|
|
|
//check if all touches ended
|
|
|
|
if ((ea.getTouchData()->getNumTouchPoints() > 0) && (ea.getTouchData()->getNumTouchPoints() == num_touch_ended))
|
|
|
|
{
|
|
|
|
_cleanupOnNextFrame = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// reposition mouse-pointer
|
|
|
|
aa.requestWarpPointer((ea.getWindowX() + ea.getWindowWidth()) / 2.0, (ea.getWindowY() + ea.getWindowHeight()) / 2.0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cleanup(unsigned int j)
|
|
|
|
{
|
|
|
|
for(unsigned k = j; k < _mats.size(); ++k) {
|
|
|
|
_mats[k]->setNodeMask(0x0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<osg::ShapeDrawable*> _drawables;
|
|
|
|
std::vector<osg::MatrixTransform*> _mats;
|
|
|
|
std::vector<osgText::Text*> _texts;
|
|
|
|
bool _cleanupOnNextFrame;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-27 02:19:28 +08:00
|
|
|
//
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
//Called once app has finished launching, create the viewer then realize. Can't call viewer->run as will
|
2010-11-27 02:19:28 +08:00
|
|
|
//block the final inialization of the windowing system
|
|
|
|
//
|
|
|
|
- (void)applicationDidFinishLaunching:(UIApplication *)application {
|
|
|
|
|
|
|
|
//get the screen size
|
|
|
|
CGRect lFrame = [[UIScreen mainScreen] bounds];
|
2014-01-23 23:37:48 +08:00
|
|
|
unsigned int w = lFrame.size.width * [[UIScreen mainScreen] scale];
|
|
|
|
unsigned int h = lFrame.size.height * [[UIScreen mainScreen] scale];
|
2010-11-27 02:19:28 +08:00
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
//create the viewer
|
|
|
|
_viewer = new osgViewer::Viewer();
|
|
|
|
|
|
|
|
|
2014-01-23 23:37:48 +08:00
|
|
|
if(1) {
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
|
2014-01-23 23:37:48 +08:00
|
|
|
// If you want full control over the graphics context / window creation, please uncomment this section
|
|
|
|
|
|
|
|
// create the main window at screen size
|
|
|
|
self._window = [[UIWindow alloc] initWithFrame: lFrame];
|
|
|
|
|
|
|
|
//show window
|
|
|
|
[_window makeKeyAndVisible];
|
|
|
|
|
|
|
|
UIView* parent_view = [[UIView alloc] initWithFrame: CGRectMake(0,0, w, h)];
|
|
|
|
parent_view.backgroundColor = [UIColor redColor];
|
|
|
|
[self._window addSubview: parent_view];
|
|
|
|
MyViewController* view_controller = [[MyViewController alloc] init];
|
|
|
|
view_controller.view = parent_view;
|
|
|
|
self._window.rootViewController = view_controller;
|
|
|
|
|
|
|
|
|
|
|
|
//create our graphics context directly so we can pass our own window
|
|
|
|
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
|
|
|
|
|
|
|
// Init the Windata Variable that holds the handle for the Window to display OSG in.
|
|
|
|
osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowIOS::WindowData(parent_view);
|
|
|
|
|
|
|
|
// Setup the traits parameters
|
2017-03-18 14:53:32 +08:00
|
|
|
traits->x = 0;
|
|
|
|
traits->y = 0;
|
|
|
|
traits->width = w;
|
|
|
|
traits->height = h;
|
|
|
|
traits->depth = 16; //can be 16 or 24
|
2014-01-23 23:37:48 +08:00
|
|
|
traits->windowDecoration = false;
|
|
|
|
traits->doubleBuffer = true;
|
|
|
|
traits->sharedContext = 0;
|
|
|
|
traits->setInheritedWindowPixelFormat = true;
|
|
|
|
traits->samples = 4;
|
|
|
|
traits->sampleBuffers = 1;
|
|
|
|
|
|
|
|
traits->inheritedWindowData = windata;
|
2010-11-27 02:19:28 +08:00
|
|
|
|
2014-01-23 23:37:48 +08:00
|
|
|
// Create the Graphics Context
|
|
|
|
osg::ref_ptr<osg::GraphicsContext> graphicsContext = osg::GraphicsContext::createGraphicsContext(traits.get());
|
|
|
|
|
|
|
|
// if the context was created then attach to our viewer
|
|
|
|
if(graphicsContext)
|
|
|
|
{
|
|
|
|
_viewer->getCamera()->setGraphicsContext(graphicsContext);
|
|
|
|
_viewer->getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
|
2017-03-18 14:53:32 +08:00
|
|
|
_viewer->getCamera()->setProjectionMatrixAsPerspective(60.0, (double)traits->width/(double)traits->height, 0.1, 1000.0);
|
2018-03-07 00:54:57 +08:00
|
|
|
_viewer->getCamera()->setDrawBuffer(GL_BACK);
|
|
|
|
_viewer->getCamera()->setReadBuffer(GL_BACK);
|
2014-01-23 23:37:48 +08:00
|
|
|
}
|
2010-11-27 02:19:28 +08:00
|
|
|
}
|
2017-03-18 14:53:32 +08:00
|
|
|
|
|
|
|
// create our default programs
|
|
|
|
#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
|
|
|
|
_vertColorProgram = new osg::Program();
|
|
|
|
_vertColorProgram->addShader( new osg::Shader(osg::Shader::VERTEX, ColorShaderVert));
|
|
|
|
_vertColorProgram->addShader( new osg::Shader(osg::Shader::FRAGMENT, ColorShaderFrag));
|
2017-05-04 07:24:46 +08:00
|
|
|
|
|
|
|
_textureProgram = new osg::Program();
|
|
|
|
_textureProgram->addShader( new osg::Shader(osg::Shader::VERTEX, TextureShaderVert));
|
|
|
|
_textureProgram->addShader( new osg::Shader(osg::Shader::FRAGMENT, TextureShaderFrag));
|
2017-03-18 14:53:32 +08:00
|
|
|
#endif
|
2010-11-27 02:19:28 +08:00
|
|
|
|
|
|
|
//create root
|
2017-03-18 14:53:32 +08:00
|
|
|
_root = new osg::MatrixTransform();
|
|
|
|
_root->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);
|
2010-11-27 02:19:28 +08:00
|
|
|
|
|
|
|
//load and attach scene model
|
2017-11-29 02:51:31 +08:00
|
|
|
osg::ref_ptr<osg::Node> model = osgDB::readRefNodeFile(osgDB::findDataFile("lz.osg"));
|
2017-03-18 14:53:32 +08:00
|
|
|
if (!model) {
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
osg::Geode* geode = new osg::Geode();
|
2017-03-18 14:53:32 +08:00
|
|
|
osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0,0,0), 1));
|
2017-03-19 01:35:00 +08:00
|
|
|
drawable->setColor(osg::Vec4(0.1,0.1,0.9,1.0));
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
geode->addDrawable(drawable);
|
2017-03-18 14:53:32 +08:00
|
|
|
model = geode;
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
}
|
2010-11-27 02:19:28 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
// attach shader program if needed
|
|
|
|
#if defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
|
2017-05-04 07:24:46 +08:00
|
|
|
//model->getOrCreateStateSet()->setAttributeAndModes(_vertColorProgram, osg::StateAttribute::ON);
|
|
|
|
model->getOrCreateStateSet()->setAttributeAndModes(_textureProgram, osg::StateAttribute::ON);
|
2017-03-18 14:53:32 +08:00
|
|
|
optimizeNode(model);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
_root->addChild(model);
|
|
|
|
|
|
|
|
// create text hud
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
osg::Camera* hud_camera = createHUD(w,h);
|
|
|
|
_root->addChild(hud_camera);
|
2010-11-27 02:19:28 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
|
|
|
|
// attach root to viewer and add event handlers
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
_viewer->setSceneData(_root.get());
|
|
|
|
_viewer->setCameraManipulator(new osgGA::MultiTouchTrackballManipulator());
|
|
|
|
_viewer->addEventHandler(new TestMultiTouchEventHandler(hud_camera));
|
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
// run single-threaded
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
_viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
2010-11-27 02:19:28 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
osg::setNotifyLevel(osg::INFO);
|
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
_viewer->realize();
|
2010-11-27 02:19:28 +08:00
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
// render a frame so the window-manager shows some content and not only an empty + black window
|
|
|
|
_viewer->frame();
|
2010-11-27 02:19:28 +08:00
|
|
|
|
2017-03-18 14:53:32 +08:00
|
|
|
osg::setNotifyLevel(osg::WARN);
|
2010-11-27 02:19:28 +08:00
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
// create a display link, which will update our scene on every screen-refresh
|
|
|
|
_displayLink = [application.keyWindow.screen displayLinkWithTarget:self selector:@selector(updateScene)];
|
|
|
|
[_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
2010-11-27 02:19:28 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//Timer called function to update our scene and render the viewer
|
|
|
|
//
|
|
|
|
- (void)updateScene {
|
|
|
|
_viewer->frame();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationWillResignActive:(UIApplication *)application {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
-(void)applicationWillTerminate:(UIApplication *)application {
|
|
|
|
if (_displayLink)
|
|
|
|
[_displayLink invalidate];
|
|
|
|
_displayLink = NULL;
|
2010-11-27 02:19:28 +08:00
|
|
|
_root = NULL;
|
|
|
|
_viewer = NULL;
|
|
|
|
}
|
|
|
|
|
From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 18:05:09 +08:00
|
|
|
|
2010-11-27 02:19:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
- (void)dealloc {
|
|
|
|
_root = NULL;
|
|
|
|
_viewer = NULL;
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|