-
Posts
516 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Dreikblack
-
Looks like a component of new entity that was created by entity->Instantiate() has a pointer to original entity. Several months it worked fine. Maybe something went wrong when public entity pointer was replaced by GetEntity() method. Steam beta branch. #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, 1200, 800, 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->SetPosition(1, 1, 1); auto component = box->AddComponent<Mover>(); component->rotationspeed.y = 45; auto newBox = box->Instantiate(world, true, true); newBox->SetPosition(2, 2, 2); auto componentTest = newBox->GetComponent<Mover>(); Print("first box pos x:"); Print(box->GetPosition().x); Print(component->GetEntity()->GetPosition().x); Print("second box pos x:"); Print(newBox->GetPosition().x); Print(componentTest->GetEntity()->GetPosition().x); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer, false); } return 0; }
-
You can import heightmap https://www.ultraengine.com/learn/Terrain_LoadHeightmap?lang=lua. idk how to get a world in editor console to do it there tho.
-
Outline color should match doppelganger entities to have multiple outline colors for different models. It looked like that several months ago
-
Does not work anymore in latest dev beta branch: #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, 1200, 800, 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(1, 0, 0); auto outlineBox = CreateBox(world); outlineBox->SetColor(0, 1, 0); auto material = CreateMaterial(); auto unlitShader = LoadShaderFamily("Shaders/Unlit.fam"); material->SetShaderFamily(unlitShader); outlineBox->SetMaterial(material); //Create a box2 auto box2 = CreateBox(world); box2->SetColor(1, 0, 0); auto outlineBox2 = CreateBox(world); outlineBox2->SetColor(0, 0, 1); auto material2 = CreateMaterial(); auto unlitShader2 = LoadShaderFamily("Shaders/Unlit.fam"); material2->SetShaderFamily(unlitShader); outlineBox2->SetMaterial(material); outlineBox2->SetPosition(2, 0, 0); box2->SetPosition(2, 0, 0); //Entity component system auto component = box->AddComponent<Mover>(); component->rotationspeed.y = 45; auto outlineComponent = outlineBox->AddComponent<Mover>(); outlineComponent->rotationspeed.y = 45; auto component2 = box2->AddComponent<Mover>(); component2->rotationspeed.y = 45; auto outlineComponent2 = outlineBox2->AddComponent<Mover>(); outlineComponent2->rotationspeed.y = 45; //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //Render to texture outlineBox->SetRenderLayers(2); outlineBox2->SetRenderLayers(2); auto cam2 = CreateCamera(world); cam2->SetClearColor(0, 0, 0, 0); cam2->SetRenderLayers(2); cam2->SetFov(camera->GetFov()); cam2->SetMatrix(camera->matrix); cam2->AddPostEffect(LoadPostEffect("Shaders/Outline.fx")); auto sz = framebuffer->GetSize(); auto texbuffer = CreateTextureBuffer(sz.x, sz.y); cam2->SetRenderTarget(texbuffer); ////Display overlay auto sprite = CreateSprite(world, sz.x, sz.y); sprite->SetRenderLayers(4); auto mtl = CreateMaterial(); sprite->SetMaterial(mtl); mtl->SetTransparent(true); mtl->SetTexture(texbuffer->GetColorAttachment()); auto cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); cam3->SetClearMode(CLEAR_DEPTH); cam3->SetRenderLayers(4); cam3->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0); //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer, false); } return 0; } #version 450 #extension GL_GOOGLE_include_directive : enable #extension GL_ARB_separate_shader_objects : enable #extension GL_EXT_multiview : enable #include "../Base/PushConstants.glsl" #include "../Base/CameraInfo.glsl" #include "../Base/TextureArrays.glsl" #include "../Utilities/Dither.glsl" layout(location = 0) in vec2 texCoords; layout(location = 0) out vec4 outColor; void main() { outColor = texture(texture2DSampler[PostEffectTextureID1], texCoords.xy); outColor.a = 0.0f; float depth = texture(texture2DSampler[PostEffectTextureID0], texCoords.xy).r; //Handle selected objects if (depth < 1.0f) { const int m = 4; vec2 pixelsize = 1.0f / BufferSize; for (int x = -m; x <= m; ++x) { for (int y = -m; y <= m; ++y) { if (x == 0 && y == 0) continue; float neighbor = texture(texture2DSampler[PostEffectTextureID0], texCoords.xy + pixelsize * vec2(x, y)).r; if (neighbor == 1.0f) { outColor = texture(texture2DSampler[PostEffectTextureID1], texCoords.xy); return; } } } } }
-
Leadworks as Game Engine for Commercial Projects ?
Dreikblack replied to Andy90's topic in General Discussion
-
-
Or it could be a prefab in template. Btw any eta on prefabs?
-
So it will be NVIDIA RTX that games using nowadays?
-
You can make game in any genre with Ultra. I'm working on turn based tactic game for example: It's currently on pause because i have to wait for release in Steam to be able to buy it and continue development. Had access when it had subscription system and i bought it for few months with payment for Quake Sacrifice league
-
Widget flashes purple while changing an icon or pixmap
Dreikblack replied to Dreikblack's topic in Bug Reports
My subscription has ended so i can't check it -
Debug mode has no such problem but TransformPoint in same code in release mode don't returns true when it should. A model becomes yellow when it goes through a box in debug( i.e. TransformPoint() returns true). #include "UltraEngine.h" #include "Components/Mover.hpp" 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 framebuffer auto framebuffer = CreateFramebuffer(window); //Create a world auto world = CreateWorld(); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.8); camera->Turn(35, 0, 0); camera->Move(0, 0, -2); camera->SetDebugPhysicsMode(true); //Create light auto light = CreateBoxLight(world); light->SetRange(-20, 20); light->SetArea(20, 20); light->SetRotation(35, 35, 0); auto unlitMaterial = CreateMaterial(); auto unlitShader = LoadShaderFamily("Shaders/Unlit.json"); unlitMaterial->SetShaderFamily(unlitShader); int width = 2, height = 1, length = 3; auto model = CreateModel(world); auto mesh = model->AddMesh(); mesh->AddVertex(0, 0, 0); //S mesh->AddVertex(-width * 0.5, -height * 0.5, length);//NW mesh->AddVertex(width * 0.5, -height * 0.5, length);//NE mesh->AddPrimitive(2, 1, 0);//S , NW, NE mesh->AddVertex(-width * 0.5, height * 0.5, length);//NW h mesh->AddVertex(width * 0.5, height * 0.5, length);//NE h mesh->AddPrimitive(0, 3, 4);//S , NW h, NE h mesh->AddPrimitive(0, 1, 3);//left mesh->AddPrimitive(4, 3, 1); //"face" mesh->AddPrimitive(2, 4, 1); //"face" mesh->AddPrimitive(0, 4, 2); //"right" auto& mat = unlitMaterial; mat->SetTransparent(true); model->SetMaterial(mat); model->SetColor(0.5f, 0.8f, 0, 0.25f); model->SetPosition(0, 0, 0); auto collider = CreateConvexHullCollider(mesh); model->SetCollider(collider); Vec3 targetPos(2, 0, 0); auto box = CreateBox(world, 0.1f); box->SetPosition(targetPos); auto component = model->AddComponent<Mover>(); component->rotationspeed.y = 45; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { auto newTargetPos = TransformPoint(targetPos, Mat4(), model->GetMatrix()); bool isInside = model->GetCollider()->IntersectsPoint(newTargetPos); if (isInside) { model->SetColor(1, 1, 0, 1); } else { model->SetColor(1, 0, 0, 1); } world->Update(); world->Render(framebuffer); } return 0; }
-
For some reason usual widgets don't change icon at all so had to create little custom widget with AddBlock(); #include "UltraEngine.h" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> menuWold; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> panel; shared_ptr<Widget> btn; bool isFirst = true; class TestWidget : public Widget { protected: virtual void Draw(const int x, const int y, const int width, const int height) { blocks.clear(); int blockId = AddBlock(pixmap, iVec2(0), Vec4(1)); } public: static shared_ptr<TestWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style = 0) { struct Struct : public TestWidget { }; auto instance = std::make_shared<Struct>(); instance->Initialize("", x, y, width, height, parent, style); return instance; } }; void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(menuWold, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); panel = TestWidget::create(10, 50, 64, 64, ui->root); auto icon = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/help.svg"); panel->SetIcon(icon); btn = CreateButton("Change an icon", 10, 10, 150, 20, ui->root); } int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 200, 200, displays[0], WINDOW_DEFAULT); //Create a world menuWold = CreateWorld(); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create light auto light = CreateBoxLight(menuWold); light->SetRange(-10, 10); light->SetRotation(15, 15, 0); light->SetColor(2); //Create camera auto camera = CreateCamera(menuWold); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -3); camera->SetFov(70); initGui(); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); if (ev.source == btn && ev.id == EVENT_WIDGETACTION) { isFirst = !isFirst; if (isFirst) { auto icon = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/help.svg"); //panel->SetPixmap(icon->Rasterize(1)); panel->SetIcon(icon); } else { auto icon2 = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/new.svg"); //panel->SetPixmap(icon2->Rasterize(1)); panel->SetIcon(icon2); } } ui->ProcessEvent(ev); } menuWold->Update(); menuWold->Render(framebuffer); } return 0; }
-
-
Found a way to open conchars and it has only english symbols so maybe font should be in other file but i can't find it.
-
Is that possible to use Quake font from Quake pak in Ultra? Found "conchars" file without format in gfx.wad but have no idea what can i do with that, I have a strong feeling of seeing something like that long time ago but can't find it. Currently i'm using quake-like font from the internet but in game it looks much better and supports few languages in rerelease version. I think it's the only Quake thing left that i'm not using from the Quake pak archive.
-
[UAK] Scrolling the widget with MouseWheel or Slider
Dreikblack replied to mekans's topic in Programming
Mouse scroll works only if scroll bar in focus (cursor on it). But you can fix it by overriding a table or other custom widget method: void ListView::MouseWheel(const int delta, const int x, const int y) { GetParent()->MouseWheel(delta, x, y); } -
[UAK] Scrolling the widget with MouseWheel or Slider
Dreikblack replied to mekans's topic in Programming
Had to port to UAK 6 classes for that Scroll Container.zip This is container that have scroll bars if content of it bigger that its size. You can modify table widget to increase own height when adding a new row. Call container->updateInnerContainerSize() while doing that, Use case: auto contaier = Container::create(10, 10, 600, 200, ui->root, CONTAINER_SCROLL); contaier->addWidget(listView); -
Updated my code - keeping data in another ways (maps), made setDefaultKeys() and a pollEvent() method to process everything inside of class. Still no gamepad support. Never tried to do it before and will look into that much later.
-
I made a controls manager where i'm trying reproduce system from this article but based on Ultra keys events (and no editing for action hotkeys yet) ControlsManager.h: #pragma once #include "UltraEngine.h" using namespace UltraEngine; using json = nlohmann::json; enum ACTION_TYPE { ACTION_CAMERA_MOVE_FORWARD, ACTION_CAMERA_MOVE_BACKWARD, ACTION_CAMERA_MOVE_LEFT, ACTION_CAMERA_MOVE_RIGHT, ACTION_CAMERA_ROTATE_LEFT, ACTION_CAMERA_ROTATE_RIGHT, ACTION_CONFIRM, ACTION_WEAPON_FIRE, ACTION_WEAPON_SPECIAL, ACTION_WEAPON_OVERWATCH, ACTION_UNIT_SWITCH_NEXT, ACTION_UNIT_SWITCH_PREVIOUS, ACTION_INVENTORY, ACTION_COUNT }; class ControlsManager : public Object { protected: ControlsManager(); void init(); WString configPath; json configData; map<KeyCode, bool> keysDown; map<KeyCode, bool> keysUp; map<ACTION_TYPE, vector<KeyCode>> actionsMap; public: ControlsManager(ControlsManager const&) = delete; ControlsManager& operator=(ControlsManager const&) = delete; static std::shared_ptr<ControlsManager> getInstance(); void saveConfig(); void setAction(ACTION_TYPE action, vector<KeyCode> keys); void setDefaultKeys(); void clearActionUp(); void pollEvents(Event event); bool isActionKeyDown(ACTION_TYPE action); bool isActionKeyUp(ACTION_TYPE action); }; ControlsManager.cpp: #include "UltraEngine.h" #include "ControlsManager.h" //#include "SettingsManager.h" ControlsManager::ControlsManager() { init(); } struct StructControlsManager : public ControlsManager { }; void ControlsManager::init() { configPath = AppDir() + "/Saves/Config/Controls.json"; setDefaultKeys(); try { //configData = SettingsManager::getJson(configPath); } catch (const std::invalid_argument& e) { configData = json(); } } std::shared_ptr<ControlsManager> ControlsManager::getInstance() { static std::shared_ptr<ControlsManager> instance = std::make_shared<StructControlsManager>(); return instance; } void ControlsManager::saveConfig() { auto stream = WriteFile(configPath); stream->WriteString(configData.dump()); stream->Close(); } void ControlsManager::setAction(ACTION_TYPE action, vector<KeyCode> keys) { actionsMap[action] = keys; } void ControlsManager::setDefaultKeys() { setAction(ACTION_CAMERA_MOVE_FORWARD, { KEY_W, KEY_UP }); setAction(ACTION_CAMERA_MOVE_BACKWARD, { KEY_S, KEY_DOWN }); setAction(ACTION_CAMERA_MOVE_LEFT, { KEY_A, KEY_LEFT }); setAction(ACTION_CAMERA_MOVE_RIGHT, { KEY_D, KEY_RIGHT }); setAction(ACTION_CAMERA_ROTATE_LEFT, { KEY_Q }); setAction(ACTION_CAMERA_ROTATE_RIGHT, { KEY_E }); setAction(ACTION_CONFIRM, { KEY_SPACE }); setAction(ACTION_WEAPON_FIRE, { KEY_F }); setAction(ACTION_WEAPON_SPECIAL, { KEY_T }); setAction(ACTION_WEAPON_OVERWATCH, { KEY_Y }); setAction(ACTION_UNIT_SWITCH_NEXT, { KEY_TAB }); setAction(ACTION_UNIT_SWITCH_PREVIOUS, { KEY_SHIFT }); setAction(ACTION_INVENTORY, { KEY_I }); } void ControlsManager::clearActionUp() { for (auto& keyUp : keysUp) { keyUp.second = false; } } void ControlsManager::pollEvents(Event event) { switch (event.id) { case EVENT_KEYDOWN: { keysDown[static_cast<KeyCode>(event.data)] = true; keysUp[static_cast<KeyCode>(event.data)] = false; break; } case EVENT_KEYUP: { keysUp[static_cast<KeyCode>(event.data)] = true; keysDown[static_cast<KeyCode>(event.data)] = false; break; } } } bool ControlsManager::isActionKeyDown(ACTION_TYPE action) { if (actionsMap[action].empty()) return false; for (auto& key : actionsMap[action]) { if (keysDown[key]) return true; } return false; } bool ControlsManager::isActionKeyUp(ACTION_TYPE action) { if (actionsMap[action].empty()) return false; for (auto& key : actionsMap[action]) { if (keysUp[key]) return true; } return false; } Game loop (without few parts): while (window->Closed() == false) { controlsManager->clearActionUp(); while (PeekEvent()) { const Event ev = WaitEvent(); switch (ev.id) { default: controlsManager->pollEvents(ev); ui->ProcessEvent(ev); break; } } gameWorld->Update(); gameWorld->Render(framebuffer); } Use case: auto controlsManager = ControlsManager::getInstance(); if (controlsManager->isActionKeyDown(ACTION_CAMERA_MOVE_LEFT)) entity->Move(-speed * 2, 0, 0); if (controlsManager->isActionKeyDown(ACTION_CAMERA_MOVE_RIGHT)) entity->Move(speed * 2, 0, 0);
-
EVENT_KEYUP/EVENT_KEYDOWN or checking KeyHit in loop?
-
Initially i tried to reproduced bug when while changing an icon it was blinking with purple but in test example first icons stays. #include "UltraEngine.h" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> menuWold; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> panel; shared_ptr<Widget> btn; bool isFirst = true; void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(menuWold, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); panel = CreatePanel(10, 50, 64, 64, ui->root, PANEL_DEFAULT); auto icon = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/help.svg"); panel->SetIcon(icon); btn = CreateButton("Change an icon", 10, 10, 150, 20, ui->root); } int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 200, 200, displays[0], WINDOW_DEFAULT); //Create a world menuWold = CreateWorld(); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create light auto light = CreateBoxLight(menuWold); light->SetRange(-10, 10); light->SetRotation(15, 15, 0); light->SetColor(2); //Create camera auto camera = CreateCamera(menuWold); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -3); camera->SetFov(70); initGui(); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); if (ev.source == btn && ev.id == EVENT_WIDGETACTION) { isFirst = !isFirst; if (isFirst) { auto icon = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/help.svg"); panel->SetIcon(icon); } else { auto icon2 = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/new.svg"); panel->SetIcon(icon2); } } ui->ProcessEvent(ev); } menuWold->Update(); menuWold->Render(framebuffer); } return 0; }
-
App freezes after deleting an enitity with a component
Dreikblack replied to Dreikblack's topic in Bug Reports
Fix will be later? Still have this issue after update. -
Was a case for me Updated and tried again today - now works,
-
btw the editor still crashing when i'm trying to open .lmp file (probably i don't really need it, just letting you know).