Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Trajce Nikolov NICK
if you try the code I sent you you will see that it works. Do you have
somewhere upper in the hierarchy other transform nodes, other
PositionAttitudeTransforms, MatrixTransforms. What happen if you don't set
any of the position and the attitude of the PositionAttitudeTransforms, are
you seeing the model where it should be?

Nick


On Wed, May 14, 2014 at 11:45 PM, Tiago Martins wrote:

> Do you mean this?
>
> change from
>
> final = translate1 * rotate * translate2;
>
> to
>
> final =  rotate * translate2;
>
> ??
>
> Also didn't work :s  I don't see the object..
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59421#59421
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Tiago Martins
Do you mean this?

change from 

final = translate1 * rotate * translate2; 

to

final =  rotate * translate2;

??

Also didn't work :s  I don't see the object..

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





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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Trajce Nikolov NICK
try removing translate1 from the final matrix computation.

Nick


On Wed, May 14, 2014 at 11:30 PM, Tiago Martins wrote:

> Hey man I used your code for my UpdateCallback but didn't work.. Now I
> don't even see the object..
>
> It might be one another position..
>
> The position where I want it to be is at (0,-100,10), I copy pasted your
> UpdateCallback method..
>
> Do I need to do anything more ?
>
> Thanks alot again ;)
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59418#59418
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread David Callu
Hi All,


Promoting osg::Drawable from being subclassed from osg::Object to
osg::Node is really a good idea ?
Why osg::Drawable is a subclass of osg::Object in original design ?
Which concept are implemented by this design?
Except avoid the use of geode, what is the benefice of the new design ?

I use many time in my code one Geode with one drawable, and think to
myself that could be easiest to just attach a Drawable to a Group. But
a drawable is not a node. Don't forget the first coding rules of Agile
Software "The Single Responsibility Principle". Drawable (and his
subclass) have to handle rendering of something. This is already a big
stuff, no need to add node concept in this class.

With the new design, osg::Geode is no longer a leaf node neither a
group, if it become a group, we need to check in add/removeChild
method if the node is a drawable or not, instead of constraint this by
design like this is done in original code.

osg::ParentList is not longer a "list of osg::Group" ... so other
thing that a group could be a parent? any node subclass  should be a
parent ? We have loose some concept in the process, logic of
Node/Group/Geode/Drawable is not really clear.


So ask yourself. Why drawable is not a subclass of osg node, and why
do we need to use a Geode ?
If you have no answer think again.
If you have an answer, could we avoid the concept implemented by
osg::Geode/osg::Drawable ?


My 2 cents

David




2014-05-14 18:08 GMT+02:00 Robert Osfield :
> Hi All,
>
> I have now checked in further improvements to the Drawable/Node Bound
> changes.  You can now compile and run the OSG with or without the new
> Bound adapter class.
>
> I am still undecided about the merits of the Bound class.  My C++
> developer instinct is not have the Bond class and push end user code
> to be refactored to use drawable->getBoundingBox() in place of old
> getBound() usage.  While as caretaker of the OSG codebase I really
> don't want to force users to handle broken builds because of change to
> the core.
>
> One thing we could do is just try out how end user applications cope
> with the new changes with the Bound class compiled as default, if that
> works OK, then disable the default build of the Bound class and then
> get feedback from the community about the extent of the build
> breakages.
>
> Robert.
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Tiago Martins
Hey man I used your code for my UpdateCallback but didn't work.. Now I don't 
even see the object..

It might be one another position.. 

The position where I want it to be is at (0,-100,10), I copy pasted your 
UpdateCallback method..

Do I need to do anything more ?

Thanks alot again ;)

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





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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Trajce Nikolov NICK
dude :- .. no problem dude

Nick



On Wed, May 14, 2014 at 10:41 PM, Tiago Martins wrote:

> Okay I will test it, and will let you know if it worked ;)
>
> Thanks alot for your help dude ;)
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59416#59416
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Tiago Martins
Okay I will test it, and will let you know if it worked ;)

Thanks alot for your help dude ;)

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





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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Trajce Nikolov NICK
Hi Tiago,

