Combining 3 arrayLists of PVectors
in
Programming Questions
•
2 years ago
Hi guys,
I have an arrayList called model which contains 3 other arrayLists called modelPart. modelPart are arrayLists of PVectors.
I would like to join all the PVectors of the 3 arrayLists modelParts in one new arrayList called nodes, but I don't know the correct syntax. Here is the code bit:
class Model
{
ArrayList <ModelPart> model;
Model()
{
model = new ArrayList<ModelPart>();
}
}
class ModelPart
{
ArrayList nodes;
ModelPart(ArrayList<PVector> p)
{
nodes = new ArrayList();
getPoints(p);
}
void getPoints(ArrayList<PVector> p)
{
for(int i = 0; i < mod.model.size(); ++i)
{
nodes.add(threshold.points);
}
}
void draw()
{
threshold.display();
nodes.clear();
///////////////////////////////////////////////this is my last bad tentative/////////////
for(int i = 0; i < mod.model.size(); ++i)
{
ModelPart mopa = mod.model.get(i);
for(int j = 0; j < mopa.threshold.points.size(); j++)
{
KinectThreshold n = (KinectThreshold)threshold.points.get(i);
nodes.add(n);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
println(nodes.size());
}
}
main:
void draw()
{
for(int i = 0; i < mod.model.size(); i++)
{
ModelPart mp = mod.model.get(i);
mp.draw();
}
}
void keyPressed()
{
if(key == ' ')
{
if (mod.model.size() < 3)
{
mod.model.add(new ModelPart(threshold.points)); //the vectors are coming form a threshold class with points
}
}
}
thanks for your help in advance :)
I have an arrayList called model which contains 3 other arrayLists called modelPart. modelPart are arrayLists of PVectors.
I would like to join all the PVectors of the 3 arrayLists modelParts in one new arrayList called nodes, but I don't know the correct syntax. Here is the code bit:
class Model
{
ArrayList <ModelPart> model;
Model()
{
model = new ArrayList<ModelPart>();
}
}
class ModelPart
{
ArrayList nodes;
ModelPart(ArrayList<PVector> p)
{
nodes = new ArrayList();
getPoints(p);
}
void getPoints(ArrayList<PVector> p)
{
for(int i = 0; i < mod.model.size(); ++i)
{
nodes.add(threshold.points);
}
}
void draw()
{
threshold.display();
nodes.clear();
///////////////////////////////////////////////this is my last bad tentative/////////////
for(int i = 0; i < mod.model.size(); ++i)
{
ModelPart mopa = mod.model.get(i);
for(int j = 0; j < mopa.threshold.points.size(); j++)
{
KinectThreshold n = (KinectThreshold)threshold.points.get(i);
nodes.add(n);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
println(nodes.size());
}
}
main:
void draw()
{
for(int i = 0; i < mod.model.size(); i++)
{
ModelPart mp = mod.model.get(i);
mp.draw();
}
}
void keyPressed()
{
if(key == ' ')
{
if (mod.model.size() < 3)
{
mod.model.add(new ModelPart(threshold.points)); //the vectors are coming form a threshold class with points
}
}
}
thanks for your help in advance :)
1