Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Understanding how render a 3d model  (Read 695 times)
0 Members and 1 Guest are viewing this topic.
Offline AppleSauce
« Posted 2014-06-15 21:10:30 »

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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
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. Huh Huh Huh Huh Huh Huh Huh Huh
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #1 - Posted 2014-06-15 22:30:57 »

(how do I replace the text with a url having blue text?)

[url=https://www.youtube.com/watch?v=izKAvSV3qk0]Blue Text Here[/url]

Offline AppleSauce
« Reply #2 - Posted 2014-06-15 22:35:30 »

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

1  
2  
3  
4  
5  
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:
1  
               Vector3f n1 = m.normals.get((int) face.normal.x - 1);


Line 35:
1  
        setUpDisplayLists();



This is how I render:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
   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);
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline thedanisaur

Senior Member


Medals: 10
Exp: 1 year



« Reply #3 - Posted 2014-07-11 16:56:37 »

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.

Every village needs an idiot Cool
Offline ewg

Junior Member


Medals: 8


Java games rock!


« Reply #4 - Posted 2014-07-11 17:10:09 »

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. 
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (23 views)
2014-09-12 09:08:26

Norakomi (56 views)
2014-09-10 13:57:51

TehJavaDev (69 views)
2014-09-10 06:39:09

Tekkerue (34 views)
2014-09-09 02:24:56

mitcheeb (56 views)
2014-09-08 06:06:29

BurntPizza (40 views)
2014-09-07 01:13:42

Longarmx (25 views)
2014-09-07 01:12:14

Longarmx (31 views)
2014-09-07 01:11:22

Longarmx (31 views)
2014-09-07 01:10:19

mitcheeb (39 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!