Marscr
05-12-2010, 02:01 PM
Hi!
There are 2 Problems on which I hope that someone can help me here:
First Problem:
I want to create some kind of a mini coordinate system for my scene which is always displayed at the same position (in example left bottom corner) of my scene and shows from which direction the camera is looking on the rest of the scene.
By now I created the coordinate system which is all contained by the separator "coordSysSep" and it looks like on the image in the attatchment.
My problem is that I dont know how I can always keep this "mini coordinate System" at the same position(bottom left corner) of my viewer. By now I first translated the whole content of to the camera position. And then I additionally want to translate it to place it in the bottom left corner. But How can I do this? This translation always depends on the current camera position, so I cant translate with the same value all the time.
The relevant code is this:
//combine axes to coordinate system
SoSeparator* coordSysSep = new SoSeparator;
coordSysSep->addChild(xAxesSep);
coordSysSep->addChild(yAxesSep);
coordSysSep->addChild(zAxesSep);
//translate coordinate system to same position as camera at first
SoTranslation* camPosTranslation = new SoTranslation;
camPosTranslation->translation.connectFrom(&camera_->position);
//Then translate it to the desired position relative to the cam (bottom left corner in example)
//How do I do this??? Current attempt only places it to the same relative position. But if camera looks
//in another direction the coordinate system disappears out of the displayed viewingregion
SoTranslation* sideTranslation = new SoTranslation;
sideTranslation->translation.setValue(-1000,-1000,-2000);
//does not really change anything
SoRotation* sideRotation = new SoRotation;
sideRotation->rotation.setValue(camera_->orientation.getValue());
root_->addChild(sideRotation); //this did not help as well
root_->addChild(sideTranslation);
root_->addChild(camPosTranslation);
root_->addChild(coordSysSep);
So how can I position my coordinate system at the right relative position? And/or is there a better way to
do it? Maybe some Inventor class that already does what I want?
Second Problem:
I changed the camera of my scene to SoOrthographicCamera(from SoPerspectiveCamera). Since I did this parts of my scene disappear when I zoom too close or to far away (See image).
I already experianced this problem in other situations with this camera view, however I dont entirely understand why it occurs and whether there is a way to do anything about it. Moreover the my mini coordinate system seems to get smaller and bigger when I zoom, although keep it in a constant distance from the camera (like in the code above with the sideTranslation). With the perspective camera the coordinate system appeard(as expected) in the same size irrespective of the zoom level.
So I hoped that someone can help me understand this occurances here and give me an idea how they can be prevented.
Thanks & Regards
There are 2 Problems on which I hope that someone can help me here:
First Problem:
I want to create some kind of a mini coordinate system for my scene which is always displayed at the same position (in example left bottom corner) of my scene and shows from which direction the camera is looking on the rest of the scene.
By now I created the coordinate system which is all contained by the separator "coordSysSep" and it looks like on the image in the attatchment.
My problem is that I dont know how I can always keep this "mini coordinate System" at the same position(bottom left corner) of my viewer. By now I first translated the whole content of to the camera position. And then I additionally want to translate it to place it in the bottom left corner. But How can I do this? This translation always depends on the current camera position, so I cant translate with the same value all the time.
The relevant code is this:
//combine axes to coordinate system
SoSeparator* coordSysSep = new SoSeparator;
coordSysSep->addChild(xAxesSep);
coordSysSep->addChild(yAxesSep);
coordSysSep->addChild(zAxesSep);
//translate coordinate system to same position as camera at first
SoTranslation* camPosTranslation = new SoTranslation;
camPosTranslation->translation.connectFrom(&camera_->position);
//Then translate it to the desired position relative to the cam (bottom left corner in example)
//How do I do this??? Current attempt only places it to the same relative position. But if camera looks
//in another direction the coordinate system disappears out of the displayed viewingregion
SoTranslation* sideTranslation = new SoTranslation;
sideTranslation->translation.setValue(-1000,-1000,-2000);
//does not really change anything
SoRotation* sideRotation = new SoRotation;
sideRotation->rotation.setValue(camera_->orientation.getValue());
root_->addChild(sideRotation); //this did not help as well
root_->addChild(sideTranslation);
root_->addChild(camPosTranslation);
root_->addChild(coordSysSep);
So how can I position my coordinate system at the right relative position? And/or is there a better way to
do it? Maybe some Inventor class that already does what I want?
Second Problem:
I changed the camera of my scene to SoOrthographicCamera(from SoPerspectiveCamera). Since I did this parts of my scene disappear when I zoom too close or to far away (See image).
I already experianced this problem in other situations with this camera view, however I dont entirely understand why it occurs and whether there is a way to do anything about it. Moreover the my mini coordinate system seems to get smaller and bigger when I zoom, although keep it in a constant distance from the camera (like in the code above with the sideTranslation). With the perspective camera the coordinate system appeard(as expected) in the same size irrespective of the zoom level.
So I hoped that someone can help me understand this occurances here and give me an idea how they can be prevented.
Thanks & Regards