praxis-live / support

Documentation and issue tracking
9 stars 2 forks source link

cannot getVertex() or getVertexCount() on 3D PShape example #103

Closed maxdee closed 5 years ago

maxdee commented 5 years ago

Hello! I wanted to play with 3D shapes like in the mandala rocket example. I was able to load shapes but then unable to call disableStyle(). Ideally I could copy the vertices to a new PShape with a style of my choice, but I cannot do getVertexCount() and getVertex(i). Its not super important but would be good fun!

neilcsmith-net commented 5 years ago

Hi!

You can iterate the vertices, just that it's made up of child shapes - eg.

    for (int i = 0; i < shape.getChildCount(); i++) {
            beginShape();
            PShape child = shape.getChild(i);
            for (int j = 0; j < child.getVertexCount(); j++) {
                vertex(child.getVertexX(j), child.getVertexY(j), child.getVertexZ(j));
            }
            endShape(CLOSE);
        }

You should also be able to call createShape(shape); to get a writeable copy that you can disable styles, etc. on but this doesn't seem to be working with this for some reason.

I've had to split apart how Processing does this. It first loads a PShape from the OBJ file, then creates an OpenGL shape from that - the second bit only works in the OpenGL thread. To support background loading and using across opening/closing the window when using @P() the reference is the immutable OBJ file version.

maxdee commented 5 years ago

Ok will try that out, many thanks for the prompt support!!

neilcsmith-net commented 5 years ago

@maxdee did you have an example in upstream Processing where disableStyle() works on an OBJ? I've updated the createShape() code in dev and can now create an SVG copy that I can unstyle, but doesn't seem to work the same with OBJ.