Maxscript bug / my dumb coding with trace sets?

Hi Folks!

A friend is working on a shot where he has to make gradually smaller copies of a scene with a camera zoom in, he wants all of them to look the same so that it can loop seamlessly. If we make the lights in each scene include only the objects in the max file, when we xref it multiple times we get consistent lighting. The next issue is now reflections where we don’t want a model from one xref to reflect anything from another. Since there’s a high object count I want to script trace sets so that it’ll loop through all geo in the scene and add in every object in the scene except itself. This should be fine but I’m getting a dependency loop error. Any thoughts as to why the assignment doesn’t behave?

Here’s my code which is less elegant than dave wortley’s, who is also getting the same error:


theObjs = geometry as array

for i = 1 to theObjs.count do
(
format "debug: working on object % \n" theObjs[i].name
theTempArray = (for g in geometry where [URL="http://g.name/"]g.name[/URL] != theObjs[i].name collect g)
print theTempArray
theTraceSet = vrayGetTraceSets theObjs[i]
theTraceSet.reflect_exclude = theTempArray
--theTraceSet.reflect_exclude_type = 1
    --theTraceSet.refract_exclude_type = 1
)

On a simple scene with a box, sphere and a teapot here’s my error log:


#($Box:Box001 @ [-1873.043213,223.505310,0.000000], $Sphere:Sphere001 @ [2674.760010,376.476868,0.000000], $Teapot:Teapot001 @ [6023.598633,310.325775,0.000000])
debug: working on object Box001 
$Sphere:Sphere001 @ [2674.760010,376.476868,0.000000]
$Teapot:Teapot001 @ [6023.598633,310.325775,0.000000]
debug: working on object Sphere001 
$Box:Box001 @ [-1873.043213,223.505310,0.000000]
$Teapot:Teapot001 @ [6023.598633,310.325775,0.000000]
-- Error occurred in i loop; filename: ; position: 717; line: 19
--  Frame:
--   i: 2
--   theTempArray: #($Box001, $Teapot001)
--   theTraceSet: VRayTraceSets:V-Ray trace sets
-- Runtime error: Assignment failed, possible dependency loop, $Box:Box001 @ [-1873.043213,223.505310,0.000000]

Any thoughts?

Ah, seems like it’s the same max bug from this post - Trace sets question - Issues - Chaos Forum

Instead of excluding everything - you maybe could just include what needs to be reflected. This should avoid the overlap between your trace sets that is leading to the dependency loop. There needs to be atleast 1 object in the trace set or it doesn’t work (that might be a V-ray bug or maybe there is some weird reason for that). You could make that one object anything (e.g. a Dummy).

So like this (assuming an object named “Dummy001” is in the scene):

.reflect_exclude = #($Dummy001)
.reflect_exclude_type=1 -- include instead of exclude

Looking add your code you maybe already tried that at some point and run into that. Just make sure your main loop skips the object used as a dummy in the include list and also that the object actually has a trace set. As far as I see form my experiment one hast to add a trace set first using vrayAddTraceSets(). In your code I only see a call to vrayGetTraceSets()

Best Regards,
Daniel Schmidt

Ah, that’s interesting about the one object first!

Yep, I was thinking the same thing with the include (that’s the ultimate aim, to try and ring fence things to only the scene) but I wasn’t aware about manually adding something in first. P.s. are you in canada at the minute? You might be one row away from me :smile:

Cheers!

John

Germany John - so far far away :slight_smile: I found another trick to avoid dependency loop. Let’s say you have multiple teapots and multiple spheres that should exclude each other. So no teapot should reflect a sphere and no sphere should reflect a teapot. You would run into the dependency loop issue.To avoid it one can group the objects. Now instead of excluding all the teapots individually each sphere excludes just the “group of teapots” and all teapots exclude the “group of spheres”. No dependency loop.

Daniel

We’ve a daniel schmidt in here too and he’s a bit of a max ninja it seems! Nice tip on the groups, we’re at 182 objects in the scene which all have to just include the other 181 objects, I don’t think things can be in multiple groups in max if I remember rightly due to the added group transforms conflicting but i’ll try the manual add of one object now and see how it goes!

Yeah pretty much any option comes back with that dependency loop issue - either the regular dependency loop or the max param block :confused:

I made a big dumb assumption about groups so thought i’d have to make an individual group per object containing all the other objects since the trace sets would error if you tried to assign an object to not be able to reflect itself- thanks again for the clarification Daniel, I’ll do that this evening!

This group trick looks nteresting, but groups are adding hierarchy in 3dsmax, so the transform controllers would be a mess to set and overkill with a lot of objects… 3dsmax doesn’t like huge hierarchy.
I still think that weak references is the way to go, Vlado never updated me on that so I am still in the dark about why not?

Same issue that stops distance tex maps from working with each other too I think?