How to generate different 2D displays in Repast Simphony (gui or style code?)?

217 Views Asked by At

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!

1

There are 1 best solutions below

3
On BEST ANSWER

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).