Hi everyone, first of all I’m so happy to have found a Processing instance here on Lemmy!

I’m doing a Processing project where I have ~100 instances of people, all coming from the same 3d model. I’m currently storing all the PShapes inside a 1D array and doing all the drawing inside the draw() function. Now, I would love to put everything that concerns the person inside a class. If I create something like:

class Person {
    PShape person_obj  = loadShape("path/to/shape.obj");

    Person() {}
}

does Processing automatically load only a single model or do I have 100 models in RAM? If the answer is the latter, I tried changing PShape to a static variable but loadShape() is not static and everything results in an error.

Processing documentation about explicit simply says “yeah it’s a java language feature, study it if you need it” which makes sense. So, I started looking for static usages in Java and tumbled upon this StackOverflow post, that basically says to use a context class with all the 3d objects I statically need and pass is to everything else that needs the 3d models.

(link: https://stackoverflow.com/questions/4969171/cannot-make-a-static-reference-to-the-non-static-method )

Does anyone know if it’s the correct approach for Processing?

  • @TDSOJohnOP
    link
    English
    17 months ago

    Thanks, so something like passing PersonModel in the constructor Person(PersonModel p) should work because it’s passed by reference, right?