Search the Community
Showing results for tags 'ultra'.
-
I'm not using the default widget system here, I've made my own and rasterize my fonts to a texture. In this screenshot you can clearly see the problem I have. I added a background shader to the font shader. The text only looks good when on dark backgrounds. You can see the right side is much nicer than the left side. Here's my inventory. I'm unsure if this is a font shader issue - a rasterization issue - or simply I need better font colours depending on the background color. Thought I'd ask to see if any one here might have any tips.
-
Ultimate Action Game Controller ( UAGC ) - One game controller for all situations. Ranged, melee, hand to hand, thrown and magic combat game controller. With UAGC, the developer can select from First-person, Third-Person, Top-Down and Point & Click game controller setups. Each mode features it's own unique style of gameplay made just for that particular gaming situation. The component is designed with ease-of-use in mind, just attach the component to your game player inside the editor and configure the options as you see fit. Follow the worklogs right up until release!
-
Here's a little addon for Blender 4.0 that will export any selected object as a MESH collider for use in Ultra. It may work with other versions of blender but I've not tested it. There are no options for the export process. By default Z is up in Blender so upon export the vertex y and z positions are swapped so that Y is up in Ultra. I could probably add an option to toggle this if it's needed. Any suggestions for improvements are welcome! To Install: Add the folder io_mesh_collider to Blender 4's addon folder. (Blender/4.0/scripts/addons) Launch Blender and navigate to Edit->Preferences Click the add-ons tab look for Import-Export: Ultra Engine Collider and enable it io_mesh_collider.zip
-
Discord for AdvancedProjectManager ProjectManager.zip I made this for Leadwerks years ago and have begun getting it ready for Ultra. Currently it's designed for exporting your projects so that they're ready to share. It can zip files and / or folders, it can encrypt and password protect them. It can also manager the upload process to Steam. It just needs your username, password, APP ID and DEPOT ID and it will upload it for you. Things to do; Bug Fixes Advanced management of project updating First thing to do is set the path to Ultra Engine and the path to your projects. Screenshot
-
Would it be possible disable shadows for a single light in the fragment shader, with some shader manipulation?
-
Here's a small example on how physics on a moving object can be achieved. The physics objects are different to their visual counter parts so that they can be calculated without any rotation. Then using matrix magic the physics position and rotation can be transformed to any moving target. #include "UltraEngine.h" using namespace UltraEngine; Vec3 mousepos = Vec3(0.0f); float move_adjustment = 0.1f; float move_speed = 1.0f; float lookspeed = 0.1f; float looksmoothing = 0.5f; bool enable_camera = true; void UpdatePhysics(shared_ptr<Entity> source, shared_ptr<Entity> target, shared_ptr<Entity> platform = nullptr) { auto pos = source->GetPosition(); auto rot = source->GetRotation(); if (platform != nullptr) { auto matrix = platform->GetMatrix(); matrix = matrix.Inverse(); matrix.t = Vec4(0, 0, 0, 1); pos = TransformPoint(pos, Mat4(), matrix); rot = TransformRotation(rot, Mat4(), matrix); } target->SetPosition(pos); target->SetRotation(rot); } 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, 10, -5); auto light = CreateDirectionalLight(world); light->SetRotation(35, 45, 0); auto floor = CreateBox(world, 10.0f, 0.1f, 10.0f); floor->SetCollider(nullptr); floor->SetPosition(0.0f, -3.0f, 0.0f); floor->SetMaterial(LoadMaterial("Materials\\Developer\\grid01.mat")); auto box = CreateBox(world); box->SetCollider(nullptr); box->SetPosition(2.0f, 2.0f, 0.0f); auto ref = CreateBox(world); ref->SetCollider(nullptr); ref->SetPosition(11, 0, 0); auto player = CreateCylinder(world); player->SetCollider(nullptr); player->SetPosition(0.0f, 5.0f, 0.0f); auto cam_pivot = CreatePivot(world); cam_pivot->SetParent(player); cam_pivot->SetPosition(0.0f, 1.8f, 0.0f); camera->SetParent(cam_pivot); camera->SetPosition(0.0f, 0.0f, -3.0f); camera->SetDebugPhysicsMode(true); //Create physics objects auto f2 = CreatePivot(world); auto ff2 = CreateBoxCollider(10.0f, 0.1f, 10.0f); f2->SetCollider(ff2); f2->SetPosition(0, -3, 0); f2->SetCollisionType(COLLISION_SCENE); auto b2 = CreatePivot(world); auto bb2 = CreateBoxCollider(1.0f, 1.0f, 1.0f); b2->SetCollider(bb2); b2->SetMass(1.0f); b2->SetPosition(2.0f, 2.0f, 0.0f); b2->SetCollisionType(COLLISION_PROP); //player physics object auto player_phys = CreatePivot(world); auto cyl = CreateCylinderCollider(0.5f, 1.0f); player_phys->SetCollider(cyl); player_phys->SetPhysicsMode(PHYSICS_PLAYER); player_phys->SetCollisionType(COLLISION_PLAYER); player_phys->SetMass(1.0f); player_phys->SetPosition(0, 5, 0); bool stage = 0; while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F2) == true) { camera->SetWireframe(!camera->GetWireframe()); } if (window->KeyHit(KEY_F3) == true) { camera->SetDebugPhysicsMode(!camera->GetDebugPhysicsMode()); } if (window->KeyHit(KEY_F4) == true) { enable_camera = !enable_camera; } if (enable_camera) { auto _displaySize = window->GetSize(); float cx = Round((float)_displaySize.x / 2.0f); float cy = Round((float)_displaySize.y / 2.0f); auto mpos = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z); window->SetMousePosition(cx, cy); mpos = mpos * looksmoothing + mousepos * (1 - looksmoothing); auto dx = (mpos.x - cx) * lookspeed; auto dy = (mpos.y - cy) * lookspeed; auto camrot = cam_pivot->GetRotation(); camrot.x += dy; camrot.y += dx; cam_pivot->SetRotation(camrot); mousepos = mpos; } floor->Turn(0.0f, 0.1f, 0.0f); auto y_angle = cam_pivot->GetRotation().y; auto move = 0.0f, strafe = 0.0f; if (window->KeyDown(KEY_W)) { move = 1.0f; } else if (window->KeyDown(KEY_S)) { move = -1.0f; } if (window->KeyDown(KEY_A)) { strafe = -1.0f; } else if (window->KeyDown(KEY_D)) { strafe = 1.0f; } player_phys->SetInput(y_angle, move, strafe); if (window->KeyHit(KEY_P)) { b2->AddForce(0,200,0); } UpdatePhysics(b2, box, floor); UpdatePhysics(player_phys, player, floor); world->Update(); world->Render(framebuffer); } return 0; }
-
I made this so that I didn't have to convert my entire Leadwerks projects straight away. With this you can still use (most of) Leadwerks style drawing commands. It's not perfect, maybe not even finished (haven't used it in a while) but at the bare minimum some of you may be able to use / learn from it! LegacyCanvas.zip
-
{ "component": { "properties": [ { "name": "teamId", "label": "Team id", "value": 2 }, { "name": "health", "label": "Health", "value": 10 }, { "name": "textureName", "label": "Texture", "value": "city4_2" } ] } } Same problem with default component if i move it to same folder
-
After resizing icon of yellow armor becomes a blue one. Red also becomes blue. Green stays green. Used to be fine several months ago. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> world; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> panel; shared_ptr<Widget> panel2; bool isFirst = true; void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(world, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); uiCamera = CreateCamera(world, 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, 10, 50, 50, ui->root, PANEL_DEFAULT); panel2 = CreatePanel(10, 70, 100, 100, ui->root, PANEL_DEFAULT); auto pixmap = LoadPixmap("/gfx/items.wad/armor2");//yellow armor panel->SetPixmap(pixmap); auto pixmap2 = pixmap->Resize(pixmap->size.x * 1.5f, pixmap->size.y * 1.5f);//blue now O_o panel2->SetPixmap(pixmap2); } int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 300, 300, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world world = CreateWorld(); world->SetAmbientLight(0); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Load FreeImage plugin auto plg = LoadPlugin("Plugins/FITextureLoader"); auto quakeLoaderPlugin = LoadPlugin("Plugins/QuakeLoader"); //Load model WString path = AppDir(); auto pak = LoadPackage(path + "/PAK0.PAK"); ChangeDir(path); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0, 0, 0); camera->Move(0, 0, -0.3); camera->SetRange(0.01, 100); camera->SetFov(70); initGui(); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
-
#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<Icon> icon1; shared_ptr<Icon> icon2; 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); icon1 = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/help.svg"); icon2 = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Icons/new.svg"); panel->SetIcon(icon1); } 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) { isFirst = !isFirst; if (isFirst) { panel->SetIcon(icon1); } else { panel->SetIcon(icon2); } menuWold->Update(); menuWold->Render(framebuffer); } return 0; }
-
For example in ThirdPersonControls virtual void Start() { smoothcameradistance = followdistance; auto entity = GetEntity(); entity->SetPhysicsMode(PHYSICS_PLAYER); if (entity->GetMass() == 0.0f) entity->SetMass(78); entity->SetCollisionType(COLLISION_PLAYER); //here auto collider = CreateMeshCollider(entity->As<Model>()); if (collider) entity->SetCollider(collider); camera = CreateCamera(entity->GetWorld()); camera->SetPosition(0, eyeheight, 0); camera->SetRotation(0, 0, 0); camera->SetFov(70); currentcameraposition = camera->GetPosition(true); freelookrotation = entity->GetRotation(true); }
-
Editor saves Quake models as: "package": "pak0.pak", "path": "progs/player.mdl" But if game loads a pak0 from not a game folder model is not being loaded. if i change manually to "path": "C:/Program Files (x86)/Steam/steamapps/common/Quake/rerelease/id1/progs/player.mdl" editor can't load a model. I can't find a proper way to edit .ultra map in code. stream->ReadWString() returns hieroglyphs from a map. What's a best approach to make Quake models loads in Editor and in a game?
-
1. Create brush and material. 2. Apply texture to material: Saved locally this texture for test purpose https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/tiles.dds 3. Save a map with a brush. 4. Load map - no texture on brush. I can see it in a map file with a text editor. #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_CENTER | WINDOW_TITLEBAR); //Load FreeImage plugin auto plg = LoadPlugin("Plugins/FITextureLoader"); //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->SetPosition(0, 1, -4); //Create light auto light = CreateBoxLight(world); light->SetRange(-10, 10); light->SetArea(15, 15); light->SetRotation(45, 35, 0); light->SetColor(2); //Create a scene auto scene = CreateMap(); scene->entities.push_back(camera); scene->entities.push_back(light); //Load model auto t = CreateBoxBrush(world, 1, 1, 1); auto texture = LoadTexture("tiles.dds"); auto material = CreateMaterial(); material->SetTexture(texture); t->SetMaterial(material); scene->entities.push_back(t); scene->Save("game.sav"); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_SPACE)) { scene = LoadMap(world, "game.sav"); } world->Update(); world->Render(framebuffer); } return 0; }
-
Playing sounds simultaneously causes a crash when last sounds stop playing. Happens if world created and rendered. When i tried to do it with no world, only one sound played and no crash happened. Steam beta branch. Several months ago had no such problem. #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, 300, 300, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Load FreeImage plugin auto sound = LoadSound("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Sound/notification.wav"); int i = 0; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (i < 10) { sound->Play(); i++; } world->Update(); world->Render(framebuffer); } return 0; }
-
Steam beta branch. When i first time create widgets it's works. But when i destroy them and create new ones in a same vector they are invisible. It worked several months ago. Need that for an inventory gui. #include "UltraEngine.h" using namespace UltraEngine; class ContainerWidget : public Panel { vector<shared_ptr<Widget>> btns; protected: virtual bool Initialize(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent) { btns.resize(4); return Widget::Initialize(text, x, y, width, height, parent, style); } public: void initBtns() { clearBtns(); for (int i = 0; i < btns.size(); i++) { btns[i] = CreateButton("Btn", i * 50 + 10, 0, 20, 20, Self()->As<Widget>()); } } void clearBtns() { for (int i = 0; i < btns.size(); i++) { if (btns[i]) { btns[i]->SetParent(nullptr); btns[i] = nullptr; } } } static shared_ptr<ContainerWidget> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent) { struct Struct : public ContainerWidget { }; auto instance = std::make_shared<Struct>(); instance->Initialize(x, y, width, height, parent); instance->SetColor(0.5, 0.5, 0.5, 1, WIDGETCOLOR_BACKGROUND); instance->initBtns(); return instance; } }; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> menuWold; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> btn; shared_ptr<ContainerWidget> container; 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); container = ContainerWidget::create(10, 50, 200, 50, ui->root); btn = CreateButton("Reinit buttons", 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, 300, 300, 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) { container->initBtns(); } ui->ProcessEvent(ev); } menuWold->Update(); menuWold->Render(framebuffer); } return 0; }
-
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; }
-
While the example here works, it seems if you are overlaying an interface over a 3D environment the panel won't show the assigned texture. I first noticed this in my project where I wanted to show the real-time render of a 2nd camera on the panel. #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]); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); ui->background->SetColor(0, 0, 0, 0); //Create and position camera auto camera = CreateCamera(world); camera->SetPosition(0, 1, -2); int RENDERLAYER_1 = 2; auto ui_camera = CreateCamera(world, UltraEngine::PROJECTION_ORTHOGRAPHIC); ui_camera->SetRenderLayers(RENDERLAYER_1); ui_camera->SetPosition(framebuffer->size.x / 2.0f, framebuffer->size.y / 2.0f); ui_camera->SetClearMode(UltraEngine::CLEAR_DEPTH); auto panel = CreatePanel(0, 0, 512, 512, ui->root); auto tex = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/river_small_rocks_diff_4k.dds"); panel->SetTexture(tex); auto box = CreateBox(world); box->SetColor(1, 0, 0); while (true) { while (UltraEngine::PeekEvent()) { auto event = UltraEngine::WaitEvent(); switch (event.id) { case UltraEngine::EVENT_WINDOWCLOSE: if (event.source == window) { return 0; } break; } ui->ProcessEvent(event); } world->Update(); world->Render(framebuffer); } return 0; }
-
When used Crahs the Editor.
-
Reproducing the error 1. Look at the texture toolbar and close. 2. Open a material and close it. 3. Look at texture toolbar. Or show View.
-
Now that this works - should it be that physics bodies in two separate worlds can still collide? Or is it up to the user to disable those collisions themselves?
-
I'm getting random crashes with this code. Physics in two worlds not supported? #include "UltraEngine.h" using namespace UltraEngine; Vec3 mousepos = Vec3(0.0f); float move_adjustment = 0.1f; float move_speed = 1.0f; float lookspeed = 0.1f; float looksmoothing = 0.5f; bool enable_camera = 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, 10, -5); auto light = CreateDirectionalLight(world); light->SetRotation(35, 45, 0); auto floor = CreateBox(world, 10.0f, 0.1f, 10.0f); floor->SetPosition(0.0f, -3.0f, 0.0f); floor->SetMaterial(LoadMaterial("Materials\\Developer\\bluegrid.mat")); auto box = CreateBox(world); box->SetCollider(nullptr); box->SetPosition(2.0f, 2.0f, 0.0f); auto player = CreateCylinder(world); player->SetPhysicsMode(PHYSICS_PLAYER); player->SetPosition(0.0f, 5.0f, 0.0f); player->SetMass(1.0f); auto cam_pivot = CreatePivot(world); cam_pivot->SetParent(player); cam_pivot->SetPosition(0.0f, 1.8f, 0.0f); camera->SetParent(cam_pivot); camera->SetPosition(0.0f, 0.0f, -3.0f); camera->SetDebugPhysicsMode(true); auto world_2 = CreateWorld(); auto f2 = CreateBox(world_2, 10.0f, 0.1f, 10.0f); auto b2 = CreateBox(world_2); b2->SetMass(1.0f); b2->SetPosition(2.0f, 10.0f, 0.0f); bool stage = 0; while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F2) == true) { camera->SetWireframe(!camera->GetWireframe()); } if (window->KeyHit(KEY_F3) == true) { camera->SetDebugPhysicsMode(!camera->GetDebugPhysicsMode()); } if (window->KeyHit(KEY_F4) == true) { enable_camera = !enable_camera; } if (enable_camera) { auto _displaySize = window->GetSize(); float cx = Round((float)_displaySize.x / 2.0f); float cy = Round((float)_displaySize.y / 2.0f); auto mpos = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z); window->SetMousePosition(cx, cy); mpos = mpos * looksmoothing + mousepos * (1 - looksmoothing); auto dx = (mpos.x - cx) * lookspeed; auto dy = (mpos.y - cy) * lookspeed; auto camrot = cam_pivot->GetRotation(); camrot.x += dy; camrot.y += dx; cam_pivot->SetRotation(camrot); mousepos = mpos; } world_2->Update(); world->Update(); world->Render(framebuffer); } return 0; }
-
I want to be able have physics working on various different platforms that each have there own velocity and rotations happening. (In this example I'm just turning the floor object, so that might be the wrong way to do that.) On each platform I'd want to have physics working normally as though each platform is it's own little physics world, oblivious to the fact that it's platform is moving about. Just like we can walk on Earth and not feel like were hurtling around the sun and around the Earths axis. I guess this is similar to parenting a player controller to an elevator that moves left and right so the player doesn't slide off the platform as it moves. As the GIF shows, simply parenting the box to the floor breaks the physics sim I think. But the concept is what I'm trying to achieve. The same goes for parenting the player controller to the floor. It looks like it wants to work the way I intend, it just keeps bouncing back and forth. Any one know if this might be possible? #include "UltraEngine.h" using namespace UltraEngine; Vec3 mousepos = Vec3(0.0f); float move_adjustment = 0.1f; float move_speed = 1.0f; float lookspeed = 0.1f; float looksmoothing = 0.5f; bool enable_camera = 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, 10, -5); auto light = CreateDirectionalLight(world); light->SetRotation(35, 45, 0); auto floor = CreateBox(world, 10.0f, 0.1f, 10.0f); floor->SetPosition(0.0f, -3.0f, 0.0f); floor->SetMaterial(LoadMaterial("Materials\\Developer\\bluegrid.mat")); auto box = CreateBox(world); box->SetMass(1.0f); box->SetPosition(2.0f, 2.0f, 0.0f); box->SetParent(floor); auto player = CreateCylinder(world); player->SetPhysicsMode(PHYSICS_PLAYER); player->SetPosition(0.0f, 5.0f, 0.0f); player->SetMass(1.0f); auto cam_pivot = CreatePivot(world); cam_pivot->SetParent(player); cam_pivot->SetPosition(0.0f, 1.8f, 0.0f); camera->SetParent(cam_pivot); camera->SetPosition(0.0f, 0.0f, -3.0f); camera->SetDebugPhysicsMode(true); bool stage = 0; while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F2) == true) { camera->SetWireframe(!camera->GetWireframe()); } if (window->KeyHit(KEY_F3) == true) { camera->SetDebugPhysicsMode(!camera->GetDebugPhysicsMode()); } if (window->KeyHit(KEY_F4) == true) { enable_camera = !enable_camera; } if (enable_camera) { auto _displaySize = window->GetSize(); float cx = Round((float)_displaySize.x / 2.0f); float cy = Round((float)_displaySize.y / 2.0f); auto mpos = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z); window->SetMousePosition(cx, cy); mpos = mpos * looksmoothing + mousepos * (1 - looksmoothing); auto dx = (mpos.x - cx) * lookspeed; auto dy = (mpos.y - cy) * lookspeed; auto camrot = cam_pivot->GetRotation(); camrot.x += dy; camrot.y += dx; cam_pivot->SetRotation(camrot); mousepos = mpos; } floor->Turn(0.0f, 0.1f, 0.0f); auto y_angle = cam_pivot->GetRotation().y; auto move = 0.0f, strafe = 0.0f; if (window->KeyDown(KEY_W)) { move = 1.0f; } else if (window->KeyDown(KEY_S)) { move = -1.0f; } if (window->KeyDown(KEY_A)) { strafe = -1.0f; } else if (window->KeyDown(KEY_D)) { strafe = 1.0f; } player->SetInput(y_angle, move, strafe); world->Update(); world->Render(framebuffer); } return 0; }
-
Now I think this is a bug... the cylinder falls and lands half way up. It moves around fine. I get it there's an offset of 0.5 but in this case I do not know how to fix it. Modify the vertices? Will that update the collider model too? What shape is the player controller? Is it not using the collider of the model I set PHYSICS_PLAYER on? #include "UltraEngine.h" using namespace UltraEngine; Vec3 mousepos = Vec3(0.0f); float move_adjustment = 0.1f; float move_speed = 1.0f; float lookspeed = 0.1f; float looksmoothing = 0.5f; bool enable_camera = 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, 10, -5); auto light = CreateDirectionalLight(world); light->SetRotation(35, 45, 0); auto floor = CreateBox(world, 10.0f, 0.1f, 10.0f); floor->SetPosition(0.0f, -3.0f, 0.0f); floor->SetMaterial(LoadMaterial("Materials\\Developer\\bluegrid.mat")); auto box = CreateBox(world); box->SetMass(1.0f); box->SetPosition(2.0f, 2.0f, 0.0f); auto player = CreateCylinder(world); player->SetPhysicsMode(PHYSICS_PLAYER); player->SetPosition(0.0f, 5.0f, 0.0f); player->SetMass(10.0f); auto cam_pivot = CreatePivot(world); cam_pivot->SetParent(player); cam_pivot->SetPosition(0.0f, 1.8f, 0.0f); camera->SetParent(cam_pivot); camera->SetPosition(0.0f, 0.0f, -3.0f); camera->SetDebugPhysicsMode(true); bool stage = 0; while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F2) == true) { camera->SetWireframe(!camera->GetWireframe()); } if (window->KeyHit(KEY_F3) == true) { camera->SetDebugPhysicsMode(!camera->GetDebugPhysicsMode()); } if (window->KeyHit(KEY_F4) == true) { enable_camera = !enable_camera; } if (enable_camera) { auto _displaySize = window->GetSize(); float cx = Round((float)_displaySize.x / 2.0f); float cy = Round((float)_displaySize.y / 2.0f); auto mpos = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z); window->SetMousePosition(cx, cy); mpos = mpos * looksmoothing + mousepos * (1 - looksmoothing); auto dx = (mpos.x - cx) * lookspeed; auto dy = (mpos.y - cy) * lookspeed; auto camrot = cam_pivot->GetRotation(); camrot.x += dy; camrot.y += dx; cam_pivot->SetRotation(camrot); mousepos = mpos; } auto y_angle = cam_pivot->GetRotation().y; auto move = 0.0f, strafe = 0.0f; if (window->KeyDown(KEY_W)) { move = 1.0f; } else if (window->KeyDown(KEY_S)) { move = -1.0f; } if (window->KeyDown(KEY_A)) { strafe = -1.0f; } else if (window->KeyDown(KEY_D)) { strafe = 1.0f; } player->SetInput(y_angle, move, strafe); world->Update(); world->Render(framebuffer); } return 0; }