Hi Carsten,

the last dayd I worked a little bit more on the problem. Thats my new 
approach but still not working:

I have traversed the puppet object to get one specific node. For this 
node with the help of getVolume and getCenter I get the center point of 
it in world coordinates. Now I can set it as the at coordinates with 
setAt() from the Navigator Class. After compiling the code I get the 
following error:

Unbehandelte Ausnahme(unhandled exception) bei (at) 0x0043a40e in 
01hello.exe: 0xC0000005: Zugriffsverletzung-Leseposition(access 
violation) 0x00000034.

I suppose something went wrong with the NodePtr's but I cannot fix it

-----

#include <iostream>
#include <string>

//------------  OPENSG SPECIFIC INCLUDE FILES:  ------------//
#include <OpenSG/OSGSimpleAttachments.h>
#include <OpenSG/OSGNodePtr.h>
//----------------------------------------------------------//

using namespace std;
OSG_USING_NAMESPACE

/************************************************************
  * FUNCTION: The function traverses the graph and searches  *
  *           for a specific node. The NodePtr which is re-  *
  *           turned will be used in the function getAtCoor- *
  *           dinate.                                        *
  ************************************************************/

  NodePtr getAtNode(NodePtr node_of_interest) {
         UInt32 children = node_of_interest->getNChildren();
        
         // make sure the name we need exists
         if (getName(node_of_interest)) {
                 // check if it is the name we are looking for
                 if(getName(node_of_interest) == string("Brustkorb")) {
                         // We got the node!
                         return node_of_interest;                       
                 }
         }

         // check all children
         for (int i = 0; i < children; i++) {
                 NodePtr r = getAtNode(node_of_interest->getChild(i));
                 if (r != NullFC) {
                         // if it is not NullFC it is the node we are
                             looking for
                         return r;
                 }
         }
         // no children's name matches or there are no more childs
         return NullFC;
  }

-----

#include <iostream>
#include "getAtNode.h"

//------------  OPENSG SPECIFIC INCLUDE FILES:  ------------//
#include <OpenSG/OSGVolume.h>
#include <OpenSG/OSGSphereVolume.h>
#include <OpenSG/OSGSimpleSceneManager.h>
//----------------------------------------------------------//

//using namespace std;
OSG_USING_NAMESPACE

// The SimpleSceneManager is a useful class which helps us to
// manage simple configurations. Here we create an instance of it.
extern SimpleSceneManager *mgr;

/************************************************************
  * FUNCTION: This function computes the Bounding Box for a  *
  *           given node and returns the center of it.       *
  ************************************************************/
  Pnt3f getAtCoordinate(NodePtr at_node) {
        Pnt3f at_pnt;
        at_node = getAtNode(mgr->getRoot());

        at_node->getVolume(true).getCenter(at_pnt);
        return at_pnt;
}

-----
main()-function part:

Navigator *nav = new Navigator;
NodePtr at_node;
Pnt3f at_pnt = getAtCoordinate(at_node);
nav->setAt(at_pnt);
nav->updateCameraTransformation();      
cout << "current Transformation" << nav->getMatrix() << endl;

-----

Sadi Tanis schrieb:
> Carsten Neumann schrieb:
> 
>>      Hello Sadi,
>>
>>Sadi Tanis wrote:
>>
>>
>>>Hi All!
>>>
>>>I am trying to find out how to implement a trackball navigation so that 
>>>the camera turns around a puppet I have loaded via VRML-Loader into the 
>>>scene. For now I tried the set() function which is used in the 
>>>OSG:Navigator class to change the atx,aty,atz values. Afterwards I 
>>>checked the transformation matrix with the getMatrix() function. It 
>>>changed but if I do any mouse action inside the window nothing has 
>>>changed at all. The Camera looks still at the same point: Pnt3f(0,0,0).
>>
>>
>>how does input get from your windowing system to the navigator ?
> 
> 
> At the moment I use the SimpleSceneManager because I am not that 
> experienced to "hard code" most of the stuff needed. So far for my two 
> VRML objects (puppet, gymnastics mat) the standard navigation is set. In 
> case this is bad explained by me I also added the code in addition.
> 
> www.uni-koblenz.de/~saditanis/Archiv.zip
> 
> 
>>
>>>This part I have added for testing into the main function:
>>>     
>>>     >Navigator *nav = new Navigator;
>>>     >nav->set(Pnt3f(0,0,1),Pnt3f(0,0.414,0.910),Vec3f(0,1,0));
>>>     >nav->updateCameraTransformation();     
>>>     >cout << "current Transformation" << nav->getMatrix() << endl;
>>
>>
>>does this have any effect on your view ?
> 
> 
> No :( The view is unfortunately the same.
> 
> 
>>
>>>Is there another way to get the camera turn all around the puppet?
>>
>>
>>The Navigator class is meant to be a unification of the FlyNavigator, 
>>TrackballNavigator (the default) and WalkNavigator. It might not be 
>>trivial to use it in the way you do above, as you might get funny 
>>interaction with the Navigators built in behavior. The easiest way to 
>>implement a new type of navigation would probably be to write a new 
>>class SomeNavigator that does what you want, that way you don't have to 
>>understand the Navigator first. On the other hand you'd duplicate some 
>>of the code.
> 
> 
> Ah ok. I thought that I could just modify the trackball navigation in 
> that way, so the camera turns around my puppet.
> I also have the impression that by any mouse motion the camera  does not 
> move around the scene but the scene around the point of view. I have 
> read something in the mailing list archive about setAbsolute()(turning 
> the parameter off!). But I don't know if this solves the problem.
> 
> 
>>      Hope it helps,
>>              Carsten
>>
> 
> 
> regards,
> Sadi
> 


-- 
Sadi Tanis
University of Koblenz/Landau
Student of Computer Vision
Simmerner Straße 134
56075 Koblenz Germany
Tel. +49.261.208.98.73
E-mail [EMAIL PROTECTED]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to