Drawing an icosahedron sphere with drawVertexPrimitiveList?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Drawing an icosahedron sphere with drawVertexPrimitiveList?

Post 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
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post 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.
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post 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.
Granyte
Posts: 850
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post 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.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post by hendu »

Please read the tutorial on custom scene nodes. You need to set the transform and the material when drawing manually.
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post 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.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post 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.
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post 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.
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post 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
Gawaboumga
Posts: 11
Joined: Sun Jul 14, 2013 3:06 pm

Re: Drawing an icosahedron sphere with drawVertexPrimitiveLi

Post 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".
Post Reply