Announcement

Collapse
No announcement yet.

...a way to have camera following a shape in 3D viewer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ...a way to have camera following a shape in 3D viewer

    Dear Mike,
    Dear Forum Users,

    i have the following scenario, for example, a simple examiner viewer showing this root main separator:

    MainSeparator -> SoTransform (or SoTranslation) .-> a Cube

    then a timer increment the Transform/Translation value so You can see the cube is moving and after a while it disappiars;

    Please, i'd like a little help in order to picking a point on cube (using a SoRayPickAction for example) i succeed to modify camera position in order to follow the cube by that point;

    I hope the described scenario was clear explained.

    Thank You in advance.

    Regards,
    Vincenzo

  • #2
    Vincenzo,

    I believe that the action you want to perform is called a seek action. The goal is, given a point in 3D space obtained for example with a pick action, to animate a camera by moving it to a desired seek point.
    The Open Inventor package provides a convenient class as an example class in source/Inventor/ViewerComponents/nodes. The class is called SeekAnimator. If you use the ViewerComponent API to build your renderArea, you have a SceneExaminer on top of your scene graph. This node has the SeekAnimator integrated to it and you can simply use it by calling the enableSeek function

    I would also take this opportunity to point you to the class SoCameraInteractor. This is a convenient class to perform transformation and animation on a given camera. SeekAnimator actually uses this class to perform this particular operation.

    Comment


    • #3
      Originally posted by [email protected] View Post
      i have the following scenario, for example, a simple examiner viewer showing this root main separator:

      MainSeparator -> SoTransform (or SoTranslation) .-> a Cube

      then a timer increment the Transform/Translation value so You can see the cube is moving and after a while it disappears;

      Please, i'd like a little help in order to picking a point on cube (using a SoRayPickAction for example) i succeed to modify the camera position in order to follow the cube by that point;
      Hi Vincenzo,
      I understand that the shape will change position according to some animation and you want the camera to automatically follow the shape as it moves.
      One difficulty in answering that question is that there are multiple algorithms with various trade-offs. We might have better advice if you can describe the actual use-case (what kind of shape, what kind of scene, what kind of path is the shape following - straight line, curve, etc).

      Generally useful: The class SoCameraInteractor provides methods pointAt() and lookAt(). Both methods rotate the camera to point toward a specified coordinate (e.g. the location of the shape).

      Some basic algorithms:
      1. Rotate the camera
        For some use cases, it may be sufficient to simply update the camera rotation, using pointAt() or lookAt(), when the shape's position changes.
        But that probably won't work if your shape moves outside the scene.
      2. Simple shape following
        When the shape animation starts, use pointAt/lookAt (once) to get the camera pointing at the shape.
        When the shape position changes, apply the same change (delta-xyz) to the camera position.
        This will cause the camera to follow the shape as it moves, although the camera will always be looking at the shape from the same direction (independent of the path the shape is following).
      There are more complex variations of "follow the shape". The simple algorithms may be good enough for some purposes but may seem "awkward" to the user. An example of a more complex algorithm is a game with a third person (over the shoulder) viewing model. In this case, the camera behaves as if it is pulled along by a string attached to the shape. As a result, the camera will generally point at the shape in the direction that the shape is moving (rather than a fixed direction). If the shape changes direction, the camera will also change direction (usually with some animation so the change in camera orientation in each frame is limited).
      Regards,
      Mike

      Comment


      • #4
        Dear Mike,
        thank You very much for Your help and suggestions.

        I'll take a look to the class SoCameraInteractor and i'll try to follow Your suggested way.

        Have a nice weekend.
        Regards,
        Vincenzo

        Comment

        Working...
        X