I have an fbx model which I loading in engine, but when I try to apply texture programmatically on this model it doesn't work, but it works on primitive object like cube.
This is what I do
auto fileLoaderComplete = sceneManager->assets()->loader()->complete()->connect([&](file::Loader::Ptr loader)
{
auto chair = sceneManager->assets()->symbol(FBX_MODEL_FILENAME);
//chair->addComponent(Transform::create());
auto chairMaterial = material::BasicMaterial::create();
chairMaterial->diffuseMap(sceneManager->assets()->texture(TEXTURE_FILENAME));
chair->addComponent(Surface::create(
geometry::QuadGeometry::create(sceneManager->assets()->context()),
chairMaterial,
sceneManager->assets()->effect("effect/Basic.effect")
));
chair->component<Transform>()->matrix(chair->component<Transform>()->matrix() * math::scale(math::vec3(0.005f)));
// Add the symbol to the scene
root->addChild(chair);
});
But no any texture applied on the model. How to make it work properly?
I don't know what you are really trying to achieve, but this code add a quad to the root node of your chair model with a texture on it. If the triangle culling is enabled and that your camera doesn't face this quad, it's normal that you see no change.
What you need to do is to retrieve the node that contains the surface that you want to texture and update its material.
It should looks like something like this: