Class CameraComponentExtensions
- Namespace
- Stride.CommunityToolkit.Bullet
- Assembly
- Stride.CommunityToolkit.Bullet.dll
Provides a set of static methods for working with CameraComponent instances.
public static class CameraComponentExtensions
- Inheritance
-
CameraComponentExtensions
Remarks
This class includes extension methods for performing various operations with CameraComponent instances, such as raycasting, converting screen positions to world positions, and more. These methods are useful for implementing features like object picking, camera control, and coordinate transformations in a 3D environment.
Methods
Raycast(CameraComponent, ScriptComponent, Vector2, CollisionFilterGroups, CollisionFilterGroupFlags)
Performs a raycasting operation from the specified CameraComponent's position through the specified screen position in world coordinates, using the Simulation from the specified ScriptComponent, and returns information about the hit result.
public static HitResult Raycast(this CameraComponent camera, ScriptComponent component, Vector2 screenPosition, CollisionFilterGroups collisionGroups = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags collisionFilterGroupFlags = CollisionFilterGroupFlags.DefaultFilter)
Parameters
camera
CameraComponentThe CameraComponent from which the ray should be cast.
component
ScriptComponentThe ScriptComponent that contains the Simulation used for raycasting.
screenPosition
Vector2The screen position in world coordinates through which the ray should be cast.
collisionGroups
CollisionFilterGroupsOptional. The collision filter group to consider during the raycasting. Default is DefaultFilter.
collisionFilterGroupFlags
CollisionFilterGroupFlagsOptional. The collision filter group flags to consider during the raycasting. Default is DefaultFilter.
Returns
- HitResult
A HitResult containing information about the hit result, including the hit location and other collision data.
Raycast(CameraComponent, Simulation, Vector2, CollisionFilterGroups, CollisionFilterGroupFlags)
Performs a raycasting operation from the specified CameraComponent's position through a specified screen position, using the provided Simulation, and returns information about the hit result.
public static HitResult Raycast(this CameraComponent camera, Simulation simulation, Vector2 screenPosition, CollisionFilterGroups collisionGroups = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags collisionFilterGroupFlags = CollisionFilterGroupFlags.DefaultFilter)
Parameters
camera
CameraComponentThe CameraComponent from which the ray should be cast.
simulation
SimulationThe Simulation used to perform the raycasting operation.
screenPosition
Vector2The screen position in normalized screen coordinates (e.g., mouse position) where the ray should be cast.
collisionGroups
CollisionFilterGroupsOptional. The collision filter group to consider during the raycasting. Default is DefaultFilter.
collisionFilterGroupFlags
CollisionFilterGroupFlagsOptional. The collision filter group flags to consider during the raycasting. Default is DefaultFilter.
Returns
- HitResult
A HitResult containing information about the raycasting hit, including the hit location and other collision data.
Remarks
This method is useful for implementing features like object picking, where you want to select or interact with objects in the 3D world based on screen coordinates.
RaycastMouse(CameraComponent, ScriptComponent, CollisionFilterGroups, CollisionFilterGroupFlags)
Performs a raycasting operation from the specified CameraComponent's position through the mouse cursor position in screen coordinates, using input from the specified ScriptComponent, and returns information about the hit result.
public static HitResult RaycastMouse(this CameraComponent camera, ScriptComponent component, CollisionFilterGroups collisionGroups = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags collisionFilterGroupFlags = CollisionFilterGroupFlags.DefaultFilter)
Parameters
camera
CameraComponentThe CameraComponent from which the ray should be cast.
component
ScriptComponentThe ScriptComponent from which the mouse position should be taken.
collisionGroups
CollisionFilterGroupsOptional. The collision filter group to consider during the raycasting. Default is DefaultFilter.
collisionFilterGroupFlags
CollisionFilterGroupFlagsOptional. The collision filter group flags to consider during the raycasting. Default is DefaultFilter.
Returns
- HitResult
A HitResult containing information about the hit result, including the hit location and other collision data.
RaycastMouse(CameraComponent, Simulation, Vector2, CollisionFilterGroups, CollisionFilterGroupFlags)
Performs a raycasting operation from the specified CameraComponent's position through a specified screen position, using the provided Simulation, and returns information about the hit result.
public static HitResult RaycastMouse(this CameraComponent camera, Simulation simulation, Vector2 screenPosition, CollisionFilterGroups collisionGroups = CollisionFilterGroups.DefaultFilter, CollisionFilterGroupFlags collisionFilterGroupFlags = CollisionFilterGroupFlags.DefaultFilter)
Parameters
camera
CameraComponentThe CameraComponent from which the ray should be cast.
simulation
SimulationThe Simulation used to perform the raycasting operation.
screenPosition
Vector2The screen position in screen coordinates (e.g., mouse position) from which the ray should be cast.
collisionGroups
CollisionFilterGroupsOptional. The collision filter group to consider during the raycasting. Default is DefaultFilter.
collisionFilterGroupFlags
CollisionFilterGroupFlagsOptional. The collision filter group flags to consider during the raycasting. Default is DefaultFilter.