sebastian.vesenmayer Posted June 7, 2019 Share Posted June 7, 2019 Hi, When loading my created mesh objects which I saved before there are no normals anymore in the mesh object. Here is a reproducer: { auto mesh = Unigine::Mesh::create(); mesh->addSurface("0"); mesh->addVertex(Unigine::Math::vec3(1.f, 1.f, 0.f), 0); mesh->addVertex(Unigine::Math::vec3(1.f, 0.f, 1.f), 0); mesh->addVertex(Unigine::Math::vec3(0.f, 1.f, 1.f), 0); mesh->addNormal(Unigine::Math::vec3(0.f, 0.f, 1.f), 0); mesh->addNormal(Unigine::Math::vec3(0.f, 0.f, 1.f), 0); mesh->addNormal(Unigine::Math::vec3(0.f, 0.f, 1.f), 0); mesh->addIndex(0, 0); mesh->addIndex(1, 0); mesh->addIndex(2, 0); auto numVertex = mesh->getNumVertex(0); auto numNormals=mesh->getNumNormals(0); std::cout << numVertex << numNormals << std::endl; mesh->save("hello.mesh"); } { auto mesh = Unigine::Mesh::create("hello.mesh"); auto numVertex = mesh->getNumVertex(0); auto numNormals = mesh->getNumNormals(0); std::cout << numVertex << numNormals << std::endl; } It affects versions 2.7.2.1 to 2.8.0.1. Thanks, Sebastian Link to comment
andrey-kozlov Posted June 10, 2019 Share Posted June 10, 2019 Hello Sebastian, Normals of mesh are not serializable. The whole tangent basis is serialized instead. Custom normals can be used to calculate it like this: mesh->addNormal(Unigine::Math::vec3(0.f, 0.f, 1.f), 0); mesh->addNormal(Unigine::Math::vec3(0.f, 0.f, 1.f), 0); mesh->addNormal(Unigine::Math::vec3(0.f, 0.f, 1.f), 0); mesh->addIndex(0, 0); mesh->addIndex(1, 0); mesh->addIndex(2, 0); mesh->createTangents(); And after loading normals can be read back: auto numTangents = mesh->getNumTangents(0); auto normal = mesh->getTangent(0, 0).getNormal(); Link to comment
sebastian.vesenmayer Posted June 11, 2019 Author Share Posted June 11, 2019 (edited) Ok, can you please update your documentation for the save and load method to mark which properties are serialized and which not? ;) Thanks Edited June 11, 2019 by sebastian.vesenmayer Link to comment
morbid Posted June 11, 2019 Share Posted June 11, 2019 Sure, I'll forward this to our documentation team. Thank you! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts