Re: [osg-users] Add a new child

2010-09-30 Thread Cosimo Luigi Manes
I solved the problem with the following code:


Code:
osg::Vec3 achse(0.0, 0.0, 0.0);
osg::Matrixd myRotationMatrix;
//myRotationMatrix.makeRotate(osg::DegreesToRadians(2.0f), 
achse);
myRotationMatrix.makeTranslate(0.0,20.0,0.0);

viewer.getCameraManipulator()-setByMatrix(viewer.getCameraManipulator()-getMatrix()
 * myRotationMatrix); 



thanks anyway

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





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


Re: [osg-users] Add a new child

2010-09-29 Thread Cosimo Luigi Manes

Ulrich Hertlein wrote:
 On 28/09/10 18:45 , Cosimo Luigi Manes wrote:
 osgGA::CameraManipulator (the base class for the default manipulators) has a 
 'home()'
 method than will recompute the position if 'setAutoComputeHomePosition' is 
 true.
 


Thanks you for your answer. Could you post an example of code because i am a 
newbie. Also, if i want to run a rotation or translation or zoom, what should i 
do ?

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





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


Re: [osg-users] Add a new child

2010-09-29 Thread Ulrich Hertlein
On 29/09/10 19:27 , Cosimo Luigi Manes wrote:
 Ulrich Hertlein wrote:
 On 28/09/10 18:45 , Cosimo Luigi Manes wrote: osgGA::CameraManipulator (the 
 base
 class for the default manipulators) has a 'home()' method than will 
 recompute the
 position if 'setAutoComputeHomePosition' is true.
 
 Thanks you for your answer. Could you post an example of code because i am a 
 newbie.

viewer.getCameraManipulator()-home();

 Also, if i want to run a rotation or translation or zoom, what should i do ?

I'd recommend you read the OSG QuickStartGuide, it covers this and many other 
aspects of OSG.

Basically what you need to do it modify the camera matrix to obtain 
rotation/translation
and modify the field-of-view to zoom.

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


Re: [osg-users] Add a new child

2010-09-29 Thread Cosimo Luigi Manes

Ulrich Hertlein wrote:
 
 I'd recommend you read the OSG QuickStartGuide, it covers this and many other 
 aspects of OSG.
 
 Basically what you need to do it modify the camera matrix to obtain 
 rotation/translation
 and modify the field-of-view to zoom.
 
 


thanks for the reply. I have already read QuickStartGuide OSG, but it isn't 
thorough. Can you post an example of code to execute for the operation of zoom, 
rotate and translation ? Where i can find other examples ?

thanks again

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





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


Re: [osg-users] Add a new child

2010-09-28 Thread Robert Osfield
On Mon, Sep 27, 2010 at 9:36 PM, Cosimo Luigi Manes man...@cheapnet.it wrote:
 the problem is that i load new nodes when the sg running

Could it be that your camera isn't being updated to look at your new models?

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


Re: [osg-users] Add a new child

2010-09-28 Thread Ulrich Hertlein
On 28/09/10 17:19 , Robert Osfield wrote:
 On Mon, Sep 27, 2010 at 9:36 PM, Cosimo Luigi Manes man...@cheapnet.it 
 wrote:
 the problem is that i load new nodes when the sg running
 
 Could it be that your camera isn't being updated to look at your new models?

I believe what Robert is referring to is this: that the camera will initially 
compute a
position that shows the entire scene graph *at that time* (based on the current 
scene
bounding sphere).  This position won't be updated afterwards so if you add 
nodes they
might not be in view.

What happens when you press 'space' to reset the camera position?

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


Re: [osg-users] Add a new child

2010-09-28 Thread Cosimo Luigi Manes

Ulrich Hertlein wrote:
 On 28/09/10 17:19 , Robert Osfield wrote:
 
 What happens when you press 'space' to reset the camera position?
 
 


Well, when i press 'space', software shows the nodes. How can i reset the 
camera position ?

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





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


Re: [osg-users] Add a new child

2010-09-28 Thread Ulrich Hertlein
On 28/09/10 18:45 , Cosimo Luigi Manes wrote:
 Ulrich Hertlein wrote:
 On 28/09/10 17:19 , Robert Osfield wrote:

 What happens when you press 'space' to reset the camera position?
 
 Well, when i press 'space', software shows the nodes. How can i reset the 
 camera position ?

osgGA::CameraManipulator (the base class for the default manipulators) has a 
'home()'
method than will recompute the position if 'setAutoComputeHomePosition' is true.

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


[osg-users] Add a new child

2010-09-27 Thread Cosimo Luigi Manes
Hi,

i created a menu where i can select a model. When i select a button a fuction 
loads the nodes with the following code:

Code:

 listaComponenti.push_back(osgDB::readNodeFile(aorta.ive));
listaComponenti.push_back(osgDB::readNodeFile(cuore.ive));

unsigned int ii;
for(ii=0; ii  listaComponenti.size(); ii++)
switchA-addChild((listaComponenti[ii]), true);

root-addChild(switchA.get());



In the main fuction i have this code:

Code:

if(!wm) return 1;

osg::Group*  group  = new osg::Group();
osg::Camera* camera = wm-createParentOrthoCamera();

group-addChild(camera);

if(root) group-addChild(root);

viewer.addEventHandler(new osgWidget::MouseHandler(wm));
viewer.addEventHandler(new osgWidget::KeyboardHandler(wm));
viewer.addEventHandler(new osgWidget::ResizeHandler(wm, camera));
viewer.addEventHandler(new osgWidget::CameraSwitchHandler(wm, camera));
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new 
osgGA::StateSetManipulator(viewer.getCamera()-getOrCreateStateSet()));

wm-resizeAllWindows();

viewer.setSceneData(group);

/*/


//viewer.getCamera()-setClearColor(osg::Vec4(0.,0.,0.,1));

return viewer.run();




The problem is that the software doesn't show the node in execution but if i 
load the model before, without the button callback, the software shows the node.

Why?




Thank you!

Cheers,
Cosimo[/code]

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





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


Re: [osg-users] Add a new child

2010-09-27 Thread Cosimo Luigi Manes
the problem is that i load new nodes when the sg running

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





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