Re: [osg-users] Using Ortho2D projection camera under OpenSceneGraph PRE_RENDER camera

2017-01-21 Thread Malcolm Pigott
It's not the prerender camera that's not being drawn, it's the geometry under 
the Ortho2D camera - the "overlay".

When drawn "normally", i.e. with the scene node being the loadedModel, all is 
well.

However, when the loadedModel is a subgraph to the PRE_RENDER camera, the 
Ortho2D does not appear. It may well be being drawn, but isn't visible.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70029#70029





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Using Ortho2D projection camera under OpenSceneGraph PRE_RENDER camera

2017-01-21 Thread Robert Osfield
Hi Martin,

I have am only popping online briefly so a just a quick response.
What makes you think that the pre render camera is not being drawn?

Robert.

On 20 January 2017 at 22:12, Malcolm Pigott
 wrote:
> I have a scene in OpenSceneGraph which has a "normal" 3D content overlaid 
> with content in an Ortho2D projection. This works OK.
>
> I am now trying to render this scene to a texture (via a Frame Buffer Object) 
> and am working with the osgPreRender example. Below is some code derived from 
> that example which has a 2D overlay which is shown when the scene is drawn 
> normally, but not (seemingly) drawn when rendered to a texture using 
> setRenderOrder(osg::Camera::PRE_RENDER).
>
> This is using OpenSceneGraph 3.4.0 and VS2015 Update 2.
>
>
> Code:
>
> /* OpenSceneGraph example, osgprerender.
> *
> *  Permission is hereby granted, free of charge, to any person obtaining a 
> copy
> *  of this software and associated documentation files (the "Software"), to 
> deal
> *  in the Software without restriction, including without limitation the 
> rights
> *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> *  copies of the Software, and to permit persons to whom the Software is
> *  furnished to do so, subject to the following conditions:
> *
> *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> *  THE SOFTWARE.
> */
>
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
>
> #include 
> #include 
> #include 
>
> #include 
>
> #include 
> #include 
> #include 
>
> #include 
> #include 
>
> #include 
>
> // call back which creates a deformation field to oscillate the model.
> class MyGeometryCallback :
> public osg::Drawable::UpdateCallback,
> public osg::Drawable::AttributeFunctor
> {
> public:
>
> MyGeometryCallback(const osg::Vec3& o,
> const osg::Vec3& x, const osg::Vec3& y, const osg::Vec3& z,
> double period, double xphase, double amplitude) :
> _firstCall(true),
> _startTime(0.0),
> _time(0.0),
> _period(period),
> _xphase(xphase),
> _amplitude(amplitude),
> _origin(o),
> _xAxis(x),
> _yAxis(y),
> _zAxis(z) {}
>
> virtual void update(osg::NodeVisitor* nv, osg::Drawable* drawable)
> {
> // OpenThreads::Thread::microSleep( 1000 );
>
> const osg::FrameStamp* fs = nv->getFrameStamp();
> double simulationTime = fs->getSimulationTime();
> if (_firstCall)
> {
> _firstCall = false;
> _startTime = simulationTime;
> }
>
> _time = simulationTime - _startTime;
>
> drawable->accept(*this);
> drawable->dirtyBound();
>
> osg::Geometry* geometry = dynamic_cast(drawable);
> if (geometry)
> {
> osgUtil::SmoothingVisitor::smooth(*geometry);
> }
>
> }
>
> virtual void apply(osg::Drawable::AttributeType type, unsigned int count, 
> osg::Vec3* begin)
> {
> if (type == osg::Drawable::VERTICES)
> {
> const float TwoPI = 2.0f*osg::PI;
> const float phase = -_time / _period;
>
> osg::Vec3* end = begin + count;
> for (osg::Vec3* itr = begin; itr {
> osg::Vec3 dv(*itr - _origin);
> osg::Vec3 local(dv*_xAxis, dv*_yAxis, dv*_zAxis);
>
> local.z() = local.x()*_amplitude*
> sinf(TwoPI*(phase + local.x()*_xphase));
>
> (*itr) = _origin +
> _xAxis*local.x() +
> _yAxis*local.y() +
> _zAxis*local.z();
> }
> }
> }
>
> bool_firstCall;
>
> double  _startTime;
> double  _time;
>
> double  _period;
> double  _xphase;
> float   _amplitude;
>
> osg::Vec3   _origin;
> osg::Vec3   _xAxis;
> osg::Vec3   _yAxis;
> osg::Vec3   _zAxis;
>
> };
>
> osg::Node* createPreRenderSubGraph(osg::Node* subgraph,
> unsigned tex_width, unsigned tex_height,
> osg::Camera::RenderTargetImplementation renderImplementation,
> bool useTextureRectangle,
> unsigned int samples, unsigned int colorSamples)
> {
> if (!subgraph) return 0;
>
> // create a group to contain the flag and the pre rendering camera.
> osg::Group* parent = new osg::Group;
>
> // texture to 

Re: [osg-users] bug: osgText doesn't work on MacOSX GL4.x with VAO

2017-01-21 Thread Remo Eichenberger
Hi Sebastian,

Sorry, please ignore my post. The code is wrong. I need to test it first :)


Cheers,
Remo

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=70027#70027





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org