I can not compile your code due to dependency. Attached is sample code of
what you are trying to do. Hope it helps

Cheers,
Nick


On Wed, May 14, 2014 at 9:34 PM, Trajce Nikolov NICK <
trajce.nikolov.n...@gmail.com> wrote:

> nope :-) .. give it a try .. it will return the final resulting matrix
> components
>
> Nick
>
>
> On Wed, May 14, 2014 at 9:35 PM, Tiago Martins 
> wrote:
>
>> Well here is my entire code http://tny.cz/c16abd43, but you don't have
>> the .obj files..
>>
>> And I can't use getTranslate() and getRotate()... because
>> mxt.getTranslate() will return both translations.. And the operations must
>> be in the following order: translation1 then rotation then translation2..
>>
>> I guess.. right?
>>
>> Thanks again ;)
>>
>> --
>> Read this topic online here:
>> http://forum.openscenegraph.org/viewtopic.php?p=59413#59413
>>
>>
>>
>>
>>
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
>
> --
> trajce nikolov nick
>



-- 
trajce nikolov nick
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
 *
 * This application is open source and may be redistributed and/or modified
 * freely and without restriction, both in commercial and non commercial applications,
 * as long as this copyright notice is maintained.
 *
 * This application is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

#include 
#include 
#include 

#include 
#include 

#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 

#include 

#include 
#include 

#ifndef GL_ARB_sync
#define GL_MAX_SERVER_WAIT_TIMEOUT0x9111
#define GL_OBJECT_TYPE0x9112
#define GL_SYNC_CONDITION 0x9113
#define GL_SYNC_STATUS0x9114
#define GL_SYNC_FLAGS 0x9115
#define GL_SYNC_FENCE 0x9116
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
#define GL_UNSIGNALED 0x9118
#define GL_SIGNALED   0x9119
#define GL_ALREADY_SIGNALED   0x911A
#define GL_TIMEOUT_EXPIRED0x911B
#define GL_CONDITION_SATISFIED0x911C
#define GL_WAIT_FAILED0x911D
#define GL_SYNC_FLUSH_COMMANDS_BIT0x0001
#define GL_TIMEOUT_IGNORED0xull
#endif

class MySwapBuffersCallback : public osg::GraphicsContext::SwapCallback
{
public:
MySwapBuffersCallback():
_extensionInitialized(false),
_glFenceSync(0),
_glIsSync(0),
_glDeleteSync(0),
_glClientWaitSync(0),
_glWaitSync(0),
_glGetInteger64v(0),
_glGetSynciv(0),
_previousSync(0)
{
 OSG_NOTICE<<"Created Swap callback."getState()->checkGLErrors("after glWaitSync");

//OSG_NOTICE<<"After swap"<(node);
		if (pat)
		{
			osg::Matrixd final;

			osg::Matrixd translate1 = osg::Matrixd::translate(-node->getBound().center());

			static double angle = 0;
			osg::Quat q;
			q.makeRotate(osg::DegreesToRadians(++angle),osg::Vec3(0,0,1));
			osg::Matrixd rotate = osg::Matrix::rotate(q);

			osg::Matrixd translate2 = osg::Matrixd::translate(node->getBound().center());

			final = translate1 * rotate * translate2;

			pat->setPosition(final.getTrans());
			pat->setAttitude(final.getRotate());
		}
		traverse(node,nv);
	}
};

int main(int argc, char** argv)
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);

arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("--image ","Load an image and render it on a quad");
arguments.getApplicationUsage()->addCommandLineOption("--dem ","Load an image/DEM and render it on a HeightField");
arguments.getApplicationUsage()->addCommandLineOption("--log

Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Trajce Nikolov NICK
nope :-) .. give it a try .. it will return the final resulting matrix
components

Nick


On Wed, May 14, 2014 at 9:35 PM, Tiago Martins wrote:

> Well here is my entire code http://tny.cz/c16abd43, but you don't have
> the .obj files..
>
> And I can't use getTranslate() and getRotate()... because
> mxt.getTranslate() will return both translations.. And the operations must
> be in the following order: translation1 then rotation then translation2..
>
> I guess.. right?
>
> Thanks again ;)
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59413#59413
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Tiago Martins
Well here is my entire code http://tny.cz/c16abd43, but you don't have the .obj 
files..

