GFX
  • Docs
  • API
Search Results for

    Show / Hide Table of Contents
    • Genesis.Core
      • AssetManager
      • Game
      • GameElement
      • GameEventHandler
      • GenesisWindow
      • IGameBehavior
      • Input
      • Layer
      • Light
      • Scene
      • Scene3D
      • SceneEventHandler
      • SceneSizeEvenHandler
      • Storage
      • Utils
    • Genesis.Core.Behaviors
      • AnimationBehavior
      • CameraFlags
      • CharacterController2D
      • ControllerPreset
      • MoveDirection
      • MovementFlags
      • SpriteMovementController
    • Genesis.Core.Behaviors.Physics2D
      • BufferedSpriteCollider
      • PhysicsBox2D
      • PhysicsPolygon2D
      • Rigidbody2D
    • Genesis.Core.Behaviors.Physics3D
      • BoxCollider
      • CapsuleCollider
      • ConvexHullBehavior
      • QubeConvexHull
      • SphereCollider
      • StaticMeshBehavior
    • Genesis.Core.Behaviors._3D
      • Stance
      • ThirdpersonCharacterController
    • Genesis.Core.GameElements
      • BufferedSprite
      • CameraElement
      • Element3D
      • Empty
      • Model
      • ParticleBuffers
      • ParticleDeffinition
      • ParticleEmitter
      • Qube
      • RectElement
      • Skybox
      • Sprite
      • SpriteShapeDeffinition
      • Terrain2D
      • Terrain3D
      • TerrainData
    • Genesis.Graphics
      • Animation
      • Camera
      • CameraType
      • Face
      • Font
      • Framebuffer
      • Glyphe
      • IRenderDevice
      • Material
      • MaterialBuffer
      • Mesh
      • PerspectiveCamera
      • Shader
      • ShaderProgram
      • TexCoords
      • Texture
      • Viewport
    • Genesis.Graphics.Animation3D
      • Animation
      • Animator
      • AssimpNodeData
      • Bone
      • KeyPosition
      • KeyRotation
      • KeyScale
      • ModelMesh
      • boneinfo
      • vertex
    • Genesis.Graphics.Physics
      • BulletDebugRenderer
    • Genesis.Graphics.RenderDevice
      • ClassicGL
      • GLRenderer
    • Genesis.Graphics.Shaders.OpenGL
      • AnimatedModelShader
      • BasicShader
      • DiffuseLightning
      • DiffuseNormalLightning
      • DiffuseNormalShader
      • DiffuseShader
      • DiffuseSolidShader
      • MVPRectShader
      • MVPShader
      • MVPSolidShader
      • ParticleShader
      • ScreenShader
      • SkyboxShader
      • SpriteShader
      • TerrainShader
      • WireframeShader
    • Genesis.Graphics.Shapes
      • BufferedSpriteShape
      • FrameShape
      • GlypheShape
      • LineShape
      • PlaneShape
      • QubeShape
      • RectShape
      • Shape
      • SpriteShape
    • Genesis.Math
      • Matrix4x4
      • NoisePoint
      • PerlinNoise
      • Rect
      • Vec3
    • Genesis.Physics
      • Aabb
      • HitResult
      • MatrixSet
      • MouseRay2
      • PhysicHandler
      • PhysicHandlerEvent
      • PhysicPropeterys
      • PhysicsBehavior
      • PhysicsBehaviorEvent
      • PhysicsHandler2D
      • PhysicsHandler3D
      • Raycast
    • Genesis.UI
      • Canvas
      • ImageButton
      • Label
      • ListItem
      • ListItemBehavior
      • ListSelector
      • ListSelectorBehavior
      • Panel
      • ProgressBar
      • UIEvent
      • UIParseHandler
      • UIParser
      • Widget

    Class Utils

    Contains utility functions for various tasks within the Genesis.Core namespace.

    Inheritance
    object
    Utils
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Genesis.Core
    Assembly: Genesis.dll
    Syntax
    public class Utils

    Constructors

    Utils()

    Declaration
    public Utils()

    Methods

    CalculateCameraFront(Camera)

    Calculates the front vector of a camera using its location and rotation.

    Declaration
    public static Vec3 CalculateCameraFront(Camera camera)
    Parameters
    Type Name Description
    Camera camera

    The camera.

    Returns
    Type Description
    Vec3

    The front vector of the camera.

    CalculateCameraFront2(Camera)

    Calculates the front vector of a camera using its rotation angles.

    Declaration
    public static Vec3 CalculateCameraFront2(Camera camera)
    Parameters
    Type Name Description
    Camera camera

    The camera.

    Returns
    Type Description
    Vec3

    The front vector of the camera.

    CalculateDirectionVector(Vec3, Vec3)

    Calculates the direction vector from point A to point B.

    Declaration
    public static Vec3 CalculateDirectionVector(Vec3 pointA, Vec3 pointB)
    Parameters
    Type Name Description
    Vec3 pointA

    The starting point.

    Vec3 pointB

    The target point.

    Returns
    Type Description
    Vec3

    The direction vector from point A to point B.

    CalculateFrontVec3(Vec3, Vec3, float)

    Calculates a vector infront of the given point

    Declaration
    public static Vec3 CalculateFrontVec3(Vec3 location, Vec3 rotation, float dist)
    Parameters
    Type Name Description
    Vec3 location

    The source location

    Vec3 rotation

    The rotation

    float dist

    The distance

    Returns
    Type Description
    Vec3

    Front vector

    CalculatePitch(Vec3, Vec3)

    Calculates the pitch angle from point1 to point2.

    Declaration
    public static float CalculatePitch(Vec3 point1, Vec3 point2)
    Parameters
    Type Name Description
    Vec3 point1

    The starting point.

    Vec3 point2

    The target point.

    Returns
    Type Description
    float

    The pitch angle in degrees.

    CalculateYaw(Vec3, Vec3)

    Calculates the yaw angle from point1 to point2.

    Declaration
    public static float CalculateYaw(Vec3 point1, Vec3 point2)
    Parameters
    Type Name Description
    Vec3 point1

    The starting point.

    Vec3 point2

    The target point.

    Returns
    Type Description
    float

    The yaw angle in degrees.

    ConvertBase64ToBitmap(string)

    Converts a Base64 string to a Bitmap image.

    Declaration
    public static Bitmap ConvertBase64ToBitmap(string base64)
    Parameters
    Type Name Description
    string base64

    The Base64 string to convert.

    Returns
    Type Description
    Bitmap

    The Bitmap image decoded from the Base64 string.

    ConvertBitmapToBase64(Bitmap)

    Converts a Bitmap image to a Base64 string.

    Declaration
    public static string ConvertBitmapToBase64(Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap

    The Bitmap image to convert.

    Returns
    Type Description
    string

    The Base64 string representation of the Bitmap image.

    ConvertColor(Color)

    Converts a System.Drawing.Color into a float array.

    Declaration
    public static float[] ConvertColor(Color color)
    Parameters
    Type Name Description
    Color color

    The color.

    Returns
    Type Description
    float[]

    The float array representing the color.

    ConvertDrawingColor(float, float, float, float)

    Converts float values to a System.Drawing.Color.

    Declaration
    public static Color ConvertDrawingColor(float a, float r, float g, float b)
    Parameters
    Type Name Description
    float a

    The alpha component.

    float r

    The red component.

    float g

    The green component.

    float b

    The blue component.

    Returns
    Type Description
    Color

    The System.Drawing.Color representation.

    ConvertToGlmMat4(Matrix4x4)

    Converts a Matrix4x4 from the Assimp library to a mat4 from GLM library.

    Declaration
    public static mat4 ConvertToGlmMat4(Matrix4x4 matrix)
    Parameters
    Type Name Description
    Matrix4x4 matrix

    The Matrix4x4 to convert.

    Returns
    Type Description
    mat4

    A mat4 representing the converted matrix.

    CreateEmptyNormalMap(int, int)

    Creates an empty normal map with the specified width and height.

    Declaration
    public static Bitmap CreateEmptyNormalMap(int width, int height)
    Parameters
    Type Name Description
    int width

    The width of the normal map.

    int height

    The height of the normal map.

    Returns
    Type Description
    Bitmap

    An empty normal map.

    CreateEmptyTexture(int, int)

    Creates an empty texture with the specified width and height.

    Declaration
    public static Bitmap CreateEmptyTexture(int width, int height)
    Parameters
    Type Name Description
    int width

    The width of the texture.

    int height

    The height of the texture.

    Returns
    Type Description
    Bitmap

    An empty texture.

    EulerToQuaternion(Vec3)

    Converts Euler angles to a quaternion.

    Declaration
    public static quat EulerToQuaternion(Vec3 euler)
    Parameters
    Type Name Description
    Vec3 euler

    The Euler angles vector.

    Returns
    Type Description
    quat

    The quaternion representing the rotation.

    ForwardVector(Vec3, Vec3, float)

    Calculates the vector pointing forward from a given position and rotation.

    Declaration
    public static Vec3 ForwardVector(Vec3 v, Vec3 rotaion, float dist)
    Parameters
    Type Name Description
    Vec3 v

    The starting position vector.

    Vec3 rotaion
    float dist

    The distance to move in the forward direction.

    Returns
    Type Description
    Vec3

    The resulting position vector.

    GetCurrentTimeMillis()

    Gets the current time in milliseconds.

    Declaration
    public static long GetCurrentTimeMillis()
    Returns
    Type Description
    long

    The current time in milliseconds.

    GetElementWorldLocation(GameElement)

    Returns the world location for the game element.

    Declaration
    public static Vec3 GetElementWorldLocation(GameElement element)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Returns
    Type Description
    Vec3

    The world location of the game element.

    GetElementWorldRotation(GameElement)

    Returns the world rotation for the game element.

    Declaration
    public static Vec3 GetElementWorldRotation(GameElement element)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Returns
    Type Description
    Vec3

    The world rotation of the game element.

    GetElementWorldScale(GameElement)

    Returns the world scale for the game element.

    Declaration
    public static Vec3 GetElementWorldScale(GameElement element)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Returns
    Type Description
    Vec3

    The world scale of the game element.

    GetForwardDirection(Vec3)

    Calculates the forward direction vector based on Euler angles.

    Declaration
    public static Vec3 GetForwardDirection(Vec3 eulerAngles)
    Parameters
    Type Name Description
    Vec3 eulerAngles

    The Euler angles representing rotation.

    Returns
    Type Description
    Vec3

    The forward direction vector.

    GetGLMQuat(Quaternion)

    Converts an Assimp Quaternion to a quat from GLM library.

    Declaration
    public static quat GetGLMQuat(Quaternion pOrientation)
    Parameters
    Type Name Description
    Quaternion pOrientation

    The Quaternion to convert.

    Returns
    Type Description
    quat

    A quat representing the converted quaternion.

    GetGLMVec(Vector3D)

    Converts an Assimp Vector3D to a vec3 from GLM library.

    Declaration
    public static vec3 GetGLMVec(Vector3D vec)
    Parameters
    Type Name Description
    Vector3D vec

    The Vector3D to convert.

    Returns
    Type Description
    vec3

    A vec3 representing the converted vector.

    GetModelRotation(GameElement)

    Returns the model rotation matrix relative to the world rotation.

    Declaration
    public static mat4 GetModelRotation(GameElement element)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Returns
    Type Description
    mat4

    The model rotation matrix.

    GetModelScale(GameElement)

    Returns the model scale matrix relative to the world scale.

    Declaration
    public static mat4 GetModelScale(GameElement element)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Returns
    Type Description
    mat4

    The model scale matrix.

    GetModelSpaceLocation(GameElement, Vec3)

    Converts the world transform to model space transform.

    Declaration
    public static Vec3 GetModelSpaceLocation(GameElement element, Vec3 worldPosition)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Vec3 worldPosition

    The world position vector.

    Returns
    Type Description
    Vec3

    The model space location of the game element.

    GetModelSpaceRotation(GameElement, Vec3)

    Converts the world rotation to the model space rotation.

    Declaration
    public static Vec3 GetModelSpaceRotation(GameElement element, Vec3 worldRotation)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Vec3 worldRotation

    The world rotation vector.

    Returns
    Type Description
    Vec3

    The model space rotation of the game element.

    GetModelSpaceScale(GameElement, Vec3)

    Converts the world scale to the model space scale.

    Declaration
    public static Vec3 GetModelSpaceScale(GameElement element, Vec3 worldScale)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Vec3 worldScale

    The world scale vector.

    Returns
    Type Description
    Vec3

    The model space scale of the game element.

    GetModelTransformation(GameElement)

    Returns the model transform matrix relative to the world location.

    Declaration
    public static mat4 GetModelTransformation(GameElement element)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Returns
    Type Description
    mat4

    The model transform matrix.

    GetParentModelView(GameElement)

    Gets the transformation matrix for the parent model view.

    Declaration
    public static mat4 GetParentModelView(GameElement element)
    Parameters
    Type Name Description
    GameElement element

    The game element.

    Returns
    Type Description
    mat4

    The transformation matrix for the parent model view.

    GetRandomColor()

    Generates an random color

    Declaration
    public static Color GetRandomColor()
    Returns
    Type Description
    Color

    The color

    GetRandomColor(Color, Color)

    Returns a random color between the given colors.

    Declaration
    public static Color GetRandomColor(Color colorA, Color colorB)
    Parameters
    Type Name Description
    Color colorA

    The minimum color.

    Color colorB

    The maximum color.

    Returns
    Type Description
    Color

    A randomly generated color within the specified range.

    GetRandomColor(Color, Color, int)

    Returns a random color between the given colors using a specified seed for reproducibility.

    Declaration
    public static Color GetRandomColor(Color colorA, Color colorB, int seed)
    Parameters
    Type Name Description
    Color colorA

    The minimum color.

    Color colorB

    The maximum color.

    int seed

    The seed for the random number generator.

    Returns
    Type Description
    Color

    A randomly generated color within the specified range and seed.

    GetRandomColor(int)

    Generates an random color from an seed

    Declaration
    public static Color GetRandomColor(int seed)
    Parameters
    Type Name Description
    int seed

    The seed for the randomizer

    Returns
    Type Description
    Color

    The color

    GetRelativePosition(GameElement, GameElement)

    Gets the relative position of a child GameElement with respect to a parent GameElement.

    Declaration
    public static Vec3 GetRelativePosition(GameElement parent, GameElement child)
    Parameters
    Type Name Description
    GameElement parent

    The parent GameElement.

    GameElement child

    The child GameElement.

    Returns
    Type Description
    Vec3

    A Vec3 representing the relative position of the child.

    GetRelativePosition(GameElement, Camera)

    Gets the relative position of a camera with respect to a parent GameElement.

    Declaration
    public static Vec3 GetRelativePosition(GameElement parent, Camera camera)
    Parameters
    Type Name Description
    GameElement parent

    The parent GameElement.

    Camera camera

    The camera.

    Returns
    Type Description
    Vec3

    A Vec3 representing the relative position of the camera.

    GetRelativePosition(GameElement, Vec3)

    Gets the relative position of a location with respect to a parent GameElement.

    Declaration
    public static Vec3 GetRelativePosition(GameElement parent, Vec3 location)
    Parameters
    Type Name Description
    GameElement parent

    The parent GameElement.

    Vec3 location

    The location.

    Returns
    Type Description
    Vec3

    A Vec3 representing the relative position of the location.

    GetStringBounds(Vec3, string, float, float)

    Gets the bounding rectangle of a string given its location, text, font size, and spacing.

    Declaration
    public static Rect GetStringBounds(Vec3 location, string text, float fontSize, float spacing)
    Parameters
    Type Name Description
    Vec3 location

    The location of the string.

    string text

    The input string.

    float fontSize

    The font size.

    float spacing

    The character spacing.

    Returns
    Type Description
    Rect

    The bounding rectangle of the string.

    GetStringHeight(string, float, float)

    Gets the height of a string given the font size and spacing.

    Declaration
    public static float GetStringHeight(string text, float fontSize, float spacing)
    Parameters
    Type Name Description
    string text

    The input string.

    float fontSize

    The font size.

    float spacing

    The line spacing.

    Returns
    Type Description
    float

    The height of the string.

    GetStringWidth(string, float, float)

    Gets the width of a string given the font size and spacing.

    Declaration
    public static float GetStringWidth(string text, float fontSize, float spacing)
    Parameters
    Type Name Description
    string text

    The input string.

    float fontSize

    The font size.

    float spacing

    The character spacing.

    Returns
    Type Description
    float

    The width of the string.

    GetVMirroredPosition(Vec3, Camera)

    Gets the vertically mirrored position of a reference vector relative to a camera.

    Declaration
    public static Vec3 GetVMirroredPosition(Vec3 vref, Camera camera)
    Parameters
    Type Name Description
    Vec3 vref

    The reference vector.

    Camera camera

    The camera used for mirroring.

    Returns
    Type Description
    Vec3

    The vertically mirrored position vector.

    GetVMirroredPosition(float, float, float, Camera)

    Gets the vertically mirrored position of a reference vector relative to a camera.

    Declaration
    public static Vec3 GetVMirroredPosition(float x, float y, float z, Camera camera)
    Parameters
    Type Name Description
    float x

    The reference x vector.

    float y

    The reference y vector

    float z

    The reference z vector

    Camera camera

    The camera used for mirroring.

    Returns
    Type Description
    Vec3

    The vertically mirrored position vector.

    LookAt(Camera, Vec3)

    Lets the camera look at a position.

    Declaration
    public static void LookAt(Camera camera, Vec3 targetPosition)
    Parameters
    Type Name Description
    Camera camera

    The camera.

    Vec3 targetPosition

    The target position.

    RayDirection(Camera, Viewport, float, float)

    Calculates the direction of a ray in world space based on screen coordinates.

    Declaration
    public static Vec3 RayDirection(Camera camera, Viewport viewport, float x, float y)
    Parameters
    Type Name Description
    Camera camera

    The Camera object.

    Viewport viewport

    The Viewport object.

    float x

    X-coordinate on the screen.

    float y

    Y-coordinate on the screen.

    Returns
    Type Description
    Vec3

    Direction of the ray as a Vec3.

    ToDegrees(float)

    Converts radians to degrees.

    Declaration
    public static float ToDegrees(float radians)
    Parameters
    Type Name Description
    float radians

    The angle in radians.

    Returns
    Type Description
    float

    The angle in degrees.

    ToRadians(float)

    Converts degrees to radians.

    Declaration
    public static float ToRadians(float degrees)
    Parameters
    Type Name Description
    float degrees

    The angle in degrees.

    Returns
    Type Description
    float

    The angle in radians.

    TransformToWorldCords(Game, float, float)

    Transforms screen coordinates to world coordinates in the context of a Game.

    Declaration
    public static Vec3 TransformToWorldCords(Game game, float x, float y)
    Parameters
    Type Name Description
    Game game

    The Game object.

    float x

    X-coordinate on the screen.

    float y

    Y-coordinate on the screen.

    Returns
    Type Description
    Vec3

    World coordinates as a Vec3.

    TransformToWorldCords(Camera, Viewport, float, float)

    Transforms screen coordinates to world coordinates in the context of a specific Camera and Viewport.

    Declaration
    public static Vec3 TransformToWorldCords(Camera camera, Viewport viewport, float x, float y)
    Parameters
    Type Name Description
    Camera camera

    The Camera object.

    Viewport viewport

    The Viewport object.

    float x

    X-coordinate on the screen.

    float y

    Y-coordinate on the screen.

    Returns
    Type Description
    Vec3

    World coordinates as a Vec3.

    In this article
    Back to top Generated by DocFX