Skip to content

ofMesh statics #1356

Closed
elliotwoods opened this Issue Jun 27, 2012 · 5 comments

3 participants

@elliotwoods

hey all!

i'm going back through issues this week to clean out and work on functionality.

we talked before @ofTheo and maybe marek? (iirc) about ofMesh statics

My proposal is something like 'ofMeshLibrary' which has lots of standard meshes that you can pull out or draw directly, e.g.:

  • Grid (quad, plane, etc)
  • Box
  • Sphere
  • Icosphere
  • Cylinder
  • Tube
  • Arrow etc...

for each you could do like

ofMesh myMesh;

ofMeshLibrary::sphere::draw(); // draw with default resolution

//ofMeshLibrary::sphere::init() is called the first time you either copy or draw the mesh
myMesh = ofMeshLibrary::sphere; // create a local instance of sphere with default resolution

ofMeshLibrary::sphere::setResolution(5); // change the resolution of the static sphere

myMesh = ofMeshLibrary::sphere; // create a local instance of sphere with low resolution

ofMeshLibrary::sphere::draw(); // draw with reduced resolution

Anybody see any issues with this being in the core?
If not I'll start on this. We discussed it before on irc and it was mostly positive.

@arturoc
openFrameworks member
@elliotwoods

so the sphere() function would then return (and if necessary initialise) a static sphere?

@arturoc
openFrameworks member
@elliotwoods

how about:

.cpp:

ofMesh * ofMeshLibrary::sphereInstance = 0;
const ofMesh & ofMeshLibrary::sphere(){
    if (ofMeshLibrary::sphereInstance==0) {
        ofMeshLibrary::sphereInstance = new ofMesh();
        //create sphere
    }
    return *sphere;
}

.h

class ofMeshLibrary {
public:
    const ofMesh & sphere();
protected:
    static ofMesh * sphereInstance;
};
@kylemcdonald

i think this has basically been closed by the introduction of of3dPrimitive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.