We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a 2d Arraylist, quite new with this so I might have an error in the creation of it. Can't seem to figure out what's wrong. Here's creating the arrays in settings():
for (int x = 0; x < width+gridSize; x=x+gridSize) {
ArrayList vList = new ArrayList();
for (int z = 0; z < height+gridSize; z=z+gridSize) {
vList.add(new PVector(x,0,z));
}
vectorList.add(vList);
}
then in draw()
for (int i = 0; i < vectorList.size(); ++i) {
ArrayList vList = vectorList.get(i);
for (int j = 0; j < vList.size(); ++j) {
Object v = vList.get(i);
println("v: "+v.getClass());
the getClass gives me: class processing.core.PVector but v.x: x cannot be resolved or is not a field and v.array: The function array() does not exist.
I'm lost here.. It's a PVector right? Why can't I access it methods?
Answers
Line 2 belongs outside/ before loops in the first code segment
You are producing an ArrayList of ArrayList of PVector. Completely complex. Why?
2nd code segment:
line 4: PVector v = .....
println (v.x);
Not if he's creating a list of lists - line 2 would be creating the inner list.
I think we need to see more code because there are important things going on here that we aren't being shown. Like the definition of vectorlist.
Thanks for the quick answer @chrisir !
Ok let me elaborate, I want to draw A shapes (depends on the gridSize) and each of those shapes have B coordinates. Basically the shapes are lines within a grid and I want to be able to manipulate each of the coordinates per shape independently.
When I write line 4 Pvector v = I get the error: cannot convert from Object to PVector Although getClass says it's a PVector.. So I'm very confused on this one. Sorry I forgot to add this :)
PVector v = (PVector) vList.....
Maybe look at beginShape and vertex to store a shape
In theory you can tell the ArrayList its type
Not sure in your case with a nested ArrayList though
https://forum.Processing.org/two/discussions/tagged/2darraylist
https://forum.Processing.org/two/discussions/tagged?Tag=#generics
@chrisir That way of converting works! @koogs Here is the rest of the code (removed all libraries):
I just don't get to see any points and lines yet..
Line 37
j !!!!!!!!
Not i
Not sure but might look better with lights();
thanks @chrisir ! Always the obvious little things :)
I got eyes like an eagle.
;-)
Try lights();
@chrisir no difference with the lights(). Perhaps with shaders I could do something but I just started learning how to use them (the pain in my head trying to understand it). So right now they're just vertices and lines which I want to animate with OSC (from audio analysing songs) and with controlP5 controls.
but after replacing i and j I started seeing the vertices :)
in my version you can see the effect of
lights()
:If the object isn't changing after being defined in setup () then you should look into using PShape, which you define once and then draw using a single call.
Thanks!
In flowens code I see only lines, maybe you can explain what your goal is
he @chrisir that's some cool stuff! I'll inspect the code later to see how you made this.
I created this myself:
https://www.instagram.com/p/BQx3b1dA6c5/ https://www.instagram.com/p/BQzLsYwAiAZ/
I'm using Coge (imimot.com) on top to layer some effects like mirrors and audio-analyzing. I send OSC as well and some controls in the sketch to manipulate things around. And use Syphon to stream the pixeldata from one application to the other (so from processing to Coge) and record it as well
@flowen Really cool work.
Kf
@kfrajer thanks man! appreciate it :)
Very impressive!
@chrisir thanks to you and the forum I was able to finish it!