getting vertices from a mesh and manipulate them

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
Krampe
Posts: 48
Joined: Tue Oct 14, 2003 8:37 pm

getting vertices from a mesh and manipulate them

Post by Krampe »

Hi @ll,

i know this question is really easy to solve, but im trying for hours now and just dont know what to do ;)

I want to get the vertices of a simple mesh and then manipulate specific ones of them. I guess i must use some kind of mesh buffer and then getVertices(). But i dont know how :(

Perhaps someome can show me a few lines of code or show me the way to do it?

Thx :)
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

Hi Krampe,
you can use:
...
buffer = Mesh->getMeshBuffer(0);
video::S3DVertex* v = (video::S3DVertex*)buffer->getVertices();
v[0].Pos=...(the whole pos as coordinates)
or single coordinates with
v[0].Pos.X=....
v[0].Pos.Y=...
v[0].Pos.Z=...
...
v[1].
v[2].
...
and Colors, Alphavalue and Normals, too
v[0].Color=...
v[0].Alpha=...
Krampe
Posts: 48
Joined: Tue Oct 14, 2003 8:37 pm

Post by Krampe »

Thx KnightOfLight :) It looks almost too easy...

But i got another problem: i wanted to load a prefab 3ds model and then get its vertices and modify them. But the getMeshBuffer is not a member of iAnimatedMesh (error C2039). How to solve that?

Here is my code (dont laugh pls):

Code: Select all

scene::IAnimatedMesh* meshtest = smgr->getMesh("test.3ds");
scene::IMeshBuffer* buffer = meshtest->getMeshBuffer(0); 
video::S3DVertex* v = (video::S3DVertex*)buffer->getVertices(); 
v[0].Pos.Y=300;

I know im lacking of theory... i tried to search for tutorials about mesh buffers, but was only able to find some theory about triange strips which didnt help me. I read the Api help for hours but dont understand how to use this buffer. Perhaps you can only use the meshbuffer if you create the mesh on your own inside of Irrlicht?

So how i can get the loaded mesh into the buffer if its possible at all?

Thx for reading :)
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

maybe so
scene::IMeshBuffer* buffer = meshtest->getMesh(0)->getMeshBuffer...

and noone laughs, some weeks ago i searched this things, too, and im a beginner, too
Krampe
Posts: 48
Joined: Tue Oct 14, 2003 8:37 pm

Post by Krampe »

Using your code produces this error:

error C2440: 'initializing' : cannot convert from 'class irr::scene::IMeshBuffer *(__thiscall irr::scene::IMesh::*)(int)' to 'class irr::scene::IMeshBuffer *'
There is no context in which this conversion is possible

I think its the same problem, the difference between IMesh and IMeshBuffer.
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

I'm not near a compilier, but you did add the () to the end of that right?

scene::IMeshBuffer* buffer = meshtest->getMesh(0)->getMeshBuffer();
Crud, how do I do this again?
Krampe
Posts: 48
Joined: Tue Oct 14, 2003 8:37 pm

Post by Krampe »

Eeeerm *whistle* oh man im so stupid :oops: Thx Saigumi and KnightOfLight for saving me a headache :D What can i do for you? Just tell me (no, no money, sorry :lol: ).

One question... the parameter of getMeshBuffer is just an index, a method
to differentiate between several buffers?

Edit: ok, TWO questions :)

When i move a vertex, its seperate from the rest of the geometry. Is there some possibility to weld or merge vertices or edges? For example, i want to move one vertex belonging to a grid and all edges belonging to it should move with it, too.
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

> ... What can i do for you? Just tell me (no, no money, sorry...
Thank you for the honorable offer Sire Krampe - ok then please arrange a date with a hot girl this weekend ;-)
Krampe
Posts: 48
Joined: Tue Oct 14, 2003 8:37 pm

Post by Krampe »

ok then please arrange a date with a hot girl this weekend ;-)
Uiuiui.... ahem, done. (Krampe gets his stuff and plans a vacation in Timbuktu) :lol:
Post Reply