I have six textures in my data folder, and I want to apply a different one to each face of an ofBoxPrimitive instance, how would I go about doing this?
Is there a function that lets me put one on each face, or could I do it with coordinates? How would I go about finding those coordinates? (Unfortunately I’m not the greatest at maths)
If I remember right, there is an example called 3dPrimitivesExample that binds input from a camera to various 3dPrimitives that spin. Its a great example and fun to work thru.
I’m thinking there is quite a bit of code involved in what you want to do, but it should be possible, and I would approach it in the following way:
- get the textures into the app as either ofImage or ofTexture objects
- the ofBoxPrimitive inherits from of3dPrimitive, which has an ofMesh inside of it. The ofMesh has lots of different coordinates for different kinds of things, including texture coordinates, which can be accessed with .getMesh().getTexCoords() and .getMesh().setTexCoord(). So I’d get the vertices of the primitive and set the texture coordinates from those. There are probably some other things to do too, like enabling the texture for the primitive.
- an ofImage or ofTexture can then .bind() to the texture coordinates of the 3dPrimitive
The examples folders are great resources for learning about the different oF classes; so have a look thru the ones for 3d, graphics, and maybe gl. Also have a look at the documentation for ofImage .bind(), of3dPrimitive, and ofMesh in particular, which has quite a bit to digest regarding how to set vertices, indexes, texture coordinates, etc.
Hope this helps to get your started and on the right track.