PickDemo.java + ModelFactory


Just wanted to know, how you would go about designing picking in the scene and updating the HUD. The PickDemo.java is a great example of how to pick spatials - but these are generated in a ModelFactory. Would you have a reference to a HudState (to allow for updating the HUD) and call a method there?

Kind regards,

I also had the idea of developing a ‘selected’ entitycomponent, to make it visible in the entire entity-system which entities are selected - what’s your take on this ?

My game is a tower defense / rts with lots of entities on the scene, allowing you to select multiple units (with a click-drag box soon to be implemented)

Kind regards,

You could do selection as a component but it might cause you trouble later. Selection is inherently view specific after all.

Is selection purely displayed in a HUD or is it maybe also displayed in 3D?

Either way, I might have a SelectionState to show selection and then manage it that way. This state could handle rubberband style selection maybe… but also you could add click listeners to each selectable thing that called back to this state.

The selection is displayed in the scene as well as in the HUD (which is Lemur, so also the scene I suppose?).

I forgot about how easy it is to call a state. I’ll do that I think. Thanks

So I guess my question is, is there a way to find my way back from a spatial (which Lemur PickDemo.java is using) to the ModelComponent, to the entity.

The reason I need a connection is that if I select X towers, I might upgrade them / sell them etc. so I need to know which entities I have selected.

You could stick the entity ID on the Spatial’s user data. I do that all the time.

Otherwise, you have to keep a Map<EntityId, Spatial> somewhere (and might anyway) but it’s often convenient to know which entity a spatial belongs to.

Ah, clever usage. Thank you so much.