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. |
PerformCast(Camera, Viewport, PhysicHandler, int, int)
Performs a raycast and returns the hit result based on the mouse cursor position.
Declaration
public static HitResult PerformCast(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. |
PerformCast(PhysicHandler, int, int)
Performs a raycast and returns the hit result based on the mouse cursor position.
Declaration
public HitResult PerformCast(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. |