Giter Club home page Giter Club logo

Comments (7)

peteihis avatar peteihis commented on September 22, 2024

And of course I can use the isPreview() option and create just brick model (which helps a bit) for interactive viewing, but then I'd sometimes like to see the final one on the editor too.

What if there were two toggles on the scripted object editor: Still / Animating and Preview / Final? -- Then there should probably be something to detect if isPreview() or Time() are used in the script or the parameters.

from artofillusion.

Sailsman63 avatar Sailsman63 commented on September 22, 2024

a repetitive pattern that changes along distance.

Do you mean 'changes based on location in scene' or something else?

If this really is a static object, or one that only changes at a few specific points on the timeline, the script should cache the completed CSG model, and perhaps a converted TriangleMesh. Just use the cached object unless the time/location/whatever invalidates the current shape.

from artofillusion.

peteihis avatar peteihis commented on September 22, 2024

'changes based on location'

Yes, basically so. The changing dimensions happen in local space and the scripted object actually reads some dimensions from a hand sketched curve on the scene.

script should cache the completed CSG model

Now that you say it, I think I may have tried something like that before. -- I think I used a separate script to reset the scripted object (= set the object in memory to null)... I think that could be done by a boolean variable in groovy memory.

The content of the scripted object is actually

50 CSGObjects × 2
 1 Cylinder   × 50
 1 Cylinder   ×  1
 1 Sphere     ×  1
12 parameters to control the build. 

So to cache it I'd have to cache the parameters, the vertex positions of the curve and each object with the list of coordinate systems where to add it. Then the script should check the if any of the parameters or the extra boolean or the control curve have changed to make the decision if it should recreate the objects or use the ones in the memory...

So far I have used @field and/or declared each variable, because undeclared variables that float in the memory tend to ... well ... be remembered even when they have become obsolete and then the next time I open the scene the script may not work.

Something like that?

from artofillusion.

Sailsman63 avatar Sailsman63 commented on September 22, 2024

While doing a little digging to make sure I understood the question in #241, I found that ObjectCollection (Which ScriptedObject derives from) already caches the object structure under the hood. If it's rebuilding for every frame, your script is either:

  • Calling for the current time, and (not?)changing things based on that time
  • Calling for coordinates, and (not?)changing things

The content of the scripted object is actually

That's a lot going on in a single scripted object. How many of these objects:

  • Actually depend on time, directly or indirectly?
  • Depend on location of the ScriptedObject?
  • Depend on location of/shape of another object?

Of those 12 parameters, how many vary based on time? (IE, have a track)

from artofillusion.

peteihis avatar peteihis commented on September 22, 2024

I see...

None of them depend on time in any way or have tracks or depend on the location of the object. The 50 CSGs depend of a curve on the scene. The curve is not moving and the location of the curve is not a factor, only vertex positions are used.

What is done, is that the scripted object gets a duplicate of the curve, subdivides it a few times, get vertex vectors into an array and then finds (by linear interpolation) the corresponding x-value for each of the 50 y-values that define the CSGs.

So the way to tame it down would be to extract vertexPositions() of the (unsmoothed) curve by other means and save those as an array in the script text? (A script to build a scripted object is not entirely alien to me. -- Type a marker in the scripted object text and tell a tool script to edit that part....) -- And then recreate the curve inside the scripted object and start smoothing...

It's a kind of pity I can't show the thing (not until it's public anyway) but I'm doing it for somebody else.

from artofillusion.

Sailsman63 avatar Sailsman63 commented on September 22, 2024

This doesn't sound like it should be re-building on every frame.

By default, each object does have a position & rotation track, even if there are no keyframes. Maybe that's enough? Try manually deleting these tracks from the curve object, and see if that makes a difference.

So the way to tame it down would be to extract vertexPositions() of the (unsmoothed) curve by other means and save those as an array in the script text?

I don't know if that would help, and shouldn't be necessary.

Would it be possible to share a "Anonymized" version of the script? I'm thinking:

  • 1 or 2 CSGs made up of a couple of random sphere/cylinder/whatever to stand in for your actual models
  • A simple curve, maybe no more than 3 or 4 points
  • 1 or 2 parameters

What I'm really interested in is:

  • How the parameters are input to the script
  • How all of the parts interact:
    • What math and logic are used to interrelate them?
    • How and when are the various inputs changed?

from artofillusion.

peteihis avatar peteihis commented on September 22, 2024

How the parameters are input to the script

I said parameters but what I mean is just typed in values of variables (that are in essense parameters of the process of creating the objects) -- so no script parameters involved. Like double size = 0.5; Cube cube = new Cube(size, size, size);

I'll come back to with example script.

from artofillusion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.