如何加载带纹理的 .dae 对象,以及 material
How to load .dae object with texture, and material
我刚开始使用 Minko 并试图理解这个 https://github.com/aerys/minko/blob/master/doc/tutorial/06-Loading_3D_files.md 教程。我做了一些步骤:
sceneManager->assets()->loader()
->queue(FIREAXE_D)
->queue(FIREAXE_N)
->queue(FIREAXE_S)
->queue(TEXTURE_FILENAME)
->queue("effect/Basic.effect")
->queue(OBJ_MODEL_FILENAME);
现在我正尝试将这三种纹理与我的对象和文件 .mtl 一起使用 -> material.
auto _ = sceneManager->assets()->loader()->complete()->connect([=](file::Loader::Ptr loader)
{
auto objModel = sceneManager->assets()->symbol(OBJ_MODEL_FILENAME);
objModel->component<Transform>()->matrix()->appendScale(0.01f);
objModel->component<Transform>()->matrix()->translation(-1.f, -1.f, 0.f);
objModel->component<Texture>()->set(sceneManager->assets()->texture(FIREAXE_D));
//objModel->addComponent(sceneManager->assets()->texture(FIREAXE_N));
//objModel->addComponent(sceneManager->assets()->texture(FIREAXE_S));
root->addChild(objModel);
});
这行不通,那 .mtl 文件呢?如何将它附加到我的对象?
但是教程仍然太小而且有问题,最好找例子,但我现在找不到任何带有纹理加载的对象。
This won't work and what about .mtl file? How to attach it to my object?
您的问题是关于加载 Collada (*.dae) 文件的。 Collada 文件没有 *.mtl 文件,*.obj 文件有。
不过,它对任何文件的任何依赖项都是一样的:如果它们确实可以在提供的 path/URI.
中找到,它们将自动加载
您可以使用 file::Options::includePaths()
属性 添加 include/search 路径,或者使用 file::Options::uriFunction()
自定义 URI 的解析方式。 file::Options
class 的许多其他属性将帮助您自定义资源的加载方式。
However tutorials are still to tiny and buggy
如果您发现错误,请打开 an issue on github。
it is better to look for examples but I cann't find any with texture loading for object right now.
以下示例加载 Collada 文件以及动画和纹理:
我刚开始使用 Minko 并试图理解这个 https://github.com/aerys/minko/blob/master/doc/tutorial/06-Loading_3D_files.md 教程。我做了一些步骤:
sceneManager->assets()->loader()
->queue(FIREAXE_D)
->queue(FIREAXE_N)
->queue(FIREAXE_S)
->queue(TEXTURE_FILENAME)
->queue("effect/Basic.effect")
->queue(OBJ_MODEL_FILENAME);
现在我正尝试将这三种纹理与我的对象和文件 .mtl 一起使用 -> material.
auto _ = sceneManager->assets()->loader()->complete()->connect([=](file::Loader::Ptr loader)
{
auto objModel = sceneManager->assets()->symbol(OBJ_MODEL_FILENAME);
objModel->component<Transform>()->matrix()->appendScale(0.01f);
objModel->component<Transform>()->matrix()->translation(-1.f, -1.f, 0.f);
objModel->component<Texture>()->set(sceneManager->assets()->texture(FIREAXE_D));
//objModel->addComponent(sceneManager->assets()->texture(FIREAXE_N));
//objModel->addComponent(sceneManager->assets()->texture(FIREAXE_S));
root->addChild(objModel);
});
这行不通,那 .mtl 文件呢?如何将它附加到我的对象?
但是教程仍然太小而且有问题,最好找例子,但我现在找不到任何带有纹理加载的对象。
This won't work and what about .mtl file? How to attach it to my object?
您的问题是关于加载 Collada (*.dae) 文件的。 Collada 文件没有 *.mtl 文件,*.obj 文件有。
不过,它对任何文件的任何依赖项都是一样的:如果它们确实可以在提供的 path/URI.
中找到,它们将自动加载您可以使用 file::Options::includePaths()
属性 添加 include/search 路径,或者使用 file::Options::uriFunction()
自定义 URI 的解析方式。 file::Options
class 的许多其他属性将帮助您自定义资源的加载方式。
However tutorials are still to tiny and buggy
如果您发现错误,请打开 an issue on github。
it is better to look for examples but I cann't find any with texture loading for object right now.
以下示例加载 Collada 文件以及动画和纹理: