Page 1 of 1

Drawing an icosahedron sphere with drawVertexPrimitiveList?

Posted: Wed Jan 15, 2014 6:07 am
by pandoragami
I have two files from this page http://people.sc.fsu.edu/~jburkardt%20/ ... _grid.html where one of the files is called
sphere_grid_icos1_f7_triangulation.txt and the other is sphere_grid_icos1_f7.xyz.

The first file is the triangulation part which is supposed to be used for setting up the indices in an array. I setup an array called

Code: Select all

 irr::u16 tri_i[980];
and
I'm assuming that I can just read the file from any column directly into the array for all 980 rows???

The second file is the points of each node which I store inside an array call

Code: Select all

irr::video::S3DVertex tri_v[492];
and I load all of those using a simple loop:

Code: Select all

 
for(int col = 0; col < 492; col++)
            {
                int x = this->floats_points[0][col];
                int y = this->floats_points[1][col];
                int z = this->floats_points[2][col];
 
                tri_v[col].Pos.set(x, y, z);
            }
 
where the float_points array contains all the positions.

To make a long story short I then try to use the call,

Code: Select all

driver->drawVertexPrimitiveList(tri_v, 980, tri_i, 492, irr::video::EVT_STANDARD, irr::scene::EPT_QUADS, irr::video::EIT_16BIT);
I'm just not sure what column to read for the indices and how many points I'm supposed to read in but I'm pretty sure the points array for the node positions is correct.

Any ideas?

Please,

Thanks!

EDIT: I added the files for the sphere indices and node points to pastebin for future reference in case that other site vanishes.

pastebin link for sphere_grid_icos1_f7.xyz -> http://pastebin.com/H9rn8CgX
and for sphere_grid_icos1_f7_triangles.txt -> http://pastebin.com/DP139wuT

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Thu Jan 16, 2014 2:43 am
by mongoose7
Err, the usual way would be to create a scene node and render it. You seem to be trying to do OpenGL programming inside Irrlicht. Why? You can't call the drawing method without setting the OpenGL state. My only advice to you is to try GLUT.

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Thu Jan 16, 2014 5:05 am
by pandoragami
@Mongoose,

Right, I would need to create a device with OPENGL as the driver, but using the vertexprimitive list is pretty standard in irrlicht, no? I suppose I could use glut but okay for the sake of setting up the vertexprimitivelist for drawing an icosahedron (which is what I titled this thread in the first place), how would I use the indices, anybody?


thanks Mongoose, if no one answers thats fine... no problem.

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Thu Jan 16, 2014 8:05 am
by Granyte
the indices depend on the mesh you built I don't know how to build them for an isocaedron but if what you are asking is how to draw an indexed mesh there should be a call drawIndexedVertexPrimitiveList. How ever I would sugest using a mesh buffer and drawing using drawmeshbuffer.

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Thu Jan 16, 2014 9:37 am
by hendu
Please read the tutorial on custom scene nodes. You need to set the transform and the material when drawing manually.

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Thu Jan 16, 2014 6:03 pm
by pandoragami
the indices depend on the mesh you built I don't know how to build them for an isocaedron but if what you are asking is how to draw an indexed mesh there should be a call drawIndexedVertexPrimitiveList. How ever I would sugest using a mesh buffer and drawing using drawmeshbuffer.
I tried finding the

Code: Select all

drawIndexedVertexPrimitiveList
method in the irrlicht documentation, no luck, can you point me there please?
Please read the tutorial on custom scene nodes. You need to set the transform and the material when drawing manually.
Yes, I've seen that and all the other tutorials. I've been using Irrlicht for years now and I've done a lot of stuff with it but I just wanted to try this on a whim. It's not important if it doesn't work, I just wanted to try out making an icosahedron manually.

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Thu Jan 16, 2014 7:57 pm
by hendu
Well, you're on the right track then. The drawIndexed* functions are just wrappers for drawVertexPrimitiveList. The values you need to check are vertexcount, primcount and the primitive type - you say you have 980 verts and 492 quads, which doesn't match at all the data you're providing.

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Thu Jan 16, 2014 8:13 pm
by pandoragami
hendu wrote:Well, you're on the right track then. The drawIndexed* functions are just wrappers for drawVertexPrimitiveList. The values you need to check are vertexcount, primcount and the primitive type - you say you have 980 verts and 492 quads, which doesn't match at all the data you're providing.

If you don't think it's possible with the given information I won't even bother trying to make this work. I can't find a way to generate the proper data to render the polygons correctly so I guess this is pretty much a dead subject.

Thanks to all of you for trying though.

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Mon Jan 20, 2014 5:39 am
by smso
Sure this can be done in irrlicht. Extract the vertices and indices from the data files by parsing with std::ifstream and std::stringstream. Then set up a scene::SMesh from the vertices and indices and create a scene::IMeshSceneNode for rendering.

Cautious: Index in irrlicht starts from 0 instead of 1 as depicted in the data file.

Regards,
smso

Screenshot:
http://code.google.com/p/irrcodes/downl ... enshot.png

Regards,
smso

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Posted: Mon Jan 20, 2014 7:34 am
by Gawaboumga
Have you take a look to:
http://irrlicht.sourceforge.net/forum/v ... 8&start=15

Or you could just see the code of CGeometryCreator / CCubeSceneNode ...

drawVertexPrimitiveList is less easy to work with, SMeshBuffer are more "user friendly".