And I can't use getTranslate() and getRotate()... because mxt.getTranslate() 
will return both translations.. And the operations must be in the following 
order: translation1 then rotation then translation2..

I guess.. right?

Thanks again ;)

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





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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Trajce Nikolov NICK
it will not work since you are overriding the position. Can you share your
code so I can compile .. This is simple and I have to look into
PositionAttitudeTransform. With matrices you can do it too.

Once your matrix is ready you can do something like
heliceTranf->setPosition(mx.getTranslate();
heliceTrans->setAttitude(mx.getRotate)

where mx is Matrixd and constructed as is my previous email, like:

Matrixd mx;
Matrixd translate1 = Matrixd::translate(-Vec3(x,y,z));
Matrix rotate = Marixd::rotate(q/*your quaternion*/);
Matrix translate2 = Matrixd::translate(Vec3(x,y,z));

mx = translate1 * rotate * translate2;

Send me your code I will look at Something I can compile fast :-)

Nick


On Wed, May 14, 2014 at 9:13 PM, Tiago Martins wrote:

> Thanks Nikolov, I tried something as you suggested..
>
>
> Code:
> osg::PositionAttitudeTransform* heliceTransf =
> static_cast(node);
>
> heliceTransf->setPosition(-osg::Vec3(0,-100,10));
>
>
>
> osg::Quat q = heliceTransf->getAttitude();
> q *= osg::Quat(0.0, osg::Y_AXIS, 0.0, osg::X_AXIS, 0.05,
> osg::Z_AXIS);
> heliceTransf->setAttitude(q);
>
>
>
> heliceTransf->setPosition(osg::Vec3(0,-100,10));
>
>
>
> But still is not rotating around its center..
>
> And I can't use the as you suggested using the Matrix, because the
> rotation must be placed at the node object as using the "setAttitude"
> method..
>
> Thanks alot again, can you see what is happening ?
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59411#59411
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Tiago Martins
Thanks Nikolov, I tried something as you suggested..


Code:
osg::PositionAttitudeTransform* heliceTransf = 
static_cast(node);

heliceTransf->setPosition(-osg::Vec3(0,-100,10));



osg::Quat q = heliceTransf->getAttitude();
q *= osg::Quat(0.0, osg::Y_AXIS, 0.0, osg::X_AXIS, 0.05, 
osg::Z_AXIS);
heliceTransf->setAttitude(q);



heliceTransf->setPosition(osg::Vec3(0,-100,10));



But still is not rotating around its center..

And I can't use the as you suggested using the Matrix, because the rotation 
must be placed at the node object as using the "setAttitude" method..

Thanks alot again, can you see what is happening ?

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





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


[osg-users] OSG and JOGL

2014-05-14 Thread Pavel Stepanek
Hi,

I would like to ask whether OSG can be used with JOGL.

Yes, I found some threads about the topic, but they are quite old and the 
solution seems to be not seamless.

I would like to have multiple viewers (JOGL canvases, etc.) sharing OpenGL 
contexts. Also multi-threading should be supported.

Thank you for any help!
Pavel

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





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


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread Robert Osfield
Hi All,

I have now checked in further improvements to the Drawable/Node Bound
changes.  You can now compile and run the OSG with or without the new
Bound adapter class.

I am still undecided about the merits of the Bound class.  My C++
developer instinct is not have the Bond class and push end user code
to be refactored to use drawable->getBoundingBox() in place of old
getBound() usage.  While as caretaker of the OSG codebase I really
don't want to force users to handle broken builds because of change to
the core.

One thing we could do is just try out how end user applications cope
with the new changes with the Bound class compiled as default, if that
works OK, then disable the default build of the Bound class and then
get feedback from the community about the extent of the build
breakages.

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


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread Robert Osfield
HI Lionel,

