package custom_nodes; import shout3d.core.*; import shout3d.*; import java.awt.*; public class CountDisplay extends PostRenderEffect implements DeviceObserver { boolean initialized = false; int count = 0; Font labelFont = new Font("SansSerif", Font.BOLD, 16); //constructor public CountDisplay () { } //to handle mouse input public boolean onDeviceInput(DeviceInput di, Object userData) { MouseInput mi = (MouseInput)di; switch (mi.which) { case MouseInput.DOWN: count++; return true; } return false; } //called after each render; //overriden from super class public void filter(Graphics g, int surface_pixel_bits[], float z_buffer[], int deviceWidth, int deviceHeight){ //register to receive mouse events if (!initialized) { getViewer().getDeviceListener().addDeviceObserver(this, "MouseInput", null); initialized = true; } g.setFont(labelFont); g.setColor(java.awt.Color.red); String countString = ""+count; g.drawString(countString, 30, 30); } }