Jump to content

Infect and spread color in DOPS


timur04

Recommended Posts

So I found a simple tutorial that showed how one point can infect other points around it and spread its color. 

But I'm having trouble doing the same thing in the AutoDopNetwork

I run this in a PointWrangle and nothing...

if(@infect == 0){
    float search = ch('search');
    int spnts[] = nearpoints(0,@P,search,5);
    int pt;
    foreach(pt;spnts){
        if(point(0,'infect',pt) == 1){
        @infect = 1;
        @Cd = {1,0,0};
        }
    }
} 
   

Any idea of what I'm doing wrong?

Link to comment
Share on other sites

3 hours ago, timur04 said:

So I found a simple tutorial that showed how one point can infect other points around it and spread its color. 

But I'm having trouble doing the same thing in the AutoDopNetwork

I run this in a PointWrangle and nothing...


if(@infect == 0){
    float search = ch('search');
    int spnts[] = nearpoints(0,@P,search,5);
    int pt;
    foreach(pt;spnts){
        if(point(0,'infect',pt) == 1){
        @infect = 1;
        @Cd = {1,0,0};
        }
    }
} 
   

Any idea of what I'm doing wrong?

Hi,

it should work. Maybe you did not create "search" parameter or its value equal 0. Hard to tell without scene.

Link to comment
Share on other sites

on your popwrangle2 you need to set Input1 to Myself in the Inputs tab

also it would help to disable popcolor1 (which is resetting all the color to red every timestep) and set guide visualization type to none as it's currently visualizing temperature attribute

Link to comment
Share on other sites

Beautiful boys! Worked like a charm.

One more thing, if the virus spread is too fast and reducing the search value doesn't do the trick.. How can I hake it that there us a 50/50 chance of infection?

I tried this but it didn't work
 

@infect = (rand($F)>0.5,1,0);

 

Link to comment
Share on other sites

On 3/19/2020 at 5:11 AM, anim said:

on your popwrangle2 you need to set Input1 to Myself in the Inputs tab

also it would help to disable popcolor1 (which is resetting all the color to red every timestep) and set guide visualization type to none as it's currently visualizing temperature attribute

OT: is there any definitive guide/tute on this very confusing subject ? The Input Myself blah blah...how's one noob supposed to know what to set it to ?

Link to comment
Share on other sites

2 hours ago, timur04 said:

I tried this but it didn't work


@infect = (rand($F)>0.5,1,0);

 

you need to use @Frame, also if 0.5 is a chance of infection then you want to use <=

@infect = rand(@Frame) <= chf("infection_chance");

but that will be steppy as all the potential infectees will either get infected or not per frame, so you may want to base it on frame and per particle

so make sure your particles have valid id attribute (since you are using Flip, check flipsolver1/PArticleMotion/Behavior/AddIDAttribute)  and then this should work

@infect = rand(@Frame, @id) <= chf("infection_chance");

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...