On 14 May 2014 14:51, Lionel Lagarde  wrote:
> In order to get the center of the bounding box of a drawable, using to Bound
> helper class, you have to do:
> const osg::BoundingBox &bbox = geometry->getBound(); // type cast operator
> osg::Vec3 c = bbox.center();
>
> Because:
> osg::Vec3 c = geometry->getBound().center();
>
> Will throw a segmentation fault while trying to access to the bounding
> sphere member of the Bound helper class.

It shouldn't throw an seg fault once I've checked in my current work
as the getBound() from a Drawable will always pass back a valid
BoundingBox as well as valid BoundingSphere.

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


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread Robert Osfield
Hi Pjotr,

Thanks for the testing.  I think the problems you've seen are down to
me not completing the getBound() implementation in Drawable - the
Drawable::getBound() should return a Bound with both the
BoundingSphere and BoundingBox set.  I have now done this
implementation and am about to check it in once I've done a clean
build and some more testing.

Robert.

On 14 May 2014 14:52, Pjotr Svetachov  wrote:
> I tested the code in trunk with OSG_USE_BOUND defined and I now get crashes 
> when loading files. After some debugging it looks like expressions like these 
> (see Geode::computeBound() and Group::computeBound()):
>
> bb.expandBy((*itr)->getBound());
>
> do not work anymore because the compiler can not know in advance which 
> overload of expandBy to use for the function call. If the wrong overload is 
> chosen a null pointer will be passed to the function resulting in a crash. 
> After changing te lines to:
>
> bb.expandBy((const osg::BoundingSphere&)((*itr)->getBound()));
>
> it crashes later in the cull traversal in CullVisitor::apply(osg::Drawable& 
> drawable) because the line
>
> const BoundingBox &bb =drawable.getBound();
>
> expects a BoundingBox while the Bound wrapper has a BoundingSphere.
>
> I have not looked further if there are more places these crashes can occur 
> but after a bit of thinking I must say that Farshid is right about the 
> segfaults and just forcing people to rename their methods is a better 
> solution. Basically if your test suite does not cover your whole code base 
> you could accidentally skip one of these bugs and ship it to customers which 
> would be bad.
>
> Cheers,
> Pjotr
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59404#59404
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to use gDEBugger for OSG performance analysis

2014-05-14 Thread Alistair Baxter
I can use GDEBugger with OpenSceneGraph perfectly well, despite using several 
dlls in my application.

The key thing seems to be that it needs access to debug symbols (i.e pdb files) 
for all of the code, or at least any of the code that is using OpenGL directly, 
which in our cases includes osg itself.

Alistair Baxter
Software Engineer

View our 2014 Public Training schedule online at http://www.mve.com/calendar

Midland Valley Exploration Ltd.
2 West Regent Street
Glasgow G2 1RW
United Kingdom
Tel: +44 (0) 141 332 2681
Fax:+44 (0) 141 332 6792
The structural geology experts 
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread Lionel Lagarde
In order to get the center of the bounding box of a drawable, using to 
Bound helper class, you have to do:

const osg::BoundingBox &bbox = geometry->getBound(); // type cast operator
osg::Vec3 c = bbox.center();

Because:
osg::Vec3 c = geometry->getBound().center();

Will throw a segmentation fault while trying to access to the bounding 
sphere member of the Bound helper class.


User code have to be modified (or at least checked) in order to prevent 
that.


Lionel.

On 14/05/2014 15:04, Robert Osfield wrote:

Hi Lionel,

On 14 May 2014 10:59, Lionel Lagarde  wrote:

The center() method exists in the BoundingBox interface. With the Bound
interface you provide, this code would throw a seg fault:
og::Vec3 c = geometry->getBound().center();


The Bound class that I have implemented so far only access the
BoundingSphere::center() and doesn't attempt to pass back the
BoundingBox::center().  As the BoundingSphere is always implemented
this code should never produce a seg fault.




In order to avoid any modification of user code, the center method (and all
the methods defined in the BoundingBox and the BoundingSphere classes) has
to be redefined in the helper class:
osg::Vec3 Bound::center() const
{
 if (bb) return bb->center();
 return bs->center();
}

