We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › array list/get question
Page Index Toggle Pages: 1
array list/get question (Read 324 times)
array list/get question
Nov 8th, 2008, 3:55pm
 
at the risk of looking stupid (again)

i've done a quick simulation using an agent i've developed. the agent samples pixel colors along a series of rays and so can 'see' obstacles etc of a particular colour.

the agents are drawn with an array list to allow them to be added/removed incrementally.

problem is that at the minute an agent can only 'see' the colours of the agents after it on the array list, not those drawn before.

is there an easy way around this? i tried using pixels[] instead of 'get' but it gave an array out of bounds exception.

ta
S

i've put a zip file with the simulation here:
http://www.surfacearchitects.com/gfx/AGENT_MK_IV.zip

Re: array list/get question
Reply #1 - Nov 9th, 2008, 8:18pm
 
> problem is that at the minute an agent can only 'see' the colours of the agents after it on the array list, not those drawn before.

but you're drawing them in reverse order so it's actually only seeing the ones that are already drawn, which makes sense.

not sure what you're trying to do and whether this will be possible, but you might have to have two loops, one for drawing and another after all the drawing for the detecting.
Re: array list/get question
Reply #2 - Nov 9th, 2008, 9:08pm
 
ok, i see now, that won't work because they all need to be aware of each other during the drawing.

the only way to do it would be to do it in increments, interlacing the separate ray detecting calls.

ie where you have, in your depth ray code checking each pixel along the path in turn
 for (int x = 16; x < ray_view; x++)

you should move this up a level or two so you're effectively doing

Code:

for each pixel in path
for each ray
detect next pixel
draw next pixel


um, not sure that will work (efficiently) because you'll be testing each ray up to 400 pixels whether they get blocked or not.
Page Index Toggle Pages: 1