class methods
Extends
This class extends others, you can call their methods on an instance of ofSpherePrimitive too:
The ofSpherePrimitive allows you to create an UV sphere, which is a sphere based on UV slices rather than faces like the ofIcoSpherePrimitive. Note this:
On the left is a UV sphere and on the right is an ICO sphere.
Like all primitives it allows you to set the size (radius), draw it, set positions, etc, as a simple example:
void setup()
{
sphere.setRadius( width );
}
void draw()
{
sphere.setPosition(ofGetWidth()*.2, ofGetHeight()*.75, 0);
sphere.rotate(spinX, 1.0, 0.0, 0.0);
sphere.rotate(spinY, 0, 1.0, 0.0);
// get all the faces from the icoSphere, handy when you want to copy
// individual vertices or tweak them a little ;)
vector<ofMeshFace> triangles = sphere.getMesh().getUniqueFaces();
// now draw
sphere.draw();
}
To draw a texture over any primitive, simply bind the ofTexture instance and then draw your primitive:
texture.getTextureReference().bind();
// now draw
sphere.draw();
The sphere can look a little weird if you don't do ofEnabledDepthTesting() and ofDisableAlphaBlending().
ofSpherePrimitive(...)
ofSpherePrimitive::ofSpherePrimitive(float radius, int res, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP)
set(...)
void ofSpherePrimitive::set(float radius, int resolution, ofPrimitiveMode mode=OF_PRIMITIVE_TRIANGLE_STRIP)
Last updated Tuesday, 19 November 2024 17:24:04 UTC - 2537ee49f6d46d5fe98e408849448314fd1f180e
If you have any doubt about the usage of this module you can ask in the forum.
If you want to contribute better documentation or start documenting this section you can do so here
If you find anything wrong with this docs you can report any error by opening an issue