Search code examples
java3djava-3dalice

Store 3D objects? (Java)


I am making a program such as Alice from Carnegie Melon University using JAVA.

I am not asking about Alice! What I really want to know is HOW DO I Store 3D Graphics?

I can't seem to find a very efficient way to store complicated 3D objects and figures! I need this for 3D object libraries. I have extracted all the files from alice.JAR and decompiled them to *.JAVA. I have studied them and I don't get it. I think Alice stores them in *.XML. Am I correct? If so, how are the *.XML files so small? Is there any better way to store 3D Graphics?

I am kind of really confused!?!

Can anybody please help me?

Any answers would be greatly appreciated! :)


Solution

  • Typically You have a list points, and a list of vertices.

    List points = new ArrayList<Point3D>();
    
    List verts = new ArrayList<Vertex3D>();
    

    You should encapsulate this data into an object and write it out you could do something like this

    NOTE not adding all the constructors / public methods

    CLass Model3D {
    
        List points = new ArrayList<Point3D>();
        List verts = new ArrayList<Vertex3D>();
    }
    
    Model3D m = new Model3D();
    
    ObjectOutputStream oos = new ObjectOutpuStream(new FileOutputStream( new File('./3d-file-otuput') ) );
    oos.write(m);