SpiderPig Posted April 20, 2019 Share Posted April 20, 2019 If I assign a material to an object in the editor then load it, it displays with the material yet GetMaterial() returns NULL. #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } bool wireframe = false; bool App::Start() { window = Window::Create(); context = Context::Create(window); world = World::Create(); camera = Camera::Create(); camera->SetFOV(70.0f); camera->Move(0, 0, -15); auto m = Model::Load("Models\\Characters\\Generic\\generic.mdl"); //auto mat = Material::Load("Materials\\Developer\\bluegrid.mat"); //m->SetMaterial(mat); auto m2 = m->GetMaterial();//returns NULL unless I load the material and apply it via code return true; } bool App::Loop() { if (window->KeyHit(Key::Escape) == true) { return false; } if (window->KeyHit(Key::F3) == true) { camera->SetDebugPhysicsMode(!camera->GetDebugPhysicsMode()); } if (window->KeyHit(Key::F2) == true) { if (wireframe == true) { camera->SetDrawMode(0); wireframe = false; } else { camera->SetDrawMode(2); wireframe = true; } } Time::Update(); world->Update(); world->Render(); context->Sync(); return true; } I am using the latest update on the default branch. Quote Link to comment Share on other sites More sharing options...
Solution Yue Posted April 20, 2019 Solution Share Posted April 20, 2019 I think you should get the surface first. Material* material = ((Model*)player.model->GetChild(1))->GetSurface(0)->GetMaterial(); Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted May 2, 2019 Author Share Posted May 2, 2019 That will work but it still dosnt answer the question on why GetMaterial() returns null on an entity that has been loaded from disc. Quote Link to comment Share on other sites More sharing options...
reepblue Posted May 2, 2019 Share Posted May 2, 2019 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.) Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Recommended Posts
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.