Jump to content

Visualize Colliders on a Pivot


SpiderPig
 Share

Go to solution Solved by Josh,

Recommended Posts

The collider is not visible on a pivot.  I use pivots as the hubs for Collison patches on voxel terrain, mainly due to the fact it doesn't need a visible model.  The code below shows the problem but I have just found out it will work on a model even if it doesn't have a mesh.

Should a pivot be used like this?  Or is is there any harm in using a model without a mesh assigned to it this way?

#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 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, 1, -5);

    camera->SetDebugPhysicsMode(true);

    //Create a light
    auto light = CreateBoxLight(world);
    light->SetRotation(35, 45, 0);
    light->SetRange(-10, 10);

    vector<Vec3> verts;
    verts.push_back(Vec3(-3.0f, 0.0f, -3.0f));
    verts.push_back(Vec3(3.0f, 0.0f, -3.0f));
    verts.push_back(Vec3(3.0f, 0.0f, 3.0f));

    auto c = CreateMeshCollider();
    c->AddFace(verts);
    c->Finalize();

    auto pivot = CreateModel(world);//Works
   // auto pivot = CreatePivot(world);//Dosn't Work
    pivot->SetCollider(c);
    pivot->SetCollisionType(COLLISION_SCENE);

    world->SetCollisionResponse(COLLISION_SCENE, COLLISION_PROP, COLLISION_COLLIDE);

    //Main loop
    vector<shared_ptr<Entity>> cubes;
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {
        if (window->KeyHit(KEY_SPACE) == true) {
            auto cube = CreateBox(world);
            cube->SetPosition(0.0f, 10.0f, 0.0f, true);
            cube->SetMass(1.0f);
            cube->SetCollisionType(COLLISION_PROP);

            cubes.push_back(cube);
        }

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...