Lua
C++
Edit

CreateProbe

This function creates a new environment probe.

Syntax

Paraemter Description
world world to create the entity in

Returns

Returns a new probe entity.

Example

#include "UltraEngine.h"
#include "ComponentSystem.h"

using namespace UltraEngine;

const WString remotepath = "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets";

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create framebuffer
    auto framebuffer = CreateFramebuffer(window);
    framebuffer->GetSize();

    //Create world
    auto world = CreateWorld();
    world->SetAmbientLight(0.05);

    //Set environment maps
    auto specmap = LoadTexture(remotepath + "/Materials/Environment/Storm/specular.dds");
    auto diffmap = LoadTexture(remotepath + "/Materials/Environment/Storm/diffuse.dds");
    world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR);
    world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE);

    //Create light
    auto light = CreateDirectionalLight(world);
    light->SetRotation(25, 315, 0);

    //Create camera
    auto camera = CreateCamera(world);
    camera->SetFov(70);
    camera->SetPosition(8, 2.5, 0);
    camera->SetRotation(0, -90, 0);
    camera->SetClearColor(0.125f);

    //Create the scene
    auto wall = CreateBox(world, 10, 5, 0.5);
    wall->SetPosition(0, 2.5, 4.75);
    wall->SetColor(0, 1, 1);

    auto wall2 = CreateBox(world, 10, 5, 0.5);
    wall2->SetPosition(0, 2.5, -4.75);
    wall2->SetColor(1, 0, 0);

    auto wall3 = CreateBox(world, 0.5, 5, 9);
    wall3->SetPosition(-4.75, 2.5, 0);

    auto floor = CreateBox(world, 20, 1, 20);
    floor->SetPosition(0, -0.5f, 0);

    auto ceil = CreateBox(world, 10, 0.5f, 10);
    ceil->SetPosition(0, 5.25, 0);

    auto drag = LoadModel(world, remotepath + "/Models/Stanford/dragon.glb");
    drag->SetScale(0.1f);
    drag->SetColor(1, 1, 1, 1, true);
    drag->SetReflection(false);
    auto mtl = CreateMaterial();
    mtl->SetMetalness(0.75);
    mtl->SetRoughness(0);
    drag->SetMaterial(mtl, true);

    //Create environment probe
    auto probe = CreateProbe(world);
    probe->SetScale(9.5, 5, 9.5);
    probe->SetPosition(0, 2.5, 0);
    probe->SetFadeDistance(1, CUBEMAP_POSITIVE_X);
    probe->SetFadeDistance(0, CUBEMAP_NEGATIVE_X);
    probe->SetFadeDistance(0, CUBEMAP_POSITIVE_Y);
    probe->SetFadeDistance(0, CUBEMAP_NEGATIVE_Y);
    probe->SetFadeDistance(0, CUBEMAP_POSITIVE_Z);
    probe->SetFadeDistance(0, CUBEMAP_NEGATIVE_Z);

    //Camera controls
    camera->AddComponent<CameraControls>();

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer, true);
    }
    return 0;
}
Copyright © 2024 Ultra Software.
All rights reserved.