home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-11-27 | 1.8 KB | 52 lines |
- // A class for NFF objects
-
- // Written by Bernie Roehl, November 1996
-
- package nff;
-
- import java.io.*;
-
- public class Obj {
- protected String name;
- protected int nvertices, nfaces;
- protected Vertex[] vertices;
- protected Face[] faces;
-
- public String getName() { return name; }
- public int getNumberOfVertices() { return nvertices; }
- public int getNumberOfFaces() { return nfaces; }
- public Vertex getVertex(int n) { return vertices[n]; }
- public Face getFace(int n) { return faces[n]; }
-
- public void dump() {
- System.out.println("Object name = '" + name + "'");
- System.out.println("\t" + nvertices + " vertices, " + nfaces + " faces");
- System.out.println("vertices:");
- for (int i = 0; i < nvertices; ++i)
- vertices[i].dump();
- System.out.println("faces:");
- for (int i = 0; i < nfaces; ++i)
- faces[i].dump();
- }
-
- public Obj(String namevalue, CommentStripperInputStream input)
- throws IOException, NffSyntaxException {
- name = new String(namevalue);
- vertices = new Vertex[nvertices = Integer.parseInt(input.readLine())];
- for (int i = 0; i < nvertices; ++i)
- vertices[i] = new Vertex(input);
- faces = new Face[nfaces = Integer.parseInt(input.readLine())];
- for (int i = 0; i < nfaces; ++i) {
- faces[i] = new Face(input);
- for (int j = 0; j < faces[i].getNumberOfPoints(); ++j) {
- Vertex v = vertices[faces[i].getPoint(j)];
- if (v.getColor() == null) // at least one has no color
- faces[i].useVertexColors = false;
- if (v.getNormal() == null) // at least one has no normal
- faces[i].useVertexNormals = false;
- }
- }
- }
- }
-
-