What type to use for ofMesh::addNormals()

I tried to do

vector<ofPoint> normals(size);

But it doesn’t accept that. Changing ofPoint to ofVec3f doesn’t help either.
As a fix I’m a for loop with mesh.addNormal(), but I would like to how to use previous one.

What error do you get? Does this work?

std::vector<glm::vec3> normals(size);

Yes, that does work. Thank you.

This is the error:

Error (active)	E0304	no instance of overloaded function "ofMesh_<V, N, C, T>::addNormals [with V=ofDefaultVertexType, N=ofDefaultNormalType, C=ofDefaultColorType, T=ofDefaultTexCoordType]" matches the argument list	

Same issue using vector<ofPoint>:

'void ofMesh_<ofDefaultVertexType,ofDefaultNormalType,ofDefaultColorType,ofDefaultTexCoordType>::addNormals(const N *,size_t)': cannot convert argument 1 from 'std::vector<ofVec3f,std::allocator<_Ty>>' to 'const std::vector<V,std::allocator<_Ty>> &'

Guess some template deduction issue?

I’m confused. Does @noine say it works but for you @xarthur it doesn’t? What’s the difference in your programs? What version of oF?

Sorry for the confusion.
glm::vec3 works, but ofPoint not.
But isn’t the latter a derived class of the former?

no, ofPoint is an alias for ofVec3f our old vector math library. since 0.10 OF includes and uses glm for vector math. you can still use ofVec in a lot of cases mostly to keep compatibility with old projects or at least to make it as easy as possible to keep using them but it’s recommended to use glm if you are working on new projects

1 Like

So math element like normals, directions, now are different from elements like points?
Are they two different classes that are meant to be kept separately, or one is a derived version of the other?

Sorry for the naive question. I didn’t find some design philosophy of OF, and some of the things seems quite different from commonly used packages for meshes and math operations, like Eigen, libigl, etc.

no you should just use glm::vec2, 3 or 4, ofPoint shouldn’t be used in new projects