Jump to content

Josh

Staff
  • Posts

    23,228
  • Joined

  • Last visited

Everything posted by Josh

  1. Yeah, just nudge it forward away from the camera: line->SetPosition(line->position + Vec3(0,0,0.1));
  2. No, because your sprites are in 3D space. Just calculate the Y position like this: y = framebuffer->size.y - y I suppose the fact there is no 2D drawing is an argument for camera project/unproject to pre-flip the Y coordinate.
  3. No, in the GUI system everything is right angles. I thought about adding lines and Bezier curves in a future update.
  4. I'm not going to worry about small cosmetic issues right now. There are a few places where a line is off by one pixel, or something like that. This should be resolved, but I would like to focus on anything more important right now.
  5. Yep, I confirmed this. I could make the increment smaller. I don't know what the lower limit is before Z-fighting will start happening. But I don't think this is really a problem, in any case.
  6. I know why this is happening. 🤡 The engine uses the depth buffer for 2D ordering, so it does not have to draw 2D objects in order. This is one of the reasons it is so fast. When the GUI generates sprites for all the interface elements, it starts by positioning them at the far depth range, and moves each one a little closer to the camera, to make it appear on top of the last one. It seems that at about 2000 the Z-position increments pass the near depth range, so the sprites after that are no longer visible to the camera. Not a bug, just the way it is designed. Normal sprites that you position yourself will not do this.
  7. When I run it I get to about 2300. Each update gets slower and slower. I don't have an explanation right now why new panels stop appearing though. The render stats say more instances are being drawn. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; bool EventCallback(const Event& event, shared_ptr<Object> extra) { switch (event.id) { case EVENT_MOUSEENTER: Print("MOUSE_ENTER"); break; case EVENT_MOUSELEAVE: Print("MOUSE_LEAVE"); break; case EVENT_MOUSEDOWN: Print("MOUSE_DOWN"); break; case EVENT_MOUSEMOVE: //Print("MOUSE_MOVE"); break; case EVENT_MOUSEUP: Print("MOUSE_UP"); break; case EVENT_MOUSEWHEEL: Print("MOUSE_WHEEL"); break; } return true; } 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 default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->size); ui->SetRenderLayers(1); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); ui_camera->SetRenderLayers(1); ui_camera->SetClearMode(CLEAR_DEPTH); auto w1 = CreatePanel(0, 0, 1, 1, ui->root); ListenEvent(EVENT_NONE, w1, EventCallback); auto w2 = CreatePanel(0, 0, 1, 1, w1); ListenEvent(EVENT_NONE, w2, EventCallback); w2->SetColor(1, 0, 0); auto w3 = CreateTabber(10, 10, 1, 1, ui->root); w3->SetShape(25, 25, 256, 256); w3->AddItem("Page1"); w3->AddItem("Page2"); auto w4 = CreateButton("Test", 0, 0, 32, 32, w3); w4->SetShape(5, 5, 100, 50); auto terrain = CreateTerrain(world, 512, 512); terrain->SetMaterial(LoadMaterial("Data\\bluegrid.mat")); auto c = CreateCylinder(world); c->SetPhysicsMode(PHYSICS_PLAYER); vector<shared_ptr<Entity>> entities; Vec3 offset = Vec3(10.0f, 1.0f, 5.0f); float scale = 2.0f; for (int z = 0; z < 10; z++) { for (int x = 0; x < 10; x++) { auto e = CreateSphere(world); e->SetColor(Random(), Random(), Random()); e->SetPosition(Vec3((float)x * scale + Random() - 0.5f, 0.0f, (float)z * scale + Random() - 0.5f) + offset, true); e->SetMass(1.0f); entities.push_back(e); } } auto sprite = CreateSprite(world, default_font, "", 12); sprite->SetRenderLayers(1);//Still on layer 0? vector<shared_ptr<Widget>> widgets; widgets.push_back(ui->root); world->RecordStats(true); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { w1->SetShape(Random(0, 512), Random(0, 512), Random(64, 128), Random(64, 128)); w2->SetShape(Random(0, 10), Random(0, 10), Random(16, 128), Random(16, 32)); } if (!window->KeyDown(KEY_H)) { auto w = CreatePanel(Random(0, 512), Random(0, 512), Random(64, 128), Random(64, 128), ui->root);// widgets[(int)Random(0.0f, (float)widgets.size() - 0.1f)]); w->SetColor(Random(), Random(), Random()); ListenEvent(EVENT_NONE, w, EventCallback); widgets.push_back(w); } sprite->SetText(String(widgets.size())); while (PeekEvent()) { auto event = WaitEvent(); ui->ProcessEvent(event); } window->SetText(world->renderstats.instances); world->Update(); world->Render(framebuffer); } return 0; }
  8. Just use the correct camera and the correct render buffer, and everything works out: auto screen_pos = cam3->Project(box->position, buffer);
  9. These widgets do not emit mouse events.
  10. Update Fixed transparency problems
  11. Thanks for the example, I just had to move the pre-multiply alpha multiplication to come after the dither step.
  12. You can see the transparency issue a bit more clearly like this: #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 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); //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, 8); //Entity component system auto actor = CreateActor(box); auto component = actor->AddComponent<Mover>(); component->rotation.y = 45; auto material = CreateMaterial(); material->SetTransparent(true); auto s1 = CreateSphere(world); s1->SetPosition(-0.5f, 0.0f, -1.0f); s1->SetMaterial(material); s1->SetColor(1.0f, 0.0f, 0.0f, 0.5f); auto s2 = CreateSphere(world); s2->SetPosition(0.5f, 0.0f, -1.0f); s2->SetMaterial(material); s2->SetColor(0.0f, 0.0f, 0.0f, 1.0f); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  13. This indicates a serious problem, but I am unable to produce any error with this code: #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, 0, -3); vector<shared_ptr<Entity>> entities; Vec3 offset = Vec3(10.0f, 1.0f, 5.0f); float scale = 2.0f; for (int z = 0; z < 10; z++) { for (int x = 0; x < 10; x++) { auto e = CreateSphere(world); e->SetColor(Random(), Random(), Random()); e->SetPosition(Vec3((float)x * scale + Random() - 0.5f, 0.0f, (float)z * scale + Random() - 0.5f) + offset, true); e->SetMass(1.0f); entities.push_back(e); } } while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  14. Update Fixed pixmap not appearing in 3D GUI Fixed MOUSEENTER events not occurring Entity::GetValue<T> changed to GetField<T>, but you should not use this anyway RENDERLAYER_N constants are removed. You can declare your own if you want to use these: enum RenderLayer { RENDERLAYER_NONE = 0, RENDERLAYER_0 = 1, RENDERLAYER_1 = 2, RENDERLAYER_2 = 4, RENDERLAYER_3 = 8, RENDERLAYER_4 = 16, RENDERLAYER_5 = 32, RENDERLAYER_6 = 64, RENDERLAYER_7 = 128, RENDERLAYER_ALL = 255 }; inline RenderLayer operator|(RenderLayer a, RenderLayer b) { return static_cast<RenderLayer>(static_cast<int>(a) | static_cast<int>(b)); };
  15. It doesn't work recursively. You need to listen for each widget.
  16. Josh

    ChatGPT

    It's very obvious that websites that rely on free user-generated content are all going away, soon, like maybe within 12 months. Social media, news websites, general-purpose forums, are all going to be flooded with AI-generated text. I can generate 10 creepy pastas and post them in a few minutes with this. It's not much of a stretch to set up a system that generates videos and uploads them to YouTube automatically. I mean, once it was set up, I could upload 100,000 videos a day to 1000 different accounts without much trouble.
  17. Josh

    Asset Editor WIP

    I like this layout better. I think the properties can be fit into the lower-left corner under the hierarchy tree.
  18. When a new font size is used, every character in the font gets rasterized to an image. However, probably 99% of those characters are never used. It would make sense to only rasterize them as they are used, but it will make things a bit more complicated and require a lot of testing before it works perfectly. Maybe I can add this in a future update?
  19. Well, the first step was to add an annual pricing option, because no one will want to manually pay a bill each month, and cypto does not have any way of making automatic monthly payments.
  20. Heightfield colliders only handle flat terrain. There is also a dynamic collider that generates collision dynamically in a function. This is what the Leadwerks Game Engine vegetation system uses, and why collision gets very slow in the vegetation system if you accidentally use a detailed model for the collision shape. For voxel terrain I would recommend the normal mesh collider.
  21. Josh

    Ref to Self

    Also, never never never call Self or As in a constructor or destructor.
  22. Josh

    Ref to Self

    The base object class or derived from the shared_from_this class: https://www.ultraengine.com/learn/Object_Self?lang=cpp https://www.ultraengine.com/learn/Object_As?lang=cpp I don’t think you need to store a weak pointer to itself
×
×
  • Create New...