| 529 | } |
| 530 | |
| 531 | void MeshRenderer::createNode(NodeData* nodedata, Node* root, const MaterialDatas& materialdatas, bool singleMesh) |
| 532 | { |
| 533 | Node* node = nullptr; |
| 534 | for (const auto& it : nodedata->modelNodeDatas) |
| 535 | { |
| 536 | if (it) |
| 537 | { |
| 538 | if (!it->bones.empty() || singleMesh) |
| 539 | { |
| 540 | if (singleMesh && root != nullptr) |
| 541 | root->setName(nodedata->id); |
| 542 | auto mesh = Mesh::create(nodedata->id, getMeshIndexData(it->subMeshId)); |
| 543 | if (mesh) |
| 544 | { |
| 545 | _meshes.pushBack(mesh); |
| 546 | if (_skeleton && it->bones.size()) |
| 547 | { |
| 548 | auto skin = MeshSkin::create(_skeleton, it->bones, it->invBindPose); |
| 549 | mesh->setSkin(skin); |
| 550 | } |
| 551 | mesh->_visibleChanged = std::bind(&MeshRenderer::onAABBDirty, this); |
| 552 | |
| 553 | if (it->materialId == "" && materialdatas.materials.size()) |
| 554 | { |
| 555 | const NTextureData* textureData = |
| 556 | materialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse); |
| 557 | setMeshTexture(mesh, textureData->filename); |
| 558 | } |
| 559 | else |
| 560 | { |
| 561 | const NMaterialData* materialData = materialdatas.getMaterialData(it->materialId); |
| 562 | if (materialData) |
| 563 | { |
| 564 | const NTextureData* textureData = |
| 565 | materialData->getTextureData(NTextureData::Usage::Diffuse); |
| 566 | if (textureData) |
| 567 | { |
| 568 | setMeshTexture(mesh, textureData->filename); |
| 569 | auto tex = mesh->getTexture(); |
| 570 | if (tex) |
| 571 | { |
| 572 | Texture2D::TexParams texParams; |
| 573 | texParams.minFilter = backend::SamplerFilter::LINEAR; |
| 574 | texParams.magFilter = backend::SamplerFilter::LINEAR; |
| 575 | texParams.sAddressMode = textureData->wrapS; |
| 576 | texParams.tAddressMode = textureData->wrapT; |
| 577 | tex->setTexParameters(texParams); |
| 578 | _transparentMaterialHint = |
| 579 | materialData->getTextureData(NTextureData::Usage::Transparency) != nullptr; |
| 580 | } |
| 581 | } |
| 582 | textureData = materialData->getTextureData(NTextureData::Usage::Normal); |
| 583 | if (textureData) |
| 584 | { |
| 585 | auto tex = setMeshTexture(mesh, textureData->filename, NTextureData::Usage::Normal); |
| 586 | if (tex) |
| 587 | { |
| 588 | Texture2D::TexParams texParams; |
nothing calls this directly
no test coverage detected