@edapx wrote:
Hello, I’m am creating a class that inherits from of3DPrimitive and get the mesh by loading an .obj file.
Something like:
#ifndef STAIRS_H #define STAIRS_H #include "ofMain.h" #include "ofxAssimpModelLoader.h" #include "MeshHelper.hpp" class Stairs : public of3dPrimitive{ public: Stairs(); ofxAssimpModelLoader model; }; #endif // STAIRS_H
Stairs::Stairs(){ model.loadModel("stairs.obj"); getMesh().clear(); getMesh().append(model.getMesh(0)); getMesh().enableColors(); getMesh().enableNormals(); }
But the sise of the model it is too small. I have tried to scale the model before getting the mesh, but it does not work.
#include "Stairs.h" Stairs::Stairs(){ model.setScaleNormalization(false); model.loadModel("stairs.obj"); auto bbox = MeshHelper::getBoundingBox(model.getMesh(0)); float originalXSide = bbox.max.x - bbox.min.x; float side = 100; float scaleRatio = side/originalXSide; model.setScale(scaleRatio,scaleRatio,scaleRatio); model.update(); getMesh().clear(); getMesh().append(model.getMesh(0)); auto bbox1 = MeshHelper::getBoundingBox(model.getMesh(0)); getMesh().enableColors(); getMesh().enableNormals(); }
or, it does not scale the mesh. if you call
model->drawFaces()
, the model it is scaled, but if you call model.getMesh.draw(), or in my case, stairs.draw(), it draws a mesh with the original dimension.I had a look to the ofMesh class and there is no scale method. So, I think that the only way that I have to scale a mesh is to assume that all the vertices are relative to a centroid, and multiply all the vertices by a scalar. Am I correct that this is, at the moment, the only way to scale a mesh?
Posts: 1
Participants: 1