Jump to content

reepblue

Developers
  • Posts

    2,600
  • Joined

  • Last visited

Everything posted by reepblue

  1. Thought about this more, might not be a bug since it may conflict camera orientation based on the movement on the mouse. I may just be doing something that wasn't intended,
  2. While the head moves around in virtual space, the camera's quaternion remains at (0,0,0,0). You need to manually update its quaternion with the following. entity->SetQuaternion(VR::headsetrotation); This only happened with seated mode. In Roomscale, the camera's rotation/quaternion updates as expected.
  3. I'll be sure to try again. If it's still crashing, I'll file a bug report.
  4. Issue was applying a new material to the controllers crashes the app.
  5. Ok, I found the real cause. You'll get this issue when the post processing stack is empty. Adding something you'll want to use anyway like bloom fixes it. Updating the title to more pinpoint the issue. Although post process effects don't draw in VR, adding something to the stack will result this issue being patched.
  6. Update: It goes away when water is enabled - Only if the reflections on that are enabled. (Medium or greater) A temp fix is to add discard; on top of ragment entry point with water enabled. It still cuts your frames down tho, ? also water needs to be at 0.0
  7. envprobe.map After creating the second probe, the aabb bounds become visible through brushes/geometry. Also noticed that now selecting the probes in the AI and Events map now crashes. Getting this on my AMD Radeon RX480.
  8. That's funny, I swore I saw one in the SDK.. ?
  9. I encountered this issue. I think this returns the override material, (When the material is set via SetMaterial rather than the material applied via model editor.)
  10. This does not seem to happen with character controllers. I probably missed this when making my button as I only use the collision function to add an entity to a list if it's not already part of the list.
  11. I want to double check this with the character controller when I come home.
  12. All I do is fps stuff and I have seen no issues. Again, I never was looking for a problem.
  13. I'll give the marble game a look sometime. I think it has something to do with the collision mode being "Character" and it not being a character controller. I think my script uses a custom aabb test. The engine has a way to test if an entity is in its aabb. I use that function now.
  14. While we have Leadwerks today to make our apps, Turbo is currently in development. To make my projects more long term, I decided to take a step back from my VR project and create a wrapper class that apps can use to more easily transfer to the new engine. Keep in-mind, this doesn't cover everything and I'm used the last beta from November for testing so things can change. Regardless, as long as that bridge is made, I can always go back and edit the Turbo stuff as more things come online. The goal is to make the Leadwerks stuff compatible with the new tech. This code works on both engines. #include "GameEngine.hpp" using namespace ENGINE_NAMESPACE; int main(int argc, const char *argv[]) { auto window = Create_Window("MyGame"); auto context = Create_Context(window); auto world = Create_World("Maps/testrender.map"); while (window->Closed() == false) { if (window->KeyHit(KEY_ESCAPE)) break; UpdateWorld(); RenderWorld(); #ifndef TURBO_ENGINE context->Sync(true); #endif } return 0; } As you can see, I went with with the cleaner style of the new engine. The only thing is ugly is the context syncing for Leadwerks, I didn't want wrap that since context syncing is totally different between Leadwerks and the new engine. Marcos! To comply with the new engine's integer values, I've defined a few macros that is only defined in Leadwerks. While this doesn't cover everything right now, So far I got the Window stuff, Collision, and all keys defined! #ifndef TURBO_ENGINE // ------------- // Window: // ------------- #define WINDOW_TITLEBAR Window::Titlebar #define WINDOW_RESIZABLE Window::Resizable #define WINDOW_HIDDEN Window::Hidden #define WINDOW_CENTER Window::Center #define WINDOW_FULLSCREEN Window::FullScreen // ------------- // Color: // ------------- #define COLOR_DIFFUSE Leadwerks::Color::Diffuse #define COLOR_SPECULAR Leadwerks::Color::Specular #define COLOR_EDIT Leadwerks::Color::Edit // ------------- // Collision: // ------------- #define COLLISION_NONE Collision::None #define COLLISION_PROP Collision::Prop #define COLLISION_SCENE Collision::Scene #define COLLISION_CHARACTER Collision::Character #define COLLISION_TRIGGER Collision::Trigger #define COLLISION_DEBRIS Collision::Debris #define COLLISION_COLLIDE Collision::Collide // Not Turbo'd #define COLLISION_PROJECTILE Collision::Projectile // Not Turbo'd #define COLLISION_LINEOFSIGHT Collision::LineOfSight // Not Turbo'd #define COLLISION_FLUID Collision::Fluid // Not Turbo'd #define COLLISION_LASTENTRY COLLISION_FLUID // Not Turbo'd Shared Pointers vs Raw The new engine uses smart pointers to replace the current reference system. I needed macros to address this to prevent my code being #ifdef/#endif living Hell. // Smart Pointers vs Raw Pointers #ifdef TURBO_ENGINE #define ENGINE_OBJECT(x) std::shared_ptr<x> #define ENGINE_OBJECT_RELEASE(x) if (x != nil) { x->Free(); x = nil; } #define ENGINE_REFERENCE(x) std::weak_ptr<x> #define ENGINE_CAST(_class_, _pointer_) dynamic_pointer_cast<_class_>(_pointer_); #else #define ENGINE_OBJECT(x) x* #define ENGINE_OBJECT_RELEASE(x) if (x != nil) { x->Release(); x = nil; } #define ENGINE_REFERENCE(x) x* #define ENGINE_CAST(_class_, _pointer_) (_class_*)_pointer_ #endif To my surprise, you don't delete an entity alone calling something like "model = NULL". This is because the world class keeps a list of all entities in the world via a shared pointer. Instead (for right now) you call the Free command to totally remove the model. Another thing to note is that with Leadwerks, ENGINE_REFERENCE is the same as ENGINE_OBJECT. while ENGINE_REFERENCE is a weak pointer. Setters and Getters. First thing first, I needed to redefine the the Setters/Getters system from Leadwerks. While the decision to remove this functionality opens the door for more possiblites thanks to the new engine's architecture, In my five years of using Leadwerks, I never had a needed more than one world/context/window for most use cases. //----------------------------------------------------------------------------- // Purpose: We still need Getters/Setters to comply with LE code. //----------------------------------------------------------------------------- namespace ENGINE_NAMESPACE { void SetCurrentWindow(ENGINE_OBJECT(Window) pWindow); void SetCurrentContext(ENGINE_OBJECT(Context) pContext); void SetCurrentWorld(ENGINE_OBJECT(World) pWorld); void SetCurrentCamera(ENGINE_OBJECT(Camera) pCamera); ENGINE_OBJECT(Window) GetCurrentWindow(); ENGINE_OBJECT(Context) GetCurrentContext(); ENGINE_OBJECT(World) GetCurrentWorld(); ENGINE_OBJECT(Camera) GetCurrentCamera(); } While in Turbo, the object are assigned to pointers in the cpp file, In Leadwerks, this is just a wrapper for the Set/GetCurrent functions. Then we have wrapper functions for every create and load function. So we just do this to set our currents. // Creates a window. ENGINE_OBJECT(Window) Create_Window(const std::string& pszTitle, const int x, const int y, const int iWidth, const int iHeight, const int iStyle, ENGINE_OBJECT(Window) pParent) { #ifndef TURBO_ENGINE auto window = Window::Create(pszTitle, x, y, iWidth, iHeight, iStyle, pParent); #else auto window = CreateWindow(pszTitle, x, y, iWidth, iHeight, iStyle, pParent); #endif SetCurrentWindow(window); #ifdef WIN32 window->SetActive(); #endif return window; } // Creates a Context. ENGINE_OBJECT(Context) Create_Context(ENGINE_OBJECT(Window) pWindow) { #ifndef TURBO_ENGINE auto context = Context::Create(pWindow); #else auto context = CreateContext(pWindow); #endif SetCurrentContext(context); return context; } World How the world loads scenes between the two engines is completely different! In Turbo, the map is loaded to a shared pointer in which you can throw around your application while in Leadwerks it's just a static function call. As the goal is to just make a compatibility layer, I just had to do something like this: // Loads a scene into the current world. bool Load_Scene(const std::string& pszPath, void hook(ENGINE_OBJECT(Entity) entity, ENGINE_OBJECT(Object) extra)) { #ifdef TURBO_ENGINE if (m_pCurrentWorld.lock() == nil) return false; if (FileSystem::GetFileType(pszPath) == 0) { Msg("Error: Failed to load scene file " + ENGINE_NAMESPACE::FileSystem::FixPath(pszPath) + "\"...") return false; } auto scene = Turbo::LoadScene(GetCurrentWorld(), pszPath); // There is no C++ maphooks rn. :( return scene != nil; #else return Map::Load(pszPath, hook); #endif } // Creates a world. ENGINE_OBJECT(World) Create_World(const std::string& pszPath) { #ifdef TURBO_ENGINE auto world = CreateWorld(); #else auto world = World::Create(); #endif SetCurrentWorld(world); if (pszPath != "") { if (Load_Scene(pszPath) == false) { Msg("Error: Failed to load scene \"" + pszPath + "\"..."); } } return world; } Creating Entities Entities in Turbo can be assigned to any world pointer upon creation while with Leadwerks, it creates the entity to the world that's set to current. This was a easy fix as again, we are are just doing a compatibility layer. While the style is more Turbo like, there is no world argument, it grabs the current pointer just like Leadwerks. // Creates a Pivot. ENGINE_OBJECT(Pivot) Create_Pivot(ENGINE_OBJECT(Entity) pParent) { #ifdef TURBO_ENGINE if (pParent != nil) return CreatePivot(pParent); return CreatePivot(GetCurrentWorld()); #else return Pivot::Create(pParent); #endif } // Creates a Camera. ENGINE_OBJECT(Camera) Create_Camera() { #ifdef TURBO_ENGINE return CreateCamera(GetCurrentWorld()); #else return Camera::Create(); #endif } // Creates a Listener. ENGINE_OBJECT(Listener) Create_Listener(ENGINE_OBJECT(Entity) pParent) { #ifdef TURBO_ENGINE return CreateListener(GetCurrentWorld(), pParent); #else return Listener::Create(pParent); #endif } Lights are different in the new engine. Instead of lights being their own classes, the new "CreateLight" function returns "Light". Again, I solved this with Macros. // Creates a Point Light. ENGINE_OBJECT(CLASS_POINTLIGHT) Create_PointLight(ENGINE_OBJECT(Entity) pParent) { #ifdef TURBO_ENGINE return CreateLight(GetCurrentWorld(), LIGHT_POINT, pParent); #else return CLASS_POINTLIGHT::Create(pParent); #endif } // Creates a Spot Light. ENGINE_OBJECT(CLASS_SPOTLIGHT) Create_SpotLight(ENGINE_OBJECT(Entity) pParent) { #ifdef TURBO_ENGINE return CreateLight(GetCurrentWorld(), LIGHT_SPOT, pParent); #else return CLASS_SPOTLIGHT::Create(pParent); #endif } // Creates a Directional Light. ENGINE_OBJECT(CLASS_DIRECTIONALLIGHT) Create_DirectionalLight(ENGINE_OBJECT(Entity) pParent) { #ifdef TURBO_ENGINE return CreateLight(GetCurrentWorld(), LIGHT_DIRECTIONAL, pParent); #else return CLASS_DIRECTIONALLIGHT::Create(pParent); #endif } And loading things are the same concept. . . . // Load a Sound file. ENGINE_OBJECT(Sound) Load_Sound(const std::string& pszPath, const int iFlags) { #ifndef TURBO_ENGINE return Sound::Load(pszPath, iFlags); #else return LoadSound(pszPath, iFlags); #endif } That's about it. I'm going to use this going forward updating as I go and hopefully doing this will make the transition less painful when the time comes.
  15. Does it do this when the ball is set to Collision::Prop? How about the character controller set to Collision::Character? I have successfully created my floor buttons using the collision function and experienced no issues. I do an aabb test of my off touch detection, however.
  16. I'm not a shader guru, but I think I know what's happening. It has something to do with the plane in relation to the camera. I'm not sure if this can be fixed in the shader or the camera class itself. @Josh what's your take?
  17. The water reflection is probably causing this. You can set the water quality to low to fix this, or edit the shader .
  18. Gave this a go, really neat. Minus the artifacting when you make the window bigger from a small size, works really well. Really stoked about the Vulkan implementation, and I'm sure this will pay off.
  19. If you want to cap the framerate, you would use the framerate argument with context->Sync(); virtual void Sync(const bool sync=true, const float framerate=0.0f)=0;//lua This is nice to have if you have issues using VSync on your machine like I did with my 750ti. What I'd do is something like this: local vsync = System:GetProperty("sync","1") local framecap = System:GetProperty("framecap","0") if framecap ~= "0" then vsync = false context:sync(vsync,framecap)
  20. reepblue

    Hello Vulkan

    Well done. Hopefully you'll adapt to this API and be a pro in no time. ?
  21. UPDATE: Ran the demo on my Linux machine which has a 1050Ti. Everything fine there. This has to do with light quality being set to medium or lower, and might be AMD exclusive. If there are any other Windows+AMD folks to confirm this, let me know!
  22. A quick app to preview models with environment probes. Throw these files within your project directory and load the models via a batch script. Key Listings: F5 - Reload model G - Toggle Grid F - Toggle Floor W - Toggle Widget 1-7 - Change Skybox. 0 - Remove Skybox. Windows only as it was just an experiment (Could have done more null checking..), but here's the full code. Use at your own risk. #include "Leadwerks.h" using namespace Leadwerks; Model* m_pModel; Vec3 m_vCamRot; Pivot* m_pCamPivot; bool m_bShowWidget = false; bool m_bShowGrid = false; int m_intShowCubemap = -1; int m_intCurrentCubemap = -1; const char* m_pszCubeMaps[7] { "Materials/CubeMap/1SaintLazarusChurch.tex", "Materials/CubeMap/LancellottiChapel.tex", "Materials/CubeMap/MarriottMadisonWest.tex", "Materials/CubeMap/papermill.tex", "Materials/CubeMap/park.tex", "Materials/CubeMap/PereaBeach.tex", "Materials/CubeMap/Yokohama.tex" }; int main(int argc, const char *argv[]) { Leadwerks::logstream__ = NULL; #ifndef DEBUG Leadwerks::logmode = false; #endif System::ParseCommandLine(argc, argv); std::string m_strModelPath = System::GetProperty("model", FileSystem::FixPath("Models/ModelViewer/error.mdl")); // Load any zip files in main directory System::AppPath = FileSystem::ExtractDir(argv[0]); Leadwerks::Directory* dir = Leadwerks::FileSystem::LoadDir("."); if (dir) { for (size_t i = 0; i < dir->files.size(); i++) { std::string file = dir->files[i]; std::string ext = Leadwerks::String::Lower(Leadwerks::FileSystem::ExtractExt(file)); if (ext == "zip" || ext == "pak") { Leadwerks::Package::Load(file); } } delete dir; } Window* window = Window::Create("ModelViewer",0,0,1024,768,Leadwerks::Window::Titlebar+Leadwerks::Window::Center+ Leadwerks::Window::Resizable); Context* context = Context::Create(window); Font* font = Font::Load("Fonts/arial.ttf", 8); // <- Do a null check here. context->SetFont(font); font->Release(); World* world = World::Create(); world->SetSkybox(NULL); Light* light = DirectionalLight::Create(); light->SetShadowMode(Light::Static); light->SetRotation(45, 45, 0); m_pCamPivot = Pivot::Create(); m_pModel = Model::Load(m_strModelPath); if (m_pModel == NULL) m_pModel = Model::Load("Models/ModelViewer/error.mdl"); m_pModel->SetShadowMode(Light::Static); m_vCamRot = Vec3(0, 0, -4); Camera* camera = Camera::Create(); camera->SetGridMode(m_bShowGrid); if (m_pModel != NULL) { camera->Move(0, 2, -m_pModel->GetAABB().size.z * 4); } else { camera->Move(0, 2, -5); } Model* m_pFloor = Model::Box(10.24, .32, 10.24); m_pFloor->SetColor(0.25, 0.25, 0.25); m_pFloor->Move(0, -.16, 0); m_pFloor->SetShadowMode(0); m_pFloor->Hide(); Probe* probe = Probe::Create(); probe->SetScale(10.24, 10.24, 10.24); probe->UpdateAABB(Entity::GlobalAABB); probe->needsupdate = true; probe->Render(); bool mousedown; while (window->Closed() == false) { mousedown = false; if (window->MouseDown(1)) { m_vCamRot.y += (window->MouseX() - (window->GetWidth() / 2)) * Time::GetSpeed() * 0.2; m_vCamRot.x += (window->MouseY() - (window->GetHeight() / 2)) * Time::GetSpeed() * 0.2; mousedown = true; } if (window->MouseDown(2)) { if (m_pModel != NULL) { float current = m_vCamRot.z; m_vCamRot.z = Math::Clamp(current + (window->MouseY() - (window->GetHeight() / 2)) * Time::GetSpeed() * 0.1, -20.0f, -m_pModel->GetAABB().size.z * 2); } else { m_vCamRot.z += (window->MouseY() - (window->GetHeight() / 2)) * Time::GetSpeed() * 0.1; } mousedown = true; } if (window->KeyHit(Key::F)) { if (m_pFloor->Hidden()) { m_pFloor->Show(); } else { m_pFloor->Hide(); } } if (window->KeyHit(Key::W)) { m_bShowWidget = !m_bShowWidget; } if (window->KeyHit(Key::G)) { m_bShowGrid = !m_bShowGrid; camera->SetGridMode(m_bShowGrid); } if (window->KeyHit(Key::F5)) { m_pModel->Release(); m_pModel = NULL; m_pModel = Model::Load(m_strModelPath); m_pModel->SetShadowMode(Light::Static); } if (mousedown) { window->HideMouse(); window->SetMousePosition(window->GetWidth() / 2, window->GetHeight() / 2); } else { window->ShowMouse(); } Vec3 pos = m_pCamPivot->GetPosition(); camera->SetPosition(pos.x, pos.y + 1, pos.z); camera->SetRotation(m_vCamRot.x, m_vCamRot.y, 0); camera->Move(0, 0, m_vCamRot.z); if (window->KeyHit(Key::D0)) m_intShowCubemap = -1; if (window->KeyHit(Key::D1)) m_intShowCubemap = 0; if (window->KeyHit(Key::D2)) m_intShowCubemap = 1; if (window->KeyHit(Key::D3)) m_intShowCubemap = 2; if (window->KeyHit(Key::D4)) m_intShowCubemap = 3; if (window->KeyHit(Key::D5)) m_intShowCubemap = 4; if (window->KeyHit(Key::D6)) m_intShowCubemap = 5; if (window->KeyHit(Key::D7)) m_intShowCubemap = 6; if (m_intShowCubemap > -1) { if (m_intCurrentCubemap != m_intShowCubemap) { world->SetSkybox(m_pszCubeMaps[m_intShowCubemap]); probe->Render(); m_intCurrentCubemap = m_intShowCubemap; } } else { if (world->GetSkybox() != NULL) { world->SetSkybox(NULL); m_intCurrentCubemap = m_intShowCubemap; } } Time::Update(); world->Update(); world->Render(); context->SetBlendMode(Blend::Alpha); context->SetColor(1, 1, 1, 1); context->DrawStats(2, 2, true); if (m_bShowWidget) { auto dis = 1; Vec3 c = camera->Project(Vec3(0, 0, 0)); Vec3 x = camera->Project(Vec3(dis, 0, 0)); Vec3 y = camera->Project(Vec3(0, dis, 0)); Vec3 z = camera->Project(Vec3(0, 0, dis)); context->SetColor(1, 0, 0, 1); context->DrawLine(c.x, c.y, x.x, x.y); context->SetColor(0, 1, 0, 1); context->DrawLine(c.x, c.y, y.x, y.y); context->SetColor(0, 0, 1, 1); context->DrawLine(c.x, c.y, z.x, z.y); } context->SetColor(1, 1, 1, 1); context->SetBlendMode(Blend::Solid); context->Sync(true); } } modelviewer.zip modelviewer.zip
  23. An update and/or for Turbo, have a wrapper function for entities to get the status of the physics. This: bool sleepstate = NewtonBodyGetSleepState(((NewtonDynamicsBody*)entity->body)->body); Can be this: bool sleepstate = entity->IsPhysicsSleeping() IDK about the name, but this function would be nice.
  24. Tested this Windows, have not yet tested on Linux (Which as the Nivida card.) Anyone can test with Any config with this.
×
×
  • Create New...