About This File
This is a left-handed rigged model for use in VR, thanks to @reepblue. You can use this code to move joints, Make sure your joint movement occurs in between the world Update and Render calls:
#include "Leadwerks.h" #include "ComponentSystem.h" using namespace Leadwerks; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Leadwerks", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); world->SetAmbientLight(0); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 1.4, -1); camera->SetFov(70); //Activate the component system RegisterComponents(); //Add camera controls camera->AddComponent<CameraControls>(); //Create light auto light = CreateBoxLight(world); light->SetRange(-10, 10); light->SetArea(15, 15); light->SetRotation(45, 35, 0); light->SetColor(1.2); auto hand = LoadModel(world, "Models/Characters/VRHands/VR_Hand_Left.mdl"); hand->SetScale(0.1f); auto bone = hand->skeleton->FindBone("finger_index_0_l"); Vec3 r = bone->rotation; auto bone2 = hand->skeleton->FindBone("finger_index_1_l"); Vec3 r2 = bone2->rotation; auto bone3 = hand->skeleton->FindBone("finger_index_2_l"); Vec3 r3 = bone3->rotation; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); if (window->KeyDown(KEY_UP)) r.z += 1.0f; if (window->KeyDown(KEY_DOWN)) r.z -= 1.0f; bone->SetRotation(r); if (window->KeyDown(KEY_UP)) r2.z += 1.0f; if (window->KeyDown(KEY_DOWN)) r2.z -= 1.0f; bone2->SetRotation(r2); if (window->KeyDown(KEY_UP)) r3.z += 1.0f; if (window->KeyDown(KEY_DOWN)) r3.z -= 1.0f; bone3->SetRotation(r3); world->Render(framebuffer); } return 0; }
What's New in Version 08/08/26 10:42 PM
Released
Added model source files.
License
CC Attribution