123 uint shapeNum = mesh->shapes().size();
125 if (
mShapes.size() != shapeNum)
128 for (
uint i = 0; i < shapeNum; i++)
130 mShapes[i] = std::make_shared<GLShape>();
134 uint matNum = mesh->materials().size();
138 for (
uint i = 0; i < matNum; i++)
140 mMaterials[i] = std::make_shared<GLMaterial>();
144 std::map<std::shared_ptr<Material>,
uint> mapper;
146 for (
uint i = 0; i < matNum; i++)
148 mMaterials[i]->baseColor = mesh->materials()[i]->baseColor;
149 mMaterials[i]->metallic = mesh->materials()[i]->metallic;
150 mMaterials[i]->roughness = mesh->materials()[i]->roughness;
151 mMaterials[i]->metallic = mesh->materials()[i]->metallic;
152 mMaterials[i]->bumpScale = mesh->materials()[i]->bumpScale;
153 mMaterials[i]->texColor.load(mesh->materials()[i]->texColor);
154 mMaterials[i]->texBump.load(mesh->materials()[i]->texBump);
156 mapper[mesh->materials()[i]] = i;
159 for (
uint i = 0; i < shapeNum; i++)
161 mShapes[i]->glVertexIndex.load(mesh->shapes()[i]->vertexIndex);
162 mShapes[i]->glNormalIndex.load(mesh->shapes()[i]->normalIndex);
163 mShapes[i]->glTexCoordIndex.load(mesh->shapes()[i]->texCoordIndex);
165 Vec3f S = mesh->shapes()[i]->boundingTransform.scale();
166 Mat3f R = mesh->shapes()[i]->boundingTransform.rotation();
167 Vec3f T = mesh->shapes()[i]->boundingTransform.translation();
174 glm::mat4 tm = glm::mat4{
175 RS(0, 0), RS(1, 0), RS(2, 0), 0,
176 RS(0, 1), RS(1, 1), RS(2, 1), 0,
177 RS(0, 2), RS(1, 2), RS(2, 2), 0,
178 T[0],
T[1],
T[2], 1 };
183 auto test = mapper[mesh->shapes()[i]->material];
184 auto testsm = mesh->shapes()[i]->material;
186 if (mesh->shapes()[i]->material != NULL)
XBuffer< Vec2f > mTexCoord
std::vector< std::shared_ptr< GLShape > > mShapes
void load(const std::shared_ptr< TextureMesh > mesh)
std::vector< std::shared_ptr< GLMaterial > > mMaterials
XBuffer< Vec3f > mVertices
~GLTextureMesh() override