Login | Register 

Programatically create objects and access its properties.

Still a little green? Ask your beginner's questions here

Programatically create objects and access its properties.

Postby zjorge » Tue Aug 13, 2019 12:45 pm

I'm having a hard time trying to find the way to achieve this. Maybe I'm not using the proper words to search but haven't found anything on Google or this forum yet. I'd like to create a series of objects programmatically and still keep them identified so I can modify their properties individually or by group. Let's say somewhere I have something like:

Code: Select all
for x in range(0, 99):
   for y in range(0, 99):
    s[id]=new Sphere() #making this up, I have no idea...

That would just create 10,000 spheres and give then an initial position. Then at anytime let's say, change some of their sizes by using something like:

Code: Select all
for i in range(0, 200):
    #or even better calling a function that animates the property

Does this makes any sense? Is this a reasonable way of creating and accessing geometry in TD?
I'm just trying to do this https://zoada.com/lp/?l=en look more like this https://zoada.com/lpa/ and instead of using controls, make it audio reactive.
Posts: 1
Joined: Sun Mar 03, 2019 1:33 am

Re: Programatically create objects and access its properties

Postby CorbinWhite » Fri Aug 16, 2019 6:12 am

You want instancing. Matthew Ragan has great tutorials on this on YouTube. If you’re looking to created 100s-1000s of instances, i would also invest in his Make Some Noise series, it’s long, and dense, but there’s a lot of great info for dealing with lots of computations, even if you don’t get into the GLSL stuff.
Posts: 128
Joined: Sun Aug 16, 2015 2:49 pm

Re: Programatically create objects and access its properties

Postby yeataro » Sat Aug 17, 2019 10:15 am

To operate entirely through Python, if we consider real-time performance, there are several ways to think about it:

1. Create a structured numpy.array and store it via OP.store(), then manipulate it. Then extract it with script CHOP, then Instance (if you want to have different shapes, you can use different numbers to identify different CHOPs and then individual instances)

2. Create some points using the model SOP, using the built-in and custom attributes, then:
  a. Use this sop directly to Instance.
  b. Use Geometry shader to create various shapes based on the attributes of the points

3. Find a way to manipulate the Compute Shader using Python (convert each command to an array), then:
  a. Use this texture directly to Instance.
  b. Use the Geometry shader to create a variety of different shapes based on the values of each pixel.

Of course, if you don't have frequent, large-scale parallel operations, and only require static results, then using table DAT+replicator COMP is also a more intuitive method (or table DAT+Instance).
User avatar
Posts: 20
Joined: Tue Sep 28, 2010 2:31 pm
Location: Taipei

Return to Beginners

Who is online

Users browsing this forum: No registered users and 17 guests