changing vertex buffer values after locking

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Nov 18, 2008 at 18:27

say i want to create a smash effect on my model , i am stuck on how i would change the vertex buffer ,x,y,z , i know how to get the current values , i just dont know how to apply new values so the mesh looks diferent

7 Replies

Please log in or register to post a reply.

A0c9c0649c5deacc0ae3b7f7721c94d2
0
starstutter 101 Nov 18, 2008 at 18:31

sorry, don’t have time currently to give a long response, but you can modify the information in the same fashion as you would with an array of pointers.

vertexStruct *ver;

mesh.lock(*ver);
for (every vertex)
{
ver.position = whatever you want it to be;
}
mesh.unlock();

EDIT: keep in mind this isn’t the only way though. If you’re using SM 3.0 you can create damage effects in the vertex shader. IMO it’s much more straight forward and faster.

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Nov 18, 2008 at 18:52

yes but how does that know to apply it after all you only retrieve the postions , and it dosent feel like if i changes those values its not going to set them

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Nov 18, 2008 at 19:28

No, locking the vertex buffer means you get a pointer to the actual, real data. It is not just a copy of it and if you change the data, it will change what is rendered.

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Nov 18, 2008 at 19:33

ahh right , i see why its not made any effectr on the teapot , but i think it will work on a .x ,
so if i load a terrain .x intersect with it , i would need to only get the 3*x,y,z the mouse is over, then if i press mouse 1 i would increment the data on y axis to make the terrain heigher

A0c9c0649c5deacc0ae3b7f7721c94d2
0
starstutter 101 Nov 18, 2008 at 19:37

You know, I just realized. If you’re using a mesh with a vertex format you don’t have access to, you’re probably not locking it with the correct vertex structure. The structure “ver” must be the same size and order as the meshes vertex format, if it’s not accurate, the lock will fail.

EDIT: well, it doesn’t necessarily have to fail, but the right information will not be accessed.

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Nov 18, 2008 at 19:46

ive the correct values , i just cant set new values to teapot

Abd4b56ff96074042dda5243e99a5d14
0
Anddos 103 Nov 18, 2008 at 20:02

D3DXIntersectTri
do i set the taken vertices points from locking and i put them in this function then? , i want to test which triangle in a mesh the ray intersects