Jump to content
John Svensson

Duplicating RBD objects in SOP Solver

Recommended Posts

Hi!

 

I'm trying to recreate something like the duplicating treasure from Harry Potter. I've got a pretty good start but i've run in to a couple of problems. Each generating more problems.

 

The first is that I haven't succeeded to constrain my duplicating effect to only solve once a frame for each object. And the other, more important, I haven't managed to successfully give my duplicated DOP objects unique names. 

It works for the first couple of duplications but after a while it all falls apart, this leading to incorrect velocity etc.

 

I'm using packed objects in combination with a object_merge in a foreach sop in a sopsolver for this, an area that I'm not at all comfortable (DOPs).

 

If someone wanted to take a look I'm grateful. And / Or if someone is trying to do something similar, I think I'm up to a decent start here. (Could be wrong)

 

Thanks

 

/ John

Duplicating_Test_V01_02.hipnc

Share this post


Link to post
Share on other sites

Check out my last hip from this thread, maybe it could help; http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=31855

 

Tanks for your replay eetu.

 

I looked at your file and mine look a lot like yours, but I've tried to take it one step further than your example.

 

I do get an error with your file tough, at frame 30 one of the spheres duplicates and then the Rigid Body Solver gets an error due to the name attribute that doesn't exist on the newly created sphere. And on the next frame everything disappears.

 

I just opened my original file on my home computer instead at work and now I get a similar result, when the name attribute conflicts the rbd solver blanks out. 

 

This is the result I got now, and due to the naming problem this is expected, at frame 137 two cubes are created both name attribute set to "piece9". And the next frame everything blanks out.

 

https://vimeo.com/99660932

 

In my file i tried to tackle the unique name attribute problem with an Attrib Wrangle Sop with an VEX expression thats suppose to lookup how many primitives there are and use that as the name.

s@name = "piece" + itoa(nprimitives(2));

I think that it works up until that point there is more than one new object created each frame.

 

Any ideas how to get a solid unique name attribute?

Duplicating_Test_V01_03.hip

Edited by John Svensson

Share this post


Link to post
Share on other sites

Ah I didn't really look at your scene before, just remembered a similar topic.. :)

 

You could think of it a bit like a hash, something like

 s@name = "piece" + itoa(nprimitives(2)*11911 + 91*point(1, "id", 0));

didn't seem to give any duplicates up to few hundred, when I checked. You can probably figure out a safer one :)

 

edit: For me it does not complain even if there were duplicate names, interesting.

Duplicating_Test_V01_ee.hip

Edited by eetu

Share this post


Link to post
Share on other sites

Ah nice! That will suffice for now. Thank you eetu :) But still, I would like to get this nprimitives to work for future purposes.

 

I tried using the attribute wrangle with nprimitives again but with an absolute path to the node, just any node up the chain in this case. But that still didn't work when multiple instances was created on the same frame 

i@num = nprimitives("op:/obj/AutoDopNetwork_Duplicate_Cubes/sopsolver_duplicate_1/dop_geometry");

The problem is when i middle mouse button click on my sopsolver on a frame where something was just duplicated the sop solver has the correct count of primitives and points. But when dive inside it and middle mouse button click on the dop_geometry node (Dop Import) it has a lower number, as if it hasn't cooked yet or something.

If I step forward one frame and then back the number is updated and correct.... Weird, so my absolute path to the dop_geometry node doesn't help me. And I cant get the path to work for the sop solver or the multisolver one level up.

 

How to you with Vex or Hscript get something like the number of primitives in any of these Dop nodes, such as a Multisolver?

Share this post


Link to post
Share on other sites

What is your workflow for creating multiple objects at once? Why dont you just nprims + number of new instance?

I think you can dive into pop source/rbd point object dop to check what is the default solution

Share this post


Link to post
Share on other sites

Hi again! I've been away so I haven't had a chance to work on this. Anyway thanks for your answer.

 

I use a Multisolver with RBD solver and a SOP Solver, in the SOP Solver I loop through all the objects in the sim with a ForEach SOP each frame and if a condition is met, like once every 25 frame I Object Merge in a new cube at the current cubes location.

 

I think the problem is when 2 cubes is created at the same frame, this happens in different cooks of the ForEach SOP so I cant take "nprims + number".

I tried to jump up two levels, out from the ForEach and query the DOP Import of the SOP Solver. But the same thing happens when 2 instances is created on the same frame.

 

What I think might be a solution is query the Multiple Solver for the number of primitives. I've been on google for the past 2 hours trying to figure out how to use all the hscript functions like dopfield, dopnumobjects and so on without any success. I think I might be missing something with these DOP nodes.

 

How do you query number of prims or points in DOP node?

 

When i middle mouse click on my Multiple Solver it says:

 

geo1 - Geometry : 11 points; 11 prims.

 

How do I get that using HScript or VEX?

 

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×