Jump to content

Josh

Staff
  • Posts

    23,143
  • Joined

  • Last visited

Everything posted by Josh

  1. Where are you trying to upload your images?
  2. That’s probably not great, but -1 gets evaluated as the max unsigned int value so it doesn’t hurt anything.
  3. Update Added Interface::SetSize method. This makes the example here behave as I would expect: #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine - Normal", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); camera->SetViewport(200, 0, framebuffer->size.x - 200, framebuffer->size.y); auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); uiCamera->SetRenderLayers(RENDERLAYER_1); uiCamera->SetClearMode(CLEAR_DEPTH); uiCamera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); auto ui = CreateInterface(world, LoadFont("Fonts/arial.ttf"), iVec2(200, framebuffer->size.y)); ui->SetRenderLayers(RENDERLAYER_1); auto sz = ui->root->ClientSize(); auto listbox = CreateListBox(5, 5, sz.x - 10, 200, ui->root, LISTBOX_DEFAULT)->As<ListBox>(); auto tabber = CreateTabber(5, 205, sz.x - 10, sz.y - 205, ui->root)->As<Tabber>(); tabber->AddItem("Settings", true); tabber->AddItem("Output"); tabber->SetLayout(1, 0, 1, 1); for (int i = 0; i < 100; i++) { listbox->AddItem("Item " + String(i)); } //Create a light auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); //Create a box auto box = CreateBox(world); box->SetColor(0, 0, 1); //Entity component system auto actor = CreateActor(box); auto component = actor->AddComponent<Mover>(); component->rotation.y = 45; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto ev = WaitEvent(); ui->ProcessEvent(ev); switch (ev.id) { case UltraEngine::EVENT_WINDOWCLOSE: if (ev.source == window) exit(0); break; default: break; } } // Rebuild the window. if (window->KeyDown(KEY_SPACE)) { static bool bSwapped = false; framebuffer = NULL; window = NULL; if (!bSwapped) { // Make it a tad bigger window = CreateWindow("Ultra Engine - Resized", 0, 0, 1400, 800, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); framebuffer = CreateFramebuffer(window); } else { window = CreateWindow("Ultra Engine - Normal", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); framebuffer = CreateFramebuffer(window); } // Reposition the camera. uiCamera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); //Resize the interface ui->SetSize(iVec2(200, framebuffer->size.y)); bSwapped = !bSwapped; } world->Update(); if (framebuffer) world->Render(framebuffer); } return 0; }
  4. Update New command SetHrtf for better 3D audio with headphones: https://www.ultraengine.com/learn/SetHrtf Audio filters now supported: https://www.ultraengine.com/learn/LoadAudioFilter Audio filters are stored in JSON files. There are about a dozen different types of effects. One type of effect is EAXReverb, which includes all the classic EAX reverb presets (over 100), but there are other effects like distortion, auto-wah, flanger, chorus, and more. At this time, EAXReverb effects are the only ones that support loading parameters from their files. Other effects will always use their default settings, for now. A speaker can use multiple audio filters, like guitar effects pedals in a chain. This is all it takes: auto filter = LoadAudioFilter("https://raw.githubusercontent.com/UltraEngine/Assets/main/Sound/Filters/EAXReverb/SewerPipe.json"); speaker->SetFilter(filter); You can read more about head-related transfer function here: https://en.wikipedia.org/wiki/Head-related_transfer_function
  5. This will take some time to figure out what the correct behavior here should be. If you are making a desktop application with a 3D viewport, it's better to create the interface directly on the window, and use a child window to make an embedded 3D viewport: https://github.com/UltraEngine/Documentation/blob/master/CPP/Leadwerks.md#advanced-example
  6. The problem in your code was that when the ortho camera was created first, the 3D camera did not have its clear mode set to CLEAR_DEPTH, so it was still clearing the color after the ortho camera was drawn. The other issue was that the ortho camera was not clearing the color when it was the first created camera, so the contents of the previous frame would still be visible, causing a "hall of mirror" effect if the camera moves. Clear color has no effect if the clear mode does not include CLEAR_COLOR.
  7. I fixed your example: #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; // Toggle me to change the order. // Creation order of the cameras should not matter. //#define DRAW_2DCAM_FIRST int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create framebuffer auto framebuffer = CreateFramebuffer(window); //Create world auto world = CreateWorld(); #ifdef DRAW_2DCAM_FIRST //Create a ortho camera first auto camera2D = CreateCamera(world, UltraEngine::PROJECTION_ORTHOGRAPHIC); camera2D->SetDepthPrepass(false); camera2D->SetRenderLayers(UltraEngine::RENDERLAYER_7); camera2D->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); camera2D->SetClearColor(0.125); //Create sprite auto sprite = LoadSprite(world, "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Sprites/nightraider.dds"); sprite->SetRenderLayers(UltraEngine::RENDERLAYER_7); sprite->SetPosition(0, 0); sprite->mesh->material->SetAlphaMask(true); #endif //Create the 3D camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); #ifdef DRAW_2DCAM_FIRST camera->SetClearMode(CLEAR_DEPTH); #endif #ifndef DRAW_2DCAM_FIRST //Create a ortho camera first auto camera2D = CreateCamera(world, UltraEngine::PROJECTION_ORTHOGRAPHIC); camera2D->SetDepthPrepass(false); camera2D->SetClearMode(UltraEngine::CLEAR_DEPTH); camera2D->SetRenderLayers(UltraEngine::RENDERLAYER_7); camera2D->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); //Create sprite auto sprite = LoadSprite(world, "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Sprites/nightraider.dds"); sprite->SetRenderLayers(UltraEngine::RENDERLAYER_7); sprite->SetPosition(0, 0); sprite->mesh->material->SetAlphaMask(true); #endif // Create a box for us to see auto model = CreateBox(world); model->SetColor(1, 0, 0); model->Turn(45, 45, 0); //Main loop while (window->Closed() == false and window->KeyHit(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  8. This is not currently supported.
  9. AppPath() is the full path including the executable name. AppDir is the folder part of that. It looks like this is missing from the docs.
  10. https://www.ultraengine.com/learn/Widget_SetFontScale?lang=cpp
  11. This simple example shows fullscreen window resolution changes. It works but it will trigger a validation error in debug mode: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_FULLSCREEN); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create light auto light = CreateBoxLight(world); light->SetRange(-10, 10); light->SetRotation(15, 15, 0); light->SetColor(2); //Create camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -3); camera->SetFov(70); //Create scenery auto box = CreateBox(world); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { window = CreateWindow("Ultra Engine", 0, 0, 1920, 1080, displays[0], WINDOW_FULLSCREEN); framebuffer = CreateFramebuffer(window); } world->Update(); world->Render(framebuffer); } return 0; }
  12. You would never be able to do something like this with Leadwerks.
  13. Also, you guys should use floating points when setting the 2D camera's position: camera2D->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0.0f); If you do integer division your position can be slightly off if the framebuffer happens to have an odd number for width or height. This WILL cause your sprites to not be pixel-perfect, and will cause blurry font rendering.
  14. @SpiderPig In this example, you never rendered world2, so it never gets drawn. This code will work, but I don't think the engine likes constantly switching back and forth between worlds. It would be much better to use render layers to control what gets drawn on which camera. There is also a Camera::SetRealtime method which can be used to draw a camera only once or intermittently. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 2, -3); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); ui->SetRenderLayers(RENDERLAYER_1); ui->root->SetColor(0, 0, 0, 0); auto ui_cam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_cam->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2, 0); ui_cam->SetRenderLayers(RENDERLAYER_1); ui_cam->SetClearMode(CLEAR_DEPTH); auto world2 = CreateWorld(); //world2 = world; auto tex_buffer = CreateTextureBuffer(256, 256); auto cam2 = CreateCamera(world2); cam2->SetClearColor(1, 0, 0); cam2->SetRenderTarget(tex_buffer); cam2->Move(0, 0, -5); auto light2 = CreateDirectionalLight(world2); auto box2 = CreateBox(world2); auto mat = CreateMaterial(); mat->SetTexture(tex_buffer->GetColorAttachment()); auto sprite = CreateSprite(world, 256, 256); sprite->SetRenderLayers(RENDERLAYER_1); sprite->SetMaterial(mat); auto light = CreateDirectionalLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); auto floor = CreateBox(world, 1000.0f, 0.1f, 1000.0f); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { box2->Turn(0, 1, 0); world->Update(); world2->Render(framebuffer); world->Render(framebuffer); } return 0; }
  15. Update Fixed bug where transparent objects were being drawn in the depth pre-pass, causing visual errors Currently it's not really possible without using a pixmap, which would only work with image data in system memory, but it would probably not be too difficult to add an option for this, probably a Widget::SetTexture() method. What do you propose? Something like Camera::SetClipPlane(const Plane& p, const int index)?
  16. @SpiderPig This example reproduces your problem using a single camera... #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); auto ui_cam = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_cam->SetClearColor(0, 1, 0); ui_cam->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0); ui_cam->SetDepthPrepass(true); auto text = CreateLabel("Hello", 120, 10, 100, 20, ui->root); auto slider = CreateSlider(120, 40, 100, 20, ui->root); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto e = WaitEvent(); ui->ProcessEvent(e); } world->Update(); world->Render(framebuffer); } return 0; }
  17. You have too many events piling up in the queue faster than you are processing them. Change "if PeekEvent" to "while PeekEvent()".
  18. Update Adjusted depth settings when early z-pass is disabled.
  19. Here is a simpler example that demonstrates the problem: #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create framebuffer auto framebuffer = CreateFramebuffer(window); //Create world auto world = CreateWorld(); //Create a ortho camera auto camera2D = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); camera2D->SetClearColor(0, 0, 1); camera2D->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); //Create sprite auto sprite = CreateSprite(world, 400, 400); auto mtl = CreateMaterial(); sprite->SetMaterial(mtl); auto sprite2 = CreateSprite(world, 400, 400); sprite2->SetColor(1, 0, 0); sprite2->SetPosition(500, 0, 0); //Main loop while (window->Closed() == false and window->KeyHit(KEY_ESCAPE) == false) { camera2D->SetDepthPrepass(window->KeyDown(KEY_SPACE)); world->Update(); world->Render(framebuffer); } return 0; }
  20. The render layers are a bitwise flag. You can assign multiple layers to the drawn object or the camera, and if they have a value in common then the camera draws that entity.
  21. I think the API is stable, but it is possible there could be some small changes.
  22. Update Adjusted depth settings in transparency pass UTF-8 string conversion back to wide string no longer supported because it's unreliable
  23. Wow, there is a lot of stuff going on in your game. This is all with Lua?
  24. Update Fixed package stream path error Fixed z-sorting
  25. Update Added package support. Zip archive support is built-in. Zlib was alreday included in the engine in FreeImage, and I couldn't figure out any way to pass a password to a DLL plugin without it being easily intercepted, so I made it native. You must add the following search header path to your existing projects: "$(UltraEnginePath)\Include\Libraries\zlib"
×
×
  • Create New...