Download Now

    Reference TWorld

    Declared in Codebot.Render.World.pas on line 72

    TWorld provides a 2D world in a 3D space. It also gives you an optional camera and skybox
      TWorld = class(TContextManagedObject)
      public
        { World is created for you by the TWorldExtension helper below }
        constructor Create;
        { Define the world virtual resolution and perspective. USeful defaults are
          provided representing a 1080p virtual resolution for your 2D world. }
        procedure Define(Width: Integer = 1920; Height: Integer = 1080; Depth: Float = -10; FieldOfView: Float = 60; NearPlane: Float = 0.5; FarPlane: Float = 100);
        { Update the perspective and apply camera and skybox if they exist }
        procedure Update(Time: Double = 0);
        { Convert a 3D space coordinate to a 2D world coordinate }
        function SpaceToWorld(X, Y, Z: Float): TVec2; overload;
        function SpaceToWorld(const V: TVec3): TVec2; overload;
        { Convert a 2D worldcoordinate to a 3D space coordinate }
        function WorldToSpace(X, Y: Float): TVec3; overload;
        function WorldToSpace(const V: TVec2): TVec3; overload;
        { Convert a space distance to a 2d world distance }
        function DepthToWorld(Depth: Float): Float;
        { Convert a 2d world distance to a space distance }
        function WorldToDepth(Depth: Float): Float;
        { Draw a simple grid on a ground plane }
        procedure DrawGrid;
        { The virtual resolution width of world in a 2D plane }
        property Width: Integer read FWidth;
        { The virtual resolution height of world in a 2D plane }
        property Height: Integer read FHeight;
        { The distance from the origin of the world in a 2D plane }
        property Depth: Float read FDepth;
        { The field of view for the 3d space }
        property FieldOfView: Float read FFieldOfView;
        { The optional camera }
        property Camera: TCamera read GetCamera;
        { The optional skybox }
        property Skybox: TSkybox read GetSkybox;
      end;

    See also

    Float in Codebot.System.pas
    TContextManagedObject in Codebot.Render.Contexts.pas
    TVec2 in Codebot.Geometry.pas
    TVec3 in Codebot.Geometry.pas