But it's a pity to return a new instance of Vec3 for BoundingSphere (it
should be a const reference).


The BoundingBox::center() is really just a convenience method, it
doesn't access a variable in the way that the BoundingSphere::center()
does, so I'm incline not to implement a Bound::center() other than to
access the BoundingSphere::center().

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


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


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread Pjotr Svetachov
I tested the code in trunk with OSG_USE_BOUND defined and I now get crashes 
when loading files. After some debugging it looks like expressions like these 
(see Geode::computeBound() and Group::computeBound()):

bb.expandBy((*itr)->getBound());

do not work anymore because the compiler can not know in advance which overload 
of expandBy to use for the function call. If the wrong overload is chosen a 
null pointer will be passed to the function resulting in a crash. After 
changing te lines to:

bb.expandBy((const osg::BoundingSphere&)((*itr)->getBound()));

it crashes later in the cull traversal in CullVisitor::apply(osg::Drawable& 
drawable) because the line

const BoundingBox &bb =drawable.getBound();

expects a BoundingBox while the Bound wrapper has a BoundingSphere.

I have not looked further if there are more places these crashes can occur but 
after a bit of thinking I must say that Farshid is right about the segfaults 
and just forcing people to rename their methods is a better solution. Basically 
if your test suite does not cover your whole code base you could accidentally 
skip one of these bugs and ship it to customers which would be bad.

Cheers,
Pjotr

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





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


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread Robert Osfield
Hi Lionel,

On 14 May 2014 10:59, Lionel Lagarde  wrote:
> The center() method exists in the BoundingBox interface. With the Bound
> interface you provide, this code would throw a seg fault:
> og::Vec3 c = geometry->getBound().center();

The Bound class that I have implemented so far only access the
BoundingSphere::center() and doesn't attempt to pass back the
BoundingBox::center().  As the BoundingSphere is always implemented
this code should never produce a seg fault.


>
> In order to avoid any modification of user code, the center method (and all
> the methods defined in the BoundingBox and the BoundingSphere classes) has
> to be redefined in the helper class:
> osg::Vec3 Bound::center() const
> {
> if (bb) return bb->center();
> return bs->center();
> }
>
> But it's a pity to return a new instance of Vec3 for BoundingSphere (it
> should be a const reference).

The BoundingBox::center() is really just a convenience method, it
doesn't access a variable in the way that the BoundingSphere::center()
does, so I'm incline not to implement a Bound::center() other than to
access the BoundingSphere::center().

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


Re: [osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Trajce Nikolov NICK
Hi Tiago,

I am not familiar with PositionAttitudeTransform (aware of it but never
used it), so I will give you some hints how to do it with MatrixTransform
instead. If your object is positioned in 3D at some point you have to
translate the object back to 0, perform the rotation there around the
center of the object and then translate it back to it's position in 3D.

something like this:
osg::MatrixTransform* mxt = new osg::MatrixTransform;
// let say your object is at x1,y1,z1 position in 3D
osg::Matrixd translate1 = osg::Matrixd::translate(-osg::Vec3(x1,y1,z1));
osg::Quat rotate = osg::Quat();
// perform your rotation here
osg::Matrixd translate2 = osg::Matrixd::translate(osg::Vec3(x1,y1,z1));

mxt->setMatrix( translate1 * rotate * translate2)

Hope this gets you the idea

Nick


On Tue, May 13, 2014 at 8:56 PM, Tiago Martins wrote:

> Hi,
>
> I am trying to rotate an object using his center as reference..
>
> This code is rotating the object using some point as reference, but I want
> to rotate using the center point of the object.
>
> Did you understood?
>
> This is my code:
>
>
> Code:
> osg::PositionAttitudeTransform* heliceTransf =
> static_cast(node);
>
> osg::Quat q = heliceTransf->getAttitude();
>
> q *= osg::Quat(0.0, osg::Y_AXIS, 0.0, osg::X_AXIS, 0.1, osg::Z_AXIS);
> heliceTransf->setAttitude(q);
>
>
>
> Thank you!
>
> Cheers,
> Tiago
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=59396#59396
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



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


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread Lionel Lagarde
The center() method exists in the BoundingBox interface. With the Bound 
interface you provide, this code would throw a seg fault:

og::Vec3 c = geometry->getBound().center();

In order to avoid any modification of user code, the center method (and 
all the methods defined in the BoundingBox and the BoundingSphere 
classes) has to be redefined in the helper class:

osg::Vec3 Bound::center() const
{
if (bb) return bb->center();
return bs->center();
}

But it's a pity to return a new instance of Vec3 for BoundingSphere (it 
should be a const reference).


