-
Posts
2,399 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Posts posted by SpiderPig
-
-
Hmm, it possibly will then. I'll try it. I'm sure the vector joint would still come in handy though.
-
I'm not sure... a kinematic joint would allow rotation on all three axis still? A vector joint only allows rotation around the vector itself.
-
I think Leadwerks had this... can we get this for Ultra too?
CreateVectorJoint()
Would also need to change its pin as well... something Leadwerks didn't allow from memory.
vector->SetPin(0, 1, 0)
-
I use AddForce() for moving physics bodies toward multiple gravity sources so I need a controller that will respond to that as well as being able to have the up direction dynamically changed.
-
In Leadwerks I used to be able to make a player controller and turn off gravity for that entity and just use AddForce() for my own gravity system. I didn't see a problem with doing it this way for rigid bodies, but I never did think it was a good idea for the character controller. Doesn't seem to work in Ultra anyway and in all fairness that's okay because I am going to have to make my own controller I think.
I'm going to post a few attempts here and see if I can't finally get this to work the way I want!
This used to work in Leadwerks:
#include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world); camera->Move(0, 2, -3); camera->SetClearColor(1, 0, 0); auto light = CreateDirectionalLight(world); light->SetRotation(35, 35, 35); auto floor = CreateBox(world, 100.0f, 0.5f, 100.0f); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->size); ui->SetRenderLayers(2); 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(2); ui_camera->SetClearMode(CLEAR_DEPTH); auto m = CreateCylinder(world, 0.5f, 1.8f); m->SetPhysicsMode(PHYSICS_PLAYER); m->SetPosition(0, 5, 0); m->SetMass(1.0f); m->SetGravityMode(false); while (true) { m->AddForce(0.0f, -9.8f, 0.0f); world->Update(); world->Render(framebuffer); } return 0; }
-
I've only had this happen when using a custom widget. If you hide the parent of the custom widget before at least one loop it will crash.
#include "Engine.h" using namespace UltraEngine; //Declare new style constants enum CustomWidgetStyle { CUSTOMWIDGET_DEFAULT = 0 }; //Declare new widget class class CustomWidget : public Widget { bool hover; protected: virtual bool Initialize(const WString& text, const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const int style) { return Widget::Initialize(text, x, y, width, height, parent, style); } //Called when the mouse moves if this widget has the focus virtual void MouseMove(const int x, const int y) {} //Called when the mouse cursor enters the widget bounds virtual void MouseEnter(const int x, const int y) { hover = true; Redraw(); } //Called when the mouse cursor leaves the widget bounds virtual void MouseLeave(const int x, const int y) { hover = false; Redraw(); } //Called when the mouse button is pressed virtual void MouseDown(const MouseButton button, const int x, const int y) { if (button == MOUSE_LEFT) EmitEvent(EVENT_WIDGETACTION, Self()); } //Called when the mouse button is released virtual void MouseUp(const MouseButton button, const int x, const int y) {} //Called when another widget becomes selected virtual void LoseFocus() {} //Called when mouse double-click occurs virtual void DoubleClick(const MouseButton button, const int x, const int y) {} //Called when mouse triple-click occurs virtual void TripleClick(const MouseButton button, const int x, const int y) {} //Called when widget is selected virtual void GainFocus() {} //Called when key is pressed virtual void KeyDown(const KeyCode key) {} //Called when key is released virtual void KeyUp(const KeyCode key) {} //Called for each keydown event virtual void KeyChar(const int keychar) {} //Called when mouse wheel turns and mouse is hovered over this widget virtual void MouseWheel(const int delta, const int x, const int y) {} //Called each time the widget is redrawn virtual void Draw(const int x, const int y, const int width, const int height) { blocks.clear(); AddBlock("Text", iVec2(0), this->size, Vec4(1), TEXT_CENTER | TEXT_MIDDLE); } public: //Constructor CustomWidget() : hover(false) {} friend shared_ptr<Widget> CreateCustomWidget(const WString&, const int, const int, const int, const int, shared_ptr<Widget>, const CustomWidgetStyle); }; //Create function shared_ptr<Widget> CreateCustomWidget(const WString& text, const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, const CustomWidgetStyle style) { auto widget = std::make_shared<CustomWidget>(); widget->Initialize(text, x, y, width, height, parent, style); return widget; } int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world); camera->Move(0, 0, -3); camera->SetClearColor(1, 0, 0); auto box = CreateBox(world); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->size); ui->SetRenderLayers(2); 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(2); ui_camera->SetClearMode(CLEAR_DEPTH); //Create widget auto panel = CreatePanel(10, 10, 100, 100, ui->root); auto widget = CreateCustomWidget("Custom", 20, 20, 50, 30, panel, CUSTOMWIDGET_DEFAULT); while (true) { panel->SetHidden(true);//Causes crash while (PeekEvent()) { auto ev = WaitEvent(); ui->ProcessEvent(ev); } // panel->SetHidden(true);//No crash here world->Update(); world->Render(framebuffer); } return 0; }
-
I believe it is just like calling Abs() for each of the x, y & z components of the vector. Saves time writing it out all the time.
Vec3 Abs(Vec3 value) { value.x = Abs(value.x); value.y = Abs(value.y); value.z = Abs(value.z); return value; }
-
Can we get Abs() to take a Vec3? 🤔
- 2
-
Ah yes. That did the trick.
GetBounds(BOUNDS_RECURSIVE)
- 1
-
The bounds are returning 0 size for some objects I'm loading. I think its when there are two or more entities in the file. Here cube1 shows the correct bounds size but cube2 (has two cubes in it) returns 0.
#include "Engine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.0f, 0.0f, 1.0f); camera->SetFov(70); camera->SetRange(0.01f, 1000.0f); camera->SetPosition(0, 1, -3); auto light = CreateDirectionalLight(world); light->SetColor(5.0f); light->SetRotation(35, 45, 0); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); ui->SetRenderLayers(2); 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(2); ui_cam->SetClearMode(CLEAR_DEPTH); auto label = CreateLabel("", 10, 10, 200, 30, ui->root); auto cube1 = LoadModel(world, "Cube.gltf"); auto cube2 = LoadModel(world, "Cube2.gltf"); auto b1 = cube1->GetBounds(); auto b2 = cube2->GetBounds(); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { label->SetText("Size1 : " + String(b1.size.x) + ", " + String(b1.size.y) + ", " + String(b1.size.z) + "\n" "Size2 : " + String(b2.size.x) + ", " + String(b2.size.y) + ", " + String(b2.size.z)); world->Update(); world->Render(framebuffer, false); } return 0; }
-
I think I just need better environment maps.
-
-
I thought it might look better. Although the colours do look more washed out than in blender. Especially the greys. I'll take a screenshot...
-
I'm going to be using a lot of low poly assets (flat shading and plain colours - only a diffuse texture which sets the colour per triangle) and I'm not sure if the PBR lighting should be used still or if I should use the classic shading?
-
That's pretty much what I'm doing now.
-
I wonder if we could get the current update frequency of the world? I could probably store a variable for this somewhere myself actually but just wondering.
float convertRPM(float rpm) { auto frequency = (world->update_frequency * 60.0f) / rpm; return 360.0f / frequency; }
-
Sweet, thanks!
-
Is there a need for something like this in Ultra or is the game loop frequency manged by the engine as indicated by world::Update()'s frequency parameter?
uint64_t time_span = 1000;//ms uint64_t time_interval = 100;//ms uint64_t start_time = Millisecs(); float range = 90.0f; float inc = range / (float)(time_span / time_interval); //loop auto result = 0.0f; uint64_t current_time = Millisecs(); if (current_time >= start_time + time_interval) { start_time = current_time; result += inc;//Should be approx 90.0f after a second }
-
I don't think there is as Josh has said that the depth value can change overtime. You can read the depth value of a widget with Widget::z but this is a temporary member so I wouldn't rely on it.
-
Thanks its all working now.
26 minutes ago, Josh said:BTW, it seems a lot of your colliders consist of 1-2 triangles. This is probably very inefficient and it would be better if they were in bigger pieces, but that should still not cause a crash like you were experiencing.
They do and I was actually wondering if it would be better to make less colliders with more triangles each so I will do this.
-
Okay thanks. I need to read that book too. I don't know enough about them.
3 hours ago, Josh said:Each entity stores its rotation in both Euler and quaternion form, and these are kept in sync whenever rotation changes. The Turn method uses quaternions to accurately turn the entity, and then fills in the entity's Euler rotation value by converting it from the resulting quaternion.
I want to rotate an object back and forth on the x axis between 0 and 90 degrees. I thought GetRotation() should return Euler angles?
-
Getting the rotation of an object doesn't seem to go past 90 degrees on any one axis. E.g. I turn the box along the x axis but it only just gets to 90 degrees then starts counting down again and the y and z axis flip to 180 at around 45 degrees as it counts down on the x. This probably has something to do with quaternions but I do not know for sure.
#include "Engine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.0f, 0.0f, 1.0f); camera->SetFov(70); camera->SetRange(0.01f, 1000.0f); camera->SetPosition(0, 1, -3); auto light = CreateDirectionalLight(world); light->SetColor(5.0f); light->SetRotation(35, 45, 0); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); ui->SetRenderLayers(2); 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(2); ui_cam->SetClearMode(CLEAR_DEPTH); auto label = CreateLabel("", 10, 10, 200, 30, ui->root); auto box = CreateBox(world); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { box->Turn(0.25f, 0.0f, 0.0f); auto local = box->GetRotation(); auto global = box->GetRotation(true); label->SetText("Local : " + String(local.x) + ", " + String(local.y) + ", " + String(local.z) + "\n" "Global : " + String(global.x) + ", " + String(global.y) + ", " + String(global.z)); world->Update(); world->Render(framebuffer, false); } return 0; }
-
Okay, I will collect everything into a smaller project for you tomorrow evening.
-
Kinematic Joint Shadow Glitch
in Bug Reports
Posted
Not a big deal but here it is anyway. Tap the W key quickly and you will see that the shadow lags and creates a dark spot briefly on the cylinder.