Thank you all so much for your help on this. Generally speaking, what is 
the proper approach if I want to set the initial view to a specific look-at 
but after that I want the default manipulator to behave as normal?

On Tuesday, April 21, 2020 at 1:43:45 AM UTC-5, Erik Hensens wrote:
>
> Hello everyone,
>
> I am trying to change the camera's perspective by calling 
> setViewMatrixAsLookAt, but it is not making any change in the orientation 
> of my scene. Here is the full code for the simplest application that 
> reproduces my problem. There must be something I'm fundamentally 
> misunderstanding here. I appreciate any and all help! Thanks in advance!
>
> #include <osg/Geode>
> #include <osg/ShapeDrawable>
> #include <osgViewer/Viewer>
>
>
> // Get a new sphere geode
> osg::ref_ptr<osg::Geode> CreateSphereGeode(
>  osg::Vec3 tCenter, // The location of the center of the sphere
>  osg::Vec4 tColor, // The color of the sphere
>  float fRadius // The sphere radius
>  )
> {
>  // Create the geode to return
>  osg::ref_ptr<osg::Geode> pRetv = new osg::Geode;
>
>
>  // Create the sphere
>  osg::ref_ptr<osg::Sphere> pSphere = new osg::Sphere(tCenter, fRadius);
>
>
>  // Create the drawable
>  osg::ref_ptr<osg::ShapeDrawable> pSphereDrawable = new osg::ShapeDrawable
> (pSphere);
>
>
>  // Set the color
>  pSphereDrawable->setColor(tColor);
>
>
>  // Add the drawable
>  pRetv->addDrawable(pSphereDrawable);
>
>
>  // Return this geode
>  return pRetv;
> }
>
>
> // The main application entry point
> int main(int argc, char *argv[])
> {
>  // Create the viewer
>  osg::ref_ptr<osgViewer::Viewer> pViewer = new osgViewer::Viewer;
>  
>  // Create the top group parent
>  osg::ref_ptr<osg::Group> pTopGroup = new osg::Group;
>
>
>  // Create some spheres
>  osg::ref_ptr<osg::Geode> pSphere1 = CreateSphereGeode(osg::Vec3(0.0f, 
> 0.0f, 0.0f), osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f), 2.0f);
>  osg::ref_ptr<osg::Geode> pSphere2 = CreateSphereGeode(osg::Vec3(10.0f, 
> 0.0f, 5.0f), osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f), 1.0f);
>  osg::ref_ptr<osg::Geode> pSphere3 = CreateSphereGeode(osg::Vec3(-15.0f, 
> 6.0f, 0.0f), osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f), 4.0f);
>
>
>  // Add these spheres to the top group node
>  pTopGroup->addChild(pSphere1);
>  pTopGroup->addChild(pSphere2);
>  pTopGroup->addChild(pSphere3);
>
>
>  // Here I am attempting to change the initial perspective, but I can 
> make these numbers anything and it doesn't seem to change anything
>  pViewer->getCamera()->setViewMatrixAsLookAt(
>  osg::Vec3(-0.9983f, 0.0252f, -0.0530f),
>  osg::Vec3(0.8639f, -2.5189f, -70.0939f),
>  osg::Vec3(0.8880f, -1.5194f, -70.0726f)
>  );
>  
>  // Add a viewport to the viewer and attach the scene graph
>  pViewer->setSceneData(pTopGroup);
>
>
>  // Run the viewer
>  return pViewer->run();
> }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osg-users/5a697087-a62b-4a5a-b8ab-15ab1c25cfdc%40googlegroups.com.

Reply via email to