Lionel.





On 13/05/2014 19:02, Robert Osfield wrote:

I have made a further tweak to my experimental Bound class, adding
center(), radius() from BoundingSphere and xMin(), yMin() etc. methods
from BoundingBox to help make it easier for Bound to act more like a
BoundingSphrere or BoundingBox.

In the code below I provide a segment that deliberately tries to
access BoundingBox methods from a BaseClass object that doesn't have a
BoundingBox so it accesses a NULL and creates a seg fault.  One could
potentially compute xMin() from a BoundingSphere, or we could throw an
exception. I'm not quite sure how much effort to make with this
temporary helper class though as it's only meant as a temporary helper
class to add porting to new versions of the OSG.

Thoughts?
Robert.

Latest Bound implementation:

struct Bound
{
 Bound():
 bb(0),
 bs(0) {}

 Bound(const osg::BoundingSphere& bs):
 bb(0),
 bs(&bs) {}

 Bound(const osg::BoundingBox& bb):
 bb(&bb),
 bs(0) {}

 Bound(const osg::BoundingSphere& bs, const osg::BoundingBox& bb):
 bb(&bb),
 bs(&bs) {}

 const osg::BoundingBox*bb;
 const osg::BoundingSphere* bs;

 const osg::Vec3& center() const { return bs->center(); }
 float radius() const { return bs->radius(); }

 float xMin() const { return bb->xMin(); }
 float yMin() const { return bb->yMin(); }
 float zMin() const { return bb->zMin(); }

 float xMax() const { return bb->xMax(); }
 float yMax() const { return bb->yMax(); }
 float zMax() const { return bb->zMax(); }

 operator const osg::BoundingBox& () const { return *bb; }
 operator const osg::BoundingSphere& () const { return *bs; }
};

struct BaseClass
{
 osg::BoundingSphere _bs;
 virtual Bound getBound() const { return Bound(_bs); }
};

struct SubClass : public BaseClass
{
 osg::BoundingBox _bb;
 virtual Bound getBound() const { return Bound(_bs, _bb); }
};


