Jump to content

SpiderPig

Members
  • Posts

    2,383
  • Joined

  • Last visited

Everything posted by SpiderPig

  1. 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; }
  2. 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; }
  3. 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; }
  4. Can we get Abs() to take a Vec3? 🤔
  5. Ah yes. That did the trick. GetBounds(BOUNDS_RECURSIVE)
  6. 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; } Cubes.zip
  7. I think I just need better environment maps.
  8. Okay now that I see them side by side they're not too much different. The one in blender does look better though. Looks more specular. Lighting is not my strength. Blender: Game:
  9. 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...
  10. 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?
  11. That's pretty much what I'm doing now.
  12. 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; }
  13. 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 }
  14. 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.
  15. Thanks its all working now. 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.
  16. Okay thanks. I need to read that book too. I don't know enough about them. 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?
  17. 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; }
  18. Okay, I will collect everything into a smaller project for you tomorrow evening.
  19. Thanks that worked. You are correct. Although it gives me an idea on what's going on it doesn't help me much. But it is cool to see it break to the physics code and at least tell me something. Your welcome to remote debug if you wish.
  20. Looks pretty cool! I'll be honest though I have never played any of those games. Looking forward to giving it a go. Good job!
  21. I think I've compile the right one "newton-dynamics-master\newton-3.14\sdk\projects\visualStudio_2015_dll", I copied the "newton_d.dll" that was generated into my project and it crashes. Nothing is ever easy. I also tried replacing "dCustomJoints_d.dll" but it gave a similar error. Perhaps some things have changed? The DLL is also about 2mb bigger than the one shipped with Ultra. Anyway it's here if you like to try it for yourself. I don't know how I'm going to pinpoint theses errors without debugging newton but we will see. newton_d.zip
  22. Are we able to debug newton ourselves? Is that possible?
  23. My example is working now but I still get crashes in my voxel terrain project. There must be something else going on.
  24. I'm downloading it now. Do you mean you perfected the triangle size test for CreateCollsionMesh()?
×
×
  • Create New...