Get size of .obj PShape

edited October 2014 in Questions about Code

I am trying to get the width and height (preferably the depth too) of a shape loaded as a ".obj" file. For example:

        PShape house;

        void setup() {
           size(500,500,OPENGL);
           house = loadShape("house1.obj");
        }

        void draw() {
           translate(width/2,height/2,0);
           shape(house);
           println(house.width); //this returns 0.0
        }

How would I do this? Why does it return 0? The shape shows up on the screen so it cannot be 0.

Thanks

Tagged:

Answers

  • Much probably b/c loadShape() failed somehow. Make sure you spot any red warning texts in the console! :-B

  • GoToLoop, "The shape shows up on the screen", so it is loaded correctly.

    But in general, PShape isn't able to find out its own size, being often complex (a shape can be convex, can be made of other shapes, etc.).
    I think its width and height are defined mostly for SVG, and that's the viewport size, IIRC.

Sign In or Register to comment.