help with vertices |
Author :
sapphiron
Post Date :
2005-09-30 03:40
Posts :
5
|
I have an array with 8 vertices that are supposed to draw a cube (actually they do, Im importing it from a ase file), but I have no idea how to draw it from those points, all I can do is draw 2 surfaces.. please help.
code:
GLfloat cubo [] = {
-0.2500, -0.0000, -0.2500,
0.2500, -0.0000, -0.2500,
-0.2500, -0.0000, 0.2500,
0.2500, -0.0000, 0.2500,
-0.2500, -0.5000, -0.2500,
0.2500, -0.5000, -0.2500,
-0.2500, -0.5000, 0.2500,
0.2500, -0.5000, 0.2500,
};
|
Author :
grant
Post Date :
2005-09-30 07:46
Posts :
117
|
Hi,
When specifying how to render the cube, you will need to use a vertex more than once. You could create an array containing 24 vertices with some duplicated, but the better way would be to create an array of indices.
These indices would refer back to a particular vertex. Your array of indices would be of size 24 and the elements in the array would range from between 0 and 8 (the different vertices).
You can then use the glDrawElements function. Please let me know if you continue to have problems.
Regards,
Grant |
Author :
grant
Post Date :
2005-09-30 07:48
Posts :
117
|
Hi,
Sorry, slight mistake above : the elements in the array would range from between 0 and 7, not 8.
Regards,
Grant |
Author :
sapphiron
Post Date :
2005-09-30 13:27
Posts :
5
|
I found that in the ascii file I also have the faces and the vertex they use, Ill try to parse that file and make 2 arrays and the build the poligon.
If this work, the algoritm can be used to import any object from any file converted to ascii. |
All Rights Reserved, © Zeus Communications, Multimedia & Development 2004-2005