this post was submitted on 21 Feb 2024
4 points (100.0% liked)

Processing IDE & Coding

41 readers
1 users here now

Processing is a Java based programming language designed to educate new and existing programmers with a focus on visuals & OOP.

A javascript version is also available, called P5.js @ /c/[email protected]


Guidelines

  1. Schoolwork
    • Asking for help with homework is OK
    • Asking for a complete solution to your homework is NOT OK
    • Responding to a request with hints, suggestions, explanations, and pseudocode is OK
    • Responding to a request for help with a complete solution is discouraged but OK
  2. Text, Images, GIFs, and Videos showing off your work is welcome! Show us what you've done!
    • No self-promotion

Resources


Code of Conduct

For now, code of conduct shall simply follow the official CoC from the Lemmy organization: Link

Some highlights:

founded 1 year ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] breadsmasher 2 points 9 months ago (2 children)

If I understand correctly, I think what you are getting at is a class which contains the loaded model, and this class is passed into each instance of Person when it loads up.

On my phone and stuff, not intentionally vague but off the top of my head,

Have a PersonModel class which handles loading the model into memory and then the other Person class would have this PersonModel class as a dependency. When Person needs the Model, it would use the one declared in PersonModel

[–] TDSOJohn 1 points 9 months ago (1 children)

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

[–] breadsmasher 2 points 9 months ago