4

I have built a 3D model in repast simphony and it is working (fairly) well. However, due to the nature of the model, agents tend to form dense clumps. I was wondering if there is a way to generate a 2D slice or cross section through the middle of the clump to see what agents are doing inside the clumps, by either generating a continuously updating 2D display or an end-state view.

I have explored the display options in the gui and experimented with different layering of the agents, but due to the density, none of these have worked. Would there be a way to alter this aspect of the gui slightly to give a 2D view (for example) of the yz plane at x=25 in a 50x50x50 grid.

Thank you in advance for your help!

Catherine
  • 83
  • 4

1 Answers1

3

You can change the transparency of shapes in the 3D display by changing the transparency attributes in the style class based on a visibility attribute of the agent. For example, your agents could check their current position in 3D space and only return isVisible() true when the agent is in the plane of space you'd like to visualize. This will only show agents in the 3D display that exist on your defined plane, which can be any x,y,z orientation through the space. In your style class you will need to update the transparency in the getAppearance(...) method as follows:

public TaggedAppearance getAppearance(MyAgent agent, TaggedAppearance taggedAppearance, Object shapeID) {
    if (taggedAppearance == null) {
        taggedAppearance = new TaggedAppearance();

    // Customize your agent style here...           

     AppearanceFactory.setMaterialAppearance(taggedAppearance.getAppearance(), Color.white);
    }


    if (trans == null) { 
        trans = new TransparencyAttributes();
        trans.setCapability(TransparencyAttributes.ALLOW_VALUE_READ);
        trans.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
        trans.setCapability(TransparencyAttributes.ALLOW_MODE_READ);
        trans.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
        trans.setTransparencyMode(TransparencyAttributes.FASTEST);
        taggedAppearance.getAppearance().setTransparencyAttributes(trans);
    }

    if (agent.isVisible())
        trans.setTransparency(0.0f);
    else 
        trans.setTransparency(1.0f);

    return taggedAppearance;
}

You could also adjust the transparency value from 0 to 1 to provide different levels of transparency, so that the agents of interest are purely opaque (0.0f) while agents in the periphery are very transparent (0.8f).

Eric Tatara
  • 715
  • 3
  • 12
  • Thank you! Quick follow up question- how do I edit the style class? I believe I found the proper location (Repast Simphony Development Libraries/repast.simphony.bin_and_src.jar/visualization3D.style/TaggedAppearance.class), but I am unable to edit it. Also, would isVisible() need to be a parameter of the object, or could it be just a returned value in the step function? – Catherine Sep 24 '18 at 17:25
  • 1
    Please look at one of the Repast demo models that include 3D displays like the Predator Prey model to see how to include and edit style classes. The style classes need to be in your model source folder. – Eric Tatara Oct 12 '18 at 16:39
  • 1
    Hi Catherine, did you also ask a question recently about modeling the endothelium in Repast? If so you could please repost the question as it seems to have been removed. – Eric Tatara Oct 12 '18 at 16:40