Understanding how render a 3d model

I watched the video2 times, the first time I just copied the source code, this time I actually followed along and coded, but I had a hard time actually drawing the figure. Based off of the video https://www.youtube.com/watch?v=izKAvSV3qk0 (how do I replace the text with a url having blue text?)
I coded along, mostly understanding. Then in the DisplayList rendering code, I’m not sure what I did wrong, and I’m clueless as to what it does. In the source code he uses this:

for (Model.Face face : m.getFaces()) {
                Vector3f n1 = m.getNormals().get(face.getNormalIndices()[0] - 1);
                glNormal3f(n1.x, n1.y, n1.z);
                Vector3f v1 = m.getVertices().get(face.getVertexIndices()[0] - 1);
                glVertex3f(v1.x, v1.y, v1.z);
                Vector3f n2 = m.getNormals().get(face.getNormalIndices()[1] - 1);
                glNormal3f(n2.x, n2.y, n2.z);
                Vector3f v2 = m.getVertices().get(face.getVertexIndices()[1] - 1);
                glVertex3f(v2.x, v2.y, v2.z);
                Vector3f n3 = m.getNormals().get(face.getNormalIndices()[2] - 1);
                glNormal3f(n3.x, n3.y, n3.z);
                Vector3f v3 = m.getVertices().get(face.getVertexIndices()[2] - 1);
                glVertex3f(v3.x, v3.y, v3.z);
}

(Calm your tits, I used glBegin/End glNewLists…)

And since I was coding along, I ended up with this:

what he did but I deleted it lol… Let’s just say if I typed exactly what he did in the vvideo should it work? I’m using the classes from episode 19 also but I don’t understand the source code. ??? ??? ??? ??? ??? ??? ??? ???

[icode]Blue Text Here[/icode]

I re-wrote everything from the video. Now, I get this exception:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 34831, Size: 34831
	at java.util.ArrayList.rangeCheck(ArrayList.java:638)
	at java.util.ArrayList.get(ArrayList.java:414)
	at dabunny.ModelDemo.setUpDisplayLists(ModelDemo.java:65)
	at dabunny.ModelDemo.main(ModelDemo.java:35)

Line 65:

            	Vector3f n1 = m.normals.get((int) face.normal.x - 1);

Line 35:

        setUpDisplayLists();

This is how I render:

	Vector3f n1 = m.normals.get((int) face.normal.x - 1);
           /**/ glNormal3f(n1.x, n1.y, n1.z);
                Vector3f v1 = m.vertices.get((int) face.vertex.x - 1);
                glVertex3f(v1.x, v1.y, v1.z);
                
                
                Vector3f n2 = m.normals.get((int) face.normal.y - 1);
          /**/  glNormal3f(n1.x, n1.y, n1.z);
                Vector3f v2 = m.vertices.get((int) face.vertex.y - 1);
                glVertex3f(v2.x, v2.y, v2.z);
                
                
                Vector3f n3 = m.normals.get((int) face.normal.z - 1);
          /**/  glNormal3f(n1.x, n1.y, n1.z);
                Vector3f v3 = m.vertices.get((int) face.vertex.z - 1);
                glVertex3f(v3.x, v3.y, v3.z);

Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 34831, Size: 34831

^Tells us that you’re checking a position that doesn’t exist, you can’t get the index of the size of the array, because arrays start at 0. So find out why you’re sampling a bad position and we can go from there.

You are using the x value of your normal as if it is an index into the normal list and calling a get() on it.