我有一個fbx模型,我在引擎中加載,但是當我嘗試在此模型上以編程方式應用紋理時,它不起作用,但它適用於原始對象像立方體。Minko:如何在3D加載模型上應用材質(紋理)
這是我做的
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);
});
但應用在模型上沒有任何紋理。如何使其正常工作?
相反scene :: NodeSet :: create(model)應該是scene :: NodeSet :: create(chair)我相信嗎? 但是,這段代碼仍然不起作用看看結果http://postimg.org/image/h8ep1b0lj/ – Arsenius
你是對的,你必須給「椅子」變量來創建你的NodeSet,我已經編輯了代碼。但這應該工作,確保您的紋理正確加載,並且您的NodeSet包含一些節點。 – Noxalus
這是完整的代碼https://github.com/atonamy/FbxImport/blob/master/src/main.cpp,這是模型和紋理https://github.com/atonamy/FbxImport/tree/master/asset/模型我嘗試與立方體和球體和紋理加載和正常工作。但是,當我嘗試椅子模型不起作用。請嘗試自己。 – Arsenius