How to create a mesh giving it's vertexes?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
WindScar
Posts: 7
Joined: Wed Sep 01, 2010 10:38 pm

How to create a mesh giving it's vertexes?

Post by WindScar »

For instance:
IMesh * createMesh(v3d(0,0,0),v3d(1,0,0),v3d(0,1,0),v3d(1,0,0));

To create a simple pyramid. What's the right code for it?
Thanks in advance.
cookie
Posts: 83
Joined: Sun Aug 23, 2009 9:30 pm

Post by cookie »

Out of the exampleSceneNodePlugin from irrEdit:


Pyramid:

Code: Select all

video::S3DVertex Vertices[4];

Vertices[0] = video::S3DVertex(0,0,10, 1,1,0, video::SColor(255,0,255,255), 0, 1);
	Vertices[1] = video::S3DVertex(10,0,-10, 1,0,0, video::SColor(255,255,0,255), 1, 1);
	Vertices[2] = video::S3DVertex(0,20,0, 0,1,1, video::SColor(255,255,255,0), 1, 0);
	Vertices[3] = video::S3DVertex(-10,0,-10, 0,0,1, video::SColor(255,0,255,0), 0, 0);
And here for a cube:

Code: Select all

video::S3DVertex Vertices[8];

Vertices[0] = video::S3DVertex(-5,-5,-5, 0,0,0, video::SColor(200,255,255,255), 0, 0);
	Vertices[1] = video::S3DVertex(5,-5,-5, 0,0,0, video::SColor(200,255,255,255), 0, 0);
	Vertices[2] = video::S3DVertex(5,-5,5, 0,0,0, video::SColor(200,255,255,255), 0, 0);
	Vertices[3] = video::S3DVertex(-5,-5,5, 0,0,0, video::SColor(200,255,255,255), 0, 0);
	Vertices[4] = video::S3DVertex(-5,5,5, 0,0,0, video::SColor(200,255,255,255), 0, 0);
	Vertices[5] = video::S3DVertex(-5,5,-5, 0,0,0, video::SColor(200,255,255,255), 0, 0);
	Vertices[6] = video::S3DVertex(5,5,-5, 0,0,0, video::SColor(200,255,255,255), 0, 0);
	Vertices[7] = video::S3DVertex(5,5,5, 0,0,0, video::SColor(200,255,255,255), 0, 0);

Maybe it helps
WindScar
Posts: 7
Joined: Wed Sep 01, 2010 10:38 pm

Post by WindScar »

But can that be converted to a IMesh object?
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Check out example 22, it creates meshes manually.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Remember that meshes (or more specifically, the mesh buffers in an IMesh) are made up of two things: vertices and indices. The indices are just as important since they tell the program how to connect the vertices you gave it into triangles.
WindScar
Posts: 7
Joined: Wed Sep 01, 2010 10:38 pm

Post by WindScar »

True. Can you tell me or link me to an explanation about indices?
zeph
Posts: 2
Joined: Thu Jul 08, 2010 12:12 pm

Post by zeph »

Post Reply