int main(int, char**)
{

 BaseClass object1;
 SubClass object2;

 const osg::BoundingSphere& bs1 = object1.getBound();
 const osg::BoundingBox& bb1 = object1.getBound();

 OSG_NOTICE<<"bs1 = "<<& bs1

[osg-users] How to use gDEBugger for OSG performance analysis

2014-05-14 Thread umesh ramesh
Hi Everyone,

I have an App that loads various DLLs before opening a GUI. After giving some 
input from another App, this GUI invokes OSG DLLs for doing the rendering in 
that GUI, which has a OSG viewport.

How to use gDEBugger for making performance analysis on such type of set up 
(that includes various DLLs & osg DLLs)?
As fas as I know gDEBugger takes an exe & does the job. In my case, if I 
provide my EXE as input to gDEBugger, only it shows the CPU usage.

Thank you!

Cheers,
Umesh

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





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


Re: [osg-users] Promoting Drawable from being subclassed from osg::Object to osg::Node

2014-05-14 Thread Robert Osfield
Hi Farshid,

On 13 May 2014 22:55, Farshid Lashkari  wrote:
> Regarding the change to Node::ParentList, I think this will cause some
> breakage. I know I have a lot of code that assumes the elements of
> ParentList are group nodes and performs Group operations on them (addChild,
> removeChild, etc..).

To help with this issue I've put virtual addChild/removeChild methods
into osg::Node that are implemented as non ops, but implemented by
osg::Group.  I haven't put all the child access methods, just what I
needed to get the OSG building cleanly with minimal changes, I am open
to adding more as they are required.

The other thing you can do is add a asGroup() to access to do a cheap
case to Group.  This addition would be compatible with older versions
of the OSG as well.

> Perhaps Geode could be modified to inherit from Group
> instead? The add/remove drawable methods could simply be wrappers for
> add/remove child. Just throwing the idea out there, I'm sure this would
> cause a whole host of other problems though. In general, I think breaking
> code is going to be unavoidable.

I have considered this, but Geode is built around Drawable so am
incline to just leave it as it is.  Geode itself actually become less
important thanks to promoting Drawable to Node as you can create
functional scene graphs without any Geodes.  Given this I'm inclined
to not change Geode too much, keep it around for purposes of backwards
compatiblility.


> The bounding sphere/box wrapper class is an interesting solution. I'm
> worried about the potential for segfaults though. It might be better to
> simply rename the method and force people to update their code at compile
> time, rather than dealing with possible segfaults at runtime.

Segfaults would be only a problem in new code that assumed that all
Node had a BoundingBox they could access.  Old code would be fine as
it will only ever be using a BoundingBox in conjunction with a
Drawable.

For new code I'd actually want users to use getBoundingBox() if they
wanted the bounding box.  I see the Bound helper class as a temporary
measure.  I'd rather not have it, but I'm aware that changes like
promoting Drawable to Node has potential for breaking lots of user
code in way that makes it awkward to maintain compatibility with
multiple versions of the OSG i.e. compile against OSG-3.x and OSG-3.4
and later.

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


[osg-users] [build] Error building OSG 3.2.0 (FFMPEG)

2014-05-14 Thread Curvian Vynes
Hi, I'm having problems building OSG 3.2.0 on Linux Mint. 

Error:

Code:
[ 96%] Building CXX object 
src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/FFmpegDecoderAudio.o
/home/curvv/Downloads/OpenSceneGraph-3.2.0/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:
 In function ‘int osgFFmpeg::decode_audio(AVCodecContext*, int16_t*, int*, 
const uint8_t*, int)’:
/home/curvv/Downloads/OpenSceneGraph-3.2.0/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:33:72:
 error: ‘avcodec_decode_audio3’ was not declared in this scope
/home/curvv/Downloads/OpenSceneGraph-3.2.0/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:
 In member function ‘void osgFFmpeg::FFmpegDecoderAudio::open(AVStream*)’:
/home/curvv/Downloads/OpenSceneGraph-3.2.0/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:103:36:
 error: ‘CODEC_ID_NONE’ was not declared in this scope
/home/curvv/Downloads/OpenSceneGraph-3.2.0/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:
 In function ‘int osgFFmpeg::decode_audio(AVCodecContext*, int16_t*, int*, 
const uint8_t*, int)’:
/home/curvv/Downloads/OpenSceneGraph-3.2.0/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp:38:1:
 warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** 
[src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/FFmpegDecoderAudio.o] Error 1
make[1]: *** [src/osgPlugins/ffmpeg/CMakeFiles/osgdb_ffmpeg.dir/all] Error 2
make: *** [all] Error 2



I have libav, which is prob why this happens. But I'm building OSG for use with 
FlightGear which doesn't need OSG's FFMPEG support. So how can I build without 
FFMpeg? I tried with 
-DCMAKE_WITH_FFMPEG=OFF
-DWITH_FFMPEG=OFF

but no joy.

Thanks[/code]

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





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


[osg-users] Quat Rotation using Center of Object as Rerefence

2014-05-14 Thread Tiago Martins
Hi,

I am trying to rotate an object using his center as reference..

This code is rotating the object using some point as reference, but I want to 
rotate using the center point of the object. 

Did you understood?

This is my code:


Code:
osg::PositionAttitudeTransform* heliceTransf = 
static_cast(node);

osg::Quat q = heliceTransf->getAttitude();

q *= osg::Quat(0.0, osg::Y_AXIS, 0.0, osg::X_AXIS, 0.1, osg::Z_AXIS);
heliceTransf->setAttitude(q);



Thank you!

Cheers,
Tiago

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





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