# Set vertex position

Can anyone tell me how to set the positions of model vertices? I want to be able to change the position of some of the vertices of a Model. Is there any way to make that happen? And make the changed visible at that moment.

EDIT: Well, the thing is,I have a model, a cube, that is made up of four "thin" cubes(top,bottom,left side, right side), so I get this cube with "hole" in the middle. And I want to scale it on Y axis. If I do Scale(0,2,0) it will scale the whole object meaning, it will double the Y size of left and right side, but also double the size of the top and bottom cube, which I do not want. Same for X axis I want to double the size of top and bottom cubes but not the left and right one.

Hope you can help

You generally don't want to manipulate the vertices of the model objects to move them around in your world.

Instead, you set the world transformation matrix (that you pass to Draw) accordingly, for example setting it to a translation matrix that moves the model by the desired amount.

That said, if you really want to manipulate the vertices directly -- perhaps because you only need a subset to change, or infrequently, you can iterate the Parts collection of the Meshes collection of the model. Each mesh part has a vertex (and index) buffer object you can use to update the model.

Since you say you want to move some vertices...

Assuming you do simply want to move the vertices in object space, you would need to reupload them to the graphics card (however XNA handles this).

Or else apply a transformation to a particular set of vertices (eg. if you are moving an arm or a leg). That would require some method of identifying only those vertices which are intended to move, in your shader code... this can be done using vertex IDs, possibly.