> > I've got a bunch of autonomous objects that have there own threads and
> > control there own movement. Speed of these objects is therefore
[quoted text clipped - 18 lines]
> [*] Swing may create various worker threads in the background, but I'm
> saying that you should not be creating any threads in your own code.
Though any of my threads are coaleseced onto the event thread.
Anyhow what you are saying is effectively - Have one thread to paint and
poll other objects for their position. Therefore it is this polling that
provides a 'clock cycle' for the autonomous objects. They know to go y
pixels when polled. Is this what you are getting at Oliver?
I'm less interested in the best Swing approach more interested in the
modeling of the objects, so thought that they should not be reliant on a
view tiers polling?
If I keep the gui poll at a higher rate than any model tier update rate it
seems to behave nicely. The view can always ask the model what its minimum
rate should be.
I don't have a ton of threads, I realise this is bad. More, one thread
manages a group of related objects. I'm trying hard at cohesive design at
the moment.
--
Mike W
Oliver Wong - 31 Aug 2006 14:39 GMT
>> > I've got a bunch of autonomous objects that have there own threads and
>> > control there own movement. Speed of these objects is therefore
[quoted text clipped - 27 lines]
> provides a 'clock cycle' for the autonomous objects. They know to go y
> pixels when polled. Is this what you are getting at Oliver?
Yes.
> I'm less interested in the best Swing approach more interested in the
> modeling of the objects, so thought that they should not be reliant on a
[quoted text clipped - 7 lines]
> manages a group of related objects. I'm trying hard at cohesive design at
> the moment.
If you're going for an accurate simulation, you may have to choose to do
non-realtime rendering. For example, when scientists are modeling the
interactions of particles, they usually want something like nanoseconds or
less between each frame, since the particles are moving so fast. That leads
to something on the order of a billion frames per second, which their
computers can't handle. So they pre-render it such that a 3 second animation
might take 3 weeks to produce, and then save it as a video file to review.
- Oliver
gwlucas@adelphia.net - 01 Sep 2006 18:53 GMT
Quite awhile ago, I wrote a robot simulator in Java. It is now quite
obsolete
both in terms of Java practices and having been bypassed by other
simulator
projects, but you may find some useful ideas in some of its concepts,
particularly the simulator task queue. At the time it was written,
Java had a big
overhead problem with mutex locking and synchronized methods.
The way tasks were managed was a way of reducing the problem.
The thing that might be most relevant to you is the way
animation rendering was treated as just another simulation task that
could be scheduled via the task queue.
See http://rossum.sourceforge.net/sim/
> > > I've got a bunch of autonomous objects that have there own threads and
> > > control there own movement. Speed of these objects is therefore
[quoted text clipped - 41 lines]
> --
> Mike W