what im trying to do is take my nice little data structure and put it into a 2D array which i can copy and paste as code into my compiler... it takes TDPoints(like Point2D except has z value) which are in Faces(an arraylist of points, each face also has a color value), which are in objects(arraylist of faces, + other attributes)
for my sake im only working with one object, here is my code:
private void saveArrayToTXT(String name) throws IOException
{
double X;
double Y;
double Z;
FileOutputStream xos = new FileOutputStream("C:/Program Files/Xinox Software/JCreatorV3LE/MyProjects/ThreeDRemake/Files/" + name + ".txt");
DataOutputStream fos = new DataOutputStream(xos);//ObjectOutputStream oos = new ObjectOutputStream(fos);
//oos.writeObject(myObject);
//for(int ob = 0; ob < ((ArrayList)myObject).size(); ob++)
//{
ThreeDObject object = (ThreeDObject)(((ArrayList)myObject).get(0));
fos.writeChars("{");
for(int shape = 0; shape < object.getFaces().size(); shape++)
{
fos.writeChars("{");
ArrayList faces = object.getFaces();
for(int count = 0; count < ((Face)(faces.get(shape))).getPoints().size(); count++)
{
X = ((TDPoint)(((Face)(faces.get(shape))).getPoints().get(count))).getX();
Y = ((TDPoint)(((Face)(faces.get(shape))).getPoints().get(count))).getY();
Z = ((TDPoint)(((Face)(faces.get(shape))).getPoints().get(count))).getZ();
fos.writeChars("" + (int)X);
fos.writeChars(",");
fos.writeChars("" + (int)Y);
fos.writeChars(",");
fos.writeChars("" + (int)Z);
if(count != ((Face)(faces.get(shape))).getPoints().size()-1)
fos.writeChars(",");
if((count == ((Face)(faces.get(shape))).getPoints().size()-1) && (count < 5))
{
for(int lkj = count; lkj <5; lkj ++)
{
fos.writeChars(",");
fos.writeChars("" + (int)X);
fos.writeChars(",");
fos.writeChars("" + (int)Y);
fos.writeChars(",");
fos.writeChars("" + (int)Z);
}
}
}
fos.writeChars("}");
}
fos.writeChars("}");
//}
fos.close();
xos.close();
}
i happen to know for a fact that there are no faces with more than 6 points, so i used this line:
if((count == ((Face)(faces.get(shape))).getPoints().size()-1) && (count < 5))
and everything that follows to write ditto information(the last point) over and over again to fill up the array(i could even write a null value here if i wanted)
the problem im having is i seem to be missing two right brackets("}") and with all the information thats going through these loops its impossible to trace where and what is going wrong. can anyone point out any possible flaws to help me figure out what im doing wrong??
Message was edited by:
sosleepy
also, though its not important, when i do:
fos.writeChars("...")//(i used writeChars(); to save myself the hassle of typeing writeChar((int)'char').)
it writes a blankspace(spacebar) between each string i write, how can i prevent this from happening?
Message was edited by:
sosleepy
nvm i just realized what i was doing wrong... fixed the error, but a reply on the spaces between writes would be nice