Back

InteractiveCamera

The `InteractiveCamera` is a camera class in the SOFA framework that allows for interactive control using mouse and keyboard inputs.

abstract
The `InteractiveCamera` component in SOFA provides interactive control over the camera using mouse and keyboard inputs for visualization purposes.
sheet
# InteractiveCamera ## Overview The `InteractiveCamera` is a visualization component that allows users to interactively control the camera within the simulation scene. It inherits from `BaseCamera` and handles events such as mouse movements, key presses, and releases to enable panning, zooming, and rotating. ## Parameters and Data - **zoomSpeed**: Controls the speed at which the camera zooms in or out (`double`, default not specified). - **panSpeed**: Determines the speed of camera panning (`double`, default not specified). - **pivot**: Specifies the pivot point for camera movements (0: Camera lookAt, 1: Camera position, 2: Scene center, 3: World center; `int`, default not specified). ## Practical Notes The `InteractiveCamera` relies on mouse and keyboard events to update its state. Ensure that event handling is properly configured in the simulation scene for smooth interaction.
description
The `InteractiveCamera` is a camera class in the SOFA framework that allows for interactive control using mouse and keyboard inputs.
properties
{
  "panSpeed": {
    "default": 0.1,
    "description": "Determines the speed at which the camera pans horizontally and vertically with right-click dragging.",
    "type": "double"
  },
  "pivot": {
    "default": 2,
    "description": "Specifies the pivot point for camera rotations. Possible values are: \n- **0 (CAMERA_LOOKAT_PIVOT)** - rotates around the look-at point.\n- **1 (CAMERA_POSITION_PIVOT)** - rotates around the camera position.\n- **2 (SCENE_CENTER_PIVOT)** - rotates around the center of the scene (default).\n- **3 (WORLD_CENTER_PIVOT)** - rotates around the world origin.",
    "type": "int"
  },
  "zoomSpeed": {
    "default": 250.0,
    "description": "Controls how fast the camera zooms when the mouse wheel or middle click is used.",
    "type": "double"
  }
}
methods
{
  "manageEvent": {
    "description": "Handles various events such as mouse and keyboard inputs to control the camera.",
    "parameters": [
      {
        "name": "e",
        "type": "core::objectmodel::Event*"
      }
    ]
  },
  "moveCamera": {
    "description": "Adjusts camera position based on mouse movements.",
    "parameters": [
      {
        "name": "x",
        "type": "int"
      },
      {
        "name": "y",
        "type": "int"
      }
    ]
  },
  "processKeyPressedEvent": {
    "description": "Handles keypress events. Currently, it has minimal implementation (e.g., for the \u0027a\u0027 key).",
    "parameters": [
      {
        "name": "kpe",
        "type": "core::objectmodel::KeypressedEvent*"
      }
    ]
  },
  "processKeyReleasedEvent": {
    "description": "Handles key release events. Currently, it does not perform any action.",
    "parameters": [
      {
        "name": "kre",
        "type": "core::objectmodel::KeyreleasedEvent*"
      }
    ]
  },
  "processMouseEvent": {
    "description": "Processes mouse events (clicks, movements) for controlling camera zoom, pan, and rotation.",
    "parameters": [
      {
        "name": "me",
        "type": "core::objectmodel::MouseEvent*"
      }
    ]
  }
}
interactions
{
  "mouse_left_click_drag": {
    "action": "Rotates the camera around its pivot point."
  },
  "mouse_middle_click_drag": {
    "action": "Zooms in or out of the scene."
  },
  "mouse_right_click_drag": {
    "action": "Pans the camera horizontally and vertically."
  },
  "mouse_wheel_scroll": {
    "action": "Zooms in or out based on wheel direction."
  }
}
activation
{
  "activated": {
    "default": true,
    "description": "Determines whether the camera is enabled to respond to user inputs. When deactivated, no interactions are processed.",
    "type": "bool"
  }
}
maths
The `InteractiveCamera` is a visualization component in the SOFA framework that provides interactive control over the camera using mouse and keyboard inputs. It does not directly contribute to the mathematical or physical models used in FEM simulations, such as mass matrices, stiffness matrices, internal forces, residuals, or constitutive laws. Instead, it focuses on user interaction with the simulation scene for visualization purposes. ### Mathematical and Physical Content - **Governing Equations/Operators**: None. - **Constitutive/Kinematic Laws**: None. - **Role in FEM Pipeline**: This component does not play a role in the FEM pipeline as it is purely concerned with user interface interactions for visualization. - **Numerical Methods/Discretization Choices**: The `InteractiveCamera` employs mouse and keyboard event handling to enable interactive camera controls, such as panning, zooming, and rotating. It uses trackball-based rotation for smooth camera movement and updates the camera position and orientation accordingly. - **Variational/Lagrangian Mechanics Framework**: This component is not directly related to variational or Lagrangian mechanics frameworks. Its purpose is purely to provide an intuitive user interface for navigating the simulation scene.
{
  "name": "InteractiveCamera",
  "main": {
    "name": "InteractiveCamera",
    "namespace": "sofa::component::visual",
    "module": "Sofa.Component.Visual",
    "include": "sofa/component/visual/InteractiveCamera.h",
    "doc": "Camera with mouse and keyboard controls.",
    "inherits": [
      "BaseCamera"
    ],
    "templates": [],
    "data_fields": [
      {
        "name": "d_zoomSpeed",
        "type": "double",
        "xmlname": "zoomSpeed",
        "help": "Zoom Speed"
      },
      {
        "name": "d_panSpeed",
        "type": "double",
        "xmlname": "panSpeed",
        "help": "Pan Speed"
      },
      {
        "name": "d_pivot",
        "type": "int",
        "xmlname": "pivot",
        "help": "Pivot (0 => Camera lookAt, 1 => Camera position, 2 => Scene center, 3 => World center"
      }
    ],
    "links": [],
    "methods": [
      {
        "name": "moveCamera",
        "return_type": "void",
        "params": [
          {
            "name": "x",
            "type": "int"
          },
          {
            "name": "y",
            "type": "int"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "manageEvent",
        "return_type": "void",
        "params": [
          {
            "name": "e",
            "type": "core::objectmodel::Event *"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "processMouseEvent",
        "return_type": "void",
        "params": [
          {
            "name": "me",
            "type": "core::objectmodel::MouseEvent *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "processKeyPressedEvent",
        "return_type": "void",
        "params": [
          {
            "name": "kpe",
            "type": "core::objectmodel::KeypressedEvent *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "processKeyReleasedEvent",
        "return_type": "void",
        "params": [
          {
            "name": "kre",
            "type": "core::objectmodel::KeyreleasedEvent *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      }
    ]
  },
  "desc": {
    "description": "The `InteractiveCamera` is a camera class in the SOFA framework that allows for interactive control using mouse and keyboard inputs.",
    "properties": {
      "zoomSpeed": {
        "type": "double",
        "default": 250.0,
        "description": "Controls how fast the camera zooms when the mouse wheel or middle click is used."
      },
      "panSpeed": {
        "type": "double",
        "default": 0.1,
        "description": "Determines the speed at which the camera pans horizontally and vertically with right-click dragging."
      },
      "pivot": {
        "type": "int",
        "default": 2,
        "description": "Specifies the pivot point for camera rotations. Possible values are: \n- **0 (CAMERA_LOOKAT_PIVOT)** - rotates around the look-at point.\n- **1 (CAMERA_POSITION_PIVOT)** - rotates around the camera position.\n- **2 (SCENE_CENTER_PIVOT)** - rotates around the center of the scene (default).\n- **3 (WORLD_CENTER_PIVOT)** - rotates around the world origin."
      }
    },
    "methods": {
      "moveCamera": {
        "description": "Adjusts camera position based on mouse movements.",
        "parameters": [
          {
            "name": "x",
            "type": "int"
          },
          {
            "name": "y",
            "type": "int"
          }
        ]
      },
      "manageEvent": {
        "description": "Handles various events such as mouse and keyboard inputs to control the camera.",
        "parameters": [
          {
            "name": "e",
            "type": "core::objectmodel::Event*"
          }
        ]
      },
      "processMouseEvent": {
        "description": "Processes mouse events (clicks, movements) for controlling camera zoom, pan, and rotation.",
        "parameters": [
          {
            "name": "me",
            "type": "core::objectmodel::MouseEvent*"
          }
        ]
      },
      "processKeyPressedEvent": {
        "description": "Handles keypress events. Currently, it has minimal implementation (e.g., for the 'a' key).",
        "parameters": [
          {
            "name": "kpe",
            "type": "core::objectmodel::KeypressedEvent*"
          }
        ]
      },
      "processKeyReleasedEvent": {
        "description": "Handles key release events. Currently, it does not perform any action.",
        "parameters": [
          {
            "name": "kre",
            "type": "core::objectmodel::KeyreleasedEvent*"
          }
        ]
      }
    },
    "interactions": {
      "mouse_left_click_drag": {
        "action": "Rotates the camera around its pivot point."
      },
      "mouse_right_click_drag": {
        "action": "Pans the camera horizontally and vertically."
      },
      "mouse_middle_click_drag": {
        "action": "Zooms in or out of the scene."
      },
      "mouse_wheel_scroll": {
        "action": "Zooms in or out based on wheel direction."
      }
    },
    "activation": {
      "activated": {
        "type": "bool",
        "default": true,
        "description": "Determines whether the camera is enabled to respond to user inputs. When deactivated, no interactions are processed."
      }
    }
  },
  "maths": {
    "maths": "The `InteractiveCamera` is a visualization component in the SOFA framework that provides interactive control over the camera using mouse and keyboard inputs. It does not directly contribute to the mathematical or physical models used in FEM simulations, such as mass matrices, stiffness matrices, internal forces, residuals, or constitutive laws. Instead, it focuses on user interaction with the simulation scene for visualization purposes.\n\n### Mathematical and Physical Content\n- **Governing Equations/Operators**: None.\n- **Constitutive/Kinematic Laws**: None.\n- **Role in FEM Pipeline**: This component does not play a role in the FEM pipeline as it is purely concerned with user interface interactions for visualization.\n- **Numerical Methods/Discretization Choices**: The `InteractiveCamera` employs mouse and keyboard event handling to enable interactive camera controls, such as panning, zooming, and rotating. It uses trackball-based rotation for smooth camera movement and updates the camera position and orientation accordingly.\n- **Variational/Lagrangian Mechanics Framework**: This component is not directly related to variational or Lagrangian mechanics frameworks. Its purpose is purely to provide an intuitive user interface for navigating the simulation scene."
  },
  "summary": {
    "abstract": "The `InteractiveCamera` component in SOFA provides interactive control over the camera using mouse and keyboard inputs for visualization purposes.",
    "sheet": "# InteractiveCamera\n\n## Overview\nThe `InteractiveCamera` is a visualization component that allows users to interactively control the camera within the simulation scene. It inherits from `BaseCamera` and handles events such as mouse movements, key presses, and releases to enable panning, zooming, and rotating.\n\n## Parameters and Data\n- **zoomSpeed**: Controls the speed at which the camera zooms in or out (`double`, default not specified).\n- **panSpeed**: Determines the speed of camera panning (`double`, default not specified).\n- **pivot**: Specifies the pivot point for camera movements (0: Camera lookAt, 1: Camera position, 2: Scene center, 3: World center; `int`, default not specified).\n\n## Practical Notes\nThe `InteractiveCamera` relies on mouse and keyboard events to update its state. Ensure that event handling is properly configured in the simulation scene for smooth interaction."
  }
}