The code from the download seems to work, but there are a few differences in the downloaded code and where I am currently in the chapter. I will continue on with the chapter to see if it clears up, but it doesn’t seem to work as it should in the order that it is presented now (again unless I missed a step).
Hi,
I have not read that book but it already has some years and openFrameworks has changed a bit.
In the case of your problem I am almost sure it is because OF has now switched to use GLM vector maths instead of using its own vector classes.
So, probably your vertices0 variable is of the type vector<ofVec3f>, which is what the getVertices() function used to return. Now, as I said, openFrameworks switched to GLM, thus this function returns a vector<glm::vec3>. So simply said, where ever you have declared your vertices0 object, which should read like vector<ofVec3f> vertices0; just change it for vector<glm::vec3> vertices0; .
Furthermore, in a lot of cases ofVec3f can automatically get converted back and forth to glm, but not when it is used in a container such as a vector. This said, the easiest thing to do is, when ever you come across to a vector<ofVec3f> object just change it to be vector<glm::vec3>.
Be aware though that the glm::vec3 is not compatible with the ofVec3f class regarding its methods, it will only work when you access its variables (x, y or z).
Last but not least, if you are not happy with changing to glm or having to fix the code to make it work, then go to the ofConstants.h file and change the line that reads #define OF_USE_LEGACY_VECTOR_MATH 0 to #define OF_USE_LEGACY_VECTOR_MATH 1
The methods used in that example are deprecated. It does not mean these will not work but you should use the newer way of handling the ofBuffer object. Take a look at examples/input_output/fileBufferLoadingCSVExample.
When you have a vector out of range the app will crash and if you are in debug your IDE should show you the line where this happened.
Is that all the code? Are you actually loading something into the buffer?
When posting code, in the forum’s text input paste the code, select it and press the </> button that is in the toolbar. This will format the code into a much more readable format.
I will have a look at the example but I am a little bit afraid since its the first time that I do something with files in OF and I dont have previous coding experience