Class Raycast
Represents a class for performing raycasting in 3D space.
Inherited Members
Namespace: Genesis.Physics
Assembly: Genesis.dll
Syntax
public class Raycast
Constructors
Raycast(Camera, Viewport)
Initializes a new instance of the Raycast class.
Declaration
public Raycast(Camera camera, Viewport viewport)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera used for raycasting. |
Viewport | viewport | The viewport associated with the raycasting. |
Properties
Camera
Gets or sets the camera used for raycasting.
Declaration
public Camera Camera { get; set; }
Property Value
Type | Description |
---|---|
Camera |
Viewport
Gets or sets the viewport associated with the raycasting.
Declaration
public Viewport Viewport { get; set; }
Property Value
Type | Description |
---|---|
Viewport |
Methods
GetEndVec(Camera, Viewport, int, int)
Gets the end vector for raycasting based on the mouse cursor position.
Declaration
public static vec4 GetEndVec(Camera camera, Viewport vp, int posX, int posY)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera used for raycasting. |
Viewport | vp | The viewport associated with the raycasting. |
int | posX | X-coordinate of the mouse cursor. |
int | posY | Y-coordinate of the mouse cursor. |
Returns
Type | Description |
---|---|
vec4 | The end vector for raycasting. |
GetMouseWorldPosition(Camera, Viewport, int, int)
Gets the world position of the mouse cursor based on a given camera and viewport.
Declaration
public static Vec3 GetMouseWorldPosition(Camera camera, Viewport viewport, int mouseX, int mouseY)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera used for raycasting. |
Viewport | viewport | The viewport associated with the raycasting. |
int | mouseX | X-coordinate of the mouse cursor. |
int | mouseY | Y-coordinate of the mouse cursor. |
Returns
Type | Description |
---|---|
Vec3 | World position of the mouse cursor. |
GetMouseWorldPosition(int, int)
Gets the world position of the mouse cursor.
Declaration
public Vec3 GetMouseWorldPosition(int mouseX, int mouseY)
Parameters
Type | Name | Description |
---|---|---|
int | mouseX | X-coordinate of the mouse cursor. |
int | mouseY | Y-coordinate of the mouse cursor. |
Returns
Type | Description |
---|---|
Vec3 | World position of the mouse cursor. |
GetRayDir(vec4, vec4)
Gets the direction vector for a ray based on start and end vectors.
Declaration
public static vec3 GetRayDir(vec4 start, vec4 end)
Parameters
Type | Name | Description |
---|---|---|
vec4 | start | The start vector of the ray. |
vec4 | end | The end vector of the ray. |
Returns
Type | Description |
---|---|
vec3 | The direction vector of the ray. |
GetStartVec(Camera, Viewport, int, int)
Gets the start vector for raycasting based on the mouse cursor position.
Declaration
public static vec4 GetStartVec(Camera camera, Viewport vp, int posX, int posY)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera used for raycasting. |
Viewport | vp | The viewport associated with the raycasting. |
int | posX | X-coordinate of the mouse cursor. |
int | posY | Y-coordinate of the mouse cursor. |
Returns
Type | Description |
---|---|
vec4 | The start vector for raycasting. |
GetViewProjectionMatrix(Camera)
Gets the view and projection matrices for raycasting based on a given camera.
Declaration
public static MatrixSet GetViewProjectionMatrix(Camera camera)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera for which matrices are calculated. |
Returns
Type | Description |
---|---|
MatrixSet | MatrixSet containing the view and projection matrices. |
PerformRaycast(Vec3, Vec3, PhysicHandler)
Performs a raycast between two 3D points to detect collisions within the physics world.
Declaration
public static HitResult PerformRaycast(Vec3 start, Vec3 end, PhysicHandler physicHandler)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | start | The starting point of the ray in world space. |
Vec3 | end | The ending point of the ray in world space. |
PhysicHandler | physicHandler | The PhysicHandler responsible for physics simulation and raycasting. |
Returns
Type | Description |
---|---|
HitResult | A HitResult object containing information about whether a hit occurred, the collided game element, and the collision details (e.g., location of the hit and collision object). |
Remarks
The method casts a ray from the start
position to the end
position.
If the ray intersects any object within the physics world, the HitResult will contain details
about the hit, including the element hit and the collision object.
PerformRaycastFromScreen(Camera, Viewport, PhysicHandler, int, int)
Performs a raycast and returns the hit result based on the mouse cursor position.
Declaration
public static HitResult PerformRaycastFromScreen(Camera camera, Viewport viewport, PhysicHandler physicHandler, int posX, int posY)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera used for raycasting. |
Viewport | viewport | The viewport associated with the raycasting. |
PhysicHandler | physicHandler | The physics handler used for raycasting. |
int | posX | X-coordinate of the mouse cursor. |
int | posY | Y-coordinate of the mouse cursor. |
Returns
Type | Description |
---|---|
HitResult | HitResult containing information about the raycasting hit. |
PerformRaycastFromScreen(PhysicHandler, int, int)
Performs a raycast and returns the hit result based on the mouse cursor position.
Declaration
public HitResult PerformRaycastFromScreen(PhysicHandler physicHandler, int posX, int posY)
Parameters
Type | Name | Description |
---|---|---|
PhysicHandler | physicHandler | The physics handler used for raycasting. |
int | posX | X-coordinate of the mouse cursor. |
int | posY | Y-coordinate of the mouse cursor. |
Returns
Type | Description |
---|---|
HitResult | HitResult containing information about the raycasting hit. |
PerformRaycastFromScreenAll(Camera, Viewport, PhysicHandler, int, int)
Declaration
public static List<HitResult> PerformRaycastFromScreenAll(Camera camera, Viewport viewport, PhysicHandler physicHandler, int posX, int posY)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | |
Viewport | viewport | |
PhysicHandler | physicHandler | |
int | posX | |
int | posY |
Returns
Type | Description |
---|---|
List<HitResult> |
PerformRaycastFromScreenFiltered(Camera, Viewport, PhysicHandler, int, int, int, int)
Declaration
public static HitResult PerformRaycastFromScreenFiltered(Camera camera, Viewport viewport, PhysicHandler physicHandler, int posX, int posY, int collisionGroup = -1, int collisionMask = -1)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | |
Viewport | viewport | |
PhysicHandler | physicHandler | |
int | posX | |
int | posY | |
int | collisionGroup | |
int | collisionMask |
Returns
Type | Description |
---|---|
HitResult |