Starter:hello_keyinput, bug?

http://www.jmonkeyengine.com/wiki/doku.php?id=starter:hello_keyinput



…building TriMesh (a square):


...
 Vector3f[] vertexes={
  new Vector3f(0,0,0),
  new Vector3f(1,0,0),
  new Vector3f(0,1,0),
  new Vector3f(1,1,0)
  };
...
int[] indexes={
  0,1,2,1,2,3
  };
...



aren't indexes wrong? For the second triangle, if following counter-clockwise rule it should be "1,3,2" ?

... also in tutorial is used:


Texture t=TextureManager.loadTexture(monkeyLoc,
  Texture.MM_LINEAR,
  Texture.FM_LINEAR,true);



and that method doesn't exist (anymore?), there is one that takes extra "float anisoLevel" but javadoc doesn't says anywhere what anisoLevel actually is.

I'm noob so I won't even try to edit it myself :)
gerbildrop said:

The indexes are correct and, I believe, that they are actually related to the triangles themselves

0, 1, 2, 1, 3, 2 will not split the square into two triangles... it will simply not split the square at all.

1 and 2 are the common points that connected give a line that both triangles splitting the square have in common.


I wasn't talking about splitting it... just that second triangle that makes upper right half of the square is drawn clockwise if you put indexes 1,2,3, and the other is drawn counter-clock wise. So at the end you see half of the square upfront and half from behind?

the code for the tutorial is wrong, but not b/c of the anisoLevel.



It's incorrect, b/c the boolean value at the end isn't needed.



The indexes are correct and, I believe, that they are actually related to the triangles themselves





0, 1, 2, 1, 3, 2 will not split the square into two triangles… it will simply not split the square at all.



1 and 2 are the common points that connected give a line that both triangles splitting the square have in common.



And the javadocs on the homepage of jmonkeyengine are probably a little out of date…



timo

PS, I'll make the change in the wiki… if I have permission to

In this case both are drawn the same direction… or "splitting" the square by being drawn the same direction.



I'm not entirely sure about why the indicies are the way they are… I'm not that great at math, believe it or not.



I do know that when this is drawn the "split" line is indexed twice… 0 - 1 - 2 then starting back at 1 - 2 - 3



I don't know which direction is drawn first, CW or CCW… but I believe both triangles are drawn the same direction, in this implementation.



I basically know what caused the code to fail and what to do to fix it :smiley:



If you want anything in depth or explanatory… well, that's someone else.

…where do I get the free time for this? :slight_smile:





is this correct, anybody?

i'd say yes.

Kova, you are correct.  The reversed direction you found in the test is incorrect unless you were intending to have a flipped triangle or were drawing strips.  If you want to correct the wiki (changing the indices to 0,1,2,1,3,2 as you proposed) that would be great.

thx all, I corrected the wiki…