Hi oF community! This may be a rather stupid question but I’m having some trouble with a project I am doing. Just a quick overview, I am attempting to create an interactive piece where a vboMesh cycles through an array of images based on a blob tracker. Essentially the effect that I want to create is when someone steps on location A, a mesh will appear. When he/she steps on location B, another image will appear. The reason why I am using a mesh is because i want to apply shaders afterwards to play around with how the image looks.
I am currently at the stage where I am simply trying to apply multiple images to the vboMesh. I am able to link one image to the mesh. However when I try linking the array to the mesh, i get an error saying "img declared as array of references of type ‘ofImage & (aka ofImage &’)
I am basing my code off of the vbo example hence that is why my code is like that right now. I may possibly be approaching this problem in an incorrect way, but any help will be much appreciated right now!
without digging into your logic / what you are trying to do – if you want to pass the array by reference (which you should), you need to declare it properly:
It does not seem that you are using an array within the function, just its MAXIMAGES’th element. If that’s the intent, just pass that single element of array as ofImage& img and then within the function use img variable instead of img[MAXIMAGES].
thanks for the help @zach and @eight! I realized that I’m actually not familiar enough with pointers and reference to be diving into that area. I took the & out and changed a couple parameters. Instead of having:
ofVec3f getVertexForming(ofImage& img, int x, int y);
i changed it to:
ofVec3f getVertexForming(int x, int y);
It somehow struck me that I didn’t need to use an image to create the points on which the mesh will be based on. With this in mind, i changed that section of the code to: (IMAGESIZE is simply 1000 ~ all my images are 1000x1000, MAXIMAGES is still set to 5)
the issue that I am running into now is cycling through the array. I currently have
img[int(ofRandom(0,4))].bind
what happens from this is that my mesh cycles through the entire array on it’s own. Any thoughts on how I can change the image on my mesh one by one on click? I know that ofMesh has a mesh.update() function but vboMesh does not seem to have any.
Thank you very much for being so patient with me. I’m relatively new to C++ and still trying to learn as I go.